summaryrefslogtreecommitdiff
path: root/heat_cfntools
diff options
context:
space:
mode:
authorClint Byrum <clint@fewbar.com>2013-05-07 20:26:50 -0700
committerClint Byrum <clint@fewbar.com>2013-05-07 20:26:50 -0700
commitceed49d075fd3ed6ffa5b2f529b75ae76dc00870 (patch)
tree62dd3674a648c5f9bffa435c0d6fd60311ac4aaa /heat_cfntools
parent25c3f97159b428e3ded65a337a6931dcab7c41ee (diff)
downloadheat-cfntools-ceed49d075fd3ed6ffa5b2f529b75ae76dc00870.tar.gz
Run hooks even without cfn-init Metadata.
When we don't have AWS::CloudFormation::Init in Metadata, this just means that cfn-init cannot do anything. However, cfn-hup still has hooks which are just scheduled to be run on any change in the Metadata. Fixes bug #1155999 Change-Id: I21c4f2137f8045128a86278b4d90768ea97455d1
Diffstat (limited to 'heat_cfntools')
-rw-r--r--heat_cfntools/cfntools/cfn_helper.py23
-rw-r--r--heat_cfntools/tests/test_cfn_hup.py21
2 files changed, 20 insertions, 24 deletions
diff --git a/heat_cfntools/cfntools/cfn_helper.py b/heat_cfntools/cfntools/cfn_helper.py
index c2247ba..9a00c2a 100644
--- a/heat_cfntools/cfntools/cfn_helper.py
+++ b/heat_cfntools/cfntools/cfn_helper.py
@@ -1214,14 +1214,15 @@ class Metadata(object):
Process the resource metadata
"""
if not self._is_valid_metadata():
- LOG.info('Metadata does not contain a %s section' % self._init_key)
- else:
- if self._is_local_metadata:
- self._config = self._metadata["config"]
- s = self._config.get("services")
- sh = ServicesHandler(s, resource=self.resource, hooks=hooks)
- sh.monitor_services()
-
- if self._has_changed:
- for h in hooks:
- h.event('post.update', self.resource, self.resource)
+ LOG.debug(
+ 'Metadata does not contain a %s section' % self._init_key)
+
+ if self._is_local_metadata:
+ self._config = self._metadata.get("config", {})
+ s = self._config.get("services")
+ sh = ServicesHandler(s, resource=self.resource, hooks=hooks)
+ sh.monitor_services()
+
+ if self._has_changed:
+ for h in hooks:
+ h.event('post.update', self.resource, self.resource)
diff --git a/heat_cfntools/tests/test_cfn_hup.py b/heat_cfntools/tests/test_cfn_hup.py
index 9cfe98e..3ebd671 100644
--- a/heat_cfntools/tests/test_cfn_hup.py
+++ b/heat_cfntools/tests/test_cfn_hup.py
@@ -80,20 +80,9 @@ class TestCfnHup(testtools.TestCase):
with tempfile.NamedTemporaryFile() as last_md:
self.metadata.retrieve(last_path=last_md.name)
- def test_cfn_hup_empty_metadata(self):
-
- self._mock_retrieve_metadata({})
-
- hooks = []
- self.metadata.cfn_hup(hooks)
-
- self.assertIn('Metadata does not contain a', self.logger.output)
- self.m.VerifyAll()
- self.m.UnsetStubs()
-
- def test_cfn_hup_hooks(self):
+ def _test_cfn_hup_metadata(self, metadata):
- self._mock_retrieve_metadata(self.init_section)
+ self._mock_retrieve_metadata(metadata)
self.useFixture(
fixtures.MonkeyPatch(
'heat_cfntools.cfntools.cfn_helper.ServicesHandler',
@@ -112,3 +101,9 @@ class TestCfnHup(testtools.TestCase):
self.metadata.cfn_hup([hook])
self.m.VerifyAll()
self.m.UnsetStubs()
+
+ def test_cfn_hup_empty_metadata(self):
+ self._test_cfn_hup_metadata({})
+
+ def test_cfn_hup_cfn_init_metadata(self):
+ self._test_cfn_hup_metadata(self.init_section)