From 9b30c6b0437afeb679cdf00bc8b7abae3e41dbd3 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Tue, 14 Feb 2012 13:10:14 -0500 Subject: [PATCH] changed some config options --- config/default_config.xml | 26 ++++++++++++++++++++++++++ sfa/openstack/euca_shell.py | 31 ++++++++++++++++++------------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/config/default_config.xml b/config/default_config.xml index 6158905d..5ce430e4 100644 --- a/config/default_config.xml +++ b/config/default_config.xml @@ -277,6 +277,32 @@ Thierry Parmentelat + + + + SFA Flash Policy + The settings that affect how SFA connects to + the Nova/EC2 API + + + Sfa nova user + novaadmin + Account/context to use when performing + administrative nova operations + + + Nova API url + 127.0.0.1 + The Nova/EC2 API url + + + Nova API Port + 8773 + The Nova/EC2 API port. + + + + diff --git a/sfa/openstack/euca_shell.py b/sfa/openstack/euca_shell.py index c67d60ec..cb2817cd 100644 --- a/sfa/openstack/euca_shell.py +++ b/sfa/openstack/euca_shell.py @@ -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, -- 2.43.0