h'dWc@sdZddlZddlZddlmZddlmZmZddl m Z m Z m Z mZmZdZdZdZd Zd Zd Zd Zd ZdZeeeefZeeeeefZeeZdZedZdefdYZ de!fdYZ"de!fdYZ#defdYZ$defdYZ%defdYZ&defdYZ'defd YZ(d!efd"YZ)d#efd$YZ*dS(%s AI Criteria Interface iN(tStringIO(t AIServerErrort ERROR_TYPE(tlogt ai_databaset verifyxmlt KNOWN_CPUStKNOWN_PLATFORMStarchtcputhostnametipv4tmactmemtnetworktplatformtzonenames+/usr/share/auto_install/criteria_schema.rngltCriteriacBs7eZdZdedZedZedZe edZ e edZ dZ e edZe dZd Ze ed Ze ed Zdeed Zd ZddZedZdZdZdZdZe dZe dddedZRS(sThe Criteria interface represents a set of criteria in the AI server. Each specific criteria is associated with exactly one AI manifest or profile. There are no events for Criteria objects. cCs|r~t|ts0ttjtdnxK|jD]:\}}t|ts=ttjtd|q=q=Wn||_||_ |jr|j ndS(sThis method creates a new Criteria for use with Manifests or Profiles, initializing with the specified values. Parameters criteria: dict Optional: This is a dictionary of keys and values that define the criteria that make up the core of this interface. Any empty Criteria object may by created by omitting this value - for later population using methods. All keys in the dictionary must be valid criteria and all dictionary elements must be valid criteria class types. strict_validation: boolean Specify whether criteria that have a predefined list of associated values should adhere to strict validation or not. This is to support backwards compatibility with old s11 installadm as it allowed invalid values for certain criteria. Return Value None Errors / Exceptions AIServerError The following error types can be raised by this method: - Insufficient Arguments This signifies a non dictionary parameter was passed in - Invalid Values Validation of criteria failed s.Error: Criteria parameter must be a dictionarys>Error: Criteria dictionary element '%s' must be of type list()N( t isinstancetdictRRtINSUFFICIENT_ARGUMENTSt_titemstlistt _criteriat_strict_validationtvalidate(tselftcriteriatstrict_validationtkytval((s criteria.pyt__init__@s     cCs|jS(s?This is reference to the entire set of criteria as a dictionary(R(R((s criteria.pyRvscCs|jS(s4Return if this criteria adheres to strict validation(R(R((s criteria.pytstrictly_validated{scCs2tjg|jdD]}|j^q|S(s Convert command line argument string of "key=value, key=value, .." into a Criteria object. Parameters: criteria_string: string String containing key/value criteria pairs See from_list() for more information strict_validation: boolean Whether Criteria object created adheres to strict validation Return Value: Criteria: dict Criteria class object containing a dictionary, which in turn contains a list of Criteria specific objects, all keys are lower case, values are case-sensitive. Errors/Exceptions: AIServerError The following error types can be raised by this method: - InvalidValue This signifies the is a malformed name=value string in the input list, or invalid name or value provided. t,(Rt from_listtsplittstrip(tclstcriteria_stringRts((s criteria.pyt from_strings "cCst}x|D]}|jddjddjd\}}}|skttjtd|n|j}|r|tkrttjtd|nW||krttj tdi|d6n%|sttjtd |nt }|j } x| D]} d} d} | jd } |t kr/| d r/| d  sh| d  rttjtd| n| d jdkrtj|| d |} n| d jdkrtj|| d |} nyt| | g}WqDtjk r+}ttj|qDXntj|| |}|t krt|t ryt||g}Wqtjk r}ttj|qXn|j|qW|||-) strict_validation: boolean Whether Criteria object created adheres to strict validation Return Value: Criteria: dict Criteria class object containing a dictionary, which in turn contains a list of Criteria specific objects, all keys are lower case, values are case-sensitive. Errors/Exceptions: AIServerError The following error types can be raised by this method: - InvalidValue This signifies there is a malformed name=value string in the input list, or invalid name or value provided. t'tt"t=s$Error: Missing criteria name in '%s's"Error: Invalid criteria name: '%s's3Error: Criteria '%(name)s' specified more than oncetnames'Error: Missing value for criteria: '%s't-iiis#Error: Invalid criteria range: '%s't unboundeds6Error: Criteria must be of the form =s'Error: Invalid structured criteria listN(Rtreplacet partitionRRt INVALID_VALUERtlowertVALID_CRITERIAt PARSING_ERRORRR$tNonetRANGE_CRITERIARt_create_crit_objtRanget RangeErrorRtappendtlen(R&t criteria_listRt crit_dicttentrytcrit_keytcrit_delimitert crit_valuet crit_listtvaluestvaluetobj1tobj2trangestcritobjterr((s criteria.pyR#s  0                       cCsx|jjD]}|tkrAttjtd|n|tkrt|j|dkrttjtdi|d6nx)|j|D]}|t krt |t  rttjtd|nA|t krt |t rttjtdi|d6nt |t r|j rc|j rcttjtdi|d6n|jrtj||jn|jrtj||jqqtj||qWqWdS( s.This method performs semantec validation of the criteria information For range criterion it ensures both boundary elements are present and also ensures IPv4 and MAC addresss are formatted fully zero padded. Valid Criteria types are: arch : Archictecture e.g. uname -m cpu : CPU Class, e.g. uname -p hostname : Assigned hostname ipv4 : IP Version 4 network address mac : Hexadecimal colon delimited MAC address mem : Memory size in MB, e.g. prtconf(1M) network : IP Version 4 network number platform : Platform name e.g. uname -i zonename : Name of zone e.g. zones(5) Parameters None. Return Value None. Errors / Exceptions AIServerError The following error types can be raised by this method: - InvalidValue This signifies that there was some issue with the stored criteria s Error: Invalid criteria type: %sis:Error: Criteria '%(name)s' cannot contain a list of valuesR.s0Error: Invalid range criteria specified for '%s's<Error: Criteria '%(name)s' can not be passed as a range pairsDError: Range criteria '%(name)s' must have one of its boundaries setN(RtkeysR5RRR3Rt LIST_CRITERIAR=R8RR:tis_lower_unboundedtis_upper_unboundedR4Rt_validate_crit_objtupper(RtkeyR((s criteria.pyRs> %        c Cs| s| r;ttjtdi|d6|d6n|tkrtttjtdi|d6|d6nd}y|tkrt||}n|tkrt ||}n|t krt |}n|t krt |}n|tkr t|}nl|tkr%t|}nQ|tkr@t |}n6|tkr[t|}n|tkrvt|}nWnUtjt jt jt jtjtjtjtjfk r}ttj|nX|S(s} This class method takes a criteria key and returns a specific criteria object relating to that key. s=Error: Invalid criteria key/value pair: '%(key)s' : '%(val)s'RRRs2Error: Invalid criteria key: '%(key)s' : '%(val)s'N(RRR3RR5R7t ARCH_CRITt ArchitecturetCPU_CRITtCPUt HOSTNAME_CRITtHostnamet IPV4_CRITt IPv4AddresstMAC_CRITt MACAddresstMEM_CRITt MemorySizet NETWORK_CRITt PLATFORM_CRITtPlatformt ZONENAME_CRITtZonenametArchitectureErrortCPUErrort HostnameErrortIPv4AddressErrortMACAddressErrortMemorySizeErrort PlatformErrort ZonenameError(RRRRtcrit_objRK((s criteria.pyR9isH               cCs9|tkrt|t s|tkr8t|t s|tkrTt|t s|tkrpt|t s|t krt|t  s|t krt|t  s|t krt|t s|tkrt|t s|tkr5t|t r5ttjtdi|d6tt|d6ndS(sX This class method Validates that object type is valid for criteria key s;Error: Invalid object type for criteria: %(key)s : %(type)sRRttypeN(RSRRTRURVRWRXRYRZR[R\R]R^R_R`RaRbRcRRR3RtstrRm(RRtobj((s criteria.pyRPs cCs|jrtttdt}g}xt|jjD]l\}}g}x%|D]}|jdt|qVWdj|}|jd|j |d|fq=Wdj|SdSdS( sPretty print criteriaRRs%ss, s%s = %st s R+N( RR=tmaxR5tsortedRR<Rntjointljust(Rtmaxlentstr_listRREtval_listtvltval_str((s criteria.pyt__str__s " ' c Csc|d krd StjjtsAttjtdtnt td}t j j dt dt dt dtdt}yt j jt||}Wn;t j jk r}ttjtd|jjnXtj|tt j j|j\}}|rCttjtd i|jd 6|jd 6ntjd tj||S(sThis class-method will create a new Criteria object, populating its data by parsing the passed XML formatted criteria data string. Parameters criteria_xml_string: String This is the XML formatted criteria to be parsed. strict_validation: boolean Specify whether strict criteria validation should occur Return Value Criteria A new Criteria object. Errors/Exeptions AIServerError The following error types can be raised by this method: - ParsingError This signifies that there was some issue with either the stored criteria or the parameter value s+Error: Unable to find criteria_schema: '%s'trtload_dtdtresolve_entitiestdtd_validationtremove_commentst no_networks Error: %ss>Error: Criteria XML failed validation: line %(line)s: %(msg)stlinetmsgs$Criteria file passed RNG validation.N(R7tostpathtexiststCRITERIA_RNG_SCHEMARRR6Rtopentlxmltetreet XMLParsertFalsetTruetparseRtXMLSyntaxErrort error_logt last_errorRtverify_relaxng_manifestttostringtgetrootRtmessageRtdebugRt_from_criteria_dom( R&tcriteria_xml_stringRtschematparsertcritRKtrootterrors((s criteria.pytfrom_criteria_xmls4    ' !c Cs|d krd St}t}x|jdD]}}|jdj}xa|jD]S}|jdks||jdkr|jd k r|tkrt t j t d|n||krt t j t di|d6n|jdkr)|tkr)t t j t di|d6n|jdkra|jj}|dd j|} n|d|j} |j| |j|qXt t j t d |qXWq2Wtj||S( sThis class-method will create a new Criteria object, populating its data by parsing the passed XML DOM tree. Parameters root: XML DOM This is the root node of the criteria DOM strict_validation: boolean Specify whether strict criteria validation should occur Return Value Criteria A new Criteria object. the data imported is not yet validated. Errors/Exeptions AIServerError The following error types can be raised by this method: - ParsingError This signifies that there was some issue with either the stored criteria or the parameter valeue s.//ai_criteriaR.trangeRFs Error: Invalid criteria type: %ss3Error: Criteria '%(name)s' specified more than onces<Error: Criteria '%(name)s' can not be passed as a range pairR-R/s(Error: Criteria contains no values: '%s'N(R7RtfindalltattribR4t getchildrenttagttextR5RRR3RR6R8R$RsR<RR#( R&RRRDtkey_listRRRtchildt range_valuestcrit_str((s criteria.pyRsB        cs sj sj rtStjjtjj}}|j|}|r{t|t|kr{tSt|tjkrtStfd|DrtStSdS(sThis method will match this Criteria object against the provided criteria object parameter. Matching is based on sets, the parameter passed Criteria object is the master object (larger circle), All of the criteria elements within the main criteria object must match those contained in the parameter based criteria in order to have a match. If match_all is True then all of the passed in master criteria must match all of the criteria objects criteria and not just a subset. Parameters: param_crit: Criteria object The criteria object ot match against this object match_all: Boolean If True, only profiles matching all the criteria passed in are considered a match collision_detection: Boolean Set to True to indicate we're being called to verify that the given parameter criteria won't cause a collision with this criteria object's criteria. In this case we: - Ensure either ends of ranges don't overlap. e.g. Range 1->10 and Range 4->20 would return a true match as there is a potential collision from 4->10 - Allow param_crit to have multiple values. Return Value Boolean: True for matching criteria, 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. c3s;|]1}j|j|j|s|VqdS(N(t_isequalR(t.0Ro(tcollision_detectiont param_critR(s criteria.pys s N(RRtsetRLt intersectionR=R(RRt match_allRtosettpsett intersect((RRRs criteria.pytmatchesGs)+"cCs<t|jkrdnd|jtr-dndt|jkrEdnd|jtr]dndt|jkrudndt|jkrdndt|jkrdndt|jkrdndt|jkrdnd|jt rdndt |jkrdnd|jt rdndt |jkr5dndf S(smReturn a tuple indicating what criteria have been set intended for use in sorting the best matching criteria for manifests. As all matching profiles are returned, it is not required for profiles. Manifests sorting order is: hostname MAC (Exact) MAC (Range) IPv4 (Exact) IPv4 (Range) zonename platform arch cpu network (Exact) network (Range) mem (Exact) mem (Range) This is based on heaviest criteria weighting value first ii( RWRt_range_is_uniqueR[RYRbR`RSRUR_R](R((s criteria.pytgenerate_sorting_tuplescCs|dk r|}n |j}t}||krt||dtr||d}|j r|j r|j|jkrt }qn|S(sConvenience method to determine if a Range criteria specifies a unique single value e.g. its upper and lower bounds are equal. Parameters: key: String Dictionary key to internal stored criteria criteria: Dictionary Optional dictionary of criteria elements, if not supplied default to self.criteria Returns: True if range specifies a single value, otherwise False iN( R7RRRR:RNROR4RQR(RRRRtcheck_criteriat unique_ranget range_crit((s criteria.pyRs   #   cCst}t|dkr3|d}x|D]}|tkr|jrM|js_|jrh|jrht}q"|j||\}} |j||\} } |r| |kr| | ks| | krt}qq"|| kr| | krt}q"t}n*t|tj t|kr"t}n|r)Pq)q)Wn|tkr^t t j t d|n|st t j t dnqtg|D]} t| ^q} tg|D]} tj t| ^q}| j|}|rt}n|S(sThis method compares two criteria keys for quality. It is intended To be used only in conjunction with the public matches() method. As such the assumption is made that for each key checked param_criteria only contains one value when we are not looking for collisions. Range overlaps are reported for collision detection, and in this scenario param_criteria could contain multiple values. It is assumed that Range param_criteria cannot have unbounded values. Parameters: key: String Dictionary key to internal stored criteria obj_criteria: list Object stored list of criteria param_criteria: list Parameter list of criteria values to compare collision_detection: Boolean Set to True to indicate we're being called to verify that the given parameter criteria won't cause a collision with this criteria object's criteria. In this case we: - Ensure either ends of ranges don't overlap. e.g. Range 1->10 and Range 4->20 would return a true match as there is a potential collision from 4->10 - Allow param_crit to have multiple values. Return Value True: If both criteria values are equal, or for range criteria if param_criteria is within the range boundaries. False: If criteria values differ Errors/Exceptions: AIServerError - Invalid Value, if attempting to match multiple ranges against multiple ranges iis5Error: Cannot match multiple ranges for criteria '%s's;Criteria to be matched against cannot have multiple values.(RR=R8RNRORtget_criteria_boundary_valuesRntAIdbt sanitize_sqlRRR3RRR(RRRt obj_criteriatparam_criteriaRtret_valt param_valRt crit_lowert crit_uppert param_lowert param_uppertcRRR((s criteria.pyRsN(                !      %. cCstd}td}t|ts1||fS|jrItd}n |jj}|jr|dkr|ttd}qtt}n |jj}||fS(s8Given a range criteria return its upper and lower boundaries converted to long values. Parameters criteria: Range Object Range object for which to return upper/lower boundary values Return Value tuple consisting of lower and upper values iR i( tlongRR:RNR4tdb_valueROtINFINITYRQ(RRRRR4RQ((s criteria.pyRJs        cCs|dkst|t r7ttjtdnt|dkrdttjtdntj |}|j dkrt |_ nx+|j j D]}|j ||j |t append_critRR((s criteria.pyR<jscCsS|dkr'ttjtdn|jrO||jkrO|j|=qOndS(sRemove criteria from Criteria object. This method simply removes the specified criteria key from the list of stored criteria on this object. To amend a specific criteria use the append() method providing a new value for the criteria to be replaced. If the criteria to be removed does not exist, this method does nothing Parameters criteria: string Criteria key to be removed from this criteria object Return Value None Errors / Exceptions AIServerError The following error types can be raised by this method: - Insufficient Arguments This signifies a non string criteria parameter was passed in s-Error: Missing criteria parameter for removalN(R7RRRRR(RR((s criteria.pytremoves  cCsg}x9tj|j|dtdtD]}|j|q+Wx|jD]}t|j|dts||krtt j t d|qqLd||krLd||krLtt j t d|qLqLWdS( s Validate that criteria from Criteria object exists on the database Parameters dbo: ai_database object An ai_database object for the install service. table: String Name of database table Return Value None Errors / Exceptions AIServerError The following error types can be raised by this method: - Invalid Value The criteria is not found in database t only_usedR%is+Error: Criteria %s is not a valid criteria!tMINtMAXs-Error: Criteria '%s' is not a valid criteria!N( Rt get_criteriat get_queueRR<RRR:RRR3R(RtdbottabletcritlistR((s criteria.pytvalidate_criteria_in_databases    cCs$|dks|tkrtStSdS(sxValidate if specified criteria string is a valid criteria name Returning True if valid and False if not N(R7R5RR(R&R((s criteria.pytvalidate_criteria_stringsc Cs.d }|d ks*|d ks*|d kr.d Stj|jd|dtdt}|tjkrtj|d|j|dtdt}n@|tjkrtj|d |j|dtdt}nd S|d ks|d krd St |t |kr d St }x|D]} | j dr4qn| j ddd }|t | } |tkr| } d|} |t | } | dkrd } n| dkrd } n| d kr| d krqn|d }| d krd }nH|tkr tj| }n*|tkr%t | }ntj| }| d krId }nH|tkrgtj| }n*|tkrt | }ntj| }||kr||7}n||d |7}|j|q| d kst | dkrqn|d | }|j|qW|r*tj||}n|S(sReturn a Criteria object constructed from the contents of the database for this manifest/profile. Parameters: name: string Manifest or Profile name db: AIdb database object Database object to query table: string Name of database table to query strict_validation: boolean Adhere to strict criteria value validation. For backwards compatibility creating criteria from DB defaults to False to not enforce strict validation. Return Value: Criteria object or None Errors / Exceptions: None RRR%it human_outputRRR+iR-R0R/N(R7RRRRtMANIFESTS_TABLEtget_table_criteriaRtPROFILES_TABLER=Rt startswithR1RnR8R[R\tformat_db_valueR]RZR<RR#(R&R.tdbRRtret_critt crit_keyst crit_valuesRDRRtminvaltmax_keytmaxvalRtminstrtmaxstr((s criteria.pyt_from_dbsz$                      N(t__name__t __module__t__doc__R7RR tpropertyRR!t classmethodR)R#Rt staticmethodR9RPRzRRRRRRRRR<RRRR(((s criteria.pyR7s:6 J- =N C $  | * ! + R\cBseZdZedZdefdYZdZedZ ddZ e dZ e d Z ed Zd Zd Zd ZdZdZRS(s1 Class to store and verify MAC addresses s"Error: Malformed MAC address: '%s'RhcBseZdZRS(sD Class to report MAC address mal-formatted problems (RRR(((s criteria.pyRhescCs|j|jd}t|dkr@|jtj|ntt|j|y tt dj |dWn't k r|jt d|nXdS(s Initialize a MAC address object. Will verify the address is reasonable. Can accept ':' or '-' delimited addresses or hex strings with no punctuation (and is case insensitive) Parameters mac: String A string containing the mac address. Return Value None Errors / Exceptions MACAddressError The given mac address is not acceptable. t:iR+is>Failed to convert MAC address '%s', to valid hexadecimal valueN( tformatR$R=RhR\tMSG_MALFORMED_MACtsuperR RRnRst ValueErrorR(RR RF((s criteria.pyR ks   cCs|s|jtdnd|krKd|krK|jdd}nd|kr:t}x|jdD]}t|dks|jddkst|dkr|ddkr|jtj|nt|dkr|g}n3|ddkrd|dg}n|d dg}|j |qpWnd|krX|jd}nt|d kr|dd!d kr|d}nt|d kr|jtj|ngt dt|ddD]}|||d!^q}t|d ks;t g|D]*}dt|kp/t|dk^qkrQ|jtj|nt}x|D]}yud|kr|j |nUdt |d kodknr|j dt |d n|jtj|Wqattfk r|jtj|qaXqaWdj|S(sR Format the given MAC string and returns the result. Formatting allows the use of '*' in a single octet, so for example a MAC address like '1:2:3:*' will return '01:02:03:*'. Can accept ':' or '-' delimited addresses. Parameters mac: String A string containing the mac address or pattern to be formatted Return Value String A ':' separated valid MAC address or pattern Errors / Exceptions MACAddressError The given argument is not acceptable. s+Error: MACAddress class expects an argumentR/Rt*iiiiit01i iiis%.2X(RhRR1RR$R=tcountR\RtextendRRR<tintt TypeErrorRRs(R&R REtoctetRFtxt formatted_mac((s criteria.pyRsT  '"  % ::   %RcCs |j|S(s> Return a delimiter punctuated representation (Rs(Rtsep((s criteria.pyRsscCstt|jdS(s? Return MAC address as represented on database i(RRnRQ(R((s criteria.pyRscCs t|S(sD Return MAC Address as represented in SQL statement (Rn(R((s criteria.pyt sql_valuescCs\|dd!d|dd!d|dd!d|dd!d|dd!d|dd!}|S( sR Return a string formatted MAC address constructed from an string iiRiiii i ((R&RFtret((s criteria.pyRsXcCs dj|S(sB Return a non-delimiter punctuated representation R+(Rs(R((s criteria.pyRz scCs$t|t|krtStSdS(s6 Compare two MAC address for equality N(RnRR(Rtother((s criteria.pyt__eq__scCs$t|t|krtStSdS(s: Compare two MAC address for Non equality N(RnRR(RR((s criteria.pyt__ne__scCs$t|t|krtStSdS(s@ Compare two MAC address lesss than or equal to N(RnRR(RR((s criteria.pyt__le__$scCs$t|t|krtStSdS(sF Compare two MAC address for greater than or equal to N(RnRR(RR((s criteria.pyt__ge__-s(RRRRRt ExceptionRhR RRRsRRRRRzRRRR(((s criteria.pyR\^s  $_   RZcBseZdZedZdefdYZdZddZe dZ e dZ e d Z e d Ze d Zd Zd ZdZdZdZRS(s2 Class to store and verify IPv4 addresses s#Error: Malformed IPv4 address: '%s'RgcBseZdZRS(sE Class to report IPv4 address mal-formatted problems (RRR(((s criteria.pyRg>scCs|s|jtdnt|tsO|jtdt|nnd|krm|jd}nPt|dkr|d |dd!|dd!|dg}n|jtj|t|dkr|jtj|nyUt g|D](}d t |kod kn^qkr9|jtj|nWn*t t fk rf|jtj|nXg|D]}|j d^qn}tt|j|yttd j|}Wn't k r|jtd |nX|d kr |jtd |ndS(s Initialize a IPv4 address object. Will verify the address is reasonable. Can accept '.' delimited addresses only Parameters ipv4: String A string containing the ipv4 address. Return Value None Errors / Exceptions IPv4AddressError The given apv4 address is not acceptable. s,Error: IPv4Address class expects an arguments+Error: Argument is not an IPv4Address: '%s't.i iii iiiR+sBError: Failed to convert IPv4 address '%s', to valid integer valuesJError: Invalid IPv4 address '%s', one decimal range must be greater than 0N(RgRRt basestringRnR$R=RZtMSG_MALFORMED_IPV4RRRRtzfillRR RRs(RR RERFRtint_val((s criteria.pyR DsB + ;"     RcCs|jd|DS(s> Return a delimiter punctuated representation css!|]}tt|VqdS(N(RnR(Rti((s criteria.pys s(Rs(RR((s criteria.pyRsscCstt|jS(s@ Return IPv4 address as represented on database (RRnRQ(R((s criteria.pyRscCs t|S(sE Return IPv4 Address as represented in SQL statement (Rn(R((s criteria.pyRscCs~dt|}tt|dd!dtt|dd!dtt|dd!dtt|dd!}|S(sS Return a string formatted IPv4 address constructed from an string s%12.12diiRii i (RRnR(R&RFtsvalueR((s criteria.pyRsPcCsyt|d}Wn%tk r;}ttj|nX|dkrmttjtdt|nt|jd}d}xa|dkrt|||}t|d||<|dkr|d}|d8}qd}qWtdj |S(s;Returns the IP address with an offset of ip_count addressesiisError: Invalid IP count: '%s'Riii( RRRRR3RRnR$RZRs(R&tip_starttip_countt value_errortfinishRRF((s criteria.pytoffsets$       cCs|jd}|jd}t|dt|ddt|dt|ddt|dt|ddt|dt|ddS( sqReturn the number of IP addresses that can be allocated between the ip_start and ip_finish range Riiiiiii(R$R(R&Rt ip_finishtstartR ((s criteria.pyRscCs dj|S(sB Return a non-delimiter punctuated representation R+(Rs(R((s criteria.pyRzscCs$t|t|krtStSdS(s, Compare two IPv4 Addresses N(RnRR(RR((s criteria.pyRscCs$t|t|krtStSdS(s, Compare two IPv4 Addresses N(RnRR(RR((s criteria.pyRscCs$t|t|krtStSdS(s, Compare two IPv4 Addresses N(RnRR(RR((s criteria.pyRscCs$t|t|krtStSdS(s, Compare two IPv4 Addresses N(RnRR(RR((s criteria.pyRs(RRRRRRRgR RsRRRRRR RRzRRRR(((s criteria.pyRZ7s  D    R^cBseZdZdefdYZdZdZdZedZ edZ edZ d Z d Z d Zd ZRS( s/ Class to store and verify Memory size RicBseZdZRS(s6 Class to report Memory size problems (RRR(((s criteria.pyRiscCs|s|jtdnyt|}Wn*tk rZ|jtd|nX|dkr|jtd|n||_dS(s Initialize a MemorySize object. Will verify the memory is reasonable. Raises: MemorySizeError if not acceptable. s,Error: Memory size class expects an arguments"Error: Malformed memory size: '%s'is(Error: Memory size '%s' must be positiveN(RiRRRt_size(RtsizeRF((s criteria.pyR s   cCs t|jS(s. Return memory size as string (RnR(R((s criteria.pyRzscCst|jdS(s? Return memory size with unit descriptive name s MB(RnR(R((s criteria.pytstr_with_unit_name$scCstt|S(s? Return Memory Size as represented on database (RRn(R((s criteria.pyR*scCs t|jS(sD Return Memory Size as represented in SQL statement (RnR(R((s criteria.pyR1scCs|jS(s$ Return actual size (R(R((s criteria.pyR8scCs|j|jkrtStSdS(s7 Compare two size objects for equality N(RRR(RR((s criteria.pyR?scCs|j|jkrtStSdS(s; Compare two size objects for non equality N(RRR(RR((s criteria.pyRHscCs|j|jkrtStSdS(sD Compare two size objects for less than or equal to N(RRR(RR((s criteria.pyRQscCs|j|jkrtStSdS(sG Compare two size objects for greater than or equal to N(RRR(RR((s criteria.pyRZs(RRRRRiR RzRRRRRRRRR(((s criteria.pyR^s    RTcBsieZdZdefdYZedZedZdZ dZ dZ edZ RS( s0 Class to store and verify Architecture RdcBseZdZRS(s7 Class to report architecture problems (RRR(((s criteria.pyRdiscCsv|s|jtdn|r`|tkr`tdi|d6td6}|j|n||_||_dS(s Initialize a Architecture object. Will verify the arch is valid. Raises: ArchitectureError if not acceptable. s-Error: Architecture class expects an argumentsVError: Architecture '%(value)s' is not listed in list of known architectures: %(arch)sRFRN(RdRRt_archR(RRRterr_msg((s criteria.pyR os  cCs t|jS(sF Return architecture value as represented on database (RnR(R((s criteria.pyRscCsA|j r0|jtkr0t|jtdSt|jSdS(s/ Return architecture as string s (unvalidated)N(RRRRnR(R((s criteria.pyRzscCs|j|jkrtStSdS(s? Compare two Architectire objects for equality N(RRR(RR((s criteria.pyRscCs|j|jkrtStSdS(sC Compare two Architectire objects for non equality N(RRR(RR((s criteria.pyRscCs|jS(s/ return the architecture value (R(R((s criteria.pyRs( RRRRRdRR RRRzRRR(((s criteria.pyRTds  RVcBsieZdZdefdYZedZedZdZ dZ dZ edZ RS( s- Class to store and verify CPU class RecBseZdZRS(s4 Class to report CPU class problems (RRR(((s criteria.pyRescCsv|s|jtdn|r`|tkr`tdi|d6td6}|j|n||_||_dS(sz Initialize a CPU object. Will verify the CPU class is valid. Raises: CPUError if not acceptable. s$Error: CPU class expects an argumentsQError: CPU class '%(value)s' is not listed in list of known CPU classes: %(cpus)sRFtcpusN(ReRRt_cpuR(RR RR((s criteria.pyR s  cCs t|jS(s= Return CPU value as represented on database (RnR (R((s criteria.pyRscCsA|j r0|jtkr0t|jtdSt|jSdS(s& Return CPU as string s (unvalidated)N(RR RRnR(R((s criteria.pyRzscCs|j|jkrtStSdS(s6 Compare two CPU objects for equality N(R RR(RR((s criteria.pyRscCs|j|jkrtStSdS(s: Compare two CPU objects for non equality N(R RR(RR((s criteria.pyRscCs|jS(s& return the CPU value (R(R((s criteria.pyR s( RRRRReRR RRRzRRR (((s criteria.pyRVs  RXcBsfeZdZdefdYZdZedZdZdZ dZ edZ RS( s, Class to store and verify hostname RfcBseZdZRS(s3 Class to report hostname problems (RRR(((s criteria.pyRfscCs+|s|jtdn||_dS(s Initialize a hostname object. Will verify the hostname class is valid. Raises: HostnameError if not acceptable. s)Error: Hostname class expects an argumentN(RfRt _hostname(RR ((s criteria.pyR scCs t|jS(s< Return hostname as represented on database (RnR (R((s criteria.pyR scCs t|jS(s+ Return Hostname as string (RnR (R((s criteria.pyRzscCs|j|jkrtStSdS(s; Compare two hostname objects for equality N(R RR(RR((s criteria.pyRscCs|j|jkrtStSdS(s? Compare two hostname objects for non equality N(R RR(RR((s criteria.pyR scCs|jS(s+ return the hostname value (R(R((s criteria.pyR )s( RRRRRfR RRRzRRR (((s criteria.pyRXs   RacBsfeZdZdefdYZdZedZdZdZ dZ edZ RS( s, Class to store and verify platform RjcBseZdZRS(s3 Class to report platform problems (RRR(((s criteria.pyRj6scCs+|s|jtdn||_dS(s Initialize a platform object. Will verify the platform class is valid. Raises: PlatformError if not acceptable. s)Error: Platform class expects an argumentN(RjRt _platform(RR((s criteria.pyR <scCs t|jS(s< Return platform as represented on database (RnR(R((s criteria.pyRHscCs t|jS(s+ Return Platform as string (RnR(R((s criteria.pyRzOscCs|j|jkrtStSdS(s; Compare two platform objects for equality N(RRR(RR((s criteria.pyRUscCs|j|jkrtStSdS(s? Compare two platform objects for non equality N(RRR(RR((s criteria.pyR^scCs|jS(s+ return the platform value (R(R((s criteria.pyRgs( RRRRRjR RRRzRRR(((s criteria.pyRa1s   RccBsfeZdZdefdYZdZedZdZdZ dZ edZ RS( s, Class to store and verify zonename RkcBseZdZRS(s3 Class to report zonename problems (RRR(((s criteria.pyRktscCs+|s|jtdn||_dS(s Initialize a zonename object. Will verify the zonename class is valid. Raises: ZonenameError if not acceptable. s)Error: Zonename class expects an argumentN(RkRt _zonename(RR((s criteria.pyR zscCs t|jS(s< Return zonename as represented on database (RnR(R((s criteria.pyRscCs t|jS(s+ Return Zonename as string (RnR(R((s criteria.pyRzscCs|j|jkrtStSdS(s; Compare two zonename objects for equality N(RRR(RR((s criteria.pyRscCs|j|jkrtStSdS(s? Compare two zonename objects for non equality N(RRR(RR((s criteria.pyRscCs|jS(s+ return the zonename value (R(R((s criteria.pyRs( RRRRRkR RRRzRRR(((s criteria.pyRcos   R:cBseZdZdefdYZdZdZdZedZ edZ edZ ed Z ed Z ed Zd ZRS( sz Class to represent a Range of values Contains a two element list for upper and lower boundaries of the range R;cBseZdZRS(s0 Class to report range problems (RRR(((s criteria.pyR;scCs|s|jtdnt|tsE|jtdnt|dkro|jtdn|ds|drD|dr|d}n |d}|rDt|dd}t|dd}t|d d}t|d d}t| s&t| s&t| s&t| rA|jtd qAqDn|dr|drt|dt|dkr|jtd n|d|dks|jtd qn||_ dS(s Initialize a range object. Parameters: ranges : 2 element list Each element of a range object must implement the following comparison methods : equals : __eq__() not equals : __ne__() less than or equal : __le__() greather than or equal : __ge__() Lower/upper bounds value of None indicates unbounded Where both lower/upper bounds values are provided they must be of the same type Raises: RangeError : validation error s&Error: Range class expects an arguments(Error: Ranges must be provided as a listis2Error: Must provide only 2 values for range valuesiiRRRRs/Error: Range element missing comparison methodss0Error: Range boundaries must be of the same typesIError: Range lower boundary must be less than or equal to upper boundary.N( R;RRRR=tgetattrR7tcallableRmt_ranges(RRItcheckobjteqtnetgetle((s criteria.pyR s2    cCs|ru|j rut|t|jdkrG|jtdn||jdksu|jtdqun||jdsD  (    +gHG>>>