From 76c96d0c7095978e5d51ead79f1a85eff46b4143 Mon Sep 17 00:00:00 2001 From: spisarski Date: Thu, 2 Nov 2017 14:52:58 -0600 Subject: Added logging when a heat stack fails. Added the stack resource reason to the error logs for each resource who's status is 'CREATE_FAILED'. All resons will be output to debug. JIRA: SNAPS-190 Change-Id: Ieb1cdb2089eb6e1c1a7c96c143b82af1b7a9efb7 Signed-off-by: spisarski --- snaps/domain/stack.py | 11 +++++++++-- snaps/domain/test/stack_tests.py | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'snaps/domain') diff --git a/snaps/domain/stack.py b/snaps/domain/stack.py index 543c78b..080ab17 100644 --- a/snaps/domain/stack.py +++ b/snaps/domain/stack.py @@ -37,14 +37,21 @@ class Resource: """ SNAPS domain object for a resource created by a heat template """ - def __init__(self, resource_type, resource_id): + def __init__(self, name, resource_type, resource_id, status, + status_reason): """ Constructor - :param resource_type: the type + :param name: the resource's name + :param resource_type: the resource's type :param resource_id: the ID attached to the resource of the given type + :param status: the resource's status code + :param status_reason: the resource's status code reason """ + self.name = name self.type = resource_type self.id = resource_id + self.status = status + self.status_reason = status_reason class Output: diff --git a/snaps/domain/test/stack_tests.py b/snaps/domain/test/stack_tests.py index f816ef8..21e31d2 100644 --- a/snaps/domain/test/stack_tests.py +++ b/snaps/domain/test/stack_tests.py @@ -39,14 +39,22 @@ class ResourceDomainObjectTests(unittest.TestCase): """ def test_construction_positional(self): - resource = Resource('foo', 'bar') + resource = Resource('res_name', 'foo', 'bar', 'status', 'reason') + self.assertEqual('res_name', resource.name) self.assertEqual('foo', resource.type) self.assertEqual('bar', resource.id) + self.assertEqual('status', resource.status) + self.assertEqual('reason', resource.status_reason) def test_construction_named(self): - resource = Resource(resource_id='bar', resource_type='foo') + resource = Resource( + status_reason=None, status=None, resource_id='bar', + resource_type='foo', name='res_name') + self.assertEqual('res_name', resource.name) self.assertEqual('foo', resource.type) self.assertEqual('bar', resource.id) + self.assertIsNone(resource.status) + self.assertIsNone(resource.status_reason) class OutputDomainObjectTests(unittest.TestCase): -- cgit 1.2.3-korg