Merge "bug fix: ensure resource class instead of getting it."
This commit is contained in:
commit
41d03fc1da
@ -28,6 +28,7 @@ PLACEMENT_CLIENT_SEMAPHORE = 'placement_client'
|
|||||||
|
|
||||||
class PlacementClient(object):
|
class PlacementClient(object):
|
||||||
"""Client class for reporting to placement."""
|
"""Client class for reporting to placement."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._client = utils.get_sdk_adapter('placement')
|
self._client = utils.get_sdk_adapter('placement')
|
||||||
|
|
||||||
@ -226,6 +227,12 @@ class PlacementClient(object):
|
|||||||
}
|
}
|
||||||
LOG.error(msg, args)
|
LOG.error(msg, args)
|
||||||
raise exception.InvalidResourceClass(resource_class=name)
|
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):
|
def _get_providers_in_tree(self, context, uuid):
|
||||||
"""Queries the placement API for a list of the resource providers in
|
"""Queries the placement API for a list of the resource providers in
|
||||||
|
@ -386,12 +386,9 @@ class ConductorManager(object):
|
|||||||
def provider_report(self, context, name, resource_class, traits, total,
|
def provider_report(self, context, name, resource_class, traits, total,
|
||||||
parent):
|
parent):
|
||||||
try:
|
try:
|
||||||
self.placement_client.get("/resource_classes/%s" %
|
self.placement_client.ensure_resource_classes(
|
||||||
resource_class,
|
context, [resource_class])
|
||||||
version='1.26')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.placement_client.ensure_resource_classes(context,
|
|
||||||
[resource_class])
|
|
||||||
LOG.error("Error, could not access resource_classes."
|
LOG.error("Error, could not access resource_classes."
|
||||||
"Details: %(info)s", {"info": e})
|
"Details: %(info)s", {"info": e})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user