1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

move ifupdown2/* .

ifupdown2 code was one level deeper because ifupdown2 initially
had ifupdown2 and ifupdown2-addons as two separate packages.
Since they were combined into one package, it makes sense to
move all combined code under the top level directory

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
Roopa Prabhu
2015-08-02 05:05:52 -07:00
parent 6b14b64e62
commit ff50f301d5
89 changed files with 0 additions and 0 deletions

56
tests/ifstatetest Executable file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/python
""" test for testing and profiling state manager """
import cProfile
from ifupdown.networkinterfaces import *
from ifupdown.iface import *
from ifupdown.statemanager import pickling
import os
ifaceobjdict = {}
state_file = '/tmp/ifstatetest'
def save_iface(ifaceobj):
ifaceobjdict[ifaceobj.get_name()] = ifaceobj
def read_default_iface_config():
""" Reads default network interface config /etc/network/interfaces. """
nifaces = networkInterfaces()
nifaces.subscribe('iface_found', save_iface)
nifaces.load()
def save_state():
try:
with open(state_file, 'w') as f:
for ifaceobj in ifaceobjdict.values():
pickling.save_obj(f, ifaceobj)
except:
raise
def load_state():
global ifaceobjdict
if not os.path.exists(state_file):
return
del ifaceobjdict
ifaceobjdict = {}
# Read all ifaces from file
for ifaceobj in pickling.load(state_file):
save_iface(ifaceobj)
print 'Reading iface config files ..'
cProfile.run('read_default_iface_config()')
print 'number of objects: %d' %len(ifaceobjdict)
print 'saving iface state ..'
cProfile.run('save_state()')
print 'loading iface state ..'
cProfile.run('load_state()')
print 'number of objects: %d' %len(ifaceobjdict)