From: Tomas Sedovic Date: Thu, 13 Dec 2012 17:22:07 +0000 (+0100) Subject: Add configurable cloud backend X-Git-Tag: 2014.1~1016 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=714c3f9e7c2e1945e1b3a68a032d8e62b5f35cc4;p=openstack-build%2Fheat-build.git Add configurable cloud backend 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 --- diff --git a/etc/heat/heat-engine.conf b/etc/heat/heat-engine.conf index 82a47175..755df057 100644 --- a/etc/heat/heat-engine.conf +++ b/etc/heat/heat-engine.conf @@ -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 diff --git a/heat/engine/clients.py b/heat/engine/clients.py index 6ac05054..7a42b788 100644 --- a/heat/engine/clients.py +++ b/heat/engine/clients.py @@ -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)