Infoblox::DHCP::MSSuperscope - Microsoft (r) Server Superscope object.
A superscope is a feature of Microsoft DHCP servers. You can use a superscope to group and activate multiple ranges via a single object.
my $superscope = Infoblox::DHCP::Superscope->new( name => $string, #Required ranges => [ $dhcprange1,$dhcprange2,...], #Required comment => $string, #Optional extattrs => { $string => $extattr, ... }, #Optional / Default is undefined extensible_attributes => { $string => $string | $num, $string => [ $string | $num, ... ], ... }, #Optional / Default is undefined network_view => $NetworkView, #Optional / Default is the default network view disable => "true" | "false", #Optional / Default is "false" )
You cannot set both extattrs and extensible_attributes attributes at the same time.
This section describes all the methods in an Infoblox::Session module that you can apply to a superscope object.
Use this method to add a superscope object to the Infoblox appliance. See Infoblox::Session->add() for parameters and return values.
#Construct an object my $superscope = Infoblox::DHCP::MSSuperscope->new( name => 'test superscope', comment => 'test comment', disable => 'true', network_view => $view, ranges => [ $dhcp_range ], );
# Submit for addition my $response = $session->add( $superscope );
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 superscope object:
name - Optional. Name value for the superscope. comment - Optional. Comment value for the superscope. network_view - Optional. Network view in which the superscope is located. By default, all network views are searched. extattrs - Optional. A hash reference containing extensible attributes. extensible_attributes - Optional. A hash reference containing extensible attributes.
my @retrieved_objs = $session->get( object => "Infoblox::DHCP::MSSuperscope", name => "test superscope" );
my @retrieved_objs = $session->get( object => "Infoblox::DHCP::MSSuperscope", name => "other superscope", network_view => "external" );
my @retrieved_objs = $session->get( object => "Infoblox::DHCP::MSSuperscope", extensible_attributes => { 'Site' => 'Santa Clara' });
Use this method to modify a superscope object in the Infoblox appliance. See Infoblox::Session->modify() for parameters and return values.
# Use this method to modify the comment. $superscope->comment("this is a modified comment"); # Submit modification my $response = $session->modify( $superscope );
Use this method to remove a superscope 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 superscope object, and then submit this object for removal.
# Get the objects with the same name my @retrieved_objs = $session->get( object => "Infoblox::DHCP::MSSuperscope", name => "some superscope", newtork_view => "default" ); # Find the desired object from the retrieved list. my $desired_superscope = $retrieved_objs[0]; # Submit for removal my $response = $session->remove( $desired_superscope );
Use this method to search for superscope objects in the Infoblox appliance. See Infoblox::Session->search() for parameters and return values.
Apply the following attributes to search for a superscope object:
name - Optional. Name value for the superscope (regular expression). comment - Optional. Comment value for the superscope (regular expression). network_view - Optional. Network view in which the superscope is located. By default, all network views are searched. 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 superscope objects with comments ending with 'comment' my @retrieved_objs = $session->search( object => "Infoblox::DHCP::MSSuperscope", comment => ".*comment" );
This section describes all the methods that can be used to configure and retrieve the attribute values of a superscope.
Use this method to set or retrieve a 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. The default value is undefined.
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 my $comment = $superscope->comment(); #Modify comment $superscope->comment("Modifying the Superscope comment");
Use this method to set or retrieve the disable flag of a superscope.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Specify "true" to set the disable flag or "false" to deactivate/unset it. The default value for this field is false.
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 my $disable = $superscope->disable(); #Modify disable $superscope->disable("false");
Use this method to set or retrieve the extensible attributes associated with a superscope 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 my $ref_extattrs = $superscope->extattrs(); #Modify extattrs $superscope->extattrs({ 'Site' => $extattr1, 'Administrator' => $extattr2 });
Use this method to set or retrieve the extensible attributes that are associated with a superscope object.
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 my $ref_extensible_attributes = $superscope->extensible_attributes(); #Modify extensible attributes $superscope->extensible_attributes({ 'Site' => 'Santa Clara', 'Administrator' => [ 'Peter', 'Tom' ] });
Use this method to set or retrieve the name of the superscope.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Specify the name of the superscope in string format. The string must not be longer than 256 characters.
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 my $name = $superscope->name(); #Modify name $superscope->name("superscope name");
Use this method to set or retrieve the network view of the superscope.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The valid value is a defined Infoblox::DHCP::View object. The default network view value is the system-defined default network view object.
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 network view my $nview = $superscope->network_view(); #Modify network view, with an Infoblox::DHCP::View object $superscope->network_view($nview);
Use this method to set or retrieve the DHCP ranges that are associated with this superscope.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Valid value is an array reference that contains defined Infoblox::DHCP::Range objects. The default value is empty.
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 ranges my $ref_options = $superscope->ranges(); #Modify ranges $superscope->ranges([$range]); #$range is an Infoblox::DHCP::Range object
Use this method to retrieve the percent above "Normal" when the DHCP utilization status becomes "High".
None
The method returns the attribute value.
#Get high-water mark my $range_high_water_mark = $superscope->range_high_water_mark();
Use this method to retrieve the percent below "Normal" when the DHCP utilization status becomes "Low".
None
The method returns the attribute value.
#Get low-water mark my $range_low_water_mark = $superscope->range_low_water_mark();
The following sample code demonstrates the different functions that can be applied to a superscope object such as add, modify, and remove. Also, this sample includes error handling for the operations.
#Preparation prior to a DHCP superscope 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", #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 supporting objects, $host_name is the grid member's fqdn
my $ms_member = Infoblox::Grid::MSServer->new( address => '10.0.0.1', comment => 'basic member', disable => 'true', extensible_attributes => { Site => 'Somewhere'}, login => 'user', password => 'password', managing_member => $host_name, read_only => 'false', synchronization_interval => 5, logging_mode => 'minimum', );
unless($ms_member) { die("Construct MS Member object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "MS Member object created successfully\n";
unless($session->add($ms_member)) { die("Add MS Member object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "MS Member object added successfully\n";
my $ms_dhcp = Infoblox::DHCP::MSServer->new(address => '10.0.0.1');
unless($ms_dhcp) { die("Construct MS DHCP Member object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "MS DHCP Member object created successfully\n";
my $network1 = Infoblox::DHCP::Network->new( network => "10.0.0.0/255.255.0.0", comment => "add network", members => [$ms_dhcp], ); unless($network1) { die("Construct DHCP Network object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP Network object created successfully\n";
unless($session->add($network1)) { die("Add DHCP Network object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "DHCP Network object added successfully\n";
my $dhcp_range1 = Infoblox::DHCP::Range->new( end_addr => "10.0.0.10", network => "10.0.0.0/16", start_addr => "10.0.0.1", disable => "true", member => $ms_dhcp, );
unless($dhcp_range1) { die("Construct DHCP Range object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP Range object created successfully\n";
unless($session->add($dhcp_range1)) { die("Add DHCP Range object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "DHCP Range object added successfully\n";
my $network2 = Infoblox::DHCP::Network->new( network => "10.1.0.0/255.255.0.0", comment => "add network", members => [$ms_dhcp], ); unless($network2) { die("Construct DHCP Network object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP Network object created successfully\n";
unless($session->add($network2)) { die("Add DHCP Network object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "DHCP Network object added successfully\n";
my $dhcp_range2 = Infoblox::DHCP::Range->new( end_addr => "10.1.0.30", network => "10.1.0.0/16", start_addr => "10.1.0.21", disable => "true", member => $ms_dhcp, );
unless($dhcp_range2) { die("Construct DHCP Range object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP Range object created successfully\n";
unless($session->add($dhcp_range2)) { die("Add DHCP Range object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "DHCP Range object added successfully\n";
#Create a DHCP Superscope object
my $superscope = Infoblox::DHCP::MSSuperscope->new( name => 'test superscope', comment => 'test comment', disable => 'true', ranges => [ $dhcp_range1, $dhcp_range2], ); unless($superscope) { die("Construct DHCP Superscope object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP Superscope object created successfully\n";
unless($session->add($superscope)) { die("Add DHCP Superscope object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "DHCP Superscope object added successfully\n";
#Get the DHCP Superscope object and change its ranges
#Get the DHCP Superscope object my @retrieved_objs = $session->get( object => "Infoblox::DHCP::MSSuperscope", name => "test superscope" ); my $object = $retrieved_objs[0]; unless ($object) { die("Get DHCP Superscope object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Get DHCP Superscope object found at least 1 matching entry\n";
#Apply the changes $session->modify($object) or die("Modify DHCP Superscope object failed: ", $session->status_code() . ":" . $session->status_detail()); print "DHCP Superscope object with new range assignments updated to Infoblox appliance successfully\n";
#Remove DHCP Superscope and support objects
$session->remove($object) or die("Remove DHCP Superscope object failed: ", $session->status_code() . ":" . $session->status_detail());
$session->remove($dhcp_range2) or die("Remove DHCP Range object failed: ", $session->status_code() . ":" . $session->status_detail());
$session->remove($dhcp_range1) or die("Remove DHCP Range object failed: ", $session->status_code() . ":" . $session->status_detail());
$session->remove($network2) or die("Remove DHCP Network object failed: ", $session->status_code() . ":" . $session->status_detail());
$session->remove($network1) or die("Remove DHCP Network object failed: ", $session->status_code() . ":" . $session->status_detail());
$session->remove($ms_member) or die("Remove Grid MSServer object failed: ", $session->status_code() . ":" . $session->status_detail());
print "All objects removed from the Infoblox appliance successfully\n";
####PROGRAM ENDS####
Infoblox Inc. http://www.infoblox.com/
Infoblox::Session, Infoblox::Session->get(), Infoblox::Session->modify(),Infoblox::DHCP::Range,Infoblox::DHCP::MSOption
Copyright (c) 2017 Infoblox Inc.