Fix warlock model creation

Commands like glance md-namespace-show <namespace> fail because
of a breaking change in warlock 1.3.0's model creation factory
method.

Warlock introduced a new kwarg 'resolver' in model_factory method
but changed its position with the 'base_class' kwarg. Since we
were calling the model_factory method with positional arg, this
broke the model creation.

Closes-Bug: #1596573

Change-Id: Ic7821f4fdb1b752e0c7ed2bc486299a06bf485c1
This commit is contained in:
Sabari Kumar Murugesan 2016-07-06 18:02:28 -07:00
parent f2c02830f6
commit d7db97c926
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.