changed some config options
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 14 Feb 2012 18:10:14 +0000 (13:10 -0500)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 14 Feb 2012 18:10:14 +0000 (13:10 -0500)
config/default_config.xml
sfa/openstack/euca_shell.py

index 6158905..5ce430e 100644 (file)
@@ -277,6 +277,32 @@ Thierry Parmentelat
       </variablelist>
     </category>
 
+
+    <!-- ======================================== -->
+    <category id="sfa_nova">
+      <name>SFA Flash Policy</name>
+      <description>The settings that affect how SFA connects to 
+                   the Nova/EC2 API</description>
+      <variablelist>
+        <variable id="user" type="string">
+          <name>Sfa nova user</name>
+          <value>novaadmin</value>
+          <description>Account/context to use when performing 
+                       administrative nova operations</description>
+        </variable>
+        <variable id="api_url" type="string">
+          <name>Nova API url</name>
+          <value>127.0.0.1</value>
+          <description>The Nova/EC2 API url </description>
+        </variable>
+        <variable id="api_port" type="int">
+          <name>Nova API Port</name>
+          <value>8773</value>
+          <description>The Nova/EC2 API port.</description>
+        </variable>
+      </variablelist>
+    </category>
+
   </variables>
 
   <comps>
index c67d60e..cb2817c 100644 (file)
@@ -1,8 +1,13 @@
-import boto
-from boto.ec2.regioninfo import RegionInfo
-from boto.exception import EC2ResponseError
-from sfa.util.sfalogging import logger
+try:
+    import boto
+    from boto.ec2.regioninfo import RegionInfo
+    from boto.exception import EC2ResponseError
+    has_boto=True
+except:
+    has_boto=False    
 
+from sfa.util.sfalogging import logger
+from sfa.openstack.nova_shell import NovaShell
 
 class EucaShell:
     """
@@ -13,12 +18,16 @@ class EucaShell:
         self.config = Config
 
     def get_euca_connection(self):
-
-        access_key = self.config.SFA_EUCA_ACCESS_KEY
-        secret_key = self.config.SFA_EUCA_SECRET_KEY
-        url = self.config.SFA_EUCA_URL
+        if not has_boto:
+            logger.info('Unable to access EC2 API - boto library not found.')
+            return None
+        nova = NovaShell(self.config)
+        admin_user = nova.auth_manager.get_user(self.config.SFA_NOVA_USER)
+        access_key = admin_user.access
+        secret_key = admin_user.secret
+        url = self.config.SFA_NOVA_API_URL
         path = "/"
-        euca_port = self.config.SFA_EUCA_PORT        
+        euca_port = self.config.SFA_NOVA_API_PORT        
         use_ssl = False
 
         # Split the url into parts 
@@ -35,10 +44,6 @@ class EucaShell:
             parts = parts[1:]
             path = '/'.join(parts)
         
-        if not access_key or not secret_key or not url:
-            logger.error('Please set ALL of the required environment ' \
-                         'variables by sourcing the eucarc file.')
-            return None
         return boto.connect_ec2(aws_access_key_id=access_key,
                                 aws_secret_access_key=secret_key,
                                 is_secure=use_ssl,