Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

Cutom YML for QoS

[ Edited ]
‎12-11-2017 12:03 PM

I'm attempting to tack on to the existing YAML table to pull some additional information from the EthPortTable (i've bolded my additions):

 

yaml_data="""
---
EthPortTable:
  rpc: get-interface-information
  args:
    media: True
    interface_name: '[afgxe][et]-*' 
  args_key: interface_name
  item: physical-interface
  view: EthPortView

EthPortView:
  groups:
    mac_stats: ethernet-mac-statistics
    queue_stats: queue-counters
    flags: if-device-flags
  fields:
    oper: oper-status
    admin: admin-status
    description: description
    mtu: { mtu : int }
    link_mode: link-mode
    macaddr: current-physical-address
  fields_mac_stats:
    rx_bytes: input-bytes
    rx_packets: input-packets
    tx_bytes: output-bytes
    tx_packets: output-packets
  fields_queue_stats:
    queue_name: forwarding-class-name
    queue_tx: queue-counters-trans-packets
    queue_drop: queue-counters-total-drop-packets
  fields_flags:
    running: { ifdf-running: flag }
present: { ifdf-present: flag }

I'm trying to get a good way to be able to pull queue information for an interface as I'm trying to do some tracking for it.  The only problem is that it doesn't appear to pull the information I'm tyring to get.

 

Relevent part of the script:

 

globals().update(FactoryLoader().load(yaml.load(yaml_data)))
cos = EthPortTable(dev).get()

for item in cos:
    print("{}: " .format(item.name))
    print("Queue: {} Sent / Dropped: {} / {} " .format(item.queue_name, item.queue_tx, item.queue_drop))

dev.close()

It however, doesn't pull said info:

 

et-0/0/0: 
Queue: None Sent / Dropped: None / None 
et-0/0/2: 
Queue: None Sent / Dropped: None / None 

Any thoughts or suggestions as where I'm steering wrong?

 

Thanks!

 

EDIT =============

 

So, I was able to finally get the YAML worked out so that it pulls the queue, but it appears to only pull the first queue and I can't seem to get it to itterate through each queue.

 

---
PhyPortTable:
  rpc: get-interface-information
  args:
    interface_name: '[efgx][et]-*'
  args_key: interface_name
  item: physical-interface
  view: PhyPortView

PhyPortView:
  fields:
    oper : oper-status
    admin : admin-status
    description: description
    mtu: { mtu : int }
    link_mode: link-mode
    speed: speed
    macaddr: current-physical-address
    flapped: interface-flapped

## --------
## Get CoS
## --------

PortCosTable:
  rpc: get-interface-information
  args:
    extensive: True
    interface_name: '[efgx][et]-*'
  args_key: interface_name
  item: physical-interface
  view: CosTableView

CosTableView:
  groups:
   queues: queue-counters/queue
  
  fields_queues:
    queue_name: forwarding-class-name
    queue_queue: { queue-counters-queued-packets: int }
    queue_tx: {queue-counters-trans-packets: int }
    queue_drop: {queue-counters-total-drop-packets: int }
"""

And my output:

et-0/0/0: 
Queue: best-effort Sent: 8743 Dropped: 0 
et-0/0/2: 
Queue: best-effort Sent: 2230 Dropped: 0 
et-0/0/3: 
Queue: best-effort Sent: 1308 Dropped: 0 

The hunt contintues...