Add support continuously-optimization

This patch set adds support for interval
field to python-watcherclient

Depends-On: I5f4ec97b2082c8a6b3ccebe36b2a343fa4a67d19
Implements: blueprint continuously-optimization

Change-Id: I1152c9c6d9379e250ba46adbc58789d8b13bfd5a
This commit is contained in:
Vladimir Ostroverkhov
2016-07-07 17:23:51 +03:00
committed by David TARDIVEL
parent 91d1d8b0e1
commit 918d2f0bbd
4 changed files with 48 additions and 6 deletions

View File

@@ -49,6 +49,7 @@ AUDIT_1 = {
'updated_at': None,
'deleted_at': None,
'parameters': None,
'interval': None,
}
AUDIT_2 = {
@@ -62,6 +63,21 @@ AUDIT_2 = {
'updated_at': None,
'deleted_at': None,
'parameters': None,
'interval': None,
}
AUDIT_3 = {
'uuid': '43199d0e-0712-1213-9674-5ae2af8dhgte',
'deadline': None,
'audit_type': 'CONTINUOUS',
'audit_template_uuid': 'f8e47706-efcf-49a4-a5c4-af604eb492f2',
'audit_template_name': 'at1',
'state': 'PENDING',
'created_at': datetime.datetime.now().isoformat(),
'updated_at': None,
'deleted_at': None,
'parameters': None,
'interval': 3600,
}
@@ -297,3 +313,21 @@ class AuditShellTest(base.CommandTestCase):
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
audit_type='ONESHOT',
parameters={'para1': 10, 'para2': 20})
def test_do_audit_create_with_type_continuous(self):
audit = resource.Audit(mock.Mock(), AUDIT_3)
audit_template = resource.AuditTemplate(mock.Mock(), AUDIT_TEMPLATE_1)
self.m_audit_template_mgr.get.return_value = audit_template
self.m_audit_mgr.create.return_value = audit
exit_code, result = self.run_cmd(
'audit create -a at1 -t CONTINUOUS -i 3600')
self.assertEqual(0, exit_code)
self.assertEqual(
self.resource_as_dict(audit, self.FIELDS, self.FIELD_LABELS),
result)
self.m_audit_mgr.create.assert_called_once_with(
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
audit_type='CONTINUOUS',
interval='3600')

View File

@@ -18,8 +18,9 @@ from watcherclient.common import base
from watcherclient.common import utils
from watcherclient import exceptions as exc
CREATION_ATTRIBUTES = ['audit_template_uuid', 'deadline', 'audit_type',
'parameters']
CREATION_ATTRIBUTES = ['audit_template_uuid', 'deadline',
'audit_type', 'parameters', 'interval']
class Audit(base.Resource):

View File

@@ -139,13 +139,20 @@ class CreateAudit(command.ShowOne):
action='append',
help=_("Record strategy parameter/value metadata. "
"Can be specified multiple times."))
parser.add_argument(
'-i', '--interval',
dest='interval',
metavar='<interval>',
help=_("Audit interval."))
return parser
def take_action(self, parsed_args):
client = getattr(self.app.client_manager, "infra-optim")
field_list = ['audit_template_uuid', 'audit_type', 'deadline',
'parameters']
field_list = ['audit_template_uuid', 'audit_type',
'deadline', 'parameters', 'interval']
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
if k in field_list and v is not None)
fields = common_utils.args_array_to_dict(fields, 'parameters')

View File

@@ -35,11 +35,11 @@ AUDIT_TEMPLATE_SHORT_LIST_FIELD_LABELS = ['UUID', 'Name', 'Goal', 'Strategy']
# Audit
AUDIT_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at',
'deadline', 'state', 'audit_type', 'audit_template_uuid',
'audit_template_name', 'parameters']
'audit_template_name', 'parameters', 'interval']
AUDIT_FIELD_LABELS = ['UUID', 'Created At', 'Updated At', 'Deleted At',
'Deadline', 'State', 'Audit Type', 'Audit Template uuid',
'Audit Template Name', 'Parameters']
'Audit Template Name', 'Parameters', 'Interval']
AUDIT_SHORT_LIST_FIELDS = [
'uuid', 'audit_type', 'audit_template_name', 'state']