ó h'dWc@sûdZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z mZmZmZddlmZmZmZmZddlmZmZejdƒjZejdƒjZde fd„ƒYZ d „Z!dS( s AI Profile Interface iÿÿÿÿN( tCriteriat AIServerErrort ERROR_TYPEtSERVICE_STATUStEventsGeneratortObjectChangedEventt DeletedEventt CreatedEventt check_authst PROFILE_AUTH(t ai_databasetget_server_instancetlogtMAX_PROFILE_NAME_LEN(tperform_templatingtvalidate_profile_stringtwebservdtProfilecBs=eZdZdZdZdZeegZdddd„Ze d„ƒZ d„Z e d„ƒZ e dd „ƒZ e dd „ƒZed „Zd „Zd „Zed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZd„Zd„Zeeed„Zed„ƒZd„ZRS(sThe Profile interface represents a profile in the AI server. Each specific profile is associated with exactly one AI service. The following event types are possible for a Profile: - CreatedEvent - DeletedEvent - ObjectChangedEvent tinstalltsystemtallcCs||_||_||_||_||_t|_|dkršd}dt|ƒ}x3|j j d|ƒr|d7}dt|ƒ}q[W||_nJ|j |j ƒ|j j d|j ƒrät tjtdƒ|j ƒ‚ntt|ƒjtttgƒdS(s‘This method creates a new profile for the service, initializing with the specified values. Parameters name: String Optional: This is the name to give to the profile. If no name is provided, then a name will be generated. content: String This is the complete content of an XML system configuration profile file, and will be validated against the service it's being added to. criteria: Criteria object Optional: This is the Criteria used in selecting a profile for use by a client. environment: list Optional: This is the list of environments where this profile should be applied. Return Value None Errors / Exceptions AIServerError The following error types can be raised by this method: - ParsingError This error/exception will be raised should the provided profile content fail to validate against the DTDs in the service. isprofile-tfilter_by_namesDuplicated profile name: '%s'N(t_servicet_contentt_namet _criteriat _environmenttFalset_pendingtNonetstrtservicet get_profilest validate_nametnameRRtDUPLICATE_ENTRYt_tsuperRt__init__RRR(tselfRtcontentR"tcriteriat environmentt profile_numt profile_name((s profile.pyR&<s(           c Ksâttƒ||||}t|_|jƒtƒ}tƒ}||d<|j|d<||d<|j|d<|j|d<|j |dtnametag(RRt INVALID_VALUER$t isinstancet basestringRtlenR tAIdbt sanitize_sqlR?R@RAtsett ExceptionR2(R9R"troot((s profile.pyR!Ôs(      t,cCsÌ|s!ttjtdƒƒ‚nt|tƒsUttjtdƒt|ƒƒ‚n|j|ƒ}xK|D]C}|tj krk|tj krkttjtdƒ|ƒ‚qkqkWtj |krÈtj S|S(s¶ Convert a 'delim' separated string of environment names into a list of strings. If the 'all' value was given, translate that to all supported environments. s*Profile environment string cannot be emptys(Invalid profile environment string: '%s's/Invalid profile environment value in string: %s( RRRLR$RMRNRtsplitRtSUPPORTED_ENVIRONMENTStENVIRONMENT_ALL(R9tenv_strtdelimtenvlisttenv((s profile.pytenv_str_to_listús"      cCsÅ|s!ttjtdƒƒ‚nt|tƒsKttjtdƒƒ‚nxK|D]C}|tjkrR|tjkrRttjtdƒ|ƒ‚qRqRWtj|kr¸|j tjƒS|j |ƒS(s° Convert a list of environment names into a 'delim' separated string. If the 'all' value is in the list, translate that to all supported environments. s(Profile environment list cannot be emptys!Invalid profile environment list.s-Invalid profile environment value in list: %s( RRRLR$RMR4RRWRXtjoin(R9R[RZR\((s profile.pytenv_list_to_strs     cCs|jjd|d|ƒS(s This method will match this manifest object against the provided criteria. Parameters criteria: Criteria Criteria object containing the criteria to match match_all: Boolean If True, only profiles matching all the criteria passed in are considered a match Return Value Boolean True will be returned if the criteria matches exactly, otherwise False. Errors / Exceptions AIServerError The following error types can be raised by this method: - InvalidValue This error/exception will be raised should invalid criteria keys or values be specified. t param_critt match_all(R)tmatches(R'tcrit_objRa((s profile.pyRb1sc CsÙttƒ|jjd|jƒsDttjtdƒ|jƒ‚nt ƒ}t ƒ}||d<|jj|d<|j|d|rÔt ƒ} x!|jjD]} | j| ƒq™Wxˆ| D]} |jj| ƒq·WqX|rþx^|D]} |jj| ƒqáWqX|r2x4|jD]} |j| |jj| R3R!R]R_RRbRfRitpropertyRR"RkR(R)R*RR‚R‘R’R”(((s profile.pyR,s:   :6 '&  ) 5 # # _c Csætƒ}x8|D]0}tj|||dtƒ|d|jƒs    F"ÿÿƒ