2 from boto.ec2.regioninfo import RegionInfo
3 from boto.exception import EC2ResponseError
4 from sfa.util.sfalogging import logger
9 A xmlrpc connection to the euca api.
12 def __init__(self, config):
15 def get_euca_connection(self):
17 access_key = self.config.SFA_EUCA_ACCESS_KEY
18 secret_key = self.config.SFA_EUCA_SECRET_KEY
19 url = self.config.SFA_EUCA_URL
21 euca_port = self.config.SFA_EUCA_PORT
24 # Split the url into parts
25 if url.find('https://') >= 0:
27 url = url.replace('https://', '')
28 elif url.find('http://') >= 0:
30 url = url.replace('http://', '')
31 (host, parts) = url.split(':')
33 parts = parts.split('/')
36 path = '/'.join(parts)
38 if not access_key or not secret_key or not url:
39 logger.error('Please set ALL of the required environment ' \
40 'variables by sourcing the eucarc file.')
42 return boto.connect_ec2(aws_access_key_id=access_key,
43 aws_secret_access_key=secret_key,
45 region=RegionInfo(None, 'eucalyptus', host),
49 def __getattr__(self, name):
50 def func(*args, **kwds):
51 conn = self.get_euca_connection()
52 return getattr(conn, name)(*args, **kwds)