Sindbad~EG File Manager

Current Path : /lib64/python3.6/site-packages/lsm/lsmcli/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/lsm/lsmcli/__pycache__/cmdline.cpython-36.opt-1.pyc

3

�.'e��?@sFddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddlm
Z
ddlZddlm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)dddd	d
gZ*ej+r�e,Z-yddl.m/Z/Wn"e0k
�r&ddl1m/Z/YnXda2�dhdd
�Z3dd�Z4dd�Z5dd�Z6dd�Z7dZ8dd�Z9dd�Z:dd�Z;dd�Z<�did d!�Z=d"d#�Z>d$d%�Z?Gd&d'�d'e@�ZA�djd*d+�ZBd,d-�ZCd.d/d0d1d2d3d4d5d6d7d8d9gZD�dkZEd=d>jFeE�ZG�dlZHdCd>jFeH�ZIdDdEgZJdFd>jFeJ�ZKeLdGdHeKeJe9dI�ZMdJdKdLgZNdMd>jFeN�dNdOZOeLdGdHeOeNe9dI�ZPdPZQeLdQdRdSdT�ZReRjS�ZTdUeTdV<eLdWdXdYdT�ZUeUjS�ZVdZeVdV<eLd[d\d]dT�ZWeWjS�ZXd^eXdV<eLd_d`dadT�ZYeYjS�ZZdbeZdV<eLdcdddedT�Z[e[jS�Z\dfe\dV<eLdgdhdie6dj�Z]eLdkdldmdT�Z^eLdndodpdT�Z_eLdqdrdsdT�Z`eLdtdudvdT�ZaeLdwdxeQdT�ZbeLdydzd{dT�ZceLd|d}d~d�ZdeLd�d�eLd�d�d�jFeD�d�d�eDe9d��geLeT�eLeV�eLeX�eLea�eLe\�eLeZ�eLe`�eLec�gd��eLd�d�eLd�d�d�dT�gd��eLd�d�eLeR�gd��eLd�d�d��eLd�d�eLd�d�d�d�eLeb�eLeU�geLd�eGd:eEe9d��gd��eLd�d�eLd�d�d�d�eLdtd�d�d�d��eLd�d�d�jFe%je�e%jee9d��geLd�d�eQd��gd��eLd�d�eLeR�gd��eLd�d�eLeW�gd��eLd�d�eLeW�eLdwd�d�eQdT�gd��eLd�d�eLeW�eLd�d�d�dT�eLd�d�eIeHd��geLdWd�d��gd��eLd�d�eLd�d�d�dT�eLd�d�d�dT�eLd�d�d�d?d@gd��eLd�d�d�d�e7dÍeLd�d�d�d�e7dÍeLd�d�d�d�e7dÍgd��eLd�d�eLeR�gd��eLd�d�eLeW�gd��eLd�d�eLeW�gd��eLd�d�eLeW�gd��eLd�d�eLeW�eLe[�gd��eLd�d�eLe[�eLeW�gd��eLd�d�eLeW�gd��eLd�d�eLeW�gd��eLd�d�eLeW�gd��eLd�d�eLd[d\d�dT�gd��eLd�d�eLd[d\d�dT�gd��eLd�d�eLdQdRd�dT�eLd�d�e7d�gd��eLd�d�eLeU�gd��eLd�d�eLd�d�d�dT�eLe]�eLeR�gd��eLd�d�eLe[�eLe]�gd��eLd�d�eLe[�eLe]�gd��eLd�d�eLe[�gd��eLd�d�eLe[�gd��eLd�d�eLe]�geLd�d�d�dT�eLd�d�d�dT�eLd�d�d�dT�eL�d�d�ddT�gd��eL�d�deLd��d�ddT�eLeb�eLeU�gd��eL�d�deLeY�gd��eL�d	�d
eLeY�eLdwd�d�eQdT�gd��eL�d�deLeY�geL�d
�d�ddT�eL�d�d�dejfe7�d�eL�d�d�dejfe7�d�eL�d�d�ddT�eL�d�d�dd�geC�d�eL�d�d�d d�geC�d�eL�d!�d"�d#d�geC�d�gd��eL�d$�d%eLe_�gd��eL�d&�d'eL�d(�d)�d*dT�eL�d+�d,�d-dT�geL�d.�d/�d0dT�gd��eL�d1�d2eLd��d3�d4dT�eLeY�gd��eL�d5�d6eLe^�eLeY�gd��eL�d7�d8eLe^�eLeY�geL�d9�d:�d;d�g�d<�eL�d=�d>�d?d�g�d<�gd��eL�d@�dAeLeY�geL�d9�d:d�g�dB�dC�gd��eL�dD�dEeLeY�geL�d9d�g�dF�dG�gd��eL�dH�dIeLeY�eL�dJ�dK�dLdT�eL�dM�dN�dOdT�geL�d.�d0d��gd��eLd�dPggd��eL�dQ�dReLeW�gd��eL�dS�dTeLeW�eLeM�gd��eL�dU�dVeLeW�eLeM�gd��eL�dW�dXeLeW�eLeP�gd��eLd�dYeLed�gd��eLd�dZeLed�gd��eLd	�d[eLed�gd��eLd
�d\eLed�gd��f3ZgeL�d]�d^�d_�d`�da�db�dcd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�dd�dQ�dS�dU�dWddd	d
�de�%ZhG�df�dg��dgei�ZjdS(m�N)�ArgumentParser�ArgumentTypeError)�RawTextHelpFormatter)�Client�Pool�VERSION�LsmError�Disk�Volume�	JobStatus�ErrorNumber�
BlockRange�	uri_parse�Proxy�size_human_2_size_bytes�AccessGroup�
FileSystem�	NfsExport�
TargetPort�	LocalDisk�Battery)
�DisplayData�PlugData�out�vol_provision_str_to_type�vol_rep_type_str_to_type�VolumeRAIDInfo�PoolRAIDInfo�VcrCap�
LocalDiskInfo�VolumeRAMCacheInfozlocal-disk-listzlocal-disk-ident-led-onzlocal-disk-ident-led-offzlocal-disk-fault-led-onzlocal-disk-fault-led-off)�OrderedDictc CsVd}d}�zyt�}|j|�Wn�tk
r`}z$tjjt|��tjj�d}WYdd}~Xn�tk
r�}z:tjjt|�d�tjj�|j	t
jkr�d}nd}WYdd}~Xnbtk
r�d}YnLt
k
r�}z|j	}WYdd}~Xn&ddl}|jtjd�d}YnXWd|�rFy|j|�Wntk
�rDYnXtj|�XdS)	z+
    Common command line code, called.
    rN��
�
��)�file)�CmdLine�process�ArgError�sys�stderr�write�str�flushr�coderZPERMISSION_DENIED�KeyboardInterrupt�
SystemExit�	traceback�	print_exc�stdout�shutdown�	Exception�exit)�cZerr_exit�cliZae�leZser3�r<�/usr/lib64/python3.6/cmdline.py�cmd_line_wrapper?s:

r>c
CsLtjj�}tj|�}z tjtjj��tjjd�}Wdtj|tj	|�X|S)Nr&)
r+�stdin�fileno�termiosZ	tcgetattr�ttyZsetraw�readZ	tcsetattrZ	TCSADRAIN)�fd�prevZchr<r<r=�getchls

rFcCs,tj|�\}}}|r||fStd|��dS)z�
    If init_id is a WWPN, convert it into LSM standard version:
        (?:[0-9a-f]{2}:){7}[0-9a-f]{2}

    Return (converted_init_id, lsm_init_type)
    z,--init "%s" is not a valid WWPN or iSCSI IQNN)r�initiator_id_verifyr*)�init_id�validZconverted_init_type�converted_init_idr<r<r=�parse_convert_initwsrKcCs(tj|�\}}}|r|Std|��dS)z�
    Call back from validating an initiator
    :param init_id: Initiator to validate
    :return: Value of initiator or raises an exception
    z!"%s" is invalid WWPN or iSCSI IQNN)rrGr)rHrI�_rJr<r<r=�_check_init�srMcCsHy"t|d�}|dkr td|��|Stk
rBtd|��YnXdS)z�
    Call back for validating a positive integer
    :param num: Number string to check
    :return: Numeric value, else exception
    �
rz,invalid: require positive integer value '%d'z*invalid: not a positive integer value '%s'N)�longr�
ValueError)Znum�rcr<r<r=�_check_positive_integer�s

rRZchild_cCs|j�S)N)�upper)�sr<r<r=�_upper�srUcCs�|sdS|jd�}t|�dkr"dSd|kr.dSxt|D]l}dt|�koNdknsXdSt|�dkrt|ddkrtdSyt|d	�d
kr�dSWq4tk
r�dSXq4WdS)z�
    Check if a string represents a valid ip4 address
    :param address: String representing address
    :return: True if valid address, else false
    F�.r%�/r�r&�0rN�T)�split�len�intrP)�address�parts�ir<r<r=�_valid_ip4_address�s$


racs�d�d}|sdSd|krdSt|jd��dkr2dS|jd�}t|�dksTt|�dkrXdSd	|dkr�t|j��s|td�dS|jddg�d|kr�d
d�|D�}|jd�d}|r�t|�dks�t|�dkr�tdd�|D��o�t�fdd�dj|�D��SdS)z�
    Check if a string represents a valid ipv6 address
    :param address: String representing address
    :return: True if valid address, else false
    zABCDEFabcdef0123456789:FrWz::r"�:rX�	rVr&zNot valid ipv suffixrYcSsg|]}|dkr|�qS)�r<)�.0�pr<r<r=�
<listcomp>�sz&_valid_ip6_address.<locals>.<listcomp>T�css|]}t|�dkVqdS)r%N)r\)re�xr<r<r=�	<genexpr>�sz%_valid_ip6_address.<locals>.<genexpr>c3s|]}|�kVqdS)Nr<)reri)�allowedr<r=rj�srd���)	r\r[ra�pop�print�extend�append�all�join)r^Z	has_zerosr_r<)rkr=�_valid_ip6_address�s0

rscs�tjdtj��tjd�}t|�r$dSt|�r0dSt|�dkr@dS|j|�rNdS|ddkrf|dd�}t�fd	d
�|jd�D��S)
z�
    Checks to see if the supplied string is a valid ip4/6 or hostname
    :param ip_hn: String representing address user inputted
    :return: True if valid IP address or hostname
    z(?!-)[A-Z0-9-]{1,63}(?<!-)$z	^[0-9.]+$TrZFr&rVNc3s|]}�j|�VqdS)N)�match)reri)rkr<r=rjsz)_is_valid_network_name.<locals>.<genexpr>rlrl)	�re�compile�
IGNORECASErarsr\rtrqr[)Zip_hnZdigits_onlyr<)rkr=�_is_valid_network_name�s

rxFc	CsPd}|rt}|jddddtjdtfd�|jdd	d
tdd|d
d�|jdddd|dd�|jdddd|dd�|jddd
d|ddd�|jdd dd!|d"d#d$�|jd%d&dd'|d"d(d$�|jd)d*d
d+|d,td-�|jd.dd/|d0d�|jd1dd2|d"d3d$�|jd4d5dd6|d"d7d$�|�rLt�}d8|d+|<|jf|�d9S):a
    As https://bugs.python.org/issue23058 indicate, argument parser should
    not have subparser sharing the same argument and destination.
    For subparser, we add common options as 'child_xxx' destination.
    For default value, False is the only allowed default value in root.
    rdz-vz	--version�versionz%s %sr)�actionryz-uz--uriZstorez<URI>z%suriz,Uniform resource identifier (env LSMCLI_URI))rz�type�metavar�dest�helpz-Pz--prompt�
store_truez%spromptz)Prompt for password (env LSMCLI_PASSWORD))rzr}r~z-Hz--humanz%shumanz:Print sizes in human readable format
(e.g., MiB, GiB, TiB)z-tz--tersez%ssepz<SEP>z;Print output in terse form with "SEP" as a record separator)rzr}r|r~z-ez--enumz%senumFz3Display enumerated types as numbers instead of text)rzr}�defaultr~z-fz--forcez%sforcez3Bypass confirmation prompt for data loss operationsz-wz--waitz%swaitz+Command timeout value in ms (default = 30s))rzr}r~r{z--headerz%sheaderzInclude the header with tersez-bz%s_asynczmRun the command async. Instead of waiting for completion.
 Command will exit(7) and job id written to stdout.z-sz--scriptz%sscriptzMDisplaying data in script friendly way with additional information(if exists)i0uN)	�_CHILD_OPTION_DST_PREFIX�add_argumentr+�argvrr.rR�dict�set_defaults)Z
arg_parser�is_child�prefixZdefault_dictr<r<r=�_add_common_optionss\

r�cCsbi}xXtj�D]L}ytj|�}|||<Wqtk
rX}z|jtjkrH�WYdd}~XqXqW|S)N)r�list�	vpd83_getrr0r�
NO_SUPPORT)�lookup�dZvpd�lsm_errr<r<r=�_sd_paths_cache\s
r�cCstg|_tdkrt�ay*t|j�dkr<|jtkr<tj|j�|_Wn0tk
rn}z|jt	j
kr^�WYdd}~XnX|S)Nr)Zsd_paths�LOCAL_DISK_LOOKUPr�r\�vpd83rZvpd83_searchrr0rr�)Zlsm_objr�r<r<r=�
_add_sd_pathshs
r�c@seZdZdd�Zdd�ZdS)r*cOstj|f|�|�||_dS)z,
        Class represents an error.
        N)r7�__init__�msg)�self�message�args�kwargsr<r<r=r�|szArgError.__init__cCsdtjjtjd�|jfS)Nz%s: error: %s
r)�os�path�basenamer+r�r�)r�r<r<r=�__str__�szArgError.__str__N)�__name__�
__module__�__qualname__r�r�r<r<r<r=r*{sr*�itemTcCs:x|D]}|j|kr|SqW|r2td||f��ndSdS)Nz%s with ID %s not found!)�idr*)�lZthe_idZ
friendly_name�raise_errorr�r<r<r=�	_get_item�s

r�cCs t|�}|r|Std|��dS)zT
    Custom value checker for hostname/IP address
    :param addr:
    :return:
    z%s is invalid IP or hostnameN)rxr)ZaddrrIr<r<r=�_check_network_host�sr��VOLUMES�POOLS�FS�	SNAPSHOTS�EXPORTS�NFS_CLIENT_AUTH�
ACCESS_GROUPS�SYSTEMS�DISKS�PLUGINS�TARGET_PORTS�	BATTERIES�DEFAULT�THIN�FULLzprovisioning type: z, �CLONE�COPY�MIRROR_ASYNC�MIRROR_SYNCzreplication type: �ENABLEZDISABLEzPolicy: z--policyz<POLICY>)�namer|r~�choicesr{�WB�AUTOZWTzWrite cache polices: z' which stand for "write back", "auto", z"write through"z7Can use B, KiB, MiB, GiB, TiB, PiB postfix (IEC sizing)z--sysz<SYS_ID>z	System ID)r�r|r~zmSearch by System ID. Only supported for: 
(VOLUMES, POOLS, FS, DISKS, ACCESS_GROUPS,
TARGET_PORTS, BATTERIES)r~z--poolz	<POOL_ID>zPool IDz;Search by Pool ID. Only supported for:
(VOLUMES, POOLS, FS)z--volz<VOL_ID>z	Volume IDzASearch by Volume ID. Only supported for:
(VOLUMES, ACCESS_GROUPS)z--fsz<FS_ID>zFile System IDz=Search by FS ID. Only supported for:
(FS, SNAPSHOTS, EXPORTS)z--agz<AG_ID>zAccess Group IDzGSearch by Access Group ID. Only supported for:
(ACCESS_GROUPS, VOLUMES)z--initz	<INIT_ID>zInitiator ID)r�r|r~r{z--snapz	<SNAP_ID>zSnapshot IDz--exportz<EXPORT_ID>z	Export IDz--nfs-exportz<NFS_EXPORT_ID>z6Search by NFS Export ID. Only supported for:
(EXPORTS)z--diskz	<DISK_ID>z.Search by Disk ID. Only supported for:
(DISKS)z--sizez<SIZE>z--tgtz<TGT_ID>z=Search by target port ID.  Only supported for:
(TARGET_PORTS)z--pathzLocal disk pathz<DISK_PATH>)r�r~r|r�zList records of different typesz--typezList records of type:
    z
    z3

When listing SNAPSHOTS, it requires --fs <FS_ID>.z<TYPE>)r�r~r|r�r{)r�r~r��optionalz
job-statusz Retrieve information about a jobz--jobz<JOB_ID>z
job status id)r�r~r��capabilitieszRetrieves array capabilitieszplugin-infoz(Retrieves plugin description and version)r�r~z
volume-createzCreates a volume (logical unit)z--namezvolume namez<NAME>z--provisioning)r�r~r�r�r{zvolume-raid-createz(Creates a RAIDed volume on hardware RAIDz<DISK>z>Free disks for new RAIDed volume.
This is repeatable argument.rp)r�r|r~rzz--raid-typez@RAID type for the new RAID group. Should be one of these:
    %s)r�r~r�r{z--strip-sizezStrip size. zvolume-raid-create-capz=Query capability of creating a RAIDed volume on hardware RAIDz
volume-deletezDeletes a volume given its idz
volume-resizezRe-sizes a volumez
<NEW_SIZE>zNew size. %szvolume-replicatez:Creates a new volume and replicates provided volume to it.z<NEW_VOL_NAME>z"The name for New replicated volumez
--rep-typez<REPL_TYPE>)r�r|r~r�z[Pool ID to contain the new volume.
By default, new volume will be created in the same pool.zvolume-replicate-rangez3Replicates a portion of a volume to existing volumez	--src-volz<SRC_VOL_ID>zSource volume idz	--dst-volz<DST_VOL_ID>zDestination volume idz
<REP_TYPE>zReplication type: CLONE, COPYz--src-startz<SRC_START_BLK>z>Source volume start block number.
This is repeatable argument.)r�r|r~rzr{z--dst-startz<DST_START_BLK>zCDestination volume start block number.
This is repeatable argument.z--countz<BLK_COUNT>z;Number of blocks to replicate.
This is repeatable argument.z!volume-replicate-range-block-sizez2Size of each replicated block on a system in byteszvolume-dependantsz>Returns True if volume has a dependant child, like replicationzvolume-dependants-rmzRemoves volume dependencieszvolume-access-groupz4Lists the access group(s) that have access to volumezvolume-maskz>Grants access to an access group to a volume, like LUN Maskingz
volume-unmaskz7Revoke the access of specified access group to a volumez
volume-enablezEnable block access of a volumezvolume-disablez Disable block access of a volumezvolume-raid-infozQuery volume RAID informationzvolume-ident-led-onz!Enable the IDENT LED for a volumezTargeted volume.
zvolume-ident-led-offz"Disable the IDENT LED for a volumezsystem-read-cache-pct-updatez,Change the read cache percentage of a systemzTargeted system.
z
--read-pctzRead cache percentage.
)r�r~r{zpool-member-infoz!Query Pool membership informationzaccess-group-createzCreate an access groupz	<AG_NAME>z$Human readable name for access groupzaccess-group-addz+Add an initiator into existing access groupzaccess-group-removez.Remove an initiator from existing access groupzaccess-group-deletezDeletes an access groupzaccess-group-volumeszBLists the volumes that the access group has been granted access toz
iscsi-chapz5Configures iSCSI inbound/outbound CHAP authenticationz	--in-userz	<IN_USER>zInbound chap user namez	--in-passz	<IN_PASS>zInbound chap passwordz
--out-userz
<OUT_USER>zOutbound chap user namez
--out-passz
<OUT_PASS>zOutbound chap passwordz	fs-createzCreates a file systemz	<FS_NAME>zname of the file systemz	fs-deletezDelete a filesystemz	fs-resizezRe-sizes a filesystemz	fs-exportzExport a filesystem via NFS.z--exportpathz
<EXPORT_PATH>z(NFS server export path. e.g. '/foo/bar'.z	--anonuidz
<ANON_UID>z%UID(User ID) to map to anonymous user)r�r|r~r�r{z	--anongidz
<ANON_GID>z&GID(Group ID) to map to anonymous userz--auth-typez<AUTH_TYPE>zNFS client authentication typez--root-hostz<ROOT_HOST>z9The host/IP has root access.
This is repeatable argument.)r�r|r~rzr�r{z	--ro-hostz	<RO_HOST>zrThe host/IP has readonly access.
This is repeatable argument.
At least one '--ro-host' or '--rw-host' is required.z	--rw-hostz	<RW_HOST>zsThe host/IP has readwrite access.
This is repeatable argument.
At least one '--ro-host' or '--rw-host' is required.zfs-unexportzRemove an NFS exportzfs-clonezCreates a file system clonez--src-fsz<SRC_FS_ID>z&The ID of existing source file system.z
--dst-namez
<DST_FS_NAME>z3The name for newly created destination file system.z--backing-snapshotz
<BE_SS_ID>zbacking snapshot idzfs-snap-createzCreates a snapshotz<SNAP_NAME>z'The human friendly name of new snapshotzfs-snap-deletezDeletes a snapshotzfs-snap-restorez;Restores a FS or specified files to previous snapshot statez--filez<FILE_PATH>zkOnly restore provided file
Without this argument, all files will be restored
This is a repeatable argument.)r�r|r~rzr�z--fileasz<NEW_FILE_PATH>zGstore restore file name to another name.
This is a repeatable argument.z
fs-dependantszHReturns True if filesystem has a child dependency(clone/snapshot) existsz-For file check
This is a repeatable argument.)r�r|rzr�r~zfs-dependants-rmz Removes file system dependencieszHFile or files to remove dependencies for.
This is a repeatable argument.)r�rzr�r~z
file-clonez,Creates a clone of a file (thin provisioned)z--srcz<SRC_FILE_PATH>zCsource file to clone (relative path)
This is a repeatable argument.z--dstz<DST_FILE_PATH>z@Destination file (relative path), this is a repeatable argument.zQuery local disk informationzvolume-cache-infoz"Query volume RAM cache informationzvolume-phy-disk-cache-updatez)Update volume physical disk cache settingzvolume-read-cache-policy-updatezUpdate volume read cache policyz volume-write-cache-policy-updatez Update volume write cache policyz/Turn on the identification LED for a local diskz0Turn off the identification LED for a local diskz&Turn on the fault LED for a local diskz'Turn off the fault LED for a local diskzlist --type systemszlist --type poolszlist --type volumeszlist --type diskszlist --type access_groupszlist --type fszlist --type target_portszlist --type batteries)%ZlsZlpZlvZldZlaZlf�ltr9rfZvcZvrcZvrccZvdZvrZvmZvu�veZviZacZaa�arZadZvriZvilonZviloffZsrcpuZpmiZldlZlbZvciZvpdcuZvrcpuZvwcpuZldilonZldiloffZldflonZldfloffc@sPeZdZdZdd�Zdd�Zdd�Zedd	��Zed
d��Z	dd
�Z
dd�Zedd��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zed.d/��Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dBdC�Z%dDdE�Z&edFdG��Z'dHdI�Z(dJdK�Z)dLdM�Z*dNdO�Z+dPdQ�Z,dRdS�Z-dTdU�Z.dVdW�Z/dXdY�Z0dZd[�Z1d\d]�Z2d^d_�Z3d`da�Z4dbdc�Z5ddde�Z6dfdg�Z7dhdi�Z8djdk�Z9dldm�Z:dndo�Z;dpdq�Z<drds�Z=dtdu�Z>d�dwdx�Z?d�dydz�Z@d{d|�ZAd}d~�ZBdd��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZIdvS)�r(z'
    Command line interface class.
    cCsL|jjsD|rdnd}td|�t�}|j�dkr6dStd�dSndSdS)	z1
        Give the user a chance to bail.
        ZwillZmayzxWarning: You are about to do an operation that %s cause data to be lost!
Press [Y|y] to continue, any other key to abort�YTzOperation aborted!FN)r��forcerrFrS)r�Zdeletingr�Zpressedr<r<r=�confirm_promptkszCmdLine.confirm_promptc	Csld}t|�dkrdStj}d}|jjr*d}|jjr6d}|jjrDtj}tj|||jj	|jj
|jj||d�dS)NFrT)�display_wayZ
flag_humanZ	flag_enumZsplitter�flag_with_headerZflag_dsp_all_data)r\rZDISPLAY_WAY_DEFAULTr��sep�headerZscriptZDISPLAY_WAY_SCRIPT�display_dataZhuman�enum)r�ZobjectsZdisplay_allr�r�r<r<r=r��s 
zCmdLine.display_datacCsLg}d}tj|�}x*|D]"}|j|�\}}|jt||��qW|j|�dS)Nz<}{>)rZavailable_pluginsr[rprr�)r�r�r�Zpluginsrf�descryr<r<r=�display_available_plugins�s

z!CmdLine.display_available_pluginscCsHg}x>tjdd�D],}|tkr6|jt|jd��q|j|�qW|S)ab
        Walk the command line argument list and build up a new command line
        with the appropriate substitutions which is then passed to argparse, so
        that we can avoid adding more sub parsers and do all argument parsing
        before the need to talk to the library
        :return copy of command line args with alias expansion:
        r&N� )r+r��aliasesror[rp)rQr`r<r<r=�handle_alias�s	zCmdLine.handle_aliascCs2d}x(ttj��D]\}}|dj||�7}qW|S)Nzcommand aliases:
z   {0:<18}   Alias of '{1}'
)�sortedr��items�format)rQ�k�vr<r<r=�alias_help_text�szCmdLine.alias_help_textcCs�tdd�}t|dd�tdtj�dtd�}t|dd�|jdd	�}d|_x�tD]�}|j|d
|d|gtd�}|j	d
�}x8|j
dg�D](}|d
}|d
=|j|fddi|��q�W|j	d�}x>|j
dg�D].}|d
}	|d
=t|	t
�s�|	f}	|j|	|�q�W|jt||d
jdd��d�qPWttj�dk�r@|j�td�||_|jtj�d�}
xbt|
�j�D]R\}}|jt��rd|tt�d�}
t|
|
�dk�s�t|
|
�dk�rdt|
|
|��qdW|
S)z3
        Command line interface parameters
        F)Zadd_helpT)r�z^The libStorageMgmt command line interface. Run %(prog)s <command> -h for more on each command.zh

Copyright 2012-2018 Red Hat, Inc.
Please report bugs to <libstoragemgmt-devel@lists.fedorahosted.org>
)�descriptionZepilog�formatter_classZcommand)r|r�r~)r~�parentsr�zcmd required argumentsr��requiredzcmd optional argumentsr��-rL)�funcr&)r�N)rr�r(r�rZadd_subparsersr��cmdsZ
add_parserZadd_argument_group�getr��
isinstance�tupler��getattr�replacer\r+r�Zprint_usager8�parser�
parse_argsr��varsr��
startswithr��setattr)r�Z
parent_parserr�Z
subparsers�cmdZ
sub_parser�group�argr��flagsZ
known_argsr�r�Zroot_kr<r<r=r:�sP




zCmdLine.clicCs:|jjr"t|jjj|jj���ntdj|jj���dS)zD
        Dump the supported nfs client authentication types
        z, N)r�r�rrrr9Zexport_auth)r�r<r<r=�!display_nfs_client_authentication�sz)CmdLine.display_nfs_client_authenticationc	Cs�d}d}|jdf|jdf|jdf|jdf|jdf|jdf|jdf|jdff}x6|D].}|d	rR|rxtd
||df��qR|\}}qRW||fS)NZ	system_id�pool_id�	volume_id�disk_id�access_group_id�fs_id�
nfs_export_id�tgt_port_idrz,Search key specified more than once (%s, %s)r&)	r+�pool�vol�disk�ag�fsZ
nfs_exportZtgtr*)r��
search_key�search_valueZsearch_argsZsar<r<r=�_get_search_key_values$
zCmdLine._get_search_key_valuecCs�tj|�\}}|jdkr�g}|dkr(d}|dkrZt|jj�|jddd�}|r�|jj|�}n*|rv|tj	krvt
d|��n|jj||�}|jt
d	d
�|D����nT|jdkr�|dkr�d}|r�|tj	kr�t
d
|��|j|jj||���n|jdk�r8|dk�rd}|�r |tj	k�r t
d|��|j|jj||���n�|jdk�r�|jdk�rXt
d��|�rt|dk�rtt
d|��t|jj�|jd�}|j|jj|���nV|jdk�r�|dk�r�d}|�r�|tj	k�r�t
d|��|j|jj||���n|jdk�r|�rt
d��|j��n�|jdk�r�|dk�r.d}|dk�rtt|jj�|jddd�}|�rh|j|jj|��S|jg�Sn|�r�|tj	k�r�t
d|��|j|jj||���nJ|jdk�r�|�r�t
d��|j|jj���n|jdk�r4|dk�r�d}|�r|tj	k�rt
d |��|jt
d!d
�|jj||�D���n�|jd"k�r�|d#k�rNd}|�rl|tj	k�rlt
d$|��|j|jj||��nr|jd%k�r�|�r�t
d&��|j�nN|jd'k�r�|�r�|tj	k�r�t
d(|��|j|jj ||��nt
d)|j��dS)*Nr�r�r�r�zAccess GroupF)r�z3Search key '%s' is not supported by volume listing.css|]}t|�VqdS)N)r�)rer�r<r<r=rj7szCmdLine.list.<locals>.<genexpr>r�r�z1Search key '%s' is not supported by pool listing.r�r�r�z--fs <file system id> requiredz5Search key '%s' is not supported by snapshot listing.zFile Systemr�r�z6Search key '%s' is not supported by NFS Export listingr�zCNFS client authentication type listing with search is not supportedr�r
z8Search key '%s' is not supported by Access Group listingr�z+System listing with search is not supportedr�r�z0Search key '%s' is not supported by disk listingcss|]}t|�VqdS)N)r�)rer�r<r<r=rjzsr�r�z7Search key '%s' is not supported by target port listingr�z,Plugins listing with search is not supportedr�z3Search key '%s' is not supported by battery listingzunsupported listing type=%s)!r(r�r{r�r9�
access_groupsr��"volumes_accessible_by_access_groupr
ZSUPPORTED_SEARCH_KEYSr*�volumesr�r�r�poolsrr��fs_snapshotsr�exportsr�r��access_groups_granted_to_volumer�systemsr	�disksrZtarget_portsr�rZ	batteries)r�r�r�r�Zlsm_vols�lsm_agr��lsm_volr<r<r=r�$s�











zCmdLine.listcCsFt|jj�|jd�}t|j�\}}|jj|j|||�}|j|g�dS)N�System)	r�r9rr+rK�init�access_group_creater�r�)r�r��systemrH�	init_typeZaccess_groupr<r<r=r	�s
zCmdLine.access_group_createcCsJt|jj�|jd�}t|j�\}}|r6|jj|||�S|jj|||�SdS)NzAccess Group)r�r9r�r�rKrZaccess_group_initiator_addZaccess_group_initiator_delete)r�r��oprrHrr<r<r=�_add_rm_access_grp_init�s

zCmdLine._add_rm_access_grp_initcCs|j|j|d�g�dS)NT)r�r
)r�r�r<r<r=�access_group_add�szCmdLine.access_group_addcCs|j|j|d�g�dS)NF)r�r
)r�r�r<r<r=�access_group_remove�szCmdLine.access_group_removecCs@|jj�}t||jd�}|jj|�}|jtdd�|D���dS)NzAccess Groupcss|]}t|�VqdS)N)r�)rer�r<r<r=rj�sz/CmdLine.access_group_volumes.<locals>.<genexpr>)r9r�r�r�r�r�r�)r�r��aglr�Zvolsr<r<r=�access_group_volumes�s
zCmdLine.access_group_volumescCs�t|j�\}}|tjkr&td|j��|jjr@|jjr@td��|jjrZ|jjrZtd��|jjrt|jj	rttd��|jj	r�|jjr�td��|jjr�|jj	r�|jjo�|jjr�td��|j
j||j|jj|jj|jj	�dS)Nz$--init "%s" is not a valid iSCSI IQNz--in-user requires --in-passz--in-pass requires --in-userz--out-user requires --out-passz--out-pass requires --out-userz?out-user and out-password only supported if inbound is supplied)rKrrZINIT_TYPE_ISCSI_IQNr*r�Zin_userZin_passZout_userZout_passr9Ziscsi_chap_auth)r�r�rHrr<r<r=�
iscsi_chap�s$
zCmdLine.iscsi_chapcCs.t|jj�|jd�}|jj|�}|j|�dS)Nr
)r�r9r�r�rr�)r�r�r��groupsr<r<r=�volume_access_group�szCmdLine.volume_access_groupcCs$|jj�}t||jd�}|jj|�S)NzAccess Group)r9r�r�r��access_group_delete)r�r�rr�r<r<r=r�s
zCmdLine.access_group_deletecCs8t|jj�|jd�}|jd�r4|jd|jj|�d�dS)NzFile SystemTz	fs-delete)r�r9r�r��_wait_for_it�	fs_delete)r�r�r�r<r<r=r�s
zCmdLine.fs_deletecCsHt|jj�|jd�}|jd|jj||j|j|j����}|j	|g�dS)Nr�	fs-create)r)
r�r9r�r�r�	fs_creater��_size�sizer�)r�r�rfr�r<r<r=r�s
zCmdLine.fs_createcCsht|jj�|jd�}|j|j�}||jkr6ttjd��|j	d�rd|j
d|jj||���}|j|g�dS)NzFile SystemzSpecified size same as currentF�	fs-resize)r)
r�r9r�rrZtotal_spacerr�NO_STATE_CHANGEr�r�	fs_resizer�)r�r�r�rr<r<r=r�s


zCmdLine.fs_resizecCs`t|jj�|jd�}d}|jr4t|jj|�|jd�}|jd|jj||j|���}|j	|g�dS)NzSource File System�Snapshot�fs_clone)r )
r�r9r��src_fs�backing_snapshotrrr Zdst_namer�)r�r�r!�ssr�r<r<r=r �s
zCmdLine.fs_clonecCs\t|jj�|jd�}|jjr4t|jj|�|jd�}nd}|jd|jj||j|j	|�d�dS)NzFile Systemr�
fs_file_clone)
r�r9r�r�r"rrr$�src�dst)r�r�r�r#r<r<r=�
file_cloneszCmdLine.file_clonecCs t|�}|dkrtd|��|S)Nrz$Incorrect size argument format: '%s')rr*)rTZ
size_bytesr<r<r=rsz
CmdLine._sizecCs>|jjdk	r|jj}nd}|r$d}nd}td|||f�dS)Nrb�	SUPPORTED�UNSUPPORTEDz%s%s%s)r�r�r)r��cap�valrTr�r<r<r=�_cps
zCmdLine._cpc	Cs�t|jj�|jd�}|jj|�}t|j�j��}t|jd�j��}tj	}|j
jdk	r\|j
j}t�}x|D]}d||<qhWx|D]}||kr~d||<q~Wtj
|g|�dS)NrTr(r))r�r9rr+r�r�Z
get_supported�valuesrZDEFAULT_SPLITTERr�r�r!Zdisplay_data_script_way)	r�r�rTr*Zsup_capsZall_capsr�Zcap_datar�r<r<r=r�+s

zCmdLine.capabilitiescCs>|jj�\}}|jr*td||j|f�ntd||f�dS)Nz%s%s%szDescription: %s Version: %s)r9�plugin_infor�r)r�r�r�ryr<r<r=r.AszCmdLine.plugin_infocCsTt|jj�|jd�}|jd|jj||j|j|j�t	|j
����}|jt|�g�dS)Nr�
volume-create)r/)
r�r9r�r�r�
volume_creater�rrrZprovisioningr�r�)r�r�rfr�r<r<r=r0Js
zCmdLine.volume_createcCs>t|jj�|jd�}|jd|jj||j���}|j|g�dS)NzFile System�snapshot-create)r1)r�r9r�rZfs_snapshot_creater�r�)r�r�r�r#r<r<r=�fs_snap_createWszCmdLine.fs_snap_createcCs�t|jj�|jd�}t|jj|�|jd�}|jj}t|�dkrBd}d}|jjrzd}|jjrzt|jj�t|jj�krzt	d��|j
d�r�|jd|jj||||jj|�d�dS)NzFile SystemrrTFz&number of --file not equal to --fileaszfs-snap-restore)
r�r9r�r�snapr�r'r\Zfileasr*r�rZfs_snapshot_restore)r�r�r�r#�filesZflag_all_filesr<r<r=�fs_snap_restorebs$
zCmdLine.fs_snap_restorecCs8t|jj�|jd�}|jd�r4|jd|jj|�d�dS)Nr
Tz
volume-delete)r�r9r�r�r�r�
volume_delete)r�r�r�r<r<r=r6{s
zCmdLine.volume_deletecCsPt|jj�|jd�}t|jj|�|jd�}|jd�rL|jd|jj||�d�dS)NzFile SystemrT�fs_snap_delete)r�r9r�rr3r�rZfs_snapshot_delete)r�r�r�r#r<r<r=r7�s

zCmdLine.fs_snap_deletecCs�|s|S|jjr$t|�|jtj�xZ|jj|�\}}}|tj	krNt
jd�q&|tjkrh|jj
|�|St|dt|���q&WdS)Ng�?z job error code= )r�Z_asyncrr6r�JOB_STARTEDr9�
job_statusrZ
INPROGRESS�timeZsleep�COMPLETE�job_freer*r.)r�r��jobr�rT�percentr<r<r=r�s

zCmdLine._wait_for_itcCs^|jj|j�\}}}|tjkrB|r2|jt|�g�|jj|j�ntt	|��|j
tj�dS)N)
r9r9r=rr;r�r�r<rr.r6rr8)r�r�rTr>r�r<r<r=r9�s
zCmdLine.job_statuscCs�d}|jrt|jj�|jd�}t|jj�|jd�}t|j�}|tj	krRt
d|��|jd|jj||||j
���}|jt|�g�dS)Nrr
zinvalid replication type= %s�replicate volume)r?)r�r�r9r�r�r�r�rep_typer
�REPLICATE_UNKNOWNr*r�volume_replicater�r�r�)r�r�rfr�r@r�r<r<r=rB�s

zCmdLine.volume_replicatecCs@dd�}|jdd�d�||d�|jdd�d�||d�dS)	Nc	Ss�x�tdt|��D]n}t||d|�}||dj}t|||�}||j}|||krtd||||d|||df��qWdS)Nr&z<Overlapping %s replication range %d..%d overlaps with %d..%d)�ranger\r�Zblock_countr*)�r�memberr`ZpsZpcZcsZccr<r<r=�_overlap�s
z(CmdLine._check_overlap.<locals>._overlapcSs|jS)N)�	src_block)rir<r<r=�<lambda>�sz(CmdLine._check_overlap.<locals>.<lambda>)�keyrGcSs|jS)N)�
dest_block)rir<r<r=rH�srJ)�sort)�rangesrFr<r<r=�_check_overlap�s

zCmdLine._check_overlapc
Csnt|jj�|jd�}t|jj�|jd�}t|j�}|tjkrHt	d|��|j
}|j}|j}t
|�s�t
|�t
|�ko�t
|�knr�t	d��g}x�tt
|��D]�}	t||	�}
t||	�}t||	�}|
dkr�t	d��|dkr�t	d��|dkr�t	d��||
|jk�rt	d	��||
|jk�r,t	d
��|jt|||
��q�Wtj|�|jd��rj|jj||||�dS)Nz
Source VolumezDestination Volumezinvalid replication type= %sz@Differing numbers of src_start, dest_start, and count parametersrz--count: value < 0z--src-start: value < 0z--dst_start: value < 0z#--src-start + --count > source sizez(--dst-start + --count > destination sizeF)r�r9r�Zsrc_volZdst_volrr@r
rAr*�	src_start�	dst_start�countr\rCrO�
num_of_blocksrpr
r(rMr��volume_replicate_range)
r�r�r%r&r@Z
src_startsZ
dst_startsZcountsrL�brPrNrOr<r<r=rR�s>


&
zCmdLine.volume_replicate_rangecCs(t|jj�|jd�}t|jj|��dS)Nr)r�r9rr+r�!volume_replicate_range_block_size)r�r�rTr<r<r=rT
sz)CmdLine.volume_replicate_range_block_sizecCs:t|jj�|jd�}t|jj�|jd�}|jj||�dS)Nr
zAccess Group)r�r9r�r�r�r��volume_mask)r�r�r�r�r<r<r=rUszCmdLine.volume_maskcCs6t|jj�|jd�}t|jj�|jd�}|jj||�S)NzAccess Groupr
)r�r9r�r�r�r��
volume_unmask)r�r�r�r�r<r<r=rVszCmdLine.volume_unmaskcCsrt|jj�|jd�}|j|j�}||j|jkr<tt	j
d��|jd�rn|jd|jj
||���}|jt|�g�dS)Nr
zSpecified size same as currentF�resize)rW)r�r9r�r�rrZ
block_sizerQrrrr�r�
volume_resizer�r�)r�r�r�rr�r<r<r=rXs

zCmdLine.volume_resizecCs$t|jj�|jd�}|jj|�dS)Nr
)r�r9r�r��
volume_enable)r�r�r�r<r<r=rY*szCmdLine.volume_enablecCs$t|jj�|jd�}|jj|�dS)Nr
)r�r9r�r��volume_disable)r�r�r�r<r<r=rZ/szCmdLine.volume_disablecCs$t|jj�|jd�}|jj|�dS)Nz
NFS Export)r�r9r�exportZ
export_remove)r�r�r[r<r<r=�fs_unexport4szCmdLine.fs_unexportc
Cstt|jj�|jd�}t|j�dkr8t|j�dkr8td��|jj|j|j	|j
|j|j|j|j|j
d�	}|j|g�dS)NzFile Systemrz& please specify --ro-host or --rw-host)r�r9r�r\Zrw_hostZro_hostr*Z	export_fsr�Z
exportpathZ	root_hostZanonuidZanongidZ	auth_typer�)r�r�r�r[r<r<r=�	fs_export9szCmdLine.fs_exportcCs,t|jj�|jd�}|jj|�}t|�dS)Nr
)r�r9r�r�Zvolume_child_dependencyr)r�r�r�rQr<r<r=�volume_dependantsNszCmdLine.volume_dependantscCs.t|jj�|jd�}|jd|jj|�d�dS)Nr
zvolume-dependant-rm)r�r9r�r�rZvolume_child_dependency_rm)r�r�r�r<r<r=�volume_dependants_rmTszCmdLine.volume_dependants_rmcCs8t|jj�|jd�}|jt|jf|jj|���g�dS)Nr
)r�r9r�r�r�rr��volume_raid_info)r�r�rr<r<r=r`YszCmdLine.volume_raid_infocCs8t|jj�|jd�}|jt|jf|jj|���g�dS)Nr)r�r9r�r�r�rr��pool_member_info)r�r�Zlsm_poolr<r<r=ra`szCmdLine.pool_member_infocs�tj�j�}|jj�}�fdd�|D�}t|�t�j�krhttj	ddj
t�j�tdd�|D�����dd�|D�}t|�dkr�ttjd	dj
|����j
r�t�j
�}ntj}|jt|jj�j|||��g�dS)
Ncsg|]}|j�jkr|�qSr<)r�r�)rer�)r�r<r=rgksz.CmdLine.volume_raid_create.<locals>.<listcomp>zDisk ID %s not foundz, css|]}|jVqdS)N)r�)rer�r<r<r=rjpsz-CmdLine.volume_raid_create.<locals>.<genexpr>cSsg|]}|jtj@s|j�qSr<)Zstatusr	ZSTATUS_FREEr�)rer�r<r<r=rgrsr&zDisk %s is not free)rZraid_type_str_to_lsm�	raid_typer9rr\r�rrZNOT_FOUND_DISKrr�setZ
DISK_NOT_FREE�
strip_sizerr
ZVCR_STRIP_SIZE_DEFAULTr�r��volume_raid_creater�)r�r�rbZ
all_lsm_disksZ	lsm_disksZ
busy_disksrdr<)r�r=regs(
&zCmdLine.volume_raid_createcCs8t|jj�|jd�}|jt|jf|jj|���g�dS)Nr)r�r9rr+r�rr�Zvolume_raid_create_cap_get)r�r�Zlsm_sysr<r<r=�volume_raid_create_cap�szCmdLine.volume_raid_create_capcCs$t|jj�|jd�}|jj|�dS)Nr
)r�r9r�r��volume_ident_led_on)r�r��
lsm_volumer<r<r=rg�szCmdLine.volume_ident_led_oncCs$t|jj�|jd�}|jj|�dS)Nr
)r�r9r�r��volume_ident_led_off)r�r�rhr<r<r=ri�szCmdLine.volume_ident_led_offcCs�t|jj�|jd�}yt|j�}Wn2tk
rT}zttj	t
|���WYdd}~XnX|jj||�t|jj�|jd�}|j|g�dS)Nr)
r�r9rr+r]�read_pctrPrrZINVALID_ARGUMENTr.�system_read_cache_pct_updater�)r�r�Z
lsm_systemrjr�r<r<r=rk�s"z$CmdLine.system_read_cache_pct_updatecCs0t|jj�|jd�}|jj||j�}t|�dS)NzFile System)r�r9r�Zfs_child_dependencyr'r)r�r�r�rQr<r<r=�
fs_dependants�szCmdLine.fs_dependantscCs2t|jj�|jd�}|jd|jj||j�d�dS)NzFile Systemzfs-dependants-rm)r�r9r�rZfs_child_dependency_rmr')r�r�r�r<r<r=�fs_dependants_rm�s
zCmdLine.fs_dependants_rmcCs�d
}tjjd�d}tjj|�s$dSt|��l}xd|D]\}|j�jd�rHq4y2dd�|jdd	�D�\}}||krxt|||�Wq4t	k
r�Yq4Xq4WWdQRXdS)zo
        Set uri from config file. Will be overridden by cmdline option or
        env var if present.
        �uri�~z/.lsmcliN�#cSsg|]}|j��qSr<)�strip)rerir<r<r=rg�sz,CmdLine._read_configfile.<locals>.<listcomp>�=r&)rn)
r�r��
expanduser�exists�open�lstripr�r[r�rP)r�Zallowed_config_optionsZconfig_path�f�liner�r+r<r<r=�_read_configfile�s

zCmdLine._read_configfilecCs|jjjjdd�tkrdSdS)zU
        Return True if current command is one of _CONNECTION_FREE_COMMANDS.
        rLr�TF)r�r�r�r��_CONNECTION_FREE_COMMANDS)r�r<r<r=�is_connection_free_cmd�szCmdLine.is_connection_free_cmdcCsd|_d|_d|_d|_|j�|_d|_t|jj�|_	|j	sH|j	dkrPt
d��|j�r\dS|j�t
jd�dk	r~t
jd�|_t
jd�|_|jjdk	r�|jj|_|jdkr�d|jkr�|jjdkr�d|_d|_nt
d��|jjr�tj�|_|jdk	�rt|j�}|d	dk�rt
d
��dS)Nrz0[-w|--wait] requires a non-zero positive integerZ
LSMCLI_URIZLSMCLI_PASSWORDr{r�zsim://z"--uri missing or export LSMCLI_URIZusernamez+password specified with no user name in uri)rnr9r�Zunknown_argsr:r��cleanupr]�wait�tmor*r{ryr��getenv�passwordr{�prompt�getpassr)r��ur<r<r=r��s8




zCmdLine.__init__NcCs |jr|j�|rtj|�dS)N)r|r+r8)r�Zecr<r<r=r6�szCmdLine.shutdowncCs�|j�r|jj|j�n||rJt|��|_|jj|j|j|j�|jj	|_
n4tt|j|j|j��|_tj
d�rttd�|jj|_
|jj|j�|j�dS)z-
        Process the parsed command.
        ZLSM_DEBUG_PLUGINz8Attach debugger to plug-in, press <return> when ready...N)r{r�r�rr9Zplugin_registerrnr�r~Zplugin_unregisterr|rr�r�input�closer6)r�r:r<r<r=r)s

zCmdLine.processcCsg}tjtjtjtjtjtjtjd�}x�tj�D]�}dt	j
t	jdt	jt	j
t	jd�}xv|j�D]j}y|||�||<Wq\tk
r�}z4|jtjkr�tjjd||j||j|jf�WYdd}~Xq\Xq\W|jt||d|d|d|d|d|d	|d
��q0W|j|�dS)N)r��rpm�	link_type�
serial_num�
led_status�
link_speed�
health_statusrdzWARN: %s('%s'): %d %s
r�r�r�r�r�r�r�)rr�Zrpm_getZ
link_type_getZserial_num_getZled_status_getZlink_speed_getZhealth_status_getr�r	ZRPM_NO_SUPPORTZLINK_TYPE_NO_SUPPORTZLED_STATUS_UNKNOWNZLINK_SPEED_UNKNOWNZHEALTH_STATUS_UNKNOWN�keysrr0rr�r+r,r-r�r�rprr�)r�r�Zlocal_disksZ	func_dictZ	disk_pathZ	info_dictrIr�r<r<r=�local_disk_list!sD


&zCmdLine.local_disk_listcCs8t|jj�|jd�}|jt|jf|jj|���g�dS)Nr
)r�r9r�r�r�r r��volume_cache_info)r�r�rr<r<r=r�KszCmdLine.volume_cache_infocCs^t|jj�|jd�}|jdkr&tj}ntj}|jj||�|j	t
|jf|jj|���g�dS)Nr
r�)
r�r9r�r��policyr
ZREAD_CACHE_POLICY_ENABLEDZREAD_CACHE_POLICY_DISABLEDZ!volume_physical_disk_cache_updater�r r�r�)r�r�rr�r<r<r=�volume_phy_disk_cache_updateRs
z$CmdLine.volume_phy_disk_cache_updatecCs^t|jj�|jd�}|jdkr&tj}ntj}|jj||�|j	t
|jf|jj|���g�dS)Nr
r�)
r�r9r�r�r�r
ZPHYSICAL_DISK_CACHE_ENABLEDZPHYSICAL_DISK_CACHE_DISABLED�volume_read_cache_policy_updater�r r�r�)r�r�rr�r<r<r=r�^s
z'CmdLine.volume_read_cache_policy_updatecCspt|jj�|jd�}|jdkr&tj}n|jdkr8tj}ntj}|jj	||�|j
t|jf|jj
|���g�dS)Nr
r�r�)r�r9r�r�r�r
ZWRITE_CACHE_POLICY_WRITE_BACKZWRITE_CACHE_POLICY_AUTOZ WRITE_CACHE_POLICY_WRITE_THROUGH� volume_write_cache_policy_updater�r r�r�)r�r�rr�r<r<r=r�js

z(CmdLine.volume_write_cache_policy_updatecCstj|j�dS)N)rZident_led_onr�)r�r�r<r<r=�local_disk_ident_led_onxszCmdLine.local_disk_ident_led_oncCstj|j�dS)N)rZ
ident_led_offr�)r�r�r<r<r=�local_disk_ident_led_off{sz CmdLine.local_disk_ident_led_offcCstj|j�dS)N)rZfault_led_onr�)r�r�r<r<r=�local_disk_fault_led_on~szCmdLine.local_disk_fault_led_oncCstj|j�dS)N)rZ
fault_led_offr�)r�r�r<r<r=�local_disk_fault_led_off�sz CmdLine.local_disk_fault_led_off)N)N)Jr�r�r��__doc__r�r�r��staticmethodr�r�r:r�r�r�r	r
rrrrrrrrrr r'rr,r�r.r0r2r5r6r7rr9rBrMrRrTrUrVrXrYrZr\r]r^r_r`rarerfrgrirkrlrmryr{r�r6r)r�r�r�r�r�r�r�r�r�r<r<r<r=r(as�?p
	


2
/
	
*r()N)F)r�T)r�r�r�)r�r�r�r�)kr�r+r�rur:rBrA�argparserrrZsixZlsmrrrrr	r
rrr
rrrrrrrrrZlsm.lsmcli.data_displayrrrrrrrrrr rzZPY3r]rO�collectionsr!�ImportErrorZordereddictr�r>rFrKrMrRr�rUrarsrxr�r�r�r7r*r�r�Zlist_choicesZprovision_typesrrZprovision_helpZreplicate_typesZreplicate_helpZpolicy_typesZpolicy_helpr�Z
policy_optZwrite_cache_policy_typesZwrite_cache_policy_helpZwrite_cache_policy_optZ	size_helpZ
sys_id_opt�copyZsys_id_filter_optZpool_id_optZpool_id_filter_optZ
vol_id_optZvol_id_filter_optZ	fs_id_optZfs_id_filter_optZ	ag_id_optZag_id_filter_optZinit_id_optZsnap_id_optZ
export_id_optZnfs_export_id_filter_optZdisk_id_filter_optZsize_optZtgt_id_filter_optZlocal_disk_path_optZVOL_CREATE_RAID_TYPES_STRZANON_UID_GID_NAr�r��objectr(r<r<r<r=�<module>s�P0- *G



























Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists