]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Add configurable cloud backend
authorTomas Sedovic <tomas@sedovic.cz>
Thu, 13 Dec 2012 17:22:07 +0000 (18:22 +0100)
committerTomas Sedovic <tomas@sedovic.cz>
Mon, 14 Jan 2013 09:21:59 +0000 (10:21 +0100)
This allows us to use a different IaaS backend (other than OpenStack).
OpenStack is still used by default.

Change-Id: I1772d57ae583a281204edfb80fbfde220b004a9d
Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
etc/heat/heat-engine.conf
heat/engine/clients.py

index 82a471757e39a5c5cfb28b65b1194f64692a8013..755df05773bb7f05150e8ddcce4a5d0fa484f37a 100644 (file)
@@ -50,6 +50,10 @@ use_syslog = False
 # Facility to use. If unset defaults to LOG_USER.
 # syslog_log_facility = LOG_LOCAL0
 
+# The namespace for the custom backend. Must provide class Clients which will be
+# imported. Defaults to OpenStack if none provided.
+# cloud_backend=deltacloud_heat.client
+
 sql_connection = mysql://heat:heat@localhost/heat
 
 db_backend=heat.db.sqlalchemy.api
index 6ac05054f989eacd312b9807b2bab71dc8d45f98..7a42b788a150a572a7b4b387d8b618f690aa8e6d 100644 (file)
@@ -13,6 +13,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from heat.openstack.common import cfg
+from heat.openstack.common import importutils
 from heat.openstack.common import log as logging
 
 logger = logging.getLogger(__name__)
@@ -32,7 +34,15 @@ except ImportError:
     logger.info('quantumclient not available')
 
 
-class Clients(object):
+cloud_opts = [
+    cfg.StrOpt('cloud_backend',
+               default=None,
+               help="Cloud module to use as a backend. Defaults to OpenStack.")
+]
+cfg.CONF.register_opts(cloud_opts)
+
+
+class OpenStackClients(object):
     '''
     Convenience class to create and cache client instances.
     '''
@@ -162,3 +172,12 @@ class Clients(object):
         self._quantum = quantumclient.Client(**args)
 
         return self._quantum
+
+
+if cfg.CONF.cloud_backend:
+    cloud_backend_module = importutils.import_module(cfg.CONF.cloud_backend)
+    Clients = cloud_backend_module.Clients
+else:
+    Clients = OpenStackClients
+
+logger.debug('Using backend %s' % Clients)