netutils icon indicating copy to clipboard operation
netutils copied to clipboard

Future Parser Support List

Open jeffkala opened this issue 4 years ago • 7 comments

List of Parser that should be created.

  • [x] IOS-XR
  • [x] Aruba
  • [ ] Checkpoint
  • [ ] A10
  • [x] NetScaler
  • [ ] Netscreen
  • [ ] Palo Alto
  • [ ] Huawei

jeffkala avatar Dec 09 '21 21:12 jeffkala

A few more to add: -Moved to top comment-

jdrew82 avatar Jun 16 '22 17:06 jdrew82

Any updates on Huawei parser?

Huawei config is a BaseSpaceConfigParser with:

  • comment_chars as #
  • banner_start as header login information
  • A banner starts and ends with "

A one-line banner:

[device]header login information "My one-line banner"

A multi-line banner:

[device]header login information "
The banner text supports 480 characters max, including the start and the end character.If you want to enter more than this, use banner file instead.Input banner text, and quit with the character '"':
==============================
My multi-line banner
==============================
"

A sample config file:

#
interface GigabitEthernet0/0/4
 undo portswitch
 undo shutdown
 l2 binding vsi CUST
#
interface GigabitEthernet0/0/5
 undo portswitch
 undo shutdown
 l2 binding vsi CUST
#
bgp 34177
 router-id 1.1.1.1
 ipv4-family vpn-instance ADMIN
  import-route static
#
header login information "==============================
My multi-line banner
==============================
"
#

Is this enough for you to implement it, or do you prefer a PR?

Thanks!

angely-dev avatar Sep 05 '23 07:09 angely-dev

PR would be best, can see some hints here: https://netutils.readthedocs.io/en/latest/dev/dev_config/#new-parsers

itdependsnetworks avatar Sep 05 '23 11:09 itdependsnetworks

Thanks @itdependsnetworks.

So using this simple snippet:

# netutils/config/parser.py

class HuaweiVRPConfigParser(BaseSpaceConfigParser):
    """Huawei VRP implementation of ConfigParser Class."""

    comment_chars: t.List[str] = ["#"]
    banner_start = ["header login information"]
    banner_end = '"'

I got this diff output:

interface GigabitEthernet0/0/2
 l2 binding vsi CUST
header login information "==================================================
my multi-line banner
==================================================^C

The banner end delimiter " gets replaced by ^C. It is done by the generic space config parser #L215. Is this normal behavior? I can override the _build_banner method but I doubt this is the guideline.

angely-dev avatar Sep 05 '23 13:09 angely-dev

I do not know know, what is banner end meant to be? you show an output (not the original) that would make it seem like ^C is the proper end, but not really clear to me.

itdependsnetworks avatar Sep 05 '23 16:09 itdependsnetworks

Sorry, that wasn't so clear. The original command is:

header login information "==================================================
my multi-line banner
=================================================="

The last " denotes the end of the banner. When I call diff_network_config, I got the previous output:

header login information "==================================================
my multi-line banner
==================================================^C

The last " gets replaced by ^C by _build_banner.normalise_delimiter_caret_c which is part of the BaseSpaceConfigParser. So this is made on purpose obviously but I don't know why.

angely-dev avatar Sep 05 '23 17:09 angely-dev

Probably best to ask on slack, so can be a bit more real time in convo.

itdependsnetworks avatar Sep 05 '23 20:09 itdependsnetworks