X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=blobdiff_plain;f=sfa%2Fopenstack%2Fclient.py;h=40a3f85db88874a76d52bb7ee53972cb40765ebf;hp=215d33305412e2a24ddaf547faa59181b5f69428;hb=04a3f20dc71bf8b3f96b1e3172623aa346a638a7;hpb=c1c136b3042a24604823c6da135308b7c031c234 diff --git a/sfa/openstack/client.py b/sfa/openstack/client.py index 215d3330..40a3f85d 100644 --- a/sfa/openstack/client.py +++ b/sfa/openstack/client.py @@ -14,7 +14,7 @@ def parse_novarc(filename): parts = line.split('=') if len(parts) > 1: value = parts[1].replace("\'", "") - value = value.replace('\"', '') + value = value.replace('\"', '') opts[parts[0]] = value except: pass @@ -23,6 +23,7 @@ def parse_novarc(filename): class KeystoneClient: + def __init__(self, username=None, password=None, tenant=None, url=None, config=None): if not config: config = Config() @@ -35,33 +36,41 @@ class KeystoneClient: opts['OS_TENANT_NAME'] = tenant if url: opts['OS_AUTH_URL'] = url - self.opts = opts + 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'), + 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) + return getattr(self.client, name) class GlanceClient: + def __init__(self, config=None): if not config: config = Config() opts = parse_novarc(config.SFA_NOVA_NOVARC) self.client = glance_client.get_client(host='0.0.0.0', - username=opts.get('OS_USERNAME'), - password=opts.get('OS_PASSWORD'), - tenant=opts.get('OS_TENANT_NAME'), + username=opts.get( + 'OS_USERNAME'), + password=opts.get( + 'OS_PASSWORD'), + tenant=opts.get( + 'OS_TENANT_NAME'), auth_url=opts.get('OS_AUTH_URL')) + def __getattr__(self, name): return getattr(self.client, name) + class NovaClient: + def __init__(self, username=None, password=None, tenant=None, url=None, config=None): if not config: config = Config() @@ -82,11 +91,11 @@ class NovaClient: region_name='', extensions=[], service_type='compute', - service_name='', + service_name='', ) def connect(self, *args, **kwds): self.__init__(*args, **kwds) - + def __getattr__(self, name): - return getattr(self.client, name) + return getattr(self.client, name)