From: Steven Dake Date: Tue, 11 Sep 2012 20:49:09 +0000 (-0700) Subject: Make S3 optional since swiftclient is not available in all distributions X-Git-Tag: 2014.1~1436 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1ba219d38df61ab4b0807c5fa730287ec903ccca;p=openstack-build%2Fheat-build.git Make S3 optional since swiftclient is not available in all distributions Change-Id: Ic5f61ac41090fd599f01b3eaae4ffb03aac2ebdd Signed-off-by: Steven Dake --- diff --git a/heat/engine/resources.py b/heat/engine/resources.py index 5c39033a..428cd736 100644 --- a/heat/engine/resources.py +++ b/heat/engine/resources.py @@ -18,7 +18,14 @@ from datetime import datetime from novaclient.v1_1 import client as nc from keystoneclient.v2_0 import client as kc -from swiftclient import client as swiftclient + +# swiftclient not available in all distributions - make s3 an optional +# feature +try: + from swiftclient import client as swiftclient + swiftclient_present = True +except: + swiftclient_present = False from heat.common import exception from heat.common import config @@ -230,6 +237,8 @@ class Resource(object): return self._nova[service_type] def swift(self): + if swiftclient_present == False: + return None if self._swift: return self._swift diff --git a/heat/engine/s3.py b/heat/engine/s3.py index 37271fb6..7a181635 100644 --- a/heat/engine/s3.py +++ b/heat/engine/s3.py @@ -20,7 +20,11 @@ from urlparse import urlparse from heat.common import exception from heat.engine.resources import Resource from heat.openstack.common import log as logging -from swiftclient.client import ClientException +try: + from swiftclient.client import ClientException + swiftclient_present = True +except: + swiftclient_present = False logger = logging.getLogger('heat.engine.s3') @@ -46,6 +50,15 @@ class S3Bucket(Resource): def __init__(self, name, json_snippet, stack): super(S3Bucket, self).__init__(name, json_snippet, stack) + def validate(self): + ''' + Validate any of the provided params + ''' + #check if swiftclient is installed + if swiftclient_present == False: + return {'Error': + 'S3 services unavaialble because of missing swiftclient.'} + def handle_create(self): """Create a bucket.""" container = 'heat-%s-%s' % (self.name,