NAME

PDK::Device::Radware - A module for interacting with Radware devices, enabling configuration retrieval, command execution, and automated management.

SYNOPSIS

use PDK::Device::Radware;

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

$device->login();
my $config = $device->getConfig();
$device->runCommands(['show version', 'show interfaces']);
$device->ftpConfig('hostname', 'ftp.example.com', 'ftpuser', 'ftppass');

DESCRIPTION

The PDK::Device::Radware module provides methods to interact with Radware devices. It includes capabilities for retrieving configurations, executing commands, and automating CLI-based interactions. The module handles prompts, error detection, and special input scenarios such as confirmations or passphrase requests.

This module is designed to emulate the behavior of proficient network administrators, providing a robust interface for managing Radware devices programmatically.

ATTRIBUTES

prompt

A regular expression that matches the Radware device's prompt. The default is set to '^>>.*?#\s*$', which captures common device prompt formats.

METHODS

new(%options)

Creates a new PDK::Device::Radware object.

my $device = PDK::Device::Radware->new(
  host     => '192.168.1.1',
  username => 'admin',
  password => 'password',
  prompt   => '^MyRadware>>.*?#\s*$' # Optional custom prompt
);
errCodes()

Returns an array reference of regular expressions that match common error messages, such as "Error:", helping to identify issues during command execution.

waitfor($prompt, $params)

Waits for a specific prompt during interaction with the device. This method captures output, manages paging, handles confirmations, and processes passphrases if required.

$device->waitfor('^MyPrompt>>', {
  send     => 'show version',
  continue => 1,
  cache    => 1
});
runCommands(\@commands)

Executes a series of commands in configuration mode. Automatically adds commands to switch to the root view and ensures the configuration is saved by appending necessary save commands.

$device->runCommands(['set hostname MyRadware', 'set ntp server 192.168.1.100']);
getConfig()

Retrieves the current configuration from the Radware device. This is done by running a series of commands, and the configuration is returned as a hash reference containing the status and configuration data.

my $config = $device->getConfig();
print $config->{config} if $config->{success};
ftpConfig($hostname, $server, $username, $password)

Backs up the device configuration using FTP. It connects to an FTP server, uploads the configuration file, and handles authentication using provided credentials or environment variables.

$device->ftpConfig('MyRadware', 'ftp.example.com', 'ftpuser', 'ftppass');

ENVIRONMENT

The module uses the following environment variables if they are set:

PDK_FTP_SERVER

The default FTP server to use for configuration backups.

PDK_FTP_USERNAME

The default username for FTP authentication.

PDK_FTP_PASSWORD

The default password for FTP authentication.

DEPENDENCIES

This module requires the following Perl modules:

Moose
Expect
Carp
namespace::autoclean

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.