!`Nc@szdZddlZddlZddlZddlZddlZddlZddlZdej j fdYZ dS(sDNS Dynamic Update SupportiNtUpdatecBseZejjd d ejjdZd d dZ dZ dZ dZ dZ dZd dZd dd ZRS( c Cstt|j|jtjjtjjO_t|t t fr^tj j |}n||_ t|t rtjj |}n||_|j|j|j |tjjdtdt|dk r|j||d|ndS(sInitialize a new DNS Update object. @param zone: The zone which is being updated. @type zone: A dns.name.Name or string @param rdclass: The class of the zone; defaults to dns.rdataclass.IN. @type rdclass: An int designating the class, or a string whose value is the name of a class. @param keyring: The TSIG keyring to use; defaults to None. @type keyring: dict @param keyname: The name of the TSIG key to use; defaults to None. The key must be defined in the keyring. If a keyring is specified but a keyname is not, then the key used will be the first key in the keyring. Note that the order of keys in a dictionary is not defined, so applications should supply a keyname when a keyring is used, unless they know the keyring contains only one key. @type keyname: dns.name.Name or string @param keyalgorithm: The TSIG algorithm to use; defaults to dns.tsig.default_algorithm. Constants for TSIG algorithms are defined in dns.tsig, and the currently implemented algorithms are HMAC_MD5, HMAC_SHA1, HMAC_SHA224, HMAC_SHA256, HMAC_SHA384, and HMAC_SHA512. @type keyalgorithm: string tcreatet force_uniquet algorithmN(tsuperRt__init__tflagstdnstopcodetto_flagstUPDATEt isinstancetstrtunicodetnamet from_texttorigint rdataclasst zone_rdclasst find_rrsettquestiont rdatatypetSOAtTruetNonetuse_tsig(tselftzonetrdclasstkeyringtkeynamet keyalgorithm((s0/usr/lib64/python2.7/site-packages/dns/update.pyRs!  !  c Csb|dkr|j}n|j}|j|||j|j||tt}|j||dS(s&Add a single RR to the update section.N(Rt authoritytcoversRRtrdtypeRtadd(RRtttltrdtdeletingtsectionR!trrset((s0/usr/lib64/python2.7/site-packages/dns/update.pyt_add_rrAs    c Gst|ttfr-tjj|d}nt|dtjjrxx|D]O}|ro|j ||j nx*|D]"}|j ||j |d|qvWqMWnt |}t|jd}t|dtjjr*|r|j ||dj nx|D]}|j |||d|qWn|jd}t|tr]tjj|}n|rv|j ||nxH|D]@} tjj|j|| |j}|j |||d|q}WdS(sAdd records. The first argument is the replace mode. If false, RRs are added to an existing RRset; if true, the RRset is replaced with the specified contents. The second argument is the section to add to. The third argument is always a name. The other arguments can be: - rdataset... - ttl, rdata... - ttl, rdtype, string...iR'N(R R R RRRRtrdatasettRdatasettdeleteR"R)R$tlisttinttpoptrdatatRdataRRR( RtreplaceR'RtargstrdsR%R$R"ts((s0/usr/lib64/python2.7/site-packages/dns/update.pyt_addKs0   '     cGs|jt|j||dS(sAdd records. The first argument is always a name. The other arguments can be: - rdataset... - ttl, rdata... - ttl, rdtype, string...N(R6tFalseR (RRR3((s0/usr/lib64/python2.7/site-packages/dns/update.pyR#ss c Gst|ttfr-tjj|d}nt|dkr|j|j |tj j tj j tj j tj j tt}nt|dtjjrxe|D]3}x*|D]"}|j|d|tj j qWqWn't|}t|dtjjr0x|D]"}|j|d|tj j qWn|jd}t|ttfritj j|}nt|dkr|j|j ||j|tj j tj j tt}nNxK|D]C}tjj|j|||j}|j|d|tj j qWdS(sDelete records. The first argument is always a name. The other arguments can be: - I{nothing} - rdataset... - rdata... - rdtype, [string...]iN(R R R RRRRtlenRR RtANYRtNONERR*R+R)R-R0R1R/RR(RRR3R(R4R%R"R5((s0/usr/lib64/python2.7/site-packages/dns/update.pyR,~s6   '  #     cGs|jt|j||dS(sQReplace records. The first argument is always a name. The other arguments can be: - rdataset... - ttl, rdata... - ttl, rdtype, string... Note that if you want to replace the entire node, you should do a delete of the name followed by one or more calls to add.N(R6RR (RRR3((s0/usr/lib64/python2.7/site-packages/dns/update.pyR2s c Gs~t|ttfr-tjj|d}nt|dkr{|j|j |tj j tj j tj j dtt}nt|dtjjst|dtjjst|dkrt|dtjjst|}|jddn|jt|j ||ng|d}t|ttfrGtj j|}n|j|j |tj j |tj j dtt}dS(sBRequire that an owner name (and optionally an rdata type, or specific rdataset) exists as a prerequisite to the execution of the update. The first argument is always a name. The other arguments can be: - rdataset... - rdata... - rdtype, string...iiN(R R R RRRRR8RtanswerRR9RR:RR*R+R0R1R-tinsertR6R7(RRR3R(R"((s0/usr/lib64/python2.7/site-packages/dns/update.pytpresents*      c Cst|ttfr-tjj|d}n|dkru|j|j|tj j tj j tj j dt t }n]t|ttfrtj j|}n|j|j|tj j |tj j dt t }dS(sRequire that an owner name (and optionally an rdata type) does not exist as a prerequisite to the execution of the update.N(R R R RRRRRR;RR:RR9R(RRR"R(((s0/usr/lib64/python2.7/site-packages/dns/update.pytabsents    icCs1|dkr|j}ntt|j||S(scReturn a string containing the update in DNS compressed wire format. @rtype: stringN(RRRRtto_wire(RRtmax_size((s0/usr/lib64/python2.7/site-packages/dns/update.pyR?s  N(t__name__t __module__RRtINRttsigtdefault_algorithmRR)R6R#R,R2R=R>R?(((s0/usr/lib64/python2.7/site-packages/dns/update.pyRs % ( +  $ ( t__doc__t dns.messageRtdns.namet dns.opcodet dns.rdatatdns.rdataclasst dns.rdatasettdns.tsigtmessagetMessageR(((s0/usr/lib64/python2.7/site-packages/dns/update.pyts