Merge "Fix DEFAULT_SCHEMA to validate host_aggreates"
This commit is contained in:
@@ -36,12 +36,10 @@ class DefaultScope(base.BaseScope):
|
||||
"host_aggregates": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"anyOf": [
|
||||
{"type": ["string", "number"]}
|
||||
]
|
||||
},
|
||||
"anyOf": [
|
||||
{"$ref": "#/host_aggregates/id"},
|
||||
{"$ref": "#/host_aggregates/name"},
|
||||
]
|
||||
}
|
||||
},
|
||||
"availability_zones": {
|
||||
@@ -69,7 +67,8 @@ class DefaultScope(base.BaseScope):
|
||||
"uuid": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"compute_nodes": {
|
||||
@@ -80,18 +79,17 @@ class DefaultScope(base.BaseScope):
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"host_aggregates": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"anyOf": [
|
||||
{"type": ["string", "number"]}
|
||||
]
|
||||
},
|
||||
"anyOf": [
|
||||
{"$ref": "#/host_aggregates/id"},
|
||||
{"$ref": "#/host_aggregates/name"},
|
||||
]
|
||||
}
|
||||
},
|
||||
"instance_metadata": {
|
||||
@@ -106,7 +104,29 @@ class DefaultScope(base.BaseScope):
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"host_aggregates": {
|
||||
"id": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"oneOf": [
|
||||
{"type": "integer"},
|
||||
{"enum": ["*"]}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
},
|
||||
"name": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
def __init__(self, scope, config, osc=None):
|
||||
|
||||
@@ -511,7 +511,7 @@ class TestPost(FunctionalTestWithSetup):
|
||||
response.json['created_at']).replace(tzinfo=None)
|
||||
self.assertEqual(test_time, return_created_at)
|
||||
|
||||
def test_create_audit_template_vlidation_with_aggregates(self):
|
||||
def test_create_audit_template_validation_with_aggregates(self):
|
||||
scope = [{'host_aggregates': [{'id': '*'}]},
|
||||
{'availability_zones': [{'name': 'AZ1'},
|
||||
{'name': 'AZ2'}]},
|
||||
@@ -532,6 +532,14 @@ class TestPost(FunctionalTestWithSetup):
|
||||
"be included and excluded together"):
|
||||
self.post_json('/audit_templates', audit_template_dict)
|
||||
|
||||
scope = [{'host_aggregates': [{'id1': '*'}]}]
|
||||
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, expect_errors=True)
|
||||
self.assertEqual(500, response.status_int)
|
||||
|
||||
def test_create_audit_template_does_autogenerate_id(self):
|
||||
audit_template_dict = post_get_test_audit_template(
|
||||
goal=self.fake_goal1.uuid, strategy=None)
|
||||
|
||||
Reference in New Issue
Block a user