mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Fix whitespace issue + uninitialized variable issue
Ticket: CM-2997 Reviewed By: shm Testing Done: Ran precommit
This commit is contained in:
@@ -408,7 +408,7 @@ class ifupdownMain(ifupdownBase):
|
||||
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)
|
||||
@@ -705,7 +705,8 @@ class ifupdownMain(ifupdownBase):
|
||||
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)
|
||||
@@ -791,6 +792,7 @@ class ifupdownMain(ifupdownBase):
|
||||
""" reload interface config """
|
||||
|
||||
allow_classes = []
|
||||
new_ifaceobjdict = {}
|
||||
|
||||
self.logger.debug('reloading interface config ..')
|
||||
if auto:
|
||||
@@ -802,6 +804,10 @@ class ifupdownMain(ifupdownBase):
|
||||
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
|
||||
@@ -866,6 +872,8 @@ class ifupdownMain(ifupdownBase):
|
||||
|
||||
# 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()
|
||||
|
@@ -15,6 +15,8 @@ import os
|
||||
from iface import *
|
||||
from template import templateEngine
|
||||
|
||||
whitespaces = '\n\t\r '
|
||||
|
||||
class networkInterfaces():
|
||||
|
||||
hotplugs = {}
|
||||
@@ -80,7 +82,7 @@ class networkInterfaces():
|
||||
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
|
||||
@@ -163,7 +165,7 @@ class networkInterfaces():
|
||||
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]
|
||||
|
||||
@@ -171,7 +173,7 @@ class networkInterfaces():
|
||||
|
||||
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]):
|
||||
@@ -247,12 +249,15 @@ class networkInterfaces():
|
||||
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])
|
||||
|
Reference in New Issue
Block a user