NAME
PDK::Device::H3C - A module for interacting with H3C devices
SYNOPSIS
use PDK::Device::H3C;
my $device = PDK::Device::H3C->new(
host => '192.168.1.1',
username => 'admin',
password => 'H3Cpassword'
);
# Log in to the device
$device->login();
# Execute script in normal mode
$device->execCommands(['display version', 'display arp']);
# Execute script in configuration mode, automatically outfitting [system-view, save]
$device->runCommands(['display version']);
# Retrieve running configuration
my $config = $device->getConfig('hostname');
# FTP configuration backup
my $config = $device->ftpConfig('hostname', 'ftp_server', 'ftp_username', 'ftp_password');
# filename is optional, defaults to device IP address, e.g., 192.168.1.1.cfg
$device->write_file('content', 'filename');
DESCRIPTION
This module provides functionality to interact with H3C devices, including executing commands, retrieving configurations, and backing up configurations via FTP.
ATTRIBUTES
- prompt
-
The device's default prompt, defaults to '\S+[#>]\s*\z'.
- enPrompt
-
Enable mode prompt, defaults to '\S+[>]\s*\z'.
- enCommand
-
Command to switch to enable mode, defaults to 'system-view'.
METHODS
- errCodes
-
Returns a list of possible error codes for checking errors during command execution.
- waitfor
-
Waits for a specific prompt match, automatically executing the script interactively.
- write_file
-
Writes configuration information to a text file.
- runCommands
-
Executes a series of commands and configures the sending mode.
Parameters: - $commands: List of commands (array reference).
- getConfig
-
Retrieves the running configuration of the device.
Returns: A hash reference containing a success flag and configuration content.
- ftpConfig
-
Backs up the running configuration via FTP.
Parameters: - $hostname: Optional hostname. - $server: FTP server address. - $username: FTP username. - $password: FTP password. Returns: The result of executing the command.
AUTHOR
WENWU YAN <968828@gmail.com>