Merge "bug fix: ensure resource class instead of getting it."

This commit is contained in:
Zuul 2019-10-29 06:20:22 +00:00 committed by Gerrit Code Review
commit 41d03fc1da
2 changed files with 9 additions and 5 deletions

View File

@ -28,6 +28,7 @@ PLACEMENT_CLIENT_SEMAPHORE = 'placement_client'
class PlacementClient(object):
"""Client class for reporting to placement."""
def __init__(self):
self._client = utils.get_sdk_adapter('placement')
@ -226,6 +227,12 @@ class PlacementClient(object):
}
LOG.error(msg, args)
raise exception.InvalidResourceClass(resource_class=name)
elif resp.status_code == 204:
LOG.info("Resource class %(rc_name)s already exists",
{"rc_name": name})
elif resp.status_code == 201:
LOG.info("Successfully created resource class %(rc_name).", {
"rc_name", name})
def _get_providers_in_tree(self, context, uuid):
"""Queries the placement API for a list of the resource providers in

View File

@ -386,12 +386,9 @@ class ConductorManager(object):
def provider_report(self, context, name, resource_class, traits, total,
parent):
try:
self.placement_client.get("/resource_classes/%s" %
resource_class,
version='1.26')
self.placement_client.ensure_resource_classes(
context, [resource_class])
except Exception as e:
self.placement_client.ensure_resource_classes(context,
[resource_class])
LOG.error("Error, could not access resource_classes."
"Details: %(info)s", {"info": e})