/P`cK@sddlZddlZddlZddlZddlZddlZddlZddlmZm Z ddlm Z ddl Z ddl 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*e j+rie,Z-nydd l.m/Z/Wn!e0k rdd l1m/Z/nXdd Z3d Z4dZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<e=dZ>dZ?de@fdYZAdeBdZCdZDdddd d!d"d#d$d%d&d'd(g ZEdpZFd,d-jGeFZHdqZId2d-jGeIZJd3d4gZKd5d-jGeKZLeMd6d7d8d9d:eLd;eKd<e9ZNd=d>d?gZOd@d-jGeOdAdBZPeMd6d7d8d9d:ePd;eOd<e9ZQdCZReMd6dDd8dEd:dFZSeSjTZUdGeUd:dqeMeegeMd6d d:d?dqeMeegeMd6d d:d@dqeMeegf3ZheMdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOd}dPddQddRddSddTddUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcddddedfd5dgd7dhd9did;djddkddld dmd %ZidnejfdoYZkdS(riN(tArgumentParsertArgumentTypeError(tRawTextHelpFormatter(tClienttPooltVERSIONtLsmErrortDisktVolumet JobStatust ErrorNumbert BlockRanget uri_parsetProxytsize_human_2_size_bytest AccessGroupt FileSystemt NfsExportt TargetPortt LocalDisktBattery( t DisplayDatatPlugDatatouttvol_provision_str_to_typetvol_rep_type_str_to_typetVolumeRAIDInfot PoolRAIDInfotVcrCapt LocalDiskInfotVolumeRAMCacheInfoslocal-disk-listslocal-disk-ident-led-onslocal-disk-ident-led-offslocal-disk-fault-led-onslocal-disk-fault-led-off(t OrderedDictcCsbd}d}zyt}|j|Wntk rg}tjjt|tjjd}nt k r}tjjt|dtjj|j t j krd}qd}n]t k rd}nGtk r}|j }n,ddl}|jd tjd}nXWd|rPy|j|WqPtk rLqPXntj|XdS( s+ Common command line code, called. iis i iiiNtfile(tNonetCmdLinetprocesstArgErrortsyststderrtwritetstrtflushRtcodeR tPERMISSION_DENIEDtKeyboardInterruptt SystemExitt tracebackt print_exctstdouttshutdownt Exceptiontexit(tcterr_exittclitaetletseR.((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytcmd_line_wrapper;s<           cCshtjj}tj|}z,tjtjjtjjd}Wdtj|tj |X|S(Ni( R%tstdintfilenottermiost tcgetattrtttytsetrawtreadt tcsetattrt TCSADRAIN(tfdtprevtch((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytgetchhscCs<tj|\}}}|r(||fStd|dS(s 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) s,--init "%s" is not a valid WWPN or iSCSI IQNN(Rtinitiator_id_verifyR$(tinit_idtvalidtconverted_init_typetconverted_init_id((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytparse_convert_initss cCs6tj|\}}}|r"|Std|dS(s Call back from validating an initiator :param init_id: Initiator to validate :return: Value of initiator or raises an exception s!"%s" is invalid WWPN or iSCSI IQNN(RRHR(RIRJt_RL((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt _check_initscCs^y6t|d}|dkr1td|n|SWn!tk rYtd|nXdS(s Call back for validating a positive integer :param num: Number string to check :return: Numeric value, else exception i is,invalid: require positive integer value '%d's*invalid: not a positive integer value '%s'N(tlongRt ValueError(tnumtrc((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_check_positive_integers  tchild_cCs |jS(N(tupper(ts((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_upperscCs|s tS|jd}t|dkr/tSd|kr?tSx|D]}dt|koidknsrtSt|dkr|ddkrtSyt|dd krtSWqFtk rtSXqFWtS( s Check if a string represents a valid ip4 address :param address: String representing address :return: True if valid address, else false t.it/iiit0i i(tFalsetsplittlentintRQtTrue(taddresstpartsti((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_valid_ip4_addresss$  ""  cskdt}|stSd|kr&tSt|jddkrEtS|jd}t|dksxt|dkr|tSd|d krt|jsd GHtS|jd d gnd|krg|D]}|d kr|^q}|jd t}n|rt|d ks.t|d krgtd|Doftfdd j |DStS(s Check if a string represents a valid ipv6 address :param address: String representing address :return: True if valid address, else false sABCDEFabcdef0123456789:RZs::it:ii RYisNot valid ipv suffixR[ticss!|]}t|dkVqdS(iN(R^(t.0tx((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pys sc3s|]}|kVqdS(N((RgRh(tallowed(s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pys s( R\R^R]RdtpoptextendtappendR`talltjoin(Rat has_zerosRbtp((Ris6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_valid_ip6_addresss0 $ %  *#cstjdtjtjd}t|r4tSt|rDtSt|dkrZtS|j|rmtS|ddkr|d }nt fd|j dDS(s 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 s(?!-)[A-Z0-9-]{1,63}(?s( tretcompilet IGNORECASERdR`RqR^R\RrRmR](tip_hnt digits_only((Ris6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_is_valid_network_names   c Csd}|rt}n|jddddddtjdtf|jdd dd d td d dd|dd|jdddddd|dd|jdddddd|dd|jdddd dd|d ddd|jd d!dddd"|d#tdd$|jd%d&dddd'|d#tdd(|jd)d*dd dd+|dd,d t|jd-dddd.|dd/|jd0dddd1|d#tdd2|jd3d4dddd5|d#tdd6|rt}d7|d+|<|j |nd8S(9s 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. Rfs-vs --versiontactiontversions%s %sis-us--uritstorettypetmetavarstdests%surithelps,Uniform resource identifier (env LSMCLI_URI)s-Ps--promptt store_trues%sprompts)Prompt for password (env LSMCLI_PASSWORD)s-Hs--humans%shumans:Print sizes in human readable format (e.g., MiB, GiB, TiB)s-ts--terses%ssepss;Print output in terse form with "SEP" as a record separators-es--enums%senumtdefaults3Display enumerated types as numbers instead of texts-fs--forces%sforces3Bypass confirmation prompt for data loss operationss-ws--waits%swaits+Command timeout value in ms (default = 30s)s--headers%sheadersInclude the header with terses-bs%s_asyncsmRun the command async. Instead of waiting for completion. Command will exit(7) and job id written to stdout.s-ss--scripts%sscriptsMDisplaying data in script friendly way with additional information(if exists)i0uN( t_CHILD_OPTION_DST_PREFIXt add_argumentR%targvRR(R\RTtdictt set_defaults(t arg_parsertis_childtprefixt default_dict((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_add_common_optionss\   cCslg|_y1t|jdkr9tj|j|_nWn+tk rg}|jtjkrhqhnX|S(Ni( tsd_pathsR^tvpd83Rt vpd83_searchRR*R t NO_SUPPORT(tlsm_objtlsm_err((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt _add_sd_pathsXs  R$cBseZdZdZRS(cOs tj|||||_dS(s, Class represents an error. N(R2t__init__tmsg(tselftmessagetargstkwargs((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRescCs$dtjjtjd|jfS(Ns%s: error: %s i(tostpathtbasenameR%RR(R((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt__str__ls(t__name__t __module__RR(((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyR$ds titemcCsKx!|D]}|j|kr|SqW|rCtd||fndSdS(Ns%s with ID %s not found!(tidR$R!(tltthe_idt friendly_namet raise_errorR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt _get_itemus  cCs*t|}|r|Std|dS(sT Custom value checker for hostname/IP address :param addr: :return: s%s is invalid IP or hostnameN(RxR(taddrRJ((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_check_network_hosts tVOLUMEStPOOLStFSt SNAPSHOTStEXPORTStNFS_CLIENT_AUTHt ACCESS_GROUPStSYSTEMStDISKStPLUGINSt TARGET_PORTSt BATTERIEStDEFAULTtTHINtFULLsprovisioning type: s, tCLONEtCOPYt MIRROR_ASYNCt MIRROR_SYNCsreplication type: tENABLEtDISABLEsPolicy: tnames--policyR}sRtchoicesR|tWBtAUTOtWTsWrite cache polices: s' which stand for "write back", "auto", s"write through"s7Can use B, KiB, MiB, GiB, TiB, PiB postfix (IEC sizing)s--sysss System IDsmSearch by System ID. Only supported for: (VOLUMES, POOLS, FS, DISKS, ACCESS_GROUPS, TARGET_PORTS, BATTERIES)s--pools sPool IDs;Search by Pool ID. Only supported for: (VOLUMES, POOLS, FS)s--volss Volume IDsASearch by Volume ID. Only supported for: (VOLUMES, ACCESS_GROUPS)s--fsssFile System IDs=Search by FS ID. Only supported for: (FS, SNAPSHOTS, EXPORTS)s--agssAccess Group IDsGSearch by Access Group ID. Only supported for: (ACCESS_GROUPS, VOLUMES)s--inits s Initiator IDs--snaps s Snapshot IDs--exports s Export IDs --nfs-exportss6Search by NFS Export ID. Only supported for: (EXPORTS)s--disks s.Search by Disk ID. Only supported for: (DISKS)s--sizess--tgtss=Search by target port ID. Only supported for: (TARGET_PORTS)s--pathsLocal disk paths tlistsList records of different typesRs--typesList records of type: s s3 When listing SNAPSHOTS, it requires --fs .stoptionals job-statuss Retrieve information about a jobs--jobss job status idt capabilitiessRetrieves array capabilitiess plugin-infos(Retrieves plugin description and versions volume-createsCreates a volume (logical unit)s--names volume namess--provisioningRsvolume-raid-creates(Creates a RAIDed volume on hardware RAIDss>Free disks for new RAIDed volume. This is repeatable argument.RyRls --raid-types@RAID type for the new RAID group. Should be one of these: %ss --strip-sizes Strip size. svolume-raid-create-caps=Query capability of creating a RAIDed volume on hardware RAIDs volume-deletesDeletes a volume given its ids volume-resizesRe-sizes a volumes s New size. %ssvolume-replicates:Creates a new volume and replicates provided volume to it.ss"The name for New replicated volumes --rep-types s[Pool ID to contain the new volume. By default, new volume will be created in the same pool.svolume-replicate-ranges3Replicates a portion of a volume to existing volumes --src-vols sSource volume ids --dst-vols sDestination volume ids sReplication type: CLONE, COPYs --src-startss>Source volume start block number. This is repeatable argument.s --dst-startssCDestination volume start block number. This is repeatable argument.s--counts s;Number of blocks to replicate. This is repeatable argument.s!volume-replicate-range-block-sizes2Size of each replicated block on a system in bytessvolume-dependantss>Returns True if volume has a dependant child, like replicationsvolume-dependants-rmsRemoves volume dependenciessvolume-access-groups4Lists the access group(s) that have access to volumes volume-masks>Grants access to an access group to a volume, like LUN Maskings volume-unmasks7Revoke the access of specified access group to a volumes volume-enablesEnable block access of a volumesvolume-disables Disable block access of a volumesvolume-raid-infosQuery volume RAID informationsvolume-ident-led-ons!Enable the IDENT LED for a volumesTargeted volume. svolume-ident-led-offs"Disable the IDENT LED for a volumessystem-read-cache-pct-updates,Change the read cache percentage of a systemsTargeted system. s --read-pctsRead cache percentage. spool-member-infos!Query Pool membership informationsaccess-group-createsCreate an access groups s$Human readable name for access groupsaccess-group-adds+Add an initiator into existing access groupsaccess-group-removes.Remove an initiator from existing access groupsaccess-group-deletesDeletes an access groupsaccess-group-volumessBLists the volumes that the access group has been granted access tos iscsi-chaps5Configures iSCSI inbound/outbound CHAP authentications --in-users sInbound chap user names --in-passs sInbound chap passwords --out-users sOutbound chap user names --out-passs sOutbound chap passwords fs-createsCreates a file systems sname of the file systems fs-deletesDelete a filesystems fs-resizesRe-sizes a filesystems fs-exportsExport a filesystem via NFS.s --exportpaths s(NFS server export path. e.g. '/foo/bar'.s --anonuids s%UID(User ID) to map to anonymous users --anongids s&GID(Group ID) to map to anonymous users --auth-types sNFS client authentication types --root-hosts s9The host/IP has root access. This is repeatable argument.s --ro-hosts srThe host/IP has readonly access. This is repeatable argument. At least one '--ro-host' or '--rw-host' is required.s --rw-hosts ssThe host/IP has readwrite access. This is repeatable argument. At least one '--ro-host' or '--rw-host' is required.s fs-unexportsRemove an NFS exportsfs-clonesCreates a file system clones--src-fss s&The ID of existing source file system.s --dst-names s3The name for newly created destination file system.s--backing-snapshots sbacking snapshot idsfs-snap-createsCreates a snapshots s'The human friendly name of new snapshotsfs-snap-deletesDeletes a snapshotsfs-snap-restores;Restores a FS or specified files to previous snapshot states--files skOnly restore provided file Without this argument, all files will be restored This is a repeatable argument.s--fileasssGstore restore file name to another name. This is a repeatable argument.s fs-dependantssHReturns True if filesystem has a child dependency(clone/snapshot) existss-For file check This is a repeatable argument.sfs-dependants-rms Removes file system dependenciessHFile or files to remove dependencies for. This is a repeatable argument.s file-clones,Creates a clone of a file (thin provisioned)s--srcssCsource file to clone (relative path) This is a repeatable argument.s--dstss@Destination file (relative path), this is a repeatable argument.sQuery local disk informationsvolume-cache-infos"Query volume RAM cache informationsvolume-phy-disk-cache-updates)Update volume physical disk cache settingsvolume-read-cache-policy-updatesUpdate volume read cache policys volume-write-cache-policy-updates Update volume write cache policys/Turn on the identification LED for a local disks0Turn off the identification LED for a local disks&Turn on the fault LED for a local disks'Turn off the fault LED for a local disktlsslist --type systemstlpslist --type poolstlvslist --type volumestldslist --type diskstlaslist --type access_groupstlfslist --type fstltslist --type target_portsR4Rptvctvrctvrcctvdtvrtvmtvutvetvitactaatartadtvritvilontvilofftsrcputpmitldltlbslist --type batteriestvcitvpdcutvrcputvwcputldilontldilofftldflontldfloffR"cBseZdZdZdZdZedZedZdZ dZ edZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZedZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%ed#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9Z<d:Z=dFd;Z?dFd<Z@d=ZAd>ZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIRS(Gs' Command line interface class. cCsd|jjs\|rdnd}td|t}|jdkrKtStdtSntSdS(s1 Give the user a chance to bail. twilltmaysxWarning: You are about to do an operation that %s cause data to be lost! Press [Y|y] to continue, any other key to aborttYsOperation aborted!N(RtforceRRGRVR`R\(RtdeletingRtpressed((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytconfirm_promptTs   cCst}t|dkrdStj}t}|jjr@t}n|jjrUt}n|jjrmtj }ntj |d|d|jj d|jj d|jjd|d|dS(Nit display_wayt flag_humant flag_enumtsplittertflag_with_headertflag_dsp_all_data( R\R^RtDISPLAY_WAY_DEFAULTR`RtseptheadertscripttDISPLAY_WAY_SCRIPTt display_datathumantenum(Rtobjectst display_allRR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRks         cCshg}d}tj|}x9|D]1}|j|\}}|jt||q"W|j|dS(Ns<}{>(Rtavailable_pluginsR]RlRR(RtdRtpluginsRptdescRz((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytdisplay_available_pluginss cCsXg}xKtjdD]<}|tkrC|jt|jdq|j|qW|S(sb 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: it (R%RtaliasesRkR]Rl(RSRc((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt handle_aliass  cCsCd}x6ttjD]"\}}|dj||7}qW|S(Nscommand aliases: s {0:<18} Alias of '{1}' (tsortedRtitemstformat(RStktv((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytalias_help_textsc CsZtdt}t|dttdddtjddt}t|dt|jdd }xtD]}|j |d d |d d |gdt}|j d }xA|j dgD]-}|d }|d =|j |dt|qW|j d}xV|j dgD]B}|d } |d =t | tsF| f} n|j | |qW|jdt||d jddqmWttjdkr|jtdn||_|jdtj} xt| jD]k\} } | jtr| tt} t| | dks<t| | tkrRt| | | qRqqW| S(s3 Command line interface parameters tadd_helpRt descriptions^The libStorageMgmt command line interface. Run %(prog)s -h for more on each command.tepilogsh Copyright 2012-2018 Red Hat, Inc. Please report bugs to tformatter_classR}tcommandRRtparentsscmd required argumentsRtrequiredscmd optional argumentsRtfunct-RNiN( RR\RR`R"R Rtadd_subparserstcmdst add_parsertadd_argument_grouptgetRt isinstancettupleRtgetattrtreplaceR^R%Rt print_usageR3tparsert parse_argsRtvarsRt startswithRR!tsetattr(Rt parent_parserR t subparserstcmdt sub_parsertgrouptargRtflagst known_argsR R troot_k((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyR6sN        $   cCsQ|jjr1t|jjj|jjntdj|jjdS(sD Dump the supported nfs client authentication types s, N(RRRRnR4t export_auth(R((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt!display_nfs_client_authentications %c Csd}d}|jdf|jdf|jdf|jdf|jdf|jdf|jdf|jdff}xJ|D]B}|d ry|rt d ||d fq|\}}qyqyW||fS( Nt system_idtpool_idt volume_idtdisk_idtaccess_group_idtfs_idt nfs_export_idt tgt_port_idis,Search key specified more than once (%s, %s)i( R!R%tpooltvoltdisktagtfst nfs_exportttgtR$(Rt search_keyt search_valuet search_argstsa((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_get_search_key_values$         cCsstj|\}}|jdkrg}|dkr?d}n|dkrt|jj|jddt}|r|jj|}qn=|r|t j krt d|n|jj ||}|j td|Dn|jd krU|d krd}n|r6|tj kr6t d |n|j |jj||n|jd kr|d kryd}n|r|tj krt d|n|j |jj||n|jdkrL|jdkrt dn|r|d krt d|nt|jj|jd}|j |jj|n#|jdkr|dkrpd}n|r|tj krt d|n|j |jj||n|jdkr|rt dn|jn|jdkr|dkr d}n|dkrkt|jj |jddt}|r[|j |jj|S|j gSn(|r|tj krt d|n|j |jj||n|jdkr|rt dn|j |jjn|jdkrj|dkrd}n|r;|tj kr;t d|n|j td|jj||Dn|jd kr|d!krd}n|r|tj krt d"|n|j |jj||n|jd#kr|rt d$n|j ni|jd%kr\|r=|t!j kr=t d&|n|j |jj"||nt d'|jdS((NRR2RR4s Access GroupRs3Search key '%s' is not supported by volume listing.css|]}t|VqdS(N(R(RgR ((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pys sRR1s1Search key '%s' is not supported by pool listing.RR5Rs--fs requireds5Search key '%s' is not supported by snapshot listing.s File SystemRR6s6Search key '%s' is not supported by NFS Export listingRsCNFS client authentication type listing with search is not supportedRRs8Search key '%s' is not supported by Access Group listingRs+System listing with search is not supportedRR3s0Search key '%s' is not supported by disk listingcss|]}t|VqdS(N(R(RgR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pys bsRR7s7Search key '%s' is not supported by target port listingRs,Plugins listing with search is not supportedRs3Search key '%s' is not supported by battery listingsunsupported listing type=%s(#R"RCR|RR4t access_groupsR;R\t"volumes_accessible_by_access_groupRtSUPPORTED_SEARCH_KEYSR$tvolumesRRRtpoolsRR<R!t fs_snapshotsRtexportsR/R9taccess_groups_granted_to_volumeRtsystemsRtdisksRt target_portsRRt batteries(RRR?R@tlsm_volstlsm_agR<tlsm_vol((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyR s                               cCset|jj|jd}t|j\}}|jj|j|||}|j|gdS(NtSystem( RR4RLR%RMtinittaccess_group_createRR(RRtsystemRIt init_typet access_group((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRU|s  cCsit|jj|jd}t|j\}}|rO|jj|||S|jj|||SdS(Ns Access Group(RR4RDR;RMRTtaccess_group_initiator_addtaccess_group_initiator_delete(RRtopRQRIRW((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_add_rm_access_grp_initscCs |j|j|tgdS(N(RR\R`(RR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytaccess_group_addscCs |j|j|tgdS(N(RR\R\(RR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytaccess_group_removescCsW|jj}t||jd}|jj|}|jtd|DdS(Ns Access Groupcss|]}t|VqdS(N(R(RgR ((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pys s(R4RDRR;RERR(RRtaglR)tvols((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytaccess_group_volumessc CsOt|j\}}|tjkr:td|jn|jjrb|jj rbtdn|jjr|jj rtdn|jjr|jj rtdn|jj r|jj rtdn|jjr|jj r|jjo|jj rtdn|j j ||j|jj|jj|jj dS(Ns$--init "%s" is not a valid iSCSI IQNs--in-user requires --in-passs--in-pass requires --in-users--out-user requires --out-passs--out-pass requires --out-users?out-user and out-password only supported if inbound is supplied( RMRTRtINIT_TYPE_ISCSI_IQNR$Rtin_usertin_passtout_usertout_passR4tiscsi_chap_auth(RRRIRW((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt iscsi_chaps$  cCsAt|jj|jd}|jj|}|j|dS(NR(RR4RGR9RKR(RRR9tgroups((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytvolume_access_groupscCs4|jj}t||jd}|jj|S(Ns Access Group(R4RDRR;taccess_group_delete(RRR_R)((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRkscCsSt|jj|jd}|jtrO|jd|jj|dndS(Ns File Systems fs-delete(RR4R<RR`t _wait_for_itt fs_deleteR!(RRR<((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRmscCset|jj|jd}|jd|jj||j|j|j}|j |gdS(NRs fs-create( RR4RHR8Rlt fs_createRt_sizetsizeR(RRRpR<((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRns  cCst|jj|jd}|j|j}||jkrTttjdn|j t r|j d|jj ||}|j |gndS(Ns File SystemsSpecified size same as currents fs-resize(RR4R<RoRpt total_spaceRR tNO_STATE_CHANGERR\Rlt fs_resizeR(RRR<Rp((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRss cCst|jj|jd}d}|jrQt|jj||jd}n|jd|jj||j |}|j |gdS(NsSource File SystemtSnapshottfs_clone( RR4R<tsrc_fsR!tbacking_snapshotRIRlRutdst_nameR(RRRvtssR<((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRus !cCst|jj|jd}|jjrNt|jj||jd}nd}|jd|jj||j |j |ddS(Ns File SystemRtt fs_file_clone( RR4R<RRwRIR!RlRztsrctdst(RRR<Ry((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt file_clones !cCs/t|}|dkr+td|n|S(Nis$Incorrect size argument format: '%s'(RR$(RWt size_bytes((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRos  cCsW|jjdk r!|jj}nd}|r6d}nd}td|||fdS(NRet SUPPORTEDt UNSUPPORTEDs%s%s%s(RRR!R(RtcaptvalRWR ((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_cps c Cst|jj|jd}|jj|}t|jj}t|jtj}t j }|j j dk r|j j }nt}x|D]}d||sRcSs|jS(N(t dest_block(Rh((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRsR(tsort(trangesR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_check_overlaps   c Cst|jj|jd}t|jj|jd}t|j}|tjkrmt d|n|j }|j }|j }t | st |t |kot |kn rt dng}xtt |D]} t|| } t|| } t|| } | dkr=t dn| dkrXt dn| dkrst dn| | |jkrt d n| | |jkrt d n|jt| | | qWtj||jtr |jj||||ndS( Ns Source VolumesDestination Volumesinvalid replication type= %ss@Differing numbers of src_start, dest_start, and count parametersis--count: value < 0s--src-start: value < 0s--dst_start: value < 0s#--src-start + --count > source sizes(--dst-start + --count > destination size(RR4RGtsrc_voltdst_volRRRRR$t src_startt dst_starttcountR^RRPt num_of_blocksRlR R"RRR\tvolume_replicate_range( RRR{R|Rt src_startst dst_startstcountsRtbRRR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRs>     /    cCs8t|jj|jd}t|jj|dS(NRS(RR4RLR%Rt!volume_replicate_range_block_size(RRRW((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRscCsSt|jj|jd}t|jj|jd}|jj||dS(NRs Access Group(RR4RGR9RDR;t volume_mask(RRR9R;((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRscCsOt|jj|jd}t|jj|jd}|jj||S(Ns Access GroupR(RR4RDR;RGR9t volume_unmask(RRR;R9((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRscCst|jj|jd}|j|j}||j|jkr[tt j dn|j t r|j d|jj||}|jt|gndS(NRsSpecified size same as currenttresize(RR4RGR9RoRpt block_sizeRRR RrRR\Rlt volume_resizeRR(RRR RpR9((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRs cCs2t|jj|jd}|jj|dS(NR(RR4RGR9t volume_enable(RRR ((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRscCs2t|jj|jd}|jj|dS(NR(RR4RGR9tvolume_disable(RRR ((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRscCs2t|jj|jd}|jj|dS(Ns NFS Export(RR4RJtexportt export_remove(RRR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt fs_unexportsc Cst|jj|jd}t|jdkrWt|jdkrWtdn|jj|j|j |j |j|j|j |j |j d }|j|gdS(Ns File Systemis& please specify --ro-host or --rw-host(RR4R<R^trw_hosttro_hostR$t export_fsRt exportpatht root_hosttanonuidtanongidt auth_typeR!R(RRR<R((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt fs_export!s  cCs>t|jj|jd}|jj|}t|dS(NR(RR4RGR9tvolume_child_dependencyR(RRR RS((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytvolume_dependants6scCsAt|jj|jd}|jd|jj|ddS(NRsvolume-dependant-rm(RR4RGR9Rltvolume_child_dependency_rmR!(RRR ((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytvolume_dependants_rm<s cCsJt|jj|jd}|jt|j|jj|gdS(NR(RR4RGR9RRRtvolume_raid_info(RRRR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRAscCsJt|jj|jd}|jt|j|jj|gdS(NR(RR4RHR8RRRtpool_member_info(RRtlsm_pool((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRHscCs\tj|j}|jj}g|D]}|j|jkr(|^q(}t|t|jkrtt j ddj t |jt d|Dng|D]}|j tj@s|j^q}t|dkrtt jddj |n|jr!t|j}n tj}|jt|jj|j|||gdS(NsDisk ID %s not founds, css|]}|jVqdS(N(R(RgR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pys XsisDisk %s is not free(Rtraid_type_str_to_lsmt raid_typeR4RMRR:R^RR tNOT_FOUND_DISKRntsettstatusRt STATUS_FREEt DISK_NOT_FREEt strip_sizeRRtVCR_STRIP_SIZE_DEFAULTRRtvolume_raid_createR(RRRt all_lsm_disksRt lsm_diskst busy_disksR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyROs*+3    cCsJt|jj|jd}|jt|j|jj|gdS(NRS(RR4RLR%RRRtvolume_raid_create_cap_get(RRtlsm_sys((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytvolume_raid_create_caplscCs2t|jj|jd}|jj|dS(NR(RR4RGR9tvolume_ident_led_on(RRt lsm_volume((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRqscCs2t|jj|jd}|jj|dS(NR(RR4RGR9tvolume_ident_led_off(RRR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRvscCst|jj|jd}yt|j}Wn+tk r^}ttj t |nX|jj ||t|jj|jd}|j |gdS(NRS( RR4RLR%R_tread_pctRQRR tINVALID_ARGUMENTR(tsystem_read_cache_pct_updateR(RRt lsm_systemRR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyR{scCsDt|jj|jd}|jj||j}t|dS(Ns File System(RR4R<tfs_child_dependencyR R(RRR<RS((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt fs_dependantsscCsGt|jj|jd}|jd|jj||jddS(Ns File Systemsfs-dependants-rm(RR4R<Rltfs_child_dependency_rmR R!(RRR<((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytfs_dependants_rms    c Csd}tjjdd}tjj|s2dSt|}x|D]}|jjdriqHnyTg|jddD]}|j^q\}}||krt |||nWqHt k rqHXqHWWdQXdS( so Set uri from config file. Will be overridden by cmdline option or env var if present. turit~s/.lsmcliNt#t=i(suri( RRt expandusertexiststopentlstripR#R]tstripR$RQ(Rtallowed_config_optionst config_pathtftlineRhRR((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyt_read_configfiles 1  cCs)|jjjjddtkr%tStS(sU Return True if current command is one of _CONNECTION_FREE_COMMANDS. RNR(RRRRt_CONNECTION_FREE_COMMANDSR`R\(R((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pytis_connection_free_cmds cCsd|_d|_d|_d|_|j|_d|_t|jj |_ |j sj|j dkryt dn|j rdS|j tjddk rtjd|_ntjd|_|jjdk r|jj|_n|jdkrGd|jkr8|jjdkr8d|_d|_qGt dn|jjretj|_n|jdk rt|j}|d dkrt d qndS( Nis0[-w|--wait] requires a non-zero positive integert LSMCLI_URItLSMCLI_PASSWORDR|Rssim://s"--uri missing or export LSMCLI_URItusernames+password specified with no user name in uri(R!RR4R t unknown_argsR6RtcleanupR_twaitttmoR$RRRtgetenvtpasswordR|tprompttgetpassR (Rtu((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyRs8       !   cCs0|jr|jn|r,tj|ndS(N(R R%R3(Rtec((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyR1s  cCs|jr"|jj|jn|rkt||_|jj|j|j|j|jj |_ nOtt |j|j|j|_t j drtdn|jj|_ |jj|j|jdS(s- Process the parsed command. tLSM_DEBUG_PLUGINs8Attach debugger to plug-in, press when ready...N(RRRR R4tplugin_registerRRR tplugin_unregisterR RRRtinputtcloseR1(RR6((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyR#s $ c Csg}itjd6tjd6tjd6tjd6tjd6tjd6tjd6}x%tjD]}idd6t j d6t j d6dd6t j d6t j d6t jd6}x|jD]v}y|||||  p                  2                    /  *     (RRR(RRRR(lRR%RRsRR?R=targparseRRRtsixtlsmRRRRRRR R R R R RRRRRRRtlsm.lsmcli.data_displayRRRRRRRRRRRtPY3R_RPt collectionsRt ImportErrort ordereddictR!R:RGRMRORTRRXRdRqRxR\RRR2R$R`RRt list_choicestprovision_typesRntprovision_helptreplicate_typestreplicate_helpt policy_typest policy_helpRt policy_opttwrite_cache_policy_typestwrite_cache_policy_helptwrite_cache_policy_optt size_helpt sys_id_opttcopytsys_id_filter_optt pool_id_opttpool_id_filter_optt vol_id_opttvol_id_filter_optt fs_id_opttfs_id_filter_optt ag_id_opttag_id_filter_optt init_id_optt snap_id_optt export_id_opttnfs_export_id_filter_opttdisk_id_filter_opttsize_optttgt_id_filter_opttlocal_disk_path_opttVOL_CREATE_RAID_TYPES_STRtANON_UID_GID_NARRtobjectR"(((s6/usr/lib/python2.7/site-packages/lsm/lsmcli/cmdline.pyts        vF     -     *  G