Add operators to provide multivalue support
Added 'operators' to metadef jsons and property schema. With the new section end-user knows which multivalue operators are suitable for given property. Implements: blueprint metadata-multivalue-operators-support DocImpact APIImpact Change-Id: I0219bfaacfdc084200deb83d7806800c34f9aa6d
This commit is contained in:
parent
2420b6b329
commit
473ac5fff6
etc/metadefs
glance
api/v2
tests
@ -18,6 +18,7 @@
|
||||
"cpu_info:vendor": {
|
||||
"title": "Vendor",
|
||||
"description": "Specifies the CPU manufacturer.",
|
||||
"operators": ["<or>"],
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Intel",
|
||||
@ -27,6 +28,7 @@
|
||||
"cpu_info:model": {
|
||||
"title": "Model",
|
||||
"description": "Specifies the CPU model. Use this property to ensure that your vm runs on a a specific cpu model.",
|
||||
"operators": ["<or>"],
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Conroe",
|
||||
@ -65,6 +67,7 @@
|
||||
"cpu_info:arch": {
|
||||
"title": "Architecture",
|
||||
"description": "Specifies the CPU architecture. Use this property to specify the architecture supported by the hypervisor.",
|
||||
"operators": ["<or>"],
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"x86",
|
||||
@ -99,6 +102,7 @@
|
||||
"cpu_info:features": {
|
||||
"title": "Features",
|
||||
"description": "Specifies CPU flags/features. Using this property you can specify the required set of instructions supported by a vm.",
|
||||
"operators": ["<or>", "<all-in>"],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
|
@ -571,6 +571,12 @@ def get_schema_definitions():
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"operators": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
@ -28,6 +28,7 @@ class PropertyType(types.Base, WSMEModelTransformer):
|
||||
type = wsme.wsattr(types.text, mandatory=True)
|
||||
title = wsme.wsattr(types.text, mandatory=True)
|
||||
description = wsme.wsattr(types.text, mandatory=False)
|
||||
operators = wsme.wsattr([types.text], mandatory=False)
|
||||
default = wsme.wsattr(types.bytes, mandatory=False)
|
||||
|
||||
# fields for type = string
|
||||
|
@ -88,6 +88,7 @@ class TestMetadefObjects(functional.FunctionalTest):
|
||||
"type": "integer",
|
||||
"title": "property1",
|
||||
"description": "property1 description",
|
||||
"operators": ["<all-in>"],
|
||||
"default": 100,
|
||||
"minimum": 100,
|
||||
"maximum": 30000369
|
||||
@ -139,6 +140,7 @@ class TestMetadefObjects(functional.FunctionalTest):
|
||||
'type': 'integer',
|
||||
"title": "property1",
|
||||
'description': 'property1 description',
|
||||
'operators': ['<all-in>'],
|
||||
'default': 100,
|
||||
'minimum': 100,
|
||||
'maximum': 30000369
|
||||
@ -201,6 +203,7 @@ class TestMetadefObjects(functional.FunctionalTest):
|
||||
"type": "string",
|
||||
"title": "property2",
|
||||
"description": "p2 desc-UPDATED",
|
||||
'operators': ['<or>'],
|
||||
"default": "value2-UPDATED",
|
||||
"minLength": 5,
|
||||
"maxLength": 150
|
||||
@ -223,6 +226,7 @@ class TestMetadefObjects(functional.FunctionalTest):
|
||||
self.assertEqual('500', updated_property1['default'])
|
||||
self.assertEqual(500, updated_property1['minimum'])
|
||||
self.assertEqual(1369, updated_property1['maximum'])
|
||||
self.assertEqual(['<or>'], updated_property2['operators'])
|
||||
self.assertEqual('string', updated_property2['type'])
|
||||
self.assertEqual('p2 desc-UPDATED', updated_property2['description'])
|
||||
self.assertEqual('value2-UPDATED', updated_property2['default'])
|
||||
@ -244,6 +248,7 @@ class TestMetadefObjects(functional.FunctionalTest):
|
||||
self.assertEqual('500', updated_property1['default'])
|
||||
self.assertEqual(500, updated_property1['minimum'])
|
||||
self.assertEqual(1369, updated_property1['maximum'])
|
||||
self.assertEqual(['<or>'], updated_property2['operators'])
|
||||
self.assertEqual('string', updated_property2['type'])
|
||||
self.assertEqual('p2 desc-UPDATED', updated_property2['description'])
|
||||
self.assertEqual('value2-UPDATED', updated_property2['default'])
|
||||
|
@ -172,6 +172,7 @@ class TestNamespaceProperties(functional.FunctionalTest):
|
||||
"type": "string",
|
||||
"title": "string property",
|
||||
"description": "desc-UPDATED",
|
||||
"operators": ["<or>"],
|
||||
"default": "value-UPDATED",
|
||||
"minLength": 5,
|
||||
"maxLength": 10
|
||||
@ -185,6 +186,7 @@ class TestNamespaceProperties(functional.FunctionalTest):
|
||||
self.assertEqual('string', property_object['type'])
|
||||
self.assertEqual('desc-UPDATED', property_object['description'])
|
||||
self.assertEqual('value-UPDATED', property_object['default'])
|
||||
self.assertEqual(["<or>"], property_object['operators'])
|
||||
self.assertEqual(5, property_object['minLength'])
|
||||
self.assertEqual(10, property_object['maxLength'])
|
||||
|
||||
@ -195,6 +197,7 @@ class TestNamespaceProperties(functional.FunctionalTest):
|
||||
self.assertEqual('string', property_object['type'])
|
||||
self.assertEqual('desc-UPDATED', property_object['description'])
|
||||
self.assertEqual('value-UPDATED', property_object['default'])
|
||||
self.assertEqual(["<or>"], property_object['operators'])
|
||||
self.assertEqual(5, property_object['minLength'])
|
||||
self.assertEqual(10, property_object['maxLength'])
|
||||
|
||||
|
@ -673,6 +673,28 @@ class TestMetadefsControllers(base.IsolatedUnitTest):
|
||||
self.assertEqual('string', property.type)
|
||||
self.assertEqual('title', property.title)
|
||||
|
||||
def test_property_create_with_operators(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
||||
property = glance.api.v2.model.metadef_property_type.PropertyType()
|
||||
property.name = PROPERTY2
|
||||
property.type = 'string'
|
||||
property.title = 'title'
|
||||
property.operators = ['<or>']
|
||||
property = self.property_controller.create(request, NAMESPACE1,
|
||||
property)
|
||||
self.assertEqual(PROPERTY2, property.name)
|
||||
self.assertEqual('string', property.type)
|
||||
self.assertEqual('title', property.title)
|
||||
self.assertEqual(['<or>'], property.operators)
|
||||
|
||||
property = self.property_controller.show(request, NAMESPACE1,
|
||||
PROPERTY2)
|
||||
self.assertEqual(PROPERTY2, property.name)
|
||||
self.assertEqual('string', property.type)
|
||||
self.assertEqual('title', property.title)
|
||||
self.assertEqual(['<or>'], property.operators)
|
||||
|
||||
def test_property_create_conflict(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user