1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[vsphere] adds memory and cpu server attributes

This commit is contained in:
Ohad Levy 2012-03-28 10:20:27 +02:00 committed by Ohad Levy
parent 0644377c60
commit 735a8822cc
2 changed files with 14 additions and 2 deletions

View file

@ -49,6 +49,8 @@ module Fog
:tools_state => 'guest.toolsStatus',
:tools_version => 'guest.toolsVersionStatus',
:is_a_template => 'config.template',
:memory_mb => 'config.hardware.memoryMB',
:cpus => 'config.hardware.numCPU',
}
# Utility method to convert a VMware managed object into an attribute hash.
@ -65,8 +67,8 @@ module Fog
# API. The hypervisor name and mac_addresses attributes may not be available
# so we need catch any exceptions thrown during lookup and set them to nil.
#
# The use of the "tap" method here is a convience, it allows us to update the
# hash object without expliclty returning the hash at the end of the method.
# The use of the "tap" method here is a convenience, it allows us to update the
# hash object without explicitly returning the hash at the end of the method.
Hash[ATTR_TO_PROP.map { |k,v| [k.to_s, props[v]] }].tap do |attrs|
attrs['id'] ||= vm_mob_ref._ref
attrs['mo_ref'] = vm_mob_ref._ref

View file

@ -34,19 +34,24 @@ module Fog
attribute :connection_state
attribute :mo_ref
attribute :path
attribute :memory_mb
attribute :cpus
def vm_reconfig_memory(options = {})
requires :instance_uuid, :memory
connection.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory)
end
def vm_reconfig_cpus(options = {})
requires :instance_uuid, :cpus
connection.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus)
end
def vm_reconfig_hardware(options = {})
requires :instance_uuid, :hardware_spec
connection.vm_reconfig_hardware('instance_uuid' => instance_uuid, 'hardware_spec' => hardware_spec)
end
def start(options = {})
requires :instance_uuid
connection.vm_power_on('instance_uuid' => instance_uuid)
@ -82,6 +87,7 @@ module Fog
new_vm.connection = self.connection
new_vm
end
def clone(options = {})
requires :name, :path
# Convert symbols to strings
@ -108,6 +114,10 @@ module Fog
tools_state != "toolsNotInstalled"
end
def memory
memory_mb * 1024 * 1024
end
end
end