knife-esx 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -11
- data/README.rdoc +10 -0
- data/knife-esx.gemspec +3 -3
- data/lib/chef/knife/esx_base.rb +21 -1
- data/lib/chef/knife/esx_vm_create.rb +19 -2
- data/lib/chef/knife/esx_vm_delete.rb +3 -0
- data/lib/knife-esx/version.rb +1 -1
- metadata +46 -15
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
# 0.3.2 - 2012/03/28
|
2
|
-
|
3
|
-
* --vm-disk no longer mandatory. Fixes --batch mode.
|
4
|
-
|
5
1
|
# 0.3.1 - 2012/03/26
|
6
2
|
|
7
3
|
* Minor string change
|
8
4
|
|
9
5
|
# 0.3.0 - 2012/03/26
|
10
6
|
|
11
|
-
|
7
|
+
Added template commands
|
12
8
|
|
13
9
|
```
|
14
10
|
knife esx template import --esx-password password \
|
@@ -23,7 +19,7 @@
|
|
23
19
|
template.vmdk
|
24
20
|
```
|
25
21
|
|
26
|
-
|
22
|
+
Added --use-template argument to *vm create* command
|
27
23
|
|
28
24
|
```
|
29
25
|
knife esx vm create --esx-password password \
|
@@ -34,7 +30,7 @@
|
|
34
30
|
|
35
31
|
## Create a new VM using templates
|
36
32
|
|
37
|
-
1.
|
33
|
+
1.Import the template first with "knife esx template import"
|
38
34
|
|
39
35
|
```
|
40
36
|
knife esx template import --esx-host esx-test-host \
|
@@ -42,7 +38,7 @@
|
|
42
38
|
/path/to/template.vmdk
|
43
39
|
```
|
44
40
|
|
45
|
-
2.
|
41
|
+
2.Deploy using knife esx vm create
|
46
42
|
|
47
43
|
```
|
48
44
|
knife esx vm create --esx-host esx-test-host \
|
@@ -53,7 +49,7 @@
|
|
53
49
|
|
54
50
|
## Using templates with async batch deploys
|
55
51
|
|
56
|
-
1.
|
52
|
+
1.Import the template first with "knife esx template import"
|
57
53
|
|
58
54
|
```
|
59
55
|
knife esx template import --esx-host esx-test-host \
|
@@ -61,8 +57,8 @@
|
|
61
57
|
/path/to/template.vmdk
|
62
58
|
```
|
63
59
|
|
64
|
-
2.
|
65
|
-
|
60
|
+
2.Deploy using knife esx vm create --async --batch
|
61
|
+
Sample batch config for "knife esx vm create":
|
66
62
|
|
67
63
|
```
|
68
64
|
---
|
data/README.rdoc
CHANGED
@@ -40,6 +40,16 @@ You also have the option of passing your ESX Host/Username/Password into the ind
|
|
40
40
|
--esx-host my-test-host \
|
41
41
|
--esx-password secret
|
42
42
|
|
43
|
+
#provision a new ubuntu 12.04 VM using a template on the ESXi Host with the --use-template option
|
44
|
+
#- the command assumes that you have an ubuntu template located at /vmfs/volumes/datastore1/esx-gem/templates/ubuntu12.04-template-x64.vmdk.
|
45
|
+
#In this example we also changed the location of the datastore from the default datastore1 to datastore2
|
46
|
+
knife esx vm create --esx-username root \
|
47
|
+
--vm-name ubuntu-12.04-vm \
|
48
|
+
--datastore datastore2 \
|
49
|
+
--esx-host server1 \
|
50
|
+
--esx-password secret \
|
51
|
+
--use-template ubuntu12.04-template-x64.vmdk
|
52
|
+
|
43
53
|
= SUBCOMMANDS:
|
44
54
|
|
45
55
|
This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a <tt>--help</tt> flag
|
data/knife-esx.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "knife-esx"
|
7
7
|
s.version = Knife::ESX::VERSION
|
8
8
|
s.has_rdoc = true
|
9
|
-
s.authors = ["Sergio Rubio"]
|
10
|
-
s.email = ["rubiojr@frameos.org","rubiojr@frameos.org"]
|
9
|
+
s.authors = ["Sergio Rubio", "Massimo Maino"]
|
10
|
+
s.email = ["rubiojr@frameos.org","rubiojr@frameos.org","maintux@gmail.com"]
|
11
11
|
s.homepage = "http://github.com/rubiojr/knife-esx"
|
12
12
|
s.summary = "ESX Support for Chef's Knife Command"
|
13
13
|
s.description = s.summary
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.add_dependency "esx", ">= 0.4.
|
19
|
+
s.add_dependency "esx", ">= 0.4.2"
|
20
20
|
s.add_dependency "terminal-table"
|
21
21
|
s.add_dependency "chef", ">= 0.10"
|
22
22
|
s.add_dependency "celluloid", ">= 0.9"
|
data/lib/chef/knife/esx_base.rb
CHANGED
@@ -52,6 +52,24 @@ class Chef
|
|
52
52
|
:description => "Your ESX host address",
|
53
53
|
:default => "127.0.0.1",
|
54
54
|
:proc => Proc.new { |host| Chef::Config[:knife][:esx_host] = host }
|
55
|
+
|
56
|
+
option :free_license,
|
57
|
+
:long => "--free-license",
|
58
|
+
:description => "If your Hypervisor have a free license",
|
59
|
+
:boolean => true,
|
60
|
+
:default => false
|
61
|
+
|
62
|
+
option :insecure,
|
63
|
+
:long => "--insecure",
|
64
|
+
:description => "Insecure connection",
|
65
|
+
:boolean => true,
|
66
|
+
:default => true
|
67
|
+
|
68
|
+
option :esx_templates_dir,
|
69
|
+
:long => "--esx-templates-dir TEMPLATES_DIRECTORY",
|
70
|
+
:description => "Your ESX Templates directory",
|
71
|
+
:default => "",
|
72
|
+
:proc => Proc.new { |templates_dir| Chef::Config[:knife][:esx_templates_dir] = templates_dir }
|
55
73
|
end
|
56
74
|
end
|
57
75
|
|
@@ -61,7 +79,9 @@ class Chef
|
|
61
79
|
ui.info "#{ui.color("Connecting to ESX host #{config[:esx_host]}... ", :magenta)}"
|
62
80
|
@connection = ESX::Host.connect(Chef::Config[:knife][:esx_host],
|
63
81
|
Chef::Config[:knife][:esx_username],
|
64
|
-
Chef::Config[:knife][:esx_password] || ''
|
82
|
+
Chef::Config[:knife][:esx_password] || '',
|
83
|
+
config[:insecure],
|
84
|
+
{:templates_dir => Chef::Config[:knife][:esx_templates_dir], :free_license=>config[:free_license]})
|
65
85
|
else
|
66
86
|
@connection
|
67
87
|
end
|
@@ -85,6 +85,9 @@ module KnifeESX
|
|
85
85
|
if @name.nil? or @name.empty?
|
86
86
|
raise Exception.new("Invalid job name")
|
87
87
|
end
|
88
|
+
if not @options['vm-disk'] or !File.exist?(@options['vm-disk'])
|
89
|
+
raise Exception.new("Invalid VM disk for job #{@name}.")
|
90
|
+
end
|
88
91
|
end
|
89
92
|
|
90
93
|
# returns [status, stdout, stderr]
|
@@ -150,8 +153,12 @@ class Chef
|
|
150
153
|
|
151
154
|
option :vm_name,
|
152
155
|
:long => "--vm-name NAME",
|
153
|
-
:description => "The Virtual Machine name"
|
154
|
-
|
156
|
+
:description => "The Virtual Machine name"
|
157
|
+
|
158
|
+
option :cpus,
|
159
|
+
:long => "--vm-cpus CPUS",
|
160
|
+
:description => "The Virtual Machine cpus (default: 1)"
|
161
|
+
|
155
162
|
option :datastore,
|
156
163
|
:long => "--datastore NAME",
|
157
164
|
:default => 'datastore1',
|
@@ -206,6 +213,13 @@ class Chef
|
|
206
213
|
:proc => lambda { |o| o.split(/[\s,]+/) },
|
207
214
|
:default => []
|
208
215
|
|
216
|
+
option :json_attributes,
|
217
|
+
:short => "-j JSON_ATTRIBUTES",
|
218
|
+
:long => "--json-attributes JSON_ATTRIBUTES",
|
219
|
+
:description => "A JSON string to be added to the first run of chef-client",
|
220
|
+
:proc => lambda { |o| JSON.parse(o) },
|
221
|
+
:default => {}
|
222
|
+
|
209
223
|
option :ssh_user,
|
210
224
|
:short => "-x USERNAME",
|
211
225
|
:long => "--ssh-user USERNAME",
|
@@ -335,6 +349,7 @@ class Chef
|
|
335
349
|
|
336
350
|
datastore = config[:datastore]
|
337
351
|
memory = config[:memory]
|
352
|
+
cpus = config[:cpus]||1
|
338
353
|
vm_disk = config[:vm_disk]
|
339
354
|
guest_id =config[:guest_id]
|
340
355
|
destination_path = "/vmfs/volumes/#{datastore}/#{vm_name}"
|
@@ -359,6 +374,7 @@ class Chef
|
|
359
374
|
:datastore => datastore,
|
360
375
|
:disk_file => "#{vm_name}/#{vm_name}.vmdk",
|
361
376
|
:memory => memory,
|
377
|
+
:cpus => cpus,
|
362
378
|
:guest_id => guest_id,
|
363
379
|
:nics => create_nics(config[:vm_network], config[:mac_address])
|
364
380
|
vm.power_on
|
@@ -404,6 +420,7 @@ class Chef
|
|
404
420
|
bootstrap.name_args = [vm.ip_address]
|
405
421
|
bootstrap.config[:async] = config[:async]
|
406
422
|
bootstrap.config[:run_list] = config[:run_list]
|
423
|
+
bootstrap.config[:first_boot_attributes] = config[:json_attributes]
|
407
424
|
bootstrap.config[:ssh_user] = config[:ssh_user]
|
408
425
|
bootstrap.config[:identity_file] = config[:identity_file]
|
409
426
|
bootstrap.config[:chef_node_name] = config[:chef_node_name] || vm.name
|
@@ -43,6 +43,9 @@ class Chef
|
|
43
43
|
vm.power_off if (vm.name =~ /#{vm.name}/ and vm.power_state == 'poweredOn')
|
44
44
|
vm.destroy
|
45
45
|
deleted << vm_name
|
46
|
+
#Assume yes because the user already confirmed the deletion
|
47
|
+
system "knife client delete #{vm.name} -y"
|
48
|
+
system "knife node delete #{vm.name} -y"
|
46
49
|
ui.info("Deleted virtual machine #{vm.name}")
|
47
50
|
end
|
48
51
|
end
|
data/lib/knife-esx/version.rb
CHANGED
metadata
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-esx
|
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:
|
8
8
|
- Sergio Rubio
|
9
|
+
- Massimo Maino
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
+
date: 2012-12-08 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: esx
|
16
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.4.
|
22
|
+
version: 0.4.2
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.4.2
|
25
31
|
- !ruby/object:Gem::Dependency
|
26
32
|
name: terminal-table
|
27
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
28
34
|
none: false
|
29
35
|
requirements:
|
30
36
|
- - ! '>='
|
@@ -32,10 +38,15 @@ dependencies:
|
|
32
38
|
version: '0'
|
33
39
|
type: :runtime
|
34
40
|
prerelease: false
|
35
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: chef
|
38
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,15 @@ dependencies:
|
|
43
54
|
version: '0.10'
|
44
55
|
type: :runtime
|
45
56
|
prerelease: false
|
46
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.10'
|
47
63
|
- !ruby/object:Gem::Dependency
|
48
64
|
name: celluloid
|
49
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
50
66
|
none: false
|
51
67
|
requirements:
|
52
68
|
- - ! '>='
|
@@ -54,10 +70,15 @@ dependencies:
|
|
54
70
|
version: '0.9'
|
55
71
|
type: :runtime
|
56
72
|
prerelease: false
|
57
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0.9'
|
58
79
|
- !ruby/object:Gem::Dependency
|
59
80
|
name: open4
|
60
|
-
requirement:
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
61
82
|
none: false
|
62
83
|
requirements:
|
63
84
|
- - ! '>='
|
@@ -65,11 +86,17 @@ dependencies:
|
|
65
86
|
version: '0'
|
66
87
|
type: :runtime
|
67
88
|
prerelease: false
|
68
|
-
version_requirements:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
69
95
|
description: ESX Support for Chef's Knife Command
|
70
96
|
email:
|
71
97
|
- rubiojr@frameos.org
|
72
98
|
- rubiojr@frameos.org
|
99
|
+
- maintux@gmail.com
|
73
100
|
executables: []
|
74
101
|
extensions: []
|
75
102
|
extra_rdoc_files:
|
@@ -112,8 +139,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
139
|
version: '0'
|
113
140
|
requirements: []
|
114
141
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.8.
|
142
|
+
rubygems_version: 1.8.24
|
116
143
|
signing_key:
|
117
144
|
specification_version: 3
|
118
145
|
summary: ESX Support for Chef's Knife Command
|
119
|
-
test_files:
|
146
|
+
test_files:
|
147
|
+
- features/esx.feature
|
148
|
+
- features/foo
|
149
|
+
- features/step_definitions/steps.rb
|
150
|
+
- features/support/env.rb
|