revert the created device datas

Closes-Bug: #1928077
Change-Id: I32b65f4053a90dfbdd6d491fc8e356cc148d53fb
This commit is contained in:
qiufossen 2021-05-12 02:07:19 -04:00 committed by Wenping Song
parent 5bd8d929a7
commit 516a7d7094
1 changed files with 8 additions and 1 deletions

View File

@ -149,7 +149,14 @@ class ConductorManager(object):
# device is added
for a in added:
new_driver_dev_obj = new_driver_device_list[new_cpid_list.index(a)]
new_driver_dev_obj.create(context, host)
try:
new_driver_dev_obj.create(context, host)
except Exception as exc:
LOG.exception("Failed to add device %(device)s. "
"Reason: %(reason)s",
{'device': new_driver_dev_obj,
'reason': exc})
new_driver_dev_obj.destroy(context, host)
# TODO(All): If report data to Placement raise exception, we
# should revert driver device created in Cyborg and rp created
# in Placement to reduce the risk of data inconsistency here