clc-chef-metal-vsphere 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f96f40dfe5a341ed4d8522ba979e119beee05d8
4
- data.tar.gz: 309ae1f3c2b8497d5e06b8de5d235b33a0df8fe3
3
+ metadata.gz: bde0ea1b5590a556f8290d449c971aa42fb9195d
4
+ data.tar.gz: 247666cc1e8e51729208999304b10478b548d6aa
5
5
  SHA512:
6
- metadata.gz: 195eaa0939fa86f6d9645ca059af7018d2be23558bee8800c8d82309d3756218b5b9707377be33cf600bd6cb4f5931c713a3c7284ab65d7a61c029189e8bf866
7
- data.tar.gz: 2114bee171e8830c150da96241be21efd95874490656b7a278d41534838fdfe38118690a8a10f044ab64dc699481e6080b2bcb13f9de35c01024e9601f02852a
6
+ metadata.gz: 1a7e0aaef059608389aa13a78a46593bbe49198c7d4653dd6f0913a2da40c9948c802894696d62705d5b14e3121cd17e11bad30a628a8aefa3c4a4fcc3c90110
7
+ data.tar.gz: 09e2bd807f626dda10d1694b5f844ac8603c117be80725f6db402054e8d31320800056464b45e70fcd13bc487074c826ad02995ba16bf57a8db2422719e04092
@@ -1,3 +1,3 @@
1
1
  module ChefMetalVsphere
2
- VERSION = '0.3.10'
2
+ VERSION = '0.3.11'
3
3
  end
@@ -243,29 +243,8 @@ module ChefMetalVsphere
243
243
 
244
244
  machine = machine_for(machine_spec, machine_options, vm)
245
245
 
246
- if is_static
247
- host_lookup = machine.execute_always('host google.com')
248
- if host_lookup.exitstatus != 0
249
- if host_lookup.stdout.include?("setlocale: LC_ALL")
250
- machine.execute_always('locale-gen en_US && update-locale LANG=en_US')
251
- end
252
- distro = machine.execute_always("lsb_release -i | sed -e 's/Distributor ID://g'").stdout.strip
253
- Chef::Log.info "Found distro:#{distro}"
254
- if distro == 'Ubuntu'
255
- distro_version = (machine.execute_always("lsb_release -r | sed -e s/[^0-9.]//g")).stdout.strip.to_f
256
- Chef::Log.info "Found distro version:#{distro_version}"
257
- if distro_version>= 12.04
258
- Chef::Log.info "Ubuntu version 12.04 or greater. Need to patch DNS."
259
- interfaces_file = "/etc/network/interfaces"
260
- nameservers = bootstrap_options[:customization_spec][:ipsettings][:dnsServerList].join(' ')
261
- machine.execute_always("if ! cat #{interfaces_file} | grep -q dns-search ; then echo 'dns-search #{machine_spec.name}' >> #{interfaces_file} ; fi")
262
- machine.execute_always("if ! cat #{interfaces_file} | grep -q dns-nameservers ; then echo 'dns-nameservers #{nameservers}' >> #{interfaces_file} ; fi")
263
- machine.execute_always('/etc/init.d/networking restart')
264
- machine.execute_always('echo "ACTION=="add", SUBSYSTEM=="cpu", ATTR{online}="1"" > /etc/udev/rules.d/99-vmware-cpuhotplug-udev.rules')
265
- machine.execute_always('apt-get -qq update')
266
- end
267
- end
268
- end
246
+ if is_static && !is_windows?(vm)
247
+ setup_ubuntu_dns(machine, bootstrap_options, machine_spec)
269
248
  end
270
249
 
271
250
  machine
@@ -322,6 +301,31 @@ module ChefMetalVsphere
322
301
 
323
302
  protected
324
303
 
304
+ def setup_ubuntu_dns(machine, bootstrap_options, machine_spec)
305
+ host_lookup = machine.execute_always('host google.com')
306
+ if host_lookup.exitstatus != 0
307
+ if host_lookup.stdout.include?("setlocale: LC_ALL")
308
+ machine.execute_always('locale-gen en_US && update-locale LANG=en_US')
309
+ end
310
+ distro = machine.execute_always("lsb_release -i | sed -e 's/Distributor ID://g'").stdout.strip
311
+ Chef::Log.info "Found distro:#{distro}"
312
+ if distro == 'Ubuntu'
313
+ distro_version = (machine.execute_always("lsb_release -r | sed -e s/[^0-9.]//g")).stdout.strip.to_f
314
+ Chef::Log.info "Found distro version:#{distro_version}"
315
+ if distro_version>= 12.04
316
+ Chef::Log.info "Ubuntu version 12.04 or greater. Need to patch DNS."
317
+ interfaces_file = "/etc/network/interfaces"
318
+ nameservers = bootstrap_options[:customization_spec][:ipsettings][:dnsServerList].join(' ')
319
+ machine.execute_always("if ! cat #{interfaces_file} | grep -q dns-search ; then echo 'dns-search #{machine_spec.name}' >> #{interfaces_file} ; fi")
320
+ machine.execute_always("if ! cat #{interfaces_file} | grep -q dns-nameservers ; then echo 'dns-nameservers #{nameservers}' >> #{interfaces_file} ; fi")
321
+ machine.execute_always('/etc/init.d/networking restart')
322
+ machine.execute_always('echo "ACTION=="add", SUBSYSTEM=="cpu", ATTR{online}="1"" > /etc/udev/rules.d/99-vmware-cpuhotplug-udev.rules')
323
+ machine.execute_always('apt-get -qq update')
324
+ end
325
+ end
326
+ end
327
+ end
328
+
325
329
  def has_static_ip(bootstrap_options)
326
330
  if bootstrap_options.has_key?(:customization_spec)
327
331
  bootstrap_options = bootstrap_options[:customization_spec]
@@ -456,7 +460,13 @@ module ChefMetalVsphere
456
460
  end
457
461
 
458
462
  def create_winrm_transport(machine_spec, machine_options, vm)
459
- raise 'Windows guest VMs are not yet supported'
463
+ require 'chef_metal/transport/winrm'
464
+ bootstrap_options = bootstrap_options_for(machine_spec, machine_options)
465
+ ssh_options = bootstrap_options[:ssh]
466
+ remote_host = has_static_ip(bootstrap_options) ? bootstrap_options[:customization_spec][:ipsettings][:ip] : vm.guest.ipaddress
467
+ winrm_options = {:user => "#{remote_host}\\#{ssh_options[:user]}", :pass => ssh_options[:password], :disable_sspi => true}
468
+
469
+ ChefMetal::Transport::WinRM.new("http://#{remote_host}:5985/wsman", :plaintext, winrm_options, config)
460
470
  end
461
471
 
462
472
  def create_ssh_transport(machine_spec, machine_options, vm)
@@ -470,3 +480,6 @@ module ChefMetalVsphere
470
480
  end
471
481
  end
472
482
  end
483
+
484
+
485
+ # wr=WinRM::WinRMWebService.new('http://172.21.20.196:5985/wsman', :plaintext, {:user => "cmvd-test-41f91\\Administrator", :pass => 'Password123', :basic_auth_only => true})
@@ -75,7 +75,6 @@ module ChefMetalVsphere
75
75
 
76
76
  #folder could be like: /Level1/Level2/folder_name
77
77
  def find_folder(dc_name, folder_name)
78
- #dc(dc_name).vmFolder.childEntity.grep(RbVmomi::VIM::Folder).find { |x| x.name == folder_name }
79
78
  baseEntity = dc(dc_name).vmFolder
80
79
  if folder_name && folder_name.length > 0
81
80
  entityArray = folder_name.split('/')
@@ -135,16 +134,46 @@ module ChefMetalVsphere
135
134
  cust_hostname ||= RbVmomi::VIM::CustomizationFixedName.new(:name => vm_name)
136
135
  cust_hwclockutc = cust_options[:hw_clock_utc]
137
136
  cust_timezone = cust_options[:time_zone]
138
- cust_prep = RbVmomi::VIM::CustomizationLinuxPrep.new(
139
- :domain => cust_domain,
140
- :hostName => cust_hostname,
141
- :hwClockUTC => cust_hwclockutc,
142
- :timeZone => cust_timezone)
143
- cust_adapter_mapping = [RbVmomi::VIM::CustomizationAdapterMapping.new(:adapter => cust_ip_settings)]
144
- cust_spec = RbVmomi::VIM::CustomizationSpec.new(
145
- :identity => cust_prep,
146
- :globalIPSettings => cust_global_ip_settings,
147
- :nicSettingMap => cust_adapter_mapping)
137
+
138
+ if vm_template.guest.guestId.start_with?('win')
139
+ cust_runonce = RbVmomi::VIM::CustomizationGuiRunOnce.new(
140
+ :commandList => [
141
+ 'winrm set winrm/config/client/auth @{Basic="true"}',
142
+ 'winrm set winrm/config/service/auth @{Basic="true"}',
143
+ 'winrm set winrm/config/service @{AllowUnencrypted="true"}',
144
+ 'shutdown -l'])
145
+ cust_id = RbVmomi::VIM::CustomizationIdentification.new(
146
+ :joinWorkgroup => 'WORKGROUP')
147
+ cust_password = RbVmomi::VIM::CustomizationPassword(
148
+ :plainText => true,
149
+ :value => options[:ssh][:password])
150
+ cust_gui_unattended = RbVmomi::VIM::CustomizationGuiUnattended.new(
151
+ :autoLogon => true,
152
+ :autoLogonCount => 1,
153
+ :password => cust_password,
154
+ :timeZone => cust_options[:win_time_zone])
155
+ cust_userdata = RbVmomi::VIM::CustomizationUserData.new(
156
+ :computerName => cust_hostname,
157
+ :fullName => cust_options[:org_name],
158
+ :orgName => cust_options[:org_name],
159
+ :productId => cust_options[:product_id])
160
+ cust_prep = RbVmomi::VIM::CustomizationSysprep.new(
161
+ :guiRunOnce => cust_runonce,
162
+ :identification => cust_id,
163
+ :guiUnattended => cust_gui_unattended,
164
+ :userData => cust_userdata)
165
+ else
166
+ cust_prep = RbVmomi::VIM::CustomizationLinuxPrep.new(
167
+ :domain => cust_domain,
168
+ :hostName => cust_hostname,
169
+ :hwClockUTC => cust_hwclockutc,
170
+ :timeZone => cust_timezone)
171
+ end
172
+ cust_adapter_mapping = [RbVmomi::VIM::CustomizationAdapterMapping.new(:adapter => cust_ip_settings)]
173
+ cust_spec = RbVmomi::VIM::CustomizationSpec.new(
174
+ :identity => cust_prep,
175
+ :globalIPSettings => cust_global_ip_settings,
176
+ :nicSettingMap => cust_adapter_mapping)
148
177
  else
149
178
  cust_spec = find_customization_spec(options[:customization_spec])
150
179
  end
@@ -170,7 +199,7 @@ module ChefMetalVsphere
170
199
  :allowGuestControl => true,
171
200
  :connected => true,
172
201
  :startConnected => true)
173
- device = RbVmomi::VIM::VirtualE1000(
202
+ device = RbVmomi::VIM::VirtualVmxnet3(
174
203
  :backing => nic_backing_info,
175
204
  :deviceInfo => RbVmomi::VIM::Description(:label => "Network adapter 1", :summary => options[:network_name]),
176
205
  :key => 4000,
@@ -38,7 +38,8 @@ describe "vsphere_driver" do
38
38
  include ChefMetalVsphere::Helpers
39
39
 
40
40
  before :all do
41
- @vm_name = "cmvd-test-#{SecureRandom.hex}"
41
+ #@vm_name = "cmvd-test-#{SecureRandom.hex}"
42
+ @vm_name = "cmvd-test-41f91ed95145ffabc045df653b69ef1d"
42
43
  @metal_config = eval File.read(File.expand_path('../config.rb', __FILE__))
43
44
  Cheffish.honor_local_mode do
44
45
  chef_server = Cheffish.default_chef_server(@metal_config)
@@ -48,8 +49,11 @@ describe "vsphere_driver" do
48
49
  action_handler = ChefMetal::ActionHandler.new
49
50
  @driver.allocate_machine(action_handler, @machine_spec, @metal_config[:machine_options])
50
51
  @metal_config[:machine_options][:convergence_options] = {:chef_server => chef_server}
51
- @driver.ready_machine(action_handler, @machine_spec, @metal_config[:machine_options])
52
+ machine = @driver.ready_machine(action_handler, @machine_spec, @metal_config[:machine_options])
52
53
  @server_id = @machine_spec.location['server_id']
54
+ machine.setup_convergence(action_handler)
55
+ @machine_spec.save(action_handler)
56
+ machine.converge(action_handler)
53
57
  @connection = vim(@metal_config[:driver_options])
54
58
  @vm = find_vm_by_id(@server_id, @connection)
55
59
  end
@@ -113,20 +117,20 @@ describe "vsphere_driver" do
113
117
  end
114
118
  end
115
119
 
116
- context "destroy_machine" do
120
+ # context "destroy_machine" do
117
121
 
118
- it "removes the machine" do
119
- Cheffish.honor_local_mode do
120
- chef_server = Cheffish.default_chef_server(@metal_config)
121
- driver = ChefMetal.driver_for_url("vsphere://#{@metal_config[:driver_options][:host]}", @metal_config)
122
- action_handler = ChefMetal::ActionHandler.new
123
- machine_spec = ChefMetal::ChefMachineSpec.new({'name' => @vm_name}, chef_server)
124
- machine_spec.location = { 'driver_url' => driver.driver_url,
125
- 'server_id' => @server_id}
126
- driver.destroy_machine(action_handler, machine_spec, @metal_config[:machine_options])
127
- end
128
- vm = find_vm_by_id(@server_id, @connection)
129
- expect(vm).to eq(nil)
130
- end
131
- end
122
+ # it "removes the machine" do
123
+ # Cheffish.honor_local_mode do
124
+ # chef_server = Cheffish.default_chef_server(@metal_config)
125
+ # driver = ChefMetal.driver_for_url("vsphere://#{@metal_config[:driver_options][:host]}", @metal_config)
126
+ # action_handler = ChefMetal::ActionHandler.new
127
+ # machine_spec = ChefMetal::ChefMachineSpec.new({'name' => @vm_name}, chef_server)
128
+ # machine_spec.location = { 'driver_url' => driver.driver_url,
129
+ # 'server_id' => @server_id}
130
+ # driver.destroy_machine(action_handler, machine_spec, @metal_config[:machine_options])
131
+ # end
132
+ # vm = find_vm_by_id(@server_id, @connection)
133
+ # expect(vm).to eq(nil)
134
+ # end
135
+ # end
132
136
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clc-chef-metal-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.5.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: chef-metal
42
+ name: clc-fork-chef-metal
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.12.1
47
+ version: 0.12.1.alpha.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.12.1
54
+ version: 0.12.1.alpha.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement