4.2.2.3. Node

It is important to note that creation of a Node class will not immediately take affect on the dyn.tm System unless it is created via a Zone instance. While creating Node‘s via a Zone you are required to place either a DNSRecord or a service on that Node which allows it to be created. To clerify, because Node‘s may not exist without either a record or service node = Node('zone.com', 'fqdn.zone.com.') will not actually create anything on the Dyn side until you add a record or service, whereas rec = zone.add_record('fqnd', 'A', '127.0.0.1') will create a new Node named ‘fqdn’ with an ARecord attached.

class dyn.tm.zones.Node(zone, fqdn=None)[source]

Node object. Represents a valid fqdn node within a zone. It should be noted that simply creating a Node object does not actually create anything on the DynECT System. The only way to actively create a Node on the DynECT System is by attaching either a record or a service to it.

__init__(zone, fqdn=None)[source]

Create a Node object

Parameters:
  • zone – name of the zone that this Node belongs to
  • fqdn – the fully qualified domain name of this zone
add_record(record_type='A', *args, **kwargs)[source]

Adds an a record with the provided data to this Node

Parameters:
  • record_type – The type of record you would like to add. Valid record_type arguments are: ‘A’, ‘AAAA’, ‘CERT’, ‘CNAME’, ‘DHCID’, ‘DNAME’, ‘DNSKEY’, ‘DS’, ‘KEY’, ‘KX’, ‘LOC’, ‘IPSECKEY’, ‘MX’, ‘NAPTR’, ‘PTR’, ‘PX’, ‘NSAP’, ‘RP’, ‘NS’, ‘SOA’, ‘SPF’, ‘SRV’, and ‘TXT’.
  • args – Non-keyword arguments to pass to the Record constructor
  • kwargs – Keyword arguments to pass to the Record constructor
add_service(service_type=None, *args, **kwargs)[source]

Add the specified service type to this Node

Parameters:
  • service_type – The type of the service you would like to create. Valid service_type arguments are: ‘ActiveFailover’, ‘DDNS’, ‘DNSSEC’, ‘DSF’, ‘GSLB’, ‘RDNS’, ‘RTTM’, ‘HTTPRedirect’
  • args – Non-keyword arguments to pass to the Record constructor
  • kwargs – Keyword arguments to pass to the Record constructor
delete()[source]

Delete this node, any records within this node, and any nodes underneath this node

get_all_records()[source]

Retrieve a list of all record resources for the specified node and zone combination as well as all records from any Base_Record below that point on the zone hierarchy

get_all_records_by_type(record_type)[source]

Get a list of all DNSRecord of type record_type which are owned by this node.

Parameters:record_type – The type of DNSRecord you wish returned. Valid record_type arguments are: ‘A’, ‘AAAA’, ‘CERT’, ‘CNAME’, ‘DHCID’, ‘DNAME’, ‘DNSKEY’, ‘DS’, ‘KEY’, ‘KX’, ‘LOC’, ‘IPSECKEY’, ‘MX’, ‘NAPTR’, ‘PTR’, ‘PX’, ‘NSAP’, ‘RP’, ‘NS’, ‘SOA’, ‘SPF’, ‘SRV’, and ‘TXT’.
Returns:A list of DNSRecord‘s
get_any_records()[source]

Retrieve a list of all recs

4.2.2.3.1. Node Examples

The following examples highlight how to use the Node class to get/create Zone‘s on the dyn.tm System and how to edit these objects from within a Python script.

4.2.2.3.1.1. Creating a new Node

The following example shows how to create a new Node on the dyn.tm System and how to edit some of the fields using the returned Node object. The easiest way to manipulate Node objects is via a Zone object. This example will show how to create new Node objects both by using a Zone as a proxy, and by creating a Node as a standalone object.

>>> from dyn.tm.zones import Zone
>>> # Create a dyn.tmSession
>>> new_zone = Zone('myzone.com', 'me@email.com')
>>> new_zone.add_record('NewNode', 'A', '127.0.0.1')
<ARecord>: 127.0.0.1
>>> node = new_zone.get_node('NewNode')
>>> node.add_record('A', '127.0.1.1')
<ARecord>: 127.0.1.1
>>> node.get_any_records()
{u'a_records': [<ARecord>: 127.0.0.1, <ARecord>: 127.0.1.1]}
>>> from dyn.tm.zones import Node
>>> # Create a dyn.tmSession
>>> # Assuming the :class:`Zone` from the above example still exists
>>> new_node = Node('myzone.com', 'NewNode.myzone.com')
>>> new_node.get_any_records()
{u'a_records': [<ARecord>: 127.0.0.1, <ARecord>: 127.0.1.1]}

4.2.2.3.1.2. Getting an Existing Node

The following example shows how to get an existing Node from the dyn.tm System. Similarly to the above examples the easiest way to manipulate existing Node objects is via a Zone object.

>>> from dyn.tm.zones import Zone
>>> # Create a dyn.tmSession
>>> new_zone = Zone('myzone.com', 'me@email.com')
>>> new_zone.add_record('NewNode', 'A', '127.0.0.1')
>>> node = new_zone.get_node('NewNode')
>>> node.get_any_records()
{u'a_records': ['127.0.0.1'], ...}
>>> from dyn.tm.zones import Node
>>> # Create a dyn.tmSession
>>> # Assuming the :class:`Zone` from the above example still exists
>>> new_node = Node('myzone.com', 'NewNode.myzone.com')
>>> new_node.get_any_records()
{u'a_records': ['127.0.0.1'], ...}