summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-07-24 03:28:12 +0000
committerGerrit Code Review <review@openstack.org>2012-07-24 03:28:12 +0000
commit4d882ab978055b0b4199a749f4c243cfd53425ef (patch)
treec8bb2aac83b377ed832fa202d061bda1764d8a9a /nova/api
parent8a164f5e05509307720ad8a8f39ab1f352553098 (diff)
parent09d978994325b28c76050f112af3ee66b84a5e1f (diff)
Merge "Add call to get hypervisor statistics"
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/hypervisors.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/hypervisors.py b/nova/api/openstack/compute/contrib/hypervisors.py
index 49b050871..33aaa014b 100644
--- a/nova/api/openstack/compute/contrib/hypervisors.py
+++ b/nova/api/openstack/compute/contrib/hypervisors.py
@@ -104,6 +104,26 @@ class HypervisorServersTemplate(xmlutil.TemplateBuilder):
return xmlutil.MasterTemplate(root, 1)
+class HypervisorStatisticsTemplate(xmlutil.TemplateBuilder):
+ def construct(self):
+ root = xmlutil.TemplateElement('hypervisor_statistics',
+ selector='hypervisor_statistics')
+ root.set('count')
+ root.set('vcpus')
+ root.set('memory_mb')
+ root.set('local_gb')
+ root.set('vcpus_used')
+ root.set('memory_mb_used')
+ root.set('local_gb_used')
+ root.set('free_ram_mb')
+ root.set('free_disk_gb')
+ root.set('current_workload')
+ root.set('running_vms')
+ root.set('disk_available_least')
+
+ return xmlutil.MasterTemplate(root, 1)
+
+
class HypervisorsController(object):
"""The Hypervisors API controller for the OpenStack API."""
@@ -211,6 +231,13 @@ class HypervisorsController(object):
msg = _("No hypervisor matching '%s' could be found.") % id
raise webob.exc.HTTPNotFound(explanation=msg)
+ @wsgi.serializers(xml=HypervisorStatisticsTemplate)
+ def statistics(self, req):
+ context = req.environ['nova.context']
+ authorize(context)
+ stats = db.compute_node_statistics(context)
+ return dict(hypervisor_statistics=stats)
+
class Hypervisors(extensions.ExtensionDescriptor):
"""Admin-only hypervisor administration"""
@@ -223,7 +250,8 @@ class Hypervisors(extensions.ExtensionDescriptor):
def get_resources(self):
resources = [extensions.ResourceExtension('os-hypervisors',
HypervisorsController(),
- collection_actions={'detail': 'GET'},
+ collection_actions={'detail': 'GET',
+ 'statistics': 'GET'},
member_actions={'uptime': 'GET',
'search': 'GET',
'servers': 'GET'})]