summaryrefslogtreecommitdiffstats
path: root/nova/adminclient.py
diff options
context:
space:
mode:
authorTodd Willey <todd@ansolabs.com>2011-02-22 23:42:49 -0500
committerTodd Willey <todd@ansolabs.com>2011-02-22 23:42:49 -0500
commit409ee5ff22bbd62d94a7afb1df1e6b7353c95d83 (patch)
treedb20f793e64db576bf1b088f581c0443da7ab0e7 /nova/adminclient.py
parentafcec00e9e05031e1e7c086ff75fb05cf97c412d (diff)
downloadnova-409ee5ff22bbd62d94a7afb1df1e6b7353c95d83.tar.gz
nova-409ee5ff22bbd62d94a7afb1df1e6b7353c95d83.tar.xz
nova-409ee5ff22bbd62d94a7afb1df1e6b7353c95d83.zip
Update the admin client to deal with VPNs and have a function host list.
Diffstat (limited to 'nova/adminclient.py')
-rw-r--r--nova/adminclient.py63
1 files changed, 54 insertions, 9 deletions
diff --git a/nova/adminclient.py b/nova/adminclient.py
index c614b274c..fe2aca351 100644
--- a/nova/adminclient.py
+++ b/nova/adminclient.py
@@ -23,6 +23,8 @@ import base64
import boto
import boto.exception
import httplib
+import re
+import string
from boto.ec2.regioninfo import RegionInfo
@@ -165,19 +167,20 @@ class HostInfo(object):
**Fields Include**
- * Disk stats
- * Running Instances
- * Memory stats
- * CPU stats
- * Network address info
- * Firewall info
- * Bridge and devices
-
+ * Hostname
+ * Compute service status
+ * Volume service status
+ * Instance count
+ * Volume count
"""
def __init__(self, connection=None):
self.connection = connection
self.hostname = None
+ self.compute = None
+ self.volume = None
+ self.instance_count = 0
+ self.volume_count = 0
def __repr__(self):
return 'Host:%s' % self.hostname
@@ -188,7 +191,39 @@ class HostInfo(object):
# this is needed by the sax parser, so ignore the ugly name
def endElement(self, name, value, connection):
- setattr(self, name, value)
+ fixed_name = string.lower(re.sub(r'([A-Z])', r'_\1', name))
+ setattr(self, fixed_name, value)
+
+
+class Vpn(object):
+ """
+ Information about a Vpn, as parsed through SAX
+
+ **Fields Include**
+
+ * instance_id
+ * project_id
+ * public_ip
+ * public_port
+ * created_at
+ * internal_ip
+ * state
+ """
+
+ def __init__(self, connection=None):
+ self.connection = connection
+ self.instance_id = None
+ self.project_id = None
+
+ def __repr__(self):
+ return 'Vpn:%s:%s' % (self.project_id, self.instance_id)
+
+ def startElement(self, name, attrs, connection):
+ return None
+
+ def endElement(self, name, value, connection):
+ fixed_name = string.lower(re.sub(r'([A-Z])', r'_\1', name))
+ setattr(self, fixed_name, value)
class InstanceType(object):
@@ -422,6 +457,16 @@ class NovaAdminClient(object):
zip = self.apiconn.get_object('GenerateX509ForUser', params, UserInfo)
return zip.file
+ def start_vpn(self, project):
+ """
+ Starts the vpn for a user
+ """
+ return self.apiconn.get_object('StartVpn', {'Project': project}, Vpn)
+
+ def get_vpns(self):
+ """Return a list of vpn with project name"""
+ return self.apiconn.get_list('DescribeVpns', {}, [('item', Vpn)])
+
def get_hosts(self):
return self.apiconn.get_list('DescribeHosts', {}, [('item', HostInfo)])