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.separator = "."
|
||||||
self.service_type = 'image'
|
self.service_type = 'image'
|
||||||
self.endpoint_type = 'publicURL'
|
self.endpoint_type = 'publicURL'
|
||||||
self.default_namespace = "Default"
|
self.unknown_properties_type = "AdditionalProperties"
|
||||||
self.default_capability_type = "Default"
|
|
||||||
self.default_resource_type = "OS::Glance::Image"
|
|
||||||
|
|
||||||
def get_resource(self, resource_type, resource_id, auth_token,
|
def get_resource(self, resource_type, resource_id, auth_token,
|
||||||
endpoint_id=None, **kwargs):
|
endpoint_id=None, **kwargs):
|
||||||
@ -77,29 +75,36 @@ class GlanceResourceDriver(base.ResourceInterface):
|
|||||||
|
|
||||||
image_properties = {}
|
image_properties = {}
|
||||||
for capability in resource.capabilities:
|
for capability in resource.capabilities:
|
||||||
properties = capability.properties
|
if capability.capability_type_namespace == resource_type \
|
||||||
capability_type = self.replace_colon_from_name(
|
and capability.capability_type \
|
||||||
capability.capability_type
|
== self.unknown_properties_type:
|
||||||
)
|
for property in capability.properties:
|
||||||
capability_type_namespace = self.replace_colon_from_name(
|
image_properties[property.name] = property.value
|
||||||
capability.capability_type_namespace
|
else:
|
||||||
)
|
properties = capability.properties
|
||||||
|
capability_type = self.replace_colon_from_name(
|
||||||
|
capability.capability_type
|
||||||
|
)
|
||||||
|
capability_type_namespace = self.replace_colon_from_name(
|
||||||
|
capability.capability_type_namespace
|
||||||
|
)
|
||||||
|
|
||||||
for property in properties:
|
for property in properties:
|
||||||
prop_name = capability_type_namespace + \
|
prop_name = capability_type_namespace + \
|
||||||
self.separator + \
|
self.separator + \
|
||||||
capability_type + \
|
capability_type + \
|
||||||
self.separator + \
|
self.separator + \
|
||||||
self.replace_colon_from_name(property.name)
|
self.replace_colon_from_name(property.name)
|
||||||
image_properties[prop_name] = property.value
|
image_properties[prop_name] = property.value
|
||||||
|
|
||||||
image = glance_client.images.get(resource.id)
|
image = glance_client.images.get(resource.id)
|
||||||
image.update(properties=image_properties, purge_props=False)
|
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):
|
endpoint_id=None, **kwargs):
|
||||||
"""Find resources matching the query
|
"""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 auth_token: keystone auth_token of request user
|
||||||
:param endpoint_id: id for locating the cloud resource provider
|
:param endpoint_id: id for locating the cloud resource provider
|
||||||
:param **kwargs: Include additional info required by the driver,
|
:param **kwargs: Include additional info required by the driver,
|
||||||
@ -111,7 +116,7 @@ class GlanceResourceDriver(base.ResourceInterface):
|
|||||||
images = glance_client.images.list()
|
images = glance_client.images.list()
|
||||||
for image in list(images):
|
for image in list(images):
|
||||||
resource = self.transform_image_to_resource(
|
resource = self.transform_image_to_resource(
|
||||||
self.default_resource_type,
|
resource_type,
|
||||||
image
|
image
|
||||||
)
|
)
|
||||||
resource_list[resource.id] = resource
|
resource_list[resource.id] = resource
|
||||||
@ -187,8 +192,8 @@ class GlanceResourceDriver(base.ResourceInterface):
|
|||||||
capability_type = self.replace_hash_from_name(capability_type)
|
capability_type = self.replace_hash_from_name(capability_type)
|
||||||
prop_name = self.replace_hash_from_name(prop_name)
|
prop_name = self.replace_hash_from_name(prop_name)
|
||||||
else:
|
else:
|
||||||
namespace = self.default_namespace
|
namespace = resource_type
|
||||||
capability_type = self.default_capability_type
|
capability_type = self.unknown_properties_type
|
||||||
prop_name = key
|
prop_name = key
|
||||||
|
|
||||||
image_property = Property()
|
image_property = Property()
|
||||||
@ -221,3 +226,4 @@ class GlanceResourceDriver(base.ResourceInterface):
|
|||||||
if name:
|
if name:
|
||||||
return name.replace('#', ':')
|
return name.replace('#', ':')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user