コード例 #1
0
ファイル: test_zone.py プロジェクト: omarbelaggoun/dnspython
 def testNodeReplaceRdatasetConvertsRRsets(self):
     node = dns.node.Node()
     rrs = dns.rrset.from_text('foo', 300, 'in', 'a', '10.0.0.1')
     node.replace_rdataset(rrs)
     rds = node.find_rdataset(dns.rdataclass.IN, dns.rdatatype.A)
     self.assertEqual(rds, rrs)
     self.assertTrue(rds is not rrs)
     self.assertFalse(isinstance(rds, dns.rrset.RRset))
コード例 #2
0
 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)
コード例 #3
0
ファイル: cli53.py プロジェクト: maraca/cli53
    def convert(self, info, rrsets, z=None):
        if not z:
            origin = info.HostedZone.Name
            z = dns.zone.Zone(dns.name.from_text(origin))
        
        for rrset in rrsets:
            name = rrset.name
            if '\\052' in name:
                # * char seems to confuse Amazon and is returned as \\052
                name = name.replace('\\052', '*')
            rtype = rrset.type
            ttl = int(rrset.ttl)

            rdataset = _create_rdataset(rtype, ttl, rrset.resource_records)
            node = z.get_node(name, create=True)
            node.replace_rdataset(rdataset)
        
        return z
コード例 #4
0
ファイル: cli53.py プロジェクト: maraca/cli53
    def convert(self, info, rrsets, z=None):
        if not z:
            origin = info.HostedZone.Name
            z = dns.zone.Zone(dns.name.from_text(origin))

        for rrset in rrsets:
            name = rrset.name
            if '\\052' in name:
                # * char seems to confuse Amazon and is returned as \\052
                name = name.replace('\\052', '*')
            rtype = rrset.type
            ttl = int(rrset.ttl)

            rdataset = _create_rdataset(rtype, ttl, rrset.resource_records)
            node = z.get_node(name, create=True)
            node.replace_rdataset(rdataset)

        return z
コード例 #5
0
ファイル: zone.py プロジェクト: cawka/dnspython
    def replace_rdataset(self, name, replacement):
        """Replace an rdataset at name.

        It is not an error if there is no rdataset matching I{replacement}.

        Ownership of the I{replacement} object is transferred to the zone;
        in other words, this method does not store a copy of I{replacement}
        at the node, it stores I{replacement} itself.

        If the I{name} node does not exist, it is created.

        :param name: the owner name
        :type name: DNS.name.Name object or string
        :param replacement: the replacement rdataset
        :type replacement: dns.rdataset.Rdataset
        """

        if replacement.rdclass != self.rdclass:
            raise ValueError('replacement.rdclass != zone.rdclass')
        node = self.find_node(name, True)
        node.replace_rdataset(replacement)
コード例 #6
0
    def replace_rdataset(self, name, replacement):
        """Replace an rdataset at name.

        It is not an error if there is no rdataset matching I{replacement}.

        Ownership of the I{replacement} object is transferred to the zone;
        in other words, this method does not store a copy of I{replacement}
        at the node, it stores I{replacement} itself.

        If the I{name} node does not exist, it is created.

        @param name: the owner name
        @type name: DNS.name.Name object or string
        @param replacement: the replacement rdataset
        @type replacement: dns.rdataset.Rdataset
        """

        if replacement.rdclass != self.rdclass:
            raise ValueError('replacement.rdclass != zone.rdclass')
        node = self.find_node(name, True)
        node.replace_rdataset(replacement)
コード例 #7
0
ファイル: cli53.py プロジェクト: joemiller/cli53
 def convert(self, info, xml):
     origin = info.HostedZone.Name
     z = dns.zone.Zone(dns.name.from_text(origin))
     
     ns = boto.route53.Route53Connection.XMLNameSpace
     tree = et.fromstring(xml)
     
     for rrsets in tree.findall("{%s}ResourceRecordSets" % ns):
         for rrset in rrsets.findall("{%s}ResourceRecordSet" % ns):
             name = rrset.find('{%s}Name' % ns).text
             if '\\052' in name:
                 # * char seems to confuse Amazon and is returned as \\052
                 name = name.replace('\\052', '*')
             rtype = rrset.find('{%s}Type' % ns).text
             ttl = int(rrset.find('{%s}TTL' % ns).text)
             
             values = [ rr.text for rr in rrset.findall('{%(ns)s}ResourceRecords/{%(ns)s}ResourceRecord/{%(ns)s}Value' % {'ns':ns}) ]
             rdataset = _create_rdataset(rtype, ttl, values)
             node = z.get_node(name, create=True)
             node.replace_rdataset(rdataset)
     
     return z
コード例 #8
0
ファイル: zone.py プロジェクト: selfsk/dnspython
    def replace_rdataset(self, name, replacement):
        """Replace an rdataset at name.

        It is not an error if there is no rdataset matching I{replacement}.

        Ownership of the *replacement* object is transferred to the zone;
        in other words, this method does not store a copy of *replacement*
        at the node, it stores *replacement* itself.

        If the node does not exist, it is created.

        *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.

        *replacement*, a ``dns.rdataset.Rdataset``, the replacement rdataset.
        """

        if replacement.rdclass != self.rdclass:
            raise ValueError('replacement.rdclass != zone.rdclass')
        node = self.find_node(name, True)
        node.replace_rdataset(replacement)
コード例 #9
0
 def put_rdataset(self, name, rdataset):
     node = self._maybe_cow(name)
     node.replace_rdataset(rdataset)
コード例 #10
0
 def put_rdataset(self, name: dns.name.Name,
                  rdataset: dns.rdataset.Rdataset) -> None:
     node = self._maybe_cow(name)
     node.replace_rdataset(rdataset)