From: Tony Mack Date: Tue, 26 Jun 2012 02:30:01 +0000 (-0400) Subject: added NovaClient X-Git-Tag: sfa-2.1-12~36^2~8 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=2507c4bc6a6c840ee5fd1099aad520a60d459cfe;hp=2e3b53c4bcd4926efe82d50fef5922548b88eff7;p=sfa.git added NovaClient --- diff --git a/sfa/openstack/client.py b/sfa/openstack/client.py index 59003394..11d9221c 100644 --- a/sfa/openstack/client.py +++ b/sfa/openstack/client.py @@ -1,5 +1,6 @@ from sfa.util.sfalogging import logger from glance import client as glance_client +from novaclient.v1_1.client import Client from sfa.util.config import Config @@ -21,7 +22,7 @@ def parse_novarc(filename): class GlanceClient: - def __init__(self, config): + def __init__(self, config=None): if not config: config = Config() opts = parse_novarc(config.SFA_NOVA_NOVARC) @@ -36,5 +37,24 @@ class GlanceClient: return getattr(self.client, name) +class NovaClient: + def __init__(self, config=None): + if not config: + config = Config() + opts = parse_novarc(config.SFA_NOVA_NOVARC) + + self.client = Client(username=opts.get('OS_USERNAME'), + api_key=opts.get('OS_PASSWORD'), + project_id=opts.get('OS_TENANT_NAME'), + auth_url=opts.get('OS_AUTH_URL'), + region_name='', + extensions=[], + service_type='compute', + service_name='', + ) + + + def __getattr__(self, name): + return getattr(self.client, name)