def delete_reservation_inventory(self, host_name, reserv_uuid): """Delete the reservation inventory for the reservation provider. :param host_name: The name of the target host :param reserv_uuid: The reservation uuid :raises: ResourceProviderNotFound if the reservation provider is not found """ # Get reservation provider uuid rp_name = "blazar_" + host_name rp = self.get_resource_provider(rp_name) if rp is None: raise exceptions.ResourceProviderNotFound( resource_provider=rp_name) rp_uuid = rp['uuid'] # Convert reservation uuid to resource class name reserv_uuid = reserv_uuid.upper().replace("-", "_") rc_name = 'CUSTOM_RESERVATION_' + reserv_uuid try: self.delete_inventory(rp_uuid, rc_name) except exceptions.InventoryUpdateFailed: # We just log it and skip to keep the compatibility before Stein LOG.info( "Resource class %s doesn't exist or there is no " "inventory for that resource class on resource provider " "%s. Skipped the deletion", rc_name, rp_name)
def get_inventory(self, rp_uuid): """Calls the placement API to get resource inventory information. :param rp_uuid: UUID of the resource provider to get """ url = '/resource_providers/%s/inventories' % rp_uuid resp = self.get(url) if resp: return resp.json() raise exceptions.ResourceProviderNotFound(resource_provider=rp_uuid)
def create_reservation_provider(self, host_name): """Create a reservation provider as a child of the given host""" host_rp = self.get_resource_provider(host_name) if host_rp is None: raise exceptions.ResourceProviderNotFound( resource_provider=host_name) host_uuid = host_rp['uuid'] rp_name = "blazar_" + host_name reservation_rp = self.create_resource_provider(rp_name, parent_uuid=host_uuid) return reservation_rp