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/__init__.py (-6 / +4 lines)
 Lines 63-69   _ = Translation('univention-management-console-module-setup').translate Link Here 
63
63
64
PATH_SYS_CLASS_NET = '/sys/class/net'
64
PATH_SYS_CLASS_NET = '/sys/class/net'
65
65
66
RE_IPV4 = re.compile(r'^interfaces/(([^/_]+)(_[0-9])?)/(address|netmask)$')
66
RE_IPV4 = re.compile(r'^interfaces/(([^/]+?)(_[0-9])?)/(address|netmask)$')
67
RE_IPV6_DEFAULT = re.compile(r'^interfaces/([^/]+)/ipv6/default/(prefix|address)$')
67
RE_IPV6_DEFAULT = re.compile(r'^interfaces/([^/]+)/ipv6/default/(prefix|address)$')
68
RE_SPACE = re.compile(r'\s+')
68
RE_SPACE = re.compile(r'\s+')
69
RE_SSL = re.compile(r'^ssl/.*')
69
RE_SSL = re.compile(r'^ssl/.*')
 Lines 135-142   class Instance(umcm.Base): Link Here 
135
		'''Reconfigures the system according to the values specified in the dict given as
135
		'''Reconfigures the system according to the values specified in the dict given as
136
		option named "values".'''
136
		option named "values".'''
137
137
138
		# get old and new values
138
		# get new values
139
		orgValues = util.load_values()
140
		values = request.options.get('values', {})
139
		values = request.options.get('values', {})
141
140
142
		def _thread(request, obj):
141
		def _thread(request, obj):
 Lines 147-154   class Instance(umcm.Base): Link Here 
147
				self._progressParser.reset()
146
				self._progressParser.reset()
148
147
149
				# write the profile file and run setup scripts
148
				# write the profile file and run setup scripts
150
				orgValues = util.load_values()
149
				util.pre_save(values)
151
				util.pre_save(values, orgValues)
152
150
153
				MODULE.info('saving profile values')
151
				MODULE.info('saving profile values')
154
				util.write_profile(values)
152
				util.write_profile(values)
 Lines 211-217   class Instance(umcm.Base): Link Here 
211
				self._progressParser.reset()
209
				self._progressParser.reset()
212
210
213
				# write the profile file and run setup scripts
211
				# write the profile file and run setup scripts
214
				util.pre_save(values, orgValues)
212
				util.pre_save(values)
215
213
216
				# on unjoined DC master the nameserver must be set to the external nameserver
214
				# on unjoined DC master the nameserver must be set to the external nameserver
217
				if newrole == 'domaincontroller_master' and not orgValues.get('joined'):
215
				if newrole == 'domaincontroller_master' and not orgValues.get('joined'):
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/network.py (-30 / +11 lines)
 Lines 46-54   ucr.load() Link Here 
46
46
47
_ = Translation('univention-management-console-module-setup').translate
47
_ = Translation('univention-management-console-module-setup').translate
48
48
49
RE_INTERFACE = re.compile(r'^interfaces/(?!(?:primary|restart/auto|handler)$)([^/_]+)(_[0-9]+)?/')
49
RE_INTERFACE = re.compile(r'^interfaces/(?!(?:primary|restart/auto|handler)$)([^/]+?)(_[0-9]+)?/')
50
RE_IPV6_ID = re.compile(r'^[a-zA-Z0-9]+\Z')
50
RE_IPV6_ID = re.compile(r'^[a-zA-Z0-9]+\Z')
51
VALID_NAME_RE = re.compile(r'^[^/ \t\n\r\f]{1,16}\Z')
51
VALID_NAME_RE = re.compile(r'^(?![.]{1,2})[^/ \t\n\r\f]{1,15}\Z')
52
52
53
PHYSICAL_INTERFACES = [dev['name'] for dev in detect_interfaces()]
53
PHYSICAL_INTERFACES = [dev['name'] for dev in detect_interfaces()]
54
54
 Lines 80-100   class IP6Set(set): Link Here 
80
class Interfaces(dict):
80
class Interfaces(dict):
81
	"""All network interfaces"""
81
	"""All network interfaces"""
82
82
83
	@property
84
	def primary(self):
85
		"""Returns the primary network interface if exists else None"""
86
		for device in self.values():
87
			if device.primary:
88
				return device
89
90
	@primary.setter
91
	def primary(self, primary=None):
92
		"""Removes the primary flag from all devices and sets it to the new device if exists"""
93
		for device in self.values():
94
			device.primary = False
95
		if primary in self:
96
			self[primary].primary = True
97
98
	def __init__(self, *args, **kwargs):
83
	def __init__(self, *args, **kwargs):
99
		"""Loads all network devices from UCR variables"""
84
		"""Loads all network devices from UCR variables"""
100
		super(Interfaces, self).__init__(*args, **kwargs)
85
		super(Interfaces, self).__init__(*args, **kwargs)
 Lines 102-108   class Interfaces(dict): Link Here 
102
		ucr.load()
87
		ucr.load()
103
88
104
		# get all available interfaces
89
		# get all available interfaces
105
		interfaces = set(RE_INTERFACE.match(key).group(1) for key in ucr if RE_INTERFACE.match(key))
90
		interfaces = set(_.group(1) for _ in (RE_INTERFACE.match(key) for key in ucr) if _)
106
		for name in interfaces:
91
		for name in interfaces:
107
			device = Device(name, self)
92
			device = Device(name, self)
108
			device.parse_ucr()
93
			device.parse_ucr()
 Lines 113-119   class Interfaces(dict): Link Here 
113
		ucr.load()
98
		ucr.load()
114
99
115
		# remove old devices
100
		# remove old devices
116
		to_remove = set(self.keys()).difference(set(interfaces.keys()))
101
		to_remove = set(self.keys()) - set(interfaces.keys())
117
		for name in to_remove:
102
		for name in to_remove:
118
			device = _RemovedDevice(name, self)
103
			device = _RemovedDevice(name, self)
119
			self[device.name] = device
104
			self[device.name] = device
 Lines 131-137   class Interfaces(dict): Link Here 
131
		"""Returns a UCR representation of all interfaces"""
116
		"""Returns a UCR representation of all interfaces"""
132
		ucr.load()
117
		ucr.load()
133
118
134
		ucrv = {'interfaces/primary': None}
119
		ucrv = {}  # 'interfaces/primary' is handled in util.py
135
		for device in self.values():
120
		for device in self.values():
136
			ucrv.update(device.to_ucr())
121
			ucrv.update(device.to_ucr())
137
122
 Lines 261-269   class Device(object): Link Here 
261
		self.ip4dynamic = False
246
		self.ip4dynamic = False
262
		self.ip6dynamic = False
247
		self.ip6dynamic = False
263
248
264
		# flag indicating that this interface is the primary network interface of the system
265
		self.primary = False
266
267
		# flag indicating that this interface should automatically start at system startup
249
		# flag indicating that this interface should automatically start at system startup
268
		self.start = None
250
		self.start = None
269
251
 Lines 420-427   class Device(object): Link Here 
420
		pattern = re.compile(r'^interfaces/%s(?:_[0-9]+)?/' % re.escape(name))
402
		pattern = re.compile(r'^interfaces/%s(?:_[0-9]+)?/' % re.escape(name))
421
		vals = dict((key, ucr[key]) for key in ucr if pattern.match(key))
403
		vals = dict((key, ucr[key]) for key in ucr if pattern.match(key))
422
404
423
		self.primary = ucr.get('interfaces/primary') == name
424
425
		self.start = ucr.is_true(value=vals.pop('interfaces/%s/start' % (name), None))
405
		self.start = ucr.is_true(value=vals.pop('interfaces/%s/start' % (name), None))
426
406
427
		self.type = vals.pop('interfaces/%s/type' % (name), None)
407
		self.type = vals.pop('interfaces/%s/type' % (name), None)
 Lines 473-481   class Device(object): Link Here 
473
		for key, val in self._leftover:
453
		for key, val in self._leftover:
474
			vals[key] = val
454
			vals[key] = val
475
455
476
		if self.primary:
477
			vals['interfaces/primary'] = name
478
479
		if self.start is not None:
456
		if self.start is not None:
480
			vals['interfaces/%s/start' % (name)] = str(bool(self.start)).lower()
457
			vals['interfaces/%s/start' % (name)] = str(bool(self.start)).lower()
481
458
 Lines 558-564   class Device(object): Link Here 
558
class _RemovedDevice(Device):
535
class _RemovedDevice(Device):
559
	"""Internal class representing that a device have to be removed from UCR"""
536
	"""Internal class representing that a device have to be removed from UCR"""
560
	def to_ucr(self):
537
	def to_ucr(self):
561
		return dict((key, None) for key in ucr.iterkeys() if RE_INTERFACE.match(key))
538
		to_remove = {}
539
		for key in ucr.iterkeys():
540
			match = RE_INTERFACE.match(key)
541
			if match and self.name == match.group(1):
542
				to_remove[key] = None
543
		return to_remove
562
544
563
	def validate(self):
545
	def validate(self):
564
		return True
546
		return True
 Lines 823-829   class Bridge(Device): Link Here 
823
				try:
805
				try:
824
					self.bridge_fd = int(value)
806
					self.bridge_fd = int(value)
825
				except ValueError:
807
				except ValueError:
826
					# invalid value
827
					pass
808
					pass
828
			else:
809
			else:
829
				options.append(option)
810
				options.append(option)
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/util.py (-2 / +1 lines)
 Lines 147-153   def _xkeymap(keymap): Link Here 
147
	return xkeymap
147
	return xkeymap
148
148
149
149
150
def pre_save(newValues, oldValues):
150
def pre_save(newValues):
151
	'''Modify the final dict before saving it to the profile file.'''
151
	'''Modify the final dict before saving it to the profile file.'''
152
152
153
	# use new system role (or as fallback the current system role)
153
	# use new system role (or as fallback the current system role)
154
- 

Return to bug 30816