Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Including Infoblox_Job.pm in a Perl script will manage the initialization sequence for the job manager. Infoblox_Job.pm abstracts many of the details of the NetMRI v2 PAPI for common Perl script tasks and exposes them through standard Perl functions. These functions are as follows:

#  Name                         : open_session

# Description                   : Open a session with the DIS (Device Interaction Server) for the current job. The DIS proxies CLI requests between clients (e.g. Perl scripts) and network devices. A single DIS session can handle connections to multiple network devices.

# Arguments                     : None

# Returns                       : None

#Example:                       : open_session();


#Name                           : close_session

#Description                    : Close the current DIS session.

#Arguments                      : None

#Returns                        : None

#Example:                       : close_session();


#Name                           : log_message

#Description                    : Log a message of the given severity. The message is written to the custom.log file.

#Arguments                      : severity (string, required - valids =

#                                       debug, error, warning, info)

#                                The severity.

#                                message (string, required)

#                                The message.

#Returns                        : None

#Example:                       : log_message(

#                                          "debug",

#                                           "Hello World!"

#                                );


# Name                           : open_connection

# Description                    : Open a connection with the target device via the DIS for the current DIS session.

# Arguments                      : None

# Returns                        : None

# Example:                       : open_connection();


# Name                           : close_connection

# Description                    : Close the connection with the target device for the current DIS session.

# Arguments                      : None

# Returns                        : None

# Example:                       : close_connection();

# Name                           : set_variable

# Description                    : Set a server-side variable. This is useful when retrieving a template via get_template and the template contains variables that are not defined by the Script-Variables for the current job. This is because template merging (i.e. variable substitution) is performed on the server-side.

# Arguments                      : command (string, required)

#                                 The set variable command.

# Returns                        : None

# Example:                       : set_variable("\$Username = \"$some_username\"");


# Name                           : send_command

# Description                    : Send a command to the target device.

# Arguments                      : command (string, required)

#                                 The command to be sent to the target device.

#

#                                 debug (boolean, optional - default = "off")

#                                 Debug mode. If enabled, the command will not be sent to the

#                                 target device, but what would have been sent will appear in the logs.

# Returns                       : (string)

#                                1. The output from the command (debug == "off").

#                                2. "" (debug == "on").

# Example:                      : my $output = send_command("show version");


# Name                          : get_template

# Description                   : Retrieve a template. For the given template, retrieve the content and perform any necessary variable substutions.

# Arguments                     : template (string, required)

#                                The name of the template to be retrieved.

#

#                                stage (boolean, optional - default = "off")

#                                Stage mode. If enabled, the template is staged on NetMRI in a location that is anonymously available via TFTP and HTTP. The staged file is removed when the script has exited.

# Returns                       : (string)

#                                1. The template contents (stage == "off").

#                                2. The path to the template contents (stage == "on").

# Example:                      : my $contents = get_template("Cisco Router");


# Name                          : get_list_value

# Description                   : Lookup a value in a list. For the given list name, finds the first row containing the given key value in the given key column and returns the value contained in the given value column. If the lookup fails, the given default is returned.

# Arguments                     : list_name (string, required)

#                                The list name.

#

#                                key_column (string, required)

#                                The key column.

#

#                                key_value (string, required)

#                                The key value.

#

#                                value_column (string, required)

#                                The value column.

#

#                                default (string, optional - default = "")

#                                The default.

#

# Returns                       : (string)

#                                The result of the lookup.

# Example:                      : my $enable_password = get_list_value(

#                                       "Enable Passwords",

#                                       "IP Address",

#                                       $ipaddress,

#                                       "Password",

#                                       "NOT FOUND"

#                                 );

# Name                            : generate_issue

# Description                     : Generate an issue. For the given issue type id, generate an issue of the given severity using the name/value pairs defined in the given params as the issue details.

# Arguments                       : issue_type_id (string, required)

#                                  The issue type id.

#

#                                  severity (string, required - valids = error, warning, info)

#                                  The severity.

#

#                                  params (hash reference, required)

#                                  The issue details.

# Returns                         : (number)

#                                 The assigned issue id.

# Example:                        : my $issue_id = generate_issue(

#                                       "Invalid Accounts",

#                                        "warning", {

#                                        "IP Address"=> $ipaddress,

#                                        "Username"=> $some_username

#                                  });

When including Infoblox_Job.pm in your Perl scripts, you do not have to explicitly call log_message(), open_session(), open_connection(), close_session() or close_connection(). Infoblox_Job.pm contains code that executes upon being included. Therefore, the second line of your Perl script can begin to access the other functions defined in Infoblox_Jon.pm. As an example:

require "Infoblox_Job.pm";
my $output = send_command("show version");

  • No labels