Merge "Add operators to provide multivalue support"

This commit is contained in:
Jenkins 2015-03-11 06:57:54 +00:00 committed by Gerrit Code Review
commit 030250ed64
6 changed files with 41 additions and 0 deletions

View File

@ -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",

View File

@ -571,6 +571,12 @@ def get_schema_definitions():
"description": {
"type": "string"
},
"operators": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string",
"enum": [

View File

@ -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)
readonly = wsme.wsattr(bool, mandatory=False)

View File

@ -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'])

View File

@ -176,6 +176,7 @@ class TestNamespaceProperties(functional.FunctionalTest):
"type": "string",
"title": "string property",
"description": "desc-UPDATED",
"operators": ["<or>"],
"default": "value-UPDATED",
"minLength": 5,
"maxLength": 10,
@ -190,6 +191,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'])
self.assertTrue(property_object['readonly'])
@ -201,6 +203,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'])

View File

@ -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()