knife-esx 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Sat Feb 25 12:16:01 CET 2012 - 0.1.5
2
+
3
+ * Patch from @pperezrubio adding multiple networks support
4
+
5
+ knife esx vm create --vm-disk ubuntu-oneiric.vmdk \
6
+ --vm-name testvm --datastore datastore1 \
7
+ --esx-host 192.168.88.1 --ssh-user ubuntu \
8
+ --ssh-password ubuntu \
9
+ --vm-network "VLAN-Integration,VLAN-Test"
10
+
11
+
12
+ This will create a VM with two NICs, attaching them to the VLAN-Integration and VLAN-Test networks respectively.
13
+
14
+
@@ -114,6 +114,18 @@ class Chef
114
114
  :default => false,
115
115
  :proc => Proc.new { true }
116
116
 
117
+ option :vm_network,
118
+ :short => "-N network[,network..]",
119
+ :long => "--vm-network",
120
+ :description => "Network where nic is attached to",
121
+ :default => 'VM Network'
122
+
123
+ option :mac_address,
124
+ :short => "-M mac[,mac..]",
125
+ :long => "--mac-address",
126
+ :description => "Mac address list",
127
+ :default => nil
128
+
117
129
  def tcp_test_ssh(hostname)
118
130
  tcp_socket = TCPSocket.new(hostname, 22)
119
131
  readable = IO.select([tcp_socket], nil, nil, 5)
@@ -152,6 +164,7 @@ class Chef
152
164
  exit 1
153
165
  end
154
166
 
167
+
155
168
  datastore = config[:datastore]
156
169
  memory = config[:memory]
157
170
  vm_disk = config[:vm_disk]
@@ -161,13 +174,14 @@ class Chef
161
174
  connection.remote_command "mkdir #{destination_path}"
162
175
  puts "#{ui.color("Creating VM... ", :magenta)}"
163
176
  puts "#{ui.color("Importing VM disk... ", :magenta)}"
177
+
164
178
  connection.import_disk vm_disk, destination_path + "/#{vm_name}.vmdk"
165
179
  vm = connection.create_vm :vm_name => vm_name,
166
180
  :datastore => datastore,
167
181
  :disk_file => "#{vm_name}/#{vm_name}.vmdk",
168
182
  :memory => memory,
169
183
  :guest_id => guest_id,
170
- :nics => [{:mac_address => nil, :network => "VM Network"}]
184
+ :nics => create_nics(config[:vm_network], config[:mac_address])
171
185
  vm.power_on
172
186
 
173
187
  puts "#{ui.color("VM Name", :cyan)}: #{vm.name}"
@@ -221,6 +235,15 @@ class Chef
221
235
  bootstrap
222
236
  end
223
237
 
238
+ def create_nics(networks, macs)
239
+ net_arr = networks.split(/,/).map { |x| { :network => x } }
240
+ if macs
241
+ mac_arr = macs.split(/,/)
242
+ net_arr.each_index { |x| net_arr[x][:mac_address] = mac_arr[x] if mac_arr[x] and !mac_arr[x].empty? }
243
+ else
244
+ net_arr
245
+ end
246
+ end
224
247
  end
225
248
  end
226
249
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module ESX
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-esx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-02 00:00:00.000000000 Z
12
+ date: 2012-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: esx
16
- requirement: &10223740 !ruby/object:Gem::Requirement
16
+ requirement: &14262920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.3.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *10223740
24
+ version_requirements: *14262920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: terminal-table
27
- requirement: &10223060 !ruby/object:Gem::Requirement
27
+ requirement: &14262220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *10223060
35
+ version_requirements: *14262220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: chef
38
- requirement: &10222160 !ruby/object:Gem::Requirement
38
+ requirement: &14261380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0.10'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *10222160
46
+ version_requirements: *14261380
47
47
  description: ESX Support for Chef's Knife Command
48
48
  email:
49
49
  - rubiojr@frameos.org
@@ -54,6 +54,7 @@ extra_rdoc_files:
54
54
  - README.rdoc
55
55
  - LICENSE
56
56
  files:
57
+ - CHANGELOG.md
57
58
  - LICENSE
58
59
  - README.rdoc
59
60
  - features/esx.feature
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  requirements: []
88
89
  rubyforge_project:
89
- rubygems_version: 1.8.10
90
+ rubygems_version: 1.8.16
90
91
  signing_key:
91
92
  specification_version: 3
92
93
  summary: ESX Support for Chef's Knife Command