vagrant-vsphere 1.12.1 → 1.13.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: ebe9f0396290f0413d0752d2d97266dd4b7bdda8
4
- data.tar.gz: 815e05d6f5ba00a7b8ed805e11508656dc769d07
3
+ metadata.gz: '02349de22aa61f900e082d22099a5010bf77c1fd'
4
+ data.tar.gz: f3cd646a826ef3deb077a2e123992dbc8dc6ef8a
5
5
  SHA512:
6
- metadata.gz: 3cec1f42099820c8e7c6e1c0c88d151aabbca18a69ca0d5849cbaa39b30540d621554ae8b2da601925fce8f4b838c67ea0e9534a389e9a9b2fe2b32d6ad6bec0
7
- data.tar.gz: ecbd3ac119f4605d14e16bccab73d4831953283ef2c98c83a19f82b13134cfc5f05288a7219814f5a7ecdcb0736e3adfb21b1fa6232a437550d8ced4c1197d1f
6
+ metadata.gz: 3b4789843ce0833dd2d510b17a8ed5fc13328410e5f0c17518a87749b303fd58cd3e40ec1542f4abbb7982d05b613c2b164088e614010faf9931d440086fff6d
7
+ data.tar.gz: 87f956a7410bde5568d37187af7569733e5eec5ab63b7eb1dc471ce237149c834b9dc06a414049bce5a003921beb9f2e6a3bf6ca9c1899314df1ab59a14e45e3
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 1.12.1
2
+ current_version = 1.13.0
3
3
  tag = true
4
4
  commit = true
5
5
 
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.5
data/.travis.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.2.3
4
+ - 2.3.5
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.12.5'
9
+ - gem install bundler --version '1.15.4'
10
10
 
11
11
  sudo: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [1.13.0 (2017-11-06)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.13.0)
2
+
3
+ - Add support for the commands
4
+ [`suspend`](https://www.vagrantup.com/docs/cli/suspend.html) and
5
+ [`resume`](https://www.vagrantup.com/docs/cli/resume.html).
6
+
1
7
  ## [1.12.1 (2017-03-07)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.12.1)
2
8
 
3
9
  - If no valid adapters can be found on a host when using the `real_nic_ip`
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gemspec
4
-
5
3
  group :development do
6
4
  # We depend on Vagrant for development, but we don't add it as a
7
5
  # gem dependency because we expect to be installed within the
@@ -10,5 +8,5 @@ group :development do
10
8
  end
11
9
 
12
10
  group :plugins do
13
- gem 'vagrant-vsphere', path: '.'
11
+ gemspec
14
12
  end
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.12.1**
22
+ **version: 1.13.0**
23
23
 
24
- vagrant-vsphere (**version: 1.12.1**) is available from
24
+ vagrant-vsphere (**version: 1.13.0**) is available from
25
25
  [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
26
26
 
27
27
  ## Installation
@@ -157,6 +157,52 @@ module VagrantPlugins
157
157
  end
158
158
  end
159
159
 
160
+ def self.action_resume
161
+ Vagrant::Action::Builder.new.tap do |b|
162
+ b.use ConfigValidate
163
+ b.use ConnectVSphere
164
+ b.use Call, IsCreated do |env, b2|
165
+ unless env[:result]
166
+ b2.use MessageNotCreated
167
+ next
168
+ end
169
+
170
+ b2.use Call, IsSuspended do |env2, b3|
171
+ unless env2[:result]
172
+ b3.use MessageNotSuspended
173
+ next
174
+ end
175
+
176
+ b3.use Resume
177
+ end
178
+ end
179
+ b.use CloseVSphere
180
+ end
181
+ end
182
+
183
+ def self.action_suspend
184
+ Vagrant::Action::Builder.new.tap do |b|
185
+ b.use ConfigValidate
186
+ b.use ConnectVSphere
187
+ b.use Call, IsCreated do |env, b2|
188
+ unless env[:result]
189
+ b2.use MessageNotCreated
190
+ next
191
+ end
192
+
193
+ b2.use Call, IsRunning do |env2, b3|
194
+ unless env2[:result]
195
+ b3.use MessageNotRunning
196
+ next
197
+ end
198
+
199
+ b3.use Suspend
200
+ end
201
+ end
202
+ b.use CloseVSphere
203
+ end
204
+ end
205
+
160
206
  # vSphere specific actions
161
207
  def self.action_get_state
162
208
  Vagrant::Action::Builder.new.tap do |b|
@@ -259,11 +305,15 @@ module VagrantPlugins
259
305
  autoload :GetState, action_root.join('get_state')
260
306
  autoload :IsCreated, action_root.join('is_created')
261
307
  autoload :IsRunning, action_root.join('is_running')
308
+ autoload :IsSuspended, action_root.join('is_suspended')
262
309
  autoload :MessageAlreadyCreated, action_root.join('message_already_created')
263
310
  autoload :MessageNotCreated, action_root.join('message_not_created')
264
311
  autoload :MessageNotRunning, action_root.join('message_not_running')
312
+ autoload :MessageNotSuspended, action_root.join('message_not_suspended')
265
313
  autoload :PowerOff, action_root.join('power_off')
266
314
  autoload :PowerOn, action_root.join('power_on')
315
+ autoload :Resume, action_root.join('resume')
316
+ autoload :Suspend, action_root.join('suspend')
267
317
  autoload :WaitForIPAddress, action_root.join('wait_for_ip_address')
268
318
 
269
319
  # TODO: Remove the if guard when Vagrant 1.8.0 is the minimum version.
@@ -30,8 +30,9 @@ module VagrantPlugins
30
30
 
31
31
  if powered_on?(vm)
32
32
  :running
33
+ elsif suspended?(vm)
34
+ :suspended
33
35
  else
34
- # If the VM is powered off or suspended, we consider it to be powered off. A power on command will either turn on or resume the VM
35
36
  :poweroff
36
37
  end
37
38
  end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module VSphere
3
+ module Action
4
+ class IsSuspended
5
+ def initialize(app, _env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:result] = env[:machine].state.id == :suspended
11
+ @app.call env
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'i18n'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ module Action
6
+ class MessageNotSuspended
7
+ def initialize(app, _env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ env[:ui].info I18n.t('vsphere.vm_not_suspended')
13
+ @app.call(env)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ require 'rbvmomi'
2
+ require 'i18n'
3
+ require 'vSphere/util/vim_helpers'
4
+ require 'vSphere/util/vm_helpers'
5
+
6
+ module VagrantPlugins
7
+ module VSphere
8
+ module Action
9
+ class Resume
10
+ include Util::VimHelpers
11
+ include Util::VmHelpers
12
+
13
+ def initialize(app, _env)
14
+ @app = app
15
+ end
16
+
17
+ def call(env)
18
+ vm = get_vm_by_uuid env[:vSphere_connection], env[:machine]
19
+
20
+ if suspended?(vm)
21
+ env[:ui].info I18n.t('vsphere.resume_vm')
22
+ resume_vm(vm)
23
+ end
24
+
25
+ @app.call env
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ require 'rbvmomi'
2
+ require 'i18n'
3
+ require 'vSphere/util/vim_helpers'
4
+ require 'vSphere/util/vm_helpers'
5
+
6
+ module VagrantPlugins
7
+ module VSphere
8
+ module Action
9
+ class Suspend
10
+ include Util::VimHelpers
11
+ include Util::VmHelpers
12
+
13
+ def initialize(app, _env)
14
+ @app = app
15
+ end
16
+
17
+ def call(env)
18
+ vm = get_vm_by_uuid env[:vSphere_connection], env[:machine]
19
+
20
+ # Suspending is a no-op if we can't find the VM or it is already off
21
+ # or suspended
22
+ unless vm.nil? || suspended?(vm) || powered_off?(vm)
23
+ env[:ui].info I18n.t('vsphere.suspend_vm')
24
+ suspend_vm(vm)
25
+ end
26
+
27
+ @app.call env
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -18,6 +18,15 @@ module VagrantPlugins
18
18
  vm.PowerOffVM_Task.wait_for_completion
19
19
  end
20
20
 
21
+ # https://www.vmware.com/support/developer/converter-sdk/conv61_apireference/vim.VirtualMachine.html#powerOn
22
+ def resume_vm(vm)
23
+ vm.PowerOnVM_Task.wait_for_completion
24
+ end
25
+
26
+ def suspend_vm(vm)
27
+ vm.SuspendVM_Task.wait_for_completion
28
+ end
29
+
21
30
  def get_vm_state(vm)
22
31
  vm.runtime.powerState
23
32
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VSphere
3
- VERSION = '1.12.1'
3
+ VERSION = '1.13.0'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -14,12 +14,18 @@ en:
14
14
  Calling vSphere PowerOff
15
15
  power_on_vm: |-
16
16
  Calling vSphere PowerOn
17
+ resume_vm: |-
18
+ Calling vSphere PowerOn
19
+ suspend_vm: |-
20
+ Calling vSphere Suspend
17
21
  vm_already_created: |-
18
22
  The VM is already created
19
23
  vm_not_created: |-
20
24
  The VM has not been created
21
25
  vm_not_running: |-
22
26
  The VM is not running
27
+ vm_not_suspended: |-
28
+ The VM is not suspended
23
29
  wait_sysprep: |-
24
30
  Waiting for sysprep
25
31
 
data/spec/action_spec.rb CHANGED
@@ -164,4 +164,66 @@ describe VagrantPlugins::VSphere::Action do
164
164
  VagrantPlugins::VSphere::Action::MessageAlreadyCreated.any_instance.should_receive(:call)
165
165
  end
166
166
  end
167
+
168
+ describe 'suspend' do
169
+ it 'should connect to vSphere' do
170
+ VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
171
+ run :suspend
172
+ end
173
+
174
+ it 'should check if the VM exits' do
175
+ @machine.state.stub(:id).and_return(:running)
176
+ VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
177
+ run :suspend
178
+ end
179
+
180
+ it 'should suspend the VM when the VM is running' do
181
+ @machine.state.stub(:id).and_return(:running)
182
+ VagrantPlugins::VSphere::Action::Suspend.any_instance.should_receive(:call)
183
+ run :suspend
184
+ end
185
+
186
+ it 'should not suspend the VM when the VM is suspended' do
187
+ @machine.state.stub(:id).and_return(:suspended)
188
+ VagrantPlugins::VSphere::Action::Suspend.any_instance.should_not_receive(:call)
189
+ run :suspend
190
+ end
191
+
192
+ it 'should not suspend the VM when the VM is off' do
193
+ @machine.state.stub(:id).and_return(:poweroff)
194
+ VagrantPlugins::VSphere::Action::Suspend.any_instance.should_not_receive(:call)
195
+ run :suspend
196
+ end
197
+ end
198
+
199
+ describe 'resume' do
200
+ it 'should connect to vSphere' do
201
+ VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
202
+ run :resume
203
+ end
204
+
205
+ it 'should check if the VM exits' do
206
+ @machine.state.stub(:id).and_return(:suspended)
207
+ VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
208
+ run :resume
209
+ end
210
+
211
+ it 'should not resume the VM when the VM is running' do
212
+ @machine.state.stub(:id).and_return(:running)
213
+ VagrantPlugins::VSphere::Action::Resume.any_instance.should_not_receive(:call)
214
+ run :resume
215
+ end
216
+
217
+ it 'should resume the VM when the VM is suspended' do
218
+ @machine.state.stub(:id).and_return(:suspended)
219
+ VagrantPlugins::VSphere::Action::Resume.any_instance.should_receive(:call)
220
+ run :resume
221
+ end
222
+
223
+ it 'should not resume the VM when the VM is off' do
224
+ @machine.state.stub(:id).and_return(:poweroff)
225
+ VagrantPlugins::VSphere::Action::Resume.any_instance.should_not_receive(:call)
226
+ run :resume
227
+ end
228
+ end
167
229
  end
@@ -119,10 +119,11 @@ describe VagrantPlugins::VSphere::Action::GetSshInfo do
119
119
  context 'when the VM networking is uninitialized' do
120
120
  before do
121
121
  allow(@vm.guest).to receive(:net) { [] }
122
+ allow(@vm.guest).to receive(:ipAddress) { '123.234.156.78' }
122
123
  end
123
- it 'should set the ssh info to nil if no valid adapters are present' do
124
+ it 'should set the ssh info to the guest ipAddress and port 22 if no valid adapters are present' do
124
125
  call
125
- expect(@env[:machine_ssh_info]).to eq nil
126
+ expect(@env[:machine_ssh_info]).to eq(host: '123.234.156.78', port: 22)
126
127
  end
127
128
  end
128
129
  end
@@ -38,13 +38,13 @@ describe VagrantPlugins::VSphere::Action::GetState do
38
38
  expect(@env[:machine_state_id]).to be :poweroff
39
39
  end
40
40
 
41
- it 'should set state id to powered off if machine is suspended' do
41
+ it 'should set state id to suspended if machine is suspended' do
42
42
  @env[:machine].stub(:id).and_return(EXISTING_UUID)
43
43
  @vm.runtime.stub(:powerState).and_return(VagrantPlugins::VSphere::Util::VmState::SUSPENDED)
44
44
 
45
45
  call
46
46
 
47
- expect(@env[:machine_state_id]).to be :poweroff
47
+ expect(@env[:machine_state_id]).to be :suspended
48
48
  end
49
49
 
50
50
  it 'should call the next item in the middleware stack' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 1.13.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: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -145,6 +145,7 @@ files:
145
145
  - ".gitignore"
146
146
  - ".rubocop.yml"
147
147
  - ".rubocop_todo.yml"
148
+ - ".ruby-version"
148
149
  - ".travis.yml"
149
150
  - CHANGELOG.md
150
151
  - DEVELOPMENT.md
@@ -162,15 +163,19 @@ files:
162
163
  - lib/vSphere/action/get_state.rb
163
164
  - lib/vSphere/action/is_created.rb
164
165
  - lib/vSphere/action/is_running.rb
166
+ - lib/vSphere/action/is_suspended.rb
165
167
  - lib/vSphere/action/message_already_created.rb
166
168
  - lib/vSphere/action/message_not_created.rb
167
169
  - lib/vSphere/action/message_not_running.rb
170
+ - lib/vSphere/action/message_not_suspended.rb
168
171
  - lib/vSphere/action/power_off.rb
169
172
  - lib/vSphere/action/power_on.rb
173
+ - lib/vSphere/action/resume.rb
170
174
  - lib/vSphere/action/snapshot_delete.rb
171
175
  - lib/vSphere/action/snapshot_list.rb
172
176
  - lib/vSphere/action/snapshot_restore.rb
173
177
  - lib/vSphere/action/snapshot_save.rb
178
+ - lib/vSphere/action/suspend.rb
174
179
  - lib/vSphere/action/wait_for_ip_address.rb
175
180
  - lib/vSphere/cap/public_address.rb
176
181
  - lib/vSphere/cap/snapshot_list.rb
@@ -214,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
219
  version: '0'
215
220
  requirements: []
216
221
  rubyforge_project:
217
- rubygems_version: 2.4.7
222
+ rubygems_version: 2.5.2.1
218
223
  signing_key:
219
224
  specification_version: 4
220
225
  summary: VMWare vSphere provider