NAME

PDK::Device::Paloalto - Module for managing Palo Alto Networks devices

SYNOPSIS

use PDK::Device::Paloalto;

my $device = PDK::Device::Paloalto->new(
  host     => '192.168.1.1',
  username => 'admin',
  password => 'paloalto_password'
);

# Log in to the device
$device->login();

# Execute commands
$device->execCommands(['show system info', 'show interface all']);

# Retrieve running configuration
my $config = $device->getConfig();

DESCRIPTION

This module provides functionality to interact with Palo Alto Networks devices, including executing commands and retrieving configurations. It extends the PDK::Device::Base role and is tailored for Palo Alto-specific operations.

ATTRIBUTES

prompt

The device's default prompt, defaults to '^.*?$$(?:active|passive|suspended)$$[>#]\s*$'. This pattern is designed to handle various Palo Alto device prompts, including active, passive, and suspended states.

METHODS

errCodes

$device->errCodes();

Returns an array reference of regular expressions representing possible error patterns that may occur during command execution. These include patterns for unknown commands, invalid syntax, and other common errors.

waitfor($prompt, $params)

Waits for a specific prompt match and handles device responses interactively.

Parameters: - $prompt: The prompt to match (optional) - $params: A hash reference containing send command and other options (optional) - send: The command to send - continue: Whether to continue execution (default: false) - cache: Whether to cache the output (default: true)

Returns: The output of the command execution

This method handles pagination ("lines X-Y") and confirmation prompts ("are you sure?").

getConfig

$device->getConfig();

Retrieves the running configuration of the device. It executes a series of commands to set the CLI pager off, set the config output format, enter configuration mode, show the configuration, and exit.

Returns: A hash reference containing a success flag and configuration content.

ERROR HANDLING

The module uses croak to throw exceptions when errors occur, including:

  • Connection timeouts to the device.

  • Unexpected disconnections during command execution.

  • Invalid syntax or unknown commands.

DEPENDENCIES

This module depends on the following Perl modules:

  • Moose - For object-oriented programming.

  • Expect - For interacting with devices through terminal sessions.

  • Carp - For error handling with croak.

  • namespace::autoclean - For keeping the namespace clean.

INHERITANCE

This module inherits from PDK::Device::Base.

AUTHOR

WENWU YAN <968828@gmail.com>

LICENSE AND COPYRIGHT

Copyright (C) 2024 WENWU YAN

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

SEE ALSO

PDK::Device::Base, Moose, Expect