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