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:
parent
0644377c60
commit
735a8822cc
2 changed files with 14 additions and 2 deletions
|
@ -49,6 +49,8 @@ module Fog
|
||||||
:tools_state => 'guest.toolsStatus',
|
:tools_state => 'guest.toolsStatus',
|
||||||
:tools_version => 'guest.toolsVersionStatus',
|
:tools_version => 'guest.toolsVersionStatus',
|
||||||
:is_a_template => 'config.template',
|
: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.
|
# 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
|
# 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.
|
# 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
|
# The use of the "tap" method here is a convenience, it allows us to update the
|
||||||
# hash object without expliclty returning the hash at the end of the method.
|
# 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|
|
Hash[ATTR_TO_PROP.map { |k,v| [k.to_s, props[v]] }].tap do |attrs|
|
||||||
attrs['id'] ||= vm_mob_ref._ref
|
attrs['id'] ||= vm_mob_ref._ref
|
||||||
attrs['mo_ref'] = vm_mob_ref._ref
|
attrs['mo_ref'] = vm_mob_ref._ref
|
||||||
|
|
|
@ -34,19 +34,24 @@ module Fog
|
||||||
attribute :connection_state
|
attribute :connection_state
|
||||||
attribute :mo_ref
|
attribute :mo_ref
|
||||||
attribute :path
|
attribute :path
|
||||||
|
attribute :memory_mb
|
||||||
|
attribute :cpus
|
||||||
|
|
||||||
def vm_reconfig_memory(options = {})
|
def vm_reconfig_memory(options = {})
|
||||||
requires :instance_uuid, :memory
|
requires :instance_uuid, :memory
|
||||||
connection.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory)
|
connection.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory)
|
||||||
end
|
end
|
||||||
|
|
||||||
def vm_reconfig_cpus(options = {})
|
def vm_reconfig_cpus(options = {})
|
||||||
requires :instance_uuid, :cpus
|
requires :instance_uuid, :cpus
|
||||||
connection.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus)
|
connection.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus)
|
||||||
end
|
end
|
||||||
|
|
||||||
def vm_reconfig_hardware(options = {})
|
def vm_reconfig_hardware(options = {})
|
||||||
requires :instance_uuid, :hardware_spec
|
requires :instance_uuid, :hardware_spec
|
||||||
connection.vm_reconfig_hardware('instance_uuid' => instance_uuid, 'hardware_spec' => hardware_spec)
|
connection.vm_reconfig_hardware('instance_uuid' => instance_uuid, 'hardware_spec' => hardware_spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
def start(options = {})
|
def start(options = {})
|
||||||
requires :instance_uuid
|
requires :instance_uuid
|
||||||
connection.vm_power_on('instance_uuid' => instance_uuid)
|
connection.vm_power_on('instance_uuid' => instance_uuid)
|
||||||
|
@ -82,6 +87,7 @@ module Fog
|
||||||
new_vm.connection = self.connection
|
new_vm.connection = self.connection
|
||||||
new_vm
|
new_vm
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone(options = {})
|
def clone(options = {})
|
||||||
requires :name, :path
|
requires :name, :path
|
||||||
# Convert symbols to strings
|
# Convert symbols to strings
|
||||||
|
@ -108,6 +114,10 @@ module Fog
|
||||||
tools_state != "toolsNotInstalled"
|
tools_state != "toolsNotInstalled"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def memory
|
||||||
|
memory_mb * 1024 * 1024
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue