fog 1.35.0 → 1.36.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 +2 -0
- data/CHANGELOG.md +50 -0
- data/fog.gemspec +6 -6
- data/lib/fog/digitalocean/models/compute/server.rb +0 -1
- data/lib/fog/digitalocean/requests/compute_v2/create_ssh_key.rb +10 -8
- data/lib/fog/digitalocean/requests/compute_v2/delete_ssh_key.rb +5 -1
- data/lib/fog/digitalocean/requests/compute_v2/list_ssh_keys.rb +6 -1
- data/lib/fog/glesys/models/compute/server.rb +0 -1
- data/lib/fog/joyent/compute.rb +6 -1
- data/lib/fog/linode/compute.rb +3 -0
- data/lib/fog/linode/models/compute/data_center.rb +1 -0
- data/lib/fog/linode/models/compute/flavor.rb +3 -0
- data/lib/fog/linode/models/compute/flavors.rb +8 -1
- data/lib/fog/linode/models/compute/image.rb +2 -0
- data/lib/fog/linode/models/compute/images.rb +2 -1
- data/lib/fog/linode/models/compute/kernel.rb +3 -0
- data/lib/fog/linode/models/compute/kernels.rb +14 -8
- data/lib/fog/linode/models/compute/node_balancer_flavor.rb +13 -0
- data/lib/fog/linode/models/compute/node_balancer_flavors.rb +27 -0
- data/lib/fog/linode/requests/compute/avail_kernels.rb +17 -18
- data/lib/fog/linode/requests/compute/avail_linodeplans.rb +4 -2
- data/lib/fog/linode/requests/compute/avail_nodebalancers.rb +42 -0
- data/lib/fog/linode/requests/compute/avail_stackscripts.rb +6 -11
- data/lib/fog/openstack/core.rb +22 -21
- data/lib/fog/openstack/models/baremetal/nodes.rb +1 -1
- data/lib/fog/openstack/models/identity_v3/domain.rb +6 -0
- data/lib/fog/openstack/models/identity_v3/domains.rb +19 -4
- data/lib/fog/openstack/models/identity_v3/project.rb +10 -0
- data/lib/fog/openstack/models/identity_v3/projects.rb +16 -3
- data/lib/fog/openstack/models/identity_v3/tokens.rb +1 -0
- data/lib/fog/openstack/models/storage/file.rb +9 -0
- data/lib/fog/openstack/requests/baremetal/delete_node.rb +1 -1
- data/lib/fog/rackspace/requests/load_balancers/create_node.rb +1 -1
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/compute.rb +8 -0
- data/lib/fog/vsphere/models/compute/network.rb +1 -0
- data/lib/fog/vsphere/models/compute/process.rb +18 -0
- data/lib/fog/vsphere/models/compute/server.rb +29 -0
- data/lib/fog/vsphere/models/compute/snapshot.rb +35 -0
- data/lib/fog/vsphere/models/compute/snapshots.rb +27 -0
- data/lib/fog/vsphere/requests/compute/create_vm.rb +65 -2
- data/lib/fog/vsphere/requests/compute/list_child_snapshots.rb +71 -0
- data/lib/fog/vsphere/requests/compute/list_networks.rb +5 -4
- data/lib/fog/vsphere/requests/compute/list_processes.rb +41 -0
- data/lib/fog/vsphere/requests/compute/list_vm_snapshots.rb +66 -0
- data/lib/fog/vsphere/requests/compute/revert_to_snapshot.rb +30 -0
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -5
- data/lib/fog/vsphere/requests/compute/vm_take_snapshot.rb +37 -0
- data/lib/tasks/changelog_task.rb +1 -0
- data/spec/fog/openstack/identity_v3/authv3_a.yml +18 -18
- data/spec/fog/openstack/identity_v3/authv3_b.yml +18 -18
- data/spec/fog/openstack/identity_v3/authv3_c.yml +293 -55
- data/spec/fog/openstack/identity_v3/authv3_token.yml +89 -89
- data/spec/fog/openstack/identity_v3/authv3_unscoped.yml +325 -222
- data/spec/fog/openstack/identity_v3/authv3_unscoped_reauth.yml +587 -111
- data/spec/fog/openstack/identity_v3/common_setup.yml +30 -30
- data/spec/fog/openstack/identity_v3/idv3_credential.yml +17 -17
- data/spec/fog/openstack/identity_v3/idv3_credential_crud.yml +343 -106
- data/spec/fog/openstack/identity_v3/idv3_domain.yml +27 -122
- data/spec/fog/openstack/identity_v3/idv3_domain_crud.yml +75 -128
- data/spec/fog/openstack/identity_v3/idv3_domain_group_roles_mutation.yml +141 -141
- data/spec/fog/openstack/identity_v3/idv3_domain_roles_mutation.yml +326 -86
- data/spec/fog/openstack/identity_v3/idv3_endpoint.yml +221 -221
- data/spec/fog/openstack/identity_v3/idv3_endpoints_crud.yml +314 -314
- data/spec/fog/openstack/identity_v3/idv3_group_crud_mutation.yml +191 -188
- data/spec/fog/openstack/identity_v3/idv3_policy.yml +23 -23
- data/spec/fog/openstack/identity_v3/idv3_policy_crud.yml +67 -67
- data/spec/fog/openstack/identity_v3/idv3_project.yml +267 -161
- data/spec/fog/openstack/identity_v3/idv3_project_crud.yml +70 -145
- data/spec/fog/openstack/identity_v3/idv3_project_group_user_roles_mutation.yml +195 -243
- data/spec/fog/openstack/identity_v3/idv3_project_hier_crud_list.yml +203 -553
- data/spec/fog/openstack/identity_v3/idv3_role.yml +49 -49
- data/spec/fog/openstack/identity_v3/idv3_role_crud.yml +92 -92
- data/spec/fog/openstack/identity_v3/idv3_service.yml +61 -61
- data/spec/fog/openstack/identity_v3/idv3_services_crud.yml +111 -111
- data/spec/fog/openstack/identity_v3/idv3_token.yml +84 -84
- data/spec/fog/openstack/identity_v3/idv3_user_crud.yml +140 -125
- data/spec/fog/openstack/identity_v3/idv3_users.yml +98 -78
- data/spec/fog/openstack/network/common_setup.yml +84 -75
- data/spec/fog/openstack/network/subnets_crud.yml +75 -35
- data/spec/fog/openstack/shared_context.rb +5 -1
- data/tests/helper.rb +1 -0
- data/tests/linode/requests/compute/datacenter_tests.rb +2 -1
- data/tests/linode/requests/compute/kernel_tests.rb +2 -10
- data/tests/linode/requests/compute/linodeplans_tests.rb +10 -7
- data/tests/linode/requests/compute/nodebalancers_tests.rb +20 -0
- data/tests/openstack/models/storage/file_tests.rb +29 -0
- data/tests/rackspace/requests/load_balancers/node_tests.rb +7 -0
- data/tests/vsphere/models/compute/server_tests.rb +27 -1
- data/tests/vsphere/requests/compute/list_child_snapshots_tests.rb +10 -0
- data/tests/vsphere/requests/compute/list_vm_snapshots_tests.rb +10 -0
- data/tests/vsphere/requests/compute/revert_to_snapshot_tests.rb +15 -0
- data/tests/vsphere/requests/compute/vm_take_snapshot_tests.rb +19 -0
- metadata +41 -16
- data/spec/fog/openstack/identity_v3/authv3_project.yml +0 -98
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fog/compute/models/server'
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module Compute
|
|
5
|
+
class Vsphere
|
|
6
|
+
class Process < Fog::Model
|
|
7
|
+
attribute :cmd_line
|
|
8
|
+
attribute :end_time
|
|
9
|
+
attribute :exit_code
|
|
10
|
+
attribute :name
|
|
11
|
+
attribute :owner
|
|
12
|
+
attribute :pid
|
|
13
|
+
attribute :start_time
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
@@ -148,6 +148,11 @@ module Fog
|
|
|
148
148
|
new_vm
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
+
def take_snapshot(options = {})
|
|
152
|
+
requires :instance_uuid
|
|
153
|
+
service.vm_take_snapshot(options.merge('instance_uuid' => instance_uuid))
|
|
154
|
+
end
|
|
155
|
+
|
|
151
156
|
def ready?
|
|
152
157
|
power_state == "poweredOn"
|
|
153
158
|
end
|
|
@@ -213,6 +218,30 @@ module Fog
|
|
|
213
218
|
attributes[:volumes] ||= id.nil? ? [] : service.volumes(:server_id => self.id)
|
|
214
219
|
end
|
|
215
220
|
|
|
221
|
+
def snapshots(opts = {})
|
|
222
|
+
service.snapshots(server_id: self.id).all(opts)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def find_snapshot(snapshot_ref)
|
|
226
|
+
snapshots.get(snapshot_ref)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def revert_snapshot(snapshot)
|
|
230
|
+
case snapshot
|
|
231
|
+
when Snapshot
|
|
232
|
+
service.revert_to_snapshot(snapshot)
|
|
233
|
+
when String
|
|
234
|
+
service.revert_to_snapshot(find_snapshot(snapshot))
|
|
235
|
+
else
|
|
236
|
+
fail ArgumentError, "snapshot has to be kind of Snapshot or String class"
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def guest_processes(opts = {})
|
|
241
|
+
fail 'VM tools must be running' unless tools_running?
|
|
242
|
+
service.list_processes(self.id, opts)
|
|
243
|
+
end
|
|
244
|
+
|
|
216
245
|
def customvalues
|
|
217
246
|
attributes[:customvalues] ||= id.nil? ? [] : service.customvalues( :vm => self )
|
|
218
247
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'fog/compute/models/server'
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module Compute
|
|
5
|
+
class Vsphere
|
|
6
|
+
class Snapshot < Fog::Model
|
|
7
|
+
|
|
8
|
+
identity :ref
|
|
9
|
+
attribute :server_id
|
|
10
|
+
|
|
11
|
+
attribute :name
|
|
12
|
+
attribute :quiescedi, :default => false
|
|
13
|
+
attribute :description, :default => ''
|
|
14
|
+
attribute :create_time
|
|
15
|
+
attribute :power_state, :default => 'none'
|
|
16
|
+
attribute :ref
|
|
17
|
+
attribute :mo_ref
|
|
18
|
+
attribute :tree_node
|
|
19
|
+
attribute :snapshot_name_chain
|
|
20
|
+
attribute :ref_chain
|
|
21
|
+
|
|
22
|
+
def child_snapshots(filters = {})
|
|
23
|
+
service.snapshots(
|
|
24
|
+
{ :server_id => server_id, :parent_snapshot => self }.update(filters)
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_child(snapshot_ref)
|
|
29
|
+
return self if ref == snapshot_ref
|
|
30
|
+
child_snapshots().get(snapshot_ref)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'fog/core/collection'
|
|
2
|
+
require 'fog/vsphere/models/compute/snapshot'
|
|
3
|
+
|
|
4
|
+
module Fog
|
|
5
|
+
module Compute
|
|
6
|
+
class Vsphere
|
|
7
|
+
class Snapshots < Fog::Collection
|
|
8
|
+
attribute :server_id, alias: :instance_uuid
|
|
9
|
+
attribute :parent_snapshot
|
|
10
|
+
model Fog::Compute::Vsphere::Snapshot
|
|
11
|
+
|
|
12
|
+
def all(filters = {})
|
|
13
|
+
if parent_snapshot
|
|
14
|
+
load service.list_child_snapshots(parent_snapshot, filters)
|
|
15
|
+
else
|
|
16
|
+
requires :server_id
|
|
17
|
+
load service.list_vm_snapshots(server_id, filters)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get(snapshot_ref)
|
|
22
|
+
all.find { |snapshot| snapshot.get_child(snapshot_ref) }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -19,6 +19,7 @@ module Fog
|
|
|
19
19
|
vm_cfg[:cpuHotAddEnabled] = attributes[:cpuHotAddEnabled] if attributes.key?(:cpuHotAddEnabled)
|
|
20
20
|
vm_cfg[:memoryHotAddEnabled] = attributes[:memoryHotAddEnabled] if attributes.key?(:memoryHotAddEnabled)
|
|
21
21
|
vm_cfg[:firmware] = attributes[:firmware] if attributes.key?(:firmware)
|
|
22
|
+
vm_cfg[:bootOptions] = boot_options(attributes) if attributes.key?(:boot_order)
|
|
22
23
|
resource_pool = if attributes[:resource_pool]
|
|
23
24
|
get_raw_resource_pool(attributes[:resource_pool], attributes[:cluster], attributes[:datacenter])
|
|
24
25
|
else
|
|
@@ -54,6 +55,63 @@ module Fog
|
|
|
54
55
|
devices.flatten
|
|
55
56
|
end
|
|
56
57
|
|
|
58
|
+
def boot_options attributes
|
|
59
|
+
# NOTE: you must be using vsphere_rev 5.0 or greater to set boot_order
|
|
60
|
+
# e.g. Fog::Compute.new(provider: "vsphere", vsphere_rev: "5.5", etc)
|
|
61
|
+
RbVmomi::VIM::VirtualMachineBootOptions.new(
|
|
62
|
+
:bootOrder => boot_order(attributes)
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def boot_order attributes
|
|
67
|
+
# attributes[:boot_order] may be an array like this ['network', 'disk']
|
|
68
|
+
# stating, that we want to prefer network boots over disk boots
|
|
69
|
+
boot_order = []
|
|
70
|
+
attributes[:boot_order].each do |boot_device|
|
|
71
|
+
case boot_device
|
|
72
|
+
when 'network'
|
|
73
|
+
if nics = attributes[:interfaces]
|
|
74
|
+
# key is based on 4000 + the interface index
|
|
75
|
+
# we allow booting from all network interfaces, the first interface has the highest priority
|
|
76
|
+
nics.each do |nic|
|
|
77
|
+
boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableEthernetDevice.new(
|
|
78
|
+
:deviceKey => 4000 + nics.index(nic),
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
when 'disk'
|
|
83
|
+
if disks = attributes[:volumes]
|
|
84
|
+
disks.each do |disk|
|
|
85
|
+
# we allow booting from all harddisks, the first disk has the highest priority
|
|
86
|
+
boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableDiskDevice.new(
|
|
87
|
+
:deviceKey => disk.key || get_disk_device_key(disks.index(disk)),
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
when 'cdrom'
|
|
92
|
+
boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableCdromDevice.new()
|
|
93
|
+
when 'floppy'
|
|
94
|
+
boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableFloppyDevice.new()
|
|
95
|
+
else
|
|
96
|
+
raise "failed to create boot device because \"#{boot_device}\" is unknown"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
boot_order
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def get_disk_device_key(index)
|
|
103
|
+
# disk key is based on 2000 + the SCSI ID + the controller bus * 16
|
|
104
|
+
# the scsi host adapter appears as SCSI ID 7, so we have to skip that
|
|
105
|
+
# host adapter key is based on 1000 + bus id
|
|
106
|
+
# fog assumes that there is only a single scsi controller, see device_change()
|
|
107
|
+
if (index > 6) then
|
|
108
|
+
_index = index + 1
|
|
109
|
+
else
|
|
110
|
+
_index = index
|
|
111
|
+
end
|
|
112
|
+
2000 + _index
|
|
113
|
+
end
|
|
114
|
+
|
|
57
115
|
def create_nic_backing nic, attributes
|
|
58
116
|
raw_network = get_raw_network(nic.network, attributes[:datacenter], if nic.virtualswitch then nic.virtualswitch end)
|
|
59
117
|
|
|
@@ -122,18 +180,23 @@ module Fog
|
|
|
122
180
|
end
|
|
123
181
|
|
|
124
182
|
def create_disk disk, index = 0, operation = :add, controller_key = 1000
|
|
183
|
+
if (index > 6) then
|
|
184
|
+
_index = index + 1
|
|
185
|
+
else
|
|
186
|
+
_index = index
|
|
187
|
+
end
|
|
125
188
|
payload = {
|
|
126
189
|
:operation => operation,
|
|
127
190
|
:fileOperation => operation == :add ? :create : :destroy,
|
|
128
191
|
:device => RbVmomi::VIM.VirtualDisk(
|
|
129
|
-
:key => disk.key ||
|
|
192
|
+
:key => disk.key || _index,
|
|
130
193
|
:backing => RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
|
|
131
194
|
:fileName => "[#{disk.datastore}]",
|
|
132
195
|
:diskMode => disk.mode.to_sym,
|
|
133
196
|
:thinProvisioned => disk.thin
|
|
134
197
|
),
|
|
135
198
|
:controllerKey => controller_key,
|
|
136
|
-
:unitNumber =>
|
|
199
|
+
:unitNumber => _index,
|
|
137
200
|
:capacityInKB => disk.size
|
|
138
201
|
)
|
|
139
202
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class Vsphere
|
|
4
|
+
class Real
|
|
5
|
+
def list_child_snapshots(snapshot, opts = {})
|
|
6
|
+
normalized_snapshot = Hash === snapshot ?
|
|
7
|
+
Snapshot.new(snapshot.update(service: self)) : snapshot
|
|
8
|
+
|
|
9
|
+
child_snapshots = normalized_snapshot.tree_node.childSnapshotList.map do |snap|
|
|
10
|
+
item = child_snapshot_info(snap, normalized_snapshot)
|
|
11
|
+
[
|
|
12
|
+
item,
|
|
13
|
+
opts[:recursive] ? list_child_snapshots(item, opts) : nil
|
|
14
|
+
]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
child_snapshots.flatten.compact
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
def child_snapshot_info(snap_tree, parent_snap)
|
|
23
|
+
{
|
|
24
|
+
name: snap_tree.name,
|
|
25
|
+
quiesced: snap_tree.quiesced,
|
|
26
|
+
description: snap_tree.description,
|
|
27
|
+
create_time: snap_tree.createTime,
|
|
28
|
+
power_state: snap_tree.state,
|
|
29
|
+
ref: snap_tree.snapshot._ref,
|
|
30
|
+
mo_ref: snap_tree.snapshot,
|
|
31
|
+
tree_node: snap_tree,
|
|
32
|
+
snapshot_name_chain:
|
|
33
|
+
"#{parent_snap.snapshot_name_chain}/#{snap_tree.name}",
|
|
34
|
+
ref_chain:
|
|
35
|
+
"#{parent_snap.ref_chain}/#{snap_tree.snapshot._ref}"
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
class Mock
|
|
40
|
+
def list_child_snapshots(snapshot, opts = {})
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
name: 'clean',
|
|
44
|
+
quiesced: false,
|
|
45
|
+
description: '',
|
|
46
|
+
create_time: Time.now.utc,
|
|
47
|
+
power_state: 'poweredOn',
|
|
48
|
+
ref: 'snapshot-0101',
|
|
49
|
+
mo_ref: nil,
|
|
50
|
+
tree_node: nil,
|
|
51
|
+
snapshot_name_chain: '123/clean',
|
|
52
|
+
ref_chain: '123/snap-0101'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'dirty',
|
|
56
|
+
quiesced: false,
|
|
57
|
+
description: '',
|
|
58
|
+
create_time: Time.now.utc,
|
|
59
|
+
power_state: 'poweredOn',
|
|
60
|
+
ref: 'snapshot-0102',
|
|
61
|
+
mo_ref: nil,
|
|
62
|
+
tree_node: nil,
|
|
63
|
+
snapshot_name_chain: '123/dirty',
|
|
64
|
+
ref_chain: '123/snap-0102'
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -20,10 +20,11 @@ module Fog
|
|
|
20
20
|
|
|
21
21
|
def network_attributes network, datacenter
|
|
22
22
|
{
|
|
23
|
-
:id
|
|
24
|
-
:name
|
|
25
|
-
:accessible
|
|
26
|
-
:datacenter
|
|
23
|
+
:id => managed_obj_id(network),
|
|
24
|
+
:name => network.name,
|
|
25
|
+
:accessible => network.summary.accessible,
|
|
26
|
+
:datacenter => datacenter,
|
|
27
|
+
:virtualswitch => network.class.name == "DistributedVirtualPortgroup" ? network.config.distributedVirtualSwitch.name : nil
|
|
27
28
|
}
|
|
28
29
|
end
|
|
29
30
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class Vsphere
|
|
4
|
+
class Real
|
|
5
|
+
def list_processes(vm_id, opts)
|
|
6
|
+
vm = get_vm_ref(vm_id)
|
|
7
|
+
|
|
8
|
+
auth = RbVmomi::VIM::NamePasswordAuthentication(
|
|
9
|
+
username: opts[:user],
|
|
10
|
+
password: opts[:password],
|
|
11
|
+
interactiveSession: false
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
p_manager = @connection.serviceContent.guestOperationsManager.processManager
|
|
15
|
+
processes = p_manager.ListProcessesInGuest(vm: vm, auth: auth)
|
|
16
|
+
processes.map do |pi|
|
|
17
|
+
Process.new(
|
|
18
|
+
cmd_line: pi.cmdLine,
|
|
19
|
+
end_time: pi.endTime,
|
|
20
|
+
exit_code: pi.exitCode,
|
|
21
|
+
name: pi.name,
|
|
22
|
+
owner: pi.owner,
|
|
23
|
+
pid: pi.pid,
|
|
24
|
+
start_time: pi.startTime
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Mock
|
|
31
|
+
def list_processes(vm_id, opts = {})
|
|
32
|
+
[
|
|
33
|
+
Process.new(name: 'winlogon'),
|
|
34
|
+
Process.new(name: 'init')
|
|
35
|
+
]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class Vsphere
|
|
4
|
+
class Real
|
|
5
|
+
def list_vm_snapshots(vm_id, opts = {})
|
|
6
|
+
root_snapshots = get_vm_ref(vm_id).snapshot.rootSnapshotList.map do |snap|
|
|
7
|
+
item = snapshot_info(snap, vm_id)
|
|
8
|
+
[
|
|
9
|
+
item,
|
|
10
|
+
opts[:recursive] ? list_child_snapshots(item, opts) : nil
|
|
11
|
+
]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
root_snapshots.flatten.compact
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
protected
|
|
18
|
+
|
|
19
|
+
def snapshot_info(snap_tree, vm_id)
|
|
20
|
+
{
|
|
21
|
+
name: snap_tree.name,
|
|
22
|
+
quiesced: snap_tree.quiesced,
|
|
23
|
+
description: snap_tree.description,
|
|
24
|
+
create_time: snap_tree.createTime,
|
|
25
|
+
power_state: snap_tree.state,
|
|
26
|
+
ref: snap_tree.snapshot._ref,
|
|
27
|
+
mo_ref: snap_tree.snapshot,
|
|
28
|
+
tree_node: snap_tree,
|
|
29
|
+
ref_chain: "#{vm_id}/#{snap_tree.snapshot._ref}",
|
|
30
|
+
snapshot_name_chain: "#{vm_id}/#{snap_tree.name}"
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
class Mock
|
|
35
|
+
def list_vm_snapshots(vm_id, opts = {})
|
|
36
|
+
[
|
|
37
|
+
{
|
|
38
|
+
name: 'clean',
|
|
39
|
+
quiesced: false,
|
|
40
|
+
description: '',
|
|
41
|
+
create_time: Time.now.utc,
|
|
42
|
+
power_state: 'poweredOn',
|
|
43
|
+
ref: 'snapshot-0101',
|
|
44
|
+
mo_ref: nil,
|
|
45
|
+
tree_node: nil,
|
|
46
|
+
snapshot_name_chain: '123/clean',
|
|
47
|
+
ref_chain: "#{vm_id}/snapshot-0101"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'dirty',
|
|
51
|
+
quiesced: false,
|
|
52
|
+
description: '',
|
|
53
|
+
create_time: Time.now.utc,
|
|
54
|
+
power_state: 'poweredOn',
|
|
55
|
+
ref: 'snapshot-0102',
|
|
56
|
+
mo_ref: nil,
|
|
57
|
+
tree_node: nil,
|
|
58
|
+
snapshot_name_chain: '123/dirty',
|
|
59
|
+
ref_chain: "#{vm_id}/snapshot-0102"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class Vsphere
|
|
4
|
+
class Real
|
|
5
|
+
def revert_to_snapshot(snapshot)
|
|
6
|
+
unless Snapshot === snapshot
|
|
7
|
+
fail ArgumentError, 'snapshot is a required parameter'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
task = snapshot.mo_ref.RevertToSnapshot_Task
|
|
11
|
+
task.wait_for_completion
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
'state' => task.info.state
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Mock
|
|
20
|
+
def revert_to_snapshot(snapshot)
|
|
21
|
+
fail ArgumentError, 'snapshot is a required parameter' if snapshot.nil?
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
'state' => 'success'
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|