"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cyborg/conductor/manager.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).

manager.py  (openstack-cyborg-6.0.0):manager.py  (openstack-cyborg-7.0.0)
skipping to change at line 151 skipping to change at line 151
# device is deleted. # device is deleted.
for d in deleted: for d in deleted:
old_driver_dev_obj = old_driver_device_list[old_cpid_list.index(d)] old_driver_dev_obj = old_driver_device_list[old_cpid_list.index(d)]
for driver_dep_obj in old_driver_dev_obj.deployable_list: for driver_dep_obj in old_driver_dev_obj.deployable_list:
rp_uuid = self.get_rp_uuid_from_obj(driver_dep_obj) rp_uuid = self.get_rp_uuid_from_obj(driver_dep_obj)
self._delete_provider_and_sub_providers(context, rp_uuid) self._delete_provider_and_sub_providers(context, rp_uuid)
old_driver_dev_obj.destroy(context, host) old_driver_dev_obj.destroy(context, host)
# device is added # device is added
for a in added: for a in added:
new_driver_dev_obj = new_driver_device_list[new_cpid_list.index(a)] new_driver_dev_obj = new_driver_device_list[new_cpid_list.index(a)]
new_driver_dev_obj.create(context, host) try:
# TODO(All): If report data to Placement raise exception, we new_driver_dev_obj.create(context, host)
# should revert driver device created in Cyborg and rp created except Exception as exc:
# in Placement to reduce the risk of data inconsistency here LOG.exception("Failed to add device %(device)s. "
# between Cyborg and Placement, we will consider to fix in V "Reason: %(reason)s",
# release. {'device': new_driver_dev_obj,
'reason': exc})
new_driver_dev_obj.destroy(context, host)
# TODO(All): If report device data to Placement raise exception,
# we should revert driver device created in Cyborg and resources
# created in Placement to reduce the risk of data inconsistency
# here between Cyborg and Placement.
cleanup_inconsistency_resources = False cleanup_inconsistency_resources = False
for driver_dep_obj in new_driver_dev_obj.deployable_list: for driver_dep_obj in new_driver_dev_obj.deployable_list:
try: try:
self.get_placement_needed_info_and_report(context, self.get_placement_needed_info_and_report(context,
driver_dep_obj, driver_dep_obj,
host_rp) host_rp)
except Exception as exc: except Exception as exc:
LOG.info("Failed to add device %(device)s. " LOG.info("Failed to add device %(device)s. "
"Reason: %(reason)s", "Reason: %(reason)s",
{'device': new_driver_dev_obj, {'device': new_driver_dev_obj,
skipping to change at line 240 skipping to change at line 246
self.get_placement_needed_info_and_report(context, self.get_placement_needed_info_and_report(context,
new_driver_dep_obj, new_driver_dep_obj,
host_rp) host_rp)
except Exception as exc: except Exception as exc:
LOG.info("Failed to add deployable %(deployable)s. " LOG.info("Failed to add deployable %(deployable)s. "
"Reason: %(reason)s", "Reason: %(reason)s",
{'deployable': new_driver_dep_obj, {'deployable': new_driver_dep_obj,
'reason': exc}) 'reason': exc})
new_driver_dep_obj.destroy(context, device_id) new_driver_dep_obj.destroy(context, device_id)
rp_uuid = self.get_rp_uuid_from_obj(new_driver_dep_obj) rp_uuid = self.get_rp_uuid_from_obj(new_driver_dep_obj)
# TODO(All): If report data to Placement raise exception, we # TODO(All): If report deployable data to Placement raise
# should revert driver deployable created in Cyborg and # exception, we should revert driver deployable created in
# rp created in Placement to reduce the risk of data # Cyborg and resources created in Placement to reduce the risk
# inconsistency here between Cyborg and Placement, # of data inconsistency here between Cyborg and Placement.
# we will consider to fix in V release.
self._delete_provider_and_sub_providers(context, rp_uuid) self._delete_provider_and_sub_providers(context, rp_uuid)
for s in same: for s in same:
# get the driver_dep_obj, diff the driver_dep layer # get the driver_dep_obj, diff the driver_dep layer
new_driver_dep_obj = new_driver_dep_list[new_name_list.index(s)] new_driver_dep_obj = new_driver_dep_list[new_name_list.index(s)]
old_driver_dep_obj = old_driver_dep_list[old_name_list.index(s)] old_driver_dep_obj = old_driver_dep_list[old_name_list.index(s)]
# get dep_obj, it won't be None because it stored before. # get dep_obj, it won't be None because it stored before.
dep_obj = Deployable.get_by_name_deviceid(context, s, device_id) dep_obj = Deployable.get_by_name_deviceid(context, s, device_id)
# update the driver_dep num_accelerators field # update the driver_dep num_accelerators field
if dep_obj.num_accelerators != new_driver_dep_obj.num_accelerators: if dep_obj.num_accelerators != new_driver_dep_obj.num_accelerators:
dep_obj.num_accelerators = new_driver_dep_obj.num_accelerators dep_obj.num_accelerators = new_driver_dep_obj.num_accelerators
skipping to change at line 276 skipping to change at line 281
self.drv_attr_make_diff(context, dep_obj.id, self.drv_attr_make_diff(context, dep_obj.id,
old_driver_dep_obj.attribute_list, old_driver_dep_obj.attribute_list,
new_attribute_list) new_attribute_list)
# diff the internal layer: driver_attach_hanle_list # diff the internal layer: driver_attach_hanle_list
self.drv_ah_make_diff(context, dep_obj.id, cpid_id, self.drv_ah_make_diff(context, dep_obj.id, cpid_id,
old_driver_dep_obj.attach_handle_list, old_driver_dep_obj.attach_handle_list,
new_driver_dep_obj.attach_handle_list) new_driver_dep_obj.attach_handle_list)
def drv_attr_make_diff(self, context, dep_id, old_driver_attr_list, def drv_attr_make_diff(self, context, dep_id, old_driver_attr_list,
new_driver_attr_list): new_driver_attr_list):
"""Diff new dirver-side Attribute Object lists with the old one.""" """Diff new driver-side Attribute Object lists with the old one."""
LOG.info("Start differing attributes.") LOG.info("Start differing attributes.")
dep_obj = Deployable.get_by_id(context, dep_id) dep_obj = Deployable.get_by_id(context, dep_id)
driver_dep = DriverDeployable.get_by_name(context, dep_obj.name) driver_dep = DriverDeployable.get_by_name(context, dep_obj.name)
rp_uuid = self.get_rp_uuid_from_obj(driver_dep) rp_uuid = self.get_rp_uuid_from_obj(driver_dep)
new_key_list = [driver_attr_obj.key for driver_attr_obj in new_key_list = [driver_attr_obj.key for driver_attr_obj in
new_driver_attr_list] new_driver_attr_list]
old_key_list = [driver_attr_obj.key for driver_attr_obj in old_key_list = [driver_attr_obj.key for driver_attr_obj in
old_driver_attr_list] old_driver_attr_list]
same = set(new_key_list) & set(old_key_list) same = set(new_key_list) & set(old_key_list)
# key is same, diff the value.
# key is deleted. # key is deleted.
deleted = set(old_key_list) - same deleted = set(old_key_list) - same
for d in deleted: for d in deleted:
old_driver_attr_obj = old_driver_attr_list[old_key_list.index(d)] old_driver_attr_obj = old_driver_attr_list[old_key_list.index(d)]
self.placement_client.delete_trait_by_name( self.placement_client.delete_trait_by_name(
rp_uuid, old_driver_attr_obj.value) context, rp_uuid, old_driver_attr_obj.value)
old_driver_attr_obj.delete_by_key(context, dep_id, d) old_driver_attr_obj.delete_by_key(context, dep_id, d)
# key is added. # key is added.
added = set(new_key_list) - same added = set(new_key_list) - same
for a in added: for a in added:
new_driver_attr_obj = new_driver_attr_list[new_key_list.index(a)] new_driver_attr_obj = new_driver_attr_list[new_key_list.index(a)]
new_driver_attr_obj.create(context, dep_id) new_driver_attr_obj.create(context, dep_id)
self.placement_client.add_traits_to_rp( self.placement_client.add_traits_to_rp(
rp_uuid, [new_driver_attr_obj.value]) rp_uuid, [new_driver_attr_obj.value])
# key is same, diff the value.
for s in same: for s in same:
# value is not same, update # value is not same, update
new_driver_attr_obj = new_driver_attr_list[new_key_list.index(s)] new_driver_attr_obj = new_driver_attr_list[new_key_list.index(s)]
old_driver_attr_obj = old_driver_attr_list[old_key_list.index(s)] old_driver_attr_obj = old_driver_attr_list[old_key_list.index(s)]
if new_driver_attr_obj.value != old_driver_attr_obj.value: if new_driver_attr_obj.value != old_driver_attr_obj.value:
attr_obj = Attribute.get_by_dep_key(context, dep_id, s) attr_obj = Attribute.get_by_dep_key(context, dep_id, s)
attr_obj.value = new_driver_attr_obj.value attr_obj.value = new_driver_attr_obj.value
attr_obj.save(context) attr_obj.save(context)
# Update traits here. # Update traits here.
if new_driver_attr_obj.key.startswith("trait"): if new_driver_attr_obj.key.startswith("trait"):
self.placement_client.delete_trait_by_name( self.placement_client.delete_trait_by_name(
rp_uuid, old_driver_attr_obj.value) context, rp_uuid, old_driver_attr_obj.value)
self.placement_client.add_traits_to_rp( self.placement_client.add_traits_to_rp(
rp_uuid, [new_driver_attr_obj.value]) rp_uuid, [new_driver_attr_obj.value])
# Update resource classes here.
if new_driver_attr_obj.key.startswith("rc"):
self.placement_client.ensure_resource_classes(
context, [new_driver_attr_obj.value])
inv_data = _gen_resource_inventory(
new_driver_attr_obj.value, dep_obj.num_accelerators)
self.placement_client.update_inventory(rp_uuid, inv_data)
self.placement_client.delete_rc_by_name(
context, old_driver_attr_obj.value)
@classmethod @classmethod
def drv_ah_make_diff(cls, context, dep_id, cpid_id, old_driver_ah_list, def drv_ah_make_diff(cls, context, dep_id, cpid_id, old_driver_ah_list,
new_driver_ah_list): new_driver_ah_list):
"""Diff new dirver-side AttachHandle Object lists with the old one.""" """Diff new driver-side AttachHandle Object lists with the old one."""
LOG.info("Start differing attach_handles.") LOG.info("Start differing attach_handles.")
new_info_list = [driver_ah_obj.attach_info for driver_ah_obj in new_info_list = [driver_ah_obj.attach_info for driver_ah_obj in
new_driver_ah_list] new_driver_ah_list]
old_info_list = [driver_ah_obj.attach_info for driver_ah_obj in old_info_list = [driver_ah_obj.attach_info for driver_ah_obj in
old_driver_ah_list] old_driver_ah_list]
same = set(new_info_list) & set(old_info_list) same = set(new_info_list) & set(old_info_list)
LOG.info('new info list %s', new_info_list) LOG.info('new info list %s', new_info_list)
LOG.info('old info list %s', old_info_list) LOG.info('old info list %s', old_info_list)
# attach_info is deleted. # attach_info is deleted.
deleted = set(old_info_list) - same deleted = set(old_info_list) - same
 End of changes. 9 change blocks. 
16 lines changed or deleted 30 lines changed or added

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