def cleanup_tmp_vol(self, tmp_vol, convert_dir, scrub_callback): if not tmp_vol: raise ValueError("No tmp_vol") if not os.path.exists(tmp_vol['path']): raise ValueError("tmp_vol doesn't exist") if convert_dir: execute('umount', convert_dir) rmtree(convert_dir) spawn(NullResource(), self.remove_lvm_volume, tmp_vol, callback=scrub_callback, skip_fork=self.skip_fork)
def delete(self, id=None, scrub=None): """ Remove a volume on disk """ helper = self.load_conf(self.config) if scrub: # delete will scrub the volume before deletion lock = NullResource() helper.volumes.delete(id, lock=lock) else: volume = helper.volumes.get(id) # remove the volume without scrubing helper.volumes.remove(volume['path']) print "deleted '%s'" % id
raise InvalidImage("Error fetching image: %s" % image_id) # Create a tag to apply to the lvm volume tag = encode_tag(backup_source_volume_id=backup_source_volume_id, backup_id=backup_id) try: self._do_create(volume_id, size_str, tag, backup_source_volume_id) except Exception, e: # If we ran out of space due to the tmp_vol logger.error('Failed to create volume: %s' % e) # Update cinder immediately. if callback: callback() if tmp_vol: spawn(NullResource(), self.remove_lvm_volume, tmp_vol, callback=scrub_callback, skip_fork=self.skip_fork) raise def log_duration(): duration = time() - op_start parts = ['STAT: Create Volume'] if volume_id: parts.append('Volume_ID: %s' % (volume_id, )) if backup_id: parts.append('Backup_ID: %s' % (backup_id, )) if backup_source_volume_id:
raise InvalidImage("Error fetching image: %s" % image_id) # Create a tag to apply to the lvm volume tag = encode_tag(backup_source_volume_id=backup_source_volume_id, backup_id=backup_id) try: self._do_create(volume_id, size_str, tag, backup_source_volume_id) except Exception, e: # If we ran out of space due to the tmp_vol logger.error('Failed to create volume: %s' % e) # Update cinder immediately. if callback: callback() if tmp_vol: spawn(NullResource(), self.remove_lvm_volume, tmp_vol, callback=scrub_callback, skip_fork=self.skip_fork) raise def log_duration(): duration = time() - op_start parts = ['STAT: Create Volume'] if volume_id: parts.append('Volume_ID: %s' % (volume_id,)) if backup_id: parts.append('Backup_ID: %s' % (backup_id,)) if backup_source_volume_id: parts.append('Backup_Source_Volume_ID: %s' % (backup_id,)) if image_id: parts.append('Image_ID: %s' % (image_id,))