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:
Vladimir Ostroverkhov
2016-05-26 11:49:55 +03:00
parent 544db1951f
commit 888a58fd2a
4 changed files with 17 additions and 8 deletions

View File

@@ -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)

View File

@@ -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):

View File

@@ -132,13 +132,19 @@ class CreateAudit(command.ShowOne):
metavar='<type>',
default='ONESHOT',
help=_("Audit type."))
parser.add_argument(
'-p', '--period',
dest='period',
metavar='<period>',
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'):

View File

@@ -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']