h'dWc @sdZddkZddkZddklZddklZlZddk l Z l Z l Z lZlZdZdZdZd 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|o}t|tpttitdnxN|iD]<\}}t|tp ttitd|q@q@Wn||_||_ |io|i 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|iS(s?This is reference to the entire set of criteria as a dictionary(R(R((s../criteria.pyRvscCs|iS(s4Return if this criteria adheres to strict validation(R(R((s../criteria.pytstrictly_validated{scCs:tig}|idD]}||iq~|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_stringRt_[1]ts((s../criteria.pyt from_strings &c Cs5t}x|D]}|iddiddid\}}}|p ttitd|n|i}|o]|tjo ttitd|n\||jo'tti tdh|d6n(|p ttitd |nt }|i } x| D]} d} d} | id } |t jo| d o| d  p | d  o ttitd| n| d idjoti|| d |} n| d idjoti|| d |} nyt| | g}WqYtij o}tti|qYXnti|| |}|t joXt|t oGyt||g}Wqtij o}tti|qXn|i|q$W|||-) 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|iiD]}|tjo ttitd|n|tjoAt|i|djo'ttitdh|d6nx8|i|D])}|t jo1t |t  o ttitd|nE|t jo7t |t o'ttitdh|d6nt |t o|i o1|i o'ttitdh|d6n|ioti||in|ioti||iqqti||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(RtkeysR6RRR4Rt LIST_CRITERIAR>R9RR;tis_lower_unboundedtis_upper_unboundedR5Rt_validate_crit_objtupper(RtkeyR((s../criteria.pyRsB '       c Cs| p| o.ttitdh|d6|d6n|tjo.ttitdh|d6|d6nd}y|tjot||}n|tjot ||}n|t jot |}n|t jot |}n|tjot|}nu|tjot|}nX|tjot |}n;|tjot|}n|tjot|}nWnWtit it it ititititifj o}tti|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'RSRs2Error: Invalid criteria key: '%(key)s' : '%(val)s'N(RRR4RR6R8t ARCH_CRITt ArchitecturetCPU_CRITtCPUt HOSTNAME_CRITtHostnamet IPV4_CRITt IPv4AddresstMAC_CRITt MACAddresstMEM_CRITt MemorySizet NETWORK_CRITt PLATFORM_CRITtPlatformt ZONENAME_CRITtZonenametArchitectureErrortCPUErrort HostnameErrortIPv4AddressErrortMACAddressErrortMemorySizeErrort PlatformErrort ZonenameError(RSRRtcrit_objRL((s../criteria.pyR:isH               cCsL|tjot|t p|tjot|t p|tjot|t p|tjot|t p|t jot|t  px|t jot|t  pZ|t jot|t p<|tjot|t p|tjoKt|t o:ttitdh|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)sRSttypeN(RTRRURVRWRXRYRZR[R\R]R^R_R`RaRbRcRdRRR4RtstrRn(RStobj((s../criteria.pyRQs cCs|iotttdt}g}xt|iiD]l\}}g}x%|D]}|idt|qWWdi|}|id|i |d|fq>Wdi|SdSdS( sPretty print criteriaRSs%ss, s%s = %st s R,N( RR>tmaxR6tsortedRR=Rotjointljust(Rtmaxlentstr_listRRFtval_listtvltval_str((s../criteria.pyt__str__s  'c Csk|d jod Stiitp ttitdtnt td}t i i dt dt dt dtdt}yt i it||}Wn=t i ij o+}ttitd|iinXti|tt i i|i\}}|o4ttitd h|id 6|id 6ntid ti||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(R8tostpathtexiststCRITERIA_RNG_SCHEMARRR7Rtopentlxmltetreet XMLParsertFalsetTruetparseRtXMLSyntaxErrort error_logt last_errorRtverify_relaxng_manifestttostringtgetrootRtmessageRtdebugRt_from_criteria_dom( R&tcriteria_xml_stringRtschematparsertcritRLtrootterrors((s../criteria.pytfrom_criteria_xmls4   ' "c Cs|d jod St}t}x|idD]}|idi}xn|iD]`}|idjp|idjo|id j o|tjo t t i t d|n||jo't t i t dh|d6n|idjo4|tjo't t i t dh|d6n|idjo*|ii}|dd i|} n|d|i} |i| |i|qZt t i t d |qZWq4Wti||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/trangeRGs Error: Invalid criteria type: %ss3Error: Criteria '%(name)s' specified more than onces<Error: Criteria '%(name)s' can not be passed as a range pairR.R0s(Error: Criteria contains no values: '%s'N(R8RtfindalltattribR5t getchildrenttagttextR6RRR4RR7R9R$RtR=RR#( R&RRREtkey_listRRStchildt range_valuestcrit_str((s../criteria.pyRsF          cs pi p i otStiitii}}|i|}|ot|t|jotSt|tijotStfd|DotStSdS(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. c3sDx=|]6}i|i|i|p |VqqWdS(N(t_isequalR(t.0Rp(t param_critRtcollision_detection(s../criteria.pys s  N(RRtsetRMt intersectionR>R(RRt match_allRtosettpsett intersect((RRRs../criteria.pytmatchesGs)+ #cCsVt|ijodnd|itodndt|ijodnd|itodndt|ijodndt|ijodndt|ijodndt|ijodndt|ijodnd|it odndt |ijodnd|it odndt |ijodndf 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( RXRt_range_is_uniqueR\RZRcRaRTRVR`R^(R((s../criteria.pytgenerate_sorting_tuplescCs|dj o |}n |i}t}||jo]t||dtoE||d}|i o(|i o|i|ijo t }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( R8RRRR;RORPR5RRR(RRSRtcheck_criteriat unique_ranget range_crit((s../criteria.pyRs   %  c Cs t}t|djo0|d}x|D]}|tjo|io |ip|io|io t}q5|i||\}} |i||\} } |o5| |jo | | jp | | jo t}qq5|| jo| | jo t}q5t}n-t|ti t|jo t}n|oPq*q*Wn|tjo t t i t d|n|pt t i t dntg} |D]} | t| q~ }tg}|D]} |ti t| q~}|i|}|o t}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>R9RORPRtget_criteria_boundary_valuesRotAIdbt sanitize_sqlRRR4RRR(RRSt obj_criteriatparam_criteriaRtret_valt param_valRt crit_lowert crit_uppert param_lowert param_upperR(tcRt_[2]RR((s../criteria.pyRsP(              "     -6 cCstd}td}t|tp ||fS|iotd}n |ii}|io0|djottd}qtt}n |ii}||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;ROR5tdb_valueRPtINFINITYRR(RRSRR5RR((s../criteria.pyRJs        cCs|djpt|t ottitdnt|djottitdnti |}|i djot |_ nx+|i i D]}|i ||i |RR#RRRRM(RR?t append_critRS((s../criteria.pyR=jscCsY|djottitdn|io"||ijo|i|=qUndS(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(R8RRRRR(RR((s../criteria.pytremoves  cCsg}x9ti|i|dtdtD]}|i|q+Wx|iD]}t|i|dtp1||jo tt i t d|qqLd||jo1d||jo tt i 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;RRR4R(RtdbottabletcritlistR((s../criteria.pytvalidate_criteria_in_databases"   "cCs'|djp |tjotStSdS(sxValidate if specified criteria string is a valid criteria name Returning True if valid and False if not N(R8R6RR(R&R((s../criteria.pytvalidate_criteria_stringsc CsYd }|d jp|d jp |d jod Sti|id|dtdt}|tijo.ti|d|i|dtdt}nC|tijo.ti|d |i|dtdt}nd S|d jp |d jod St |t |jod St }x|D]} | i doq&n| i ddd }|t | } |tjo}| } d|} |t | } | djo d } n| djo d } n| d jo| d joq&n|d }| d jo d }nM|tjoti| }n-|tjot | }nti| }| d jo d }nM|tjoti| }n-|tjot | }nti| }||jo||7}n||d |7}|i|q&| d jpt | djoq&n|d | }|i|q&W|oti||}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.R1R0N(R8RRRRtMANIFESTS_TABLEtget_table_criteriaRtPROFILES_TABLER>Rt startswithR2RoR9R\R]tformat_db_valueR^R[R=RR#(R&R/tdbRRtret_critt crit_keyst crit_valuesRERRtminvaltmax_keytmaxvalRtminstrtmaxstr((s../criteria.pyt_from_dbs|'                     N(t__name__t __module__t__doc__R8RR tpropertyRR!t classmethodR*R#Rt staticmethodR:RQR{RRRRRRRRR=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'RicBseZdZRS(sD Class to report MAC address mal-formatted problems (RRR(((s../criteria.pyRiescCs|i|id}t|djo|iti|ntt|i|y tt di |dWn)t j o|it 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>RiR]tMSG_MALFORMED_MACtsuperR RRoRtt ValueErrorR(RR RG((s../criteria.pyR ks  c CsL|p|itdnd|jo#d|jo|idd}nd|jot}x|idD]}t|djp:|iddjp$t|djo(|ddjo|iti|nt|djo |g}n6|ddjod|dg}n|d dg}|i |qvWnd|jo|id}nt|d jo"|dd!d jo|d}nt|d jo|iti|ng}t dt|ddD]}||||d!q~}t|d jpGt g}|D],}|dt|jpt|djq,~jo|iti|nt}x|D]}yzd|jo|i |nYdt |d jo djno|i dt |d n|iti|Wqttfj o|iti|qXqWdi|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 argumentR0Rt*iiiiit01i iiis%.2X(RiRR2RR$R>tcountR]RtextendRRR=tintt TypeErrorRRt( R&R RFtoctetRGR(txRt formatted_mac((s../criteria.pyRsX  )$  'BD  'RcCs |i|S(s> Return a delimiter punctuated representation (Rt(Rtsep((s../criteria.pyRtscCstt|idS(s? Return MAC address as represented on database i(RRoRR(R((s../criteria.pyRscCs t|S(sD Return MAC Address as represented in SQL statement (Ro(R((s../criteria.pyt sql_valuesc Cs\|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&RGtret((s../criteria.pyRsXcCs di|S(sB Return a non-delimiter punctuated representation R,(Rt(R((s../criteria.pyR{ scCs&t|t|jotStSdS(s6 Compare two MAC address for equality N(RoRR(Rtother((s../criteria.pyt__eq__scCs&t|t|jotStSdS(s: Compare two MAC address for Non equality N(RoRR(RR((s../criteria.pyt__ne__scCs&t|t|jotStSdS(s@ Compare two MAC address lesss than or equal to N(RoRR(RR((s../criteria.pyt__le__$scCs&t|t|jotStSdS(sF Compare two MAC address for greater than or equal to N(RoRR(RR((s../criteria.pyt__ge__-s(RRRRRt ExceptionRiR RRRtRRRRR{RRRR(((s../criteria.pyR]^s  $_   R[cBseZdZedZdefdYZdZddZe 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'RhcBseZdZRS(sE Class to report IPv4 address mal-formatted problems (RRR(((s../criteria.pyRh>scCs4|p|itdnt|tp#|itdt|nsd|jo|id}nSt|djo,|d |dd!|dd!|dg}n|iti|t|djo|iti|ny`t g}|D]*}|d t |jo d jnq~jo|iti|nWn,t t fj o|iti|nXg}|D]}||i dq~}tt|i|yttd i|}Wn)t j o|itd |nX|d jo|itd |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(RhRRt basestringRoR$R>R[tMSG_MALFORMED_IPV4RRRRtzfillRR RRt(RR RFR(RGRRtint_val((s../criteria.pyR DsB , E*    RcCs|id|DS(s> Return a delimiter punctuated representation css%x|]}tt|VqWdS(N(RoR(Rti((s../criteria.pys s (Rt(RR((s../criteria.pyRtscCstt|iS(s@ Return IPv4 address as represented on database (RRoRR(R((s../criteria.pyRscCs t|S(sE Return IPv4 Address as represented in SQL statement (Ro(R((s../criteria.pyRsc Cs~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 (RRoR(R&RGtsvalueR((s../criteria.pyRsPcCsyt|d}Wn'tj o}tti|nX|djo&ttitdt|nt|id}d}xe|djoWt|||}t|d||<|djo|d}|d8}qd}qWtdi |S(s;Returns the IP address with an offset of ip_count addressesiisError: Invalid IP count: '%s'Riii( RRRRR4RRoR$R[Rt(R&tip_starttip_countt value_errortfinishRRG((s../criteria.pytoffsets&       cCs|id}|id}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&R t ip_finishtstartR ((s../criteria.pyRscCs di|S(sB Return a non-delimiter punctuated representation R,(Rt(R((s../criteria.pyR{scCs&t|t|jotStSdS(s, Compare two IPv4 Addresses N(RoRR(RR((s../criteria.pyRscCs&t|t|jotStSdS(s, Compare two IPv4 Addresses N(RoRR(RR((s../criteria.pyRscCs&t|t|jotStSdS(s, Compare two IPv4 Addresses N(RoRR(RR((s../criteria.pyRscCs&t|t|jotStSdS(s, Compare two IPv4 Addresses N(RoRR(RR((s../criteria.pyRs(RRRRRRRhR RtRRRRRR RR{RRRR(((s../criteria.pyR[7s  D    R_cBseZdZdefdYZdZdZdZedZ edZ edZ d Z d Z d Zd ZRS( s/ Class to store and verify Memory size RjcBseZdZRS(s6 Class to report Memory size problems (RRR(((s../criteria.pyRjscCs|p|itdnyt|}Wn,tj o |itd|nX|djo|itd|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(RjRRRt_size(RtsizeRG((s../criteria.pyR s cCs t|iS(s. Return memory size as string (RoR(R((s../criteria.pyR{scCst|idS(s? Return memory size with unit descriptive name s MB(RoR(R((s../criteria.pytstr_with_unit_name$scCstt|S(s? Return Memory Size as represented on database (RRo(R((s../criteria.pyR*scCs t|iS(sD Return Memory Size as represented in SQL statement (RoR(R((s../criteria.pyR1scCs|iS(s$ Return actual size (R(R((s../criteria.pyR8scCs |i|ijotStSdS(s7 Compare two size objects for equality N(RRR(RR((s../criteria.pyR?scCs |i|ijotStSdS(s; Compare two size objects for non equality N(RRR(RR((s../criteria.pyRHscCs |i|ijotStSdS(sD Compare two size objects for less than or equal to N(RRR(RR((s../criteria.pyRQscCs |i|ijotStSdS(sG Compare two size objects for greater than or equal to N(RRR(RR((s../criteria.pyRZs(RRRRRjR R{RRRRRRRRR(((s../criteria.pyR_s    RUcBsieZdZdefdYZedZedZdZ dZ dZ edZ RS( s0 Class to store and verify Architecture RecBseZdZRS(s7 Class to report architecture problems (RRR(((s../criteria.pyReiscCs{|p|itdn|o>|tjo1tdh|d6td6}|i|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)sRGRN(ReRRt_archR(RRRterr_msg((s../criteria.pyR os  cCs t|iS(sF Return architecture value as represented on database (RoR(R((s../criteria.pyRscCsD|i o(|itjot|itdSt|iSdS(s/ Return architecture as string s (unvalidated)N(RRRRoR(R((s../criteria.pyR{scCs |i|ijotStSdS(s? Compare two Architectire objects for equality N(RRR(RR((s../criteria.pyRscCs |i|ijotStSdS(sC Compare two Architectire objects for non equality N(RRR(RR((s../criteria.pyRscCs|iS(s/ return the architecture value (R(R((s../criteria.pyRs( RRRRReRR RRR{RRR(((s../criteria.pyRUds  RWcBsieZdZdefdYZedZedZdZ dZ dZ edZ RS( s- Class to store and verify CPU class RfcBseZdZRS(s4 Class to report CPU class problems (RRR(((s../criteria.pyRfscCs{|p|itdn|o>|tjo1tdh|d6td6}|i|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)sRGtcpusN(RfRRt_cpuR(RR RR((s../criteria.pyR s  cCs t|iS(s= Return CPU value as represented on database (RoR (R((s../criteria.pyRscCsD|i o(|itjot|itdSt|iSdS(s& Return CPU as string s (unvalidated)N(RR RRoR(R((s../criteria.pyR{scCs |i|ijotStSdS(s6 Compare two CPU objects for equality N(R RR(RR((s../criteria.pyRscCs |i|ijotStSdS(s: Compare two CPU objects for non equality N(R RR(RR((s../criteria.pyRscCs|iS(s& return the CPU value (R(R((s../criteria.pyR s( RRRRRfRR RRR{RRR (((s../criteria.pyRWs  RYcBsfeZdZdefdYZdZedZdZdZ dZ edZ RS( s, Class to store and verify hostname RgcBseZdZRS(s3 Class to report hostname problems (RRR(((s../criteria.pyRgscCs-|p|itdn||_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(RgRt _hostname(RR ((s../criteria.pyR scCs t|iS(s< Return hostname as represented on database (RoR (R((s../criteria.pyR scCs t|iS(s+ Return Hostname as string (RoR (R((s../criteria.pyR{scCs |i|ijotStSdS(s; Compare two hostname objects for equality N(R RR(RR((s../criteria.pyRscCs |i|ijotStSdS(s? Compare two hostname objects for non equality N(R RR(RR((s../criteria.pyR scCs|iS(s+ return the hostname value (R(R((s../criteria.pyR )s( RRRRRgR RRR{RRR (((s../criteria.pyRYs   RbcBsfeZdZdefdYZdZedZdZdZ dZ edZ RS( s, Class to store and verify platform RkcBseZdZRS(s3 Class to report platform problems (RRR(((s../criteria.pyRk6scCs-|p|itdn||_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(RkRt _platform(RR((s../criteria.pyR <scCs t|iS(s< Return platform as represented on database (RoR(R((s../criteria.pyRHscCs t|iS(s+ Return Platform as string (RoR(R((s../criteria.pyR{OscCs |i|ijotStSdS(s; Compare two platform objects for equality N(RRR(RR((s../criteria.pyRUscCs |i|ijotStSdS(s? Compare two platform objects for non equality N(RRR(RR((s../criteria.pyR^scCs|iS(s+ return the platform value (R(R((s../criteria.pyRgs( RRRRRkR RRR{RRR(((s../criteria.pyRb1s   RdcBsfeZdZdefdYZdZedZdZdZ dZ edZ RS( s, Class to store and verify zonename RlcBseZdZRS(s3 Class to report zonename problems (RRR(((s../criteria.pyRltscCs-|p|itdn||_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(RlRt _zonename(RR((s../criteria.pyR zscCs t|iS(s< Return zonename as represented on database (RoR(R((s../criteria.pyRscCs t|iS(s+ Return Zonename as string (RoR(R((s../criteria.pyR{scCs |i|ijotStSdS(s; Compare two zonename objects for equality N(RRR(RR((s../criteria.pyRscCs |i|ijotStSdS(s? Compare two zonename objects for non equality N(RRR(RR((s../criteria.pyRscCs|iS(s+ return the zonename value (R(R((s../criteria.pyRs( RRRRRlR RRR{RRR(((s../criteria.pyRdos   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|p|itdnt|tp|itdnt|djo|itdn|dp |do|do|d}n |d}|ot|dd}t|dd}t|d d}t|d d}t| p*t| pt| pt| o|itd qRqVn|dow|dolt|dt|djo|itd n|d|djp|itd 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>tgetattrR8tcallableRnt_ranges(RRJtcheckobjteqtnetgetle((s../criteria.pyR s2  !!cCs|ou|i ojt|t|idjo|itdn||idjp|itdq|n||idsD  (    +gHG>>>