vagrant-vsphere 1.10.1 → 1.11.0

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: eb46c180bc1ef9ebd482ddf8620bd6fa4c324d43
4
- data.tar.gz: f5aa75fac5fcf413bdc568af049c78ae5a2e18c0
3
+ metadata.gz: 3a1a898766988a184569fc058c077650f032569b
4
+ data.tar.gz: e0947ca1cd5ed3b11fe6d63e2d0520cc7e1667bb
5
5
  SHA512:
6
- metadata.gz: 6f8f7c729cffbead019ed907daf78fca6c032fbf8126e180b98fdcf894cc2efe18b77f408e33b39f881b3dacb83c52d843de29858d04779cc955947165c642cd
7
- data.tar.gz: 4f74a56f9359d1f25913be8f8e6b5c57911fd44967c266f3dcd944e9f46029956357568ef0640ecad9bcf3ad4baedf2fc1aeed9a5f2314d8197f543c68e48ac7
6
+ metadata.gz: 4fb61ccad6fc0d7bb33442f22795c51da9c9b78df40c3b8e7575f3fb8e5b56bb5ff7ad7323589b2fb6befa9ccad6b27f71772d3b84818c3f47b348210c08d196
7
+ data.tar.gz: 6c64eb13ce87c80388698978a362f4ef4b525126a5d4803cc780046670ee7fb6c24628c8d052a85be8fa220441b0569519c408daf47cd6b241b51fcd5e018997
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 1.10.1
2
+ current_version = 1.11.0
3
3
  tag = true
4
4
  commit = true
5
5
 
@@ -1,11 +1,11 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.0.0
4
+ - 2.2.3
5
5
 
6
6
  before_install:
7
7
  - rvm @global do gem uninstall bundler --all --executables
8
8
  - gem uninstall bundler --all --executables
9
- - gem install bundler --version '1.6.9'
9
+ - gem install bundler --version '1.12.5'
10
10
 
11
11
  sudo: false
@@ -1,3 +1,10 @@
1
+ ## [1.11.0 (2016-11-23)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.11.0)
2
+
3
+ - Wait for Windows sysprep when cloning a Windows box
4
+ ([jcaugust:sysprep_wait](https://github.com/nsidc/vagrant-vsphere/pull/199)).
5
+ - Add a configurable timeout period for obtaining the VM's IP address
6
+ ([taliesins:wait-for-ip](https://github.com/nsidc/vagrant-vsphere/pull/204)).
7
+
1
8
  ## [1.10.1 (2016-10-17)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.10.1)
2
9
 
3
10
  - Update dependency on [rbvmomi](https://github.com/vmware/rbvmomi) to allow
data/Gemfile CHANGED
@@ -6,9 +6,7 @@ group :development do
6
6
  # We depend on Vagrant for development, but we don't add it as a
7
7
  # gem dependency because we expect to be installed within the
8
8
  # Vagrant environment itself using `vagrant plugin`.
9
-
10
- ruby '2.0.0'
11
- gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.8.1'
9
+ gem 'vagrant', github: 'mitchellh/vagrant'
12
10
  end
13
11
 
14
12
  group :plugins do
data/README.md CHANGED
@@ -19,9 +19,9 @@ This provider is built on top of the
19
19
  * libxml2, libxml2-dev, libxslt, libxslt-dev
20
20
 
21
21
  ## Current Version
22
- **version: 1.10.1**
22
+ **version: 1.11.0**
23
23
 
24
- vagrant-vsphere (**version: 1.10.1**) is available from
24
+ vagrant-vsphere (**version: 1.11.0**) is available from
25
25
  [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
26
26
 
27
27
  ## Installation
@@ -149,6 +149,8 @@ This provider has the following settings, all are required unless noted:
149
149
  for a target VM to be retrieved from the list of vm adapters on the host and filtered for a single legitimate
150
150
  adapter with a defined interface. An error will be raised if this filter is enabled and multiple valid
151
151
  adapters exist on a host.
152
+ * `ip_address_timeout` _ _Optional_ Maximum number of seconds to wait while an
153
+ IP address is obtained
152
154
 
153
155
  ### Cloning from a VM rather than a template
154
156
 
@@ -110,7 +110,8 @@ module VagrantPlugins
110
110
  b2.use PowerOn unless env[:result]
111
111
  end
112
112
  b.use CloseVSphere
113
- b.use WaitForCommunicator
113
+ b.use WaitForIPAddress
114
+ b.use WaitForCommunicator, [:running]
114
115
  b.use Provision
115
116
  b.use SyncedFolders
116
117
  b.use SetHostname
@@ -263,6 +264,7 @@ module VagrantPlugins
263
264
  autoload :MessageNotRunning, action_root.join('message_not_running')
264
265
  autoload :PowerOff, action_root.join('power_off')
265
266
  autoload :PowerOn, action_root.join('power_on')
267
+ autoload :WaitForIPAddress, action_root.join('wait_for_ip_address')
266
268
 
267
269
  # TODO: Remove the if guard when Vagrant 1.8.0 is the minimum version.
268
270
  # rubocop:disable IndentationWidth
@@ -34,12 +34,26 @@ module VagrantPlugins
34
34
  customization_info = get_customization_spec_info_by_name connection, machine
35
35
 
36
36
  spec[:customization] = get_customization_spec(machine, customization_info) unless customization_info.nil?
37
+
38
+ env[:ui].info "Setting custom address: #{config.addressType}" unless config.addressType.nil?
37
39
  add_custom_address_type(template, spec, config.addressType) unless config.addressType.nil?
40
+
41
+ env[:ui].info "Setting custom mac: #{config.mac}" unless config.mac.nil?
38
42
  add_custom_mac(template, spec, config.mac) unless config.mac.nil?
43
+
44
+ env[:ui].info "Setting custom vlan: #{config.vlan}" unless config.vlan.nil?
39
45
  add_custom_vlan(template, dc, spec, config.vlan) unless config.vlan.nil?
46
+
47
+ env[:ui].info "Setting custom memory: #{config.memory_mb}" unless config.memory_mb.nil?
40
48
  add_custom_memory(spec, config.memory_mb) unless config.memory_mb.nil?
49
+
50
+ env[:ui].info "Setting custom cpu count: #{config.cpu_count}" unless config.cpu_count.nil?
41
51
  add_custom_cpu(spec, config.cpu_count) unless config.cpu_count.nil?
52
+
53
+ env[:ui].info "Setting custom cpu reservation: #{config.cpu_reservation}" unless config.cpu_reservation.nil?
42
54
  add_custom_cpu_reservation(spec, config.cpu_reservation) unless config.cpu_reservation.nil?
55
+
56
+ env[:ui].info "Setting custom memmory reservation: #{config.mem_reservation}" unless config.mem_reservation.nil?
43
57
  add_custom_mem_reservation(spec, config.mem_reservation) unless config.mem_reservation.nil?
44
58
  add_custom_extra_config(spec, config.extra_config) unless config.extra_config.empty?
45
59
  add_custom_notes(spec, config.notes) unless config.notes.nil?
@@ -71,7 +85,6 @@ module VagrantPlugins
71
85
  new_vm = apply_sr_result.vm
72
86
 
73
87
  else
74
-
75
88
  env[:ui].info I18n.t('vsphere.creating_cloned_vm')
76
89
  env[:ui].info " -- #{config.clone_from_vm ? 'Source' : 'Template'} VM: #{template.pretty_path}"
77
90
  env[:ui].info " -- Target VM: #{vm_base_folder.pretty_path}/#{name}"
@@ -79,6 +92,7 @@ module VagrantPlugins
79
92
  new_vm = template.CloneVM_Task(folder: vm_base_folder, name: name, spec: spec).wait_for_completion
80
93
 
81
94
  config.custom_attributes.each do |k, v|
95
+ env[:ui].info "Setting custom attribute: #{k}=#{v}"
82
96
  new_vm.setCustomValue(key: k, value: v)
83
97
  end
84
98
  end
@@ -92,6 +106,8 @@ module VagrantPlugins
92
106
 
93
107
  machine.id = new_vm.config.uuid
94
108
 
109
+ wait_for_sysprep(env, new_vm, connection, 600, 10) if machine.config.vm.guest.eql?(:windows)
110
+
95
111
  env[:ui].info I18n.t('vsphere.vm_clone_success')
96
112
 
97
113
  @app.call env
@@ -99,6 +115,37 @@ module VagrantPlugins
99
115
 
100
116
  private
101
117
 
118
+ def wait_for_sysprep(env, vm, vim_connection, timeout, sleep_time)
119
+ vem = vim_connection.serviceContent.eventManager
120
+
121
+ wait = true
122
+ waited_seconds = 0
123
+
124
+ env[:ui].info I18n.t('vsphere.wait_sysprep')
125
+ while wait
126
+ events = query_customization_succeeded(vm, vem)
127
+
128
+ if events.size > 0
129
+ events.each do |e|
130
+ env[:ui].info e.fullFormattedMessage
131
+ end
132
+ wait = false
133
+ elsif waited_seconds >= timeout
134
+ fail Errors::VSphereError, :'sysprep_timeout'
135
+ else
136
+ sleep(sleep_time)
137
+ waited_seconds += sleep_time
138
+ end
139
+ end
140
+ end
141
+
142
+ def query_customization_succeeded(vm, vem)
143
+ vem.QueryEvents(filter:
144
+ RbVmomi::VIM::EventFilterSpec(entity:
145
+ RbVmomi::VIM::EventFilterSpecByEntity(entity: vm, recursion:
146
+ RbVmomi::VIM::EventFilterSpecRecursionOption(:self)), eventTypeId: ['CustomizationSucceeded']))
147
+ end
148
+
102
149
  def get_customization_spec(machine, spec_info)
103
150
  customization_spec = spec_info.spec.clone
104
151
 
@@ -9,7 +9,7 @@ module VagrantPlugins
9
9
  end
10
10
 
11
11
  def call(env)
12
- env[:vSphere_connection].close
12
+ env[:vSphere_connection].close if env && env[:vSphere_connection]
13
13
  @app.call env
14
14
  rescue Errors::VSphereError
15
15
  raise
@@ -0,0 +1,58 @@
1
+ require 'ipaddr'
2
+ require 'timeout'
3
+
4
+ module VagrantPlugins
5
+ module VSphere
6
+ module Action
7
+ class WaitForIPAddress
8
+ def initialize(app, _env)
9
+ @app = app
10
+ @logger = Log4r::Logger.new('vagrant::vsphere::wait_for_ip_addr')
11
+ end
12
+
13
+ def call(env)
14
+ timeout = env[:machine].provider_config.ip_address_timeout
15
+
16
+ env[:ui].output('Waiting for the machine to report its IP address...')
17
+ env[:ui].detail("Timeout: #{timeout} seconds")
18
+
19
+ guest_ip = nil
20
+ Timeout.timeout(timeout) do
21
+ loop do
22
+ # If a ctrl-c came through, break out
23
+ return if env[:interrupted]
24
+
25
+ guest_ip = nil
26
+
27
+ if env[:machine].state.id == :running
28
+ ssh_info = env[:machine].ssh_info
29
+ guest_ip = ssh_info[:host] unless ssh_info.nil?
30
+ end
31
+
32
+ if guest_ip
33
+ begin
34
+ IPAddr.new(guest_ip)
35
+ break
36
+ rescue IPAddr::InvalidAddressError
37
+ # Ignore, continue looking.
38
+ @logger.warn("Invalid IP address returned: #{guest_ip}")
39
+ end
40
+ end
41
+
42
+ sleep 1
43
+ end
44
+ end
45
+
46
+ # If we were interrupted then return now
47
+ return if env[:interrupted]
48
+
49
+ env[:ui].detail("IP: #{guest_ip}")
50
+
51
+ @app.call(env)
52
+ rescue Timeout::Error
53
+ raise Errors::VSphereError, :wait_for_ip_address_timeout
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -3,6 +3,7 @@ require 'vagrant'
3
3
  module VagrantPlugins
4
4
  module VSphere
5
5
  class Config < Vagrant.plugin('2', :config)
6
+ attr_accessor :ip_address_timeout # Time to wait for an IP address when booting, in seconds @return [Integer]
6
7
  attr_accessor :host
7
8
  attr_accessor :insecure
8
9
  attr_accessor :user
@@ -33,10 +34,15 @@ module VagrantPlugins
33
34
  attr_reader :custom_attributes
34
35
 
35
36
  def initialize
37
+ @ip_address_timeout = UNSET_VALUE
36
38
  @custom_attributes = {}
37
39
  @extra_config = {}
38
40
  end
39
41
 
42
+ def finalize!
43
+ @ip_address_timeout = 240 if @ip_address_timeout == UNSET_VALUE
44
+ end
45
+
40
46
  def custom_attribute(key, value)
41
47
  @custom_attributes[key.to_sym] = value
42
48
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VSphere
3
- VERSION = '1.10.1'
3
+ VERSION = '1.11.0'
4
4
  end
5
5
  end
@@ -20,6 +20,8 @@ en:
20
20
  The VM has not been created
21
21
  vm_not_running: |-
22
22
  The VM is not running
23
+ wait_sysprep: |-
24
+ Waiting for sysprep
23
25
 
24
26
  errors:
25
27
  missing_template: |-
@@ -48,6 +50,10 @@ en:
48
50
  Cannot use Linked Clone with Storage DRS
49
51
  multiple_interface_with_real_nic_ip_set: |-
50
52
  real_nic_ip filtering set with multiple valid VM interfaces available
53
+ sysprep_timeout: |-
54
+ Customization of VM not succeeded within timeout.
55
+ wait_for_ip_address_timeout: |-
56
+ Timeout while waiting for ip address
51
57
 
52
58
  config:
53
59
  host: |-
@@ -25,6 +25,8 @@ describe VagrantPlugins::VSphere::Action do
25
25
  end
26
26
 
27
27
  it 'should check if the VM exits' do
28
+ @machine.state.stub(:id).and_return(:running)
29
+
28
30
  VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
29
31
 
30
32
  run_up
@@ -65,6 +65,7 @@ RSpec.configure do |config|
65
65
  custom_attributes: {},
66
66
  notes: nil,
67
67
  extra_config: {},
68
+ ip_address_timeout: 1,
68
69
  real_nic_ip: false)
69
70
  vm_config = double(
70
71
  vm: double('config_vm',
@@ -75,7 +76,8 @@ RSpec.configure do |config|
75
76
  communicator: nil,
76
77
  networks: [[:private_network, { ip: '0.0.0.0' }]],
77
78
  boot_timeout: 1,
78
- graceful_halt_timeout: 0.1),
79
+ graceful_halt_timeout: 0.1,
80
+ guest: nil),
79
81
  validate: []
80
82
  )
81
83
  @app = double 'app', call: true
@@ -84,7 +86,7 @@ RSpec.configure do |config|
84
86
  :config => vm_config,
85
87
  :state => double('state', id: nil),
86
88
  :communicate => double('communicator', :wait_for_ready => true, :ready? => true),
87
- :ssh_info => {},
89
+ :ssh_info => { :host => IP_ADDRESS },
88
90
  :data_dir => Pathname.new(''),
89
91
  :id => nil,
90
92
  :id= => nil,
@@ -92,7 +94,7 @@ RSpec.configure do |config|
92
94
 
93
95
  @env = {
94
96
  machine: @machine,
95
- ui: double('ui', info: nil, output: nil)
97
+ ui: double('ui', info: nil, output: nil, detail: nil)
96
98
  }
97
99
 
98
100
  @vm = double('vm',
metadata CHANGED
@@ -1,137 +1,137 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Grauch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-17 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rbvmomi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.8.2
34
- - - <
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: 2.0.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.8.2
44
- - - <
44
+ - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 2.0.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: i18n
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.6.4
54
- - - <
54
+ - - "<"
55
55
  - !ruby/object:Gem::Version
56
56
  version: 0.8.0
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: 0.6.4
64
- - - <
64
+ - - "<"
65
65
  - !ruby/object:Gem::Version
66
66
  version: 0.8.0
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: rake
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rspec-core
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - '>='
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rspec-expectations
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - '>='
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: rspec-mocks
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - '>='
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: rubocop
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ~>
127
+ - - "~>"
128
128
  - !ruby/object:Gem::Version
129
129
  version: 0.32.1
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ~>
134
+ - - "~>"
135
135
  - !ruby/object:Gem::Version
136
136
  version: 0.32.1
137
137
  description: Enables Vagrant to manage machines with VMWare vSphere.
@@ -141,11 +141,11 @@ executables: []
141
141
  extensions: []
142
142
  extra_rdoc_files: []
143
143
  files:
144
- - .bumpversion.cfg
145
- - .gitignore
146
- - .rubocop.yml
147
- - .rubocop_todo.yml
148
- - .travis.yml
144
+ - ".bumpversion.cfg"
145
+ - ".gitignore"
146
+ - ".rubocop.yml"
147
+ - ".rubocop_todo.yml"
148
+ - ".travis.yml"
149
149
  - CHANGELOG.md
150
150
  - DEVELOPMENT.md
151
151
  - Gemfile
@@ -171,6 +171,7 @@ files:
171
171
  - lib/vSphere/action/snapshot_list.rb
172
172
  - lib/vSphere/action/snapshot_restore.rb
173
173
  - lib/vSphere/action/snapshot_save.rb
174
+ - lib/vSphere/action/wait_for_ip_address.rb
174
175
  - lib/vSphere/cap/public_address.rb
175
176
  - lib/vSphere/cap/snapshot_list.rb
176
177
  - lib/vSphere/config.rb
@@ -203,12 +204,12 @@ require_paths:
203
204
  - lib
204
205
  required_ruby_version: !ruby/object:Gem::Requirement
205
206
  requirements:
206
- - - '>='
207
+ - - ">="
207
208
  - !ruby/object:Gem::Version
208
209
  version: '0'
209
210
  required_rubygems_version: !ruby/object:Gem::Requirement
210
211
  requirements:
211
- - - '>='
212
+ - - ">="
212
213
  - !ruby/object:Gem::Version
213
214
  version: '0'
214
215
  requirements: []