Infoblox::DHCP::OptionDefinition - DHCP option definition object
An OptionDefinition defines a DHCP option within a specific option space. A custom option can be defined in the predefined DHCP option space or in the user-defined vendor option space. To define an option, add the option definition to the required option space.
my $option_definition1 = Infoblox::DHCP::OptionDefinition->new( name => $string, #Required code => $num, #Required space => $string, #Optional / Default is DHCP type => $string, #Optional / Default is string );
This section describes all the methods in an Infoblox::Session module that can be applied to a DHCP option definition object.
Use this method to add a option definition object to the Infoblox appliance. See Infoblox::Session->add() for parameters and return values.
#Create a DHCP OptionDefinition object. my $option_definition1 = Infoblox::DHCP::OptionDefinition->new( space => "SUNW", name => "JumpStart-server", code => "6", type => "text" ); # Submit for adding my $response = $session->add( $option_definition1 );
Use this method to retrieve all the matching DHCP option definition objects from the Infoblox appliance. See Infoblox::Session->get() for parameters and return values.
Apply the following attributes to get a specific DHCP option definition object:
name - A name for the option definition in string format (regular expression). code - Option number. Either a name or code is required. space- Optional. The option space in which the option is defined. The default is the DHCP option space.
#Getting option by name my @result_array = $session->get( object => "Infoblox::DHCP::OptionDefinition", space => "SUNW", name => "JumpStart-server", );
#Getting option by code my @result_array = $session->get( object => "Infoblox::DHCP::OptionDefinition", space => "DHCP", code => 176, );
Use this method to modify a DHCP option definition object in the Infoblox appliance. See Infoblox::Session->modify() for parameters and return values.
#Use method to modify code $object->code(20); # Submit modification my $response = $session->modify($object);
Use this method to retrieve all the matching DHCP option definition objects from the Infoblox appliance. See Infoblox::Session->search() for parameters and return values.
Apply the following attributes to get a specific DHCP option definition object:
name - A name for the option definition in string format (regular expression). code - Option number. Either a name or code is required. space- Optional. The option space in which the option is defined. The default is the DHCP option space.
#Getting option by name my @result_array = $session->search( object => "Infoblox::DHCP::OptionDefinition", space => "SUNW", name => "JumpStart-server", );
#Getting option by code my @result_array = $session->search( object => "Infoblox::DHCP::OptionDefinition", space => "DHCP", code => 176, );
Use this method to remove a DHCP option definition object from the Infoblox appliance. See Infoblox::Session->remove() for parameters and return values.
To remove a specifc object, first use get()
to retrieve the specific object, and then submit this object for removal.
my @result_array = $session->get( object => "Infoblox::DHCP::OptionDefinition", space => "SUNW", name => "JumpStart-server", );
# find the desired object from retrieved list. my $desired_obj = $result_array[0];
# Submit for removal my $response = $session->remove($desired_obj);
This section describes all the methods that can be used to configure and retrieve the attribute values of a DHCP option definition object.
Use this method to set or retrieve the name of a DHCP option definition object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Desired name 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 name my $option_definitionname = $option_definition1 ->name(); # Modify name $option_definition1 ->name("Start-server");
Use this method to set or retrieve the code of a DHCP option definition object. An option code number is used to identify the DHCP option.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Number for the option code. Value must be between 1 and 254. Values 1-79, 81-82, 85-87, 89, 91-92, 98, 112-114, 118-119, 124-125 are predefined. These option codes have corresponding predefined Types. Therefore, you cannot change the predefined Types.
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 code my $option_definitionname = $option_definition1 ->code(); # Modify code $option_definition1 ->code(14);
Use this method to set or retrieve the space of a DHCP option definition object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Specify the space name in string format.
If you did not specify a parameter, the method returns the attribute value.
# Get space my $option_space = $option_definition1 ->space(); # Modify space $option_definition1 ->space("SUNW");
Use this method to set or retrieve the data type of the grid DHCP option.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The accepted types are the following:
"boolean" - For "true" or "false" boolean values.
"ip-address" - For a single IPv4 address. An IPv4 address is a 32-bit number in dotted decimal notation. It consists of four 8-bit groups of decimal digits separated by decimal points (example: "192.168.1.2").
"array of ip-address" - For a list of IPv4 addresses, each separated by a comma. (example: "192.168.1.2, 10.11.12.13, 79.2.3.1")
"string" - For value in ASCII text string or a list of hexadecimal characters (0-9, a-f, or A-F) without spaces and separated by colons.
"text" - For value in ASCII text string.
"domain-name" - For domain name in ASCII text format
"domain-list" - For a list of domain names, each separated by a comma.
"8-bit unsigned integer" - For numeric value between 0 and 255.
"16-bit unsigned integer" - For numeric value between 0 and 65535.
"32-bit unsigned integer" - For numeric value between 0 and 4294967295.
"8-bit signed integer" - For numeric value between -128 and 127.
"16-bit signed integer" - For numeric value between -32768 and 32767.
"32-bit signed integer" - For numeric value between -2147483648 and 2147483647.
"array of 8-bit unsigned integer" - For a list of numeric values between 0 and 255, each separated by a comma.
"array of 16-bit unsigned integer" - For a list of numeric values between 0 and 65535, each separated by a comma.
"array of 32-bit unsigned integer" - For a list of numeric values between 0 and 4294967295, each separated by a comma.
"array of 8-bit integer" - For a list of numeric values between -128 and 127, each separated by a comma.
"array of 16-bit integer" - For a list of numeric values between -32768 and 32767, each separated by a comma.
"array of 32-bit integer" - For a list of numeric values between -2147483648 and 2147483647, each separated by a comma.
The following types are valid only for Microsoft(r)
server options
"binary"
"encapsulated"
"array of string"
"array of 64-bit unsigned integer" - For a list of numeric values between 0 and 1.8446744 * 10^19
"64-bit unsigned integer" - For a list of numeric values between 0 and 1.8446744 * 10^19, each separated by a comma.
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 type my $option_definitiontype = $option_definition1 ->type(); # Modify type $option_definition1 ->type("string");
The following sample code demonstrates the different functions that can be applied to an object such as add, modify, and remove. Also, this sample includes error handling for the operations.
#Preparation prior to a DHCP Network 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: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "Session created successfully\n";
my $option_space1 = Infoblox::DHCP::OptionSpace->new( "name" => "SUNW" ); my $response = $session->add( $option_space1); print "Add option space operation success \n" if ($response ); print "Add option space operation failed \n" if ( not $response );
#Create a DHCP OptionDefinition object.
my $option_definition1 = Infoblox::DHCP::OptionDefinition->new( space => "SUNW", name => "JumpStart-server", code => "6", type => "text" ); unless ($option_definition1) { die("Construct DHCP OptionDefinition failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP OptionDefinition object created successfully\n";
#Add the DHCP OptionDefinition object to Infoblox appliance through a session my $response = $session->add( $option_definition1 ) or die("Add a DHCP OptionDefinition object failed: ", $session->status_code() . ":" . $session->status_detail());
print "Add a DHCP OptionDefinition object successfully\n";
#Get and modify a DHCP OptionDefinition object attribute
#Get Network through the session my @retrieved_objs = $session->get( object => "Infoblox::DHCP::OptionDefinition", space => "SUNW", name => "JumpStart-server", );
my $object = $retrieved_objs[0];
unless ($object) { die("Get DHCP OptionDefinition object failed: ", $session->status_code() . ":" . $session->status_detail()); } print "Get DHCP OptionDefinition object found at least 1 matching entry\n";
#Modify one of the attributes of the specified Network attribute
$object->code(20); #Apply the changes
$session->modify($object) or die("Modify DHCP OptionDefinition attribute failed: ", $session->status_code() . ":" . $session->status_detail());
print "DHCP OptionDefinition object modified successfully \n";
#Remove a DHCP OptionDefinition Object
#Get DHCP OptionDefinition object through the session my @retrieved_objs = $session->get( object =>"Infoblox::DHCP::OptionDefinition", space => "SUNW", name => "JumpStart-server", );
my $object = $retrieved_objs[0];
unless ($object) { die("Get DHCP OptionDefinition object failed: ", $session->status_code() . ":" . $session->status_detail()); }
print "Get DHCP OptionDefinition object found at least 1 matching entry\n";
#Submit the object for removal
$session->remove($object) or die("Remove Network failed: ", $session->status_code() . ":" . $session->status_detail());
print "DHCP OptionDefinition removed successfully \n";
#Remove option space.
my $response = $session->remove( object => "Infoblox::DHCP::OptionSpace" , name => "SUNW", ); print "Remove option space success \n" if ($response ); print "Remove option space failed \n" if ( not $response );
####PROGRAM ENDS####
Infoblox Inc. http://www.infoblox.com/
Infoblox::Session, Infoblox::DHCP::OptionSpace, Infoblox::DHCP::Option, Infoblox::Session->get(), Infoblox::Session->add(), Infoblox::Session->remove(), Infoblox::Session->modify()
Copyright (c) 2017 Infoblox Inc.