def lustre_filesystem_mount_exists(mountpoint):
    return next(
        iter(
            [m for m in get_local_mounts() if m[2] == "lustre" and m[1] == mountpoint]
        ),
        None,
    )
示例#2
0
def target_running(uuid):
    # This is called by the Target RA from corosync
    from os import _exit

    try:
        info = _get_target_config(uuid)
    except (KeyError, TypeError) as err:
        # it can't possibly be running here if the config entry for
        # it doesn't even exist, or if the store doesn't even exist!
        console_log.warning("Exception getting target config: %s", err)
        _exit(1)

    filesystem = FileSystem(info["backfstype"], info["bdev"])

    for devices, mntpnt, _ in get_local_mounts():
        if (mntpnt == info["mntpt"]) and next(
            (True for device in devices
             if filesystem.devices_match(device, info["bdev"], uuid)),
                False,
        ):
            _exit(0)

    console_log.warning(
        "Did not find mount with matching mntpt and device for %s", uuid)
    _exit(1)
示例#3
0
 def _client_mounts(cls):
     from chroma_agent.device_plugins.block_devices import get_local_mounts
     spec = re.compile(r'@\w+:/\w+')
     # get_local_mounts() returns a list of tuples in which the third element
     # is the filesystem type.
     return [
         mount for mount in get_local_mounts()
         if mount[2] == 'lustre' and spec.search(mount[0])
     ]
示例#4
0
    def __init__(self, target_devices):
        # Working set: accumulate device paths for each (uuid, name).  This is
        # necessary because in multipathed environments we will see the same
        # lustre target on more than one block device.  The reason we use name
        # as well as UUID is that two logical targets can have the same UUID
        # when we see a combined MGS+MDT
        uuid_name_to_target = {}

        for device in sorted(target_devices, cmp=LocalTargets.comparator):
            block_device = BlockDevice(device["type"], device["path"])

            # If the target_device has no uuid then it doesn't have a filesystem and is of no use to use, but
            # for now let's fill it in an see what happens.
            if device["uuid"] is None:
                try:
                    device["uuid"] = block_device.uuid
                except AgentShell.CommandExecutionError:
                    pass

            # OK, so we really don't have a uuid for this, so we won't find a lustre filesystem on it.
            if device["uuid"] is None:
                daemon_log.info(
                    "Device %s had no UUID and so will not be examined for Lustre"
                    % device["path"])
                continue

            targets = block_device.targets(uuid_name_to_target, device,
                                           daemon_log)

            ndp = get_normalized_device_table()

            mounted = ndp.normalized_device_path(device["path"]) in set([
                ndp.normalized_device_path(path)
                for path, _, _ in get_local_mounts()
            ])

            for name in targets.names:
                daemon_log.info(
                    "Device %s contained name:%s and is %smounted" %
                    (device["path"], name, "" if mounted else "un"))

                try:
                    target_dict = uuid_name_to_target[(device["uuid"], name)]
                    target_dict["devices"].append(device)
                except KeyError:
                    target_dict = {
                        "name": name,
                        "uuid": device["uuid"],
                        "params": targets.params,
                        "device_paths": [device["path"]],
                        "mounted": mounted,
                        "type": device["type"],
                    }
                    uuid_name_to_target[(device["uuid"], name)] = target_dict

        self.targets = uuid_name_to_target.values()
示例#5
0
def target_running(uuid):
    from os import _exit
    try:
        info = _get_target_config(uuid)
    except (KeyError, TypeError) as e:
        # it can't possibly be running here if the config entry for
        # it doesn't even exist, or if the store doesn't even exist!
        console_log.warning("Exception getting target config: '%s'" % e)
        _exit(1)

    filesystem = FileSystem(info['backfstype'], info['bdev'])

    for device, mntpnt, fstype in get_local_mounts():
        if (mntpnt == info['mntpt']) and filesystem.devices_match(
                device, info['bdev'], uuid):
            _exit(0)

    console_log.warning(
        "Did not find mount with matching mntpt and device for %s" % uuid)
    _exit(1)
示例#6
0
 def get_patched_local_mounts(self, fixture):
     with patch(
             "chroma_agent.device_plugins.block_devices.scanner_cmd",
             return_value=fixture,
     ):
         return get_local_mounts()