Merge "Implements PowerVM get_available_resource method."
This commit is contained in:
commit
d0693f6c5c
@ -59,6 +59,9 @@ class BaseCommand(object):
|
||||
def lshwres(self, args=''):
|
||||
return 'lshwres %s' % args
|
||||
|
||||
def hostname(self, args=''):
|
||||
return 'hostname %s' % args
|
||||
|
||||
def vhost_by_instance_id(self, instance_id_hex):
|
||||
pass
|
||||
|
||||
@ -88,3 +91,6 @@ class IVMCommand(BaseCommand):
|
||||
|
||||
def mkvdev(self, args=''):
|
||||
return 'ioscli ' + BaseCommand.mkvdev(self, args=args)
|
||||
|
||||
def hostname(self, args=''):
|
||||
return 'ioscli ' + BaseCommand.hostname(self, args=args)
|
||||
|
@ -169,17 +169,9 @@ class PowerVMDriver(driver.ComputeDriver):
|
||||
"""Power on the specified instance"""
|
||||
self._powervm.power_on(instance['name'])
|
||||
|
||||
def update_available_resource(self, ctxt, host):
|
||||
"""Updates compute manager resource info on ComputeNode table.
|
||||
|
||||
This method is called when nova-compute launches, and
|
||||
whenever admin executes "nova-manage service update_resource".
|
||||
|
||||
:param ctxt: security context
|
||||
:param host: hostname that compute manager is currently running
|
||||
|
||||
"""
|
||||
pass
|
||||
def get_available_resource(self):
|
||||
"""Retrieve resource info."""
|
||||
return self._powervm.get_available_resource()
|
||||
|
||||
def host_power_action(self, host, action):
|
||||
"""Reboots, shuts down or powers up the host."""
|
||||
|
@ -106,6 +106,32 @@ class PowerVMOperator(object):
|
||||
if re.search(r'^instance-[0-9]{8}$', instance)]
|
||||
return instances
|
||||
|
||||
def get_available_resource(self):
|
||||
"""Retrieve resource info.
|
||||
|
||||
:returns: dictionary containing resource info
|
||||
"""
|
||||
data = self.get_host_stats()
|
||||
# Memory data is in MB already.
|
||||
memory_mb_used = data['host_memory_total'] - data['host_memory_free']
|
||||
|
||||
# Convert to GB
|
||||
local_gb = data['disk_total'] / 1024
|
||||
local_gb_used = data['disk_used'] / 1024
|
||||
|
||||
dic = {'vcpus': data['vcpus'],
|
||||
'memory_mb': data['host_memory_total'],
|
||||
'local_gb': local_gb,
|
||||
'vcpus_used': data['vcpus_used'],
|
||||
'memory_mb_used': memory_mb_used,
|
||||
'local_gb_used': local_gb_used,
|
||||
'hypervisor_type': data['hypervisor_type'],
|
||||
'hypervisor_version': data['hypervisor_version'],
|
||||
'hypervisor_hostname': self._operator.get_hostname(),
|
||||
'cpu_info': ','.join(data['cpu_info']),
|
||||
'disk_available_least': data['disk_total']}
|
||||
return dic
|
||||
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""Return currently known host stats"""
|
||||
if refresh:
|
||||
@ -401,6 +427,14 @@ class BaseOperator(object):
|
||||
|
||||
return None
|
||||
|
||||
def get_hostname(self):
|
||||
"""Returns the managed system hostname.
|
||||
|
||||
:returns: string -- hostname
|
||||
"""
|
||||
output = self.run_command(self.command.hostname())
|
||||
return output[0]
|
||||
|
||||
def remove_disk(self, disk_name):
|
||||
"""Removes a disk.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user