Add support to get recovery workflow details

In microversion 1.1, Masakari supports to return ``recovery_workflow_details``
information of the notification in ``GET /notifications/{notification_id}``
API. Added ``recovery_workflow_details `` attribute to Notification class
to read the recovery_workflow_details of the notification.

Change-Id: I639fd38312c88522ac6dc628eb3b798066cca74d
This commit is contained in:
niraj singh 2019-02-28 07:59:10 +00:00 committed by Niraj Singh
parent da4ec3e70c
commit 1066c9385f
3 changed files with 68 additions and 1 deletions

View File

@ -15,6 +15,27 @@
from openstack import resource
class ProgressDetailsItem(resource.Resource):
#: The timestamp of recovery workflow task.
timestamp = resource.Body("timestamp")
#: The message of recovery workflow task.
message = resource.Body("message")
#: The progress of recovery workflow task.
progress = resource.Body("progress")
class RecoveryWorkflowDetailItem(resource.Resource):
#: The progress of recovery workflow.
progress = resource.Body("progress")
#: The name of recovery workflow.
name = resource.Body("name")
#: The state of recovery workflow.
state = resource.Body("state")
#: The progress details of this recovery workflow.
progress_details = resource.Body(
"progress_details", type=list, list_type=ProgressDetailsItem)
class Notification(resource.Resource):
resource_key = "notification"
resources_key = "notifications"
@ -56,6 +77,10 @@ class Notification(resource.Resource):
payload = resource.Body("payload")
#: The source host uuid of this notification.
source_host_uuid = resource.Body("source_host_uuid")
#: The recovery workflow details of this notification.
recovery_workflow_details = resource.Body(
"recovery_workflow_details",
type=list, list_type=RecoveryWorkflowDetailItem)
_query_mapping = resource.QueryParameters(
"sort_key", "sort_dir", source_host_uuid="source_host_uuid",

View File

@ -23,6 +23,16 @@ PAYLOAD = {
"vir_domain_event": "STOPPED_FAILED",
"event": "LIFECYCLE"
}
PROGRESS_DETAILS = [{"timestamp": "2019-02-28 07:21:33.291810",
"progress": 1.0,
"message": "Skipping recovery for process "
"nova-compute as it is already disabled"}]
RECOVERY_WORKFLOW_DETAILS = [{"progress": 1.0, "state": "SUCCESS",
"name": "DisableComputeNodeTask",
"progress_details": PROGRESS_DETAILS}]
NOTIFICATION = {
"id": FAKE_ID,
"notification_uuid": FAKE_UUID,
@ -33,7 +43,8 @@ NOTIFICATION = {
"status": "new",
"generated_time": "2018-03-21T00:00:00.000000",
"payload": PAYLOAD,
"source_host_uuid": FAKE_HOST_UUID
"source_host_uuid": FAKE_HOST_UUID,
"recovery_workflow_details": RECOVERY_WORKFLOW_DETAILS
}
@ -62,6 +73,7 @@ class TestNotification(base.TestCase):
def test_create(self):
sot = notification.Notification(**NOTIFICATION)
rec_workflow_details = NOTIFICATION["recovery_workflow_details"][0]
self.assertEqual(NOTIFICATION["id"], sot.id)
self.assertEqual(
NOTIFICATION["notification_uuid"], sot.notification_uuid)
@ -74,3 +86,26 @@ class TestNotification(base.TestCase):
self.assertEqual(NOTIFICATION["payload"], sot.payload)
self.assertEqual(
NOTIFICATION["source_host_uuid"], sot.source_host_uuid)
self.assertEqual(rec_workflow_details["name"],
sot.recovery_workflow_details[0].name)
self.assertEqual(rec_workflow_details["state"],
sot.recovery_workflow_details[0].state)
self.assertEqual(rec_workflow_details["progress"],
sot.recovery_workflow_details[0].progress)
self.assertEqual(
rec_workflow_details["progress_details"][0]['progress'],
sot.recovery_workflow_details[0].progress_details[0].progress)
self.assertEqual(
rec_workflow_details["progress_details"][0]['message'],
sot.recovery_workflow_details[0].progress_details[0].message)
self.assertEqual(
rec_workflow_details["progress_details"][0]['timestamp'],
sot.recovery_workflow_details[0].progress_details[0].timestamp)
self.assertIsInstance(sot.recovery_workflow_details, list)
self.assertIsInstance(
sot.recovery_workflow_details[0].progress_details, list)
self.assertIsInstance(sot.recovery_workflow_details[0],
notification.RecoveryWorkflowDetailItem)
self.assertIsInstance(
sot.recovery_workflow_details[0].progress_details[0],
notification.ProgressDetailsItem)

View File

@ -0,0 +1,7 @@
---
features:
- |
In microversion 1.1, Masakari returns ``recovery_workflow_details`` information
of the notification in ``GET /notifications/{notification_id}`` API. Added
``recovery_workflow_details`` attribute to Notification class to read the
recovery_workflow_details of the notification.