Class: Fog::Compute::Vsphere::Mock

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/fog/vsphere/compute.rb,
lib/fog/vsphere/requests/compute/vm_clone.rb,
lib/fog/vsphere/requests/compute/create_vm.rb,
lib/fog/vsphere/requests/compute/vm_reboot.rb,
lib/fog/vsphere/requests/compute/get_folder.rb,
lib/fog/vsphere/requests/compute/vm_destroy.rb,
lib/fog/vsphere/requests/compute/vm_migrate.rb,
lib/fog/vsphere/requests/compute/get_cluster.rb,
lib/fog/vsphere/requests/compute/get_network.rb,
lib/fog/vsphere/requests/compute/vm_power_on.rb,
lib/fog/vsphere/requests/compute/current_time.rb,
lib/fog/vsphere/requests/compute/get_template.rb,
lib/fog/vsphere/requests/compute/vm_power_off.rb,
lib/fog/vsphere/requests/compute/get_datastore.rb,
lib/fog/vsphere/requests/compute/list_clusters.rb,
lib/fog/vsphere/requests/compute/list_networks.rb,
lib/fog/vsphere/requests/compute/vm_config_vnc.rb,
lib/fog/vsphere/requests/compute/get_datacenter.rb,
lib/fog/vsphere/requests/compute/list_templates.rb,
lib/fog/vsphere/requests/compute/get_server_type.rb,
lib/fog/vsphere/requests/compute/list_datastores.rb,
lib/fog/vsphere/requests/compute/list_vm_volumes.rb,
lib/fog/vsphere/requests/compute/list_datacenters.rb,
lib/fog/vsphere/requests/compute/modify_vm_volume.rb,
lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb,
lib/fog/vsphere/requests/compute/get_resource_pool.rb,
lib/fog/vsphere/requests/compute/list_customfields.rb,
lib/fog/vsphere/requests/compute/list_server_types.rb,
lib/fog/vsphere/requests/compute/list_vm_interfaces.rb,
lib/fog/vsphere/requests/compute/set_vm_customvalue.rb,
lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb,
lib/fog/vsphere/requests/compute/get_virtual_machine.rb,
lib/fog/vsphere/requests/compute/list_resource_pools.rb,
lib/fog/vsphere/requests/compute/modify_vm_interface.rb,
lib/fog/vsphere/requests/compute/list_vm_customvalues.rb,
lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb,
lib/fog/vsphere/requests/compute/list_virtual_machines.rb,
lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb

Instance Attribute Summary

Attributes included from Shared

#vsphere_is_vcenter, #vsphere_rev, #vsphere_server, #vsphere_username

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



349
350
351
352
353
354
355
356
357
# File 'lib/fog/vsphere/compute.rb', line 349

def initialize(options={})
  require 'rbvmomi'
  @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

Class Method Details

.dataObject



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/fog/vsphere/compute.rb', line 192

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :servers => {
        "5032c8a5-9c5e-ba7a-3804-832a03e16381" => {
         "resource_pool"    => "Resources",
         "memory_mb"        => 2196,
         "mac_addresses"    => { "Network adapter 1" => "00:50:56:a9:00:28" },
         "power_state"      => "poweredOn",
         "cpus"             => 1,
         "hostname"         => "dhcp75-197.virt.bos.redhat.com",
         "mo_ref"           => "vm-562",
         "connection_state" => "connected",
         "overall_status"   => "green",
         "datacenter"       => "Solutions",
         "volumes"          =>
            [{
              "id"        => "6000C29c-a47d-4cd9-5249-c371de775f06",
              "datastore" => "Storage1",
              "mode"      => "persistent",
              "size"      => 8388608,
              "thin"      => true,
              "name"      => "Hard disk 1",
              "filename"  => "[Storage1] rhel6-mfojtik/rhel6-mfojtik.vmdk",
              "size_gb"   => 8
             }],
         "interfaces"       =>
            [{"mac"     => "00:50:56:a9:00:28",
              "network" => "VM Network",
              "name"    => "Network adapter 1",
              "status"  => "ok",
              "summary" => "VM Network",
             }],
         "hypervisor"       => "gunab.puppetlabs.lan",
         "guest_id"         => "rhel6_64Guest",
         "tools_state"      => "toolsOk",
         "cluster"          => "Solutionscluster",
         "name"             => "rhel64",
         "operatingsystem"  => "Red Hat Enterprise Linux 6 (64-bit)",
         "path"             => "/Datacenters/Solutions/vm",
         "uuid"             => "4229f0e9-bfdc-d9a7-7bac-12070772e6dc",
         "instance_uuid"    => "5032c8a5-9c5e-ba7a-3804-832a03e16381",
         "id"               => "5032c8a5-9c5e-ba7a-3804-832a03e16381",
         "tools_version"    => "guestToolsUnmanaged",
         "ipaddress"        => "192.168.100.184",
         "template"         => false
        },
        "502916a3-b42e-17c7-43ce-b3206e9524dc" => {
         "resource_pool"    => "Resources",
         "memory_mb"        => 512,
         "power_state"      => "poweredOn",
         "mac_addresses"    => { "Network adapter 1" => "00:50:56:a9:00:00" },
         "hostname"         => nil,
         "cpus"             => 1,
         "connection_state" => "connected",
         "mo_ref"           => "vm-621",
         "overall_status"   => "green",
         "datacenter"       => "Solutions",
         "volumes"          =>
            [{"thin"      => false,
              "size_gb"   => 10,
              "datastore" => "datastore1",
              "filename"  => "[datastore1] i-1342439683/i-1342439683.vmdk",
              "size"      => 10485762,
              "name"      => "Hard disk 1",
              "mode"      => "persistent",
              "id"        => "6000C29b-f364-d073-8316-8e98ac0a0eae" }],
         "interfaces"       =>
            [{ "summary" => "VM Network",
              "mac"     => "00:50:56:a9:00:00",
              "status"  => "ok",
              "network" => "VM Network",
              "name"    => "Network adapter 1" }],
         "hypervisor"       => "gunab.puppetlabs.lan",
         "guest_id"         => nil,
         "cluster"          => "Solutionscluster",
         "tools_state"      => "toolsNotInstalled",
         "name"             => "i-1342439683",
         "operatingsystem"  => nil,
         "path"             => "/",
         "tools_version"    => "guestToolsNotInstalled",
         "uuid"             => "4229e0de-30cb-ceb2-21f9-4d8d8beabb52",
         "instance_uuid"    => "502916a3-b42e-17c7-43ce-b3206e9524dc",
         "id"               => "502916a3-b42e-17c7-43ce-b3206e9524dc",
         "ipaddress"        => nil,
         "template"         => false
        },
        "5029c440-85ee-c2a1-e9dd-b63e39364603" => {
         "resource_pool"    => "Resources",
         "memory_mb"        => 2196,
         "power_state"      => "poweredOn",
         "mac_addresses"    => { "Network adapter 1" => "00:50:56:b2:00:af" },
         "hostname"         => "centos56gm.localdomain",
         "cpus"             => 1,
         "connection_state" => "connected",
         "mo_ref"           => "vm-715",
         "overall_status"   => "green",
         "datacenter"       => "Solutions",
         "hypervisor"       => "gunab.puppetlabs.lan",
         "guest_id"         => "rhel6_64Guest",
         "cluster"          => "Solutionscluster",
         "tools_state"      => "toolsOk",
         "name"             => "jefftest",
         "operatingsystem"  => "Red Hat Enterprise Linux 6 (64-bit)",
         "path"             => "/",
         "tools_version"    => "guestToolsUnmanaged",
         "ipaddress"        => "192.168.100.187",
         "uuid"             => "42329da7-e8ab-29ec-1892-d6a4a964912a",
         "instance_uuid"    => "5029c440-85ee-c2a1-e9dd-b63e39364603",
         "id"               => "5029c440-85ee-c2a1-e9dd-b63e39364603",
         "template"         => false
        }
      },
      :datacenters => {
        "Solutions" => {:name => "Solutions", :status => "grey"}
      },
      :clusters =>
        [{:id => "1d4d9a3f-e4e8-4c40-b7fc-263850068fa4",
          :name => "Solutionscluster",
          :num_host => "4",
          :num_cpu_cores => "16",
          :overall_status => "green",
          :datacenter => "Solutions",
          :klass => "RbVmomi::VIM::ComputeResource"
         },
         {:id => "e4195973-102b-4096-bbd6-5429ff0b35c9",
          :name => "Problemscluster",
          :num_host => "4",
          :num_cpu_cores => "32",
          :overall_status => "green",
          :datacenter => "Solutions",
          :klass => "RbVmomi::VIM::ComputeResource"
         },
         {
           :klass => "RbVmomi::VIM::Folder",
           :clusters => [{:id => "03616b8d-b707-41fd-b3b5-The first",
                          :name => "Problemscluster",
                          :num_host => "4",
                          :num_cpu_cores => "32",
                          :overall_status => "green",
                          :datacenter => "Solutions",
                          :klass => "RbVmomi::VIM::ComputeResource"
                         },
                         {:id => "03616b8d-b707-41fd-b3b5-the Second",
                          :name => "Lastcluster",
                          :num_host => "8",
                          :num_cpu_cores => "32",
                          :overall_status => "green",
                          :datacenter => "Solutions",
                          :klass => "RbVmomi::VIM::ComputeResource"}
           ]
         }
        ]
    }
  end
end

Instance Method Details

#add_vm_interface(vmid, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


45
46
47
48
49
# File 'lib/fog/vsphere/requests/compute/modify_vm_interface.rb', line 45

def add_vm_interface(vmid, options = {})
  raise ArgumentError, "instance id is a required parameter" unless vmid
  raise ArgumentError, "interface is a required parameter" unless options and options[:interface]
  true
end

#add_vm_volume(volume) ⇒ Object



15
16
17
# File 'lib/fog/vsphere/requests/compute/modify_vm_volume.rb', line 15

def add_vm_volume(volume)
  true
end

#create_vm(attributes = { }) ⇒ Object



156
157
# File 'lib/fog/vsphere/requests/compute/create_vm.rb', line 156

def create_vm attributes = { }
end

#current_timeObject



12
13
14
# File 'lib/fog/vsphere/requests/compute/current_time.rb', line 12

def current_time
  { 'current_time' => Time.now.utc }
end

#dataObject



359
360
361
# File 'lib/fog/vsphere/compute.rb', line 359

def data
  self.class.data[@vsphere_username]
end

#destroy_vm_interface(vmid, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


51
52
53
54
55
# File 'lib/fog/vsphere/requests/compute/modify_vm_interface.rb', line 51

def destroy_vm_interface(vmid, options = {})
  raise ArgumentError, "instance id is a required parameter" unless vmid
  raise ArgumentError, "interface is a required parameter" unless options and options[:interface]
  true
end

#destroy_vm_volume(volume) ⇒ Object



19
20
21
# File 'lib/fog/vsphere/requests/compute/modify_vm_volume.rb', line 19

def destroy_vm_volume(volume)
  true
end

#get_cluster(id) ⇒ Object



20
21
# File 'lib/fog/vsphere/requests/compute/get_cluster.rb', line 20

def get_cluster(id)
end

#get_datacenter(name) ⇒ Object

Raises:

  • (Fog::Compute::Vsphere::NotFound)


23
24
25
26
27
# File 'lib/fog/vsphere/requests/compute/get_datacenter.rb', line 23

def get_datacenter name
  dc = self.data[:datacenters][name]
  raise(Fog::Compute::Vsphere::NotFound) unless dc
  dc
end

#get_datastore(name, datacenter_name) ⇒ Object



25
26
# File 'lib/fog/vsphere/requests/compute/get_datastore.rb', line 25

def get_datastore(name, datacenter_name)
end

#get_folder(path, filters = { }) ⇒ Object



69
70
# File 'lib/fog/vsphere/requests/compute/get_folder.rb', line 69

def get_folder(path, filters = { })
end

#get_folder_path(folder, root = nil) ⇒ Object



58
59
60
# File 'lib/fog/vsphere/requests/compute/list_virtual_machines.rb', line 58

def get_folder_path(folder, root = nil)
  nil
end

#get_network(id) ⇒ Object



25
26
# File 'lib/fog/vsphere/requests/compute/get_network.rb', line 25

def get_network(id)
end

#get_raw_clusters_from_folder(folder) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/fog/vsphere/requests/compute/list_clusters.rb', line 54

def get_raw_clusters_from_folder(folder)
  folder.map do |child|
    if child[:klass] == "RbVmomi::VIM::ComputeResource"
       child
    elsif child[:klass] == "RbVmomi::VIM::Folder"
      get_raw_clusters_from_folder(child[:clusters])
    end
  end.flatten
end

#get_resource_pool(name, cluster_name, datacenter_name) ⇒ Object



21
22
# File 'lib/fog/vsphere/requests/compute/get_resource_pool.rb', line 21

def get_resource_pool(name, cluster_name, datacenter_name)
end

#get_server_type(id) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/fog/vsphere/requests/compute/get_server_type.rb', line 22

def get_server_type(id)
  {:id=>"rhel6Guest",
    :name=>"rhel6Guest",
    :family=>"linuxGuest",
    :fullname=>"Red Hat Enterprise Linux 6 (32-Bit)",
    :datacenter=>"Solutions"}
end

#get_template(id, datacenter_name = nil) ⇒ Object



11
12
# File 'lib/fog/vsphere/requests/compute/get_template.rb', line 11

def get_template(id, datacenter_name = nil)
end

#get_virtual_machine(id, datacenter_name = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/fog/vsphere/requests/compute/get_virtual_machine.rb', line 32

def get_virtual_machine(id, datacenter_name = nil)
  if is_uuid?(id)
    vm = list_virtual_machines({ 'instance_uuid' => id, 'datacenter' => datacenter_name }).first
  else
    # try to find based on VM name. May need to handle the path of the VM
    vm = list_virtual_machines({ 'name' => id, 'datacenter' => datacenter_name }).first
  end
  vm ? vm : raise(Fog::Compute::Vsphere::NotFound, "#{id} was not found")
end

#get_vm_first_scsi_controller(vm_id) ⇒ Object



21
22
# File 'lib/fog/vsphere/requests/compute/get_vm_first_scsi_controller.rb', line 21

def get_vm_first_scsi_controller(vm_id)
end

#list_clusters(filters = { }) ⇒ Object



43
44
45
46
47
# File 'lib/fog/vsphere/requests/compute/list_clusters.rb', line 43

def list_clusters(filters = { })
  raw_clusters.map do |cluster|
    cluster
  end
end

#list_datacenters(filters = {}) ⇒ Object



47
48
49
# File 'lib/fog/vsphere/requests/compute/list_datacenters.rb', line 47

def list_datacenters filters = {}
  [ {:name => "Solutions", :status => "grey"}, {:name => "Solutions2", :status => "green" }]
end

#list_datastores(datacenter_name) ⇒ Object



34
35
36
# File 'lib/fog/vsphere/requests/compute/list_datastores.rb', line 34

def list_datastores(datacenter_name)
  []
end

#list_networks(datacenter_name) ⇒ Object



31
32
33
# File 'lib/fog/vsphere/requests/compute/list_networks.rb', line 31

def list_networks(datacenter_name)
  []
end

#list_resource_pools(filters = { }) ⇒ Object



33
34
# File 'lib/fog/vsphere/requests/compute/list_resource_pools.rb', line 33

def list_resource_pools(filters = { })
end

#list_server_types(datacenter_name) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/vsphere/requests/compute/list_server_types.rb', line 39

def list_server_types(datacenter_name)
  [{:id=>"rhel6Guest",
    :name=>"rhel6Guest",
    :family=>"linuxGuest",
    :fullname=>"Red Hat Enterprise Linux 6 (32-Bit)",
    :datacenter=>"Solutions"},
   {:id=>"rhel5_64Guest",
    :name=>"rhel5_64Guest",
    :family=>"linuxGuest",
    :fullname=>"Red Hat Enterprise Linux 5 (64-Bit)",
    :datacenter=>"Solutions"}]
end

#list_templates(filters = { }) ⇒ Object



43
44
# File 'lib/fog/vsphere/requests/compute/list_templates.rb', line 43

def list_templates(filters = { })
end

#list_virtual_machines(options = { }) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/fog/vsphere/requests/compute/list_virtual_machines.rb', line 62

def list_virtual_machines(options = { })
  if options['instance_uuid'].nil? and options['mo_ref'].nil?
    self.data[:servers].values
  elsif !options['instance_uuid'].nil?
    server = self.data[:servers][options['instance_uuid']]
    server.nil? ? [] : [server]
  else
    self.data[:servers].values.select{|vm| vm['mo_ref'] == options['mo_ref']}
  end
end

#list_vm_customfields(vm_id) ⇒ Object



16
17
# File 'lib/fog/vsphere/requests/compute/list_customfields.rb', line 16

def list_vm_customfields()
end

#list_vm_interfaces(vm_id) ⇒ Object



58
59
# File 'lib/fog/vsphere/requests/compute/list_vm_interfaces.rb', line 58

def list_vm_interfaces(vm_id)
end

#list_vm_volumes(vm_id) ⇒ Object



47
48
# File 'lib/fog/vsphere/requests/compute/list_vm_volumes.rb', line 47

def list_vm_volumes(vm_id)
end

#raw_clustersObject



49
50
51
52
# File 'lib/fog/vsphere/requests/compute/list_clusters.rb', line 49

def raw_clusters
  folder = self.data[:clusters]
  @raw_clusters = get_raw_clusters_from_folder(folder)
end

#reset_dataObject



363
364
365
# File 'lib/fog/vsphere/compute.rb', line 363

def reset_data
  self.class.data.delete(@vsphere_username)
end

#set_vm_customvalue(vm_id, key, value) ⇒ Object



11
12
13
# File 'lib/fog/vsphere/requests/compute/set_vm_customvalue.rb', line 11

def set_vm_customvalue(vm_id, key, value)
  nil
end

#vm_clone(options = {}) ⇒ Object



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/fog/vsphere/requests/compute/vm_clone.rb', line 276

def vm_clone(options = {})
  # Option handling TODO Needs better method of checking
  options = vm_clone_check_options(options)
  notfound = lambda { raise Fog::Compute::Vsphere::NotFound, "Could not find VM template" }
  template = list_virtual_machines.find(notfound) do |vm|
    vm['name'] == options['template_path'].split("/")[-1]
  end

  # generate a random id
  id = [8,4,4,4,12].map{|i| Fog::Mock.random_hex(i)}.join("-")
  new_vm = template.clone.merge({
    "name" => options['name'],
    "id" => id,
    "instance_uuid" => id,
    "path" => "/Datacenters/#{options['datacenter']}/#{options['dest_folder'] ? options['dest_folder']+"/" : ""}#{options['name']}"
  })
  self.data[:servers][id] = new_vm

  {
    'vm_ref'   => "vm-#{Fog::Mock.random_numbers(3)}",
    'new_vm'   => new_vm,
    'task_ref' => "task-#{Fog::Mock.random_numbers(4)}",
  }
end

#vm_config_vnc(options = { }) ⇒ Object

Raises:

  • (ArgumentError)


34
35
36
37
# File 'lib/fog/vsphere/requests/compute/vm_config_vnc.rb', line 34

def vm_config_vnc(options = { })
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  { 'task_state' => 'success' }
end

#vm_destroy(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
# File 'lib/fog/vsphere/requests/compute/vm_destroy.rb', line 16

def vm_destroy(options = {})
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  { 'task_state' => 'success' }
end

#vm_get_vnc(uuid) ⇒ Object



39
40
41
# File 'lib/fog/vsphere/requests/compute/vm_config_vnc.rb', line 39

def vm_get_vnc uuid
  {:password => 'secret', :port => '5900', :enabled => 'true'}
end

#vm_migrate(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


25
26
27
28
29
# File 'lib/fog/vsphere/requests/compute/vm_migrate.rb', line 25

def vm_migrate(options = {})
  priority = options['priority'].nil? ? 'defaultPriority' : options["priority"]
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  { 'task_state' => 'success' }
end

#vm_power_off(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
# File 'lib/fog/vsphere/requests/compute/vm_power_off.rb', line 27

def vm_power_off(options = {})
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  vm = get_virtual_machine(options['instance_uuid'])
  vm["power_state"] = "poweredOff"
  {
    'task_state'     => "running",
    'power_off_type' => options['force'] ? 'cut_power' : 'shutdown_guest',
  }
end

#vm_power_on(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
# File 'lib/fog/vsphere/requests/compute/vm_power_on.rb', line 19

def vm_power_on(options = {})
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  { 'task_state' => 'success' }
end

#vm_reboot(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
27
# File 'lib/fog/vsphere/requests/compute/vm_reboot.rb', line 24

def vm_reboot(options = {})
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  { 'task_state'     => "running", 'reboot_type' => options['force'] ? 'reset_power' : 'reboot_guest' }
end

#vm_reconfig_cpus(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb', line 14

def vm_reconfig_cpus(options = {})
  raise ArgumentError, "cpus is a required parameter" unless options.key? 'cpus'
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  hardware_spec={'numCPUs' => options['cpus'], 'numCoresPerSocket' => options['corespersocket']}
  vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec )
end

#vm_reconfig_hardware(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
# File 'lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb', line 16

def vm_reconfig_hardware(options = {})
  raise ArgumentError, "hardware_spec is a required parameter" unless options.key? 'hardware_spec'
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  { 'task_state' => 'success' }
end

#vm_reconfig_memory(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb', line 14

def vm_reconfig_memory(options = {})
  raise ArgumentError, "memory is a required parameter" unless options.key? 'memory'
  raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
  hardware_spec={'memoryMB' => options['memory']}
  vm_reconfig_hardware('instance_uuid' => options['instance_uuid'], 'hardware_spec' => hardware_spec )
end