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

Add support for Huawei VRP CLI #170

Merged
merged 1 commit into from
Jan 18, 2024
Merged

Conversation

wwijkander
Copy link
Contributor

@wwijkander wwijkander commented Jan 10, 2024

Add support for Huawei VRP CLI. A CLI session looks like this:

[wilwij@mira ~]$ ssh huawei-development-sw1.example.net

User Authentication
([email protected]) Password: 

Info: The max number of VTY users is 10, and the number
      of current VTY users on line is 1.
      The current login time is 2024-01-10 08:41:02+01:00.
<huawei-development-sw1>
<huawei-development-sw1>
<huawei-development-sw1>
<huawei-development-sw1>disp port vlan gig
<huawei-development-sw1>disp port vlan gi0/0/20
Port                        Link Type    PVID  Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/20       desirable    1     1-4094
<huawei-development-sw1>system-vi
Enter system view, return user view with Ctrl+Z.
[huawei-development-sw1]interface gi0/0/20
[huawei-development-sw1-GigabitEthernet0/0/20]?
gigabitethernet-l2 interface view commands:
  als                        Set automatic laser shutdown 
  am                         Unidirectional isolation
  arp                        Address Resolution Protocol
  arp-fake                   ARP fake entry
  arp-limit                  Limit the number of learnt ARP
  arp-miss                   ARP Miss
  authentication             Authentication
  auto                       Auto negotiates port mode 
  bandwidth                  Specify mib-referenced bandwidth of the interface
  broadcast-suppression      Set broadcast flow suppression
  carrier                    Set carrier function
  cfm                        Connectivity fault management
  clear                      Clear
  collect                    Collect TOPN information
  combo-port                 Set combo type 
  configuration              Configuration interlock
  dei                        Specify dei as drop precedence 
  description                Specify interface description
  dhcp                       Dynamic host configure protocol
  dhcpv6                     Dynamic host configure protocol for IPv6
  display                    Display current system information
  dldp                       Device link detection protocol
  dot1x                      802.1x and mac-authen configuration information
  duplex                     Configure duplex operation mode 
                                          

[huawei-development-sw1-GigabitEthernet0/0/20]quit
[huawei-development-sw1]quit
<huawei-development-sw1>disp port gi0/0/40
                                  ^
Error: Unrecognized command found at '^' position.
<huawei-development-sw1>quit
Info: The max number of VTY users is 10, and the number
      of current VTY users on line is 0.Connection to huawei-development-sw1.example.net closed.

@@ -37,7 +37,7 @@ var (

func getPromptPattern() *regexp.Regexp {
promptPatternOnce.Do(func() {
promptPattern = regexp.MustCompile(`(?im)^[a-z\d.\-@()/:]{1,48}[#>$]\s*$`)
promptPattern = regexp.MustCompile(`(?im)^<*[a-z\d.\-@()/:]{1,48}[#>$]\s*$`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, im guessing this is since we would fail to match in authenticate step without the < char? I think we "should" be using the combined pattern from the network driver before open/auth in the channel happens. on driver creation here we should be basically joining all the priv levels into one big pattern and setting that on the channel. is this not happening/working right?

if its not working right id like to fix that and then nix adding the < here just since this pattern hasn't otherwise changed in a long time (going back to scrapli python early days).

as an aside this pattern is terribly inefficient (the way I set it up, nothing you did!)... but thats a problem for another day...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, forgot to mention this change, but this is in order to get the generic driver working, without it it just times out waiting for a prompt that never matches since the huawei prompt has a < in the beginning and not just a > at the end of the prompt.

That said I only really used the generic driver at first before making a driver for VRP so I'm ok with removing it too!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, yeah that makes sense! lets go ahead and remove this and the extra commented stuff in the platform and we'll get it merged! I can do that this weekend if ya don't get to it before me!

@carlmontanari
Copy link
Contributor

👋 hey @wwijkander thanks for the work here! looks good to me - just left a few little comments to discuss then we can get it all merged! thanks a bunch!

@carlmontanari
Copy link
Contributor

ah seems I can't push to your pr for whatever reason -- so if you wanna get those comments cleared out and revert that base pattern stuff like discussed whenever ya have a sec ill get this merged. have a nice weekend!

@wwijkander
Copy link
Contributor Author

ah seems I can't push to your pr for whatever reason -- so if you wanna get those comments cleared out and revert that base pattern stuff like discussed whenever ya have a sec ill get this merged. have a nice weekend!

Hope you had a good weekend! I kind of lost this in other stuff but I pushed a new commit now. Left the comments about the error message as it might look like a typo otherwise.

Cheers!

textfsm-platform: 'huawei_vrp' # ignored in go because no ntc-templates
network-on-open:
- operation: 'acquire-priv' # targets default desired priv by default
# - operation: 'driver.send-command'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we get rid of these commented lines, looks like they're not necessary?

@@ -37,7 +37,7 @@ var (

func getPromptPattern() *regexp.Regexp {
promptPatternOnce.Do(func() {
promptPattern = regexp.MustCompile(`(?im)^[a-z\d.\-@()/:]{1,48}[#>$]\s*$`)
promptPattern = regexp.MustCompile(`(?im)^<*[a-z\d.\-@()/:]{1,48}[#>$]\s*$`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, yeah that makes sense! lets go ahead and remove this and the extra commented stuff in the platform and we'll get it merged! I can do that this weekend if ya don't get to it before me!

@carlmontanari carlmontanari merged commit c788416 into scrapli:main Jan 18, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants