Пример #1
0
Файл: lvm.py Проект: xin49/vdsm
def getVGBlockSizes(vgUUID):
    pvs = listPVNames(vgUUID)
    if not pvs:
        raise se.VolumeGroupDoesNotExist("vg_uuid: %s" % vgUUID)
    # Returning the block size of the first pv is correct since we don't allow
    # devices with different block size to be on the same VG.
    return _getpvblksize(pvs[0])
Пример #2
0
 def getVG(self, vgName):
     if vgName not in self.vgmd:
         raise se.VolumeGroupDoesNotExist(vgName)
     vg_md = deepcopy(self.vgmd[vgName])
     vg_attr = real_lvm.VG_ATTR(**vg_md['attr'])
     vg_md['attr'] = vg_attr
     return real_lvm.VG(**vg_md)
Пример #3
0
def test_VolumeGroupDoesNotExist():
    # Require a VG name or UUID at initialization.
    # Empty constructor shall raise.
    with pytest.raises(ValueError):
        e = storage_exception.VolumeGroupDoesNotExist()

    # Expected error type is LVMCommandError.
    with pytest.raises(TypeError):
        e = storage_exception.VolumeGroupDoesNotExist("vg-name", error="error")

    # Correct initialization.
    fake_error = storage_exception.LVMCommandError(
        rc=5, cmd=["fake"], out=["fake output"], err=["fake error"])
    e = storage_exception.VolumeGroupDoesNotExist("vg-name", error=fake_error)
    assert e.error == fake_error
    # Check error format
    formatted = str(e)
    assert "vg_name=vg-name" in formatted
    assert "error=" in formatted
    assert "vg_uuid=" not in formatted
Пример #4
0
Файл: lvm.py Проект: xin49/vdsm
def getVGbyUUID(vgUUID):
    # cycle through all the VGs until the one with the given UUID found
    for vg in getAllVGs():
        try:
            if vg.uuid == vgUUID:
                return vg
        except AttributeError as e:
            # An unreloadable VG found but may be we are not looking for it.
            log.debug("%s" % e.message, exc_info=True)
            continue
    # If not cry loudly
    raise se.VolumeGroupDoesNotExist("vg_uuid: %s" % vgUUID)
Пример #5
0
Файл: lvm.py Проект: xin49/vdsm
def getVG(vgName):
    vg = _lvminfo.getVg(vgName)  # returns single VG namedtuple
    if not vg:
        raise se.VolumeGroupDoesNotExist(vgName)
    else:
        return vg
Пример #6
0
Файл: lvm.py Проект: xin49/vdsm
def checkVGBlockSizes(vgUUID, vgBlkSize=None):
    pvs = listPVNames(vgUUID)
    if not pvs:
        raise se.VolumeGroupDoesNotExist("vg_uuid: %s" % vgUUID)
    _checkpvsblksize(pvs, vgBlkSize)