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