@@ -664,7 +664,9 @@ def show_counters(raw: bool, intf_name: typing.Optional[str],
664
664
return _show_raw (data , intf_name )
665
665
return _format_show_counters (data )
666
666
667
- def show_vlan_to_vni (raw : bool , intf_name : typing .Optional [str ], vid : typing .Optional [str ], detail : bool ):
667
+ def show_vlan_to_vni (raw : bool , intf_name : typing .Optional [str ],
668
+ vid : typing .Optional [str ], detail : bool ,
669
+ statistics : bool ):
668
670
if not interface_exists (intf_name ):
669
671
raise vyos .opmode .UnconfiguredObject (f"Interface { intf_name } does not exist\n " )
670
672
@@ -696,6 +698,14 @@ def show_vlan_to_vni(raw: bool, intf_name: typing.Optional[str], vid: typing.Opt
696
698
vlan_id = str (vlan .get ("vid" ))
697
699
description = mapping_config .get (vlan_id , {}).get ("description" , "" )
698
700
701
+ # detail allows for longer descriptions; each output wraps to 80 characters
702
+ if detail :
703
+ description = "\n " .join (textwrap .wrap (description , width = 65 ))
704
+ elif raw :
705
+ pass
706
+ else :
707
+ description = "\n " .join (textwrap .wrap (description , width = 48 ))
708
+
699
709
if raw :
700
710
tunnel_dict ["vlan" ] = vlan_id
701
711
tunnel_dict ["rx_bytes" ] = vlan .get ("rx_bytes" )
@@ -709,22 +719,26 @@ def show_vlan_to_vni(raw: bool, intf_name: typing.Optional[str], vid: typing.Opt
709
719
* ([intf_name ] if not detail else []),
710
720
vlan_id ,
711
721
tunnel_id ,
712
- description ,
713
- * ([vlan .get ("rx_bytes " )] if detail else []),
714
- * ([vlan .get ("tx_bytes " )] if detail else []),
715
- * ([vlan .get ("rx_packets " )] if detail else []),
716
- * ([vlan .get ("tx_packets " )] if detail else [])
722
+ * ([ description ] if not statistics else []) ,
723
+ * ([vlan .get ("rx_packets " )] if any ([ detail , statistics ]) else []),
724
+ * ([vlan .get ("rx_bytes " )] if any ([ detail , statistics ]) else []),
725
+ * ([vlan .get ("tx_packets " )] if any ([ detail , statistics ]) else []),
726
+ * ([vlan .get ("tx_bytes " )] if any ([ detail , statistics ]) else [])
717
727
])
718
728
719
729
if raw :
720
730
return raw_data
721
731
722
732
if detail :
723
733
# Detail headers; ex. show interfaces vxlan vxlan1 vlan-to-vni detail
724
- detail_header = ['VLAN' , 'VNI' , 'Description' , 'Rx Bytes ' , 'Tx Bytes' , 'Rx Packets' , 'Tx Packets ' ]
734
+ detail_header = ['VLAN' , 'VNI' , 'Description' , 'Rx Packets ' , 'Rx Bytes' , 'Tx Packets' , 'Tx Bytes ' ]
725
735
print ('-' * 35 )
726
736
print (f"Interface: { intf_name } \n " )
727
737
detailed_output (output_list , detail_header )
738
+ elif statistics :
739
+ # Statistics headers; ex. show interfaces vxlan vxlan1 vlan-to-vni statistics
740
+ headers = ['Interface' , 'VLAN' , 'VNI' , 'Rx Packets' , 'Rx Bytes' , 'Tx Packets' , 'Tx Bytes' ]
741
+ print (tabulate (output_list , headers ))
728
742
else :
729
743
# Normal headers; ex. show interfaces vxlan vxlan1 vlan-to-vni
730
744
headers = ['Interface' , 'VLAN' , 'VNI' , 'Description' ]
0 commit comments