Skip to content
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

Diagnostic results problem #306

Open
menemat opened this issue Apr 8, 2024 · 2 comments
Open

Diagnostic results problem #306

menemat opened this issue Apr 8, 2024 · 2 comments
Labels

Comments

@menemat
Copy link

menemat commented Apr 8, 2024

Hi folks,
We've created a diagnostic tool for Juniper switches. The command used is "show configuration interfaces | display xml". However, the diagnostic fails. But when we execute a command like "show configuration interfaces ge-0/0/0 | display xml", it works perfectly.

{
"type": ".SimpleDiagnostic",
"id": 4,
"name": "Juniper_interfaces_xml",
"targetGroup": {
"type": "StaticDeviceGroup",
"changeDate": 1712574127000,
"id": 30,
"name": "test",
"folder": "test",
"hiddenFromReports": false
},
"enabled": true,
"resultType": "TEXT",
"deviceDriver": "JuniperJunos",
"cliMode": "operate",
"command": "show configuration interfaces | display xml",
"modifierPattern": "",
"modifierReplacement": "",
"deviceDriverDescription": "Juniper Junos"
}

Output:

[WARN] Setting value for diagnostic key 'Juniper_interfaces_xml'
[ERROR] Error while executing the diagnostics: org.hibernate.exception.DataException: could not execute statement

Netshot version 0.18.3

The switch is a Juniper ex2200-24p-4g. There are no virtual chassis, so the network interfaces are limited.

Thanks in advance.
M.

@SCadilhac
Copy link
Contributor

The result of the diagnostic is too long to be stored in the DB as per current constraints.
Diagnostics were designed to report rather short results.
May I know why you are trying to store the entire interface config block in XML format rather that using curly and set config formats already stored by the Junos driver?

@menemat
Copy link
Author

menemat commented Apr 15, 2024

At the moment there are no way to retrive the configured vlan on a specific port.
In /devices/{id}/interfaces there aren't info about vlan.

With this diagnostic we are able to retrive this information as a text:

``
import re

def extract_interface_vlan(output):
clean_configs = [re.sub(r"^set interfaces |unit 0 family ethernet-switching vlan members ", "", line) for line in output.split('\n') if line.startswith("set interfaces") and not line.startswith("set interfaces vlan") and not line.startswith("set interfaces irb") and "native" not in line]
return '\n'.join(clean_configs)

def diagnose(cli, device, diagnostic):
cli.macro("operate")
output = cli.command("show configuration interfaces | display set | match vlan")
interface_configs = extract_interface_vlan(output)
diagnostic.set(interface_configs)

``

The output is like this:
ge-0/0/0 199-200
ge-0/0/0 204
ge-0/0/0 301
ge-0/0/1 204
ge-0/0/2 204
....

The idea would then be to make a simple graphical interface (with django) to read and modify the vlan of a port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants