From 907cc2df16af12d868531d86b92d96e1e7c35450 Mon Sep 17 00:00:00 2001 From: suzhengwei Date: Fri, 23 Jun 2017 10:48:24 +0800 Subject: [PATCH] add name for audit, update audit notifications upgrade notifications Change-Id: Ia8b7f36a8a2965bc8ec2243a10556592926297b2 Implements:blueprint add-name-for-audit --- .../action_plan-create.json | 1 + .../action_plan-delete.json | 1 + .../action_plan-execution-end.json | 1 + .../action_plan-execution-error.json | 1 + .../action_plan-execution-start.json | 1 + .../action_plan-update.json | 1 + doc/notification_samples/audit-create.json | 1 + doc/notification_samples/audit-delete.json | 1 + .../audit-planner-end.json | 1 + .../audit-planner-error.json | 1 + .../audit-planner-start.json | 1 + .../audit-strategy-end.json | 1 + .../audit-strategy-error.json | 1 + .../audit-strategy-start.json | 1 + doc/notification_samples/audit-update.json | 1 + watcher/notifications/audit.py | 11 ++++++---- .../test_action_plan_notification.py | 21 ++++++++++++------- .../notifications/test_audit_notification.py | 6 ++++++ .../tests/notifications/test_notification.py | 12 +++++------ 19 files changed, 48 insertions(+), 17 deletions(-) diff --git a/doc/notification_samples/action_plan-create.json b/doc/notification_samples/action_plan-create.json index b3de9b7bf..e8f46715e 100644 --- a/doc/notification_samples/action_plan-create.json +++ b/doc/notification_samples/action_plan-create.json @@ -23,6 +23,7 @@ "audit": { "watcher_object.version": "1.0", "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "scope": [], "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", diff --git a/doc/notification_samples/action_plan-delete.json b/doc/notification_samples/action_plan-delete.json index 29d0762b7..a5c9f10d8 100644 --- a/doc/notification_samples/action_plan-delete.json +++ b/doc/notification_samples/action_plan-delete.json @@ -8,6 +8,7 @@ "audit_uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", "audit": { "watcher_object.data": { + "name": "my_audit", "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", "goal_uuid": "bc830f84-8ae3-4fc6-8bc6-e3dd15e8b49a", "strategy_uuid": "75234dfe-87e3-4f11-a0e0-3c3305d86a39", diff --git a/doc/notification_samples/action_plan-execution-end.json b/doc/notification_samples/action_plan-execution-end.json index 2fee7f083..8ceaf5a69 100644 --- a/doc/notification_samples/action_plan-execution-end.json +++ b/doc/notification_samples/action_plan-execution-end.json @@ -15,6 +15,7 @@ "watcher_object.data": { "created_at": "2016-10-18T09:52:05Z", "deleted_at": null, + "name": "my_audit", "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", "goal_uuid": "bc830f84-8ae3-4fc6-8bc6-e3dd15e8b49a", "strategy_uuid": "75234dfe-87e3-4f11-a0e0-3c3305d86a39", diff --git a/doc/notification_samples/action_plan-execution-error.json b/doc/notification_samples/action_plan-execution-error.json index 466c67f8e..e18a481fc 100644 --- a/doc/notification_samples/action_plan-execution-error.json +++ b/doc/notification_samples/action_plan-execution-error.json @@ -45,6 +45,7 @@ "watcher_object.name": "TerseAuditPayload", "watcher_object.data": { "parameters": {}, + "name": "my_audit", "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", "goal_uuid": "bc830f84-8ae3-4fc6-8bc6-e3dd15e8b49a", "strategy_uuid": "75234dfe-87e3-4f11-a0e0-3c3305d86a39", diff --git a/doc/notification_samples/action_plan-execution-start.json b/doc/notification_samples/action_plan-execution-start.json index 704516211..95de3ffe4 100644 --- a/doc/notification_samples/action_plan-execution-start.json +++ b/doc/notification_samples/action_plan-execution-start.json @@ -15,6 +15,7 @@ "watcher_object.data": { "created_at": "2016-10-18T09:52:05Z", "deleted_at": null, + "name": "my_audit", "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", "goal_uuid": "bc830f84-8ae3-4fc6-8bc6-e3dd15e8b49a", "strategy_uuid": "75234dfe-87e3-4f11-a0e0-3c3305d86a39", diff --git a/doc/notification_samples/action_plan-update.json b/doc/notification_samples/action_plan-update.json index 60f7eece5..dc0c1dc01 100644 --- a/doc/notification_samples/action_plan-update.json +++ b/doc/notification_samples/action_plan-update.json @@ -6,6 +6,7 @@ "audit": { "watcher_object.version": "1.0", "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "scope": [], "created_at": "2016-10-18T09:52:05Z", diff --git a/doc/notification_samples/audit-create.json b/doc/notification_samples/audit-create.json index dd655ea16..eda083245 100644 --- a/doc/notification_samples/audit-create.json +++ b/doc/notification_samples/audit-create.json @@ -2,6 +2,7 @@ "priority": "INFO", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-delete.json b/doc/notification_samples/audit-delete.json index 752782947..ebb9889ce 100644 --- a/doc/notification_samples/audit-delete.json +++ b/doc/notification_samples/audit-delete.json @@ -2,6 +2,7 @@ "priority": "INFO", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-planner-end.json b/doc/notification_samples/audit-planner-end.json index d3307c037..95001ad3d 100644 --- a/doc/notification_samples/audit-planner-end.json +++ b/doc/notification_samples/audit-planner-end.json @@ -2,6 +2,7 @@ "priority": "INFO", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-planner-error.json b/doc/notification_samples/audit-planner-error.json index d3b16359a..ef6f01bca 100644 --- a/doc/notification_samples/audit-planner-error.json +++ b/doc/notification_samples/audit-planner-error.json @@ -2,6 +2,7 @@ "priority": "ERROR", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-planner-start.json b/doc/notification_samples/audit-planner-start.json index 93644dde0..da29737bd 100644 --- a/doc/notification_samples/audit-planner-start.json +++ b/doc/notification_samples/audit-planner-start.json @@ -2,6 +2,7 @@ "priority": "INFO", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-strategy-end.json b/doc/notification_samples/audit-strategy-end.json index 3874fbfef..b3f7306be 100644 --- a/doc/notification_samples/audit-strategy-end.json +++ b/doc/notification_samples/audit-strategy-end.json @@ -2,6 +2,7 @@ "priority": "INFO", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-strategy-error.json b/doc/notification_samples/audit-strategy-error.json index 4c6fd1853..4b775066c 100644 --- a/doc/notification_samples/audit-strategy-error.json +++ b/doc/notification_samples/audit-strategy-error.json @@ -2,6 +2,7 @@ "priority": "ERROR", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-strategy-start.json b/doc/notification_samples/audit-strategy-start.json index 43322a7bd..f648591e2 100644 --- a/doc/notification_samples/audit-strategy-start.json +++ b/doc/notification_samples/audit-strategy-start.json @@ -2,6 +2,7 @@ "priority": "INFO", "payload": { "watcher_object.data": { + "name": "my_audit", "audit_type": "ONESHOT", "parameters": { "para2": "hello", diff --git a/doc/notification_samples/audit-update.json b/doc/notification_samples/audit-update.json index 3dc4b0ba8..d4fccb3a7 100644 --- a/doc/notification_samples/audit-update.json +++ b/doc/notification_samples/audit-update.json @@ -4,6 +4,7 @@ "payload": { "watcher_object.name": "AuditUpdatePayload", "watcher_object.data": { + "name": "my_audit", "strategy_uuid": "75234dfe-87e3-4f11-a0e0-3c3305d86a39", "strategy": { "watcher_object.name": "StrategyPayload", diff --git a/watcher/notifications/audit.py b/watcher/notifications/audit.py index 83ec80de2..cfdf88fa6 100644 --- a/watcher/notifications/audit.py +++ b/watcher/notifications/audit.py @@ -33,7 +33,7 @@ CONF = cfg.CONF class TerseAuditPayload(notificationbase.NotificationPayloadBase): SCHEMA = { 'uuid': ('audit', 'uuid'), - + 'name': ('audit', 'name'), 'audit_type': ('audit', 'audit_type'), 'state': ('audit', 'state'), 'parameters': ('audit', 'parameters'), @@ -51,10 +51,12 @@ class TerseAuditPayload(notificationbase.NotificationPayloadBase): # Version 1.1: Added 'auto_trigger' boolean field, # Added 'next_run_time' DateTime field, # 'interval' type has been changed from Integer to String - VERSION = '1.1' + # Version 1.2: Added 'name' string field + VERSION = '1.2' fields = { 'uuid': wfields.UUIDField(), + 'name': wfields.StringField(), 'audit_type': wfields.StringField(), 'state': wfields.StringField(), 'parameters': wfields.FlexibleDictField(nullable=True), @@ -80,7 +82,7 @@ class TerseAuditPayload(notificationbase.NotificationPayloadBase): class AuditPayload(TerseAuditPayload): SCHEMA = { 'uuid': ('audit', 'uuid'), - + 'name': ('audit', 'name'), 'audit_type': ('audit', 'audit_type'), 'state': ('audit', 'state'), 'parameters': ('audit', 'parameters'), @@ -97,7 +99,8 @@ class AuditPayload(TerseAuditPayload): # Version 1.0: Initial version # Version 1.1: Added 'auto_trigger' field, # Added 'next_run_time' field - VERSION = '1.1' + # Version 1.2: Added 'name' string field + VERSION = '1.2' fields = { 'goal': wfields.ObjectField('GoalPayload'), diff --git a/watcher/tests/notifications/test_action_plan_notification.py b/watcher/tests/notifications/test_action_plan_notification.py index fbdd24ce4..466b348d8 100644 --- a/watcher/tests/notifications/test_action_plan_notification.py +++ b/watcher/tests/notifications/test_action_plan_notification.py @@ -98,6 +98,7 @@ class TestActionPlanNotification(base.DbTestCase): "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "strategy_uuid": None, "goal_uuid": ( "f7ad87ae-4298-91cf-93a0-f35a852e3652"), @@ -110,7 +111,7 @@ class TestActionPlanNotification(base.DbTestCase): }, "watcher_object.name": "TerseAuditPayload", "watcher_object.namespace": "watcher", - "watcher_object.version": "1.1" + "watcher_object.version": "1.2" }, "deleted_at": None, "state": "ONGOING", @@ -174,6 +175,7 @@ class TestActionPlanNotification(base.DbTestCase): "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "strategy_uuid": None, "goal_uuid": ( "f7ad87ae-4298-91cf-93a0-f35a852e3652"), @@ -186,7 +188,7 @@ class TestActionPlanNotification(base.DbTestCase): }, "watcher_object.name": "TerseAuditPayload", "watcher_object.namespace": "watcher", - "watcher_object.version": "1.1" + "watcher_object.version": "1.2" }, "deleted_at": None, "state": "PENDING", @@ -242,6 +244,7 @@ class TestActionPlanNotification(base.DbTestCase): "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "strategy_uuid": None, "goal_uuid": ( "f7ad87ae-4298-91cf-93a0-f35a852e3652"), @@ -254,7 +257,7 @@ class TestActionPlanNotification(base.DbTestCase): }, "watcher_object.name": "TerseAuditPayload", "watcher_object.namespace": "watcher", - "watcher_object.version": "1.1" + "watcher_object.version": "1.2" }, "deleted_at": None, "state": "DELETED", @@ -293,13 +296,14 @@ class TestActionPlanNotification(base.DbTestCase): "audit": { "watcher_object.namespace": "watcher", "watcher_object.name": "TerseAuditPayload", - "watcher_object.version": "1.1", + "watcher_object.version": "1.2", "watcher_object.data": { "interval": None, "next_run_time": None, "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "strategy_uuid": None, "goal_uuid": ( "f7ad87ae-4298-91cf-93a0-f35a852e3652"), @@ -385,6 +389,7 @@ class TestActionPlanNotification(base.DbTestCase): "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "strategy_uuid": None, "goal_uuid": ( "f7ad87ae-4298-91cf-93a0-f35a852e3652"), @@ -397,7 +402,7 @@ class TestActionPlanNotification(base.DbTestCase): }, "watcher_object.name": "TerseAuditPayload", "watcher_object.namespace": "watcher", - "watcher_object.version": "1.1" + "watcher_object.version": "1.2" }, "global_efficacy": {}, "state": "ONGOING", @@ -454,13 +459,14 @@ class TestActionPlanNotification(base.DbTestCase): "audit": { "watcher_object.namespace": "watcher", "watcher_object.name": "TerseAuditPayload", - "watcher_object.version": "1.1", + "watcher_object.version": "1.2", "watcher_object.data": { "interval": None, "next_run_time": None, "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + 'name': 'My Audit', "strategy_uuid": None, "goal_uuid": ( "f7ad87ae-4298-91cf-93a0-f35a852e3652"), @@ -546,6 +552,7 @@ class TestActionPlanNotification(base.DbTestCase): "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + 'name': 'My Audit', "strategy_uuid": None, "goal_uuid": ( "f7ad87ae-4298-91cf-93a0-f35a852e3652"), @@ -558,7 +565,7 @@ class TestActionPlanNotification(base.DbTestCase): }, "watcher_object.name": "TerseAuditPayload", "watcher_object.namespace": "watcher", - "watcher_object.version": "1.1" + "watcher_object.version": "1.2" }, "global_efficacy": {}, "state": "ONGOING", diff --git a/watcher/tests/notifications/test_audit_notification.py b/watcher/tests/notifications/test_audit_notification.py index 0a5178a98..f7eb2c097 100644 --- a/watcher/tests/notifications/test_audit_notification.py +++ b/watcher/tests/notifications/test_audit_notification.py @@ -91,6 +91,7 @@ class TestAuditNotification(base.DbTestCase): }, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "goal_uuid": "f7ad87ae-4298-91cf-93a0-f35a852e3652", "goal": { "watcher_object.namespace": "watcher", @@ -150,6 +151,7 @@ class TestAuditNotification(base.DbTestCase): "auto_trigger": False, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "goal_uuid": "f7ad87ae-4298-91cf-93a0-f35a852e3652", "goal": { "watcher_object.namespace": "watcher", @@ -226,6 +228,7 @@ class TestAuditNotification(base.DbTestCase): }, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "goal_uuid": "f7ad87ae-4298-91cf-93a0-f35a852e3652", "goal": { "watcher_object.namespace": "watcher", @@ -291,6 +294,7 @@ class TestAuditNotification(base.DbTestCase): }, "parameters": {}, "uuid": "10a47dd1-4874-4298-91cf-eff046dbdb8d", + "name": "My Audit", "goal_uuid": "f7ad87ae-4298-91cf-93a0-f35a852e3652", "goal": { "watcher_object.namespace": "watcher", @@ -360,6 +364,7 @@ class TestAuditNotification(base.DbTestCase): "interval": None, "next_run_time": None, "auto_trigger": False, + "name": "My Audit", "parameters": {}, "scope": [], "state": "ONGOING", @@ -446,6 +451,7 @@ class TestAuditNotification(base.DbTestCase): "interval": None, "next_run_time": None, "auto_trigger": False, + "name": "My Audit", "parameters": {}, "scope": [], "state": "ONGOING", diff --git a/watcher/tests/notifications/test_notification.py b/watcher/tests/notifications/test_notification.py index de9f236ef..fc8f5cf43 100644 --- a/watcher/tests/notifications/test_notification.py +++ b/watcher/tests/notifications/test_notification.py @@ -254,17 +254,17 @@ expected_notification_fingerprints = { 'ExceptionNotification': '1.0-9b69de0724fda8310d05e18418178866', 'ExceptionPayload': '1.0-4516ae282a55fe2fd5c754967ee6248b', 'NotificationPublisher': '1.0-bbbc1402fb0e443a3eb227cc52b61545', - 'TerseAuditPayload': '1.1-19b0e9224c0953366418a30ed785f267', - 'AuditPayload': '1.1-4c59e0cc5d30c42d3b842ce0332709d5', + 'TerseAuditPayload': '1.2-0fda1751c39f29b539944c2b44690f65', + 'AuditPayload': '1.2-d30cc1639404ed380b0742b781db690e', 'AuditStateUpdatePayload': '1.0-1a1b606bf14a2c468800c2b010801ce5', 'AuditUpdateNotification': '1.0-9b69de0724fda8310d05e18418178866', - 'AuditUpdatePayload': '1.1-9b1f725e736051b976571701e5cc1e55', + 'AuditUpdatePayload': '1.1-e32c3f69c353d47948afa44359246828', 'AuditCreateNotification': '1.0-9b69de0724fda8310d05e18418178866', - 'AuditCreatePayload': '1.1-4c59e0cc5d30c42d3b842ce0332709d5', + 'AuditCreatePayload': '1.1-d30cc1639404ed380b0742b781db690e', 'AuditDeleteNotification': '1.0-9b69de0724fda8310d05e18418178866', - 'AuditDeletePayload': '1.1-4c59e0cc5d30c42d3b842ce0332709d5', + 'AuditDeletePayload': '1.1-d30cc1639404ed380b0742b781db690e', 'AuditActionNotification': '1.0-9b69de0724fda8310d05e18418178866', - 'AuditActionPayload': '1.1-5a43e7321495c19f98ef5663efa0a821', + 'AuditActionPayload': '1.1-3d19c75dd9cdf2a833d0367b234e20d2', 'GoalPayload': '1.0-fa1fecb8b01dd047eef808ded4d50d1a', 'StrategyPayload': '1.0-94f01c137b083ac236ae82573c1fcfc1', 'ActionPlanActionPayload': '1.0-d9f134708e06cf2ff2d3b8d522ac2aa8',