diff options
Diffstat (limited to 'heat_cfntools')
-rw-r--r-- | heat_cfntools/cfntools/cfn_helper.py | 23 | ||||
-rw-r--r-- | heat_cfntools/tests/test_cfn_hup.py | 21 |
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) |