diff --git a/watcherclient/tests/v1/test_audit_shell.py b/watcherclient/tests/v1/test_audit_shell.py index d4dbcb5..1bc377f 100644 --- a/watcherclient/tests/v1/test_audit_shell.py +++ b/watcherclient/tests/v1/test_audit_shell.py @@ -48,6 +48,7 @@ AUDIT_1 = { 'created_at': datetime.datetime.now().isoformat(), 'updated_at': None, 'deleted_at': None, + 'period': 3600, } AUDIT_2 = { @@ -60,6 +61,7 @@ AUDIT_2 = { 'created_at': datetime.datetime.now().isoformat(), 'updated_at': None, 'deleted_at': None, + 'period': 3600, } @@ -225,7 +227,7 @@ class AuditShellTest(base.CommandTestCase): result) self.m_audit_mgr.create.assert_called_once_with( audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2', - type='ONESHOT') + type='ONESHOT', period=3600) def test_do_audit_create_with_audit_template_name(self): audit = resource.Audit(mock.Mock(), AUDIT_1) @@ -241,7 +243,7 @@ class AuditShellTest(base.CommandTestCase): result) self.m_audit_mgr.create.assert_called_once_with( audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2', - type='ONESHOT') + type='ONESHOT', period=3600) def test_do_audit_create_with_deadline(self): audit = resource.Audit(mock.Mock(), AUDIT_1) @@ -259,7 +261,8 @@ class AuditShellTest(base.CommandTestCase): self.m_audit_mgr.create.assert_called_once_with( audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2', type='ONESHOT', - deadline='2016-04-28T10:48:32.064802') + deadline='2016-04-28T10:48:32.064802', + period=3600) def test_do_audit_create_with_type(self): audit = resource.Audit(mock.Mock(), AUDIT_1) @@ -276,4 +279,4 @@ class AuditShellTest(base.CommandTestCase): result) self.m_audit_mgr.create.assert_called_once_with( audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2', - type='ONESHOT') + type='ONESHOT', period=3600) diff --git a/watcherclient/v1/audit.py b/watcherclient/v1/audit.py index 830e67c..2b2d434 100644 --- a/watcherclient/v1/audit.py +++ b/watcherclient/v1/audit.py @@ -18,7 +18,7 @@ from watcherclient.common import base from watcherclient.common import utils from watcherclient import exceptions as exc -CREATION_ATTRIBUTES = ['audit_template_uuid', 'deadline', 'type'] +CREATION_ATTRIBUTES = ['audit_template_uuid', 'deadline', 'type', 'period'] class Audit(base.Resource): diff --git a/watcherclient/v1/audit_shell.py b/watcherclient/v1/audit_shell.py index c3da48d..a38a05b 100644 --- a/watcherclient/v1/audit_shell.py +++ b/watcherclient/v1/audit_shell.py @@ -132,13 +132,19 @@ class CreateAudit(command.ShowOne): metavar='', default='ONESHOT', help=_("Audit type.")) + parser.add_argument( + '-p', '--period', + dest='period', + metavar='', + default=3600, + help=_("Audit period.")) return parser def take_action(self, parsed_args): client = getattr(self.app.client_manager, "infra-optim") - field_list = ['audit_template_uuid', 'type', 'deadline'] + field_list = ['audit_template_uuid', 'type', 'deadline', 'period'] fields = dict((k, v) for (k, v) in vars(parsed_args).items() if k in field_list and v is not None) if fields.get('audit_template_uuid'): diff --git a/watcherclient/v1/resource_fields.py b/watcherclient/v1/resource_fields.py index b4e0299..3754da9 100644 --- a/watcherclient/v1/resource_fields.py +++ b/watcherclient/v1/resource_fields.py @@ -34,11 +34,11 @@ AUDIT_TEMPLATE_SHORT_LIST_FIELD_LABELS = ['UUID', 'Name'] # Audit AUDIT_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at', 'deadline', 'state', 'type', 'audit_template_uuid', - 'audit_template_name'] + 'audit_template_name', 'period'] AUDIT_FIELD_LABELS = ['UUID', 'Created At', 'Updated At', 'Deleted At', 'Deadline', 'State', 'Type', 'Audit Template uuid', - 'Audit Template Name'] + 'Audit Template Name', 'Period'] AUDIT_SHORT_LIST_FIELDS = ['uuid', 'type', 'audit_template_name', 'state']