View Only


This community is currently under full moderation, meaning  all posts will be reviewed before appearing in the community. Please expect a brief delay—there is no need to post multiple times. If your post is rejected, you'll receive an email outlining the reason(s). We've implemented full moderation to control spam. Thank you for your patience and participation.

  • 1.  PyEZ table with duplicate fields

    Posted 09-16-2015 23:33

    Hi all,


    I'm trying to figure out how to create a YAML table for the output of "show multicast route" which can have multiple duplicate fields for the downstream interface. For e.g.


    <rpc-reply xmlns:junos="">
        <multicast-route-information xmlns="">
                <multicast-route junos:style="brief">

    The field <downstream-interface-names> has multiple <interface-name>. Just wondering how I can create the YAML table for this.





  • 2.  RE: PyEZ table with duplicate fields

    Posted 09-17-2015 01:21



    The documentation is difficult to understand how to do this, I did however do exactly what you are trying to achieve.


    The old techwiki looks to have been migrated to the forum here;



    The wiki is the documentation that I used to figure it out.


    My exmaple on an SRX is for the sessions table;


    get-flow-session-information <- RPC

    Within <flow-session-information> there are multiple <flow-session> records with two <flow-information> records




        <flow-session-information xmlns="">
            <flow-session junos:style="brief">
                <flow-information junos:style="brief">
                <flow-information junos:style="brief">

    The YAML file for this is


      rpc: get-flow-session-information
      item: flow-session
      key: session-identifier
      view: FlowSessView
        id: session-identifier
        app: application-name
        policy: policy
        state: sess-state
        flow: _rspTable
      item: flow-information
      key: direction
      view: _rspView
        dir: direction
        src: source-address
        src_port: source-port
        dst: destination-address
        dst_port: destination-port
        proto: protocol
        int: interface-name
        pkt: pkt-cnt
        byte: byte-cnt

    The code to access the data


    catalog = loadyaml('flowsess.yml')
    flows = catalog['FlowSessTable'](dev).get()

    for flow in flows: print "+ id:{:<10} Policy:{:<30}".format(, for item in flow.flow: print "+ Direction:{:<4} - src:{:<16} -> dst:{:<16} protocol:{:<5} +" .format(item.dir, item.src, item.dst, item.proto)

    You can see that I have accessed the FlowSessTable and then create the first iterator to view the <flow-session> records and another iterator to view both <flow-information> records per session.



  • 3.  RE: PyEZ table with duplicate fields

    Posted 09-17-2015 03:13

    Hi Tim,


    Thanks for your reply. I've not tried it out yet, but I see that my case is slightly different from yours. For my case, the <interface-name> which are duplicates and these are the "fields" and not an "item" (like <downstream-interface-names>) :-





  • 4.  RE: PyEZ table with duplicate fields

    Posted 09-17-2015 03:47



    I see what you are referring too now. I have found another xml structure with duplicates.



    I will try on my system.



  • 5.  RE: PyEZ table with duplicate fields
    Best Answer

    Posted 09-17-2015 16:32



    I tested this and confirmed that the duplicates can be model in YAML as a single entry. When you access the field in python it will return a list of values.


      ds-if: interface-name 

    When you access ds-if it would contain


    ['xe-4/0/0.3', 'ae6.5']

    Then you just need to iterate through the list to access each text field 🙂


    Let me know if you need anymore help.





  • 6.  RE: PyEZ table with duplicate fields

    Posted 09-17-2015 20:56

    Hi Tim,


    Thanks for your help with this. I've not coded it yet but since you have tested it, I'm sure it'll work.



  • 7.  RE: PyEZ table with duplicate fields

    Posted 09-17-2015 23:11

    For those interested, here's the YAML table I ended up with :-


        rpc: get-multicast-route-information
            - multicast-group-address
            - multicast-source-address
        item: route-family/multicast-route
        view: MulticastView
           group_add: multicast-group-address
           source_add: multicast-source-address
           upstream_int: upstream-interface-name
           downstream_int: downstream-interface-names/interface-name


    As Tim mentioned above, the "downstream_int" is a string when there is no duplicate and will be a list when there are multiple entries.



  • 8.  RE: PyEZ table with duplicate fields

    Posted 09-18-2015 06:39

    Thanks for sharing your working results.  

    More examples is always better.