knife-xapi 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/chef/knife/xapi_base.rb +3 -6
- data/lib/chef/knife/xapi_guest_create.rb +25 -27
- data/lib/knife-xapi/version.rb +1 -1
- metadata +2 -2
data/lib/chef/knife/xapi_base.rb
CHANGED
@@ -45,20 +45,17 @@ class Chef::Knife
|
|
45
45
|
option :xapi_host,
|
46
46
|
:short => "-h SERVER_URL",
|
47
47
|
:long => "--host SERVER_URL",
|
48
|
-
:description => "The url to the xenserver, http://somehost.local.lan/"
|
49
|
-
:proc => Proc.new { |host| Chef::Config[:knife][:xapi_host] = host }
|
48
|
+
:description => "The url to the xenserver, http://somehost.local.lan/"
|
50
49
|
|
51
50
|
option :xapi_password,
|
52
51
|
:short => "-K PASSWORD",
|
53
52
|
:long => "--xapi-password PASSWORD",
|
54
|
-
:description => "Your xenserver password"
|
55
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:xapi_password] = key }
|
53
|
+
:description => "Your xenserver password"
|
56
54
|
|
57
55
|
option :xapi_username,
|
58
56
|
:short => "-A USERNAME",
|
59
57
|
:long => "--xapi-username USERNAME",
|
60
|
-
:description => "Your xenserver username"
|
61
|
-
:proc => Proc.new { |username| Chef::Config[:knife][:xapi_username] = username }
|
58
|
+
:description => "Your xenserver username"
|
62
59
|
end
|
63
60
|
|
64
61
|
end
|
@@ -37,55 +37,47 @@ class Chef
|
|
37
37
|
option :vm_template,
|
38
38
|
:short => "-T Template Name Label",
|
39
39
|
:long => "--xapi-vm-template",
|
40
|
-
:description => "xapi template name to create from. accepts an string or regex"
|
41
|
-
:proc => Proc.new { |template| Chef::Config[:knife][:vm_template] = template }
|
40
|
+
:description => "xapi template name to create from. accepts an string or regex"
|
42
41
|
|
43
42
|
option :domain,
|
44
43
|
:short => "-f Name",
|
45
44
|
:long => "--domain Name",
|
46
45
|
:description => "the domain name for the guest",
|
47
|
-
:proc => Proc.new { |domain| Chef::Config[:knife][:domain] = domain },
|
48
46
|
:default => ""
|
49
47
|
|
50
48
|
option :install_repo,
|
51
49
|
:short => "-R If you're using a builtin template you will need to specify a repo url",
|
52
50
|
:long => "--xapi-install-repo",
|
53
51
|
:description => "Install repo for this template (if needed)",
|
54
|
-
:proc => Proc.new { |repo| Chef::Config[:knife][:install_repo] = repo },
|
55
52
|
:default => "http://isoredirect.centos.org/centos/6/os/x86_64/"
|
56
53
|
|
57
54
|
option :xapi_sr,
|
58
55
|
:short => "-S Storage repo to provision VM from",
|
59
56
|
:long => "--xapi-sr",
|
60
|
-
:description => "The Xen SR to use, If blank will use pool/hypervisor default"
|
61
|
-
:proc => Proc.new { |sr| Chef::Config[:knife][:xapi_sr] = sr }
|
57
|
+
:description => "The Xen SR to use, If blank will use pool/hypervisor default"
|
62
58
|
|
63
59
|
option :kernel_params,
|
64
60
|
:short => "-B Set of kernel boot params to pass to the vm",
|
65
61
|
:long => "--xapi-kernel-params",
|
66
62
|
:description => "You can add more boot options to the vm e.g.: \"ks='http://foo.local/ks'\"",
|
67
|
-
:proc => Proc.new {|kernel| Chef::Config[:knife][:kernel_params] = kernel },
|
68
63
|
:default => "graphical utf8"
|
69
64
|
|
70
65
|
option :xapi_disk_size,
|
71
66
|
:short => "-D Size of disk. 1g 512m etc",
|
72
67
|
:long => "--xapi-disk-size",
|
73
68
|
:description => "The size of the root disk, use 'm' 'g' 't' if no unit specified assumes g",
|
74
|
-
:proc => Proc.new {|disk| Chef::Config[:knife][:xapi_disk_size] = disk },
|
75
69
|
:default => "8g"
|
76
70
|
|
77
71
|
option :xapi_cpus,
|
78
72
|
:short => "-C Number of VCPUs to provision",
|
79
73
|
:long => "--xapi-cpus",
|
80
74
|
:description => "Number of VCPUS this vm should have 1 4 8 etc",
|
81
|
-
:default => 2
|
82
|
-
:proc => Proc.new {|cpu| Chef::Config[:knife][:xapi_cpus] = cpu }
|
75
|
+
:default => 2
|
83
76
|
|
84
77
|
option :xapi_mem,
|
85
78
|
:short => "-M Ammount of memory to provision",
|
86
79
|
:long => "--xapi-mem",
|
87
80
|
:description => "Ammount of memory the VM should have specify with m g etc 512m, 2g if no unit spcified it assumes gigabytes",
|
88
|
-
:proc => Proc.new {|mem| Chef::Config[:knife][:xapi_mem] = mem },
|
89
81
|
:default => "1g"
|
90
82
|
|
91
83
|
option :chef_node_name,
|
@@ -96,9 +88,7 @@ class Chef
|
|
96
88
|
option :ssh_key_name,
|
97
89
|
:short => "-S KEY",
|
98
90
|
:long => "--ssh-key KEY",
|
99
|
-
:description => "The SSH key id"
|
100
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_key_name] = key }
|
101
|
-
|
91
|
+
:description => "The SSH key id"
|
102
92
|
|
103
93
|
option :ssh_user,
|
104
94
|
:short => "-x USERNAME",
|
@@ -115,28 +105,31 @@ class Chef
|
|
115
105
|
:short => "-p PORT",
|
116
106
|
:long => "--ssh-port PORT",
|
117
107
|
:description => "The ssh port",
|
118
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key },
|
119
108
|
:default => "22"
|
120
109
|
|
121
110
|
option :bootstrap_version,
|
122
111
|
:long => "--bootstrap-version VERSION",
|
123
|
-
:description => "The version of Chef to install"
|
124
|
-
:proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
|
112
|
+
:description => "The version of Chef to install"
|
125
113
|
|
126
114
|
option :bootstrap_template,
|
127
115
|
:short => "-d Template Name",
|
128
116
|
:long => "--bootstrap-template Template Name",
|
129
117
|
:description => "Bootstrap using a specific template",
|
130
|
-
:proc => Proc.new { |d| Chef::Config[:knife][:bootstrap_template] = d },
|
131
118
|
:default => "ubuntu10.04-gems"
|
132
119
|
|
133
120
|
option :template_file,
|
134
121
|
:short => "-F FILEPATH",
|
135
122
|
:long => "--template-file TEMPLATE",
|
136
123
|
:description => "Full path to location of template to use",
|
137
|
-
:proc => Proc.new { |t| Chef::Config[:knife][:template_file] = t },
|
138
124
|
:default => false
|
139
|
-
|
125
|
+
|
126
|
+
option :json_attributes,
|
127
|
+
:short => "-j JSON_ATTRIBS",
|
128
|
+
:long => "--json-attributes",
|
129
|
+
:description => "A JSON string to be added to the first run of chef-client",
|
130
|
+
:proc => lambda { |o| JSON.parse(o) },
|
131
|
+
:default => {}
|
132
|
+
|
140
133
|
option :run_list,
|
141
134
|
:short => "-r RUN_LIST",
|
142
135
|
:long => "--run-list RUN_LIST",
|
@@ -311,6 +304,10 @@ class Chef
|
|
311
304
|
cleanup(vm_ref)
|
312
305
|
end
|
313
306
|
|
307
|
+
if locate_config_value(:run_list).empty? or ! locate_config_value(:template_file)
|
308
|
+
exit 0
|
309
|
+
end
|
310
|
+
|
314
311
|
guest_addr = get_guest_ip(vm_ref)
|
315
312
|
if guest_addr.nil? or guest_addr.empty?
|
316
313
|
ui.msg("ip seems wrong using host+domain name instead")
|
@@ -331,7 +328,7 @@ class Chef
|
|
331
328
|
end
|
332
329
|
|
333
330
|
|
334
|
-
|
331
|
+
begin
|
335
332
|
if domainname.empty?
|
336
333
|
server = server_name
|
337
334
|
else
|
@@ -346,6 +343,7 @@ class Chef
|
|
346
343
|
bootstrap.config[:identity_file] = config[:identity_file]
|
347
344
|
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server
|
348
345
|
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
|
346
|
+
bootstrap.config[:first_boot_attributes] = locate_config_value(:json_attributes)
|
349
347
|
bootstrap.config[:distro] = locate_config_value(:bootstrap_template)
|
350
348
|
bootstrap.config[:use_sudo] = true unless config[:ssh_user] == 'root'
|
351
349
|
bootstrap.config[:template_file] = locate_config_value(:template_file)
|
@@ -354,12 +352,12 @@ class Chef
|
|
354
352
|
bootstrap.config[:run_list] = config[:run_list]
|
355
353
|
|
356
354
|
bootstrap.run
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
355
|
+
rescue Exception => e
|
356
|
+
ui.msg "#{h.color 'ERROR:'} #{h.color( e.message, :red )}"
|
357
|
+
puts "Nested backtrace:"
|
358
|
+
ui.msg "#{h.color( e.backtrace.join("\n"), :yellow)}"
|
359
|
+
cleanup(vm_ref)
|
360
|
+
end
|
363
361
|
|
364
362
|
end
|
365
363
|
|
data/lib/knife-xapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-xapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|