update filter for webhook payload
Change-Id: I711074dcf28b77399fd386712a939d74b3d9d868
This commit is contained in:
parent
022e18ea7d
commit
ffed682bc2
@ -65,25 +65,15 @@ Data is sent by the webhook notifier in the following format.
|
|||||||
"update_timestamp": "2018-01-22 10:00:34.327142+00:00",
|
"update_timestamp": "2018-01-22 10:00:34.327142+00:00",
|
||||||
"vitrage_category": "RESOURCE",
|
"vitrage_category": "RESOURCE",
|
||||||
"vitrage_operational_state": "OK",
|
"vitrage_operational_state": "OK",
|
||||||
"state": "active",
|
|
||||||
"vitrage_type": "nova.instance",
|
"vitrage_type": "nova.instance",
|
||||||
"vitrage_sample_timestamp": "2018-01-22 10:00:34.327142+00:00",
|
|
||||||
"vitrage_aggregated_state": "ACTIVE",
|
|
||||||
"host_id": "iafek-devstack-pre-queens",
|
|
||||||
"project_id": "8f007e5ba0944e84baa6f2a4f2b5d03a",
|
"project_id": "8f007e5ba0944e84baa6f2a4f2b5d03a",
|
||||||
"id": "9b7d93b9-94ec-41e1-9cec-f28d4f8d702c"
|
"id": "9b7d93b9-94ec-41e1-9cec-f28d4f8d702c"
|
||||||
},
|
},
|
||||||
"severity": "warning",
|
|
||||||
"update_timestamp": "2018-01-22T10:00:34Z",
|
"update_timestamp": "2018-01-22T10:00:34Z",
|
||||||
"resource_id": "437f1f4c-ccce-40a4-ac62-1c2f1fd9f6ac",
|
|
||||||
"vitrage_category": "ALARM",
|
"vitrage_category": "ALARM",
|
||||||
"state": "Active",
|
"state": "Active",
|
||||||
"vitrage_type": "vitrage",
|
"vitrage_type": "vitrage",
|
||||||
"vitrage_sample_timestamp": "2018-01-22 10:00:34.366364+00:00",
|
|
||||||
"vitrage_operational_severity": "WARNING",
|
"vitrage_operational_severity": "WARNING",
|
||||||
"vitrage_aggregated_severity": "WARNING",
|
|
||||||
"vitrage_resource_id": "437f1f4c-ccce-40a4-ac62-1c2f1fd9f6ac",
|
|
||||||
"vitrage_resource_type": "nova.instance",
|
|
||||||
"name": "Instance memory performance degraded"
|
"name": "Instance memory performance degraded"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,34 @@ from vitrage import storage
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
URL = 'url'
|
URL = 'url'
|
||||||
IS_ADMIN_WEBHOOK = 'is_admin_webhook'
|
IS_ADMIN_WEBHOOK = 'is_admin_webhook'
|
||||||
FIELDS_TO_REMOVE = (VProps.VITRAGE_IS_PLACEHOLDER,
|
|
||||||
VProps.VITRAGE_IS_DELETED,
|
|
||||||
VProps.IS_REAL_VITRAGE_ID)
|
|
||||||
NOTIFICATION_TYPE = 'notification_type'
|
NOTIFICATION_TYPE = 'notification_type'
|
||||||
|
NOTIFICATION = 'notification'
|
||||||
PAYLOAD = 'payload'
|
PAYLOAD = 'payload'
|
||||||
|
ALARM_FILTER = (NOTIFICATION,
|
||||||
|
PAYLOAD,
|
||||||
|
VProps.VITRAGE_ID,
|
||||||
|
VProps.ID,
|
||||||
|
VProps.RESOURCE,
|
||||||
|
VProps.NAME,
|
||||||
|
VProps.UPDATE_TIMESTAMP,
|
||||||
|
VProps.VITRAGE_OPERATIONAL_STATE,
|
||||||
|
VProps.VITRAGE_TYPE,
|
||||||
|
VProps.PROJECT_ID,
|
||||||
|
VProps.UPDATE_TIMESTAMP,
|
||||||
|
VProps.VITRAGE_CATEGORY,
|
||||||
|
VProps.STATE,
|
||||||
|
VProps.VITRAGE_OPERATIONAL_SEVERITY)
|
||||||
|
RESOURCE_FILTER = (VProps.VITRAGE_ID,
|
||||||
|
VProps.ID,
|
||||||
|
VProps.RESOURCE,
|
||||||
|
VProps.NAME,
|
||||||
|
VProps.VITRAGE_CATEGORY,
|
||||||
|
VProps.UPDATE_TIMESTAMP,
|
||||||
|
VProps.VITRAGE_OPERATIONAL_STATE,
|
||||||
|
VProps.VITRAGE_TYPE,
|
||||||
|
VProps.PROJECT_ID,
|
||||||
|
VProps.UPDATE_TIMESTAMP,
|
||||||
|
VProps.VITRAGE_OPERATIONAL_SEVERITY)
|
||||||
|
|
||||||
|
|
||||||
class Webhook(NotifierBase):
|
class Webhook(NotifierBase):
|
||||||
@ -129,10 +152,11 @@ class Webhook(NotifierBase):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def _filter_fields(self, data):
|
def _filter_fields(self, data):
|
||||||
data = {k: v for k, v in data.items() if k not in FIELDS_TO_REMOVE}
|
data = {k: v for k, v in data.items() if k in ALARM_FILTER}
|
||||||
if data.get(VProps.RESOURCE):
|
if data.get(VProps.RESOURCE):
|
||||||
data[VProps.RESOURCE] = \
|
data[VProps.RESOURCE] = \
|
||||||
self._filter_fields(data[VProps.RESOURCE])
|
{k: v for k, v in data[VProps.RESOURCE].items() if k in
|
||||||
|
RESOURCE_FILTER}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _check_correct_tenant(self, webhook, data):
|
def _check_correct_tenant(self, webhook, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user