Merge "Clear alarm after last device image deletion"
This commit is contained in:
commit
b70e6eeea9
|
@ -265,17 +265,19 @@ class DeviceImageController(rest.RestController):
|
||||||
device_image = objects.device_image.get_by_uuid(
|
device_image = objects.device_image.get_by_uuid(
|
||||||
pecan.request.context, deviceimage_uuid)
|
pecan.request.context, deviceimage_uuid)
|
||||||
|
|
||||||
# Check if the image has been written to any of the devices
|
# Check if the image has been written or is being written to any of the devices
|
||||||
if pecan.request.dbapi.device_image_state_get_all(
|
if pecan.request.dbapi.device_image_state_get_all(
|
||||||
image_id=device_image.id,
|
image_id=device_image.id,
|
||||||
status=dconstants.DEVICE_IMAGE_UPDATE_COMPLETED):
|
status=[dconstants.DEVICE_IMAGE_UPDATE_COMPLETED,
|
||||||
|
dconstants.DEVICE_IMAGE_UPDATE_IN_PROGRESS]):
|
||||||
raise wsme.exc.ClientSideError(_(
|
raise wsme.exc.ClientSideError(_(
|
||||||
"Delete failed: device image has already been written to devices"))
|
"Delete failed: device image is being written to or has "
|
||||||
|
"already been written to devices"))
|
||||||
|
|
||||||
|
pecan.request.dbapi.deviceimage_destroy(deviceimage_uuid)
|
||||||
filename = cutils.format_image_filename(device_image)
|
filename = cutils.format_image_filename(device_image)
|
||||||
pecan.request.rpcapi.delete_bitstream_file(pecan.request.context,
|
pecan.request.rpcapi.delete_bitstream_file(pecan.request.context,
|
||||||
filename)
|
filename)
|
||||||
pecan.request.dbapi.deviceimage_destroy(deviceimage_uuid)
|
|
||||||
|
|
||||||
@cutils.synchronized(LOCK_NAME)
|
@cutils.synchronized(LOCK_NAME)
|
||||||
@wsme_pecan.wsexpose(DeviceImage, types.uuid, wtypes.text, body=types.apidict)
|
@wsme_pecan.wsexpose(DeviceImage, types.uuid, wtypes.text, body=types.apidict)
|
||||||
|
|
|
@ -11727,6 +11727,13 @@ class ConductorManager(service.PeriodicService):
|
||||||
os.remove(image_file_path)
|
os.remove(image_file_path)
|
||||||
except OSError:
|
except OSError:
|
||||||
LOG.exception("Failed to delete bitstream file %s" % image_file_path)
|
LOG.exception("Failed to delete bitstream file %s" % image_file_path)
|
||||||
|
# If no device image is uploaded, clear the in-progress alarm.
|
||||||
|
images = self.dbapi.deviceimages_get_all()
|
||||||
|
if not images:
|
||||||
|
system_uuid = self.dbapi.isystem_get_one().uuid
|
||||||
|
entity_instance_id = "%s=%s" % (fm_constants.FM_ENTITY_TYPE_SYSTEM, system_uuid)
|
||||||
|
self.fm_api.clear_fault(fm_constants.FM_ALARM_ID_DEVICE_IMAGE_UPDATE_IN_PROGRESS,
|
||||||
|
entity_instance_id)
|
||||||
|
|
||||||
def apply_device_image(self, context, host_uuid):
|
def apply_device_image(self, context, host_uuid):
|
||||||
"""Apply device image"""
|
"""Apply device image"""
|
||||||
|
|
|
@ -8790,5 +8790,8 @@ class Connection(api.Connection):
|
||||||
if image_id:
|
if image_id:
|
||||||
query = query.filter_by(image_id=image_id)
|
query = query.filter_by(image_id=image_id)
|
||||||
if status:
|
if status:
|
||||||
|
if isinstance(status, list):
|
||||||
|
query = query.filter(models.DeviceImageState.status.in_(status))
|
||||||
|
else:
|
||||||
query = query.filter_by(status=status)
|
query = query.filter_by(status=status)
|
||||||
return query.all()
|
return query.all()
|
||||||
|
|
Loading…
Reference in New Issue