From 9fa9a101cad6730bf0383c061b3c1be3dfaab2ea Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 17 Mar 2015 11:52:01 +1300 Subject: [PATCH] heat.conf options for transport properties default This change adds config options so that operators can choose the default transports for server software_config_transport and deployment signal_transport. With properly set config values, templates should have no need for setting these options at all, making templates more portable across clouds. The defaults currently are the cfn transports but consideration could be made in the future to switch to swift. Downstream deployment tools (puppet etc) would have enough information to set the best heat.conf values, with something like the following logic: - if there is an object-store endpoint, set for *TEMP_URL* - if there is no cloudformation endpoint, set for *HEAT* - else set for *CFN* Change-Id: I5f3d41db35e380486051cee432a7190b3c51fa00 Related-Blueprint: software-config-swift-signal --- heat/common/config.py | 32 +++++++++++++++++++ .../openstack/heat/software_deployment.py | 6 +++- .../engine/resources/openstack/nova/server.py | 3 +- heat/tests/test_server.py | 2 ++ heat/tests/test_software_deployment.py | 1 + 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/heat/common/config.py b/heat/common/config.py index a37a9043f4..80e756c3dd 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -156,6 +156,38 @@ engine_opts = [ help=_('Enables engine with convergence architecture. All ' 'stacks with this option will be created using ' 'convergence engine .')), + cfg.StrOpt('default_software_config_transport', + choices=['POLL_SERVER_CFN', + 'POLL_SERVER_HEAT', + 'POLL_TEMP_URL'], + default='POLL_SERVER_CFN', + help=_('Template default for how the server should receive the ' + 'metadata required for software configuration. ' + 'POLL_SERVER_CFN will allow calls to the cfn API action ' + 'DescribeStackResource authenticated with the provided ' + 'keypair (requires enabled heat-api-cfn). ' + 'POLL_SERVER_HEAT will allow calls to the ' + 'Heat API resource-show using the provided keystone ' + 'credentials (requires keystone v3 API, and configured ' + 'stack_user_* config options). ' + 'POLL_TEMP_URL will create and populate a ' + 'Swift TempURL with metadata for polling (requires ' + 'object-store endpoint which supports TempURL).')), + cfg.StrOpt('default_deployment_signal_transport', + choices=['CFN_SIGNAL', + 'TEMP_URL_SIGNAL', + 'HEAT_SIGNAL'], + default='CFN_SIGNAL', + help=_('Template default for how the server should signal to ' + 'heat with the deployment output values. CFN_SIGNAL ' + 'will allow an HTTP POST to a CFN keypair signed URL ' + '(requires enabled heat-api-cfn). ' + 'TEMP_URL_SIGNAL will create a Swift TempURL to be ' + 'signaled via HTTP PUT (requires object-store endpoint ' + 'which supports TempURL). ' + 'HEAT_SIGNAL will allow calls to the Heat API ' + 'resource-signal using the provided keystone ' + 'credentials')), cfg.StrOpt('onready', help=_('Deprecated.'))] diff --git a/heat/engine/resources/openstack/heat/software_deployment.py b/heat/engine/resources/openstack/heat/software_deployment.py index a171772afe..5fe0439e29 100644 --- a/heat/engine/resources/openstack/heat/software_deployment.py +++ b/heat/engine/resources/openstack/heat/software_deployment.py @@ -14,6 +14,7 @@ import copy import uuid +from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils @@ -29,6 +30,9 @@ from heat.engine.resources import signal_responder from heat.engine import support from heat.rpc import api as rpc_api +cfg.CONF.import_opt('default_deployment_signal_transport', + 'heat.common.config') + LOG = logging.getLogger(__name__) @@ -152,7 +156,7 @@ class SoftwareDeployment(signal_responder.SignalResponder): 'provided keystone credentials. NO_SIGNAL will result in the ' 'resource going to the COMPLETE state without waiting for ' 'any signal.'), - default=CFN_SIGNAL, + default=cfg.CONF.default_deployment_signal_transport, constraints=[ constraints.AllowedValues(SIGNAL_TRANSPORTS), ] diff --git a/heat/engine/resources/openstack/nova/server.py b/heat/engine/resources/openstack/nova/server.py index 472c3701bc..afc8a6ac45 100644 --- a/heat/engine/resources/openstack/nova/server.py +++ b/heat/engine/resources/openstack/nova/server.py @@ -34,6 +34,7 @@ from heat.engine import support from heat.rpc import api as rpc_api cfg.CONF.import_opt('instance_user', 'heat.common.config') +cfg.CONF.import_opt('default_software_config_transport', 'heat.common.config') LOG = logging.getLogger(__name__) @@ -285,7 +286,7 @@ class Server(stack_user.StackUser): 'the Heat API resource-show using the provided keystone ' 'credentials. POLL_TEMP_URL will create and populate a ' 'Swift TempURL with metadata for polling.'), - default=POLL_SERVER_CFN, + default=cfg.CONF.default_software_config_transport, constraints=[ constraints.AllowedValues(_SOFTWARE_CONFIG_TRANSPORTS), ] diff --git a/heat/tests/test_server.py b/heat/tests/test_server.py index db4c1f4646..55f2d844a6 100644 --- a/heat/tests/test_server.py +++ b/heat/tests/test_server.py @@ -667,6 +667,8 @@ class ServersTest(common.HeatTestCase): self.assertEqual('4567', server.access_key) self.assertEqual('8901', server.secret_key) self.assertEqual('1234', server._get_user_id()) + self.assertEqual('POLL_SERVER_CFN', + server.properties.get('software_config_transport')) self.assertTrue(stack.access_allowed('4567', 'WebServer')) self.assertFalse(stack.access_allowed('45678', 'WebServer')) diff --git a/heat/tests/test_software_deployment.py b/heat/tests/test_software_deployment.py index da641ed2a3..124f6e4536 100644 --- a/heat/tests/test_software_deployment.py +++ b/heat/tests/test_software_deployment.py @@ -148,6 +148,7 @@ class SoftwareDeploymentTest(common.HeatTestCase): props['user_data_format'] = 'SOFTWARE_CONFIG' self._create_stack(self.template_with_server) sd = self.deployment + self.assertEqual('CFN_SIGNAL', sd.properties.get('signal_transport')) sd.validate() server = self.stack['server'] self.assertTrue(server.user_data_software_config())