コード例 #1
0
 def decorated_function(path):
     try:
         return function(path)
     except processutils.ProcessExecutionError as e:
         if 'No such device or address' in e.stderr:
             raise exception.VolumeBDMPathNotFound(path=path)
         else:
             raise
コード例 #2
0
def get_volume_size(path):
    """Get logical volume size in bytes.

    :param path: logical volume path
    :raises: processutils.ProcessExecutionError if getting the volume size
             fails in some unexpected way.
    :raises: exception.VolumeBDMPathNotFound if the volume path does not exist.
    """
    try:
        out, _err = nova.privsep.fs.blockdev_size(path)
    except processutils.ProcessExecutionError:
        if not os.path.exists(path):
            raise exception.VolumeBDMPathNotFound(path=path)
        else:
            raise
    return int(out)
コード例 #3
0
ファイル: lvm.py プロジェクト: varunarya10/nova_test_latest
def get_volume_size(path):
    """Get logical volume size in bytes.

    :param path: logical volume path
    :raises: processutils.ProcessExecutionError if getting the volume size
             fails in some unexpected way.
    :raises: exception.VolumeBDMPathNotFound if the volume path does not exist.
    """
    try:
        out, _err = utils.execute('blockdev', '--getsize64', path,
                                  run_as_root=True)
    except processutils.ProcessExecutionError:
        if not utils.path_exists(path):
            raise exception.VolumeBDMPathNotFound(path=path)
        else:
            raise
    return int(out)
コード例 #4
0
 def get_volume_size(self, path):
     vol = self._find_vol_from_path(path)
     if vol is not None:
         return vol[2]
     raise exception.VolumeBDMPathNotFound(path=path)