X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fopenstack%2Fclient.py;h=215d33305412e2a24ddaf547faa59181b5f69428;hb=3522ff3c10d2507c78e790414c6cf4d01aa3ef36;hp=f0d717e607c3dc32116cca1b987aa533d6fbba0a;hpb=80930ae9f818e10b64042736b59733fc0b32b660;p=sfa.git diff --git a/sfa/openstack/client.py b/sfa/openstack/client.py index f0d717e6..215d3330 100644 --- a/sfa/openstack/client.py +++ b/sfa/openstack/client.py @@ -23,14 +23,26 @@ def parse_novarc(filename): class KeystoneClient: - def __init__(self, config=None): + def __init__(self, username=None, password=None, tenant=None, url=None, config=None): if not config: config = Config() opts = parse_novarc(config.SFA_NOVA_NOVARC) + if username: + opts['OS_USERNAME'] = username + if password: + opts['OS_PASSWORD'] = password + if tenant: + opts['OS_TENANT_NAME'] = tenant + if url: + opts['OS_AUTH_URL'] = url + self.opts = opts self.client = keystone_client.Client(username=opts.get('OS_USERNAME'), password=opts.get('OS_PASSWORD'), tenant_name=opts.get('OS_TENANT_NAME'), auth_url=opts.get('OS_AUTH_URL')) + + def connect(self, *args, **kwds): + self.__init__(*args, **kwds) def __getattr__(self, name): return getattr(self.client, name) @@ -50,10 +62,19 @@ class GlanceClient: return getattr(self.client, name) class NovaClient: - def __init__(self, config=None): + def __init__(self, username=None, password=None, tenant=None, url=None, config=None): if not config: config = Config() opts = parse_novarc(config.SFA_NOVA_NOVARC) + if username: + opts['OS_USERNAME'] = username + if password: + opts['OS_PASSWORD'] = password + if tenant: + opts['OS_TENANT_NAME'] = tenant + if url: + opts['OS_AUTH_URL'] = url + self.opts = opts self.client = nova_client.Client(username=opts.get('OS_USERNAME'), api_key=opts.get('OS_PASSWORD'), project_id=opts.get('OS_TENANT_NAME'), @@ -63,6 +84,9 @@ class NovaClient: service_type='compute', service_name='', ) + + def connect(self, *args, **kwds): + self.__init__(*args, **kwds) def __getattr__(self, name): return getattr(self.client, name)