From c5edaa2186add12947185cb1fd47e0a48eccafa9 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sun, 25 Jul 2010 20:32:33 +0100 Subject: Replace hardcoded example URL, username, and password with flags called xenapi_connection_url, xenapi_connection_username, xenapi_connection_password. --- nova/virt/xenapi.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'nova') diff --git a/nova/virt/xenapi.py b/nova/virt/xenapi.py index 58fcd79c5..dc372e3e3 100644 --- a/nova/virt/xenapi.py +++ b/nova/virt/xenapi.py @@ -30,6 +30,17 @@ from nova.compute import power_state XenAPI = None +FLAGS = flags.FLAGS +flags.DEFINE_string('xenapi_connection_url', + None, + 'URL for connection to XenServer/Xen Cloud Platform. Required if connection_type=xenapi.') +flags.DEFINE_string('xenapi_connection_username', + 'root', + 'Username for connection to XenServer/Xen Cloud Platform. Used only if connection_type=xenapi.') +flags.DEFINE_string('xenapi_connection_password', + None, + 'Password for connection to XenServer/Xen Cloud Platform. Used only if connection_type=xenapi.') + def get_connection(_): """Note that XenAPI doesn't have a read-only connection mode, so @@ -37,10 +48,14 @@ def get_connection(_): # This is loaded late so that there's no need to install this # library when not using XenAPI. global XenAPI - if XenAPI is not None: + if XenAPI is None: XenAPI = __import__('XenAPI') - return XenAPIConnection('http://eli.testdev.hq.xensource.com', - 'root', 'xensource') + url = FLAGS.xenapi_connection_url + username = FLAGS.xenapi_connection_username + password = FLAGS.xenapi_connection_password + if not url or password is None: + raise Exception('Must specify xenapi_connection_url, xenapi_connection_username (optionally), and xenapi_connection_password to use connection_type=xenapi') + return XenAPIConnection(url, username, password) class XenAPIConnection(object): -- cgit