Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Cisco to Juniper - parser help

by jamescmatt (Novice)
on May 24, 2021 at 13:26 UTC ( [id://11132963]=note: print w/replies, xml ) Need Help??


in reply to Re: Cisco to Juniper - parser help
in thread Cisco to Juniper - parser help

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).

Replies are listed 'Best First'.
Re^3: Cisco to Juniper - parser help
by LanX (Saint) on May 24, 2021 at 13:30 UTC
    > 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.

Re^3: Cisco to Juniper - parser help
by LanX (Saint) on May 24, 2021 at 13:57 UTC
    > 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).
        I don't think I know enough about those tools to help you, and you don't understand my questions.

        Your code is also very hard to read for me.

        A general solution is to parse your tree data into a nested array of hashes and to traverse that to output your new format.

        But I don't know if that's really necessary because I don't understand the data.

        I hope someone with deeper knowledge of your domain will pass by and can help you. :)

        update

        see also

        Re: Cisco to Juniper - parser help

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2024-04-18 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found