Infoblox::DNS::SRG - Create a shared record group.


NAME

Infoblox::DNS::SRG - Create a shared record group.


DESCRIPTION

A shared record group (SRG) is created to contain DNS shared records and share them between different zones. For example, if a group of DNS records needs to be in three different zones, you can include the records in a shared record group and assign the group to the three zones. For more information about shared record groups and shared records, please refer to Infoblox Administrator Guide.


CONSTRUCTOR

 my $srg = Infoblox::DNS::SRG->new(
     name                        => $string,               #Required
     comment                     => $string,               #Optional / Default is undefined
     extattrs                    => { $string => $extattr, ... },      #Optional / Default is undefined
     extensible_attributes => { $string => $string|$num, $string => [ $string|$num, ...], ... }, #Optional / Default is undefined
     override_record_name_policy => "true" | "false",      #Optional / Default is "false"
     record_name_policy          => $string,               #Optional / Required when override_record_name_policy is set to "true". Default is undefined
     zone_association            => [$Zone1, $Zone2, ...]  #Optional / Default is undefined
 );

You cannot set both extattrs and extensible_attributes attributes at the same time.


SESSION METHODS

This section describes all the methods in Infoblox::Session module that you can apply to a DNS SRG object.

Infoblox::Session->add( )

Use this method to add an SRG object to the Infoblox appliance. See Infoblox::Session->add() for parameters and return values.

Example
 #Construct an object
 my $srg = Infoblox::DNS::SRG->new (
     name     => "test_srg",
     comment  => "this is a demo SRG object",
     );
 # Submit for addition
 my $response = $session->add( $srg );

Infoblox::Session->get( )

Use this method to retrieve all the matching objects from the Infoblox appliance. See Infoblox::Session->get() for parameters and return values.

Key References
 Apply the following attributes to get a specific DNS SRG object:
  name - Required. A SRG name in string format.
  extattrs     - Optional. A hash reference containing extensible attributes.
  extensible_attributes - Optional. A hash reference containing extensible attributes.
Example
 my @retrieved_objs = $session->get(
     object => "Infoblox::DNS::SRG",
     name   => "test_srg");
 # get all shared record group objects with a given extensible attribute
 my @retrieved_objs = $session->get(
     object => "Infoblox::DNS::SRG",
     extensible_attributes => { 'Site' => 'Santa Clara' });

Infoblox::Session->modify( )

Use this method to modify an object in the Infoblox appliance. See Infoblox::Session->modify() for parameters and return values.

Example
 # Use method to modify the comment.
 $srg->comment("this is a modified comment");
 # Submit modification
 my $response = $session->modify( $srg );

Infoblox::Session->remove( )

Use this method to submit to remove an object from the Infoblox appliance. See Infoblox::Session->remove() for parameters and return values.

To remove a specific object, first use get() or search() to retrieve the specific object, and then submit this object for removal.

Example
 # Get the objects with the same name
 my @retrieved_objs = $session->get(
     object => "Infoblox::DNS::SRG",
     name   => "test_srg");
 # Find the desired object from the retrieved list.
 my $desired_srg = $retrieved_objs[0];
 # Submit for removal
 my $response = $session->remove( $desired_srg );

Infoblox::Session->search( )

Use this method to search for DNS SRG record objects in the Infoblox appliance. See Infoblox::Session->search() for parameters and return values.

Key References
 Apply the following attributes to search for a DNS SRG record object:
  name - Required. A SRG name in string format (regular expression).
  comment - Optional. A comment in string format (regular expression).
  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.

Example
 # search for all DNS SRG objects with name containing 'test'
 my @retrieved_objs = $session->search(
     object => "Infoblox::DNS::SRG",
     name   => ".*test.*");
 # search all DNS SRG objects with the extensible attribute 'Site'
 my @retrieved_objs = $session->search(
    object => "Infoblox::DNS::SRG",
    extensible_attributes => { 'Site' => 'Santa Clara' });


METHODS

This section describes all the methods that you can use to configure and retrieve the attribute values of a DNS SRG object.

comment( )

Use this method to set or retrieve the descriptive comment of a DNS SRG object.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

Desired comment in string format with a maximum of 256 bytes.

Returns

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.

Example
 #Get comment
 my $comment = $srg->comment();
 #Modify comment
 $srg->comment("Modifying the DNS SRG comment");

extattrs( )

Use this method to set or retrieve the extensible attributes associated with a DNS SRG object.

Parameter

Valid value is a hash reference containing the names of extensible attributes and their associated values ( Infoblox::Grid::Extattr objects ).

Returns

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.

Example
 #Get extattrs
 my $ref_extattrs = $srg->extattrs();
 #Modify extattrs
 $srg->extattrs({ 'Site' => $extattr1, 'Administrator' => $extattr2 });

extensible_attributes( )

Use this method to set or retrieve the extensible attributes associated with a DNS SRG object.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

For valid values for extensible attributes, see Infoblox::Grid::ExtensibleAttributeDef/Extensible Attribute Values.

Returns

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.

Example
 #Get extensible attributes
 my $ref_extensible_attributes = $srg->extensible_attributes();
 #Modify extensible attributes
 $srg->extensible_attributes({ 'Site' => 'Santa Clara', 'Administrator' => [ 'Peter', 'Tom' ] });

name( )

Use this method to set or retrieve the shared record group name of a DNS SRG object.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

The name of shared record group.

Returns

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.

Example
 #Get name
 my $name = $srg->name();
 #Modify name
 $srg->name("test_srg");

override_record_name_policy( )

Use this method to set or retrieve the override record name policy flag of a DNS SRG object.

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, which means this SRG will use default record name policy setting defined at grid level.

Parameter

Specify "true" to set the override_record_name_policy flag or "false" to deactivate/unset it.

Returns

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.

Example
 #Get override_record_name_policy
 my $override = $srg->doverride_record_name_policy();
 #Modify override_record_name_policy
 $srg->override_record_name_policy("true");

record_name_policy( )

Use this method to set or retrieve the record name policy of a DNS SRG object.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

The name of the record name policy defined at the grid level. See Infoblox::Grid::DNS for more information about record name policies.

This property is required only if override_record_name_policy is set to "true", which means SRG object will use its own record name policy.

Returns

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.

Example
 #Get record name policy
 my $policy = $srg->record_name_policy();
 #Modify record name policy
 $srg->record_name_policy("Allow Any");

zone_association( )

Use this method to set or retrieve the zone association of a DNS SRG object. All zone objects in a association list are associated with the SRG object, which means that all shared records in this SRG will be shared among these zones. For more information about SRG and zone association, please refer to Infoblox Administrator's Guide.

Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.

Parameter

Array reference of defined Infoblox::DNS::Zone objects.

Returns

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.

Example
 #Get zone association
 my $zone_associations = $srg->zone_association();
 #Modify zone associations, list of Infoblox::DNS::Zone objects
 $srg->zone_association([$zone1,$zone2,$zone3]);


SAMPLE CODE

The following sample code demonstrates the different functions that can be applied to an object such as add, search, modify, and remove. This sample also includes error handling for the operations.

#Preparation prior to a DNS SRG object insertion

 #PROGRAM STARTS: Include all the modules that will be used
 use strict;
 use Infoblox;
 #Create a session to the Infoblox Appliance
 my $session = Infoblox::Session->new(
     master   => "192.168.1.2",
     username => "admin",
     password => "infoblox"
 );
 unless ($session) {
    die("Construct session failed: ",
        $session->status_code() . ":" . $session->status_detail());
 }
 print "Session created successfully\n";
 #Create the zone prior to an SRG object 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 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 SRG object

 #Construct a DNS SRG object
 my $srg = Infoblox::DNS::SRG->new(
     name     => "test_srg",
     comment  => "this is a demo srg object",
     zone_association=> [ $zone ],
     override_record_name_policy => "true",
     record_name_policy=>"Allow Underscore"
 );
 unless ($srg) {
    die("Construct DNS SRG failed: ",
        Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "DNS SRG object created successfully\n";
 #Add the DNS SRG record object to Infoblox Appliance through a session
 $session->add($srg)
     or die("Add SRG object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "DNS SRG object added to server successfully\n";

#Search for a specific DNS SRG record

 #Search all SRG records with name containing 'test'
 my @retrieved_objs = $session->search(
     object => "Infoblox::DNS::SRG",
     name   => ".*test.*"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Search SRG failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Search DNS SRG object found at least 1 matching entry\n";

#Get and modify a DNS SRG record

 #Get SRG object through the session
 my @retrieved_objs = $session->get(
     object => "Infoblox::DNS::SRG",
     name   => "test_srg"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get SRG failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get DNS SRG object found at least 1 matching entry\n";
 #Modify one of the attributes of the specified SRG object
 $object->comment("Updated comment.");
 #Apply the changes
 $session->modify($object)
     or die("Modify SRG object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "DNS SRG object modified successfully \n";

#Remove a DNS SRG object

 #Get SRG object through the session
 my @retrieved_objs = $session->get(
     object => "Infoblox::DNS::SRG",
     name   => "test_srg"
 );
 my $object = $retrieved_objs[0];
 unless ($object) {
     die("Get SRG object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 }
 print "Get SRG object found at least 1 matching entry\n";
 #Submit the object for removal
 $session->remove($object)
     or die("Remove SRG object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 print "DNS SRG object removed successfully \n";
 ####PROGRAM ENDS####


AUTHOR

Infoblox Inc. http://www.infoblox.com/


SEE ALSO

Infoblox::DNS::Zone, Infoblox::Grid::DNS, Infoblox::Grid::RecordNamePolicy, Infoblox::Session, Infoblox::Session->get(), Infoblox::Session->search(), Infoblox::Session->add(), Infoblox::Session->remove(), Infoblox::Session->modify()


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.