Merge "Add auto_trigger support"
This commit is contained in:
@@ -68,6 +68,7 @@ AUDIT_1 = {
|
||||
'parameters': None,
|
||||
'interval': None,
|
||||
'scope': '',
|
||||
'auto_trigger': False,
|
||||
}
|
||||
|
||||
AUDIT_2 = {
|
||||
@@ -84,6 +85,7 @@ AUDIT_2 = {
|
||||
'parameters': None,
|
||||
'interval': None,
|
||||
'scope': '',
|
||||
'auto_trigger': False,
|
||||
}
|
||||
|
||||
AUDIT_3 = {
|
||||
@@ -100,6 +102,7 @@ AUDIT_3 = {
|
||||
'parameters': None,
|
||||
'interval': 3600,
|
||||
'scope': '',
|
||||
'auto_trigger': True,
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +286,7 @@ class AuditShellTest(base.CommandTestCase):
|
||||
result)
|
||||
self.m_audit_mgr.create.assert_called_once_with(
|
||||
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
||||
audit_type='ONESHOT')
|
||||
audit_type='ONESHOT', auto_trigger=False)
|
||||
|
||||
def test_do_audit_create_with_audit_template_name(self):
|
||||
audit = resource.Audit(mock.Mock(), AUDIT_3)
|
||||
@@ -299,6 +302,7 @@ class AuditShellTest(base.CommandTestCase):
|
||||
result)
|
||||
self.m_audit_mgr.create.assert_called_once_with(
|
||||
audit_template_uuid='f8e47706-efcf-49a4-a5c4-af604eb492f2',
|
||||
auto_trigger=False,
|
||||
audit_type='ONESHOT')
|
||||
|
||||
def test_do_audit_create_with_goal(self):
|
||||
@@ -314,6 +318,7 @@ class AuditShellTest(base.CommandTestCase):
|
||||
result)
|
||||
self.m_audit_mgr.create.assert_called_once_with(
|
||||
goal='fc087747-61be-4aad-8126-b701731ae836',
|
||||
auto_trigger=False,
|
||||
audit_type='ONESHOT'
|
||||
)
|
||||
|
||||
@@ -332,6 +337,7 @@ class AuditShellTest(base.CommandTestCase):
|
||||
self.m_audit_mgr.create.assert_called_once_with(
|
||||
goal='fc087747-61be-4aad-8126-b701731ae836',
|
||||
strategy='2cf86250-d309-4b81-818e-1537f3dba6e5',
|
||||
auto_trigger=False,
|
||||
audit_type='ONESHOT'
|
||||
)
|
||||
|
||||
@@ -348,7 +354,7 @@ class AuditShellTest(base.CommandTestCase):
|
||||
result)
|
||||
self.m_audit_mgr.create.assert_called_once_with(
|
||||
goal='fc087747-61be-4aad-8126-b701731ae836',
|
||||
audit_type='ONESHOT')
|
||||
auto_trigger=False, audit_type='ONESHOT')
|
||||
|
||||
def test_do_audit_create_with_parameter(self):
|
||||
audit = resource.Audit(mock.Mock(), AUDIT_1)
|
||||
@@ -365,6 +371,7 @@ class AuditShellTest(base.CommandTestCase):
|
||||
self.m_audit_mgr.create.assert_called_once_with(
|
||||
goal='fc087747-61be-4aad-8126-b701731ae836',
|
||||
audit_type='ONESHOT',
|
||||
auto_trigger=False,
|
||||
parameters={'para1': 10, 'para2': 20})
|
||||
|
||||
def test_do_audit_create_with_type_continuous(self):
|
||||
@@ -382,4 +389,5 @@ class AuditShellTest(base.CommandTestCase):
|
||||
self.m_audit_mgr.create.assert_called_once_with(
|
||||
goal='fc087747-61be-4aad-8126-b701731ae836',
|
||||
audit_type='CONTINUOUS',
|
||||
auto_trigger=False,
|
||||
interval='3600')
|
||||
|
@@ -19,7 +19,7 @@ from watcherclient import exceptions as exc
|
||||
|
||||
|
||||
CREATION_ATTRIBUTES = ['audit_template_uuid', 'audit_type', 'interval',
|
||||
'parameters', 'goal', 'strategy']
|
||||
'parameters', 'goal', 'strategy', 'auto_trigger']
|
||||
|
||||
|
||||
class Audit(base.Resource):
|
||||
|
@@ -167,13 +167,20 @@ class CreateAudit(command.ShowOne):
|
||||
dest='audit_template_uuid',
|
||||
metavar='<audit_template>',
|
||||
help=_('Audit template used for this audit (name or uuid).'))
|
||||
parser.add_argument(
|
||||
'--auto-trigger',
|
||||
dest='auto_trigger',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('Trigger automatically action plan '
|
||||
'once audit is succeeded.'))
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
client = getattr(self.app.client_manager, "infra-optim")
|
||||
|
||||
field_list = ['audit_template_uuid', 'audit_type', 'parameters',
|
||||
'interval', 'goal', 'strategy']
|
||||
'interval', 'goal', 'strategy', 'auto_trigger']
|
||||
|
||||
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
|
||||
if k in field_list and v is not None)
|
||||
|
@@ -32,17 +32,18 @@ AUDIT_TEMPLATE_SHORT_LIST_FIELD_LABELS = ['UUID', 'Name', 'Goal', 'Strategy']
|
||||
# Audit
|
||||
AUDIT_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at',
|
||||
'state', 'audit_type', 'parameters', 'interval', 'goal_name',
|
||||
'strategy_name', 'scope']
|
||||
'strategy_name', 'scope', 'auto_trigger']
|
||||
|
||||
AUDIT_FIELD_LABELS = ['UUID', 'Created At', 'Updated At', 'Deleted At',
|
||||
'State', 'Audit Type', 'Parameters', 'Interval', 'Goal',
|
||||
'Strategy', 'Audit Scope']
|
||||
'Strategy', 'Audit Scope', 'Auto Trigger']
|
||||
|
||||
AUDIT_SHORT_LIST_FIELDS = ['uuid', 'audit_type',
|
||||
'state', 'goal_name', 'strategy_name']
|
||||
'state', 'goal_name', 'strategy_name',
|
||||
'auto_trigger']
|
||||
|
||||
AUDIT_SHORT_LIST_FIELD_LABELS = ['UUID', 'Audit Type', 'State', 'Goal',
|
||||
'Strategy']
|
||||
'Strategy', 'Auto Trigger']
|
||||
|
||||
# Action Plan
|
||||
ACTION_PLAN_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at',
|
||||
|
Reference in New Issue
Block a user