f-dZddlZddlZddlmZmZmZmZmZddl Z ddl Z ddl Z ddl Z ddlZ ddlZ ddlZ ddlZ ddlZ Gdde j&j(Ze j,j.Ze j,j2Ze j,j6Ze j,j8Ze j,j:Ze j,j<ZGdde j,j>Zy)zDNS Versioned Zones.N)CallableDequeOptionalSetUnionceZdZdZy)UseTransactionz-To alter a versioned zone, use a transaction.N)__name__ __module__ __qualname____doc__V/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/versioned.pyr r s7rr c eZdZgdZeZejjddfde e ejje fdejjdede edege efffd Z d'd e ed e ed efd Zd(ded efdZdZdZdZde ed dfdZde edege efd dfdZdZdZdZdZdZ dZ! d(de ejje fded ejDjffd Z#de ejje fd dfd Z$ejJjLd fde ejje fd!e ejJjNe fd"e ejJjNe fded ejPjRf fd# Z*ejJjLd fde ejje fd!e ejJjNe fd"e ejJjNe fded e ejPjRf fd$ Z+ejJjLfde ejje fd!e ejJjNe fd"e ejJjNe fd dfd%Z,de ejje fdejPjRd dfd&Z-xZ.S))Zone) _versions_versions_lock _write_txn_write_waiters _write_event_pruning_policy_readersTNoriginrdclass relativizepruning_policycjt||||tj|_t j |_||j|_ n||_ d|_ d|_ tj|_ t|_|jdt!|d|y)aInitialize a versioned zone object. *origin* is the origin of the zone. It may be a ``dns.name.Name``, a ``str``, or ``None``. If ``None``, then the zone's origin will be set by the first ``$ORIGIN`` line in a zone file. *rdclass*, an ``int``, the zone's rdata class; the default is class IN. *relativize*, a ``bool``, determine's whether domain names are relativized to the zone's origin. The default is ``True``. *pruning policy*, a function taking a ``Zone`` and a ``Version`` and returning a ``bool``, or ``None``. Should the version be pruned? If ``None``, the default policy, which retains one version is used. NT) replacement)super__init__ collectionsdequer threadingLock _version_lock_default_pruning_policyrrrrsetr_commit_version_unlockedWritableVersion)selfrrrr __class__s rr!z Zone.__init__.s, *5)4):):)<&^^-  !#'#?#?D #1D 157;6A6G6G6I*-%  %% /$D96 ridserialreturnc| | td|j5|f0@A A    ~!$..1Attrz"#2?"#677#??HHNNE;;222 KKE!$..1A E*AnnT\\3==;L;LM3q6==F#:&'G! 2?"#566..,dE73C MM  c ";   s%,E4 B E46E4 E4 A E44E=Frcd} |j5|j3||jk(r$t||d|_d|_ dddnHt j }|j j|ddd|j|jj|jS#1swY@xYw)NT)make_immutable) r&rrr=r$Eventrappendwait_setup_version)r+revents rwriterz Zone.writerws## 2 ??*u8I8I/I '2k$'DO)-D%! 2 2(")##**51+ 2R JJLUX &&(Y 2 2s7B>/B>>Cct|jdkDr:|jj|_|jj yy)Nr)lenrpopleftrr()r+s r!_maybe_wakeup_one_waiter_unlockedz&Zone._maybe_wakeup_one_waiter_unlockedsC t"" #a ' $ 3 3 ; ; =D     ! ! # (rcy)NTr)r+zoner?s rr'zZone._default_pruning_policysrct|jdkDsJt|jdkDrtd|jD}n|jdj}|jdj|krx|j ||jdrX|jj |jdj|kr!|j ||jdrVyyyy)Nrc3HK|]}|jjywN)r?r-).0rDs r z0Zone._prune_versions_unlocked..sES[[^^Es "r1)rOrrminr-rrP)r+ least_kepts r_prune_versions_unlockedzZone._prune_versions_unlockeds4>>"Q&&& t}}  !Et}}EEJ+..JnnQ""Z/D4H4H $..#5  NN " " $nnQ""Z/D4H4H $..#5 /5 /r max_versionscbdkr tdd}nfd}|j|y)zYSet a pruning policy that retains up to the specified number of versions Nzmax versions must be at least 1cy)NFr)rS_s rpolicyz%Zone.set_max_versions..policysrc4t|jkDSrV)rOr)rSr`r\s rraz%Zone.set_max_versions..policys4>>*\99r)r2set_pruning_policy)r+r\ras ` rset_max_versionszZone.set_max_versionss>  # q(8>? ?     : 'rrac| |j}|j5||_|jdddy#1swYyxYw)aSet the pruning policy for the zone. The *policy* function takes a `Version` and returns `True` if the version should be pruned, and `False` otherwise. `None` may also be specified for policy, in which case the default policy is used. Pruning checking proceeds from the least version and the first time the function returns `False`, the checking stops. I.e. the retained versions are always a consecutive sequence. N)r'r&rr[)r+ras rrczZone.set_pruning_policysF >11F    ,#)D  ) ) + , , ,s <Ac|j5|jj||jdddy#1swYyxYwrV)r&rremover[r+rDs r _end_readzZone._end_reads>    , MM  %  ) ) + , , ,s ,AA cT|j|k(sJd|_|jyrV)rrQrhs r_end_write_unlockedzZone._end_write_unlockeds'#%%% ..0rch|j5|j|dddy#1swYyxYwrV)r&rkrhs r _end_writezZone._end_writes.    *  $ $S ) * * *s(1c|jj||j|j|_|j||_||j |yyrV)rrIr[r8rrkr+rDr?rs rr)zZone._commit_version_unlockedsT g& %%']] ;;  DK ?  $ $S ) rcl|j5|j|||dddy#1swYyxYwrV)r&r)ros r_commit_versionzZone._commit_versions6    @  ) )#w ? @ @ @s*3cvt|jdkDr|jdjdz}|Sd}|S)Nrr1r^)rOrr-)r+r-s r_get_next_version_idzZone._get_next_version_ids? t~~  "#&&*B B rr6createc2|rtt| |SrV)r r find_node)r+r6rtr,s rrvzZone.find_nodes  w &&rctrVr )r+r6s r delete_nodezZone.delete_nodesrrdtypecoversct|rtt| |||}tjj |SrV)r r find_rdatasetr5rdatasetImmutableRdatasetr+r6rzr{rtr~r,s rr}zZone.find_rdatasets6  7(vv>||--h77rcz|rtt| |||}|tjj |SyrV)r r r:r5r~rrs rr:zZone.get_rdataset$s?  7'ff=  <<11(; ;rctrVrx)r+r6rzr{s rdelete_rdatasetzZone.delete_rdataset3s rctrVrx)r+r6rs rreplace_rdatasetzZone.replace_rdataset;s r)NN)F)/r r r __slots__Node node_factoryr5 rdataclassINrrr6Namestr RdataClassboolrVersionr!intr=rErMrQr'r[rdrcrirkrmr)rqrsnodervryr;NONE RdataTyper~Rdatasetr}r:rr __classcell__)r,s@rrr!shIL .1^^->->PT # sxx}}c123# **#  # !67*;Xd^*K!LM # LAE"3-"08 " "H/$/;/b$  %$(Xc](t($,x(98D>(IJK, ,(, 1 **@?D'#((--,-'7;' 'chhmmS&8 9d7:mm6H6H 8CHHMM3&' 8cmm--s23 8cmm--s23 8  8    8 7:mm6H6H CHHMM3&' cmm--s23 cmm--s23    #,,'' ( &7:mm6H6H CHHMM3&'cmm--s23cmm--s23   #((--,-rs888S]]//8  xx// ((  ((**88,,hh"" ]388==]r