From 65af455afd6bffea8d9fa8d61b5bbc46f3889e8a Mon Sep 17 00:00:00 2001 From: Idan Hefetz Date: Wed, 3 Jan 2018 13:32:49 +0000 Subject: [PATCH] alarm show release notes and logging Change-Id: Iaefe15a34f2851e511c231df1f7e77682afeb2da --- releasenotes/notes/add_alarm_show_api-0b001dd185e2e523.yaml | 4 ---- .../notes/support_alarm_show_api-0b001dd185e2e523.yaml | 5 +++++ vitrage/api_handler/apis/alarm.py | 4 ++-- vitrage/api_handler/apis/resource.py | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) delete mode 100644 releasenotes/notes/add_alarm_show_api-0b001dd185e2e523.yaml create mode 100644 releasenotes/notes/support_alarm_show_api-0b001dd185e2e523.yaml diff --git a/releasenotes/notes/add_alarm_show_api-0b001dd185e2e523.yaml b/releasenotes/notes/add_alarm_show_api-0b001dd185e2e523.yaml deleted file mode 100644 index 703195e7d..000000000 --- a/releasenotes/notes/add_alarm_show_api-0b001dd185e2e523.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -features: - - Created a new API to show all alarm properties, with a mandatory parameter - vitrage_id of the alarm. The path for the api is ``/v1/alarm/_id_``. diff --git a/releasenotes/notes/support_alarm_show_api-0b001dd185e2e523.yaml b/releasenotes/notes/support_alarm_show_api-0b001dd185e2e523.yaml new file mode 100644 index 000000000..9ef0cdac7 --- /dev/null +++ b/releasenotes/notes/support_alarm_show_api-0b001dd185e2e523.yaml @@ -0,0 +1,5 @@ +--- +features: + - Backend support for alarm show API. + Return the alarm properties for a specific alarm. Alarm is fetched + according to ``vitrage_id`` parameter. Path for the api is ``/v1/alarm/_id_``. diff --git a/vitrage/api_handler/apis/alarm.py b/vitrage/api_handler/apis/alarm.py index 5de7a9cf7..fac4837e6 100755 --- a/vitrage/api_handler/apis/alarm.py +++ b/vitrage/api_handler/apis/alarm.py @@ -65,14 +65,14 @@ class AlarmApis(EntityGraphApisBase): alarm = self.entity_graph.get_vertex(vitrage_id) if not alarm or alarm.get(VProps.VITRAGE_CATEGORY) != ECategory.ALARM: - LOG.warning('Alarm show - not found (%s)', vitrage_id) + LOG.warning('Alarm show - Not found (%s)', vitrage_id) return None is_admin = ctx.get(self.IS_ADMIN_PROJECT_PROPERTY, False) curr_project = ctx.get(self.TENANT_PROPERTY, None) alarm_project = alarm.get(VProps.PROJECT_ID) if not is_admin and curr_project != alarm_project: - LOG.warning('Authorization failed for alarm (%s)', vitrage_id) + LOG.warning('Alarm show - Authorization failed (%s)', vitrage_id) return None return json.dumps(alarm.properties) diff --git a/vitrage/api_handler/apis/resource.py b/vitrage/api_handler/apis/resource.py index a11441f1d..5e95ebffc 100644 --- a/vitrage/api_handler/apis/resource.py +++ b/vitrage/api_handler/apis/resource.py @@ -63,14 +63,15 @@ class ResourceApis(EntityGraphApisBase): resource = self.entity_graph.get_vertex(vitrage_id) if not resource or resource.get(VProps.VITRAGE_CATEGORY) != \ EntityCategory.RESOURCE: - LOG.warning('Resource show - not found (%s)', vitrage_id) + LOG.warning('Resource show - Not found (%s)', vitrage_id) return None is_admin = ctx.get(self.IS_ADMIN_PROJECT_PROPERTY, False) curr_project = ctx.get(self.TENANT_PROPERTY, None) resource_project = resource.get(VProps.PROJECT_ID) if not is_admin and curr_project != resource_project: - LOG.warning('Authorization failed for resource (%s)', vitrage_id) + LOG.warning('Resource show - Authorization failed (%s)', + vitrage_id) return None return json.dumps(resource.properties)