with open(self.addon_modules_configfile, 'r') as f:
lines = f.readlines()
for l in lines:
- litems = l.rstrip(' \n').split(',')
+ litems = l.rstrip(' \n\t\r').split(',')
operation = litems[0]
mname = litems[1]
self.module_ops[operation].append(mname)
if self._iface_whitelisted(auto, allow_classes,
excludepats, i)]
if not filtered_ifacenames:
- raise Exception('no ifaces found matching given allow lists')
+ raise Exception('no ifaces found matching given allow lists ' +
+ '(interfaces were probably never up)')
if printdependency:
self.populate_dependency_info(ops, filtered_ifacenames)
""" reload interface config """
allow_classes = []
+ new_ifaceobjdict = {}
self.logger.debug('reloading interface config ..')
if auto:
except:
raise
+ if not self.ifaceobjdict:
+ self.logger.warn("nothing to reload ..exiting.")
+ return
+
# generate dependency graph of interfaces
self.populate_dependency_info(upops)
if (not usecurrentconfig and self.STATEMANAGER_ENABLE
# Now, run 'up' with new config dict
# reset statemanager update flag to default
+ if not new_ifaceobjdict:
+ return
self.ifaceobjdict = new_ifaceobjdict
self.dependency_graph = new_dependency_graph
ifacenames = self.ifaceobjdict.keys()
from iface import *
from template import templateEngine
+whitespaces = '\n\t\r '
+
class networkInterfaces():
hotplugs = {}
self.callbacks[callback_name] = callback_func
def ignore_line(self, line):
- l = line.strip('\n ')
+ l = line.strip(whitespaces)
if not l or l[0] == '#':
return 1
return 0
line_idx = cur_idx
ifaceobj = iface()
- iface_line = lines[cur_idx].strip('\n ')
+ iface_line = lines[cur_idx].strip(whitespaces)
iface_attrs = iface_line.split()
ifacename = iface_attrs[1]
iface_config = collections.OrderedDict()
for line_idx in range(cur_idx + 1, len(lines)):
- l = lines[line_idx].strip('\n\t ')
+ l = lines[line_idx].strip(whitespaces)
if self.ignore_line(l) == 1:
continue
if self._is_keyword(l.split()[0]):
line_idx = 0
lines_consumed = 0
raw_config = filedata.split('\n')
- lines = [l.strip(' \n') for l in raw_config]
+ lines = [l.strip(whitespaces) for l in raw_config]
while (line_idx < len(lines)):
if self.ignore_line(lines[line_idx]):
line_idx += 1
continue
words = lines[line_idx].split()
+ if not words:
+ line_idx += 1
+ continue
# Check if first element is a supported keyword
if self._is_keyword(words[0]):
keyword_func = self._get_keyword_func(words[0])