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@s7dZddlZddlZddlmZddlmZddlmZddl m Z m Z ddl m Z mZmZmZddl mZdd lmZmZmZdd lmZdd lmZmZmZmZmZmZmZdd l m!Z!m"Z"dd l#m$Z$m%Z%ddl&m'Z'm(Z(ej)rJe*Z+nej,e-Z.dZ/dZ0dZ1dZ2de fdYZ3iZ4de3fdYZ5de5fdYZ6de5fdYZ7de3fdYZ8de fdYZ9de9e5fd YZ:d!e fd"YZ;dS(#s) Base classes for all front-end plugins. iN(t API_VERSION(t APIVersion(t NameSpace(tPlugint APINameSpace(t create_paramtParamtStrtFlag(tPassword(tOutputtEntryt ListOfEntries(t_(tZeroArgumentErrortMaxArgumentErrort OverlapErrort VersionErrort OptionErrortValidationErrortConversionError(terrorstmessages(tcontextt context_frame(t classpropertytjson_serializetvalidation_rulecCst|tt|S(N(tsetattrt RULE_FLAGtTrue(tobj((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytrule1scCs"t|o!t|tttkS(N(tcallabletgetattrRtFalseR(R((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytis_rule6scCs\d}xO|D]G}t||tkr@|t||}q |t||}q W|S(s Return the number of entries in an entry. This is primarly for the failed output parameter so we don't print empty values. We also use this to determine if a non-zero return value is needed. i(ttypetdictt entry_counttlen(tentryt num_entriestf((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR':s  tHasParamcBsGeZdZeZddZddZddZe dZ RS(s Base class for plugins that have `Param` `NameSpace` attributes. Subclasses of `HasParam` will on one or more attributes store `NameSpace` instances containing zero or more `Param` instances. These parameters might describe, for example, the arguments and options a command takes, or the attributes an LDAP entry can include, or whatever else the subclass sees fit. Although the interface a subclass must implement is very simple, it must conform to a specific naming convention: if you want a namespace ``SubClass.foo``, you must define a ``Subclass.takes_foo`` attribute and a ``SubCLass.get_foo()`` method, and you may optionally define a ``SubClass.check_foo()`` method. A quick big-picture example =========================== Say you want the ``options`` instance attribute on your subclass to be a `Param` `NameSpace`... then according to the enforced naming convention, your subclass must define a ``takes_options`` attribute and a ``get_options()`` method. For example: >>> from ipalib import Str, Int >>> class Example(HasParam): ... ... options = None # This will be replaced with your namespace ... ... takes_options = (Str('one'), Int('two')) ... ... def get_options(self): ... return self._get_param_iterable('options') ... >>> eg = Example() The ``Example.takes_options`` attribute is a ``tuple`` defining the parameters you want your ``Example.options`` namespace to contain. Your ``Example.takes_options`` attribute will be accessed via `HasParam._get_param_iterable()`, which, among other things, enforces the ``('takes_' + name)`` naming convention. For example: >>> eg._get_param_iterable('options') (Str('one'), Int('two')) The ``Example.get_options()`` method simply returns ``Example.takes_options`` by calling `HasParam._get_param_iterable()`. Your ``Example.get_options()`` method will be called via `HasParam._filter_param_by_context()`, which, among other things, enforces the ``('get_' + name)`` naming convention. For example: >>> list(eg._filter_param_by_context('options')) [Str('one'), Int('two')] At this point, the ``eg.options`` instance attribute is still ``None``: >>> eg.options is None True `HasParam._create_param_namespace()` will create the ``eg.options`` namespace from the parameters yielded by `HasParam._filter_param_by_context()`. For example: >>> eg._create_param_namespace('options') >>> eg.options NameSpace(<2 members>, sort=False) >>> list(eg.options) # Like dict.__iter__() ['one', 'two'] Your subclass can optionally define a ``check_options()`` method to perform sanity checks. If it exists, the ``check_options()`` method is called by `HasParam._create_param_namespace()` with a single value, the `NameSpace` instance it created. For example: >>> class Example2(Example): ... ... def check_options(self, namespace): ... for param in namespace(): # Like dict.itervalues() ... if param.name == 'three': ... raise ValueError("I dislike the param 'three'") ... print ' ** Looks good! **' # Note output below ... >>> eg = Example2() >>> eg._create_param_namespace('options') ** Looks good! ** >>> eg.options NameSpace(<2 members>, sort=False) However, if we subclass again and add a `Param` named ``'three'``: >>> class Example3(Example2): ... ... takes_options = (Str('one'), Int('two'), Str('three')) ... >>> eg = Example3() >>> eg._create_param_namespace('options') Traceback (most recent call last): ... ValueError: I dislike the param 'three' >>> eg.options is None # eg.options was not set True The Devil and the details ========================= In the above example, ``takes_options`` is a ``tuple``, but it can also be a param spec (see `create_param()`), or a callable that returns an iterable containing one or more param spec. Regardless of how ``takes_options`` is defined, `HasParam._get_param_iterable()` will return a uniform iterable, conveniently hiding the details. The above example uses the simplest ``get_options()`` method possible, but you could instead implement a ``get_options()`` method that would, for example, produce (or withhold) certain parameters based on the whether certain plugins are loaded. Think of ``takes_options`` as declarative, a simple definition of *what* parameters should be included in the namespace. You should only implement a ``takes_options()`` method if a `Param` must reference attributes on your plugin instance (for example, for validation rules); you should not use a ``takes_options()`` method to filter the parameters or add any other procedural behaviour. On the other hand, think of the ``get_options()`` method as imperative, a procedure for *how* the parameters should be created and filtered. In the example above the *how* just returns the *what* unchanged, but arbitrary logic can be implemented in the ``get_options()`` method. For example, you might filter certain parameters from ``takes_options`` base on some criteria, or you might insert additional parameters provided by other plugins. The typical use case for using ``get_options()`` this way is to procedurally generate the arguments and options for all the CRUD commands operating on a specific LDAP object: the `Object` plugin defines the possible LDAP entry attributes (as `Param`), and then the CRUD commands intelligently build their ``args`` and ``options`` namespaces based on which attribute is the primary key. In this way new LDAP attributes (aka parameters) can be added to the single point of definition (the `Object` plugin), and all the corresponding CRUD commands pick up these new parameters without requiring modification. For an example of how this is done, see the `ipalib.crud.Create` base class. However, there is one type of filtering you should not implement in your ``get_options()`` method, because it's already provided at a higher level: you should not filter parameters based on the value of ``api.env.context`` nor (preferably) on any values in ``api.env``. `HasParam._filter_param_by_context()` already does this by calling `Param.use_in_context()` for each parameter. Although the base `Param.use_in_context()` implementation makes a decision solely on the value of ``api.env.context``, subclasses can override this with implementations that consider arbitrary ``api.env`` values. ttakescCs|d|}t||d}t|tkr6|St|ttfrR|fSt|re|S|dkrxtStd|j ||fdS(s Return an iterable of params defined by the attribute named ``name``. A sequence of params can be defined one of three ways: as a ``tuple``; as a callable that returns an iterable; or as a param spec (a `Param` or ``str`` instance). This method returns a uniform iterable regardless of how the param sequence was defined. For example, when defined with a tuple: >>> class ByTuple(HasParam): ... takes_args = (Param('foo'), Param('bar')) ... >>> by_tuple = ByTuple() >>> list(by_tuple._get_param_iterable('args')) [Param('foo'), Param('bar')] Or you can define your param sequence with a callable when you need to reference attributes on your plugin instance (for validation rules, etc.). For example: >>> class ByCallable(HasParam): ... def takes_args(self): ... yield Param('foo', self.validate_foo) ... yield Param('bar', self.validate_bar) ... ... def validate_foo(self, _, value, **kw): ... if value != 'Foo': ... return _("must be 'Foo'") ... ... def validate_bar(self, _, value, **kw): ... if value != 'Bar': ... return _("must be 'Bar'") ... >>> by_callable = ByCallable() >>> list(by_callable._get_param_iterable('args')) [Param('foo', validate_foo), Param('bar', validate_bar)] Lastly, as a convenience for when a param sequence contains a single param, your defining attribute may a param spec (either a `Param` or an ``str`` instance). For example: >>> class BySpec(HasParam): ... takes_args = Param('foo') ... takes_options = 'bar?' ... >>> by_spec = BySpec() >>> list(by_spec._get_param_iterable('args')) [Param('foo')] >>> list(by_spec._get_param_iterable('options')) ['bar?'] For information on how an ``str`` param spec is interpreted, see the `create_param()` and `parse_param_spec()` functions in the `ipalib.parameters` module. Also see `HasParam._filter_param_by_context()`. R s0%s.%s must be a tuple, callable, or spec; got %rN( R"tNoneR%ttuplet isinstanceRtstrR!t TypeErrortname(tselfR3tverbtsrc_nametsrc((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt_get_param_iterables;  ccst|d|}d|}t||sGtd|j|fnt||}t|std|j||fnx@|D]5}t|}|dks|j|r|VqqWdS(sK Filter params on attribute named ``name`` by environment ``env``. For example: >>> from ipalib.config import Env >>> class Example(HasParam): ... ... takes_args = ( ... Str('foo_only', include=['foo']), ... Str('not_bar', exclude=['bar']), ... 'both', ... ) ... ... def get_args(self): ... return self._get_param_iterable('args') ... ... >>> eg = Example() >>> foo = Env(context='foo') >>> bar = Env(context='bar') >>> another = Env(context='another') >>> (foo.context, bar.context, another.context) (u'foo', u'bar', u'another') >>> list(eg._filter_param_by_context('args', foo)) [Str('foo_only', include=['foo']), Str('not_bar', exclude=['bar']), Str('both')] >>> list(eg._filter_param_by_context('args', bar)) [Str('both')] >>> list(eg._filter_param_by_context('args', another)) [Str('not_bar', exclude=['bar']), Str('both')] tenvtget_s%s.%s()s %s.%s must be a callable; got %rN( R"thasattrtNotImplementedErrorR3R!R2RR.tuse_in_context(R4R3R9tget_nametgettspectparam((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt_filter_param_by_context4s    cCsst|j||dt}|jjs_t|d|d}t|r_||q_nt|||dS(Ntsorttcheck_( RRBR#tapitis_production_modeR"R.R!R(R4R3R9t namespacetcheck((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt_create_param_namespaceds  cCstjS(N(Rt current_frame(R4((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRosN( t__name__t __module__t__doc__R#tNO_CLIR8R.RBRItpropertyR(((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR,Ks  K 0 tCommandcBsoeZdZeZeZejdZejdZ ejdZ ejdZ d5Z eZejdZd6ZejdZeZeZd5ZedZd7ZeZed ZeeZed Z d Z!d Z"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+d5e,e-d5dZ.dZ/dZ0dZ1d5dZ2dZ3dZ4dZ5dZ6d Z7d!Z8d"Z9d#Z:d$Z;d%Z<d&Z=d'Z>ed(Z?d)Z@d*ZAd+ZBd,ZCd8ZDd0ZEed1ZFee,d2ZGee,d3ZHd4ZIRS(9s A public IPA atomic operation. All plugins that subclass from `Command` will be automatically available as a CLI command and as an XML-RPC method. Plugins that subclass from Command are registered in the ``api.Command`` namespace. For example: >>> from ipalib import create_api >>> api = create_api() >>> class my_command(Command): ... pass ... >>> api.add_plugin(my_command) >>> api.finalize() >>> list(api.Command) [] >>> api.Command.my_command # doctest:+ELLIPSIS ipalib.frontend.my_command() This class's subclasses allow different types of callbacks to be added and removed to them. Registering a callback is done either by ``register_callback``, or by defining a ``_callback`` method. Subclasses should define the `callback_types` attribute as a tuple of allowed callback types. targstoptionstparamstparams_by_defaulttoutputtresultt output_paramss1Results are truncated, try a more specific searchtinteractive_promptcCs|jjddS(Nt.i(RLt rpartition(tcls((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt__topic_getterscCs|jS(N(t full_name(R4((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytforwarded_namescOsF|jt-ttdd|j_|j||SWdQXdS(s Perform validation and then execute the command. If not in a server context, the call will be forwarded over XML-RPC and the executed an the nearest IPA server. t principalN(tensure_finalizedRR"RR.R_t_Command__do_call(R4RQRR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt__call__s  c Os@g|j_d|kr2|jt|dng|jjjr^|jjj r^d|d>> class my_cmd(Command): ... takes_args = ('login',) ... takes_options=(Password('passwd'),) ... >>> c = my_cmd() >>> c.finalize() >>> list(c._repr_iter(login=u'Okay.', passwd=u'Private!')) ["u'Okay.'", "passwd=u'********'"] s%s=%rN(RQR?R3R.treprt safe_valueRR(R4RStargtvaluetoption((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRrs cOs|jdk rft||jkrf|jdkrHtd|jntd|jd|jnt|j|}t|dkrt|j|}t |j |}t|dkrt dt |n|j |n|S(s4 Merge (args, options) into params. iR3tcounttnamesN(tmax_argsR.R(RR3RR&t_Command__options_2_paramst_Command__args_2_paramstsett intersectionRtsortedRs(R4RQRRRStarg_kwR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRn s$ccst}xt|jD]\}}t||kr|jrt}t||dkrt||ttfkr|j ||fVq|j ||fVq|j ||fVqPqWdS(Ni( R#t enumerateRQR(t multivalueRR%tlistR/R3(R4tvaluesRtiR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt__args_2_paramss 2ccszx4|jD])}||kr ||j|fVq q Wt|j|j}|rvttdd|jndS(NsUnknown option: %(option)sR(RStpopRt differencetinternal_optionsRR (R4RRR3t unused_keys((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt__options_2_params,s cOs%|j||}t|j|S(sK Creates a LDAP entry from attributes in args and options. (RnR&t_Command__attributes_2_entry(R4RQRRtkw((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytargs_options_2_entry6sccssxl|jD]a}|j|jr ||kr ||}t|trY|t|fVqk|||fVq q WdS(N(RSt attributeR0R/R(R4RR3R((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt__attributes_2_entry=s  cKst}t|j|}t}x\|jD]Q}y||}Wntk r^t}q.nX|ru||f7}q.|||>> class my_command(Command): ... takes_options = ( ... Param('first', normalizer=lambda value: value.lower()), ... Param('last'), ... ) ... >>> c = my_command() >>> c.finalize() >>> c.normalize(first=u'JOHN', last=u'DOE') {'last': u'DOE', 'first': u'john'} c3s1|]'\}}|j|j|fVqdS(N(RSRu(t.0tktv(R4(s3/usr/lib/python2.7/site-packages/ipalib/frontend.pys s(R&titems(R4R((R4s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRuzsc s tfd|jDS(s Return a dictionary of values converted to correct type. >>> from ipalib import Int >>> class my_command(Command): ... takes_args = ( ... Int('one'), ... 'two', ... ) ... >>> c = my_command() >>> c.finalize() >>> c.convert(one=1, two=2) {'two': u'2', 'one': 1} c3s1|]'\}}|j|j|fVqdS(N(RSRv(RRR(R4(s3/usr/lib/python2.7/site-packages/ipalib/frontend.pys s(R&R(R4R((R4s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRvscCs<x5|jD]'}|j|jddkr q q q WdS(N(RSR?R3R.(R4RRA((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt__convert_iterscKsh|dkrRg|jD]0}|j|kr|js@|jr|j^q}nt|j||S(s Return a dictionary of defaults for all missing required values. For example: >>> from ipalib import Str >>> class my_command(Command): ... takes_args = Str('color', default=u'Red') ... >>> c = my_command() >>> c.finalize() >>> c.get_default() {'color': u'Red'} >>> c.get_default(color=u'Yellow') {} N(R.RSR3trequiredtautofillR&t_Command__get_default_iter(R4t_paramsRtp((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRts 3cKs(t|j|g|}|j|S(s= Return default value for parameter `_name`. (R&RR?(R4t_nameRR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytget_default_ofsc cst}xqt|jD]`}|j|ks=|j|kr|jdkrRqnx$|jjD]}|j|q_WqqWx#|jD]}d}t}|j|krX|j|kr|||j|}|j j j r|j |dt n|||j>> class user_add(Command): ... def execute(self, **kw): ... return self.api.Backend.ldap.add(**kw) ... s %s.execute()N(R<R3(R4RQR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR#s cOsy |jjj|j||SWntjk r}|jjjdkrPnt |dd}|dks}||j krntjd|j |j nXdS(sG Forward call over RPC to this same command on server. tcliR3N( Rt rpcclientRR^RtRequirementErrorRER9RR"R.RStcli_name(R4RQRRR3((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR2scCs|jdt|jdks3|jdj rHt|j|_n d |_|jdt|jt|j}d}tt |d|dt |_ g}x|D]}t|}xn|D]f}|j d krqn|j |j jkrqnyt||j|}Wqtk r5qXqW|j||qWt|dt |_t|jdt |_|jdtt|jd S( s Finalize plugin initialization. This method creates the ``args``, ``options``, and ``params`` namespaces. This is not done in `Command.__init__` because subclasses (like `crud.Add`) might need to access other plugins loaded in self.api to determine what their custom `Command.get_args` and `Command.get_options` methods should yield. RQiiRRcSs:|jr6|jdkr|jS|jdkr2dSdSdS(Niii(Rt sortorderRR.(R((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytget_keyRs tkeyRCRWN(RIR(RQRRR.R/RRRRR#RSRR3RtmintindexRtinsertRTt _iter_outputRUtsuperRPt _on_finalize(R4t params_nosortRRSRtpostj((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRAs6 &  "       ccst|jtk rCtd|jtt|j|jfnxt|jD]o\}}t|tr}t|}nt|tstd|j|ttft||fn|VqSWdS(Ns&%s.has_output: need a %r; got a %r: %rs*%s.has_output[%d]: need a %r; got a %r: %r( R%t has_outputR/R2R3RR0R1R (R4Rto((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRss(+ccs#x|jdD] }|VqWdS(sM Iterate through parameters for ``Command.args`` namespace. This method gets called by `HasParam._create_param_namespace()`. Subclasses can override this to customize how the arguments are determined. For an example of why this can be useful, see the `ipalib.crud.Create` subclass. RQN(R8(R4R((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytget_argss c Cst}t}x|D]}|rf|jrftd|j|jg|D]}|j^qGfn|rtd|jn|jst}n|jrt}qqWdS(s{ Sanity test for args namespace. This method gets called by `HasParam._create_param_namespace()`. s7%s: required argument after optional in %s arguments %ss)%s: only final argument can be multivalueN(R#RRR3t param_specRR(R4RQRRRtx((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt check_argss /   c csx|jdD] }|VqWx|jD]w}t|ttfr)tddddtddddd gVtd dd dtd dddd gVPq)q)Wtd dtd ddddd gVdS(s' Iterate through parameters for ``Command.options`` namespace. This method gets called by `HasParam._create_param_namespace()`. For commands that return entries two special options are generated: --all makes the command retrieve/display all attributes --raw makes the command display attributes as they are stored Subclasses can override this to customize how the arguments are determined. For an example of why this can be useful, see the `ipalib.crud.Create` subclass. RRtallRtdocsJRetrieve and print all attributes from the server. Affects command output.texcludetwebuitflagst no_outputRsBPrint entries as stored on the server. Only affects output format.sversion?s@Client version. Used to determine if server will accept request.t no_optionN(R8RR0R R RR R(R4RR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt get_optionss&         c Csxd|j}t|tsAtd|tt||fnt|j}t|tdg}||kr||}|rtd|t||fn||}|rtd|t||fqnx|jD]}||j} |jdkpt| |jsKtd||j|jt| | fnt |j r|j || |qqWdS(sY Validate the return value to make sure it meets the interface contract. s%s.validate_output()s%s: need a %r; got a %r: %rRs%s: missing keys %r in %rs%s: unexpected keys %r in %rs%%s: output[%r]: need %r; got %r: %rN( R3R0R&R2R%RRURRR.R!Rw( R4RURctnicet expected_sett actual_settmissingtextraRR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR|s,     !(ccs)x"|jdddD] }|VqWdS(NRWR5thas(R8(R4RA((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytget_output_paramsscCs|jr|j|SdSdS(N(t msg_summaryR.(R4RU((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRzs  c Cstdtjdtjdtjdtj}xi|jdd D]U}y||d}Wn'tk rtjdtj}nX||jdq@WdS( NRptinfotwarningRRR%s'Server sent a message with a wrong typeR~((R&RoRpRRRR?R(R4RUtlogger_functionsR~tfunction((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt log_messagess       cOst|tsdSd}|j|g|jD]}|j^q3}|jdtrs|jddt }nt}|jdtrd} ntd|jD} td|jD} x|j D]} |j | } d| j krqn|j| } | dkrqn| j d krF| dkrFd }n3| j d kryt | dkrpqnd }nt| tr|j| || | |qt| ttfr|j| || | |qt| tr|j| || | |qt| tr+|j| || | |qt| trf| d krV|j| q|j| qt| trxqt| tr|j| d t|j | jqqW|S(s Generic output method. Prints values the output argument according to their type and self.output. Entry attributes are labeled and printed in the order specified in self.output_params. Attributes that aren't present in self.output_params are not printed unless the command was invokend with the --all option. Attribute labelling is disabled if the --raw option was given. Subclasses can override this method, if custom output is needed. iRtdnRcss'|]}|jt|jfVqdS(N(R3RhR(RR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pys scss!|]}|j|jfVqdS(N(R3R(RR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pys !st no_displayRRitfailedRes%s %%dN(R0R&R.RRWR3R?R#RRRURtlowerR'R t print_entriesR/RR t print_entryRht print_summarytprint_indentedtbooltintt print_countR(R4RRURQRRtrvRtordert print_alltlabelsRRtoutpRV((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytoutput_for_clisV  "       +R3RRNcsOtfdjD}tj|dPst takes_argst takes_options(R&tjson_friendly_attributesRRR(R4t json_dict((R4s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt__json__Ns ccsttj|ij|dg}xL|D]D}|dkrgyt|d|VWqltk rcqlXq(|Vq(WdS(s!Yield callbacks of the given types %s_callbackN(t_callback_registryR?R.R"tAttributeError(R[t callback_typet callbackstcallback((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt get_callbacksXs!   cCsutj|iyt||}Wn&tk rJdg}t|||^q>}t|dkrtd|j dj d |Dfnt|dkr|d |_tg|jD]}|js|^qdt|_ nd|_|j|_ d |j krE|j|j jkrE|j j|j|_ntt|jdS( NtMethodRCt name_attrt attr_nameRSis)%s (Object) has multiple primary keys: %ss, css|]}|jVqdS(N(R3(RR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pys siR(Rt_Object__get_attrsR#R'RIRSR(R(RR3RqR)R.REt backend_nameRR&RR%R(R4Rtpkeys((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRs$! (# 7  $cgst|dkr9t|dttf r9|d}nt|}x:|jD],}|j|ksR||kryqRn|VqRWdS(sA Yield all Param whose name is not in ``names``. iiN(R(R0RR1t frozensetRSR3(R4RtminusRA((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt params_minuss,  cOstd|jdS(s' Construct an LDAP DN. s %s.get_dn()N(R<R3(R4RQtkwargs((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytget_dnsccsk||jkrdS|j|}xD|D]9}|||jk rIq*n|j|jkr*|Vq*q*WdS(N(RER3tobj_name(R4R3RGtplugin((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt __get_attrss ccs)x"|jdD]}t|VqWdS(sR This method gets called by `HasParam._create_param_namespace()`. RSN(R8R(R4R@((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt get_paramssR3t takes_paramscsRtfdjD}jr;jj|d sR(R'(R&R R(R3RR'(R4R((R4s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR s  N(snames takes_params(RKRLRRR&R'RSR(R)R.R.R/R9RR2R4R-R8R R(((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR%s    t AttributecBsPeZdZdZedZedZedZedZRS(s] Base class implementing the attribute-to-object association. `Attribute` plugins are associated with an `Object` plugin to group a common set of commands that operate on a common set of parameters. The association between attribute and object is done using a simple naming convention: the first part of the plugin class name (up to the first underscore) is the object name, and rest is the attribute name, as this table shows: =============== =========== ============== Class name Object name Attribute name =============== =========== ============== noun_verb noun verb user_add user add user_first_name user first_name =============== =========== ============== For example: >>> class user_add(Attribute): ... pass ... >>> instance = user_add() >>> instance.obj_name 'user' >>> instance.attr_name 'add' In practice the `Attribute` class is not used directly, but rather is only the base class for the `Method` class. Also see the `Object` class. t1cCs|jjddS(NR i(R3t partition(R4((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR58scCs!|jdk r|jjSdSdS(N(RR.R](R4((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyt obj_full_name<s cCs#dj|j}|jt|S(Ns{}_(tformatR5R3R((R4tprefix((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR,CscCs@|jdk r8|jdk r8|jj|j|jfSdSdS(N(R5R.t obj_versionRER%(R4((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRIs( RKRLRMR@ROR5R=R,R(((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR:s !R*cBs#eZdZeZeZdZRS(s A command with an associated object. A `Method` plugin must have a corresponding `Object` plugin. The association between object and method is done through a simple naming convention: the first part of the method name (up to the first under score) is the object name, as the examples in this table show: ============= =========== ============== Method name Object name Attribute name ============= =========== ============== user_add user add noun_verb noun verb door_open_now door open_now ============= =========== ============== There are three different places a method can be accessed. For example, say you created a `Method` plugin and its corresponding `Object` plugin like this: >>> from ipalib import create_api >>> api = create_api() >>> class user_add(Method): ... def run(self, **options): ... return dict(result='Added the user!') ... >>> class user(Object): ... pass ... >>> api.add_plugin(user_add) >>> api.add_plugin(user) >>> api.finalize() First, the ``user_add`` plugin can be accessed through the ``api.Method`` namespace: >>> list(api.Method) [] >>> api.Method.user_add(version=u'2.88') # Will call user_add.run() {'result': 'Added the user!'} (The "version" argument is the API version to use. The current API version can be found in ipalib.version.API_VERSION.) Second, because `Method` is a subclass of `Command`, the ``user_add`` plugin can also be accessed through the ``api.Command`` namespace: >>> list(api.Command) [] >>> api.Command.user_add(version=u'2.88') # Will call user_add.run() {'result': 'Added the user!'} And third, ``user_add`` can be accessed as an attribute on the ``user`` `Object`: >>> list(api.Object) [] >>> list(api.Object.user.methods) ['add'] >>> api.Object.user.methods.add(version=u'2.88') # Will call user_add.run() {'result': 'Added the user!'} The `Attribute` base class implements the naming convention for the attribute-to-object association. Also see the `Object` class. ccso|jdk rFx4|jjD] }d|jkr:qn|VqWnx"tt|jD] }|Vq\WdS(NR(RR.RSRRR*R(R4RA((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRs (RKRLRMR#textra_options_firsttextra_args_firstR(((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyR*QsAtUpdatercBs eZdZdZdZRS(s An LDAP update with an associated object (always update). All plugins that subclass from `Updater` will be automatically available as a server update function. Plugins that subclass from Updater are registered in the ``api.Updater`` namespace. For example: >>> from ipalib import create_api >>> api = create_api() >>> class my(Object): ... pass ... >>> api.add_plugin(my) >>> class my_update(Updater): ... pass ... >>> api.add_plugin(my_update) >>> api.finalize() >>> list(api.Updater) [] >>> api.Updater.my_update # doctest:+ELLIPSIS ipalib.frontend.my_update() cKstd|jdS(Ns %s.execute()(R<R3(R4RR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRscKs tjd|j|j|S(Nsraw: %s(RoRpR3R(R4RR((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRbs (RKRLRMRRb(((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pyRCs (<RMtloggingtsixtipapython.versionRtipapython.ipautilRt ipalib.baseRtipalib.plugableRRtipalib.parametersRRRRR t ipalib.outputR R R t ipalib.textR t ipalib.errorsRRRRRRRtipalibRRtipalib.requestRRt ipalib.utilRRtPY3R1Rht getLoggerRKRoRR R$R'R,RRPR#R$R%R:R*RC(((s3/usr/lib/python2.7/site-packages/ipalib/frontend.pytsD  "4     *[=O