updated unmapped properties handling
Change-Id: I14b0e7d06fafc38ac35967109c17af36b0dbe150
This commit is contained in:
parent
ccc6c4683b
commit
c05f99f52a
@ -32,9 +32,7 @@ class GlanceResourceDriver(base.ResourceInterface):
|
||||
self.separator = "."
|
||||
self.service_type = 'image'
|
||||
self.endpoint_type = 'publicURL'
|
||||
self.default_namespace = "Default"
|
||||
self.default_capability_type = "Default"
|
||||
self.default_resource_type = "OS::Glance::Image"
|
||||
self.unknown_properties_type = "AdditionalProperties"
|
||||
|
||||
def get_resource(self, resource_type, resource_id, auth_token,
|
||||
endpoint_id=None, **kwargs):
|
||||
@ -77,6 +75,12 @@ class GlanceResourceDriver(base.ResourceInterface):
|
||||
|
||||
image_properties = {}
|
||||
for capability in resource.capabilities:
|
||||
if capability.capability_type_namespace == resource_type \
|
||||
and capability.capability_type \
|
||||
== self.unknown_properties_type:
|
||||
for property in capability.properties:
|
||||
image_properties[property.name] = property.value
|
||||
else:
|
||||
properties = capability.properties
|
||||
capability_type = self.replace_colon_from_name(
|
||||
capability.capability_type
|
||||
@ -96,10 +100,11 @@ class GlanceResourceDriver(base.ResourceInterface):
|
||||
image = glance_client.images.get(resource.id)
|
||||
image.update(properties=image_properties, purge_props=False)
|
||||
|
||||
def find_resources(self, query_string, auth_token,
|
||||
def find_resources(self, resource_type, query_string, auth_token,
|
||||
endpoint_id=None, **kwargs):
|
||||
"""Find resources matching the query
|
||||
:param query_string: query expression. Include resource type(s)
|
||||
:param resource_type: resource_type set for this call
|
||||
:param query_string: query expression
|
||||
:param auth_token: keystone auth_token of request user
|
||||
:param endpoint_id: id for locating the cloud resource provider
|
||||
:param **kwargs: Include additional info required by the driver,
|
||||
@ -111,7 +116,7 @@ class GlanceResourceDriver(base.ResourceInterface):
|
||||
images = glance_client.images.list()
|
||||
for image in list(images):
|
||||
resource = self.transform_image_to_resource(
|
||||
self.default_resource_type,
|
||||
resource_type,
|
||||
image
|
||||
)
|
||||
resource_list[resource.id] = resource
|
||||
@ -187,8 +192,8 @@ class GlanceResourceDriver(base.ResourceInterface):
|
||||
capability_type = self.replace_hash_from_name(capability_type)
|
||||
prop_name = self.replace_hash_from_name(prop_name)
|
||||
else:
|
||||
namespace = self.default_namespace
|
||||
capability_type = self.default_capability_type
|
||||
namespace = resource_type
|
||||
capability_type = self.unknown_properties_type
|
||||
prop_name = key
|
||||
|
||||
image_property = Property()
|
||||
@ -221,3 +226,4 @@ class GlanceResourceDriver(base.ResourceInterface):
|
||||
if name:
|
||||
return name.replace('#', ':')
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user