"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cyborg/common/placement_client.py" between
openstack-cyborg-6.0.0.tar.gz and openstack-cyborg-7.0.0.tar.gz

About: OpenStack Cyborg provides a general purpose management framework for acceleration resources.
The "Xena" series (latest release).

placement_client.py  (openstack-cyborg-6.0.0):placement_client.py  (openstack-cyborg-7.0.0)
skipping to change at line 114 skipping to change at line 114
"Failed to set traits to %s for rp %s: HTTP %d: %s" % "Failed to set traits to %s for rp %s: HTTP %d: %s" %
(traits_json, rp_uuid, resp.status_code, resp.text)) (traits_json, rp_uuid, resp.status_code, resp.text))
def add_traits_to_rp(self, rp_uuid, trait_names): def add_traits_to_rp(self, rp_uuid, trait_names):
self._ensure_traits(trait_names) self._ensure_traits(trait_names)
traits_json = self._get_rp_traits(rp_uuid) traits_json = self._get_rp_traits(rp_uuid)
traits = list(set(traits_json['traits'] + trait_names)) traits = list(set(traits_json['traits'] + trait_names))
traits_json['traits'] = traits traits_json['traits'] = traits
self._put_rp_traits(rp_uuid, traits_json) self._put_rp_traits(rp_uuid, traits_json)
def delete_trait_by_name(self, rp_uuid, trait_name): def delete_trait_by_name(self, context, rp_uuid, trait_name):
traits_json = self._get_rp_traits(rp_uuid) traits_json = self._get_rp_traits(rp_uuid)
traits = [ traits = [
trait for trait in traits_json['traits'] trait for trait in traits_json['traits']
if trait != trait_name if trait != trait_name
] ]
traits_json['traits'] = traits traits_json['traits'] = traits
self._put_rp_traits(rp_uuid, traits_json) self._put_rp_traits(rp_uuid, traits_json)
self._delete_trait(context, trait_name)
def delete_traits_with_prefixes(self, rp_uuid, trait_prefixes): def delete_traits_with_prefixes(self, context, rp_uuid, trait_prefixes):
traits_json = self._get_rp_traits(rp_uuid) traits_json = self._get_rp_traits(rp_uuid)
traits = [ traits = [
trait for trait in traits_json['traits'] trait for trait in traits_json['traits']
if not any(trait.startswith(prefix) if not any(trait.startswith(prefix)
for prefix in trait_prefixes)] for prefix in trait_prefixes)]
delete_traits = set(traits_json['traits']) - set(traits)
traits_json['traits'] = traits traits_json['traits'] = traits
self._put_rp_traits(rp_uuid, traits_json) self._put_rp_traits(rp_uuid, traits_json)
for trait in delete_traits:
self._delete_trait(context, trait)
def get_placement_request_id(self, response): def get_placement_request_id(self, response):
if response is not None: if response is not None:
return response.headers.get(request_id.HTTP_RESP_HEADER_REQUEST_ID) return response.headers.get(request_id.HTTP_RESP_HEADER_REQUEST_ID)
def update_inventory( def update_inventory(
self, resource_provider_uuid, inventories, self, resource_provider_uuid, inventories,
resource_provider_generation=None): resource_provider_generation=None):
if resource_provider_generation is None: if resource_provider_generation is None:
resource_provider_generation = self.get_resource_provider( resource_provider_generation = self.get_resource_provider(
skipping to change at line 311 skipping to change at line 315
'status_code': resp.status_code, 'status_code': resp.status_code,
'err_text': resp.text 'err_text': resp.text
} }
LOG.error(msg, args) LOG.error(msg, args)
# On conflict, the caller may wish to delete allocations and # On conflict, the caller may wish to delete allocations and
# redrive. (Note that this is not the same as a # redrive. (Note that this is not the same as a
# PlacementAPIConflict case.) # PlacementAPIConflict case.)
if resp.status_code == 409: if resp.status_code == 409:
raise exception.ResourceProviderInUse() raise exception.ResourceProviderInUse()
raise exception.ResourceProviderDeletionFailed(uuid=rp_uuid) raise exception.ResourceProviderDeletionFailed(uuid=rp_uuid)
def delete_rc_by_name(self, context, name):
"""Delete resource class from placement by name."""
resp = self.delete(
"/resouce_classes/%s" % name, global_request_id=context.global_id)
if not resp:
msg = ("Failed to delete resource class record with placement "
"API for resource class %(rc_name)s. Got "
"%(status_code)d: %(err_text)s.")
args = {
'rc_name': name,
'status_code': resp.status_code,
'err_text': resp.text,
}
LOG.error(msg, args)
elif resp.status_code == 204:
LOG.info("Successfully delete resource class %(rc_name).", {
"rc_name", name})
def _delete_trait(self, context, name):
"""Delete trait from placement by name."""
version = '1.6'
resp = self.delete("/traits/%s" % name, version=version,
global_request_id=context.global_id)
if not resp:
msg = ("Failed to delete trait record with placement "
"API for trait %(trait_name)s. Got "
"%(status_code)d: %(err_text)s.")
args = {
'trait_name': name,
'status_code': resp.status_code,
'err_text': resp.text,
}
LOG.error(msg, args)
elif resp.status_code == 204:
LOG.info("Successfully delete trait %(trait_name).", {
"trait_name", name})
 End of changes. 6 change blocks. 
2 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)