def delete_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE): """Delete the rdataset matching I{rdtype} and I{covers}, if it exists at the node specified by I{name}. The I{name}, I{rdtype}, and I{covers} parameters may be strings, in which case they will be converted to their proper type. It is not an error if the node does not exist, or if there is no matching rdataset at the node. If the node has no rdatasets after the deletion, it will itself be deleted. @param name: the owner name to look for @type name: DNS.name.Name object or string @param rdtype: the rdata type desired @type rdtype: int or string @param covers: the covered type (defaults to None) @type covers: int or string """ name = self._validate_name(name) if isinstance(rdtype, string_types): rdtype = dns.rdatatype.from_text(rdtype) if isinstance(covers, string_types): covers = dns.rdatatype.from_text(covers) node = self.get_node(name) if node is not None: node.delete_rdataset(self.rdclass, rdtype, covers) if len(node) == 0: self.delete_node(name)
def delete_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE): """Delete the rdataset matching I{rdtype} and I{covers}, if it exists at the node specified by I{name}. The I{name}, I{rdtype}, and I{covers} parameters may be strings, in which case they will be converted to their proper type. It is not an error if the node does not exist, or if there is no matching rdataset at the node. If the node has no rdatasets after the deletion, it will itself be deleted. :param name: the owner name to look for :type name: DNS.name.Name object or string :param rdtype: the rdata type desired :type rdtype: int or string :param covers: the covered type (defaults to None) :type covers: int or string """ name = self._validate_name(name) if isinstance(rdtype, (str, unicode)): rdtype = dns.rdatatype.from_text(rdtype) if isinstance(covers, (str, unicode)): covers = dns.rdatatype.from_text(covers) node = self.get_node(name) if not node is None: node.delete_rdataset(self.rdclass, rdtype, covers) if len(node) == 0: self.delete_node(name)
def delete_rdataset(self, name, rdtype, covers): node = self._maybe_cow(name) if not node.get_rdataset(self.zone.rdclass, rdtype, covers): return False node.delete_rdataset(self.zone.rdclass, rdtype, covers) if len(node) == 0: del self.nodes[name] return True
def delete_rdataset( self, name: dns.name.Name, rdtype: dns.rdatatype.RdataType, covers: dns.rdatatype.RdataType, ) -> None: node = self._maybe_cow(name) node.delete_rdataset(self.zone.rdclass, rdtype, covers) if len(node) == 0: del self.nodes[name]
def testImmutableNodes(self): z = dns.zone.from_text(example_text, 'example.', relativize=True, zone_factory=dns.versioned.Zone) node = z.find_node('@') with self.assertRaises(TypeError): node.find_rdataset(dns.rdataclass.IN, dns.rdatatype.RP, create=True) with self.assertRaises(TypeError): node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.RP, create=True) with self.assertRaises(TypeError): node.delete_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) with self.assertRaises(TypeError): node.replace_rdataset(None)
def delete_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE): """Delete the rdataset matching *rdtype* and *covers*, if it exists at the node specified by *name*. It is not an error if the node does not exist, or if there is no matching rdataset at the node. If the node has no rdatasets after the deletion, it will itself be deleted. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *rdtype*, an ``int`` or ``str``, the rdata type desired. *covers*, an ``int`` or ``str`` or ``None``, the covered type. Usually this value is ``dns.rdatatype.NONE``, but if the rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``, then the covers value will be the rdata type the SIG/RRSIG covers. The library treats the SIG and RRSIG types as if they were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA). This makes RRSIGs much easier to work with than if RRSIGs covering different rdata types were aggregated into a single RRSIG rdataset. """ name = self._validate_name(name) if isinstance(rdtype, str): rdtype = dns.rdatatype.from_text(rdtype) if isinstance(covers, str): covers = dns.rdatatype.from_text(covers) node = self.get_node(name) if node is not None: node.delete_rdataset(self.rdclass, rdtype, covers) if len(node) == 0: self.delete_node(name)
def delete_rdataset(self, name, rdtype, covers): node = self._maybe_cow(name) node.delete_rdataset(self.zone.rdclass, rdtype, covers) if len(node) == 0: del self.nodes[name]
def testNodeDeleteRdataset2(self): # type: () -> None z = dns.zone.from_text(example_text, 'example.', relativize=True) node = z['@'] node.delete_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) self.assertTrue(rds is None)
def testNodeDeleteRdataset2(self): # type: () -> None z = dns.zone.from_text(example_text, 'example.', relativize=True) node = z['@'] node.delete_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.LOC) self.failUnless(rds is None)
def testNodeDeleteRdataset1(self): # type: () -> None z = dns.zone.from_text(example_text, 'example.', relativize=True) node = z['@'] node.delete_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) self.failUnless(rds is None)
def testNodeDeleteRdataset1(self): z = dns.zone.from_text(example_text, "example.", relativize=True) node = z["@"] node.delete_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) rds = node.get_rdataset(dns.rdataclass.IN, dns.rdatatype.SOA) self.assertTrue(rds is None)