Add support continuously-optimization
This patch set adds support for period field to python-watcherclient Change-Id: I777429f9d2d596bea506664e8614da7e78a31904 Implements: blueprint continuously-optimization
This commit is contained in:
@@ -48,6 +48,7 @@ AUDIT_1 = {
|
|||||||
'created_at': datetime.datetime.now().isoformat(),
|
'created_at': datetime.datetime.now().isoformat(),
|
||||||
'updated_at': None,
|
'updated_at': None,
|
||||||
'deleted_at': None,
|
'deleted_at': None,
|
||||||
|
'period': 3600,
|
||||||
}
|
}
|
||||||
|
|
||||||
AUDIT_2 = {
|
AUDIT_2 = {
|
||||||
@@ -60,6 +61,7 @@ AUDIT_2 = {
|
|||||||
'created_at': datetime.datetime.now().isoformat(),
|
'created_at': datetime.datetime.now().isoformat(),
|
||||||
'updated_at': None,
|
'updated_at': None,
|
||||||
'deleted_at': None,
|
'deleted_at': None,
|
||||||
|
'period': 3600,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -225,7 +227,7 @@ class AuditShellTest(base.CommandTestCase):
|
|||||||
result)
|
result)
|
||||||
self.m_audit_mgr.create.assert_called_once_with(
|
self.m_audit_mgr.create.assert_called_once_with(
|
||||||
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
||||||
type='ONESHOT')
|
type='ONESHOT', period=3600)
|
||||||
|
|
||||||
def test_do_audit_create_with_audit_template_name(self):
|
def test_do_audit_create_with_audit_template_name(self):
|
||||||
audit = resource.Audit(mock.Mock(), AUDIT_1)
|
audit = resource.Audit(mock.Mock(), AUDIT_1)
|
||||||
@@ -241,7 +243,7 @@ class AuditShellTest(base.CommandTestCase):
|
|||||||
result)
|
result)
|
||||||
self.m_audit_mgr.create.assert_called_once_with(
|
self.m_audit_mgr.create.assert_called_once_with(
|
||||||
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
||||||
type='ONESHOT')
|
type='ONESHOT', period=3600)
|
||||||
|
|
||||||
def test_do_audit_create_with_deadline(self):
|
def test_do_audit_create_with_deadline(self):
|
||||||
audit = resource.Audit(mock.Mock(), AUDIT_1)
|
audit = resource.Audit(mock.Mock(), AUDIT_1)
|
||||||
@@ -259,7 +261,8 @@ class AuditShellTest(base.CommandTestCase):
|
|||||||
self.m_audit_mgr.create.assert_called_once_with(
|
self.m_audit_mgr.create.assert_called_once_with(
|
||||||
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
||||||
type='ONESHOT',
|
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):
|
def test_do_audit_create_with_type(self):
|
||||||
audit = resource.Audit(mock.Mock(), AUDIT_1)
|
audit = resource.Audit(mock.Mock(), AUDIT_1)
|
||||||
@@ -276,4 +279,4 @@ class AuditShellTest(base.CommandTestCase):
|
|||||||
result)
|
result)
|
||||||
self.m_audit_mgr.create.assert_called_once_with(
|
self.m_audit_mgr.create.assert_called_once_with(
|
||||||
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
||||||
type='ONESHOT')
|
type='ONESHOT', period=3600)
|
||||||
|
@@ -18,7 +18,7 @@ from watcherclient.common import base
|
|||||||
from watcherclient.common import utils
|
from watcherclient.common import utils
|
||||||
from watcherclient import exceptions as exc
|
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):
|
class Audit(base.Resource):
|
||||||
|
@@ -132,13 +132,19 @@ class CreateAudit(command.ShowOne):
|
|||||||
metavar='<type>',
|
metavar='<type>',
|
||||||
default='ONESHOT',
|
default='ONESHOT',
|
||||||
help=_("Audit type."))
|
help=_("Audit type."))
|
||||||
|
parser.add_argument(
|
||||||
|
'-p', '--period',
|
||||||
|
dest='period',
|
||||||
|
metavar='<period>',
|
||||||
|
default=3600,
|
||||||
|
help=_("Audit period."))
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = getattr(self.app.client_manager, "infra-optim")
|
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()
|
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
|
||||||
if k in field_list and v is not None)
|
if k in field_list and v is not None)
|
||||||
if fields.get('audit_template_uuid'):
|
if fields.get('audit_template_uuid'):
|
||||||
|
@@ -34,11 +34,11 @@ AUDIT_TEMPLATE_SHORT_LIST_FIELD_LABELS = ['UUID', 'Name']
|
|||||||
# Audit
|
# Audit
|
||||||
AUDIT_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at',
|
AUDIT_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at',
|
||||||
'deadline', 'state', 'type', 'audit_template_uuid',
|
'deadline', 'state', 'type', 'audit_template_uuid',
|
||||||
'audit_template_name']
|
'audit_template_name', 'period']
|
||||||
|
|
||||||
AUDIT_FIELD_LABELS = ['UUID', 'Created At', 'Updated At', 'Deleted At',
|
AUDIT_FIELD_LABELS = ['UUID', 'Created At', 'Updated At', 'Deleted At',
|
||||||
'Deadline', 'State', 'Type', 'Audit Template uuid',
|
'Deadline', 'State', 'Type', 'Audit Template uuid',
|
||||||
'Audit Template Name']
|
'Audit Template Name', 'Period']
|
||||||
|
|
||||||
AUDIT_SHORT_LIST_FIELDS = ['uuid', 'type', 'audit_template_name', 'state']
|
AUDIT_SHORT_LIST_FIELDS = ['uuid', 'type', 'audit_template_name', 'state']
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user