napalm-automation-community / napalm-fsos-ssh

SSH-based driver for FSOS (related products: see fs.com)
Other
1 stars 3 forks source link

Implement FSOS devicetype #17

Closed M0NsTeRRR closed 5 months ago

M0NsTeRRR commented 1 year ago

Create FSOS device type in netmiko library to replace cisco_ios implementation to fix terminal width <value> unknown command. Netmiko session log


      CLI session with the S3900-24T4S is opened.
      To end the CLI session, enter [Exit].

SW2-1#
SW2-1#terminal width 511
                     ^
% Invalid parameter value/range input detected at '^' marker.
SW2-1#terminal length 0
SW2-1#
SW2-1#
SW2-1#show system
 System Up Time         : 7 days, 10 hours, 32 minutes, and 47.15 seconds
 System Name            : SW2
 System Location        : Rack
 System Contact         : admin@example.com
 MAC Address (Unit 1)   : 64-9D-99-10-08-58
 System OID String  : 1.3.6.1.4.1.52642.2.1.45.101
 http Server        : Disabled
 http Server Port   : 80
 https Server       : Disabled
 https Server Port  : 443
 Telnet Server      : Disabled
 Telnet Server Port : 23

System Temperature:
-----------------------------------------------------------------
unit 1     Temperature 1:  54 degrees    

System Power status:
-----------------------------------------------------------------
 Unit 1     Main Power Status      : Up
SW2-1#
SW2-1#show memory

 Total  Memory:    536870912 bytes
 Used  Memory:     316882944 bytes
 Used  percent:    60%

 Generate Trap alarm threshold:    90%
 Clear Trap alarm threshold     :    70%

SW2-1#
M0NsTeRRR commented 1 year ago

Hello @adn77

I will prepare fsos device type for v2, can you tell me if :

Regards,

adn77 commented 1 year ago

Thanks again for all your support! I believe it's worth it as there are quite a few devices running FSOS 2.x.y ๐Ÿ™‚

M0NsTeRRR commented 1 year ago

Thanks you, when you set an hostname with 40 characters does your prompt is truncated like mysuperlonghostname# to mysuperlong# ?

Can you give me an output example with a long and short hostname ?

adn77 commented 1 year ago

No, the prompt is always prefixed with the max. 40 character hostname. The actual command is truncated to show only the remaining characters (totalling max. 78)

M0NsTeRRR commented 1 year ago

Okay does terminal width 256 display 256 chars max in the terminal ?

adn77 commented 1 year ago

The only command I was able to verify this with is show core-dump which actually prints lines longer than 256 chars, broken to the next line.

M0NsTeRRR commented 1 year ago

Okay we should be fine so

adn77 commented 1 year ago

I don't know if I understand the PR correctly, at least the command for saving the config is not Cisco like, but simply write instead....

M0NsTeRRR commented 1 year ago

On v1 it's copy run start and you need to put the filename instead of a confirmation. On v2 how does it works ? You simply write write and that's all ? No confirmation ?

adn77 commented 1 year ago

yes it's write unless you want to save special types of configs:

fs02#write ?
  all          -- Save all configuration file
  bvss-config  -- Save current bvss configuration
  ifindex      -- Save current ifindex
  vos-config   -- Save current vos configuration
  <cr>
fs02#write
Saving current configuration...
OK!
fs02#

Configuration mode is entered via config. The prompt will always be hostname_config.*#, e.g.

fs02#config
fs02_config#int gigaEthernet0/1
fs02_config_g0/1#

This is the CLI guide: https://resource.fs.com/mall/doc/20230214154759x25y4r.pdf

I am sorry to bother you with those details.

M0NsTeRRR commented 1 year ago

Thanks you, no it's fine don't worry thanks for your feedback. Can you provide me show version output to add ssh detection ?

adn77 commented 1 year ago

Looks like terminal length and terminal width only work AFTER enable - that's why my show interface brief never returns - it's waiting while paginating ๐Ÿ˜†

The show version can also be seen in this output:

                 Welcome to FS S3900-48T6S-R Ethernet Switch

fs01>
fs01>terminal width 511
terminal width 511
^
Unknown command
fs01>terminal length 0
terminal length 0
^
Unknown command
fs01>
fs01>
fs01>enable
fs01#
fs01#
fs01#
fs01#
fs01#show version
Fiberstore Co., Limited Internetwork Operating System Software
S3900-48T6S-R Series Software, Version 2.2.0F Build 107821, RELEASE SOFTWARE
Copyright (c) 2021 by FS.COM All Rights Reserved
Compiled: 2022-12-22 9:40:43 by SYS, Image text-base: 0x80010000
ROM: System Bootstrap, Version 0.1.9,hardware version:A
Serial num:CG2206232992Nxxxxx, ID num:0020083905324
System image file is "Switch.bin"
FS S3900-48T6S-R RISC
524288K bytes of memory,16384K bytes of flash
Base ethernet MAC Address: 64:9d:99:xx:yy:zz
PCB version:J
snmp info:
  vend_ID:52642   product_ID:2039   system_ID:1.3.6.1.4.1.52642.1.2039.0
fs01 uptime is 19:11:58:47, The current time: 2023-2-27 20:33:53
 Reboot history information:
  No. 1: System is rebooted by power-on
fs01#
M0NsTeRRR commented 1 year ago

Oh okay good to know i will update this :) thanks for your feedback

adn77 commented 1 year ago

@M0NsTeRRR how would I test your Netmiko PR?

M0NsTeRRR commented 1 year ago

Hello,

Sorry for the late reply. You can clone my work https://github.com/M0NsTeRRR/netmiko, install poetry, install dependencies with poetry and build the package. You will get a dist folder with a .whl. On your project force the reinstallation of netmiko library with my custom one with pip install netmiko-4.1.3-py3-none-any.whl --force-reinstall After that you can test it by changing self.device_type to fsos_v2. Warning for this driver enable mode is required due to terminal width command.

M0NsTeRRR commented 1 year ago

Hello @adn77,

Waiting your feedback before asking a review for my netmiko PR :)

Regards,

adn77 commented 1 year ago

Sorry for taking sooo long. What can I say - it works :)

                 Welcome to FS S3900-48T6S-R Ethernet Switch

fs01>
fs01>
fs01>
fs01>enable
fs01#
fs01#terminal width 256
fs01#terminal length 0
fs01#
fs01#
fs01#
fs01#show version
Fiberstore Co., Limited Internetwork Operating System Software
S3900-48T6S-R Series Software, Version 2.2.0F Build 107821, RELEASE SOFTWARE
Copyright (c) 2021 by FS.COM All Rights Reserved
Compiled: 2022-12-22 9:40:43 by SYS, Image text-base: 0x80010000
ROM: System Bootstrap, Version 0.1.9,hardware version:A
Serial num:CG2206232992Nxxxxx, ID num:0020083905324
System image file is "Switch.bin"
FS S3900-48T6S-R RISC
524288K bytes of memory,16384K bytes of flash
Base ethernet MAC Address: 64:9d:99:xx:yy:zz
PCB version:J
snmp info:
  vend_ID:52642   product_ID:2039   system_ID:1.3.6.1.4.1.52642.1.2039.0
fs01 uptime is 62:09:30:24, The current time: 2023-4-11 18:20:8
 Reboot history information:
  No. 1: System is rebooted by power-on
fs01#
fs01#
fs01#show interface brief
Port    Description           Status    Vlan        Duplex   Speed    Type
g0/1                          down      1           auto     auto     Giga-TX
g0/2                          down      1           auto     auto     Giga-TX
...
g0/47                         down      1           auto     auto     Giga-TX
g0/48                         down      1           auto     auto     Giga-TX
tg0/49                        down      1           full     10000Mb  10Giga-FX
tg0/50                        up        1           full     10000Mb  10Giga-FX-SFP
tg0/51                        down      1           full     10000Mb  10Giga-FX
tg0/52                        down      1           full     10000Mb  10Giga-FX
tg0/53                        down      1           full     10000Mb  10Giga-FX
tg0/54                        down      1           full     10000Mb  10Giga-FX
v1                            up
n0                            up
fs01#
fs01#exit

Looks like the netmiko PR is good to go! Thanks for pursuing this.

Alex

M0NsTeRRR commented 1 year ago

No problem thanks for your feedback :)

adn77 commented 10 months ago

Does this look familiar? https://resource.fs.com/mall/doc/202309041627276v45dm.zip

Maybe you want to ask them to provide you a free sample ๐Ÿ˜‰

M0NsTeRRR commented 10 months ago

Oh didn'see that. No it doesn't look to be a copy/paste and it's really bad code but you can't expect much from them. Thanks for the notification also I will remind netmiko maintainer if they can work on our PR.

adn77 commented 10 months ago

I finally got some time today to have a deeper look at the driver. I am familiar with Ansible but not with Napalm.

Today I managed to execute a cli call but I had to concate the entire command in string with \n linebreaks.

As far as I understood, your driver implements all Napalm methods and overloads the ones not matching pre-defined IOS commands?! How far does this get you? I imagine for proper automation one would rely on config backup/restore based on Jinja2 templates instead of implementing every possible command?

M0NsTeRRR commented 10 months ago

Yes i've implemented all napalm driver methods (if I didnt miss one) as documented here. My driver doesnt depend on other drivers. I've created this driver for an homelab purpose I love automation and I've a FS switch. At my current work (Telecom operator) we use enterprise software like Cisco NSO and I'm developping services on top of it. For backup you could rely on Oxidized/Rancid (I don't know if it works with fs switch, it's in my to do list). Of course you could rely on ansible and jinja templating to update your configuration, you could also tell the device to boot with a minimal configuration that allow to get the full configuration on a HTTP server. Some people have stored theirs configurations in Netbox too (you can find some examples on google). There is many possibilities :)

M0NsTeRRR commented 5 months ago

Hello @adn77, I've you been able to create your driver ? If yes would you like to post it under napalm-automation-community to know if I ask maintainer again for a new repo. Regards,

adn77 commented 5 months ago

To be honest I fell back to using ssh with "expect" ๐Ÿ˜ฆ

I only came to NAPALM because of it being mentioned as a Netbox plugin. I don't know what people are doing with it, but my requirements are rather basic, such as configuring port channel on uplink interfaces and assigning trunk/access ports with their respective VLANs.

We have about 30 of these devices (all documented in Netbox)... I feel embarrassed to ask, could you give me some pointers as to how I would make actual use of NAPALM here? Do I have to template out the entire config using Jinja and would I only use the cli command in NAPALM for uploading of the config?

Maybe this is the piece of information missing in my puzzle... hopefully this will get my motivation back to focus on finishing the driver.

Thanks as always! Alex

M0NsTeRRR commented 5 months ago

Hello,

Thanks for your feedback. Regarding netbox you have an example in the documentation. It's used for fetching operational data : https://demo.netbox.dev/static/docs/additional-features/napalm/ Napalm just give you an abstract layer. For example if you want to get a VLAN on a switch without be worried about vendor. For configuration purpose it remains limited.

I will close the issue, we can still discuss here :)