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

Make ifupdown2 insensitive to '-' and '_' in interface attribute names.

Ticket: CM-2501
Reviewed By:
Testing Done: Tested ifupdown sanity
This commit is contained in:
roopa
2014-04-07 14:38:06 -07:00
parent 525f0a30ef
commit 7a51240ec2
2 changed files with 6 additions and 8 deletions

View File

@ -118,8 +118,6 @@ class ifupdownMain(ifupdownBase):
self.STATEMANAGER_ENABLE = statemanager_enable
self.CACHE = cache
self.logger.debug("Roopa: DRYRUN = %s" %self.DRYRUN)
# Can be used to provide hints for caching
self.CACHE_FLAGS = 0x0
self._DELETE_DEPENDENT_IFACES_WITH_NOCONFIG = False

View File

@ -96,8 +96,9 @@ class networkInterfaces():
return 0
def _add_to_iface_config(self, iface_config, attrname, attrval):
attrvallist = iface_config.get(attrname, [])
if attrname in ['scope', 'netmask', 'broadcast', 'preferred-lifetime']:
newattrname = attrname.replace("_", "-")
attrvallist = iface_config.get(newattrname, [])
if newattrname in ['scope', 'netmask', 'broadcast', 'preferred-lifetime']:
# For attributes that are related and that can have multiple
# entries, store them at the same index as their parent attribute.
# The example of such attributes is 'address' and its related
@ -113,18 +114,17 @@ class networkInterfaces():
for i in range(0, len(addrlist) - len(attrvallist) -1):
attrvallist.append('')
attrvallist.append(attrval)
iface_config[attrname] = attrvallist
iface_config[newattrname] = attrvallist
elif not attrvallist:
iface_config[attrname] = [attrval]
iface_config[newattrname] = [attrval]
else:
iface_config[attrname].append(attrval)
iface_config[newattrname].append(attrval)
def process_iface(self, lines, cur_idx, lineno):
lines_consumed = 0
line_idx = cur_idx
ifaceobj = iface()
iface_line = lines[cur_idx].strip('\n ')
iface_attrs = iface_line.split()
ifacename = iface_attrs[1]