Пример #1
0
def update_fs_setup_devices(disk_setup, tformer):
    # update 'fs_setup' dictionary anywhere were a device may occur
    # update it with the response from 'tformer'
    for definition in disk_setup:
        if not isinstance(definition, dict):
            LOG.warn("entry in disk_setup not a dict: %s", definition)
            continue

        origname = definition.get('device')

        if origname is None:
            continue

        (dev, part) = util.expand_dotted_devname(origname)

        tformed = tformer(dev)
        if tformed is not None:
            dev = tformed
            LOG.debug("%s is mapped to disk=%s part=%s",
                      origname, tformed, part)
            definition['_origname'] = origname
            definition['device'] = tformed

        if part and 'partition' in definition:
            definition['_partition'] = definition['partition']
        definition['partition'] = part
Пример #2
0
def sanitize_devname(startname, transformer, log):
    log.debug("Attempting to determine the real name of %s", startname)

    # workaround, allow user to specify 'ephemeral'
    # rather than more ec2 correct 'ephemeral0'
    devname = startname
    if devname == "ephemeral":
        devname = "ephemeral0"
        log.debug("Adjusted mount option from ephemeral to ephemeral0")

    (blockdev, part) = util.expand_dotted_devname(devname)

    if is_mdname(blockdev):
        orig = blockdev
        blockdev = transformer(blockdev)
        if not blockdev:
            return None
        if not blockdev.startswith("/"):
            blockdev = "/dev/%s" % blockdev
        log.debug("Mapped metadata name %s to %s", orig, blockdev)
    else:
        if SHORTNAME.match(startname):
            blockdev = "/dev/%s" % blockdev

    return devnode_for_dev_part(blockdev, part)
Пример #3
0
def sanitize_devname(startname, transformer, log):
    log.debug("Attempting to determine the real name of %s", startname)

    # workaround, allow user to specify 'ephemeral'
    # rather than more ec2 correct 'ephemeral0'
    devname = startname
    if devname == "ephemeral":
        devname = "ephemeral0"
        log.debug("Adjusted mount option from ephemeral to ephemeral0")

    device_path, partition_number = util.expand_dotted_devname(devname)

    if is_meta_device_name(device_path):
        orig = device_path
        device_path = transformer(device_path)
        if not device_path:
            return None
        if not device_path.startswith("/"):
            device_path = "/dev/%s" % (device_path,)
        log.debug("Mapped metadata name %s to %s", orig, device_path)
    else:
        if DEVICE_NAME_RE.match(startname):
            device_path = "/dev/%s" % (device_path,)

    partition_path = None
    if partition_number is None:
        partition_path = _get_nth_partition_for_device(device_path, 1)
    else:
        partition_path = _get_nth_partition_for_device(device_path,
                                                       partition_number)
        if partition_path is None:
            return None

    if _is_block_device(device_path, partition_path):
        if partition_path is not None:
            return partition_path
        return device_path
    return None