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 " --- \n virtual_machines: \n - name: centos56gm\n hypervisor: gunab.puppetlabs.lan\n tools_version: guestToolsCurrent\n ipaddress: \n mo_ref: vm-698\n power_state: poweredOff\n uuid: 42322347-d791-cd34-80b9-e25fe28ad37c\n is_a_template: true\n id: 50323f93-6835-1178-8b8f-9e2109890e1a\n tools_state: toolsNotRunning\n connection_state: connected\n instance_uuid: 50323f93-6835-1178-8b8f-9e2109890e1a\n hostname: \n mac_addresses: \n Network adapter 1: 00:50:56:b2:00:a1\n operatingsystem: \n - name: centos56gm2\n hypervisor: gunab.puppetlabs.lan\n tools_version: guestToolsCurrent\n ipaddress: \n mo_ref: vm-640\n power_state: poweredOff\n uuid: 564ddcbe-853a-d29a-b329-a0a3693a004d\n is_a_template: true\n id: 5257dee8-050c-cbcd-ae25-db0e582ab530\n tools_state: toolsNotRunning\n connection_state: connected\n instance_uuid: 5257dee8-050c-cbcd-ae25-db0e582ab530\n hostname: \n mac_addresses: \n Network adapter 1: 00:0c:29:3a:00:4d\n operatingsystem: \n - name: dashboard_gm\n hypervisor: gunab.puppetlabs.lan\n tools_version: guestToolsCurrent\n ipaddress: 192.168.100.184\n mo_ref: vm-669\n power_state: poweredOn\n uuid: 564d3f91-3452-a509-a678-1246f7897979\n is_a_template: false\n id: 5032739c-c871-c0d2-034f-9700a0b5383e\n tools_state: toolsOk\n connection_state: connected\n instance_uuid: 5032739c-c871-c0d2-034f-9700a0b5383e\n hostname: compliance.puppetlabs.vm\n mac_addresses: \n Network adapter 1: 00:50:56:b2:00:96\n operatingsystem: Red Hat Enterprise Linux 6 (64-bit)\n - name: jefftest\n hypervisor: gunab.puppetlabs.lan\n tools_version: guestToolsCurrent\n ipaddress: 192.168.100.187\n mo_ref: vm-715\n power_state: poweredOn\n uuid: 42329da7-e8ab-29ec-1892-d6a4a964912a\n is_a_template: false\n id: 5032c8a5-9c5e-ba7a-3804-832a03e16381\n tools_state: toolsOk\n connection_state: connected\n instance_uuid: 5032c8a5-9c5e-ba7a-3804-832a03e16381\n hostname: centos56gm.localdomain\n mac_addresses: \n Network adapter 1: 00:50:56:b2:00:af\n operatingsystem: CentOS 4/5 (32-bit)\n ENDvmLISTING\n when '5032c8a5-9c5e-ba7a-3804-832a03e16381'\n YAML.load <<-'5032c8a5-9c5e-ba7a-3804-832a03e16381'\n --- \n virtual_machines: \n - name: jefftest\n hypervisor: gunab.puppetlabs.lan\n tools_version: guestToolsCurrent\n ipaddress: 192.168.100.187\n mo_ref: vm-715\n power_state: poweredOn\n uuid: 42329da7-e8ab-29ec-1892-d6a4a964912a\n is_a_template: false\n id: 5032c8a5-9c5e-ba7a-3804-832a03e16381\n tools_state: toolsOk\n connection_state: connected\n instance_uuid: 5032c8a5-9c5e-ba7a-3804-832a03e16381\n hostname: centos56gm.localdomain\n mac_addresses: \n Network adapter 1: 00:50:56:b2:00:af\n operatingsystem: CentOS 4/5 (32-bit)\n 5032c8a5-9c5e-ba7a-3804-832a03e16381\n when 'does-not-exist-and-is-not-a-uuid', '50323f93-6835-1178-8b8f-9e2109890e1a'\n { 'virtual_machines' => [] }\n end\nend\n"
|
#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
|