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)
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)
def register_target(device_path, mount_point, backfstype): filesystem = FileSystem(backfstype, device_path) _mkdir_p_concurrent(mount_point) filesystem.mount(mount_point) filesystem.umount() return {'label': filesystem.label}
def register_target(device_path, mount_point, backfstype): """ Mount/unmount target so it registers with MGS """ filesystem = FileSystem(backfstype, device_path) _mkdir_p_concurrent(mount_point) filesystem.mount(mount_point) filesystem.umount() return {"label": filesystem.label}
# <primitive provider="chroma" type="Target"> in dom if not next( (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