ext_arq.py (openstack-cyborg-8.0.0) | : | ext_arq.py (openstack-cyborg-9.0.0) | ||
---|---|---|---|---|
skipping to change at line 223 | skipping to change at line 223 | |||
self.attach_handle_id = ah.id | self.attach_handle_id = ah.id | |||
except Exception as e: | except Exception as e: | |||
LOG.error("Failed to allocate attach handle for ARQ %s" | LOG.error("Failed to allocate attach handle for ARQ %s" | |||
"from deployable %s. Reason: %s", | "from deployable %s. Reason: %s", | |||
self.arq.uuid, deployable.uuid, str(e)) | self.arq.uuid, deployable.uuid, str(e)) | |||
# TODO(Shaohe) Rollback? We have _update_placement, | # TODO(Shaohe) Rollback? We have _update_placement, | |||
# should cancel it. | # should cancel it. | |||
self.update_check_state( | self.update_check_state( | |||
context, constants.ARQ_BIND_FAILED) | context, constants.ARQ_BIND_FAILED) | |||
raise | raise | |||
LOG.info('Attach handle(%s) for ARQ(%s) successfully.', | LOG.info('Attach handle(%s) allocate for ARQ(%s) successfully.', | |||
ah.uuid, self.arq.uuid) | ah.uuid, self.arq.uuid) | |||
def bind(self, context, deployable): | def bind(self, context, deployable): | |||
self._allocate_attach_handle(context, deployable) | self._allocate_attach_handle(context, deployable) | |||
self.deployable_id = deployable.id | self.deployable_id = deployable.id | |||
self.save(context) | self.save(context) | |||
# ARQ state changes get committed here | # ARQ state changes get committed here | |||
self.update_check_state(context, constants.ARQ_BOUND) | self.update_check_state(context, constants.ARQ_BOUND) | |||
LOG.info('Update ARQ %s state to "Bound" successfully.', | LOG.info('Update ARQ %s state to "Bound" successfully.', | |||
self.arq.uuid) | self.arq.uuid) | |||
# TODO(Shaohe) rollback self._unbind and self._delete | # TODO(Shaohe) rollback self._unbind and self._delete | |||
# if (self.arq.state == constants.ARQ_DELETING | # if (self.arq.state == constants.ARQ_DELETING | |||
# or self.arq.state == ARQ_UNBOUND): | # or self.arq.state == ARQ_UNBOUND): | |||
def _deallocate_attach_handle(self, context, ah_id): | ||||
try: | ||||
attach_handle = AttachHandle.get_by_id(context, ah_id) | ||||
attach_handle.deallocate(context) | ||||
except Exception as e: | ||||
LOG.error("Failed to deallocate attach handle %s for ARQ %s." | ||||
"Reason: %s", ah_id, self.arq.uuid, str(e)) | ||||
self.update_check_state( | ||||
context, constants.ARQ_UNBIND_FAILED) | ||||
raise | ||||
LOG.info('Attach handle(%s) deallocate for ARQ(%s) successfully.', | ||||
ah_id, self.arq.uuid) | ||||
def unbind(self, context): | def unbind(self, context): | |||
arq = self.arq | arq = self.arq | |||
arq.hostname = None | arq.hostname = None | |||
arq.device_rp_uuid = None | arq.device_rp_uuid = None | |||
arq.instance_uuid = None | arq.instance_uuid = None | |||
arq.state = constants.ARQ_UNBOUND | arq.state = constants.ARQ_UNBOUND | |||
# Unbind: mark attach handles as freed | # Unbind: mark attach handles as freed | |||
ah_id = self.attach_handle_id | ah_id = self.attach_handle_id | |||
if ah_id: | if ah_id: | |||
attach_handle = AttachHandle.get_by_id(context, ah_id) | self._deallocate_attach_handle(context, ah_id) | |||
attach_handle.deallocate(context) | ||||
self.attach_handle_id = None | self.attach_handle_id = None | |||
self.deployable_id = None | self.deployable_id = None | |||
self.save(context) | self.save(context) | |||
@classmethod | @classmethod | |||
def _fill_obj_extarq_fields(cls, context, db_extarq): | def _fill_obj_extarq_fields(cls, context, db_extarq): | |||
"""ExtARQ object has some fields that are not present | """ExtARQ object has some fields that are not present | |||
in db_extarq. We fill them out here. | in db_extarq. We fill them out here. | |||
""" | """ | |||
# From the 2 fields in the ExtARQ, we obtain other fields. | # From the 2 fields in the ExtARQ, we obtain other fields. | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 15 lines changed or added |