View | Details | Raw Unified | Return to bug 30816 | Differences between
and this patch

Collapse All | Expand All

(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/network.py (-13 / +28 lines)
 Lines 456-462   class Device(object): Link Here 
456
		self.options.sort()
456
		self.options.sort()
457
		self._leftover.sort()
457
		self._leftover.sort()
458
458
459
	def to_ucr(self):
459
	def to_ucr(self, options=None):
460
		"""Returns a dict of UCR variables to set or unset.
460
		"""Returns a dict of UCR variables to set or unset.
461
			Values which are None should be unset.
461
			Values which are None should be unset.
462
		"""
462
		"""
 Lines 506-512   class Device(object): Link Here 
506
506
507
		vals['interfaces/%s/ipv6/acceptRA' % (name)] = str(bool(self.ip6dynamic)).lower()
507
		vals['interfaces/%s/ipv6/acceptRA' % (name)] = str(bool(self.ip6dynamic)).lower()
508
508
509
		for i, option in enumerate(self.options):
509
		for i, option in enumerate(self.options + (options or [])):
510
			vals['interfaces/%s/options/%d' % (name, i)] = option
510
			vals['interfaces/%s/options/%d' % (name, i)] = option
511
511
512
		return vals
512
		return vals
 Lines 606-613   class VLAN(Device): Link Here 
606
		super(VLAN, self).validate_name()
606
		super(VLAN, self).validate_name()
607
		if not '.' in self.name:
607
		if not '.' in self.name:
608
			raise DeviceError(_('Invalid device name: %r') % (self.name,))
608
			raise DeviceError(_('Invalid device name: %r') % (self.name,))
609
		if not (1 <= self.vlan_id <= 4096):
609
		if not (1 <= self.vlan_id <= 4095):
610
			raise DeviceError(_('Invalid VLAN ID. Must be between 1 and 4096.'), self.name)
610
			raise DeviceError(_('Invalid VLAN ID. Must be between 1 and 4095.'), self.name)
611
611
612
	@property
612
	@property
613
	def dict(self):
613
	def dict(self):
 Lines 618-623   class VLAN(Device): Link Here 
618
		))
618
		))
619
		return d
619
		return d
620
620
621
	def parse_ucr(self):
622
		super(Bond, self).parse_ucr()
623
		options = []
624
		for option in self.options:
625
			try:
626
				name, value = option.split(None, 1)
627
			except ValueError:
628
				name, value = option, ''
629
630
			if name == 'vlan-raw-device':
631
				pass
632
			else:
633
				options.append(option)
634
		self.options = options
635
636
	def to_ucr(self):
637
		options = [
638
				'vlan-raw-device %s' % (self.parent_device,),
639
				]
640
		return super(Bond, self).to_ucr(options)
641
621
642
622
class Bond(Device):
643
class Bond(Device):
623
	"""A network bonding interface"""
644
	"""A network bonding interface"""
 Lines 731-745   class Bond(Device): Link Here 
731
				'bond-slaves %s' % (' '.join(self.bond_slaves),),
752
				'bond-slaves %s' % (' '.join(self.bond_slaves),),
732
				'bond-mode %s' % (self.bond_mode,),
753
				'bond-mode %s' % (self.bond_mode,),
733
				]
754
				]
734
		if self.bond_primary:
755
		if self.bind_mode == 1 and self.bond_primary:
735
			options.append('bond-primary %s' % (' '.join(self.bond_primary),))
756
			options.append('bond-primary %s' % (' '.join(self.bond_primary),))
736
		if self.miimon is not None:
757
		if self.miimon is not None:
737
			options.append('miimon %s' % (self.miimon,))
758
			options.append('miimon %s' % (self.miimon,))
738
759
739
		vals = super(Bond, self).to_ucr()
760
		return super(Bond, self).to_ucr(options)
740
		for i, option in enumerate(options, start=len(self.options)):
741
			vals['interfaces/%s/options/%d' % (self.name, i)] = option
742
		return vals
743
761
744
762
745
class Bridge(Device):
763
class Bridge(Device):
 Lines 812-821   class Bridge(Device): Link Here 
812
				'bridge_fd %d' % (self.bridge_fd,),
830
				'bridge_fd %d' % (self.bridge_fd,),
813
				]
831
				]
814
832
815
		vals = super(Bridge, self).to_ucr()
833
		return super(Bridge, self).to_ucr(options)
816
		for i, option in enumerate(options, start=len(self.options)):
817
			vals['interfaces/%s/options/%d' % (self.name, i)] = option
818
		return vals
819
834
820
835
821
if __name__ == '__main__':
836
if __name__ == '__main__':

Return to bug 30816