1 from sfa.util.sfalogging import logger
2 from glance import client as glance_client
3 from novaclient.v1_1.client import Client
4 from sfa.util.config import Config
7 def parse_novarc(filename):
9 f = open(filename, 'r')
12 line = line.replace('export', '').strip()
13 parts = line.split('=')
15 value = parts[1].replace("\'", "")
16 value = value.replace('\"', '')
17 opts[parts[0]] = value
25 def __init__(self, config=None):
28 opts = parse_novarc(config.SFA_NOVA_NOVARC)
30 self.client = glance_client.get_client(host='0.0.0.0',
31 username=opts.get('OS_USERNAME'),
32 password=opts.get('OS_PASSWORD'),
33 tenant=opts.get('OS_TENANT_NAME'),
34 auth_url=opts.get('OS_AUTH_URL'))
36 def __getattr__(self, name):
37 return getattr(self.client, name)
41 def __init__(self, config=None):
44 opts = parse_novarc(config.SFA_NOVA_NOVARC)
46 self.client = Client(username=opts.get('OS_USERNAME'),
47 api_key=opts.get('OS_PASSWORD'),
48 project_id=opts.get('OS_TENANT_NAME'),
49 auth_url=opts.get('OS_AUTH_URL'),
52 service_type='compute',
57 def __getattr__(self, name):
58 return getattr(self.client, name)