summaryrefslogtreecommitdiffstats
path: root/nova/adminclient.py
diff options
context:
space:
mode:
authorRyan Lane <rlane@wikimedia.org>2011-01-27 12:17:43 +0000
committerRyan Lane <rlane@wikimedia.org>2011-01-27 12:17:43 +0000
commitc02a587ea03fecde26f49bec52f8d96aa551979a (patch)
tree68e236b508d5019812bf7de65fc1a209d0df474f /nova/adminclient.py
parentfc8f41e9c34c8d14d1c66ca03ce7098cc6b7f04d (diff)
parentcaca4a1320638b0d806f1854ba8233d941f50e86 (diff)
downloadnova-c02a587ea03fecde26f49bec52f8d96aa551979a.tar.gz
nova-c02a587ea03fecde26f49bec52f8d96aa551979a.tar.xz
nova-c02a587ea03fecde26f49bec52f8d96aa551979a.zip
Merge from trunk
Diffstat (limited to 'nova/adminclient.py')
-rw-r--r--nova/adminclient.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/nova/adminclient.py b/nova/adminclient.py
index b2609c8c4..3cdd8347f 100644
--- a/nova/adminclient.py
+++ b/nova/adminclient.py
@@ -190,6 +190,45 @@ class HostInfo(object):
setattr(self, name, value)
+class InstanceType(object):
+ """
+ Information about a Nova instance type, as parsed through SAX.
+
+ **Fields include**
+
+ * name
+ * vcpus
+ * disk_gb
+ * memory_mb
+ * flavor_id
+
+ """
+
+ def __init__(self, connection=None):
+ self.connection = connection
+ self.name = None
+ self.vcpus = None
+ self.disk_gb = None
+ self.memory_mb = None
+ self.flavor_id = None
+
+ def __repr__(self):
+ return 'InstanceType:%s' % self.name
+
+ def startElement(self, name, attrs, connection):
+ return None
+
+ def endElement(self, name, value, connection):
+ if name == "memoryMb":
+ self.memory_mb = str(value)
+ elif name == "flavorId":
+ self.flavor_id = str(value)
+ elif name == "diskGb":
+ self.disk_gb = str(value)
+ else:
+ setattr(self, name, str(value))
+
+
class NovaAdminClient(object):
def __init__(
@@ -373,3 +412,8 @@ class NovaAdminClient(object):
def get_hosts(self):
return self.apiconn.get_list('DescribeHosts', {}, [('item', HostInfo)])
+
+ def get_instance_types(self):
+ """Grabs the list of all users."""
+ return self.apiconn.get_list('DescribeInstanceTypes', {},
+ [('item', InstanceType)])