Hi,
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;
http://forums.juniper.net/t5/Automation-Scripting/Junos-PyEZ/ta-p/280496
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
ie
<flow-session-information xmlns="http://xml.juniper.net/junos/12.1X46/junos-flow">
<flow-session junos:style="brief">
<session-identifier>821</session-identifier>
<flow-information junos:style="brief">
<direction>In</direction>
</flow-information>
<flow-information junos:style="brief">
<direction>Out</direction>
</flow-information>
</flow-session>
The YAML file for this is
---
FlowSessTable:
rpc: get-flow-session-information
item: flow-session
key: session-identifier
view: FlowSessView
FlowSessView:
fields:
id: session-identifier
app: application-name
policy: policy
state: sess-state
flow: _rspTable
_rspTable:
item: flow-information
key: direction
view: _rspView
_rspView:
fields:
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(flow.id, flow.app)
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.
Tim