knife-cosmic 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.rdoc +186 -0
  3. data/LICENSE +202 -0
  4. data/README.rdoc +427 -0
  5. data/lib/chef/knife/cosmic_aag_list.rb +58 -0
  6. data/lib/chef/knife/cosmic_account_list.rb +87 -0
  7. data/lib/chef/knife/cosmic_base.rb +108 -0
  8. data/lib/chef/knife/cosmic_baselist.rb +111 -0
  9. data/lib/chef/knife/cosmic_cluster_list.rb +60 -0
  10. data/lib/chef/knife/cosmic_config_list.rb +56 -0
  11. data/lib/chef/knife/cosmic_disk_list.rb +58 -0
  12. data/lib/chef/knife/cosmic_domain_list.rb +53 -0
  13. data/lib/chef/knife/cosmic_firewallrule_create.rb +138 -0
  14. data/lib/chef/knife/cosmic_firewallrule_list.rb +62 -0
  15. data/lib/chef/knife/cosmic_forwardrule_create.rb +145 -0
  16. data/lib/chef/knife/cosmic_host_list.rb +61 -0
  17. data/lib/chef/knife/cosmic_hosts.rb +58 -0
  18. data/lib/chef/knife/cosmic_iso_list.rb +89 -0
  19. data/lib/chef/knife/cosmic_keypair_create.rb +72 -0
  20. data/lib/chef/knife/cosmic_keypair_delete.rb +60 -0
  21. data/lib/chef/knife/cosmic_keypair_list.rb +44 -0
  22. data/lib/chef/knife/cosmic_network_list.rb +63 -0
  23. data/lib/chef/knife/cosmic_oscategory_list.rb +50 -0
  24. data/lib/chef/knife/cosmic_ostype_list.rb +52 -0
  25. data/lib/chef/knife/cosmic_pod_list.rb +60 -0
  26. data/lib/chef/knife/cosmic_project_list.rb +63 -0
  27. data/lib/chef/knife/cosmic_publicip_list.rb +55 -0
  28. data/lib/chef/knife/cosmic_router_list.rb +64 -0
  29. data/lib/chef/knife/cosmic_securitygroup_list.rb +59 -0
  30. data/lib/chef/knife/cosmic_server_add_nic.rb +109 -0
  31. data/lib/chef/knife/cosmic_server_create.rb +674 -0
  32. data/lib/chef/knife/cosmic_server_delete.rb +153 -0
  33. data/lib/chef/knife/cosmic_server_list.rb +167 -0
  34. data/lib/chef/knife/cosmic_server_passwordreset.rb +91 -0
  35. data/lib/chef/knife/cosmic_server_reboot.rb +99 -0
  36. data/lib/chef/knife/cosmic_server_remove_nic.rb +101 -0
  37. data/lib/chef/knife/cosmic_server_start.rb +104 -0
  38. data/lib/chef/knife/cosmic_server_stop.rb +118 -0
  39. data/lib/chef/knife/cosmic_server_update.rb +47 -0
  40. data/lib/chef/knife/cosmic_service_list.rb +74 -0
  41. data/lib/chef/knife/cosmic_stack_create.rb +298 -0
  42. data/lib/chef/knife/cosmic_stack_delete.rb +79 -0
  43. data/lib/chef/knife/cosmic_template_create.rb +129 -0
  44. data/lib/chef/knife/cosmic_template_extract.rb +104 -0
  45. data/lib/chef/knife/cosmic_template_list.rb +88 -0
  46. data/lib/chef/knife/cosmic_template_register.rb +187 -0
  47. data/lib/chef/knife/cosmic_user_list.rb +62 -0
  48. data/lib/chef/knife/cosmic_volume_attach.rb +70 -0
  49. data/lib/chef/knife/cosmic_volume_create.rb +108 -0
  50. data/lib/chef/knife/cosmic_volume_delete.rb +97 -0
  51. data/lib/chef/knife/cosmic_volume_detach.rb +61 -0
  52. data/lib/chef/knife/cosmic_volume_list.rb +77 -0
  53. data/lib/chef/knife/cosmic_zone_list.rb +53 -0
  54. data/lib/knife-cosmic/connection.rb +1046 -0
  55. metadata +127 -0
@@ -0,0 +1,79 @@
1
+ #
2
+ # Original knife-cloudstack author:: Ryan Holmes (<rholmes@edmunds.com>)
3
+ # Copyright:: Copyright (c) 2011 Edmunds, Inc.
4
+ # License:: Apache License, Version 2.0
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/cosmic_base'
20
+
21
+ module Knifecosmic
22
+ class CosmicStackDelete < Chef::Knife
23
+
24
+ include Chef::Knife::KnifecosmicBase
25
+
26
+ deps do
27
+ require 'chef/json_compat'
28
+ require 'chef/mash'
29
+ require 'knife-cosmic/connection'
30
+ require 'chef/knife'
31
+ Chef::Knife.load_deps
32
+ Knifecosmic::CosmicServerDelete.load_deps
33
+ end
34
+
35
+ banner "knife cosmic stack delete JSON_FILE (options)"
36
+
37
+ def run
38
+ if @name_args.first.nil?
39
+ ui.error "Please specify json file eg: knife cosmic stack delete JSON_FILE"
40
+ exit 1
41
+ end
42
+ file_path = File.expand_path(@name_args.first)
43
+ unless File.exist?(file_path) then
44
+ ui.error "Stack file '#{file_path}' not found. Please check the path."
45
+ exit 1
46
+ end
47
+
48
+ data = File.read file_path
49
+ stack = Chef::JSONCompat.from_json data
50
+ delete_stack stack
51
+
52
+ end
53
+
54
+ def delete_stack(stack)
55
+ current_stack = Mash.new(stack)
56
+ current_stack[:servers].each do |server|
57
+ if server[:name]
58
+
59
+ # delete server(s)
60
+ names = server[:name].split(/[\s,]+/)
61
+ names.each do |name|
62
+ delete_server(name)
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+ end
69
+
70
+ def delete_server(server_name)
71
+ cmd = Knifecosmic::CosmicServerDelete.new([server_name])
72
+ cmd.config[:yes] = true
73
+ cmd.config[:expunge] = true
74
+ cmd.run_with_pretty_exceptions
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,129 @@
1
+ #
2
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
3
+ # Original knife-cloudstack author:: Frank Breedijk (<fbreedijk@schubergphilis.com>)
4
+ # Copyright:: Copyright (c) 2013
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'chef/knife/cosmic_base'
21
+
22
+ module Knifecosmic
23
+ class CosmicTemplateCreate < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBase
26
+
27
+ deps do
28
+ require 'knife-cosmic/connection'
29
+ Chef::Knife.load_deps
30
+ end
31
+
32
+ banner "knife cosmic template create NAME (options)"
33
+
34
+ option :displaytext,
35
+ :long => "--displaytext DISPLAYTEXT",
36
+ :description => "The display text of the template",
37
+ :on => :head
38
+
39
+ option :name,
40
+ :long => "--name NAME",
41
+ :description => "Specify templatename (without format checking)"
42
+
43
+ option :ostypeid,
44
+ :long => "--ostypeid ID",
45
+ :description => "Specify OS type ID",
46
+ :on => :head
47
+
48
+ option :volumeid,
49
+ :long => "--volumeid ID",
50
+ :description => "Specify volume ID",
51
+ :on => :head
52
+
53
+ option :hypervisor,
54
+ :long => "--hypervisor=TYPE",
55
+ :description => "Specify hypervisor type",
56
+ :on => :head
57
+
58
+ option :optimisefor,
59
+ :long => "--optimisefor PROFILE",
60
+ :description => "Specify hardware optimisation (Generic vs Windows)",
61
+ :on => :head
62
+
63
+ option :ispublic,
64
+ :long => "--[no-]public",
65
+ :description => "Make the template public after creation",
66
+ :boolean => true,
67
+ :default => false
68
+
69
+ option :isfeatured,
70
+ :long => "--[no-]featured",
71
+ :description => "Make the template featured after creation",
72
+ :boolean => true,
73
+ :default => false
74
+
75
+ option :passwordenabled,
76
+ :long => "--[no-]passwordenabled",
77
+ :description => "Make the template password reset enabled after creation",
78
+ :boolean => true,
79
+ :default => true
80
+
81
+ option :extractable,
82
+ :long => "--[no-]extractable",
83
+ :description => "Make the template extractable after creation",
84
+ :boolean => "true",
85
+ :default => false
86
+
87
+ def run
88
+ validate_base_options
89
+
90
+ Chef::Log.debug("Validate hostname and options")
91
+ if locate_config_value(:name)
92
+ templatename = locate_config_value(:name)
93
+ else
94
+ templatename = @name_args.first
95
+ unless /^[a-zA-Z0-9][a-zA-Z0-9_\-#]*$/.match templatename then
96
+ ui.error "Invalid templatename. Please specify a simple name without any spaces"
97
+ exit 1
98
+ end
99
+ end
100
+
101
+ print "#{ui.color("Creating template: #{templatename}", :magenta)}\n"
102
+
103
+ params = {
104
+ 'command' => 'createTemplate',
105
+ 'name' => templatename,
106
+ 'displaytext' => locate_config_value(:displaytext),
107
+ 'ostypeid' => locate_config_value(:ostypeid),
108
+ 'volumeid' => locate_config_value(:volumeid),
109
+ 'hypervisor' => locate_config_value(:hypervisor)
110
+ }
111
+ params['ispublic'] = locate_config_value(:ispublic) if locate_config_value(:ispublic)
112
+ params['isfeatured'] = locate_config_value(:isfeatured) if locate_config_value(:isfeatured)
113
+ params['optimisefor'] = locate_config_value(:optimisefor) if locate_config_value(:optimisefor)
114
+ params['passwordenabled'] = locate_config_value(:passwordenabled) if locate_config_value(:passwordenabled)
115
+ params['isextractable'] = locate_config_value(:extractable) if locate_config_value(:extractable)
116
+ json = connection.send_request(params)
117
+
118
+ if ! json then
119
+ ui.error("Unable to create template")
120
+ exit 1
121
+ end
122
+
123
+ print "Template #{json['id']} is being created in the background\n";
124
+
125
+ return json['id']
126
+ end
127
+
128
+ end # class
129
+ end
@@ -0,0 +1,104 @@
1
+ #
2
+ # Original knife-cloudstack author:: Frank Breedijk (<fbreedijk@schubergphilis.com>)
3
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
4
+ # Copyright:: Copyright (c) 2013
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'chef/knife/cosmic_base'
21
+
22
+ module Knifecosmic
23
+ class CosmicTemplateExtract < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBase
26
+
27
+ deps do
28
+ require 'knife-cosmic/connection'
29
+ Chef::Knife.load_deps
30
+ end
31
+
32
+ banner "knife cosmic template extract NAME (options)"
33
+
34
+ option :name,
35
+ :long => "--name NAME",
36
+ :description => "Name of template to extract (without format checking)"
37
+
38
+ option :zone,
39
+ :long => "--zone NAME",
40
+ :description => "Name of the zone to extract the template in"
41
+
42
+ def run
43
+ validate_base_options
44
+
45
+ Chef::Log.debug("Validate template name")
46
+ if locate_config_value(:name)
47
+ templatename = locate_config_value(:name)
48
+ else
49
+ templatename = @name_args.first
50
+ unless /^[a-zA-Z0-9][a-zA-Z0-9_\-# ]*$/.match templatename then
51
+ ui.error "Invalid templatename."
52
+ exit 1
53
+ end
54
+ end
55
+
56
+ zonename = locate_config_value(:zone)
57
+ if ! zonename
58
+ then
59
+ ui.error "No zone specified"
60
+ exit 1
61
+ end
62
+
63
+ print "#{ui.color("Extracting template: #{templatename}", :magenta)}\n"
64
+
65
+ Chef::Log.debug("Getting zone")
66
+
67
+ zone = connection.get_zone(
68
+ zonename,
69
+ )
70
+ if ! zone then
71
+ ui.error "Zone #{zonename} not found"
72
+ exit 1
73
+ end
74
+
75
+ Chef::Log.debug("Getting template")
76
+
77
+ template = connection.get_template(
78
+ templatename,
79
+ )
80
+ if ! template then
81
+ ui.error "Template #{templatename} not found"
82
+ exit 1
83
+ end
84
+
85
+ Chef::Log.debug("Extracting template")
86
+ params = {
87
+ 'command' => 'extractTemplate',
88
+ 'id' => template["id"],
89
+ 'mode' => "HTTP_DOWNLOAD",
90
+ 'zoneid' => zone["id"]
91
+ }
92
+ json = connection.send_async_request(params)
93
+
94
+ if json then
95
+ url = json["template"]["url"]
96
+ print "\n#{url}\n"
97
+ else
98
+ ui.error "Template extraction failed.\n"
99
+ exit 1
100
+ end
101
+ end
102
+
103
+ end # class
104
+ end
@@ -0,0 +1,88 @@
1
+ #
2
+ # Original knife-cloudstack author:: Ryan Holmes (<rholmes@edmunds.com>)
3
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
4
+ # Copyright:: Copyright (c) 2011 Edmunds, Inc.
5
+ # Copyright:: Copyright (c) 2013 Sander Botman.
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ require 'chef/knife'
22
+ require 'chef/knife/cosmic_baselist'
23
+
24
+ module Knifecosmic
25
+ class CosmicTemplateList < Chef::Knife
26
+
27
+ include Chef::Knife::KnifecosmicBaseList
28
+
29
+ banner "knife cosmic template list (options)"
30
+
31
+ option :listall,
32
+ :long => "--listall",
33
+ :description => "List all templates",
34
+ :boolean => true
35
+
36
+ option :index,
37
+ :long => "--index",
38
+ :description => "Add index numbers to the output",
39
+ :boolean => true
40
+
41
+ option :templatefilter,
42
+ :long => "--templatefilter FILTER",
43
+ :description => "Default: 'featured'. Options: 'self','selfexecutable','sharedexecutable','executable','community'",
44
+ :default => "featured"
45
+
46
+ def run
47
+ validate_base_options
48
+
49
+ columns = [
50
+ 'Name :name',
51
+ 'Size :size',
52
+ 'Zone :zonename',
53
+ 'Public :ispublic',
54
+ 'Created :created'
55
+ ]
56
+
57
+ params = { 'command' => "listTemplates" }
58
+ params['filter'] = locate_config_value(:filter) if locate_config_value(:filter)
59
+ params['listall'] = locate_config_value(:listall) if locate_config_value(:listall)
60
+ params['keyword'] = locate_config_value(:keyword) if locate_config_value(:keyword)
61
+ params['name'] = locate_config_value(:name) if locate_config_value(:name)
62
+
63
+ if ['all','featured','self','selfexecutable','sharedexecutable','executable','community'].include?(locate_config_value(:templatefilter))
64
+ params['templatefilter'] = locate_config_value(:templatefilter)
65
+ else
66
+ params['templatefilter'] = 'featured'
67
+ end
68
+
69
+ result = connection.list_object(params, "template")
70
+
71
+ result.each do |r|
72
+ r['size'] = human_file_size(r['size']) if r['size']
73
+ end
74
+
75
+ list_object(columns, result)
76
+ end
77
+
78
+ def human_file_size n
79
+ count = 0
80
+ while n >= 1024 and count < 4
81
+ n /= 1024.0
82
+ count += 1
83
+ end
84
+ format("%.0f", n) + %w(B KB MB GB TB)[count]
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,187 @@
1
+ #
2
+ # Original knife-cloudstack author:: Frank Breedijk (<fbreedijk@schubergphilis.com>)
3
+ # Original knife-cloudstack author:: Sander Botman (<sbotman@schubergphilis.com>)
4
+ # Copyright:: Copyright (c) 2013
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'chef/knife/cosmic_base'
21
+
22
+ module Knifecosmic
23
+ class CosmicTemplateRegister < Chef::Knife
24
+
25
+ include Chef::Knife::KnifecosmicBase
26
+
27
+ deps do
28
+ require 'knife-cosmic/connection'
29
+ Chef::Knife.load_deps
30
+ end
31
+
32
+ banner "knife cosmic template register NAME (options)"
33
+
34
+ option :name,
35
+ :long => "--name NAME",
36
+ :description => "Name of template to register (without format checking)"
37
+
38
+ option :displaytext,
39
+ :long => "--displaytext DESCRIPTION",
40
+ :description => "Description of the template as shown in cosmic"
41
+
42
+ option :format,
43
+ :long => "--format FORMAT",
44
+ :description => "Format of the template file QCOW2, RAW or VHD (default)",
45
+ :default => "VHD"
46
+
47
+ option :hypervisor,
48
+ :long => "--hypervisor NAME",
49
+ :description => "Target hypervisor for the template (default XEN)",
50
+ :default => "XenServer"
51
+
52
+ option :ostypeid,
53
+ :long => '--ostypeid OSTYPEID',
54
+ :description => "The ID of the OS Type that best represents the OS of this template"
55
+
56
+ option :url,
57
+ :long => '--url URL',
58
+ :description => "The URL of where the template is hosted. Including http:// and https://"
59
+
60
+ option :zone,
61
+ :long => "--zone NAME",
62
+ :description => "Name of the zone to register the template in. Default: All zones",
63
+ :default => -1
64
+
65
+ option :bits,
66
+ :long => "--bits 32|64",
67
+ :description => "32 or 64 bits support, defaults to 64",
68
+ :default => 64
69
+
70
+ option :isextractable,
71
+ :long => "--[no-]isextractable",
72
+ :description => "Is the template extractable. Default: NO",
73
+ :boolean => true,
74
+ :default => false
75
+
76
+ option :isdynamicallyscalable,
77
+ :long => "--isdynamicallyscalable",
78
+ :description => "Is the template dynamically scalable. Default: NO",
79
+ :boolean => true,
80
+ :default => false
81
+
82
+ option :featured,
83
+ :long => "--[no-]featured",
84
+ :description => "Is the tempalte featured? Default: NO",
85
+ :boolean => true,
86
+ :default => false
87
+
88
+ option :public,
89
+ :long => "--[no-]public",
90
+ :description => "Is the template public? Default: NO",
91
+ :boolean => true,
92
+ :default => false
93
+
94
+ option :passwordenabled,
95
+ :long => "--[no-]passwordenabled",
96
+ :description => "Is the password reset feature enabled, Default: YES",
97
+ :boolean => true,
98
+ :default => true
99
+
100
+ option :requireshvm,
101
+ :long => "--[no-]requireshvm",
102
+ :description => "Does the template require HVM? Default: NO",
103
+ :boolean => true,
104
+ :default => false
105
+
106
+ option :sshkeyenabled,
107
+ :long => "--[no-]sshkeyenabled",
108
+ :description => "Does this tempalte support the sshkey upload feature? Default: NO",
109
+ :boolean => true,
110
+ :default => false
111
+
112
+ def run
113
+ validate_base_options
114
+
115
+ Chef::Log.debug("Validate template name")
116
+ if locate_config_value(:name)
117
+ templatename = locate_config_value(:name)
118
+ else
119
+ templatename = @name_args.first
120
+ unless /^[a-zA-Z0-9][a-zA-Z0-9_\-# ]*$/.match templatename then
121
+ ui.error "Invalid templatename."
122
+ exit 1
123
+ end
124
+ end
125
+
126
+ unless locate_config_value(:ostypeid) then
127
+ ui.error "No os type id specified"
128
+ exit 1
129
+ end
130
+
131
+ unless /^http(s)?\:\/\//.match locate_config_value(:url) then
132
+ ui.error "URL (#{locate_config_value(:url)}) is not a well formatted url"
133
+ exit 1
134
+ end
135
+
136
+ unless (locate_config_value(:bits) == 64 or locate_config_value(:bits) == 32 ) then
137
+ ui.error "Bits must be 32 or 64"
138
+ exit 1
139
+ end
140
+
141
+ if (locate_config_value(:zone) == -1)
142
+ zoneid = -1
143
+ else
144
+ Chef::Log.debug("Resolving zone #{locate_config_value(:zone)}\n")
145
+
146
+ zone = connection.get_zone(locate_config_value(:zone))
147
+
148
+ if ! zone then
149
+ ui.error "Unable to resolve zone #{locate_config_value(:zone)}\n"
150
+ exit 1
151
+ end
152
+ zoneid = zone['id']
153
+ end
154
+
155
+ print "#{ui.color("Registring template: #{templatename}", :magenta)}\n"
156
+
157
+ params = {
158
+ 'command' => 'registerTemplate',
159
+ 'name' => templatename,
160
+ 'displaytext' => locate_config_value(:displaytext),
161
+ 'format' => locate_config_value(:format),
162
+ 'hypervisor' => locate_config_value(:hypervisor),
163
+ 'ostypeid' => locate_config_value(:ostypeid),
164
+ 'url' => locate_config_value(:url),
165
+ 'zoneid' => zoneid,
166
+ 'bits' => locate_config_value(:bits),
167
+ }
168
+ params['isdynamicallyscalable'] = locate_config_value(:isdynamicallyscalable) if locate_config_value(:isdynamicallyscalable)
169
+ params['isextractable'] = locate_config_value(:isextractable) if locate_config_value(:isextractable)
170
+ params['ispublic'] = locate_config_value(:public) if locate_config_value(:public)
171
+ params['isfeatured'] = locate_config_value(:featured) if locate_config_value(:featured)
172
+ params['passwordenabled'] = locate_config_value(:passwordenabled) if locate_config_value(:passwordenabled)
173
+ params['sshkeyenabled'] = locate_config_value(:sshkeyenabled) if locate_config_value(:sshkeyenabled)
174
+ params['requireshvm'] = locate_config_value(:requireshvm) if locate_config_value(:requireshvm)
175
+
176
+ json = connection.send_request(params)
177
+
178
+ if ! json then
179
+ ui.error "Template #{templatename} not registered\n"
180
+ exit 1
181
+ end
182
+
183
+ print "TemplateId #{json['template'][0]['id']} is being created\n"
184
+ end
185
+
186
+ end # class
187
+ end