Infoblox::Grid::DNS::Nsgroup - Creates a name server group.


NAME

Infoblox::Grid::DNS::Nsgroup - Creates a name server group.


DESCRIPTION

A name server group is a collection of one and more primary DNS servers and one or more secondary DNS servers. Grouping a commonly used set of primary and secondary DNS servers together simplifies zone creation, allowing you to specify a single name server group instead of specifying multiple name servers individually.


CONSTRUCTOR

 my $nsg1 = Infoblox::Grid::DNS::Nsgroup->new(
     name        => $string,                                                                      #Required
     comment     => $string,                                                                      #Optional
     extattrs              => { $string => $extattr, ... },                                       #Optional / Default is undefined
     extensible_attributes => { $string => $string|$num, $string => [ $string|$num, ...], ... },  #Optional / Default is undefined
     is_multimaster      => "true" | "false",                                                     #Optional / Default is "false"
     multiple_primaries  => [$Member1, ...] | [$Nameserver1, ...] | [$MSServer1, ...],            #Optional / Default is undefined
     secondaries         => [$Member1, $Member2, $Nameserver1, $Nameserver2, ...]                 #Optional / List of Infoblox::DNS::Member object(s) and/or Infoblox::DNS::Nameserver object(s).
 );

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


SESSION METHODS

This section describes all the methods in the Infoblox::Session module that you can apply to an Nsgroup object.

Infoblox::Session->add( )

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

Example
 #Creating Member objects.
 my $member1 = Infoblox::DNS::Member->new(
     name     => "infoblox.localdomain",
     ipv4addr => "192.168.1.2",
     stealth  => "false"
     );
 my $member2 = Infoblox::DNS::Member->new(
     name     => "member2.test.com",
     ipv4addr => "2.2.2.2",
     stealth  => "false"
     );
 #Creating a nameserver object.
 my $nameserver1 = Infoblox::DNS::Nameserver->new(
     name     => "ns1.test.extra",
     ipv4addr => "4.4.4.4",
     stealth  => "false",
     TSIGname => "tsig_name",
     TSIGkey  => "ZX1jVJl7C58GT/sc7Q3ucA=="
     );
 #Creating a nameserver object.
 my $nameserver2 = Infoblox::DNS::Nameserver->new(
     name     => "ns2.test.extra",
     ipv4addr => "5.5.5.5",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
     );
 #Creating a nameserver object.
 my $nameserver3 = Infoblox::DNS::Nameserver->new(
     name     => "ns3.test.extra",
     ipv6addr => "12ab::34a",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
     );
 #Construct an object
 my $nsg1 = Infoblox::Grid::DNS::Nsgroup->new(
     name        => "ns_group_A",
     multiple_primaries => [$member1],
     secondaries => [$member2, $nameserver1, $nameserver2, $nameserver3]
     );
 #Submit for addition
 my $response = $session->add( $nsg1 );

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 Nsgroup object:
  name - Required. A name server group name in string format.
  extattrs     - Optional. A hash reference containing extensible attributes.
  extensible_attributes - Optional. A hash reference containing extensible attributes.
Examples
 my @retrieved_objs = $session->get(
     object => "Infoblox::Grid::DNS::Nsgroup",
     name   => "ns_group_A",
     );
 my @retrieved_objs = $session->get(
     object => "Infoblox::Grid::DNS::Nsgroup",
     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 this method to modify the comment.
 $nsg1->comment("this is a modified comment");
 #Submit modification
 my $response = $session->modify( $nsg1 );

Infoblox::Session->remove( )

Use this method 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::Grid::DNS::Nsgroup",
     name   => "ns_group_A",
      );
 #Find the desired object from the retrieved list.
 my $desired_nsgroup= $retrieved_objs[0];
 #Submit for removal
 my $response = $session->remove( $desired_nsgroup );

Infoblox::Session->search( )

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

Key References
 Apply the following attributes to search for an Nsgroup object:
  name - Required. A host name 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.

Examples
 # Search for all Nsgroup objects
 my @retrieved_objs = $session->search(
     object => "Infoblox::Grid::DNS::Nsgroup",
     name   => ".*",
     );
 # search for all Nsgroup objects with "Santa Clara" as the value for the "Site" extensible attribute
 my @retrieved_objs = $session->get(
     object => "Infoblox::Grid::DNS::Nsgroup",
     extensible_attributes => { 'Site' => 'Santa Clara' });


MODULE METHODS

This section describes all the methods that you can appy to an Nsgroup object.

Infoblox::Grid::DNS->nsgroups( )

Use this function to specify a name server group at the grid level on the Infoblox appliance. See Infoblox::Grid::DNS->nsgroups() for parameters and return values.

Example
 #Creating Member objects.
 my $member1 = Infoblox::DNS::Member->new(
     name     => "infoblox.localdomain",
     ipv4addr => "192.168.1.2",
     stealth  => "false"
     );
 my $member2 = Infoblox::DNS::Member->new(
     name     => "member2.test.com",
     ipv4addr => "2.2.2.2",
     stealth  => "false"
     );
 #Creating a nameserver object.
 my $nameserver1 = Infoblox::DNS::Nameserver->new(
     name     => "ns1.test.extra",
     ipv4addr => "4.4.4.4",
     stealth  => "false",
     TSIGname => "tsig_name",
     TSIGkey  => "ZX1jVJl7C58GT/sc7Q3ucA=="
     );
 #Creating a nameserver object.
 my $nameserver2 = Infoblox::DNS::Nameserver->new(
     name     => "ns2.test.extra",
     ipv4addr => "5.5.5.5",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
     );
 #Creating a nameserver object.
 my $nameserver3 = Infoblox::DNS::Nameserver->new(
     name     => "ns3.test.extra",
     ipv6addr => "12ab::34a",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
     );
 my $nsg1 = Infoblox::Grid::DNS::Nsgroup->new(
     name        => "ns_group_A",
     multiple_primaries => [$member1],
     secondaries => [$member2, $nameserver1, $nameserver2,$nameserver3]
     );
 my @result_array = $session->get( "object" => "Infoblox::Grid::DNS" ,  "grid" => "Infoblox" );
  my $dns = $result_array[0];
  $dns->nsgroups([$nsg1]);


METHODS

This section describes all the methods that you can use to configure and retrieve the attribute values of an Nsgroup object

name( )

Use this method to set or retrieve the name server group, providing a meaningful reference for the set of servers.

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

Parameter

Name of the nameserver group in string format.

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
  #Getting name
   my $name = $nsg1->name();
   #Modifying name
   $nsg1->name("ns_group_2");

comment( )

Use this method to set or retrieve the comment field of the Nsgroup object. You can enter additional information about the NS group in this field.

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

Parameter

Comment of the nameserver group in string format.

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
 #Getting comment
 my $comment = $nsg1->comment();
 #Modifying comment
 $nsg1->comment("Some comment");

extensible_attributes( )

Use this method to set or retrieve the extensible attributes associated with an Nsgroup 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 = $nsg1->extensible_attributes();
 #Modify extensible attributes
 $nsg1->extensible_attributes({ 'Site' => 'Santa Clara', 'Administrator' => [ 'Peter', 'Tom' ] });

is_multimaster( )

Use this method to set or retrieve the is_multimaster flag.

Parameter

Specify "true" to set the is_multimaster flag or "false" to deactivate/unset it. The default value is "false".

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 the attribute value
 my $attr = $nsg1->is_multimaster();
 # Modify the attribute value
 $nsg1->is_multimaster('true');

multiple_primaries( )

Use this method to set or retrieve Grid primary servers or external primary servers of the name server group.

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

Parameter

The valid value is an array reference that contains Infoblox::DNS::Member objects for Grid primary servers or Infoblox::DNS::Nameserver objects for external primary servers.

To set two and more Infoblox::DNS::Member objects you should set the is_multimaster flag to "true".

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
 #For grid primary:
 my $member1 = Infoblox::DNS::Member->new(
     name     => "infoblox.localdomain",
     ipv4addr => "192.168.1.2",
     stealth  => "true"
 );
 $nsg1->multiple_primaries([$member1]);
 #For external primary:
 my $nameserver1 = Infoblox::DNS::Nameserver->new(
     name     => "ns1.domain.extra",
     ipv4addr => "5.5.5.5",
     stealth  => "false",
     TSIGname => "tsig_name",
     TSIGkey  => "ZX1jVJl7C58GT/sc7Q3ucA=="
 );
 my $nameserver2 = Infoblox::DNS::Nameserver->new(
     name     => "ns2.domain.extra",
     ipv4addr => "6.6.6.6",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
 );
 #Creating a nameserver object.
 my $nameserver3 = Infoblox::DNS::Nameserver->new(
     name     => "ns3.test.extra",
     ipv6addr => "12ab::34a",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
     );
 $nsg1->multiple_primaries([$nameserver1, $nameserver2,$nameserver3]);

secondaries( )

Use this method to set or retrieve the grid secondary server or external secondary servers of the nameserver group.

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

Parameter

The valid value is an array reference that contains Infoblox::DNS::Member objects for grid secondary servers and Infoblox::DNS::Nameserver objects for external secondary servers.

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
 my $member2 = Infoblox::DNS::Member->new(
     name     => "member2.domain.com",
     ipv4addr => "2.2.2.2",
     stealth  => "false"
 );
 my $nameserver1 = Infoblox::DNS::Nameserver->new(
     name     => "ns1.domain.extra",
     ipv4addr => "4.4.4.4",
     stealth  => "false",
     TSIGname => "tsig_name",
     TSIGkey  => "ZX1jVJl7C58GT/sc7Q3ucA=="
 );
 my $nameserver2 = Infoblox::DNS::Nameserver->new(
     name     => "ns2.domain.extra",
     ipv4addr => "5.5.5.5",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
 );
 #Creating a nameserver object.
 my $nameserver3 = Infoblox::DNS::Nameserver->new(
     name     => "ns3.test.extra",
     ipv6addr => "12ab::34a",
     stealth  => "false",
     TSIGname => "tsig_name2",
     TSIGkey  => "qwqwqwqwqwqwqwqwqwqwqA=="
     );
 $nsg1->secondaries([$member2, $nameserver1, $nameserver2,$nameserver3]);


SAMPLE CODE

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

#Preparation prior to an Nsgroup object insertion

 #PROGRAM STARTS: Include all the modules that will be used
 use strict;
 use Infoblox;
 #Create a session to the Infoblox device
 my $session = Infoblox::Session->new(
     master   => "192.168.1.2",
     username => "admin",
     password => "infoblox"
 );
 unless ($session) {
    die("Construct session failed: ",
        Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Session created successfully\n";

#Create an Nsgroup object

 #Creating a member object.
 my $member1 = Infoblox::DNS::Member->new(
     name     => "infoblox.localdomain",
     ipv4addr => "192.168.1.2",
     stealth  => "false"
 );
 #Creating a nsgroup object.
 my $nsg1 = Infoblox::Grid::DNS::Nsgroup->new(
     name    => "ns_group_1",
     multiple_primaries => [$member1]
 );
 my $nsg1_A = Infoblox::Grid::DNS::Nsgroup->new(
     name    => "ns_group_A",
     multiple_primaries => [$member1]
 );
 unless ($nsg1) {
    die("Construct Nsgroup failed: ",
        Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Nsgroup object created successfully\n";

#Get and add the Nsgroup object

 my @result_array = $session->get( "object" => "Infoblox::Grid::DNS" ,  "grid" => "Infoblox" );
 if( defined @result_array  and scalar( @result_array ) > 0 )
 {
        my $object = $result_array[0];
        if( ref( $object ) eq "Infoblox::Grid::DNS" )
        {
                $object->nsgroups( [ $nsg1 ,$nsg1_A] );
                my $response = $session->modify( $object );
                print "Add Nsgroup to grid dns properties success.\n" if ( $response );
                         }
  unless ($object) {
     die("Add Nsgroup to grid dns properties failed: ",
         $session->status_code() . ":" . $session->status_detail());
  }
   }

#Modify the Nsgroup object

 my @result_array = $session->get( "object" => "Infoblox::Grid::DNS" ,  "grid" => "Infoblox" );
 if( defined @result_array  and scalar( @result_array ) > 0 )
 {
        my $object = $result_array[0];
        if( ref( $object ) eq "Infoblox::Grid::DNS" )
        {
           $nsg1_A->name("ns_group_modified");
          $object->nsgroups( [ $nsg1 ,$nsg1_A] );
                my $response = $session->modify( $object );
                print "Modify Nsgroup success.\n" if ( $response );
                         }
  unless ($object) {
     die("Modify NSgroup failed: ",
         $session->status_code() . ":" . $session->status_detail());
  }
   }

#Remove a Nsgroup object

 my @result_array = $session->get( "object" => "Infoblox::Grid::DNS" ,  "grid" => "Infoblox" );
 if( defined @result_array  and scalar( @result_array ) > 0 )
 {
        my $object = $result_array[0];
        if( ref( $object ) eq "Infoblox::Grid::DNS" )
        {
                $object->nsgroups( [ ] );
                my $response = $session->modify( $object );
                print "Remove Nsgroup success.\n" if ( $response );
                         }
  unless ($object) {
     die("Remove Nsgroup failed: ",
         $session->status_code() . ":" . $session->status_detail());
  }
   }
 ####PROGRAM ENDS####


AUTHOR

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


SEE ALSO

Infoblox::Session, Infoblox::Session->get(),Infoblox::Session->modify(),Infoblox::Grid::DNS, Infoblox::DNS::Member,Infoblox::DNS::Nameserver


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.