Exemplo n.º 1
0
def test_dm_id(zero_dm_device):
    # Resolve the dm link and get dm name of the device.
    device_path = "{}{}".format(DMPATH_PREFIX, zero_dm_device)
    real_path = os.path.realpath(device_path)
    device_name = real_path.split("/")[-1]

    dm_id = devicemapper.getDmId(zero_dm_device)
    assert device_name == dm_id

    # Test also devicemapper.resolveDevName() as it returns device_name
    # directly.
    resolved_name = devicemapper.resolveDevName(device_name)
    assert device_name == resolved_name

    # Or returns dm_id().
    resolved_name = devicemapper.resolveDevName(zero_dm_device)
    assert device_name == resolved_name
Exemplo n.º 2
0
def _resize_if_needed(guid):
    name = devicemapper.getDmId(guid)
    slaves = [(slave, getDeviceSize(slave))
              for slave in devicemapper.getSlaves(name)]

    if len(slaves) == 0:
        log.warning("Map %r has no slaves" % guid)
        return False

    if len(set(size for slave, size in slaves)) != 1:
        raise Error("Map %r slaves size differ %s" % (guid, slaves))

    map_size = getDeviceSize(name)
    slave_size = slaves[0][1]
    if map_size == slave_size:
        return False

    log.info("Resizing map %r (map_size=%d, slave_size=%d)",
             guid, map_size, slave_size)
    supervdsm.getProxy().resizeMap(name)
    return True
Exemplo n.º 3
0
def _resize_if_needed(guid):
    name = devicemapper.getDmId(guid)
    slaves = [(slave, getDeviceSize(slave))
              for slave in devicemapper.getSlaves(name)]

    if len(slaves) == 0:
        log.warning("Map %r has no slaves" % guid)
        return False

    if len(set(size for slave, size in slaves)) != 1:
        raise Error("Map %r slaves size differ %s" % (guid, slaves))

    map_size = getDeviceSize(name)
    slave_size = slaves[0][1]
    if map_size == slave_size:
        return False

    log.info("Resizing map %r (map_size=%d, slave_size=%d)",
             guid, map_size, slave_size)
    supervdsm.getProxy().resizeMap(name)
    return True
Exemplo n.º 4
0
def _getpvblksize(pv):
    dev = devicemapper.getDmId(os.path.basename(pv))
    return multipath.getDeviceBlockSizes(dev)
Exemplo n.º 5
0
def test_is_dm_device(zero_dm_device):
    dm_id = devicemapper.getDmId(zero_dm_device)
    assert devicemapper.isDmDevice(dm_id)
Exemplo n.º 6
0
def test_is_block_device(zero_dm_device):
    dm_id = devicemapper.getDmId(zero_dm_device)
    assert devicemapper.isBlockDevice(dm_id)
Exemplo n.º 7
0
def test_is_virtual_device(zero_dm_device):
    dm_id = devicemapper.getDmId(zero_dm_device)
    assert devicemapper.isVirtualDevice(dm_id)
Exemplo n.º 8
0
def test_dev_name(zero_dm_device):
    dm_id = devicemapper.getDmId(zero_dm_device)
    device_name = devicemapper.getDevName(dm_id)
    assert zero_dm_device == device_name
Exemplo n.º 9
0
Arquivo: lvm.py Projeto: xin49/vdsm
def _getpvblksize(pv):
    dev = devicemapper.getDmId(os.path.basename(pv))
    return multipath.getDeviceBlockSizes(dev)