Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Cisco to Juniper - parser help

by LanX (Saint)
on May 24, 2021 at 13:09 UTC ( [id://11132961]=note: print w/replies, xml ) Need Help??


in reply to Cisco to Juniper - parser help

Does this mtu info belong to the previous line or is it independent, i.e. does indentation matter?

xconnect 192.168.51.21 838969736 encapsulation mpls mtu 9202
edit:

do you need to have read all services before you can start the output, or can you write directly for each service ?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Cisco to Juniper - parser help
by jamescmatt (Novice) on May 24, 2021 at 13:26 UTC
    the MTU is a part of the above line, and is the last line for each service instance. But in this case, I am not using it at all, since my default MTU on the Juniper is already configured. It doesnt matter how it reads/writes, as long as the output is coherent ( I am outputting it this way because I can generally keep the new interface configuration/l2circuits in order).
      > It doesnt matter how it reads/writes, as long as the output is coherent

      Sorry I don't know what that means. °

      Can you output each service independently or do you need to know all the data before writing?

      Update

      My approach would be using a flip-flop operator to read each service and to output at the end.

      Each line would be processed by a dedicated subroutine based on the first word.

      Like service::description() and so on.

      This would make your code far more readable and easier to maintain.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      °) I can help you with Perl, but not with Cisco or Juniper, sorry.

      > the MTU is a part of the above line,

      does it mean

      • it's a continuation of the previous line indicated by the extra indentation
      • it's nested information, and this cisco format has to be parsed like a tree
      ?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        service instance 20 ethernet description Internal site encapsulation dot1q 17 rewrite ingress tag pop 1 symmetric xconnect 192.168.51.20 838969735 encapsulation mpls mtu 9202 !
        The above is exactly the configuration for each service instance. The extra indentation for the MTU is because the MTU is being applied to the configuration of the xconnect (xconnect being nested under service instance, mtu nested under xconnect). Hope that helps. edit: forgot a /
        Yes, the xconnect is nested under the service instance(directly configured under the service instance), and the MTU is nested under the xconnect(directly configured under the xconnect).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found