def process_vlan(self, lines, cur_idx, lineno): ifaceobj = iface() lines_consumed = self.parse_iface(lines, cur_idx, lineno, ifaceobj) range_val = utils.parse_iface_range(ifaceobj.name) if range_val: if len(range_val) == 3: for v in range(range_val[1], range_val[2] + 1): flags = iface.IFACERANGE_ENTRY if v == range_val[1]: flags |= iface.IFACERANGE_START ifaceobj_new = self._create_ifaceobj_clone( ifaceobj, '%s%d' % (range_val[0], v), ifaceType.BRIDGE_VLAN, flags) self.callbacks.get('iface_found')(ifaceobj_new) elif len(range_val) == 4: for v in range(range_val[1], range_val[2] + 1): flags = iface.IFACERANGE_ENTRY if v == range_val[1]: flags |= iface.IFACERANGE_START ifaceobj_new = self._create_ifaceobj_clone( ifaceobj, '%s%d%s' % (range_val[0], v, range_val[3]), ifaceType.BRIDGE_VLAN, flags) self.callbacks.get('iface_found')(ifaceobj_new) else: ifaceobj.type = ifaceType.BRIDGE_VLAN self.callbacks.get('iface_found')(ifaceobj) return lines_consumed # Return next index
def process_vlan(self, lines, cur_idx, lineno): ifaceobj = iface() lines_consumed = self.parse_iface(lines, cur_idx, lineno, ifaceobj) range_val = utils.parse_iface_range(ifaceobj.name) if range_val: if len(range_val) == 3: for v in range(range_val[1], range_val[2]+1): flags = iface.IFACERANGE_ENTRY if v == range_val[1]: flags |= iface.IFACERANGE_START ifaceobj_new = self._create_ifaceobj_clone(ifaceobj, '%s%d' %(range_val[0], v), ifaceType.BRIDGE_VLAN, flags) self.callbacks.get('iface_found')(ifaceobj_new) elif len(range_val) == 4: for v in range(range_val[1], range_val[2]+1): flags = iface.IFACERANGE_ENTRY if v == range_val[1]: flags |= iface.IFACERANGE_START ifaceobj_new = self._create_ifaceobj_clone(ifaceobj, '%s%d%s' %(range_val[0], v, range_val[3]), ifaceType.BRIDGE_VLAN, flags) self.callbacks.get('iface_found')(ifaceobj_new) else: ifaceobj.type = ifaceType.BRIDGE_VLAN self.callbacks.get('iface_found')(ifaceobj) return lines_consumed # Return next index
def process_iface(self, lines, cur_idx, lineno): ifaceobj = iface() lines_consumed = self.parse_iface(lines, cur_idx, lineno, ifaceobj) range_val = utils.parse_iface_range(ifaceobj.name) if range_val: if len(range_val) == 3: for v in range(range_val[1], range_val[2]+1): ifacename = '%s%d' %(range_val[0], v) if utils.check_ifname_size_invalid(ifacename): self._parse_warn(self._currentfile, lineno, '%s: interface name too long' %ifacename) flags = iface.IFACERANGE_ENTRY if v == range_val[1]: flags |= iface.IFACERANGE_START ifaceobj_new = self._create_ifaceobj_clone(ifaceobj, ifacename, ifaceobj.type, flags) self.callbacks.get('iface_found')(ifaceobj_new) elif len(range_val) == 4: for v in range(range_val[1], range_val[2]+1): ifacename = '%s%d%s' %(range_val[0], v, range_val[3]) if utils.check_ifname_size_invalid(ifacename): self._parse_warn(self._currentfile, lineno, '%s: interface name too long' %ifacename) flags = iface.IFACERANGE_ENTRY if v == range_val[1]: flags |= iface.IFACERANGE_START ifaceobj_new = self._create_ifaceobj_clone(ifaceobj, ifacename, ifaceobj.type, flags) self.callbacks.get('iface_found')(ifaceobj_new) else: self.callbacks.get('iface_found')(ifaceobj) return lines_consumed # Return next index