summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorTiago Mello <tmello@linux.vnet.ibm.com>2012-08-27 14:46:48 -0400
committerTiago Mello <tmello@linux.vnet.ibm.com>2012-08-29 11:14:54 -0400
commite5bec8b913a1f2fb2e15710bc9401e3384470cce (patch)
tree271e3e5cf1ca803369d0270f9ec2e3ae83a266f2 /nova
parent20c6bb6c9000fa0d193f688b668f5f3eeda8fb05 (diff)
downloadnova-e5bec8b913a1f2fb2e15710bc9401e3384470cce.tar.gz
nova-e5bec8b913a1f2fb2e15710bc9401e3384470cce.tar.xz
nova-e5bec8b913a1f2fb2e15710bc9401e3384470cce.zip
Implements PowerVM get_available_resource method.
Implements get_available_resource method in the PowerVM driver to fix the failure when launching nova-compute. Also, it removes the update_available_resource method from PowerVMDriver which is no longer required. Fixes bug 1040789 Change-Id: Ibc7e9b80e6d9b8ef3c1a844783a890c592517f89
Diffstat (limited to 'nova')
-rw-r--r--nova/virt/powervm/command.py6
-rw-r--r--nova/virt/powervm/driver.py14
-rw-r--r--nova/virt/powervm/operator.py34
3 files changed, 43 insertions, 11 deletions
diff --git a/nova/virt/powervm/command.py b/nova/virt/powervm/command.py
index 8cef5b728..3e51c933c 100644
--- a/nova/virt/powervm/command.py
+++ b/nova/virt/powervm/command.py
@@ -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)
diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py
index 577000828..0ee52105a 100644
--- a/nova/virt/powervm/driver.py
+++ b/nova/virt/powervm/driver.py
@@ -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."""
diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py
index 9503038f2..da90af650 100644
--- a/nova/virt/powervm/operator.py
+++ b/nova/virt/powervm/operator.py
@@ -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.