Example #1
0
def unmount_target(uuid):
    # This is called by the Target RA from corosync

    # only unmount targets that are controlled by chroma:Target
    try:
        result = cibxpath("query", "//primitive")
    except OSError as err:
        if err.rc == errno.ENOENT:
            exit(-1)
        raise err

    dom = ET.fromstring(result.stdout)

    # Searches for <nvpair name="target" value=uuid> in
    # <primitive provider="chroma" type="Target"> in dom
    if (next(
        (ops for res in dom.findall(".//primitive")
         if res.get("provider") == "chroma" and res.get("type") == "Target"
         for ops in res.findall(".//nvpair")
         if ops.get("name") == "target" and ops.get("value") == uuid),
            None,
    ) is not None):
        return
    dom.unlink()

    info = _get_target_config(uuid)

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

    filesystem.umount()

    if agent_result_is_error(export_target(info["device_type"], info["bdev"])):
        exit(-1)
Example #2
0
def unmount_target(uuid):
    # This is called by the Target RA from corosync
    info = _get_target_config(uuid)

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

    filesystem.umount()

    if agent_result_is_error(export_target(info['device_type'], info['bdev'])):
        exit(-1)
Example #3
0
def mount_target(uuid, pacemaker_ha_operation):
    # This is called by the Target RA from corosync
    info = _get_target_config(uuid)

    if agent_result_is_error(
            import_target(info['device_type'], info['bdev'],
                          pacemaker_ha_operation)):
        exit(-1)

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

    filesystem.mount(info['mntpt'])
Example #4
0
        (ops
         for res in dom.getElementsByTagName('primitive') if res.getAttribute(
             "provider") == "chroma" and res.getAttribute("type") == "Target"
         for ops in res.getElementsByTagName('nvpair')
         if ops.getAttribute("name") == "target"
         and ops.getAttribute("value") == uuid), False):
        return
    dom.unlink()

    info = _get_target_config(uuid)

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

    filesystem.umount()

    if agent_result_is_error(export_target(info['device_type'], info['bdev'])):
        exit(-1)


def import_target(device_type, path, pacemaker_ha_operation):
    """
    Passed a device type and a path import the device if such an operation make sense.
    For example a jbod scsi disk does not have the concept of import whilst zfs does.
    :param device_type: the type of device to import
    :param path: path of device to import
    :param pacemaker_ha_operation: This import is at the request of pacemaker. In HA operations the
    device may often have not have been cleanly exported because the previous mounted node failed
    in operation.
    :return: None or an Error message

    """