diff --git a/cyborg/common/placement_client.py b/cyborg/common/placement_client.py index d83bcd6e..25d62acc 100644 --- a/cyborg/common/placement_client.py +++ b/cyborg/common/placement_client.py @@ -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 diff --git a/cyborg/conductor/manager.py b/cyborg/conductor/manager.py index f268231e..e8134298 100644 --- a/cyborg/conductor/manager.py +++ b/cyborg/conductor/manager.py @@ -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})