PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  #^c@sdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZyddlZddlZWnek reZZnXddlZddlmZddlmZmZmZejrZeZddl Z n ddl!Z ej"re#eej$dnddl%m&Z&ddl%m'Z'dd l%m(Z(dd l)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2dd l3m4Z4m5Z5dd l6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<dd l=m>Z>ddl%m?Z?ddl@mAZAddlBmCZCddlDZDejEeFZGdZHdZIde'jJfdYZKde&jLfdYZMde&jNfdYZOde&jNfdYZPde&jNfdYZQeMePeQfZRdeSfdYZTde jUfd YZVd!e jWfd"YZXd#e'jYfd$YZZd%e jUfd&YZ[eZeKePeMeOfZ\d'Z]dS((s+ Functionality for Command Line Interface. i(tprint_functionN(tinput(tcheck_client_configurationtget_terminal_heightt open_in_pagersutf-8(tfrontend(tbackend(tplugable( t PublicErrort CommandErrort HelpErrort InternalErrortNoSuchNamespaceErrortValidationErrortNotFoundtNotConfiguredErrort PromptFailed(tCLI_TABtLDAP_GENERALIZED_TIME_FORMAT(tFilet BinaryFiletStrtEnumtAnytFlag(t_(tapi(tDNSName(t ScriptErrorcCs%t|tst|jddS(sl Takes a Python identifier and transforms it into form suitable for the Command Line Interface. Rt-(t isinstancetstrtAssertionErrortreplace(tname((s./usr/lib/python2.7/site-packages/ipalib/cli.pytto_cliRscCst|jddS(sh Takes a string from the Command Line Interface and transforms it into a Python identifier. RR(RR!(tcli_name((s./usr/lib/python2.7/site-packages/ipalib/cli.pytfrom_cli[sttextuicBseZdZdZd&dZdZejrHdZ dZ ndZ dZ d&dZ d Z d Z d&d Zd&d Zd dZd dZdd edZd idgedZd&d&d&edd dZd&d&d&edd dZeedddZdZdZdZdZdZd&dZdZed Z d!Z!d&d&e"d"Z#d&d#Z$ed$Z%ed%Z&RS('s; Backend plugin to nicely format output to stdout. c CsrtjjrnyHtjtjtjtjddddd}tj d|dSWqnt k rjqnXndS(s Return the width (in characters) of output tty. If stdout is not a tty, this method will return ``None``. tHHHHiiN( tsyststdouttisattytfcntltioctlttermiost TIOCGWINSZtstructtpacktunpacktIOErrortNone(tselftwinsize((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt get_tty_widthhs cst|ttfkr4tdtt|fnt|dkrJdSdkrjtd|DStfd|DS(s Return the max width (in characters) of a specified column. For example: >>> ui = textui(api) >>> rows = [ ... ('a', 'package'), ... ('an', 'egg'), ... ] >>> ui.max_col_width(rows, col=0) # len('an') 2 >>> ui.max_col_width(rows, col=1) # len('package') 7 >>> ui.max_col_width(['a', 'cherry', 'py']) # len('cherry') 6 srows: need %r or %r; got %ricss|]}t|VqdS(N(tlen(t.0trow((s./usr/lib/python2.7/site-packages/ipalib/cli.pys sc3s|]}t|VqdS(N(R7(R8R9(tcol(s./usr/lib/python2.7/site-packages/ipalib/cli.pys sN(ttypetlistttuplet TypeErrorR7R3tmax(R4trowsR:((R:s./usr/lib/python2.7/site-packages/ipalib/cli.pyt max_col_widthys cCsA|tjtjfkstt|dddkr:dS|jS(NtencodingsUTF-8(R(tstdinR)R tgetattrR3RB(R4tstream((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt__get_encodingscsgt|tkr1jtj}|j|St|ttfkrctfd|DS|S(s1 Decode text from stdin. c3s|]}j|VqdS(N(tdecode(R8tv(R4(s./usr/lib/python2.7/site-packages/ipalib/cli.pys s(R;tbytest_textui__get_encodingR(RCRGR<R=(R4tvalueRB((R4s./usr/lib/python2.7/site-packages/ipalib/cli.pyRGs  cCs7t|tkst|jtj}|j|S(s; Encode text for output to stdout. (R;tunicodeR RJR(R)tencode(R4t unicode_textRB((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRMscCs|S(N((R4RK((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRGscCs|S(N((R4RK((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRMscCs(|dks|dkr ||S||S(Ni(R3(R4tntsingulartplural((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt choose_numberscCskt|tkr(tj|jdSt|tjkrJ|jtSt|t rct |S|SdS(s Convert a binary value to base64. We know a value is binary if it is a python bytes type, otherwise it is a plain string. This function also converts datetime and DNSName values to string. tasciiN( R;RItbase64t b64encodeRGtdatetimetstrftimeRRRRL(R4RK((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt encode_binarys  cCstt|dS(s? Print exactly like ``print`` statement would. N(tprintRL(R4tstring((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_plainscCsb|dkr|j}n|dk rN|t|krN||d d}ntt|dS(s Force printing on a single line, using ellipsis if needed. For example: >>> ui = textui(api) >>> ui.print_line('This line can fit!', width=18) This line can fit! >>> ui.print_line('This line wont quite fit!', width=18) This line wont ... The above example aside, you normally should not specify the ``width``. When you don't, it is automatically determined by calling `textui.get_tty_width()`. is...N(R3R6R7RYRL(R4ttexttwidth((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_lines  cCsL|dkr|j}nx*tj|j|D]}t|q4WdS(s+ Print a paragraph, automatically word-wrapping to tty width. For example: >>> text = ''' ... Python is a dynamic object-oriented programming language that can ... be used for many kinds of software development. ... ''' >>> ui = textui(api) >>> ui.print_paragraph(text, width=45) Python is a dynamic object-oriented programming language that can be used for many kinds of software development. The above example aside, you normally should not specify the ``width``. When you don't, it is automatically determined by calling `textui.get_tty_width()`. The word-wrapping is done using the Python ``textwrap`` module. See: http://docs.python.org/library/textwrap.html N(R3R6ttextwraptwraptstripRY(R4R\R]tline((s./usr/lib/python2.7/site-packages/ipalib/cli.pytprint_paragraphs icCstt||dS(s~ Print at specified indentation level. For example: >>> ui = textui(api) >>> ui.print_indented('One indentation level.') One indentation level. >>> ui.print_indented('Two indentation levels.', indent=2) Two indentation levels. >>> ui.print_indented('No indentation.', indent=0) No indentation. N(RYR(R4R\tindent((s./usr/lib/python2.7/site-packages/ipalib/cli.pytprint_indentedscCs>x7|D]/\}}|jd||j|f|qWdS(s Print (key = value) pairs, one pair per line. For example: >>> items = [ ... ('in_server', True), ... ('mode', u'production'), ... ] >>> ui = textui(api) >>> ui.print_keyval(items) in_server = True mode = u'production' >>> ui.print_keyval(items, indent=0) in_server = True mode = u'production' Also see `textui.print_indented`. s%s = %rN(ReRX(R4R@RdtkeyRK((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_keyvalss%s: %sc Cs9t|tjstt|ttfsS|j|||j|f|n|rx|D])}|j|||j|f|q`Wng|D]}|j|^q}t|dkr't |dttfkr'x@|D]8}dj |}|j|||j|f|qWdSt|dkrUdj d|D}ndS|j } | r|rdt |dt|df} | t| 8} t j|| d t}t|dkrd g}qnd } |g}|j|||df|x)|d D]} |jd| | fqWdS( s Print an ldap attribute. For example: >>> attr = 'dn' >>> ui = textui(api) >>> ui.print_attribute(attr, u'dc=example,dc=com') dn: dc=example,dc=com >>> attr = 'objectClass' >>> ui.print_attribute(attr, [u'top', u'someClass'], one_value_per_line=False) objectClass: top, someClass >>> ui.print_attribute(attr, [u'top', u'someClass']) objectClass: top objectClass: someClass is: Ns, css|]}t|VqdS(N(R(R8RH((s./usr/lib/python2.7/site-packages/ipalib/cli.pys Mss%s%st itbreak_long_wordsui(Rtsixt string_typesR R<R=ReRXR7R;tjoinR6RR_R`tFalseR[( R4tattrRKtformatRdtone_value_per_lineRHtlR\tline_lents_indentRb((s./usr/lib/python2.7/site-packages/ipalib/cli.pytprint_attribute)s:& *". '   tdncsttsttts*tt|ttfsEtfd}x.|D]&krj|=qjqjWxtD]|qWdS(s+ Print an ldap entry dict. csWkr3jddn jdddS(NRdRp(Rt(ta(Rntattr_maptentryRdRpR4(s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_attrks  !N(RtdictR R<R=tsorted(R4RxRdRwt attr_orderRpRy((RnRwRxRdRpR4s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_entry1bs   c Csnt|ttfstt}xF|D]>} |sAtdnt}|j| ||||||q(WdS(Nt(RR<R=R tTrueRYRmt print_entry( R4tentriestordertlabelstflagst print_allRoRdtfirstRx((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_entries|s  c Cs1t|ttfr$t|}nt|ts9t|dkrWt}t}nt}|dk rxr|D]g} | |krqpn|j| | } |j| g} || } d| kr| dddgdgkrqpnt| trPt j | dkr qpn|j || df||j | |||||d|dnt| ttfrt d| Dr|j| d|||j| ||||||dn|j| | ||||| =qpWn|r-xFt|D]5} |j| | } |j| || |||qWndS( Ntsuppress_emptyuR~iRdicss|]}t|tVqdS(N(RRz(R8tval((s./usr/lib/python2.7/site-packages/ipalib/cli.pys s((RR<R=RzR R3RRmtgetRt entry_countReRtallRtRR{( R4RxRRRRRoRdRpRftlabeltflagRK((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRsJ        iRcCst|tjstt|dks0t|t|}|rY|j||n|j|||r|j||ndS(s Print a string with a dashed line above and/or below. For example: >>> ui = textui(api) >>> ui.print_dashed('Dashed above and below.') ----------------------- Dashed above and below. ----------------------- >>> ui.print_dashed('Only dashed below.', above=False) Only dashed below. ------------------ >>> ui.print_dashed('Only dashed above.', below=False) ------------------ Only dashed above. iN(RRjRkR R7Re(R4RZtabovetbelowRdtdashtdashes((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_dashedscCs|j|dddddS(s Print a primary header at indentation level 0. For example: >>> ui = textui(api) >>> ui.print_h1('A primary header') ================ A primary header ================ RdiRt=N(R(R4R\((s./usr/lib/python2.7/site-packages/ipalib/cli.pytprint_h1s cCs|j|dddddS(s Print a secondary header at indentation level 1. For example: >>> ui = textui(api) >>> ui.print_h2('A secondary header') ------------------ A secondary header ------------------ RdiRRN(R(R4R\((s./usr/lib/python2.7/site-packages/ipalib/cli.pytprint_h2s cCs|jdt|dS(se Print a command name. The typical use for this is to mark the start of output from a command. For example, a hypothetical ``show_status`` command would output something like this: >>> ui = textui(api) >>> ui.print_name('show_status') ------------ show-status: ------------ s%s:N(RR#(R4R"((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_namescCs|j||dS(N(R(R4tmsgtoutput((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_headerscCs|j|dS(s Print a summary at the end of a comand's output. For example: >>> ui = textui(api) >>> ui.print_summary('Added user "jdoe"') ----------------- Added user "jdoe" ----------------- N(R(R4R((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_summarys cCsbt|tk rBt|tttfks3tt|}n|j|j|||dS(s Print a summary count. The typical use for this is to print the number of items returned by a command, especially when this return count can vary. This preferably should be used as a summary and should be the final text a command outputs. For example: >>> ui = textui(api) >>> ui.print_count(1, '%d goose', '%d geese') ------- 1 goose ------- >>> ui.print_count(['Don', 'Sue'], 'Found %d user', 'Found %d users') ------------- Found 2 users ------------- If ``count`` is not an integer, it must be a list or tuple, and then ``len(count)`` is used as the count. N( R;tintR<R=RzR R7RRR(R4tcountRPRQ((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_count s !cCstdt|dS(Ns ** %s **(RYRL(R4R\((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt print_error*scCsTy |j||j|SWn-ttfk rOttd|nXdS(sPrompt user for input Handles encoding the prompt and decoding the input. On end of stream or ctrl+c, raise PromptFailed. R"N(RGRMtKeyboardInterrupttEOFErrorRYR(R4tpromptRt prompt_func((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt prompt_helper-s  cCs|jd||fdS(Ns >>> %s: %s(R[(R4t attributeterror((s./usr/lib/python2.7/site-packages/ipalib/cli.pytprint_prompt_attribute_error9scCsV|rd|}n d|}|dkr6d|}nd||f}|j||S(s( Prompt user for input. u[%s]u%su%s: u %s [%s]: N(R3R(R4Rtdefaultt get_valuestoptionalR((s./usr/lib/python2.7/site-packages/ipalib/cli.pyR<s    cCsd }|d k r*|r!d}q*d}n|rCd||f}n d|}x^tr|j||j}|d kr~tS|d krtS|d k rP|d krP|SqPW|S( s Prompt user for yes/no input. This method returns True/False according to user response. Parameter "default" should be True, False or None If Default parameter is not None, user can enter an empty input instead of Yes/No answer. Value passed to Default is returned in that case. If Default parameter is None, user is asked for Yes/No answer until a correct answer is provided. Answer is then returned. tYestNou%s Yes/No (default %s): u %s Yes/No: uyesuyununouN(uyesuy(ununo(R3RRtlowerRm(R4RRtdefault_promptRtdata((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt prompt_yesnoKs"       cCstjjrdt|}ttdtd|}xtr|j||dtj}|sl|S|j||dtj}||kr|S|j tdqAWn|j tjj j SdS(sx Prompt user for a password or read it in via stdin depending on whether there is a tty or not. u%s: s!Enter %(label)s again to verify: RRsPasswords do not match!N( R(RCR*RLRRzRRtgetpassRRGtreadlineRa(R4RtconfirmRt repeat_prompttpw1tpw2((s./usr/lib/python2.7/site-packages/ipalib/cli.pytprompt_passwordqs  c Cs|jj stjj r!dSt|}|dkrQtdtdnd}x`|D]X}i}x$|D]} |j| d|| ;s(Rt _builtinsRtCommandt get_pluginR"tNO_CLIRR3RRRR?R7RR<t_mtltsuperRt _on_finalize(R4tcRRRRRttopics((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRsH     & #!#,c s|dkrtj}n|j|}t||dkrV|jjj|dSdkrs|j|dS|j kr|j |n<|j kr|j }|j rt dn|jjj|j|ntfd|j jDr#|j |ndkrd}x|j D]|}||j j|jk rfq?n|j ruq?nt|t|j}|jdjt|jj||jq?Wnt d|jdS(NRRc3s5|]+}t|dtkr|dkVqdS(iN(R;Rz(R8tt(R"(s./usr/lib/python2.7/site-packages/ipalib/cli.pys Sstcommandsis{0} {1}(R3R(R)RR%Rtparsert print_helpt print_topicsRtprint_commandsRRR tBackendtclit build_parsertanytvaluesRR"R?R7RRoR#tljusttsummaryR(R4RfRtoptionstwritertcmdRt cmd_plugin((R"s./usr/lib/python2.7/site-packages/ipalib/cli.pytrun?s>        %   )cCsr|j|}xRt|jjD];\}}|jdjt|j|j|dq%W|j dS(Ns{0} {1}i( RR{RtitemsRRoR#RRR(R4RRRR((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRds " 'c Cso|j|}||jkrt|j|dtkrx#|j|dD]X}|j|d|d}|j|d}|jdjt|j||qMWn||jkr|j|d}|j|d}ng}x|jD]y}t|j|dtk rqn||j|dkr6qn|j|d|d}|j|d|d}PqW|j|\}} ||j krt |dkrt d|n|j||rW|j|jt dx<|D]4} |jdjt| j j|| jqW|j|jt d|jt dn|j|jdS( Niiis {0} {1}RsTopic commands:sTo get command help, use:s ipa --help(RRR;RzRRoR#RRRR7R RR"RR( R4RRRtsubtopicRRRRt_topicR((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRlsF, #!   &  N(RRRtobjectRRRt takes_argsRt takes_optionsR=t has_outputR3RRRRRRR(((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRs    8% t show_mappingscBsAeZdZeddedfZeZdZ dZ RS(sA Show mapping of LDAP attributes to command-line option. t command_nameRs Command namecKst|}||jkr-td|n|j|j}d d g}t|dd}x`|D]U}|jrd|jkrqgn|j|j|jft |t|j}qgWx7|D]/}t t |dj |d|d qWdS( NR"t ParametersLDAP attributes =========s==============itwebuis : i(RsLDAP attribute(s =========s==============( R%RR RR7texcludeRR$t param_specR?RYR#R(R4RRtparamstoutRtparamtitem((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRs   N( RRRRRR R=R R3RR(((s./usr/lib/python2.7/site-packages/ipalib/cli.pyR s   tconsolecBs8eZdZdZeZdZdZddZ RS(sStart the IPA interactive Python console, or run a script. An IPA API object is initialized and made available in the `api` global variable. s filename?cstjdtjtj|jtjjt j j dytj Wnt k renXfd}tj|dS(Ns tab: completesconsole.historycsztjj}tjj|s4tj|ntjdytjWn!tk rut j dnXdS(Ni2sUnable to store history %s( tostpathtdirnametisdirtmakedirsRtset_history_lengthtwrite_history_fileR2tloggert exception(t directory(thistory(s./usr/lib/python2.7/site-packages/ipalib/cli.pyt save_historys  (Rtparse_and_bindt set_completert rlcompletert CompletertcompleteRRRlRRtdot_ipatread_history_fileR2tatexittregister(R4tlocalR#((R"s./usr/lib/python2.7/site-packages/ipalib/cli.pyt_setup_tab_completions   cJsed|jdejde}|ry%e|}|j}WdQXWn0ek r~}ejd|j |j fnXy3e ||dde j }|e|fdUWqek rejejdqXn8edk r|j|nejdjd d |dS(NRtppt __builtins__s%s: %stexecRis s'(Custom IPA interactive Python console)s api: IPA API objects pp: pretty printerR-(s'(Custom IPA interactive Python console)s api: IPA API objects pp: pretty printer(RzRtpprinttbuiltinstopentreadR2R(texittfilenametstrerrortcompileRt compiler_flagtglobalsRt tracebackt print_excRR3R.tcodetinteractRl(R4R7RR-tftsourceRtcompiled((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRs8   !     (s filename?N( RRRR R=R R3RR.R(((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRs   tshow_apicBs;eZdZdZdZddZdZddZRS(s%Show attributes on dynamic API objects namespaces*c CsJ|dkrt|j}n8x/|D]'}||jkr%td|q%q%W|}|j|}td|D}|jjjdt }xq|D]i}|ddkr| rt dn|rt }nt dd|d|dj ||d fqWt |dkr#d }nd t |}|jjj|dS( NR"css|]}t|dVqdS(iN(R7(R8Rq((s./usr/lib/python2.7/site-packages/ipalib/cli.pys sRiR~s%s%s %rRhiis1 attribute shown.s%d attributes show.(R3R=RR t_show_api__traverseR?RR&RRRYRmRR7R( R4t namespacestnamesR"tlinestmlRRbR((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRs.       cCs?g}x2|D]*}|j|}|jd|||q W|S(Ns%s(Rt_show_api__traverse_namespace(R4RFRGR"t namespace((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt __traverse"s   ic Cs|j|||fx|D]}||}|j|d||ft|ds\qnxY|D]Q}||}t|tjrct|dkrc|j||||dqcqcWqWdS(Nit__iter__ii(RthasattrRRt APINameSpaceR7RI( R4R"RJRGttabt member_nametmemberRORn((s./usr/lib/python2.7/site-packages/ipalib/cli.pyt__traverse_namespace)s    $(s namespaces*N( RRRR R3RRRDRI(((s./usr/lib/python2.7/site-packages/ipalib/cli.pyRCs   t CollectorcBs#eZdZdZdZRS(cCstj|didS(Nt_Collector__options(R t __setattr__(R4((s./usr/lib/python2.7/site-packages/ipalib/cli.pyR>scCsq||jkrM|j|}t|tkr>||f}qM||f}n||j|ReRR2R+R-R/RTR<RR&RR3Rjt six.movesRt ipalib.utilRRRRRRLR3t __builtin__RtreloadtsetdefaultencodingtipalibRRRt ipalib.errorsRR R R R R RRRtipalib.constantsRRtipalib.parametersRRRRRRt ipalib.textRRtipapython.dnsutilRtipapython.admintoolRRVt getLoggerRRR#R%RR&R}RRR RRCtcli_application_commandsR RStIndentedHelpFormatterRWRfRbt ExecutionerRRRR(((s./usr/lib/python2.7/site-packages/ipalib/cli.pyts                      @.  ^G8 $