def add(event, ifaces): print("add interface %s" % (event['dev'])) if not ifaces.has_key(event['index']): ifaces['by-name'][event['dev']] = ifaces[ event['index']] = interface(event) else: print("already exists, skippin'")
def add(event, ifaces): print("add interface %s" % (event["dev"])) if not ifaces.has_key(event["index"]): ifaces["by-name"][event["dev"]] = ifaces[event["index"]] = interface(event) else: print("already exists, skippin'")
#!/usr/bin/env python from __future__ import print_function from cxnet.netlink.iproute2 import iproute2 from ip_playback import sync from ip_interface import interface from time import sleep from pprint import pprint # # startup: init objects # print("8<-------------------- init") ifaces = dict([(x['index'], interface(x)) for x in iproute2.get_all_links()]) [ifaces[x['index']]['addresses'].append(x) for x in iproute2.get_all_addrs()] print("8<-------------------- init results") [print(x) for x in ifaces.items()] # # playback log records # print("8<-------------------- sleep") sleep(20) print("8<-------------------- log playback") sync(ifaces) print("8<-------------------- playback results") pprint(ifaces) # # results #
#!/usr/bin/env python from __future__ import print_function from cxnet.netlink.iproute2 import iproute2 from ip_playback import sync from ip_interface import interface from time import sleep from pprint import pprint # # startup: init objects # print("8<-------------------- init") ifaces = dict([ (x['index'],interface(x)) for x in iproute2.get_all_links() ]) [ ifaces[x['index']]['addresses'].append(x) for x in iproute2.get_all_addrs() ] print("8<-------------------- init results") [ print(x) for x in ifaces.items() ] # # playback log records # print("8<-------------------- sleep") sleep(20) print("8<-------------------- log playback") sync(ifaces) print("8<-------------------- playback results") pprint(ifaces) # # results #