3 from boto.ec2.regioninfo import RegionInfo
4 from boto.exception import EC2ResponseError
9 from sfa.util.sfalogging import logger
10 from sfa.openstack.nova_shell import NovaShell
14 A xmlrpc connection to the euca api.
17 def __init__(self, config):
20 def get_euca_connection(self):
22 logger.info('Unable to access EC2 API - boto library not found.')
24 nova = NovaShell(self.config)
25 admin_user = nova.auth_manager.get_user(self.config.SFA_NOVA_USER)
26 access_key = admin_user.access
27 secret_key = admin_user.secret
28 url = self.config.SFA_NOVA_API_URL
30 euca_port = self.config.SFA_NOVA_API_PORT
33 # Split the url into parts
34 if url.find('https://') >= 0:
36 url = url.replace('https://', '')
37 elif url.find('http://') >= 0:
39 url = url.replace('http://', '')
40 (host, parts) = url.split(':')
42 parts = parts.split('/')
45 path = '/'.join(parts)
47 return boto.connect_ec2(aws_access_key_id=access_key,
48 aws_secret_access_key=secret_key,
50 region=RegionInfo(None, 'eucalyptus', host),
54 def __getattr__(self, name):
55 def func(*args, **kwds):
56 conn = self.get_euca_connection()
57 return getattr(conn, name)(*args, **kwds)