knife-cloudstack-fog 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,69 +1,69 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackServerStart < Knife
24
-
25
- include Knife::CloudstackBase
26
- banner "knife cloudstack server start INSTANCE_ID"
27
-
28
- def run
29
-
30
- if @name_args.nil?
31
- puts #{ui.color("Please provide an Instance ID.", :red)}
32
- end
33
-
34
- @name_args.each do |instance_id|
35
- response = connection.list_virtual_machines('name' => instance_id)
36
- instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name']
37
- instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress']
38
- real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id']
39
- puts "#{ui.color("Name", :green)}: #{instance_name}"
40
- puts "#{ui.color("Public IP", :green)}: #{instance_ip}"
41
- puts "\n"
42
- confirm("#{ui.color("Do you really want to start this server", :green)}")
43
-
44
-
45
- if :force
46
- server = connection.start_virtual_machine('id' => real_instance_id, 'forced' => true)
47
- else
48
- server = connection.start_virtual_machine('id' => real_instance_id)
49
- end
50
- jobid = server['startvirtualmachineresponse'].fetch('jobid')
51
- server_start = connection.query_async_job_result('jobid'=>jobid)
52
- print "#{ui.color("Waiting for server", :magenta)}"
53
- while server_start['queryasyncjobresultresponse'].fetch('jobstatus') != 1
54
- print "#{ui.color(".", :magenta)}"
55
- sleep(1)
56
- server_start = connection.query_async_job_result('jobid'=>jobid)
57
- end
58
- puts "\n\n"
59
-
60
- ui.warn("Started server #{instance_name}")
61
- end
62
- end
63
-
64
-
65
-
66
-
67
- end
68
- end
69
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackServerStart < Knife
24
+
25
+ include Knife::CloudstackBase
26
+ banner "knife cloudstack server start INSTANCE_ID"
27
+
28
+ def run
29
+
30
+ if @name_args.nil? || @name_args.empty?
31
+ puts "#{ui.color("Please provide an Instance ID.", :red)}"
32
+ end
33
+
34
+ @name_args.each do |instance_id|
35
+ response = connection.list_virtual_machines('name' => instance_id)
36
+ instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name']
37
+ instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress']
38
+ real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id']
39
+ puts "#{ui.color("Name", :green)}: #{instance_name}"
40
+ puts "#{ui.color("Public IP", :green)}: #{instance_ip}"
41
+ puts "\n"
42
+ confirm("#{ui.color("Do you really want to start this server", :green)}")
43
+
44
+
45
+ if locate_config_value(:force)
46
+ server = connection.start_virtual_machine('id' => real_instance_id, 'forced' => true)
47
+ else
48
+ server = connection.start_virtual_machine('id' => real_instance_id)
49
+ end
50
+ jobid = server['startvirtualmachineresponse'].fetch('jobid')
51
+ server_start = connection.query_async_job_result('jobid'=>jobid)
52
+ print "#{ui.color("Waiting for server", :magenta)}"
53
+ while server_start['queryasyncjobresultresponse'].fetch('jobstatus') != 1
54
+ print "#{ui.color(".", :magenta)}"
55
+ sleep(1)
56
+ server_start = connection.query_async_job_result('jobid'=>jobid)
57
+ end
58
+ puts "\n\n"
59
+
60
+ ui.warn("Started server #{instance_name}")
61
+ end
62
+ end
63
+
64
+
65
+
66
+
67
+ end
68
+ end
69
+ end
@@ -1,72 +1,72 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackServerStop < Knife
24
-
25
- include Knife::CloudstackBase
26
- banner "knife cloudstack server stop INSTANCE_ID (options)"
27
- option :forced,
28
- :short => "-f",
29
- :description => "Issue this as a forced stop command."
30
-
31
- def run
32
-
33
- if @name_args.nil?
34
- puts #{ui.color("Please provide an Instance ID.", :red)}
35
- end
36
-
37
- @name_args.each do |instance_id|
38
- response = connection.list_virtual_machines('name' => instance_id)
39
- instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name']
40
- instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress']
41
- real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id']
42
- puts "#{ui.color("Name", :red)}: #{instance_name}"
43
- puts "#{ui.color("Public IP", :red)}: #{instance_ip}"
44
- puts "\n"
45
- confirm("#{ui.color("Do you really want to stop this server", :red)}")
46
-
47
-
48
- if :force
49
- server = connection.stop_virtual_machine('id' => real_instance_id, 'forced' => true)
50
- else
51
- server = connection.stop_virtual_machine('id' => real_instance_id)
52
- end
53
- jobid = server['stopvirtualmachineresponse'].fetch('jobid')
54
- server_stop = connection.query_async_job_result('jobid'=>jobid)
55
- print "#{ui.color("Waiting for server", :magenta)}"
56
- while server_stop['queryasyncjobresultresponse'].fetch('jobstatus') != 1
57
- print "#{ui.color(".", :magenta)}"
58
- sleep(1)
59
- server_start = connection.query_async_job_result('jobid'=>jobid)
60
- end
61
- puts "\n\n"
62
-
63
- ui.warn("Stopped server #{instance_name}")
64
- end
65
- end
66
-
67
-
68
-
69
-
70
- end
71
- end
72
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackServerStop < Knife
24
+
25
+ include Knife::CloudstackBase
26
+ banner "knife cloudstack server stop INSTANCE_ID (options)"
27
+ option :forced,
28
+ :short => "-f",
29
+ :description => "Issue this as a forced stop command."
30
+
31
+ def run
32
+
33
+ if @name_args.nil? || @name_args.empty?
34
+ puts "#{ui.color("Please provide an Instance ID.", :red)}"
35
+ end
36
+
37
+ @name_args.each do |instance_id|
38
+ response = connection.list_virtual_machines('name' => instance_id)
39
+ instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name']
40
+ instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress']
41
+ real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id']
42
+ puts "#{ui.color("Name", :red)}: #{instance_name}"
43
+ puts "#{ui.color("Public IP", :red)}: #{instance_ip}"
44
+ puts "\n"
45
+ confirm("#{ui.color("Do you really want to stop this server", :red)}")
46
+
47
+
48
+ if locate_config_value(:force)
49
+ server = connection.stop_virtual_machine('id' => real_instance_id, 'forced' => true)
50
+ else
51
+ server = connection.stop_virtual_machine('id' => real_instance_id)
52
+ end
53
+ jobid = server['stopvirtualmachineresponse'].fetch('jobid')
54
+ server_stop = connection.query_async_job_result('jobid'=>jobid)
55
+ print "#{ui.color("Waiting for server", :magenta)}"
56
+ while server_stop['queryasyncjobresultresponse'].fetch('jobstatus') != 1
57
+ print "#{ui.color(".", :magenta)}"
58
+ sleep(1)
59
+ server_stop = connection.query_async_job_result('jobid'=>jobid)
60
+ end
61
+ puts "\n\n"
62
+
63
+ ui.warn("Stopped server #{instance_name}")
64
+ end
65
+ end
66
+
67
+
68
+
69
+
70
+ end
71
+ end
72
+ end
@@ -1,61 +1,61 @@
1
- # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
- # Copyright:: Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackServiceofferingList < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack serviceoffering list"
28
-
29
- def run
30
- $stdout.sync = true
31
-
32
- validate!
33
-
34
- serviceoffering_list = [
35
- ui.color('ID', :bold),
36
- ui.color('Name', :bold),
37
- ui.color('Description', :bold),
38
- ui.color('Number of CPUs', :bold),
39
- ui.color('CPU Speed', :bold),
40
- ui.color('Memory (in MB)', :bold),
41
- ui.color('Network Speed', :bold)
42
- ]
43
- response = connection.list_service_offerings['listserviceofferingsresponse']
44
- if serviceofferings = response['serviceoffering']
45
- serviceofferings.each do |serviceoffering|
46
- serviceoffering_list << serviceoffering['id'].to_s
47
- serviceoffering_list << serviceoffering['name'].to_s
48
- serviceoffering_list << serviceoffering['displaytext'].to_s
49
- serviceoffering_list << serviceoffering['cpunumber'].to_s
50
- serviceoffering_list << serviceoffering['cpuspeed'].to_s
51
- serviceoffering_list << serviceoffering['memory'].to_s
52
- serviceoffering_list << serviceoffering['networkrate'].to_s
53
- end
54
- end
55
- puts ui.list(serviceoffering_list, :uneven_columns_across, 7)
56
-
57
- end
58
-
59
- end
60
- end
61
- end
1
+ # Author:: Jeff Moody (<jmoody@datapipe.com>)
2
+ # Copyright:: Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackServiceofferingList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack serviceoffering list"
28
+
29
+ def run
30
+ $stdout.sync = true
31
+
32
+ validate!
33
+
34
+ serviceoffering_list = [
35
+ ui.color('ID', :bold),
36
+ ui.color('Name', :bold),
37
+ ui.color('Description', :bold),
38
+ ui.color('Number of CPUs', :bold),
39
+ ui.color('CPU Speed', :bold),
40
+ ui.color('Memory (in MB)', :bold),
41
+ ui.color('Network Speed', :bold)
42
+ ]
43
+ response = connection.list_service_offerings['listserviceofferingsresponse']
44
+ if serviceofferings = response['serviceoffering']
45
+ serviceofferings.each do |serviceoffering|
46
+ serviceoffering_list << serviceoffering['id'].to_s
47
+ serviceoffering_list << serviceoffering['name'].to_s
48
+ serviceoffering_list << serviceoffering['displaytext'].to_s
49
+ serviceoffering_list << serviceoffering['cpunumber'].to_s
50
+ serviceoffering_list << serviceoffering['cpuspeed'].to_s
51
+ serviceoffering_list << serviceoffering['memory'].to_s
52
+ serviceoffering_list << serviceoffering['networkrate'].to_s
53
+ end
54
+ end
55
+ puts ui.list(serviceoffering_list, :uneven_columns_across, 7)
56
+
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -1,127 +1,127 @@
1
- # Author:: Chirag Jog (<chirag@clogeny.com>), Jeff Moody (<jmoody@datapipe.com>), dfuentes77
2
- # Copyright:: Copyright (c) 2011 Clogeny Technologies, Copyright (c) 2012 Datapipe
3
- # License:: Apache License, Version 2.0
4
- #
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'chef/knife/cloudstack_base'
20
-
21
- class Chef
22
- class Knife
23
- class CloudstackTemplateList < Knife
24
-
25
- include Knife::CloudstackBase
26
-
27
- banner "knife cloudstack template list (options)"
28
- option :filter,
29
- :short => "-L FILTER",
30
- :long => "--filter FILTER",
31
- :description => "The template search filter. Default is 'featured.' Other options are 'self,' 'self-executable,' 'executable,' and 'community.'",
32
- :default => "featured"
33
- option :zone,
34
- :short => "-Z ZONE",
35
- :long => "--zone ZONE",
36
- :description => "Limit responses to templates only located in a specific zone. Default provides templates from all zones.",
37
- :default => "all"
38
- option :hypervisor,
39
- :short => "-H HYPERVISOR",
40
- :long => "--hypervisor HYPERVISOR",
41
- :description => "Limit responses to templates only running on a specific hypervisor. Default provides templates from all hypervisors.",
42
- :default => "all"
43
- option :zoneid,
44
- :short => "-z ZONEID",
45
- :long => "--zoneid ZONEID",
46
- :description => "Limit responses to templates only running in a specific zone (specified by ID #). Default provides templates from all zones.",
47
- :default => "all"
48
- option :templateid,
49
- :short => "-T TEMPLATEID",
50
- :long => "--templateid TEMPLATEID",
51
- :description => "Limit responses to a single template ID. Default provides all templates.",
52
- :default => "all"
53
-
54
-
55
- def print_templates(template_list,templates,options={})
56
- temp = templates
57
-
58
- if templateid = options[:templateid]
59
- temp.reject!{|t| t['id'] != templateid}
60
- end
61
- if zoneid = options[:zoneid]
62
- temp.reject!{|t| t['zoneid'] != zoneid}
63
- end
64
- if zone = options[:zone]
65
- temp.reject!{|t| t['zonename'] != zone}
66
- end
67
- if hypervisor = options[:hypervisor]
68
- temp.reject!{|t| t['hypervisor'] != hypervisor}
69
- end
70
-
71
- # Sorting to group by zone ID first, then ID
72
-
73
- sort1 = temp.sort_by { |hsh| hsh["id"] }
74
- sorted = sort1.sort_by { |hsh| hsh["zoneid"] }
75
-
76
- sorted.each do |template|
77
- template_list << template['id'].to_s
78
- template['hypervisor'] = ' ' if template['hypervisor'].nil?
79
- template_list << template['hypervisor']
80
-
81
- template_size = template['size']
82
- template_size = (template_size/1024/1024/1024)
83
- template_list << template_size.to_s
84
-
85
- template_list << template['zonename']
86
- template_list << template['zoneid'].to_s
87
- template_list << template['name']
88
- end
89
- end
90
-
91
- def run
92
- validate!
93
-
94
- template_list = [
95
- ui.color('ID', :bold),
96
- ui.color('Hypervisor', :bold),
97
- ui.color('Size (in GB)', :bold),
98
- ui.color('Zone Name', :bold),
99
- ui.color('Zone ID', :bold),
100
- ui.color('Name', :bold)
101
- ]
102
-
103
- filter = locate_config_value(:filter)
104
- zone = locate_config_value(:zone)
105
- zoneid = locate_config_value(:zoneid)
106
- hypervisor = locate_config_value(:hypervisor)
107
- templateid = locate_config_value(:templateid)
108
-
109
- settings = connection.list_templates('templatefilter' => filter)
110
- if response = settings['listtemplatesresponse']
111
- Chef::Log.debug("Response: #{response}")
112
- if templates = response['template']
113
- filters = {}
114
- filters[:hypervisor] = hypervisor unless hypervisor == 'all'
115
- filters[:zone] = zone unless zone == 'all'
116
- filters[:zoneid] = zoneid unless zoneid == 'all'
117
- filters[:templateid] = templateid unless templateid == 'all'
118
-
119
- print_templates(template_list,templates,filters)
120
- end
121
- puts ui.list(template_list, :uneven_columns_across, 6)
122
- end
123
-
124
- end
125
- end
126
- end
127
- end
1
+ # Author:: Chirag Jog (<chirag@clogeny.com>), Jeff Moody (<jmoody@datapipe.com>), dfuentes77
2
+ # Copyright:: Copyright (c) 2011 Clogeny Technologies, Copyright (c) 2012 Datapipe
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife/cloudstack_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class CloudstackTemplateList < Knife
24
+
25
+ include Knife::CloudstackBase
26
+
27
+ banner "knife cloudstack template list (options)"
28
+ option :filter,
29
+ :short => "-L FILTER",
30
+ :long => "--filter FILTER",
31
+ :description => "The template search filter. Default is 'featured.' Other options are 'self,' 'self-executable,' 'executable,' and 'community.'",
32
+ :default => "featured"
33
+ option :zone,
34
+ :short => "-Z ZONE",
35
+ :long => "--zone ZONE",
36
+ :description => "Limit responses to templates only located in a specific zone. Default provides templates from all zones.",
37
+ :default => "all"
38
+ option :hypervisor,
39
+ :short => "-H HYPERVISOR",
40
+ :long => "--hypervisor HYPERVISOR",
41
+ :description => "Limit responses to templates only running on a specific hypervisor. Default provides templates from all hypervisors.",
42
+ :default => "all"
43
+ option :zoneid,
44
+ :short => "-z ZONEID",
45
+ :long => "--zoneid ZONEID",
46
+ :description => "Limit responses to templates only running in a specific zone (specified by ID #). Default provides templates from all zones.",
47
+ :default => "all"
48
+ option :templateid,
49
+ :short => "-T TEMPLATEID",
50
+ :long => "--templateid TEMPLATEID",
51
+ :description => "Limit responses to a single template ID. Default provides all templates.",
52
+ :default => "all"
53
+
54
+
55
+ def print_templates(template_list,templates,options={})
56
+ temp = templates
57
+
58
+ if templateid = options[:templateid]
59
+ temp.reject!{|t| t['id'] != templateid}
60
+ end
61
+ if zoneid = options[:zoneid]
62
+ temp.reject!{|t| t['zoneid'] != zoneid}
63
+ end
64
+ if zone = options[:zone]
65
+ temp.reject!{|t| t['zonename'] != zone}
66
+ end
67
+ if hypervisor = options[:hypervisor]
68
+ temp.reject!{|t| t['hypervisor'] != hypervisor}
69
+ end
70
+
71
+ # Sorting to group by zone ID first, then ID
72
+
73
+ sort1 = temp.sort_by { |hsh| hsh["id"] }
74
+ sorted = sort1.sort_by { |hsh| hsh["zoneid"] }
75
+
76
+ sorted.each do |template|
77
+ template_list << template['id'].to_s
78
+ template['hypervisor'] = ' ' if template['hypervisor'].nil?
79
+ template_list << template['hypervisor']
80
+
81
+ template_size = template['size']
82
+ template_size = (template_size/1024/1024/1024)
83
+ template_list << template_size.to_s
84
+
85
+ template_list << template['zonename']
86
+ template_list << template['zoneid'].to_s
87
+ template_list << template['name']
88
+ end
89
+ end
90
+
91
+ def run
92
+ validate!
93
+
94
+ template_list = [
95
+ ui.color('ID', :bold),
96
+ ui.color('Hypervisor', :bold),
97
+ ui.color('Size (in GB)', :bold),
98
+ ui.color('Zone Name', :bold),
99
+ ui.color('Zone ID', :bold),
100
+ ui.color('Name', :bold)
101
+ ]
102
+
103
+ filter = locate_config_value(:filter)
104
+ zone = locate_config_value(:zone)
105
+ zoneid = locate_config_value(:zoneid)
106
+ hypervisor = locate_config_value(:hypervisor)
107
+ templateid = locate_config_value(:templateid)
108
+
109
+ settings = connection.list_templates('templatefilter' => filter)
110
+ if response = settings['listtemplatesresponse']
111
+ Chef::Log.debug("Response: #{response}")
112
+ if templates = response['template']
113
+ filters = {}
114
+ filters[:hypervisor] = hypervisor unless hypervisor == 'all'
115
+ filters[:zone] = zone unless zone == 'all'
116
+ filters[:zoneid] = zoneid unless zoneid == 'all'
117
+ filters[:templateid] = templateid unless templateid == 'all'
118
+
119
+ print_templates(template_list,templates,filters)
120
+ end
121
+ puts ui.list(template_list, :uneven_columns_across, 6)
122
+ end
123
+
124
+ end
125
+ end
126
+ end
127
+ end