Merge "Compatible with old scope format" into stable/train
This commit is contained in:
commit
69a9e4bee4
|
@ -138,6 +138,9 @@ class AuditTemplatePostType(wtypes.Base):
|
||||||
raise exception.InvalidGoal(goal=audit_template.goal)
|
raise exception.InvalidGoal(goal=audit_template.goal)
|
||||||
|
|
||||||
if audit_template.scope:
|
if audit_template.scope:
|
||||||
|
keys = [list(s)[0] for s in audit_template.scope]
|
||||||
|
if keys[0] not in ('compute', 'storage'):
|
||||||
|
audit_template.scope = [dict(compute=audit_template.scope)]
|
||||||
common_utils.Draft4Validator(
|
common_utils.Draft4Validator(
|
||||||
AuditTemplatePostType._build_schema()
|
AuditTemplatePostType._build_schema()
|
||||||
).validate(audit_template.scope)
|
).validate(audit_template.scope)
|
||||||
|
|
|
@ -663,6 +663,26 @@ class TestPost(FunctionalTestWithSetup):
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
assert not cn_mock.called
|
assert not cn_mock.called
|
||||||
|
|
||||||
|
def test_create_audit_template_with_old_scope(self):
|
||||||
|
scope = [{'host_aggregates': [{'id': '*'}]},
|
||||||
|
{'availability_zones': [{'name': 'AZ1'},
|
||||||
|
{'name': 'AZ2'}]},
|
||||||
|
{'exclude': [
|
||||||
|
{'instances': [
|
||||||
|
{'uuid': 'INSTANCE_1'},
|
||||||
|
{'uuid': 'INSTANCE_2'}]},
|
||||||
|
{'compute_nodes': [
|
||||||
|
{'name': 'Node_1'},
|
||||||
|
{'name': 'Node_2'}]},
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
audit_template_dict = post_get_test_audit_template(
|
||||||
|
goal=self.fake_goal1.uuid,
|
||||||
|
strategy=self.fake_strategy1.uuid, scope=scope)
|
||||||
|
response = self.post_json('/audit_templates',
|
||||||
|
audit_template_dict)
|
||||||
|
self.assertEqual(201, response.status_int)
|
||||||
|
|
||||||
|
|
||||||
class TestDelete(api_base.FunctionalTest):
|
class TestDelete(api_base.FunctionalTest):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue