Class: Fog::Compute::Vsphere::Mock
- Inherits:
-
Object
- Object
- Fog::Compute::Vsphere::Mock
show all
- Includes:
- Shared
- Defined in:
- lib/fog/vsphere/compute.rb,
lib/fog/vsphere/requests/compute/vm_clone.rb,
lib/fog/vsphere/requests/compute/vm_reboot.rb,
lib/fog/vsphere/requests/compute/vm_destroy.rb,
lib/fog/vsphere/requests/compute/vm_power_on.rb,
lib/fog/vsphere/requests/compute/current_time.rb,
lib/fog/vsphere/requests/compute/vm_power_off.rb,
lib/fog/vsphere/requests/compute/find_vm_by_ref.rb,
lib/fog/vsphere/requests/compute/list_virtual_machines.rb
Instance Attribute Summary
Attributes included from Shared
#vsphere_is_vcenter, #vsphere_rev, #vsphere_server, #vsphere_username
Instance Method Summary
collapse
Methods included from Shared
#convert_vm_mob_ref_to_attr_hash, #find_vm_by_ref
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
70
71
72
73
74
75
76
77
|
# File 'lib/fog/vsphere/compute.rb', line 70
def initialize(options={})
@vsphere_username = options[:vsphere_username]
@vsphere_password = 'REDACTED'
@vsphere_server = options[:vsphere_server]
@vsphere_expected_pubkey_hash = options[:vsphere_expected_pubkey_hash]
@vsphere_is_vcenter = true
@vsphere_rev = '4.0'
end
|
Instance Method Details
#current_time ⇒ Object
15
16
17
|
# File 'lib/fog/vsphere/requests/compute/current_time.rb', line 15
def current_time
{ 'current_time' => Time.now.utc }
end
|
#list_virtual_machines(options = {}) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/fog/vsphere/requests/compute/list_virtual_machines.rb', line 61
def list_virtual_machines(options = {})
case options['instance_uuid']
when nil
rval = YAML.load <<-'ENDvmLISTING'
---
virtual_machines:
- name: centos56gm
hypervisor: gunab.puppetlabs.lan
tools_version: guestToolsCurrent
ipaddress:
mo_ref: vm-698
power_state: poweredOff
uuid: 42322347-d791-cd34-80b9-e25fe28ad37c
is_a_template: true
id: 50323f93-6835-1178-8b8f-9e2109890e1a
tools_state: toolsNotRunning
connection_state: connected
instance_uuid: 50323f93-6835-1178-8b8f-9e2109890e1a
hostname:
mac_addresses:
Network adapter 1: 00:50:56:b2:00:a1
operatingsystem:
- name: centos56gm2
hypervisor: gunab.puppetlabs.lan
tools_version: guestToolsCurrent
ipaddress:
mo_ref: vm-640
power_state: poweredOff
uuid: 564ddcbe-853a-d29a-b329-a0a3693a004d
is_a_template: true
id: 5257dee8-050c-cbcd-ae25-db0e582ab530
tools_state: toolsNotRunning
connection_state: connected
instance_uuid: 5257dee8-050c-cbcd-ae25-db0e582ab530
hostname:
mac_addresses:
Network adapter 1: 00:0c:29:3a:00:4d
operatingsystem:
- name: dashboard_gm
hypervisor: gunab.puppetlabs.lan
tools_version: guestToolsCurrent
ipaddress: 192.168.100.184
mo_ref: vm-669
power_state: poweredOn
uuid: 564d3f91-3452-a509-a678-1246f7897979
is_a_template: false
id: 5032739c-c871-c0d2-034f-9700a0b5383e
tools_state: toolsOk
connection_state: connected
instance_uuid: 5032739c-c871-c0d2-034f-9700a0b5383e
hostname: compliance.puppetlabs.vm
mac_addresses:
Network adapter 1: 00:50:56:b2:00:96
operatingsystem: Red Hat Enterprise Linux 6 (64-bit)
- name: jefftest
hypervisor: gunab.puppetlabs.lan
tools_version: guestToolsCurrent
ipaddress: 192.168.100.187
mo_ref: vm-715
power_state: poweredOn
uuid: 42329da7-e8ab-29ec-1892-d6a4a964912a
is_a_template: false
id: 5032c8a5-9c5e-ba7a-3804-832a03e16381
tools_state: toolsOk
connection_state: connected
instance_uuid: 5032c8a5-9c5e-ba7a-3804-832a03e16381
hostname: centos56gm.localdomain
mac_addresses:
Network adapter 1: 00:50:56:b2:00:af
operatingsystem: CentOS 4/5 (32-bit)
ENDvmLISTING
when '5032c8a5-9c5e-ba7a-3804-832a03e16381'
YAML.load <<-'5032c8a5-9c5e-ba7a-3804-832a03e16381'
---
virtual_machines:
- name: jefftest
hypervisor: gunab.puppetlabs.lan
tools_version: guestToolsCurrent
ipaddress: 192.168.100.187
mo_ref: vm-715
power_state: poweredOn
uuid: 42329da7-e8ab-29ec-1892-d6a4a964912a
is_a_template: false
id: 5032c8a5-9c5e-ba7a-3804-832a03e16381
tools_state: toolsOk
connection_state: connected
instance_uuid: 5032c8a5-9c5e-ba7a-3804-832a03e16381
hostname: centos56gm.localdomain
mac_addresses:
Network adapter 1: 00:50:56:b2:00:af
operatingsystem: CentOS 4/5 (32-bit)
5032c8a5-9c5e-ba7a-3804-832a03e16381
when 'does-not-exist-and-is-not-a-uuid', '50323f93-6835-1178-8b8f-9e2109890e1a'
{ 'virtual_machines' => [] }
end
end
|
#vm_clone(options = {}) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/fog/vsphere/requests/compute/vm_clone.rb', line 81
def vm_clone(options = {})
options = vm_clone_check_options(options)
notfound = lambda { raise Fog::Compute::Vsphere::NotFound, "Cloud not find VM template" }
vm_mob_ref = list_virtual_machines['virtual_machines'].find(notfound) do |vm|
vm['instance_uuid'] == options['instance_uuid']
end
{
'vm_ref' => 'vm-123',
'task_ref' => 'task-1234'
}
end
|
#vm_destroy(options = {}) ⇒ Object
26
27
28
29
|
# File 'lib/fog/vsphere/requests/compute/vm_destroy.rb', line 26
def vm_destroy(options = {})
raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
{ 'task_state' => 'success' }
end
|
#vm_power_off(options = {}) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/fog/vsphere/requests/compute/vm_power_off.rb', line 30
def vm_power_off(options = {})
raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
{
'task_state' => "running",
'power_off_type' => options['force'] ? 'cut_power' : 'shutdown_guest',
}
end
|
#vm_power_on(options = {}) ⇒ Object
22
23
24
25
|
# File 'lib/fog/vsphere/requests/compute/vm_power_on.rb', line 22
def vm_power_on(options = {})
raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
{ 'task_state' => 'success' }
end
|
#vm_reboot(options = {}) ⇒ Object
27
28
29
30
|
# File 'lib/fog/vsphere/requests/compute/vm_reboot.rb', line 27
def vm_reboot(options = {})
raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
{ 'task_state' => "running", 'reboot_type' => options['force'] ? 'reset_power' : 'reboot_guest' }
end
|