Mini Shell
3
{)c�Q � @ s d dl Z d dlZd dlmZmZ d dlZddlmZ ddlmZ ddl m
Z
ddlmZmZ d dl
Z
e
jdd � d d
lmZ d dlZejd�Zdd
� ZdZdZdZdd� Zdd� Zdd� ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd � d �Z e � Z!dS )!� N)�ABC�abstractmethod� )�udev)�util)�_)� stringize�
unicodeize�BlockDevz2.0)r
Zblivetc C s2 t | d�}tjd|| � |jd| � |j� d S )N�wzecho %s > %sz%s
)�open�log�debug�write�close)�fn�value�f� r �/usr/lib/python3.6/zfcp.py�logged_write_line_to_file( s
r z/sys/bus/ccw/drivers/zfcpz/sys/bus/scsi/devicesz/etc/zfcp.confc C s t jdd�} | dkS )z?Return True if automatic LUN scanning is enabled by the kernel.�zfcp�allow_lun_scan�Y)r Zget_kernel_module_parameter)r r r r �_is_lun_scan_allowed4 s r c C s� d}dj | �}tj|�}y>x8|D ]0}t|��}|j� }W dQ R X tjd|�r d}q W W n8 tk
r� } ztjd| t |�� d}W Y dd}~X nX |S )z�Return True if the device ID is configured in NPIV mode. See
https://www.ibm.com/docs/en/linux-on-systems?topic=devices-use-npiv
Fz5/sys/bus/ccw/devices/{}/host*/fc_host/host*/port_typeNz(^|\s)NPIV(\s|$)Tz:Couldn't read the port_type attribute of the %s device: %s)
�format�globr �read�re�search�OSErrorr
�warning�str)� device_idZport_in_npiv_modeZport_type_pathZport_type_paths�filenamer Z port_type�er r r �_is_port_in_npiv_mode; s
r&