4 from urlparse import urlparse
5 from sfa.util.sfalogging import logger
8 from nova import context
16 A simple xmlrpc shell to a myplc instance
17 This class can receive all Openstack calls to the underlying testbed
20 # dont care about limiting calls yet
25 # use the 'capability' auth mechanism for higher performance when the PLC db is local
26 def __init__ ( self, config ) :
27 url = config.SFA_PLC_URL
28 # try to figure if the url is local
29 hostname=urlparse(url).hostname
30 if hostname == 'localhost': is_local=True
31 # otherwise compare IP addresses;
32 # this might fail for any number of reasons, so let's harden that
34 # xxx todo this seems to result in a DNS request for each incoming request to the AM
35 # should be cached or improved
36 url_ip=socket.gethostbyname(hostname)
37 local_ip=socket.gethostbyname(socket.gethostname())
38 if url_ip==local_ip: is_local=True
43 if is_local and has_nova:
44 logger.debug('openstack access - native')
46 flags.FLAGS(['foo', '--flagfile=/etc/nova/nova.conf', 'foo', 'foo'])
47 self.auth = context.get_admin_context()
52 logger.debug('openstack access - REST')
53 raise SfaNotImplemented('openstack access - Rest')
55 def __getattr__(self, name):
56 def func(*args, **kwds):
57 result=getattr(self.proxy, name)(self.auth, *args, **kwds)