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 commands in normal mode
$device->execCommands(['display version', 'display arp']);
# Execute commands in configuration mode, automatically adding [system-view, save]
$device->runCommands(['display version']);
# Retrieve running configuration
my $config = $device->getConfig();
# FTP configuration backup
my $backup = $device->ftpConfig('hostname', 'ftp_server', 'ftp_username', 'ftp_password');
DESCRIPTION
This module provides functionality to interact with H3C devices, including executing commands, retrieving configurations, and backing up configurations via FTP. It extends the PDK::Device::Base role and is tailored for H3C-specific operations.
ATTRIBUTES
- prompt
-
The device's default prompt, defaults to '^\s*(\x00)?[<\[].*?[>\]]\s*$'. This pattern is designed to handle older H3C devices that may have '^@' in their prompts.
METHODS
- errCodes
-
Returns a list of possible error patterns for checking errors during command execution. These include patterns for ambiguous commands, incomplete commands, unrecognized commands, 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
- runCommands($commands)
-
Executes a series of commands in configuration mode. It automatically adds 'system-view' at the beginning if not present, and 'save force' at the end if not already included.
Parameters: - $commands: An array reference containing the list of commands
- getConfig
-
Retrieves the running configuration of the device. It executes commands to disable screen length limitations, display the current configuration, and force a configuration save.
Returns: A hash reference containing a success flag and configuration content.
- ftpConfig($hostname, $server, $username, $password)
-
Backs up the running configuration to an FTP server.
Parameters: - $hostname: Optional hostname - $server: FTP server address (if not provided, uses the PDK_FTP_SERVER environment variable) - $username: FTP username (if not provided, uses the PDK_FTP_USERNAME environment variable) - $password: FTP password (if not provided, uses the PDK_FTP_PASSWORD environment variable)
Returns: A hash reference containing a success flag and the FTP operation result.
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.