Merge "Fix warlock model creation"

This commit is contained in:
Jenkins 2016-08-12 15:15:46 +00:00 committed by Gerrit Code Review
commit 5de07c3395
5 changed files with 19 additions and 12 deletions

View File

@ -130,7 +130,7 @@ class TestSchemaBasedModel(testtools.TestCase):
def setUp(self):
super(TestSchemaBasedModel, self).setUp()
self.model = warlock.model_factory(_SCHEMA.raw(),
schemas.SchemaBasedModel)
base_class=schemas.SchemaBasedModel)
def test_patch_should_replace_missing_core_properties(self):
obj = {

View File

@ -27,7 +27,8 @@ class Controller(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('image')
return warlock.model_factory(schema.raw(), schemas.SchemaBasedModel)
return warlock.model_factory(schema.raw(),
base_class=schemas.SchemaBasedModel)
def update(self, image_id, tag_value):
"""Update an image with the given tag.

View File

@ -39,16 +39,16 @@ class Controller(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('image')
warlock_model = warlock.model_factory(schema.raw(),
schemas.SchemaBasedModel)
warlock_model = warlock.model_factory(
schema.raw(), base_class=schemas.SchemaBasedModel)
return warlock_model
@utils.memoized_property
def unvalidated_model(self):
"""A model which does not validate the image against the v2 schema."""
schema = self.schema_client.get('image')
warlock_model = warlock.model_factory(schema.raw(),
schemas.SchemaBasedModel)
warlock_model = warlock.model_factory(
schema.raw(), base_class=schemas.SchemaBasedModel)
warlock_model.validate = lambda *args, **kwargs: None
return warlock_model

View File

@ -34,7 +34,8 @@ class NamespaceController(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('metadefs/namespace')
return warlock.model_factory(schema.raw(), schemas.SchemaBasedModel)
return warlock.model_factory(schema.raw(),
base_class=schemas.SchemaBasedModel)
def create(self, **kwargs):
"""Create a namespace.
@ -186,7 +187,8 @@ class ResourceTypeController(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('metadefs/resource_type')
return warlock.model_factory(schema.raw(), schemas.SchemaBasedModel)
return warlock.model_factory(schema.raw(),
base_class=schemas.SchemaBasedModel)
def associate(self, namespace, **kwargs):
"""Associate a resource type with a namespace."""
@ -234,7 +236,8 @@ class PropertyController(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('metadefs/property')
return warlock.model_factory(schema.raw(), schemas.SchemaBasedModel)
return warlock.model_factory(schema.raw(),
base_class=schemas.SchemaBasedModel)
def create(self, namespace, **kwargs):
"""Create a property.
@ -314,7 +317,8 @@ class ObjectController(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('metadefs/object')
return warlock.model_factory(schema.raw(), schemas.SchemaBasedModel)
return warlock.model_factory(schema.raw(),
base_class=schemas.SchemaBasedModel)
def create(self, namespace, **kwargs):
"""Create an object.
@ -397,7 +401,8 @@ class TagController(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('metadefs/tag')
return warlock.model_factory(schema.raw(), schemas.SchemaBasedModel)
return warlock.model_factory(schema.raw(),
base_class=schemas.SchemaBasedModel)
def create(self, namespace, tag_name):
"""Create a tag.

View File

@ -35,7 +35,8 @@ class Controller(object):
@utils.memoized_property
def model(self):
schema = self.schema_client.get('task')
return warlock.model_factory(schema.raw(), schemas.SchemaBasedModel)
return warlock.model_factory(schema.raw(),
base_class=schemas.SchemaBasedModel)
def list(self, **kwargs):
"""Retrieve a listing of Task objects.