n8n-nodes-netdevices
Version:
n8n node to interact with network devices (Cisco, Juniper, Palo Alto PAN-OS, Ciena SAOS, Linux, etc.)
68 lines • 2.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CienaSaosConnection = void 0;
const base_connection_1 = require("../base-connection");
class CienaSaosConnection extends base_connection_1.BaseConnection {
constructor(credentials) {
super(credentials);
}
async sessionPreparation() {
await this.createCienaShellChannel();
await this.setBasePrompt();
await this.disablePaging();
}
async createCienaShellChannel() {
return new Promise((resolve, reject) => {
this.client.shell((err, channel) => {
if (err) {
reject(err);
return;
}
this.currentChannel = channel;
this.currentChannel.setEncoding(this.encoding);
setTimeout(() => resolve(), this.fastMode ? 200 : 600);
});
});
}
async setBasePrompt() {
await this.writeChannel(this.returnChar);
const output = await this.readChannel(3000);
const lines = output.trim().split('\n');
const lastLine = lines[lines.length - 1];
this.basePrompt = lastLine.replace(/[>$#]\s*$/, '').trim();
this.enabledPrompt = this.basePrompt + '>';
this.configPrompt = this.basePrompt + '#';
}
async disablePaging() {
try {
await this.writeChannel('system shell session set more off' + this.newline);
await this.readChannel(2000);
}
catch (error) {
}
}
async saveConfig() {
try {
await this.writeChannel('configuration save' + this.newline);
const output = await this.readUntilPrompt(undefined, 10000);
return {
command: 'configuration save',
output: this.sanitizeOutput(output, 'configuration save'),
success: true
};
}
catch (error) {
return {
command: 'configuration save',
output: '',
success: false,
error: error instanceof Error ? error.message : String(error)
};
}
}
async enterConfigMode() { return; }
async exitConfigMode() { return; }
isInConfigMode() { return false; }
}
exports.CienaSaosConnection = CienaSaosConnection;
//# sourceMappingURL=ciena-saos-connection.js.map