Infoblox::DHCP::Filter::Option - DHCP filter option object
A Filter::Option defines a DHCP option filter. In the ISC DHCP terms, it defines a class of clients that match a particular (option, value) pair. To define an option filter, add Option to the DHCP Filter object.
my $optionFilter = Infoblox::DHCP::Filter::Option->new( name => $string, #Required apply_as_class => "true" | "false", #Optional / Default is "true" comment => $string, #Optional / Default is empty boot_file => $filename | undef, #Optional / Default is undefined boot_server => $fqdn | undef, #Optional / Default is undefined extattrs => { $string => $extattr, ... }, #Optional / Default is undefined extensible_attributes => { $string => $string | $num, $string => [ $string | $num, ... ], ... }, #Optional / Default is undefined expression => $string, #Optional / Default is empty lease_time => $time, #Optional / Default is empty next_server => $fqdn | undef, #Optional / Default is undefined option_list => [$Option1, $Option2,...], #Optional / Default is empty option_space => $string, #Optional / Default is "DHCP" pxe_lease_time => $time, #Optional / Default is empty );
You cannot set both extattrs and extensible_attributes attributes at the same time.
This section describes all the methods in Infoblox::Session module that can be applied to a DHCP filter option object.
Use this method to add a DHCP filter option object to the Infoblox device. See Infoblox::Session->add() for parameters and return values.
#Construct an object my $optionFilter = Infoblox::DHCP::Filter::Option->new( name => "option_filter",
);
# Submit for adding a option Filter my $response = $session->add( $optionFilter );
Use this method to retrieve all the matching DHCP option filter objects from the Infoblox device. See Infoblox::Session->get() for parameters and return values.
Apply the following attributes to get a specific DHCP relayagent filter object:
name - Required. An option filter name in string format. 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::Filter::Option" , name => "option_filter", );
# get all objects with a given extensible attribute my @retrieved_objs = $session->get( object => "Infoblox::DHCP::Filter::Option", extensible_attributes => { 'Site' => 'Santa Clara' } );
Use this method to modify a DHCP option filter object in the Infoblox device. See Infoblox::Session->modify() for parameters and return values.
#Use method to modify boot_server method. $object->boot_server("myboot_server.com"); # Submit modification my $response = $session->modify( $object );
Use this method to remove a DHCP option filter object from the Infoblox device. See Infoblox::Session->remove() for parameters and return values.
To remove a specifc object, first use get()
or search()
to retrieve the specific object, and then submit this object for removal.
# Get the object under the same name my @retrieved_objs = $session->get( object => "Infoblox::DHCP::Filter::Option" , "name" => "option_filter", );
# find the desired object from retrieved list. my $desired_obj = $retrieved_objs[0];
# Submit for removal my $response = $session->remove( $desired_obj);
Use this method to search for DHCP option filter object in the Infoblox device. See Infoblox::Session->search() for parameters and return values.
Apply the following attributes to search for a DHCP Network object:
name - Required. An option filter 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.
# search for all DHCP option filter objects my @retrieved_objs = $session->search( object => "Infoblox::DHCP::Filter::Option", name => "option.*", );
# search all DHCP option filter associations with the extensible attribute 'Site' my @retrieved_objs = $session->search( object => "Infoblox::DHCP::Filter::Option", extensible_attributes => { 'Site' => 'Santa Clara' });
This section describes all the methods that can be used to configure and retrieve the attribute values of DHCP option filter object
Use this method to set or retrieve the name of a DHCP option filter object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Specify the name in string format. The default value for this field 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 name my $name = $optionFilter->name(); #Modify name $optionFilter->name("option_filter");
Use this method to set or retrieve the "apply_as_class" flag of a DHCP filter option object. If this flag is set to "true" the filter is treated as global DHCP class, e.g it is written to dhcpd config file even if it is not present in any DHCP range.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Specify "true" to set the "apply_as_class" flag or "false" to deactivate/unset it. The default value is "true".
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 apply_as_class flag my $apply_as_class = $optionFilter->apply_as_class(); #Modify apply_as_class flag $optionFilter->apply_as_class("true");
Use this method to set or retrieve a boot_file attribute of a DHCP filter option object. If this attribute is not set, it will inherit the member level setting.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The name of the file that the client must download.
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 boot_file my $boot_file = $optionFilter->boot_file(); # Modify boot_file $optionFilter->boot_file("bootfile1"); #Un-override boot_file $optionFilter->boot_file(undef);
Use this method to set or retrieve a bootserver attribute of a DHCP filter option object. You can specify the name and/or IP address of the boot server that host needs to boot. If this attribute is not set, it will inherit the member level setting.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The boot server IP address or name in FQDN (Fully Qualified Domain Name) format. The FQDN consists of the host name followed by the domain name (example: abc.com). A boot server name can have 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 boot_server my $bootserver = $optionFilter->bootserver(); # Modify boot_server $optionFilter->boot_server("abc.domain.com"); #Un-override boot_server $optionFilter->boot_server(undef);
Use this method to set or retrieve the descriptive comment of a DHCP filter option 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 = $optionFilter->comment(); #Modify comment $optionFilter->comment("Modified DHCP filter option object comment");
Use this method to set or retrieve the conditional expression of a DHCP filter option object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
An expression in string format, with a maximum of 32768 characters. The expression must comply with the option filter expression syntax.
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.
#Getting expression my $expression = $optionFilter->expression( ); #Modifying expression $optionFilter->expression('Sophos.ComplianceState="PartialCompliant"');
Use this method to set or retrieve the extensible attributes associated with a DHCP Filter Option 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 = $optionFilter->extattrs(); #Modify extattrs $optionFilter->extattrs({ 'Site' => $extattr1, 'Administrator' => $extattr2 });
Use this method to set or retrieve the extensible attributes associated with a DHCP Filter Option 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 = $optionFilter->extensible_attributes(); #Modify extensible attributes $optionFilter->extensible_attributes({ 'Site' => 'Santa Clara', 'Administrator' => [ 'Peter', 'Tom' ] });
Use this method to set or retrieve a lease_time attribute of a DHCP filter option object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Enter appropriate values in seconds.
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 lease_time my $lease_time = $optionFilter->lease_time(); # Modify lease_time $optionFilter->lease_time("7200");
Use this method to set or retrieve a next_server attribute of a DHCP filter option object. You can specify the name and/or IP address of the next server that the host needs to boot. If this attribute is not set, it will inherit the member level setting.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The next server IP address or name in FQDN (Fully Qualified Domain Name) format. The FQDN consists of the host name followed by the domain name (example: abc.com). The next server name can have 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 next_server my $nextserver = $optionFilter->next_server(); # Modify next_server $optionFilter->next_server("blue.domain.com"); #Un-override next_server $optionFilter->next_server(undef);
Use this method to set or retrieve the option_list of a DHCP filter option object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
The valid value is an array reference that contains Infoblox::DHCP::Option objects. Option list describe filter option configuration settings and various services.
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 option_list my $options = $optionFilter->option_list(); #Modify option_list $optionFilter->option_list([$option1]);
Use this method to retrieve the option_space of a DHCP filter option object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Specify the option space value in string format. The default value of option_space is DHCP.
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 option_space my $options = $optionFilter->option_space(); #Modify option_space $optionFilter->option_space("Infoblox_DHCP");
Use this method to set or retrieve a pxe_lease_time attribute of a DHCP filter option object.
Include the specified parameter to set the attribute value. Omit the parameter to retrieve the attribute value.
Enter appropriate values in seconds.
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 pxe_lease_time my $pxe_lease_time = $optionFilter->pxe_lease_time(); # Modify pxe_lease_time $optionFilter->pxe_lease_time("3600");
The following sample code demonstrates the different functions that can be applied to an object such as add, search, modify, and remove. Also, this sample includes error handling for the operations.
#Preparation prior to a DHCP option filter 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 a DHCP Filter Option object
my $optionfilter = Infoblox::DHCP::Filter::Option->new(
name => "option_filter", next_server => "abc_server.com" , boot_file => "file1" , boot_server => "boot_server.com" , lease_time => "7200", pxe_lease_time => "3600", );
unless ($optionfilter) { die("Construct DHCP Filter::Option failed: ", Infoblox::status_code() . ":" . Infoblox::status_detail()); } print "DHCP Filter::Option object created successfully\n"; my $response = $session->add($optionfilter) or die("Add DHCP Filter Option failed: ", $session->status_code() . ":" . $session->status_detail());
print "DHCP Filter Option added successfully\n";
#Search for a specific DHCP Filter Option
#Search the DHCP Filter Option my @retrieved_objs = $session->search( object => "Infoblox::DHCP::Filter::Option", name => "option.*", ); my $object = $retrieved_objs[0]; unless ($object) { die("Search DHCP Filter Option failed: ", $session->status_code() . ":" . $session->status_detail()); }
print "Search DHCP Filter Option found at least 1 matching entry\n";
#Get and modify a DHCP Filter Option attribute
#Get DHCP Filter Option through the session my @retrieved_objs = $session->get(
object =>"Infoblox::DHCP::Filter::Option" , name => "option_filter", );
my $object = $retrieved_objs[0]; unless ($object) { die("Get option filter object failed: ", $session->status_code() . ":" . $session->status_detail()); }
print "Get DHCP Filter Option found at least 1 matching entry\n";
#Modify one of the attributes of the specified DHCP Filter Option attribute
$object->boot_server("another_Server");
#Apply the changes $session->modify($object) or die("Modify DHCP Filter Option attribute failed: ", $session->status_code() . ":" . $session->status_detail());
print "DHCP Filter Option object modified successfully \n";
#Remove a DHCP Filter Option Object
#Get object through the session my @retrieved_objs = $session->get(
object => "Infoblox::DHCP::Filter::Option" , "name" => "option_filter", );
my $object = $retrieved_objs[0];
unless ($object) { die("Get a DHCP Filter Optionobject failed: ", $session->status_code() . ":" . $session->status_detail()); }
print "Get a DHCP Filter Option object found at least 1 matching entry\n";
#Submit the object for removal $session->remove($object) or die("Remove a DHCP Filter Option failed: ", $session->status_code() . ":" . $session->status_detail());
print "DHCP Filter Option removed successfully \n";
####PROGRAM ENDS####
Infoblox Inc. http://www.infoblox.com/
Infoblox::Session, Infoblox::Session->get(), Infoblox::Session->search(), Infoblox::Session->add(), Infoblox::Session->remove(), Infoblox::Session->modify(), Infoblox::Grid::Extattr
Copyright (c) 2017 Infoblox Inc.