def delete_volume(self, volume): """Deletes a logical volume.""" stdout, _ = self._execute('rbd', 'snap', 'ls', '--pool', FLAGS.rbd_pool, volume['name']) if stdout.count('\n') > 1: raise exception.VolumeIsBusy(volume_name=volume['name']) self._try_execute('rbd', 'rm', '--pool', FLAGS.rbd_pool, volume['name'])
def delete_volume(self, volume): """Deletes a logical volume.""" if self._volume_not_present(volume['name']): # If the volume isn't present, then don't attempt to delete return True # TODO(yamahata): lvm can't delete origin volume only without # deleting derived snapshots. Can we do something fancy? out, err = self._execute( 'sudo', 'lvdisplay', '--noheading', '-C', '-o', 'Attr', '%s/%s' % (FLAGS.volume_group, volume['name'])) # fake_execute returns None resulting unit test error if out: out = out.strip() if (out[0] == 'o') or (out[0] == 'O'): raise exception.VolumeIsBusy(volume_name=volume['name']) self._delete_volume(volume, volume['size'])