*CeddlmZddlmZddlZddlmZmZGddeZGdd eZ Gd d eZ Gd d eZ GddeZ GddeZ GddeZGddeZGddeZGddeZGddeZGddeZGddeZed Zed!ej.e j0ee j2eiej4e j6ee j8eiej:ed"ej<e j>ee j@eiejBe jDeiejFe jHeiiZ%d#Z&d$e'fd%Z(y)&) defaultdict)IntEnumN)ffilibc$eZdZdZdZdZdZdZdZy)NETPLAN_ERROR_DOMAINSrN) __name__ __module__ __qualname__NETPLAN_PARSER_ERRORNETPLAN_VALIDATION_ERRORNETPLAN_FILE_ERRORNETPLAN_BACKEND_ERRORNETPLAN_EMITTER_ERRORNETPLAN_FORMAT_ERROR0/usr/lib/python3/dist-packages/netplan/_utils.pyr r s& rr ceZdZdZdZy)NETPLAN_PARSER_ERRORSrrN)rrrNETPLAN_ERROR_INVALID_YAMLNETPLAN_ERROR_INVALID_CONFIGrrrrr$s!"#$ rrceZdZdZdZy)NETPLAN_VALIDATION_ERRORSrrN)rrrNETPLAN_ERROR_CONFIG_GENERICNETPLAN_ERROR_CONFIG_VALIDATIONrrrr r )s#$ &'#rr ceZdZdZdZy)NETPLAN_BACKEND_ERRORSrrN)rrrNETPLAN_ERROR_UNSUPPORTEDNETPLAN_ERROR_VALIDATIONrrrr$r$.s ! rr$ceZdZdZy)NETPLAN_EMITTER_ERRORSrN)rrrNETPLAN_ERROR_YAML_EMITTERrrrr(r(3s!"rr(ceZdZdZy)NETPLAN_FORMAT_ERRORSrN)rrr!NETPLAN_ERROR_FORMAT_INVALID_YAMLrrrr+r+7s()%rr+ceZdZddZdZy)NetplanExceptionNc.||_||_||_yN)domainerrormessage)selfr3r1r2s r__init__zNetplanException.__init__<s   rc|jSr0)r3r4s r__str__zNetplanException.__str__As ||rNNN)rrrr5r8rrrr.r.;s  rr.ceZdZedZy)NetplanFileExceptionc|jSr0)r2r7s rerrnozNetplanFileException.errnoFs zzrN)rrrpropertyr=rrrr;r;Es rr;c(eZdZdZdZdfd ZxZS)NetplanValidationExceptiona  Netplan Validation errors are expected to contain the YAML file name from where the error was found. A validation error might happen after the parsing stage. libnetplan walks through its internal representation of the network configuration and checks if all the requirements are met. For example, if it finds that the key "set-name" is used by an interface, it will check if "match" is present. As "set-name" requires "match" to work, it will emit a validation error if it's not found. z((?P.*\.yaml): (?P.*)ct||||tj|j|}|st d||d|_|d|_y)Nz@The validation error message does not have the expected format: file_pathr3)superr5rematch!SCHEMA_VALIDATION_ERROR_MSG_REGEX ValueErrorfilenamer3r4r3r1r2 schema_error __class__s rr5z#NetplanValidationException.__init__\sZ &%0xx F FP _`g_hij j$[1 #I. rr9)rrr__doc__rFr5 __classcell__rKs@rr@r@Ks  8& / /rr@c(eZdZdZdZdfd ZxZS)NetplanParserExceptiona Netplan Parser errors are expected to contain the YAML file name and line and column numbers from where the error was found. A parser error might happen during the parsing stage. Parsing errors might be due to invalid YAML files or invalid Netplan grammar. libnetplan will check for this kind of issues while it's walking through the YAML files, so it has access to the location where the error was found. zN(?P.*):(?P\d+):(?P\d+): (?P(\s|.)*)ct||||tj|j|}|st d||d|_|d|_|d|_|d|_ y)Nzr`s2BrctSr0)NETPLAN_EXCEPTIONS_FALLBACKrrrr`r`s)DrctSr0)r;rrrr`r`sFZrc` tjd}t|g||}|s|d tjk(r t dddt j }|dz }ttjd|}t fd}t||}|||||S)NzNetplanError **rz Unknown error uint32_tcDtj|t|Sr0)rnetplan_error_messagelen)berrs rr`z#_checked_lib_call..s@Y@YZ]_`befgbh@ir) rnewboolNULLr.rnetplan_error_codeintcast_string_realloc_call_no_errorNETPLAN_EXCEPTIONS) fnargsrefret domain_code error_domain error_code error_message exceptionrks @r_checked_lib_callr}s ''# $C r~4~~ C !f #((?"?Aq9 9,,S1 "b( *k:; 56ij &|4Z@  |Z@@ Jrfunctioncd}|dkrftjd|}||}|dk(r|dz}.|dkrtd|z|dk(rytj|j dStd ) Nizchar[]r rzUnknown error: %dzutf-8z&Halting due to string buffer size > 1M)rrlr.stringdecode)r~sizebufcodes rrrrrs D .ggh%} 2:!8D  !8"#6#=> > QY::c?))'2 2 C DDr)) collectionsrenumrrD _netplan_cffirrr rr r$r(r+ Exceptionr.r;r@rPrXr\r^rbrrrrr!r"rrr%r&rr)rr,rsr}callablerrrrrrs $ #G%G% (( !W! #W#*G*y+ /!1/:/-/B .  .  - **BC!!D22 ! < <>T ! > >@V5 66 % B BDT % E EGa9 00+>Z2[33 " < <>U " ; ;=T6 33 " = =?V6 22 ! C CE[5/G  :  EHEr