Infoblox::DNS::Record::Alias - DNS Alias record object.
The Alias DNS resource record (RR) allows you to create typed aliases for standard DNS resource records which are resolved dynamically by an authoritative server. Unlike CNAME Alias can be created in the zone apex.
Note that you must specify only one view for the attribute 'views'.
my $alias = Infoblox::DNS::Record::Alias->new( name => $fqdn, # Required target_name => $fqdn, # Required target_type => 'A' | 'AAAA' | 'MX' | 'NAPTR' | 'PTR' | 'SPF' | 'SRV' | 'TXT', # Required comment => $string, # Optional / Default is empty disable => 'true' | 'false' # Optional / Default 'false' extattrs => {$string => $extattr, ...}, # Optional / Default is undefined extensible_attributes => {$string => $string|$num, $string => [$string|$num, ...], ...}, # Optional / Default is undefined ttl => $num | undef, # Optional / Default is undefined views => [$View1], # Optional / Default is 'default' view creator => 'STATIC', # Optional / Default is 'STATIC' );
You cannot set both extattrs and extensible_attributes attributes at the same time.
This section describes all the methods in Infoblox::Session module that you can apply to the object.
Use this method to add an object to the Infoblox appliance. See Infoblox::Session->add() for parameters and return values.
#Construct the object my $object = Infoblox::DNS::Record::Alias->new( name => 'alias.domain.com', target_name => 'target.com', target_type => 'A', comment => 'add Alias alias.domain.com', disable => 'false', ttl => '360', views => [$view1], );
#Submit for addition my $response = $session->add($object);
Use this method to retrieve all the matching objects from the Infoblox appliance. See Infoblox::Session->get() for parameters and return values.
Apply the following attributes to get a specific DNS Alias object:
name - Optional. A host name in string format. view - Optional. The DNS view in which the Alias record is located. By default, all DNS views are searched. But if you omit this attribute and specify a zone, the appliance searches the 'default' view only. zone - Optional. A zone name in FQDN format. target_name - Optional. A target name. target_type - Optional. A target type. creator - Optional. Record creator. extattrs - Optional. A hash reference containing extensible attributes. extensible_attributes - Optional. A hash reference containing extensible attributes.
my @retrieved_objs = $session->get( object => 'Infoblox::DNS::Record::Alias', name => 'alias.domain.com', view => 'default' );
#Get all DNS Alias records from the 'domain.com' zone of the default view my @retrieved_objs = $session->get( object => 'Infoblox::DNS::Record::Alias', zone => 'domain.com', view => 'default' );
#Get all DNS Alias records with a given extensible attribute my @retrieved_objs = $session->get( object => 'Infoblox::DNS::Record::Alias', extensible_attributes => { 'Site' => 'Santa Clara' });
Use this method to modify an object in the Infoblox appliance. See Infoblox::Session->modify() for parameters and return values.
#Use the following method to modify the comment. $object->comment('This is a modified comment');
#Submit modification my $response = $session->modify($object);
Use this method to remove an object from the Infoblox appliance. See Infoblox::Session->remove() for parameters and return values.
To remove a specifc object, first use get()
or search()
to retrieve the specific object, and then submit this object for removal.
#Get the objects with the same name my @retrieved_objs = $session->get( object => 'Infoblox::DNS::Record::Alias', name => 'alias.domain.com', view => 'default' );
#Find the desired object from the retrieved list. my $desired_object = $retrieved_objs[0];
#Submit for removal my $response = $session->remove($desired_object);
Use this method to search for objects in the Infoblox appliance. See Infoblox::Session->search() for parameters and return values.
Apply the following attributes to search for a DNS Alias record object:
name - Optional. A name in FQDN (Fully Qualified Domain Name) format (regular expression). target_name - Optional. A target name (regular expression). target_type - Optional. A target type. view - Optional. The DNS view in which the Alias record is located. By default, all DNS views are searched. But if you omit this attribute and specify a zone, the appliance searches the 'default' view only. zone - Optional. A zone name in FQDN format. comment - Optional. A comment in string format (regular expression). creator - Optional. Record creator. extattrs - Optional. A hash reference containing extensible attributes. extensible_attributes - Optional. A hash reference containing extensible attributes.
For more information about searching extensible attributes, see Infoblox::Grid::ExtensibleAttributeDef/Searching Extensible Attributes.
#Search for all DNS Alias objects that match 'domain.com' in the default DNS view my @retrieved_objs = $session->search( object => 'Infoblox::DNS::Record::Alias', name => 'domain\.com', view => 'default' );
#Search for all DNS Alias records in the 'domain.com' zone of the default view my @retrieved_objs = $session->search( object => 'Infoblox::DNS::Record::Alias', zone => 'domain.com', view => 'default' );
#Search for all DNS Alias records with a given extensible attribute 'Site' my @retrieved_objs = $session->search( object => 'Infoblox::DNS::Record::Alias', extensible_attributes => { 'Site' => 'Santa Clara' });
This section describes all the methods that you can use to configure and retrieve the attribute values of an Alias record.
Use this method to set or retrieve the descriptive comment.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Desired comment in string format with a maximum of 256 bytes.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get comment value my $value = $object->comment();
#Modify comment value $object->comment('Modifying the comment');
Use this method to retrieve cloud API related information for the Infoblox::DNS::Record::Alias object.
None
The method returns the attribute value.
# Get cloud_info value my $value = $object->cloud_info();
Use this method to set or retrieve the record creator.
Note that changing creator from or to 'SYSTEM' value is not allowed.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The valid values are 'STATIC' and 'DYNAMIC'. The default value is 'STATIC'.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get creator value my $value = $object->creator();
#Modify creator value $object->creator('DYNAMIC');
Use this method to set or retrieve the disable flag for a DNS record.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The default value for this field is false. The DNS record is enabled.
Specify 'true' to set the disable flag or 'false' to deactivate/unset it.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get disable value my $value = $object->disable();
#Modify disable value $object->disable('true');
Use this method to retrieve the name in punycode format. This is a read-only attribute.
None
The method returns the attribute value.
# Get dns_name value my $value = $object->dns_name();
Use this method to retrieve the target name in punycode format. This is a read-only attribute.
None
The method returns the attribute value.
# Get dns_target_name value my $value = $object->dns_target_name();
Use this method to set or retrieve the extensible attributes associated with a DNS Alias record object.
Valid value is a hash reference containing the names of extensible attributes and their associated values ( Infoblox::Grid::Extattr objects ).
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get extattrs value my $value = $object->extattrs();
#Modify extattrs value $object->extattrs({'Site' => $extattr1, 'Administrator' => $extattr2});
Use this method to set or retrieve the extensible attributes associated with a DNS Alias record.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
For valid values for extensible attributes, see Infoblox::Grid::ExtensibleAttributeDef/Extensible Attribute Values.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get extensible_attributes value my $value = $object->extensible_attributes();
#Modify extensible_attributes value $object->extensible_attributes({'Site' => 'Santa Clara', 'Administrator' => ['Peter', 'Tom']});
Use this method to set or retrieve the name.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The attribute value can be in unicode format.
The name of the DNS Alias object in Fully Qualified Domain Name (FQDN) format. The name can have a maximum of 256 bytes.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get name value my $value = $object->name();
#Modify name value $object->name('new.domain.com');
Use this method to set or retrieve the target name of the Alias.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The attribute value can be in unicode format.
Target name in FQDN (Fully Qualified Domain Name) format. The FQDN consists of the hostname followed by the domain name (example: abc.com). A hostname can have a maximum of 256 bytes.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get target_name my $target_name = $alias->target_name(); #Modify target_name $alias->target_name("alias.domain.com");
Use this method to set or retrieve the alias target type.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The valid values are 'A', 'AAAA', 'MX', 'NAPTR', 'PTR', 'SPF', 'SRV' and 'TXT'.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get target_type value my $value = $object->target_type();
#Modify target_type value $object->target_type('A');
Use this method to set or retrieve the Time to Live (TTL) value.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The default value is undefined which indicates that the record inherits the TTL value of the zone.
Specify a TTL value to override the TTL value at the zone level.
A 32-bit integer (range from 0 to 4294967295) that represents the duration in seconds to cache the record. Zero indicates that the record should not be cached.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get ttl value my $value = $object->ttl();
#Modify ttl value $object->ttl(1800);
#Un-override ttl $object->ttl(undef);
Use this method to set or retrieve the view of a Alias record.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The default value is the 'default' view, which means that the Alias record is located under the default view.
Array reference of defined Infoblox::DNS::View objects.
Note that the array size must be 1.
If you specified a parameter, the method returns true when the modification succeeds, and returns false when the operation fails.
If you did not specify a parameter, the method returns the attribute value.
#Get views value my $value = $object->views();
#Modify views value $object->views([$view1]);
Use this method to retrieve the zone name of a DNS Alias record. This is a read-only attribute.
None
The method returns the attribute value.
#Get zone value my $zone = $object->zone();
The following sample code demonstrates the different functions that can be applied on an object, such as add, search, modify, and remove. This sample also includes error handling for the operations.
#Preparation prior to a DNS Alias record insertion
#PROGRAM STARTS: Include all the modules that will be used use strict; use Infoblox;
#Create a session on the Infoblox appliance
my $session = Infoblox::Session->new( master => "192.168.1.2", #appliance host ip username => "admin", #appliance user login password => "infoblox" #appliance password );
unless ($session) { die("Construct session failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "Session created successfully\n";
#Create the zone prior to a Alias record insertion my $zone = Infoblox::DNS::Zone->new(name => "domain.com"); unless ($zone) { die("Construct zone failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "Zone object created successfully\n";
#Verify if the zone exists my $object = $session->get(object => "Infoblox::DNS::Zone", name => "domain.com"); unless ($object) { print "Zone does not exist on the server, safe to add the zone\n"; $session->add($zone) or die("Add zone failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Zone added successfully\n";
#Create a DNS Alias record
my $alias = Infoblox::DNS::Record::Alias->new( name => "alias.domain.com", target_name => "target.com", target_type => "A", comment => "add Alias alias.domain.com", );
unless ($alias) { die("Construct DNS record Alias failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); }
#Add the DNS Alias record object to the Infoblox appliance through a session $session->add($alias) or die("Add record Alias failed: ", $session->status_code() . ":" . $session->status_detail()); print "DNS Alias object is added to the server successfully\n";
#Search for a specific DNS Alias record
#Search all Alias records in the zone that matches "domain.com" my @retrieved_objs = $session->search( object => "Infoblox::DNS::Record::Alias", name => 'domain\.com' ); my $object = $retrieved_objs[0];
unless ($object) { die("Search record Alias failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Search a DNS Alias object found at least 1 matching entry\n";
#Search all Alias records with names that start with "alias" and end with "domain.com" my @retrieved_objs = $session->search( object => "Infoblox::DNS::Record::Alias", name => '^alias.*\.domain\.com\$' ); my $object = $retrieved_objs[0];
unless ($object) { die("Search record Alias failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Search a DNS Alias object using regexp found at least 1 matching entry\n";
#Get and modify a DNS Alias record
#Get an Alias record through the session my @retrieved_objs = $session->get( object => "Infoblox::DNS::Record::Alias", name => "alias.domain.com" ); my $object = $retrieved_objs[0];
unless ($object) { die("Get record Alias failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Get a DNS Alias object found at least 1 matching entry\n";
#Modify one of the attributes of the specified Alias record $object->comment("this is new comment string");
#Apply the changes $session->modify($object) or die("Modify record Alias failed: ", $session->status_code() . ":" . $session->status_detail()); print "DNS Alias object modified successfully \n";
#Remove a DNS Alias record
#Get Alias record through the session my @retrieved_objs = $session->get( object => "Infoblox::DNS::Record::Alias", name => "alias.domain.com" ); my $object = $retrieved_objs[0]; unless ($object) { die("Get record Alias failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Get DNS Alias object found at least 1 matching entry\n";
#Submit the object for removal $session->remove($object) or die("Remove record Alias failed: ", $session->status_code() . ":" . $session->status_detail()); print "DNS Alias object removed successfully \n";
####PROGRAM ENDS####
Infoblox Inc. http://www.infoblox.com/
Infoblox::Session->add(), Infoblox::Session->get(), Infoblox::Session->modify(), Infoblox::Session->remove(), Infoblox::Session->search(), Infoblox::Session, Infoblox::DNS::View, Infoblox::DNS::Zone
Copyright (c) 2017 Infoblox Inc.