chef-provisioning-vsphere 0.5.8 → 0.6.0.dev.1

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: 12dda7faea087859dd1c57ca94de5f57075f34ac
4
- data.tar.gz: 8ed3e2836949def6569e148c067f4ee427405218
3
+ metadata.gz: cfce09fb43f3b3cfe3787f91741a81965af267e4
4
+ data.tar.gz: 95a3fc5f27b5e6bb12b50a6b426072d0720c9ebc
5
5
  SHA512:
6
- metadata.gz: 2daa6f17429a7bc45099cf006178fd36da7f4dd684d288b67569f91dccbc2b2562271dfb049c209a237b64fc98efbd7127a4b97b2e5e4a542a020a36ebbaca8b
7
- data.tar.gz: a7adc29123fade718ff1e960ac89d57c2a46811c11ce95ac32cf75252f6c4b95879a55fcf9e56920423861c737c765260e3db13846de2e298b2a81a2807a84e8
6
+ metadata.gz: 6dffdc98cfe32f64a2da92eef7e021f52011344567cf83ca82cd34ad211d9535797bc167e6c4aa07e4151cf8e1e263eb15a4c95e1c4cfe98ec86f2d4e9397c44
7
+ data.tar.gz: 8a748e48ca8fd9d5e8cf189da50f6827cc042b01deff6c72bb36dca3da708f4dfd4a6955a1bf9e114bb731fb4d6c5a1e59e58af9d21ca66f4624fa894095568e
data/README.md CHANGED
@@ -102,6 +102,13 @@ This will use chef-zero and needs no chef server (only works for ssh). Note that
102
102
  - `[:customization_spec][:product_id]` - windows product key
103
103
  - `[:customization_spec][:win_time_zone]` - numeric time zone for windows
104
104
 
105
+ ## Timeout options
106
+ These are settings set at the root of `machine_options`. Chances are the defaults for these settings do not need to be changed:
107
+
108
+ - `start_timeout` - number of seconds to wait for a machine to be accessible after a restart (default 10 minutes)
109
+ - `create_timeout` - number of seconds to wait for a machine to be accessible after initiating provisioning (default 10 minutes)
110
+ - `ready_timeout` - number of seconds to wait for customization to complete and vmware tools to come on line (default 5 minutes)
111
+
105
112
  ## More config examples
106
113
 
107
114
  ### Static IP and an additional 50GB disk
@@ -259,22 +259,24 @@ module ChefProvisioningVsphere
259
259
  # Customization below may change this to a valid ip
260
260
  wait_until_ready(action_handler, machine_spec, machine_options, vm)
261
261
 
262
- # find the ip we actually want
263
- # this will be the static ip to assign
264
- # or the ip reported back by the vm if using dhcp
265
- # it *may* be nil if just cloned
266
- vm_ip = ip_to_bootstrap(bootstrap_options, vm)
267
- transport = nil
268
- unless vm_ip.nil?
269
- transport = transport_for(machine_spec, bootstrap_options[:ssh], vm_ip)
270
- end
262
+ if !machine_spec.location['ipaddress'] || !has_ip?(machine_spec.location['ipaddress'], vm)
263
+ # find the ip we actually want
264
+ # this will be the static ip to assign
265
+ # or the ip reported back by the vm if using dhcp
266
+ # it *may* be nil if just cloned
267
+ vm_ip = ip_to_bootstrap(bootstrap_options, vm)
268
+ transport = nil
269
+ unless vm_ip.nil?
270
+ transport = transport_for(machine_spec, bootstrap_options[:ssh], vm_ip)
271
+ end
271
272
 
272
- unless !transport.nil? && transport.available? && has_ip?(vm_ip, vm)
273
- attempt_ip(machine_options, action_handler, vm, machine_spec)
273
+ unless !transport.nil? && transport.available? && has_ip?(vm_ip, vm)
274
+ attempt_ip(machine_options, action_handler, vm, machine_spec)
275
+ end
276
+ machine_spec.location['ipaddress'] = vm.guest.ipAddress
277
+ action_handler.report_progress(
278
+ "IP address obtained: #{machine_spec.location['ipaddress']}")
274
279
  end
275
- machine_spec.location['ipaddress'] = vm.guest.ipAddress
276
- action_handler.report_progress(
277
- "IP address obtained: #{machine_spec.location['ipaddress']}")
278
280
 
279
281
  wait_for_domain(bootstrap_options, vm, machine_spec, action_handler)
280
282
 
@@ -1,3 +1,3 @@
1
1
  module ChefProvisioningVsphere
2
- VERSION = '0.5.8'
3
- end
2
+ VERSION = '0.6.0.dev.1'
3
+ end
@@ -126,7 +126,7 @@ module ChefProvisioningVsphere
126
126
  if backing_info.is_a?(RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo)
127
127
  backing_info.port.portgroupKey
128
128
  else
129
- backing_info.network
129
+ backing_info.deviceName
130
130
  end
131
131
  end
132
132
 
@@ -208,6 +208,7 @@ module ChefProvisioningVsphere
208
208
  end
209
209
 
210
210
  def backing_info_for(action_handler, network_name)
211
+ action_handler.report_progress('finding networks...')
211
212
  network = find_network(network_name)
212
213
  action_handler.report_progress(
213
214
  "network: #{network_name} is a #{network.class}")
@@ -296,7 +297,7 @@ module ChefProvisioningVsphere
296
297
  entity_array.each do |item|
297
298
  case base
298
299
  when RbVmomi::VIM::Folder
299
- base = base.childEntity.find { |f| f.name == item }
300
+ base = base.find(item)
300
301
  when RbVmomi::VIM::VmwareDistributedVirtualSwitch
301
302
  idx = base.summary.portgroupName.find_index(item)
302
303
  base = idx.nil? ? nil : base.portgroup[idx]
@@ -7,6 +7,8 @@ module Kitchen
7
7
  module Driver
8
8
  class Vsphere < Kitchen::Driver::Base
9
9
 
10
+ @@chef_zero_server = false
11
+
10
12
  default_config :machine_options,
11
13
  :start_timeout => 600,
12
14
  :create_timeout => 600,
@@ -25,16 +27,17 @@ module Kitchen
25
27
  }
26
28
 
27
29
  def create(state)
28
- config[:server_name] ||= "kitchen-#{SecureRandom.hex(4)}"
30
+ state[:vsphere_name] ||= "kitchen-#{SecureRandom.hex(4)}"
29
31
  state[:username] = config[:machine_options][:bootstrap_options][:ssh][:user]
30
32
  state[:password] = config[:machine_options][:bootstrap_options][:ssh][:password]
31
-
32
- machine = with_provisioning_driver(config[:server_name]) do | action_handler, driver, machine_spec|
33
+ config[:server_name] = state[:vsphere_name]
34
+
35
+ machine = with_provisioning_driver(state) do | action_handler, driver, machine_spec|
33
36
  driver.allocate_machine(action_handler, machine_spec, config[:machine_options])
34
37
  driver.ready_machine(action_handler, machine_spec, config[:machine_options])
35
38
  state[:server_id] = machine_spec.location['server_id']
36
39
  state[:hostname] = machine_spec.location['ipaddress']
37
- state[:vsphere_name] = config[:server_name]
40
+ machine_spec.save(action_handler)
38
41
  end
39
42
 
40
43
  node_dir = File.join(instance.verifier[:test_base_path], "nodes")
@@ -49,13 +52,12 @@ module Kitchen
49
52
  File.open(node_file, 'w') do |out|
50
53
  out << JSON.pretty_generate(node)
51
54
  end
52
-
53
55
  end
54
56
 
55
57
  def destroy(state)
56
58
  return if state[:server_id].nil?
57
59
 
58
- with_provisioning_driver(state[:vsphere_name]) do | action_handler, driver, machine_spec|
60
+ with_provisioning_driver(state) do | action_handler, driver, machine_spec|
59
61
  machine_spec.location = { 'driver_url' => driver.driver_url,
60
62
  'server_id' => state[:server_id]}
61
63
  driver.destroy_machine(action_handler, machine_spec, config[:machine_options])
@@ -69,15 +71,43 @@ module Kitchen
69
71
  File.delete(node_file) if File.exist?(node_file)
70
72
  end
71
73
 
72
- def with_provisioning_driver(name, &block)
73
- Cheffish.honor_local_mode do
74
- chef_server = Cheffish.default_chef_server
75
- config[:machine_options][:convergence_options] = {:chef_server => chef_server}
76
- machine_spec = Chef::Provisioning.chef_managed_entry_store(chef_server).new_entry(:machine, name)
77
- url = URI::VsphereUrl.from_config(@config[:driver_options]).to_s
78
- driver = Chef::Provisioning.driver_for_url(url, config)
79
- action_handler = Chef::Provisioning::ActionHandler.new
80
- block.call(action_handler, driver, machine_spec)
74
+ def with_provisioning_driver(state, &block)
75
+ config[:machine_options][:convergence_options] = {:chef_server => chef_server}
76
+ machine_spec = Chef::Provisioning.chef_managed_entry_store(chef_server).get(:machine, state[:vsphere_name])
77
+ if machine_spec.nil?
78
+ machine_spec = Chef::Provisioning.chef_managed_entry_store(chef_server)
79
+ .new_entry(:machine, state[:vsphere_name])
80
+ end
81
+ url = URI::VsphereUrl.from_config(@config[:driver_options]).to_s
82
+ driver = Chef::Provisioning.driver_for_url(url, config)
83
+ action_handler = Chef::Provisioning::ActionHandler.new
84
+ block.call(action_handler, driver, machine_spec)
85
+ end
86
+
87
+ def chef_server
88
+ if !@@chef_zero_server
89
+ vsphere_mutex.synchronize do
90
+ if !@@chef_zero_server
91
+ Chef::Config.local_mode = true
92
+ Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Dir.pwd)
93
+ require 'chef/local_mode'
94
+ Chef::LocalMode.setup_server_connectivity
95
+ @@chef_zero_server = true
96
+ end
97
+ end
98
+ end
99
+
100
+ Cheffish.default_chef_server
101
+ end
102
+
103
+ def vsphere_mutex
104
+ @@vsphere_mutex ||= begin
105
+ Kitchen.mutex.synchronize do
106
+ instance.class.mutexes ||= Hash.new
107
+ instance.class.mutexes[self.class] = Mutex.new
108
+ end
109
+
110
+ instance.class.mutexes[self.class]
81
111
  end
82
112
  end
83
113
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.6.0.dev.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-19 00:00:00.000000000 Z
11
+ date: 2015-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbvmomi
@@ -131,9 +131,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ">="
134
+ - - ">"
135
135
  - !ruby/object:Gem::Version
136
- version: '0'
136
+ version: 1.3.1
137
137
  requirements: []
138
138
  rubyforge_project:
139
139
  rubygems_version: 2.4.4