deeper pass on xmlrpclib vs xmlrpc.client as well as configparser
[sfa.git] / sfa / openstack / shell.py
1 import sys
2 import socket
3 import gettext
4 from urlparse import urlparse
5 from sfa.util.sfalogging import logger
6 from sfa.util.config import Config
7
8 try:
9     from sfa.openstack.client import GlanceClient, NovaClient, KeystoneClient
10     has_nova = True
11 except:
12     has_nova = False
13
14
15
16 class Shell:
17     """
18     A simple native shell to a nova backend. 
19     This class can receive all nova calls to the underlying testbed
20     """
21     
22     # dont care about limiting calls yet 
23     direct_calls = []
24     alias_calls = {}
25
26
27     # use the 'capability' auth mechanism for higher performance when the PLC db is local    
28     def __init__ ( self, config=None) :
29         if not config:
30             config = Config()
31         if has_nova:
32             # instantiate managers 
33             self.auth_manager = KeystoneClient(config=config)
34             self.image_manager = GlanceClient(config=config)
35             self.nova_manager = NovaClient(config=config)
36         else:
37             logger.debug('nova access - REST')
38             raise SfaNotImplemented('nova access - Rest')