Netshot icon indicating copy to clipboard operation
Netshot copied to clipboard

HPE Switches Drivers

Open bernie791023 opened this issue 5 years ago • 23 comments

Hello! Any idea if there's plan to write a driver for HPE switches?

Thanks!

bernie791023 avatar Oct 03 '19 17:10 bernie791023

Hi all, Netshot seems to be a great software, but unfortunately there is no driver for HPE switches. I try to write my own, I started from the Huawei driver, because the commands are very similar. So I replaced all the specific Huawei commands with HPE commands, but I am stocked with an error:

[INFO] Snapshot task for device [NONAME] (X.X.X.X). [ERROR] Error while taking the snapshot: Error while running CLI macro 'user' in at line number 143 at column number 4 [TRACE] Will try Telnet credentials RDL Telnet. [ERROR] I/O error: Timeout waiting for the command output. [ERROR] Error while running snapshot using driver HPE SWITCH: 'Error while running CLI macro 'user' in at line number 143 at column number 4'.

As I am not a developer, it is quite hard for me to find out the solution. Any help?

hemh avatar Oct 09 '19 19:10 hemh

@hemh, the error message means the 'user' prompt /^(<[A-Za-z\-_0-9\.]+>)$/ was not matched in the output coming from the switch. You can try to run the snapshot in debug mode (see https://github.com/netfishers-onl/Netshot/wiki/Snapshot-troubleshooting) to identify the mismatch. Share the result if you want some help.

SCadilhac avatar Oct 10 '19 22:10 SCadilhac

Thank you very much SCadilhac! It helped me a lot. I then learned how to use regex tanks to this site:https://rubular.com/ and I have been abble to write my own script for HPE switches(I built it for the version 3208P03, not shure it will work for other versions. I share my driver if other people are interested to improve it. HPE switch 3208P03.zip

hemh avatar Oct 11 '19 18:10 hemh

Other question, why the HPE driver is not automatically selected when I had a HPE device, like for cisco device? Each time, it is the Generic SNMP that is used if I do not force the utilization of HPE driver

hemh avatar Oct 11 '19 18:10 hemh

@hemh, you need to customize the snmpAutoDiscover function with the sysObjectId and sysDesc values which identify any HPE device compatible with your driver.

SCadilhac avatar Oct 12 '19 10:10 SCadilhac

Thanks, autodiscover work now. If other people are intersted in improve the HPE driver, don't hesitate to contact me by MP.

hemh avatar Oct 15 '19 16:10 hemh

I am trying to use my driver on another HPE model (7900) and the driver is stocked, check the logs:

[ERROR] I/O error: Timeout waiting for the command output. [ERROR] I/O error: Read timed out [ERROR] Error while running snapshot using driver HPE SWITCH 7900: 'Error while waiting for a response from the device after command 'display current-configuration' in at line number 224 at column number 5'.

It is like the command in the following line is not issued : var currentConfig = cli.command("display current-configuration"); Any idea?

hemh avatar Oct 15 '19 20:10 hemh

Hi,

To bring more details about the above problem here are the netshot logs for a specific snapshot that doesn't work:

2019-10-17 13:16:38,290 ERROR [QuartzScheduler_Worker-1] TakeSnapshotTask: Error while taking the snapshot. javax.script.ScriptException: Error while waiting for a response from the device after command 'save force' in at line number 224 at column number 5 at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470) at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:392) at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:190) at onl.netfishers.netshot.device.script.SnapshotCliScript.run(SnapshotCliScript.java:92) at onl.netfishers.netshot.device.script.CliScript.connectRun(CliScript.java:339) at onl.netfishers.netshot.device.script.CliScript.connectRun(CliScript.java:194) at onl.netfishers.netshot.work.tasks.TakeSnapshotTask.run(TakeSnapshotTask.java:200) at onl.netfishers.netshot.work.TaskJob.execute(TaskJob.java:90) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) Caused by: jdk.nashorn.internal.runtime.ECMAException: Error while waiting for a response from the device after command 'save force' at jdk.nashorn.internal.runtime.ECMAException.create(ECMAException.java:113) at jdk.nashorn.internal.scripts.Script$Recompilation$17673$6172AA$^eval_._connect#command(:224) at jdk.nashorn.internal.scripts.Script$Recompilation$17574$3371AAA$^eval_.snapshot(:174) at jdk.nashorn.internal.scripts.Script$Recompilation$17669$795AAAA$^eval_._connect(:534) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:645) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199) at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:386) ... 8 common frames omitted

It is very weird, because my HPE driver work for about 50 devices and is not working for 10 other witch are of the same model, same version...I try to find out but I see no difference in the behaviour, what could cause this? And the most weir is that I can see in the switch logs that the command is issued, but Netshot seems unable to proccess the output.

hemh avatar Oct 17 '19 17:10 hemh

In both cases, the logs indicate a timeout after the passed command. In most cases:

  • There is a paging system on the device (e.g. the device displays --More-- and waits for a key to be pressed)
  • Or the device displays a confirmation message and waits for an answer
  • Or the prompt has changed after the command

You should look at the debugging logs to see the precise data sent by the device. Or share your code and the debugging logs to get some help.

SCadilhac avatar Oct 17 '19 20:10 SCadilhac

Thank you SCadilhac...Sorry for that, the problem was due to the fact that SSH prompt is different than TELNET prompt.

Here is the telnet prompt: login: login Password: <XXXSW1>

Here is the SSH prompt: login as: login [email protected]'s password:

But If I force to use telnet, The driver work.

I add my new driver version.

HPE switch 3208P03-v2.zip

hemh avatar Oct 18 '19 13:10 hemh

When using SSH, the username and login are not exposed to the script (authentication is handled directly at the SSH level), so you don't have to adjust username and password macros for SSH. Your password prompt doesn't look good as a regular expression even if it may work. Please provide a debug of the snapshot (https://github.com/netfishers-onl/Netshot/wiki/Snapshot-troubleshooting) if you want more help (for SSH only, or with a fake password for Telnet).

SCadilhac avatar Oct 18 '19 15:10 SCadilhac

So I change my password prompt.

Here is the debug file of a host that doesn't work: debug_2411.zip

Here is the driver updated HPE switch 3208P03-v2.zip

Here are the Netshol logs: [INFO] Snapshot task for device [NONAME] (172.19.1.3). [ERROR] Error while taking the snapshot: Error while waiting for a response from the device after command 'save force' in at line number 224 at column number 5 [ERROR] I/O error: Timeout waiting for the command output. [ERROR] I/O error: Read timed out [ERROR] Error while running snapshot using driver HPE SWITCH: 'Error while waiting for a response from the device after command 'save force' in at line number 224 at column number 5'.

Thank you very much for your help.

hemh avatar Oct 18 '19 17:10 hemh

Is this Telnet or SSH snapshot attempt?

SCadilhac avatar Oct 19 '19 10:10 SCadilhac

It is a telnet attempt,

hemh avatar Oct 19 '19 11:10 hemh

I can't see an exact correlation between the trace and the version of the driver you provided. Are you sure they match? I thought Telnet was OK. I shall try with a virtual Comware device.

SCadilhac avatar Oct 22 '19 22:10 SCadilhac

Hi Sylvain, my driver works well with HPE 5130, and HPE 5700 but no way to make it work with HPE FF 7910 and HPE 5120. I guess this is because of the history of HP(old mix of 3COM, Huawei and H3C) You can find a good history of the brand here: https://sites.google.com/site/jrbinks/code/rancid/h3c. But my main need is for the HP FF 7910, as this is our Core router, do you have a way to get the hand on a virtual version of that model?

hemh avatar Oct 23 '19 13:10 hemh

@hemh, I have no experience with HPE switches, I have no idea whether the virtual edition version would look to which of the versions you use, so I'm not willing to waste time on this. If you want more help, please provide the full login sequence (copy/paste from your preferred terminal when you connect manually) for each version in both Telnet and SSH.

SCadilhac avatar Oct 26 '19 21:10 SCadilhac

hpswitch.js.tar.gz

Hello,

I worked on this issue and have a bit of a working driver. Sort of used the example attached but it has been heavily modified.

It is able to pull hostname and config. Otherwise the script is a mess. Literally my first time in javascript.

I have tried to get snmp autodiscover working but it doesnt work. The OID there does give that result. It ought to always be that but it doesnt seem to pull.

tbiens avatar Feb 22 '21 17:02 tbiens

SNMP autodiscovery is pretty simple. Your script's snmpAutoDiscover function will get sysObjectID and sysDesc values, it must return true or false whether it supports the device or not. What is the result of snmpwalk -v2c -c [community] [IP of the device] 1.3.6.1.2.1.1 for your device?

SCadilhac avatar Feb 22 '21 18:02 SCadilhac

That's the difficulty I think. That OID doesn't exist for procurve switches.

Name/OID: system; Value (NoSuchObject): (Snmp No Such Object)

Though looking at it now.

ObjectID and Desc is following:

Name/OID: sysObjectID.0; Value (OID): .1.3.6.1.4.1.11.2.3.7.11.88

Name/OID: sysDescr.0; Value (OctetString): ProCurve J9279A Switch 2510G-24, revision Y.11.41, ROM N.10.02 (/sw/code/build/cod)

If I do the follow it just shows up as Generic SNMP device.

function snmpAutoDiscover(sysObjectID, sysDesc) { return sysObjectID.substring(0, 255) == ".1.3.6.1.4.1.11.2.3.7.11.88" && sysDesc.match(/ProCurve*/); }

tbiens avatar Feb 22 '21 19:02 tbiens

Hi, did you read this page: https://networkangle.com/rancid-for-hp-h3c-huawei-switches/

On Mon, Feb 22, 2021 at 2:08 PM tbiens [email protected] wrote:

That's the difficulty I think. That OID doesn't exist for procurve switches.

Name/OID: system; Value (NoSuchObject): (Snmp No Such Object)

Though looking at it now.

ObjectID and Desc is following:

Name/OID: sysObjectID.0; Value (OID): .1.3.6.1.4.1.11.2.3.7.11.88

Name/OID: sysDescr.0; Value (OctetString): ProCurve J9279A Switch 2510G-24, revision Y.11.41, ROM N.10.02 (/sw/code/build/cod)

If I do the follow it just shows up as Generic SNMP device.

function snmpAutoDiscover(sysObjectID, sysDesc) { return sysObjectID.substring(0, 255) == ".1.3.6.1.4.1.11.2.3.7.11.88" && sysDesc.match(/ProCurve*/); }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/netfishers-onl/Netshot/issues/54#issuecomment-783604043, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACI5EM6GMGCO6SNLSJGOMJTTAKTTFANCNFSM4I5GJJUQ .

hemh avatar Feb 22 '21 19:02 hemh

Name/OID: sysObjectID.0; Value (OID): .1.3.6.1.4.1.11.2.3.7.11.88 Name/OID: sysDescr.0; Value (OctetString): ProCurve J9279A Switch 2510G-24, revision Y.11.41, ROM N.10.02 (/sw/code/build/cod)

1.3.6.1.4.1.11.2.3.7.11.88 points to a specific model, hpSwitchJ9279A

function snmpAutoDiscover(sysObjectID, sysDesc) { return sysObjectID.substring(0, 255) == ".1.3.6.1.4.1.11.2.3.7.11.88" && sysDesc.match(/ProCurve*/); }

You may want to write something like:

function snmpAutoDiscover(sysObjectID, sysDesc) {
	return sysObjectID.substring(0, 24) == "1.3.6.1.4.1.11.2.3.7.11." && sysDesc.match(/ProCurve/);
}

SCadilhac avatar Feb 22 '21 21:02 SCadilhac

No luck with that. Still being detected as Generic SNMP Device.

tbiens avatar Feb 23 '21 14:02 tbiens