Infoblox::Grid::Member::StaticRoute - Static route member object


NAME

Infoblox::Grid::Member::StaticRoute - Static route member object


DESCRIPTION

A StaticRoute object provides static route information for a grid member.


CONSTRUCTOR

 my $route = Infoblox::Grid::Member::StaticRoute->new(
        "network" => $network,          #Required
        "gateway" => $ip_address,       #Required
 );


MODULE METHODS

The following functions can be applied to a StaticRoute object.

Infoblox::Grid::Member->static_routes( )

Use this function to specify a StaticRoute object for the grid member. See Infoblox::Grid::Member->static_routes() for parameters and return values.

Example
 #Get static routes list
 my $static_routes = $grid_member->static_routes();
 #Modify static routes list
 my $route = Infoblox::Grid::Member::StaticRoute->new(
        "network" => "192.168.2.0/24",
        "gateway" => "192.168.1.1",
 );
 $grid_member->static_routes([$route]);


METHODS

This section describes all the methods that can be used to configure and retrieve the attribute values of a StaticRoute object.

network( )

Use this method to set or retrieve the network address of a StaticRoute object.

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

Parameter

Specify the address and netmask of network in CIDR format (example: 192.168.2.0/24).

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 network address
 my $network= $route->network();
 #Modify network address
 $route-->network("192.168.2.0/24");

gateway( )

Use this method to set or retrieve the gateway of the StaticRoute object.

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

Parameter

Specify the gateway address in IPv4 address format. 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).

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 gateway address
 my $gateway= $route->gateway();
 #Modify gateway address
 $route-->gateway("192.168.2.0");


SAMPLE CODE

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

#Preparation prior to a StaticRoute object insertion

 use strict;
 use warnings;
 use Infoblox;
 my $host_name = "infoblox.localdomain";
 my $host_ip   = "192.168.1.2";
 #Creating a session to the Infoblox appliance.
 my $session = Infoblox::Session->new(
     master   => $host_ip,
     username => "admin",
     password => "infoblox"
 );
 unless ($session) {
     die(qq(constructor for session failed: ),
         join(":", Infoblox::status_code(), Infoblox::status_detail()));
 }
 print "Session created successfully \n";

#Create a StaticRoute object

 #Creating a StaticRoute object.
 my $route = Infoblox::Grid::Member::StaticRoute->new(
        "network" => "192.168.2.0/24",
        "gateway" => "192.168.1.1",
 ) or die(qq(Constructor for StaticRoute failed: ),
    join(":", Infoblox::status_code(), Infoblox::status_detail()));
 print "StaticRoute object constructed successfully \n";

#Add a StaticRoute object to the static routes list of the grid member

 #Getting the Grid Member object from the appliance through a session.
 my @result = $session->get(
     object => "Infoblox::Grid::Member",
     name   => $host_name,
     ) or die(qq(Get Grid Member failed: ),
     join(":", $session->status_code(), $session->status_detail()));
 print "Get Grid Member successful\n";
 my $result = $result[0];
 if ($result) {
     #Modifying the value of the StaticRoute method from the member object.
     $result->static_routes([$route]);
     #Applying the changes to appliance through session.
     $session->modify($result)
         or die(qq(Modify Grid Member failed: ),
         join(":", $session->status_code(), $session->status_detail()));
 }
 print "StaticRoute object added to Grid Member successfully\n";

#Remove the static routes list

 #Remove the StaticRoute object from the Grid Member object.
 $result->static_routes([]);
 #Update the Grid Member object through the Infoblox session.
 $session->modify($result)
   or die("Modify Grid Member object failed: ",
   $session->status_code() . ":" . $session->status_detail());
 print "Removed StaticRoute object from Grid Member successfully\n";
 ####PROGRAM ENDS####


AUTHOR

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


SEE ALSO

Infoblox::Grid::Member


COPYRIGHT

Copyright (c) 2017 Infoblox Inc.