pyroute2
pyroute2 copied to clipboard
fetch bond data
When I use
ipdb = IPDB()
interfaces = ipdb.interfaces
I can't get data about bond from interfaces, such as bond mode, so I add this in ipdb/interface.py in line 270
if kind == 'bond':
data = linkinfo.get_attr('IFLA_INFO_DATA')
self['bond_mode'] = data.get_attr('IFLA_BOND_MODE')
Is this the right way to do that?
Which IPDB version do you use?
Since it supports all these attributes now:
In [34]: [x for x in ipdb.interfaces['bond0'].keys() if x.startswith('bond')]
Out[34]:
['bond_ad_actor_sys_prio',
'bond_arp_interval',
'bond_lp_interval',
'bond_downdelay',
'bond_ad_user_port_key',
'bond_ad_info',
'bond_updelay',
'bond_use_carrier',
'bond_primary',
'bond_unspec',
'bond_num_peer_notif',
'bond_ad_lacp_rate',
'bond_all_slaves_active',
'bond_packets_per_slave',
'bond_primary_reselect',
'bond_fail_over_mac',
'bond_xmit_hash_policy',
'bond_ad_select',
'bond_min_links',
'bond_tlb_dynamic_lb',
'bond_ad_actor_system',
'bond_miimon',
'bond_arp_all_targets',
'bond_active_slave',
'bond_resend_igmp',
'bond_arp_ip_target',
'bond_mode',
'bond_arp_validate']
In [35]: ipdb.interfaces['bond0']['bond_mode']
Out[35]: 0
In [36]: ipdb.interfaces['bond0']['bond_use_carrier']
Out[36]: 1