Infoblox::DHCP::FilterRule::RelayAgent - DHCP RelayAgent Filter Rule object.


NAME

Infoblox::DHCP::FilterRule::RelayAgent - DHCP RelayAgent Filter Rule object.


DESCRIPTION

A relay agent adds the circuit ID and Remote ID information to the client request and sends it to DHCP Server. Infoblox appliance uses Relay Agent Filter Rules to grant/deny the lease to a request that comes from those Relay Agents.


CONSTRUCTOR

 my $ra_filter_rule = Infoblox::DHCP::FilterRule::RelayAgent->new(
       filter_name   => $string,          #Required
       permission    => "grant" | "deny", #Required
 );


MODULE METHODS

The following functions are available to apply to a DHCP RelayAgent Filter Rule object.

Infoblox::DHCP::Range->filters( )

Use this method to add a DHCP RelayAgent Filter Rule object to the DHCP Range on the Infoblox appliance. See Infoblox::DHCP::Range->filters() for parameters and return values.

Example
 #Construct a DHCP RelayAgent Filter Rule object
 my $ra_filter_rule1 = Infoblox::DHCP::FilterRule::RelayAgent->new(
       filter_name   => "filter1",
       permission    => "grant",
 );
 #Add RelayAgent Filter Rule to the DHCP Range object.
 my $response = $dhcp_range->filters([$ra_filter_rule1]);


METHODS

This section describes all the methods that can be used to set and retrieve the attribute values of a DHCP RelayAgent Filter Rule object.

filter_name( )

Use this method to set or retrieve the filter_name of a DHCP RelayAgent Filter Rule object.

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

Parameter

Name of the DHCP RelayAgent filter. Maximum length up to 1024 bytes is supported.

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 filter_name
 my $filter_name = $ra_filter_rule->filter_name();
 #Modify filter_name
 $ra_filter_rule->filter_name("filter2");

permission( )

Use this method to set or retrieve the permission of a DHCP RelayAgent Filter Rule object.

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

Parameter

Specify the permission in string format. The permission can be either "grant" or "deny".

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 permission
 my $permission = $ra_filter_rule->permission();
 #Modify permission
 $ra_filter_rule->permission("deny");


SAMPLE CODE

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

#Preparation prior to a DHCP RelayAgent Filter Rule 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 the Network object
 my $network = Infoblox::DHCP::Network->new(
     network => "10.0.0.0/8",
     comment => "add network",
 );
 unless($network) {
        die("Construct Network object failed: ",
             Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "Network object created successfully\n";
 #Add the Network object into the Infoblox appliance through a session
 $session->add($network)
     or die("Add Network object failed: ",
             $session->status_code() . ":" . $session->status_detail());
 print "Network object added to Infoblox appliance successfully\n";
 #Construct a DHCP RelayAgent Filter object
 my $ra_filter = Infoblox::DHCP::Filter::RelayAgent->new(
        name            => "filter1",
        circuit_id_name => "circuit",
        remote_id_name  => "remote"
 );
 unless ( $ra_filter ) {
        die("Construct RelayAgent Filter failed: ",
                Infoblox::status_code() . ":" . Infoblox::status_detail() );
 }
 print "RelayAgent Filter object created successfully\n";
 #Add the RelayAgent Filter to the Infoblox appliance through a session
 $session->add($ra_filter)
     or die("Add RelayAgent Filter object failed: ",
             $session->status_code() . ":" . $session->status_detail());
 print "RelayAgent Filter object added to Infoblox appliance successfully\n";

#Create a DHCP RelayAgent Filter Rule object

 #Construct a DHCP RelayAgent Filter Rule object
 my $ra_filter_rule1 = Infoblox::DHCP::FilterRule::RelayAgent->new(
       filter_name   => "filter1",
       permission    => "grant",
 );
 unless ( $ra_filter_rule1 ) {
        die("Construct RelayAgent Filter Rule failed: ",
                Infoblox::status_code() . ":" . Infoblox::status_detail() );
 }
 print "RelayAgent Filter Rule object created successfully\n";
 #Create the DHCP Range object with this RelayAgent Filter Rule.
 my $dhcp_range = Infoblox::DHCP::Range->new(
         end_addr   => "10.0.0.10",
         network    => "10.0.0.0/8",
         start_addr => "10.0.0.1",
         filters    => [ $ra_filter_rule1 ],
 );
 unless($dhcp_range) {
        die("Construct DHCP Range object failed: ",
             Infoblox::status_code() . ":" . Infoblox::status_detail());
 }
 print "DHCP Range object created successfully\n";
 #Add the DHCP Range object into the Infoblox appliance through a session
 $session->add($dhcp_range)
     or die("Add DHCP Range object failed: ",
             $session->status_code() . ":" . $session->status_detail());
 print "DHCP Range object added to Infoblox appliance successfully\n";

#Get and modify a RelayAgent Filter Rule object

 #Get RelayAgent Filter Rule object from the DHCP Range object through session
 my @retrieved_objs = $session->get(
     object      => "Infoblox::DHCP::Range",
     start_addr  => "10.0.0.1",
 );
 my $object = $retrieved_objs[0];
 my $filter = $object->filters();
 my @filters = @{$filter};
 my $ra_filterrule = $filters[0];
 #Modify one of the attributes of the obtained RelayAgent Filter Rule object
 $ra_filterrule->permission("deny");
 $object->filters([$ra_filterrule]);
 #Apply the changes
 $session->modify($object)
     or die("Modify RelayAgent Filter Rule object failed: ",
            $session->status_code() . ":" . $session->status_detail());
 print "RelayAgent Filter Rule object modified and added to the DHCP Range object successfully \n";

#Remove a RelayAgent Filter Rule object

 $object->filters([]);
 my $response = $session->modify($object);
 unless($response) {
        die("Remove RelayAgent Filter Rule failed: ",
                session->status_code() . ":" . session->status_detail() );
 }
 print "RelayAgent Filter Rule object removed successfully \n";
 #Submit the network object for removal
 $session->remove($network)
     or die("Remove Network object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 print "Network object removed successfully \n";
 #Submit the relay agent filter object for removal
 $session->remove($ra_filter)
     or die("Remove RelayAgent Filter object failed: ",
         $session->status_code() . ":" . $session->status_detail());
 print "RelayAgent Filter object removed successfully \n";
 ####PROGRAM ENDS####


AUTHOR

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


SEE ALSO

Infoblox::DHCP::MAC, Infoblox::DHCP::FilterRule::RelayAgent, Infoblox::DHCP::Network, Infoblox::DHCP::Range, Infoblox::Session->add(), Infoblox::Session->get(), Infoblox::Session->modify(), Infoblox::Session->remove(),Infoblox::Session


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.