def error(self, snapshot, exc): """Handle an error during the snapshot process""" LOG.debug("Error encountered during snapshot processing: %s", exc) if snapshot and snapshot.exists(): snapshot.reload() if 'S' in snapshot.lv_attr: LOG.error("Snapshot space (%s) exceeded. " "Snapshot %s is no longer valid", snapshot.device_name(), format_bytes(int(snapshot.lv_size))) try: if snapshot.is_mounted(): snapshot.unmount() LOG.info("Unmounting snapshot %s on cleanup", snapshot.device_name()) except LVMCommandError as ex: LOG.error("Failed to unmount snapshot %s", ex) try: if snapshot.exists(): snapshot.remove() LOG.info("Removed snapshot %s on cleanup", snapshot.device_name()) except LVMCommandError as ex: LOG.error("Failed to remove snapshot %s", ex) return self.finish()
def error(self, snapshot, exc): """Handle an error during the snapshot process""" LOG.debug("Error encountered during snapshot processing: %s", exc) if snapshot and snapshot.exists(): snapshot.reload() if "S" in snapshot.lv_attr: LOG.error( "Snapshot space (%s) exceeded. " "Snapshot %s is no longer valid", snapshot.device_name(), format_bytes(int(snapshot.lv_size)), ) try: if snapshot.is_mounted(): snapshot.unmount() LOG.info("Unmounting snapshot %s on cleanup", snapshot.device_name()) except LVMCommandError as ex: LOG.error("Failed to unmount snapshot %s", ex) try: if snapshot.exists(): snapshot.remove() LOG.info("Removed snapshot %s on cleanup", snapshot.device_name()) except LVMCommandError as ex: LOG.error("Failed to remove snapshot %s", ex) return self.finish()
def test_format_bytes(self): """ format_bytes """ self.assertEqual(format_bytes(1024), "1.00KB") self.assertEqual(format_bytes(0), "0.00Bytes")