alarm show release notes and logging

Change-Id: Iaefe15a34f2851e511c231df1f7e77682afeb2da
This commit is contained in:
Idan Hefetz 2018-01-03 13:32:49 +00:00
parent b5fbd9862b
commit 65af455afd
4 changed files with 10 additions and 8 deletions

View File

@ -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_``.

View File

@ -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_``.

View File

@ -65,14 +65,14 @@ class AlarmApis(EntityGraphApisBase):
alarm = self.entity_graph.get_vertex(vitrage_id) alarm = self.entity_graph.get_vertex(vitrage_id)
if not alarm or alarm.get(VProps.VITRAGE_CATEGORY) != ECategory.ALARM: 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 return None
is_admin = ctx.get(self.IS_ADMIN_PROJECT_PROPERTY, False) is_admin = ctx.get(self.IS_ADMIN_PROJECT_PROPERTY, False)
curr_project = ctx.get(self.TENANT_PROPERTY, None) curr_project = ctx.get(self.TENANT_PROPERTY, None)
alarm_project = alarm.get(VProps.PROJECT_ID) alarm_project = alarm.get(VProps.PROJECT_ID)
if not is_admin and curr_project != alarm_project: 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 None
return json.dumps(alarm.properties) return json.dumps(alarm.properties)

View File

@ -63,14 +63,15 @@ class ResourceApis(EntityGraphApisBase):
resource = self.entity_graph.get_vertex(vitrage_id) resource = self.entity_graph.get_vertex(vitrage_id)
if not resource or resource.get(VProps.VITRAGE_CATEGORY) != \ if not resource or resource.get(VProps.VITRAGE_CATEGORY) != \
EntityCategory.RESOURCE: EntityCategory.RESOURCE:
LOG.warning('Resource show - not found (%s)', vitrage_id) LOG.warning('Resource show - Not found (%s)', vitrage_id)
return None return None
is_admin = ctx.get(self.IS_ADMIN_PROJECT_PROPERTY, False) is_admin = ctx.get(self.IS_ADMIN_PROJECT_PROPERTY, False)
curr_project = ctx.get(self.TENANT_PROPERTY, None) curr_project = ctx.get(self.TENANT_PROPERTY, None)
resource_project = resource.get(VProps.PROJECT_ID) resource_project = resource.get(VProps.PROJECT_ID)
if not is_admin and curr_project != resource_project: 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 None
return json.dumps(resource.properties) return json.dumps(resource.properties)