n8n-nodes-netdevices
Version:
n8n node to interact with network devices (Cisco, MikroTik, Arista, Extreme Networks, Dell, Juniper, HP, Aruba, Ubiquiti, Palo Alto, Fortinet - ISP, data center, campus, and edge)
107 lines • 3.39 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArubaAosCxConnection = void 0;
const cisco_connection_1 = require("../cisco/cisco-connection");
class ArubaAosCxConnection extends cisco_connection_1.CiscoConnection {
constructor(credentials) {
super(credentials);
this.newline = '\r';
}
async sessionPreparation() {
await this.createCiscoShellChannel();
if (this.fastMode) {
await this.setBasePrompt();
}
else {
await this.setBasePrompt();
await this.disableAosCxPaging();
await this.checkAndEnterEnableMode();
}
}
async disableAosCxPaging() {
try {
await this.writeChannel('no page' + this.newline);
await this.readChannel(2000);
}
catch (error) {
}
}
async checkConfigMode() {
try {
await this.writeChannel(this.returnChar);
const output = await this.readChannel(2000);
return output.includes('(config)#');
}
catch (error) {
return false;
}
}
async enterConfigMode() {
if (await this.checkConfigMode()) {
this.inConfigMode = true;
return;
}
if (!this.inEnableMode) {
try {
await this.enterEnableMode();
}
catch (error) {
}
}
try {
await this.writeChannel('configure term' + this.newline);
const output = await this.readChannel(3000);
if (output.includes('(config)#')) {
this.inConfigMode = true;
}
else {
throw new Error('Failed to enter configuration mode');
}
}
catch (error) {
throw new Error(`Failed to enter configuration mode: ${error}`);
}
}
async exitConfigMode() {
if (!this.inConfigMode) {
return;
}
try {
await this.writeChannel('end' + this.newline);
const output = await this.readChannel(3000);
if (output.includes('#') && !output.includes('(config)#')) {
this.inConfigMode = false;
}
else {
await this.writeChannel('exit' + this.newline);
const output2 = await this.readChannel(3000);
if (output2.includes('#') && !output2.includes('(config)#')) {
this.inConfigMode = false;
}
else {
throw new Error('Failed to exit configuration mode');
}
}
}
catch (error) {
throw new Error(`Failed to exit configuration mode: ${error}`);
}
}
async getCurrentConfig() {
return await this.sendCommand('show running-config');
}
async saveConfig() {
return await this.sendCommand('write memory');
}
async showInterfaces() {
return await this.sendCommand('show interface brief');
}
async showVlans() {
return await this.sendCommand('show vlan');
}
async showSystem() {
return await this.sendCommand('show system');
}
}
exports.ArubaAosCxConnection = ArubaAosCxConnection;
//# sourceMappingURL=aruba-aoscx-connection.js.map