fog-vsphere 1.7.1 → 1.8.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: 63a4262cd25dd64e24bcf3d02231bc108a678e14
4
- data.tar.gz: bae6e27a2c111effe8440ceb4b308fb15190a792
3
+ metadata.gz: 6d2a460b175971c18ddb06c47d33cc5e4d5a099e
4
+ data.tar.gz: f62a8ae39ab07aac91a035a62ab5c3bdbfe896fd
5
5
  SHA512:
6
- metadata.gz: 47dcd8b6aa212d64564beee1d2a22bd64d38529fceccd4752baff6bde4cced8130792fefe29a145201a5ba9695f65abbebd25e969e68f69e95b339c2526b7679
7
- data.tar.gz: ff2a5bdb21167a04acd97a87fa756d25bf043009ade394c9cce5e8ea7934c429c39a956e4fa0fe6be881c6e94ad1cc7708024582dd35d2b0efd1bba69bbbcadc
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.0
13
+ - rvm: 2.1.10
14
14
  gemfile: Gemfile
15
- - rvm: 2.1.1
15
+ - rvm: 2.2.6
16
16
  gemfile: Gemfile
17
- - rvm: 2.2.0
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
@@ -1,3 +1,8 @@
1
+ ## v1.8.0
2
+
3
+ * Add `suspend` to server model
4
+ * Add `vm_suspend` to compute request
5
+
1
6
  ## v1.7.1
2
7
 
3
8
  * Send all options to VM migrate request
@@ -56,6 +56,7 @@ module Fog
56
56
  request :list_virtual_machines
57
57
  request :vm_power_off
58
58
  request :vm_power_on
59
+ request :vm_suspend
59
60
  request :vm_reboot
60
61
  request :vm_clone
61
62
  request :vm_destroy
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '1.7.1'
3
+ VERSION = '1.8.0'
4
4
  end
5
5
  end
@@ -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{ stop start destroy reboot }.each do |action|
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.7.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-02-22 00:00:00.000000000 Z
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