-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathvm.rb
59 lines (53 loc) · 1.63 KB
/
vm.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class ManageIQ::Providers::Vmware::CloudManager::Vm < ManageIQ::Providers::CloudManager::Vm
include Operations
include RemoteConsole
include Reconfigure
supports :snapshots
supports :remove_all_snapshots
supports_not :remove_snapshot
supports :snapshot_create
supports :revert_to_snapshot
supports :reconfigure_disks
supports :reconfigure_disksize do
_("Cannot resize disks of a VM with snapshots") unless snapshots.empty?
end
supports :reconfigure_network_adapters
def provider_object(connection = nil)
connection ||= ext_management_system.connect
connection.vms.get_single_vm(uid_ems)
end
POWER_STATES = {
"creating" => "powering_up",
"off" => "off",
"on" => "on",
"unknown" => "terminated",
"suspended" => "suspended"
}.freeze
def self.params_for_create_snapshot
{
:fields => [
{
:component => 'text-field',
:name => 'name',
:id => 'name',
:label => _('Name'),
:isRequired => true,
:validate => [{:type => 'required'}],
},
{
:component => 'textarea',
:name => 'description',
:id => 'description',
:label => _('Description'),
},
],
}
end
def self.calculate_power_state(raw_power_state)
# https://github.com/xlab-si/fog-vcloud-director/blob/master/lib/fog/vcloud_director/parsers/compute/vm.rb#L70
POWER_STATES[raw_power_state.to_s] || "terminated"
end
def self.display_name(number = 1)
n_('Instance (VMware vCloud)', 'Instances (VMware vCloud)', number)
end
end