napalm-automation-community / napalm-fsos

FSOS Driver (for FS5800 and related products: see fs.com)
Apache License 2.0
3 stars 3 forks source link

Unable to push configuration #8

Closed raphis closed 1 year ago

raphis commented 1 year ago

Thanks for the great work for this plugin! Unfortunately I have a problem to push a config to the device - I get the following response from the JSON-API:

napalm -o json_rpc_port=8443,ssh_port=22 --user admin --vendor fsos 192.168.200.81 configure /mnt/c/tmp/startup-config.conf --strategy merge

{'jsonrpc': '2.0', 'id': 0, 'result': [{'sourceDetails': 'This operation will cause all the online HTTP(S) users to be offline.\nThis operation will cause all the online HTTP(S) users to be offline.\n% Error: duplicate domain\n% Error: duplicate name server\n% SNMP is already enabled\n% The community is already existent. \n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Cannot configure aggregator member\n% Port channel has already bound with mlag\n% Port channel has already bound with mlag\n% Port channel has already bound with mlag\nEnter configuration commands, one per line. End with CNTL/Z.\n'}]}

I wonder whether this is a specific problems with aggregates (was this ever tested and is supposed to work?) or if the switch is just not accepting the file.

I reverse-engineered the code a bit and noted that the copy-process is actually working, but afterwards activation fails.

My environment:

raphis commented 1 year ago

In the meantime I was able to drill down the issue, the problem is the

copy flash:/startup-config.conf running-config command which is sent via RPC. This command doesn't really work on our switches and brings the error above.

However what's partially working: doing a copy startup-config running-config command. The content is then actually copied into the flash:/running-config file but is not applied somehow. As this is a switch issue where I'm in touch with FS I'll close this issue again.

maxiestudies commented 1 year ago

Hi raphis,

The problem is a limitation of the FSOS. When you do a copy startup-config running-config', the switch doesn't replace the configuration atomically, but runs the file line by line, as if you were typing each line on the CLI. This is of course problematic as some commands will give an error if entered twice (e.g. you will see thisSNMP is already enabled` if you try to enable snmp twice. I have already spoken to their support about this and asked them to support atomic configuration replacements. Their reply was that if enough customers wanted this feature they might implement it, so it's worth contacting their support.

A possible workaround is to render your desired config and diff it with the current running config, and then programmatically calculate how to get from one to the other. For example, if your desired config has:

interface eth-0-7
 switchport access vlan 210
!

and the running config is

interface eth-0-7
 switchport access vlan 300
!

you would need to render:

interface eth-0-7
 no switchport access vlan
 switchport access vlan 300
!

This is the way frr reloads it's config with this script https://github.com/FRRouting/frr/blob/master/tools/frr-reload.py Be careful with this as the switch runs through the file line by line you might have some undesired states (even if for very short periods of time) that can break stuff.