--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/network.py +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/network.py @@ -456,7 +456,7 @@ class Device(object): self.options.sort() self._leftover.sort() - def to_ucr(self): + def to_ucr(self, options=None): """Returns a dict of UCR variables to set or unset. Values which are None should be unset. """ @@ -506,7 +506,7 @@ class Device(object): vals['interfaces/%s/ipv6/acceptRA' % (name)] = str(bool(self.ip6dynamic)).lower() - for i, option in enumerate(self.options): + for i, option in enumerate(self.options + (options or [])): vals['interfaces/%s/options/%d' % (name, i)] = option return vals @@ -606,8 +606,8 @@ class VLAN(Device): super(VLAN, self).validate_name() if not '.' in self.name: raise DeviceError(_('Invalid device name: %r') % (self.name,)) - if not (1 <= self.vlan_id <= 4096): - raise DeviceError(_('Invalid VLAN ID. Must be between 1 and 4096.'), self.name) + if not (1 <= self.vlan_id <= 4095): + raise DeviceError(_('Invalid VLAN ID. Must be between 1 and 4095.'), self.name) @property def dict(self): @@ -618,6 +618,27 @@ class VLAN(Device): )) return d + def parse_ucr(self): + super(Bond, self).parse_ucr() + options = [] + for option in self.options: + try: + name, value = option.split(None, 1) + except ValueError: + name, value = option, '' + + if name == 'vlan-raw-device': + pass + else: + options.append(option) + self.options = options + + def to_ucr(self): + options = [ + 'vlan-raw-device %s' % (self.parent_device,), + ] + return super(Bond, self).to_ucr(options) + class Bond(Device): """A network bonding interface""" @@ -731,15 +752,12 @@ class Bond(Device): 'bond-slaves %s' % (' '.join(self.bond_slaves),), 'bond-mode %s' % (self.bond_mode,), ] - if self.bond_primary: + if self.bind_mode == 1 and self.bond_primary: options.append('bond-primary %s' % (' '.join(self.bond_primary),)) if self.miimon is not None: options.append('miimon %s' % (self.miimon,)) - vals = super(Bond, self).to_ucr() - for i, option in enumerate(options, start=len(self.options)): - vals['interfaces/%s/options/%d' % (self.name, i)] = option - return vals + return super(Bond, self).to_ucr(options) class Bridge(Device): @@ -812,10 +830,7 @@ class Bridge(Device): 'bridge_fd %d' % (self.bridge_fd,), ] - vals = super(Bridge, self).to_ucr() - for i, option in enumerate(options, start=len(self.options)): - vals['interfaces/%s/options/%d' % (self.name, i)] = option - return vals + return super(Bridge, self).to_ucr(options) if __name__ == '__main__':