fog-vsphere 1.10.0 → 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: db0f780c6c5076000b2b57254b785e90146d45e7
4
- data.tar.gz: 2e4c439a77c42da160a258f34b71902f42ae7231
3
+ metadata.gz: ce99898828f010893cf231e4848df2e606ca70c8
4
+ data.tar.gz: ddab6c8da05931d2c347d96c7f6f3b4490577780
5
5
  SHA512:
6
- metadata.gz: 3afe86e14e6bea538af974ad4015d0f7d3bba74f9c17473a4e71bc96e3ed5274acd053f075b7b6095cd591f6871daa3090015464fa3e2bf054cbaa8f87e09d06
7
- data.tar.gz: 0ad8e324e32505f43950450efdab85ff466eb77943f3a2ec8ab01e1b5a37a8c5b998eedb5f1a7cc01776fa0e8b724bca5709866a1879b4f4328feb85d00a911e
6
+ metadata.gz: f45ddf72f15fc715f45cfbfa3ee2091817cadeaca315b281febd7b41ab0690a4d7844781a18ed26d0d95fbbdf09e07ae51fbb919686b61c65c03b920a049223c
7
+ data.tar.gz: a796b42151696961fb6c2f743f6a860b3ff221aff22715eaad57cc14a660e0d67042b292c2550c366a5986b9bdafd0de4110589189f810af93567e7e02666638
@@ -1,3 +1,11 @@
1
+ ## v1.11.0
2
+
3
+ * Add ability to query subresource pools
4
+ * Fix `snapshots.get(id)` when no snapshot is found
5
+ * Add `vm_remove_snapshot` request, use in `snapshot.destroy`
6
+ * Fix `snapshots.get` for non-root snapshot
7
+ * Add `vm_revert_snapshot` request and `revert` method to `snapshot`
8
+
1
9
  ## v1.10.0
2
10
 
3
11
  * Add request to rename VM
@@ -74,4 +74,5 @@
74
74
  * karimb <karimboumedhel@gmail.com>
75
75
  * milo_cheung <milo.cheung@appcara.com>
76
76
  * slivik <jakub.sliva@gmail.com>
77
+ * theOpenBit <theopenbit@users.noreply.github.com>
77
78
  * tipt0e <topo-2@charter.net>
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'fog-vsphere'
8
8
  spec.version = Fog::Vsphere::VERSION
9
9
  spec.authors = ['J.R. Garcia']
10
- spec.email = ['jrg@vmware.com']
10
+ spec.email = ['jr@garciaole.com']
11
11
 
12
12
  spec.summary = "Module for the 'fog' gem to support VMware vSphere."
13
13
  spec.description = 'This library can be used as a module for `fog` or as standalone provider to use vSphere in applications.'
@@ -121,6 +121,8 @@ module Fog
121
121
  request :destroy_group
122
122
  request :get_host
123
123
  request :modify_vm_controller
124
+ request :vm_revert_snapshot
125
+ request :vm_remove_snapshot
124
126
 
125
127
  module Shared
126
128
  attr_reader :vsphere_is_vcenter
@@ -29,6 +29,15 @@ module Fog
29
29
  return self if ref == snapshot_ref
30
30
  child_snapshots().get(snapshot_ref)
31
31
  end
32
+
33
+ def revert
34
+ service.vm_revert_snapshot server_id, ref
35
+ end
36
+
37
+ def destroy(remove_children = false)
38
+ requires :server_id, :ref
39
+ service.vm_remove_snapshot(server_id, ref, remove_children)
40
+ end
32
41
  end
33
42
  end
34
43
  end
@@ -19,7 +19,11 @@ module Fog
19
19
  end
20
20
 
21
21
  def get(snapshot_ref)
22
- all.find { |snapshot| snapshot.get_child(snapshot_ref) }
22
+ all.each do |snapshot|
23
+ snapshot = snapshot.get_child(snapshot_ref)
24
+ return snapshot if snapshot
25
+ end
26
+ nil
23
27
  end
24
28
  end
25
29
  end
@@ -32,7 +32,8 @@ module Fog
32
32
  :snapshot_name_chain =>
33
33
  "#{parent_snap.snapshot_name_chain}/#{snap_tree.name}",
34
34
  :ref_chain =>
35
- "#{parent_snap.ref_chain}/#{snap_tree.snapshot._ref}"
35
+ "#{parent_snap.ref_chain}/#{snap_tree.snapshot._ref}",
36
+ :server_id => parent_snap.server_id
36
37
  }
37
38
  end
38
39
  end
@@ -15,13 +15,32 @@ module Fog
15
15
 
16
16
  # root ResourcePool + Children if they exists
17
17
  def list_raw_resource_pools(cluster)
18
- [cluster.resourcePool, cluster.resourcePool.resourcePool].flatten
18
+ pools = []
19
+ traverse_raw_resource_pools(pools, cluster.resourcePool)
20
+ pools.uniq
19
21
  end
20
22
 
21
- def resource_pool_attributes resource_pool, cluster, datacenter
23
+ def traverse_raw_resource_pools(pools, rp)
24
+ if rp
25
+ if rp.respond_to? :resourcePool
26
+ traverse_raw_resource_pools(pools, rp.resourcePool)
27
+ end
28
+ if rp.respond_to? :each
29
+ rp.each do |resourcePool|
30
+ traverse_raw_resource_pools(pools, resourcePool)
31
+ end
32
+ else
33
+ pools << rp
34
+ end
35
+ end
36
+ end
37
+
38
+ def resource_pool_attributes(resource_pool, cluster, datacenter)
39
+ name = folder_path(resource_pool).gsub(/^.*Resources(\/|)/,'')
40
+ name = 'Resources' if name.empty?
22
41
  {
23
42
  :id => managed_obj_id(resource_pool),
24
- :name => resource_pool.name,
43
+ :name => name,
25
44
  :configured_memory_mb => resource_pool.summary.configuredMemoryMB,
26
45
  :overall_status => resource_pool.overallStatus,
27
46
  :cluster => cluster,
@@ -29,6 +48,7 @@ module Fog
29
48
  }
30
49
  end
31
50
  end
51
+
32
52
  class Mock
33
53
  def list_resource_pools(filters = { })
34
54
  end
@@ -31,7 +31,8 @@ module Fog
31
31
  :mo_ref => snap_tree.snapshot,
32
32
  :tree_node => snap_tree,
33
33
  :ref_chain => "#{vm_id}/#{snap_tree.snapshot._ref}",
34
- :snapshot_name_chain => "#{vm_id}/#{snap_tree.name}"
34
+ :snapshot_name_chain => "#{vm_id}/#{snap_tree.name}",
35
+ :server_id => vm_id
35
36
  }
36
37
  end
37
38
  end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def vm_remove_snapshot(vm_id, snapshot_id, remove_children = false)
6
+ vm = servers.get(vm_id)
7
+ snapshot = vm.snapshots.get(snapshot_id).mo_ref
8
+ task = snapshot.RemoveSnapshot_Task(:removeChildren => remove_children)
9
+
10
+ task.wait_for_completion
11
+
12
+ {
13
+ 'task_state' => task.info.state,
14
+ 'was_cancelled' => task.info.cancelled
15
+ }
16
+ end
17
+ end
18
+
19
+ class Mock
20
+ def vm_remove_snapshot(vm_id, snapshot_id)
21
+ {
22
+ 'task_state' => 'success',
23
+ 'was_cancelled' => false
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ def vm_revert_snapshot(vm_id, snapshot_id)
6
+ vm = servers.get(vm_id)
7
+ snapshot = vm.snapshots.get(snapshot_id).mo_ref
8
+ task = snapshot.RevertToSnapshot_Task
9
+
10
+ task.wait_for_completion
11
+
12
+ {
13
+ 'task_state' => task.info.state,
14
+ 'was_cancelled' => task.info.cancelled
15
+ }
16
+ end
17
+ end
18
+
19
+ class Mock
20
+ def vm_revert_snapshot(vm_id, snapshot_id)
21
+ {
22
+ 'task_state' => 'success',
23
+ 'was_cancelled' => false
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '1.10.0'.freeze
3
+ VERSION = '1.11.0'.freeze
4
4
  end
5
5
  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.10.0
4
+ version: 1.11.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-05-22 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -125,7 +125,7 @@ dependencies:
125
125
  description: This library can be used as a module for `fog` or as standalone provider
126
126
  to use vSphere in applications.
127
127
  email:
128
- - jrg@vmware.com
128
+ - jr@garciaole.com
129
129
  executables: []
130
130
  extensions: []
131
131
  extra_rdoc_files: []
@@ -251,7 +251,9 @@ 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_remove_snapshot.rb
254
255
  - lib/fog/vsphere/requests/compute/vm_rename.rb
256
+ - lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb
255
257
  - lib/fog/vsphere/requests/compute/vm_suspend.rb
256
258
  - lib/fog/vsphere/requests/compute/vm_take_snapshot.rb
257
259
  - lib/fog/vsphere/version.rb