Skip to content

Fortinet FortiOS : Add HA Group Name and Group ID #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/main/resources/drivers/Fortinet_FortiOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var Info = {
name: "FortinetFortiOS", /* Unique identifier of the driver within Netshot. */
description: "Fortinet FortiOS", /* Description to be used in the UI. */
author: "Netshot Team",
version: "6.0" /* Version will appear in the Admin tab. */
version: "6.1" /* Version will appear in the Admin tab. */
};

/**
Expand Down Expand Up @@ -63,6 +63,18 @@ var Device = {
type: "Text",
title: "HA peer name",
searchable: true,
checkable: true,
},
"haName": { /* This stores the name of an optional HA Group Name. */
type: "Text",
title: "HA group name",
searchable: true,
checkable: true,
},
"haId": { /* This stores the name of an optional HA Group ID. */
type: "Text",
title: "HA group ID",
searchable: true,
checkable: true
}
};
Expand Down Expand Up @@ -186,7 +198,8 @@ function snapshot(cli, device, config) {
var showSystemSnmp = cli.command("show system snmp sysinfo | grep .");
// Store the HA status
var getHa = cli.command("get system ha status | grep .");

// Store the HA config block
var showHa = cli.command("show system ha | grep .");

if (vdomMode) {
if (!useScp && version.match(/^6\.2\..*/)) {
Expand Down Expand Up @@ -253,6 +266,8 @@ function snapshot(cli, device, config) {
device.set("location", location[1]);
}
}

// Read HA Peers from the unit directly.
var peerPattern = /^(Master|Slave|Primary|Secondary) *: (.+?) *, +([A-Z0-9]+)(, HA cluster index = [0-9]|, cluster index = [0-9])*$/gm;
var match;
while (match = peerPattern.exec(getHa)) {
Expand All @@ -262,6 +277,23 @@ function snapshot(cli, device, config) {
}
}

// Read the HA Group Name and HA Group ID fields from the configuration directly.
var haInfos = cli.findSections(showHa, /config system ha/);
for (var s in haInfos) {
var haGroup = haInfos[s].config.match(/set group-name "(.*)"/);
if (haGroup) {
device.set("haName", haGroup[1]);
} else {
device.set("haName", "NOT-SET");
}
var haId = haInfos[s].config.match(/set group-id (.*)/);
if (haId) {
device.set("haId", haId[1]);
} else {
device.set("haId", "NOT-SET");
}
}

// Read the list of interfaces.
var vdomArp = {};
var interfaces = cli.findSections(showSystemInterface, /^ *edit "(.*)"/m);
Expand Down