Infoblox::DHCP::ExclusionRangeTemplate - DHCP ExclusionRangeTemplate object.
The DHCP exclusion range template describes the range of IP addresses that can be excluded in an address range template. If static IP addresses are assigned to certain hosts in the middle of an address range, those addresses can be excluded from the address range so the DHCP server does not assign those IP addresses to the clients.
my $exclusion_range_template = Infoblox::DHCP::ExclusionRangeTemplate->new( offset => $num, #Required number_of_addresses => $num, #Required comment => $string, #Optional / Default is empty );
The following functions are available to be applied to a DHCP exclusion range template object.
Use this function to specify exclusion range for the DHCP range template object. See Infoblox::DHCP::RangeTemplate->exclude() for parameters and return values.
#Construct a DHCP ExclusionRangeTemplate object my $exclusion_range_template = Infoblox::DHCP::ExclusionRangeTemplate->new( offset => "10", number_of_addresses => "5", comment => "Exclude five IP addresses" );
# Configure DHCP ExclusionRangeTemplate on the DHCP Range template object my $response = $dhcp_range_template->exclude([$exclusion_range_template]);
This section describes all the methods that can be used to configure and retrieve the attribute values of a DHCP exclusion range template object.
Use this method to set or retrieve a descriptive comment of a DHCP exclusion range template object.
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 my $comment = $exclusion_range_template->comment(); #Modify comment $exclusion_range_template->comment("Modifying the DHCP exclusion range template comment");
Use this method to set or retrieve the number of addresses in the DHCP exclusion range template object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The number of addresses in this exclusion range template.
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 number_of_addresses my $number_of_addresses = $exclusion_range_template->number_of_addresses(); #Modify number_of_addresses $exclusion_range_template->number_of_addresses("10");
Use this method to set or retrieve the address offset of the DHCP exclusion range template object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The address offset of this exclusion range template. The offset is calculated from the start address of network template to which the DHCP range template is assigned to. For example, if offset is set to 10 and number_of_addresses is set to 10, and network is set to 10.0.0.0/8, then start address of exclusion range created from this exclusion range template will be 10.0.0.10 and end address will be 10.0.0.20.
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 offset my $offset = $exclusion_range_template->offset(); #Modify offset $exclusion_range_template->offset("10");
The following sample code demonstrates the different functions that can be applied to a DHCP exclusion range object such as add, modify, and remove. Also, this sample includes error handling for the operations.
#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 the DHCP Range template object
my $dhcp_range_template = Infoblox::DHCP::RangeTemplate->new( name => "custom_range_template", offset => "10", number_of_addresses => "10", authority => "TRUE", bootfile => "bootfile1.com", ); unless($dhcp_range_template) { die("Construct DHCP Range template object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP Range template object created successfully\n";
#Add the DHCP Range object into the Infoblox appliance through a session $session->add($dhcp_range_template) or die("Add DHCP Range template object failed: ", $session->status_code() . ":" . $session->status_detail()); print "DHCP Range object added to Infoblox appliance successfully\n";
#Create a DHCP exclusion range templat object
my $exclusion_range_template = Infoblox::DHCP::ExclusionRangeTemplate->new( offset => "10", number_of_addresses => "5", comment => "Exclude five IP addresses" ); unless($exclusion_range_template) { die("Construct DHCP exclusion range template object failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP exclusion range template object created successfully\n";
#Add DHCP exclusion range template to DHCP Range template
#Get the DHCP Range template object my @retrieved_objs = $session->get( object => "Infoblox::DHCP::RangeTemplate", name => "custom_range_template" ); my $object = $retrieved_objs[0]; unless ($object) { die("Get DHCP Range template object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Get DHCP Range template object found at least 1 matching entry\n";
#Apply the changes to the DHCP Range template object $object->exclude([$exclusion_range_template]);
#Submit the changes to the Session $session->modify($object) or die("Adding DHCP exclusion range to DHCP Range template object failed: ", $session->status_code() . ":" . $session->status_detail()); print "DHCP Range template with exclusion range template updated to Infoblox appliance successfully\n";
#Remove DHCP exclusion range template
#Remove the exclusion range template from the DHCP Range template object. $object->exclude([]);
#Update DHCP Range template object through the Infoblox session. $session->modify($object) or die("Modify DHCP Range template object failed: ", $session->status_code() . ":" . $session->status_detail()); print "Removed DHCP exclusion range template from DHCP Range successfully\n";
####PROGRAM ENDS####
Infoblox Inc. http://www.infoblox.com/
Infoblox::Session,Infoblox::DHCP::RangeTemplate,Infoblox::DHCP::NetworkTemplate
Copyright (c) 2017 Infoblox Inc.