fog-vsphere 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -3
- data/CHANGELOG.md +5 -0
- data/lib/fog/vsphere/compute.rb +1 -0
- data/lib/fog/vsphere/models/compute/server.rb +6 -0
- data/lib/fog/vsphere/requests/compute/vm_suspend.rb +54 -0
- data/lib/fog/vsphere/version.rb +1 -1
- data/tests/models/compute/server_tests.rb +1 -1
- data/tests/requests/compute/vm_suspend_tests.rb +23 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d2a460b175971c18ddb06c47d33cc5e4d5a099e
|
4
|
+
data.tar.gz: f62a8ae39ab07aac91a035a62ab5c3bdbfe896fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29a92d9093e495a578fe28dffc698fa3c0f6cb8288f2470abceb4dc0becde7233a909b8004a22bab7db880191019f595ff457431ad8d6baf5e43bd0f8f17d993
|
7
|
+
data.tar.gz: cf4faa5926d2f6572faafc2cb2da2e65dcf3cb6185062f66d10cc8cf29d0e3035e5fdef8161bb6f0c0fc9710bae66237be63271134a22685af12e38fe8fa49fe
|
data/.travis.yml
CHANGED
@@ -10,11 +10,13 @@ matrix:
|
|
10
10
|
gemfile: gemfiles/Gemfile.1.9.2+
|
11
11
|
- rvm: 2.0.0
|
12
12
|
gemfile: Gemfile
|
13
|
-
- rvm: 2.1.
|
13
|
+
- rvm: 2.1.10
|
14
14
|
gemfile: Gemfile
|
15
|
-
- rvm: 2.
|
15
|
+
- rvm: 2.2.6
|
16
16
|
gemfile: Gemfile
|
17
|
-
- rvm: 2.
|
17
|
+
- rvm: 2.3.3
|
18
|
+
gemfile: Gemfile
|
19
|
+
- rvm: 2.4.0
|
18
20
|
gemfile: Gemfile
|
19
21
|
- rvm: jruby-19mode
|
20
22
|
gemfile: gemfiles/Gemfile.1.9.2+
|
data/CHANGELOG.md
CHANGED
data/lib/fog/vsphere/compute.rb
CHANGED
@@ -101,6 +101,12 @@ module Fog
|
|
101
101
|
service.vm_power_off('instance_uuid' => instance_uuid, 'force' => options[:force])
|
102
102
|
end
|
103
103
|
|
104
|
+
def suspend(options = {})
|
105
|
+
options = { :force => !tools_installed? || !tools_running? }.merge(options)
|
106
|
+
requires :instance_uuid
|
107
|
+
service.vm_suspend('instance_uuid' => instance_uuid, 'force' => options[:force])
|
108
|
+
end
|
109
|
+
|
104
110
|
def reboot(options = {})
|
105
111
|
options = { :force => false }.merge(options)
|
106
112
|
requires :instance_uuid
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Vsphere
|
4
|
+
class Real
|
5
|
+
def vm_suspend(options = {})
|
6
|
+
raise(ArgumentError, 'instance_uuid is a required parameter') unless options.key?('instance_uuid')
|
7
|
+
options = { 'force' => false }.merge(options)
|
8
|
+
|
9
|
+
search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
|
10
|
+
vm = @connection.searchIndex.FindAllByUuid(search_filter).first
|
11
|
+
|
12
|
+
if options['force']
|
13
|
+
suspend_forcefully(vm)
|
14
|
+
else
|
15
|
+
suspend_gracefully(vm)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def suspend_forcefully(vm)
|
22
|
+
task = vm.SuspendVM_Task
|
23
|
+
task.wait_for_completion
|
24
|
+
{
|
25
|
+
'task_state' => task.info.result,
|
26
|
+
'suspend_type' => 'suspend'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def suspend_gracefully(vm)
|
31
|
+
vm.StandbyGuest
|
32
|
+
{
|
33
|
+
'task_state' => 'running',
|
34
|
+
'suspend_type' => 'standby_guest'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Mock
|
40
|
+
def vm_suspend(options = {})
|
41
|
+
raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
|
42
|
+
|
43
|
+
vm = get_virtual_machine(options['instance_uuid'])
|
44
|
+
vm['power_state'] = 'suspended'
|
45
|
+
|
46
|
+
{
|
47
|
+
'task_state' => 'running',
|
48
|
+
'suspend_type' => options['force'] ? 'suspend' : 'standby_guest'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/fog/vsphere/version.rb
CHANGED
@@ -5,7 +5,7 @@ Shindo.tests('Fog::Compute[:vsphere] | server model', ['vsphere']) do
|
|
5
5
|
tests('The server model should') do
|
6
6
|
tests('have the action') do
|
7
7
|
test('reload') { server.respond_to? 'reload' }
|
8
|
-
%w
|
8
|
+
%w(stop start suspend destroy reboot).each do |action|
|
9
9
|
test(action) { server.respond_to? action }
|
10
10
|
test("#{action} returns successfully") { server.send(action.to_sym) ? true : false }
|
11
11
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:vsphere] | vm_suspend request', ['vsphere']) do
|
2
|
+
compute = Fog::Compute[:vsphere]
|
3
|
+
powered_on_vm = '5032c8a5-9c5e-ba7a-3804-832a03e16381'
|
4
|
+
|
5
|
+
tests('The response should') do
|
6
|
+
response = compute.vm_suspend('instance_uuid' => powered_on_vm)
|
7
|
+
test('be a kind of Hash') { response.is_a?(Hash) }
|
8
|
+
test('should have a task_state key') { response.key? 'task_state' }
|
9
|
+
test('should have a suspend_type key') { response.key? 'suspend_type' }
|
10
|
+
end
|
11
|
+
|
12
|
+
# When forcing the shutdown, we expect the result to be
|
13
|
+
{ true => 'suspend', false => 'standby_guest' }.each do |force, expected|
|
14
|
+
tests("When 'force' => #{force}") do
|
15
|
+
response = compute.vm_suspend('instance_uuid' => powered_on_vm, 'force' => force)
|
16
|
+
test('should return suspend_type of #{expected}') { response['suspend_type'] == expected }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
tests('The expected options') do
|
21
|
+
raises(ArgumentError, 'raises ArgumentError when instance_uuid option is missing') { compute.vm_suspend }
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-vsphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J.R. Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -251,6 +251,7 @@ files:
|
|
251
251
|
- lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb
|
252
252
|
- lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb
|
253
253
|
- lib/fog/vsphere/requests/compute/vm_reconfig_volumes.rb
|
254
|
+
- lib/fog/vsphere/requests/compute/vm_suspend.rb
|
254
255
|
- lib/fog/vsphere/requests/compute/vm_take_snapshot.rb
|
255
256
|
- lib/fog/vsphere/version.rb
|
256
257
|
- tests/class_from_string_tests.rb
|
@@ -290,6 +291,7 @@ files:
|
|
290
291
|
- tests/requests/compute/vm_reconfig_cpus_tests.rb
|
291
292
|
- tests/requests/compute/vm_reconfig_hardware_tests.rb
|
292
293
|
- tests/requests/compute/vm_reconfig_memory_tests.rb
|
294
|
+
- tests/requests/compute/vm_suspend_tests.rb
|
293
295
|
- tests/requests/compute/vm_take_snapshot_tests.rb
|
294
296
|
homepage: https://github.com/fog/fog-vsphere
|
295
297
|
licenses:
|
@@ -353,4 +355,5 @@ test_files:
|
|
353
355
|
- tests/requests/compute/vm_reconfig_cpus_tests.rb
|
354
356
|
- tests/requests/compute/vm_reconfig_hardware_tests.rb
|
355
357
|
- tests/requests/compute/vm_reconfig_memory_tests.rb
|
358
|
+
- tests/requests/compute/vm_suspend_tests.rb
|
356
359
|
- tests/requests/compute/vm_take_snapshot_tests.rb
|