Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 def process_auto(self, lines, cur_idx, lineno):
     auto_ifaces = re.split(self._ws_split_regex, lines[cur_idx])[1:]
     if not auto_ifaces:
         self._parse_error(self._currentfile, lineno,
                 'invalid auto line \'%s\''%lines[cur_idx])
         return 0
     for a in auto_ifaces:
         if a == 'all':
             self.auto_all = True
             break
         r = utils.parse_iface_range(a)
         if r:
             for i in range(r[1], r[2]):
                self.auto_ifaces.append('%s-%d' %(r[0], i))
         self.auto_ifaces.append(a)
     return 0
Exemplo n.º 4
0
    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:
           for v in range(range_val[1], range_val[2]):
                ifaceobj_new = copy.deepcopy(ifaceobj)
                ifaceobj_new.realname = '%s' %ifaceobj.name
                ifaceobj_new.name = '%s%d' %(range_val[0], v)
                ifaceobj_new.flags = iface.IFACERANGE_ENTRY
                if v == range_val[1]:
                    ifaceobj_new.flags |= iface.IFACERANGE_START
                self.callbacks.get('iface_found')(ifaceobj_new)
        else:
            self.callbacks.get('iface_found')(ifaceobj)

        return lines_consumed       # Return next index
Exemplo n.º 5
0
 def process_auto(self, lines, cur_idx, lineno):
     auto_ifaces = re.split(self._ws_split_regex, lines[cur_idx])[1:]
     if not auto_ifaces:
         self._parse_error(self._currentfile, lineno,
                 'invalid auto line \'%s\''%lines[cur_idx])
         return 0
     for a in auto_ifaces:
         if a == 'all':
             self.auto_all = True
             break
         r = utils.parse_iface_range(a)
         if r:
             if len(r) == 3:
                 # eg swp1.[2-4], r = "swp1.", 2, 4)
                 for i in range(r[1], r[2]+1):
                     self.auto_ifaces.append('%s%d' %(r[0], i))
             elif len(r) == 4:
                 for i in range(r[1], r[2]+1):
                     # eg swp[2-4].100, r = ("swp", 2, 4, ".100")
                     self.auto_ifaces.append('%s%d%s' %(r[0], i, r[3]))
         self.auto_ifaces.append(a)
     return 0