View | Details | Raw Unified | Return to bug 32995
Collapse All | Expand All

(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/__init__.py (-15 / +19 lines)
 Lines 317-338   class Instance(umcm.Base): Link Here 
317
		# helper functions
317
		# helper functions
318
		# TODO: 'valid' is not correctly evaluated in frontend
318
		# TODO: 'valid' is not correctly evaluated in frontend
319
		# i.e. if valid you may continue without getting message
319
		# i.e. if valid you may continue without getting message
320
		def _check(key, check, message, critical=True):
320
		def _append(key, message, critical=True):
321
			if key not in values:
322
				return
323
			if not check(values[key]):
324
				messages.append({
325
					'message': message,
326
					'valid': not critical,
327
					'key': key
328
				})
329
330
		def _append(key, message):
331
			messages.append({
321
			messages.append({
332
				'key': key,
322
				'key': key,
333
				'valid': False,
323
				'message': message,
334
				'message': message
324
				'valid': not critical,
335
			})
325
			})
326
		def _check(key, check, message, critical=True):
327
			try:
328
				value = values[key]
329
			except KeyError:
330
				return
331
			if not check(value):
332
				_append(key, message, critical)
336
333
337
		# system role
334
		# system role
338
		_check('server/role', lambda x: not(orgValues.get('joined')) or (orgValues.get('server/role') == values.get('server/role')), _('The system role may not change on a system that has already joined to domain.'))
335
		_check('server/role', lambda x: not(orgValues.get('joined')) or (orgValues.get('server/role') == values.get('server/role')), _('The system role may not change on a system that has already joined to domain.'))
 Lines 395-403   class Instance(umcm.Base): Link Here 
395
392
396
		# check gateways
393
		# check gateways
397
		if values.get('gateway'): # allow empty value
394
		if values.get('gateway'): # allow empty value
398
			_check('gateway', util.is_ipv4addr, _('The specified gateway IPv4 address is not valid: %s') % values.get('gateway'))
395
			_check('gateway', util.is_ipv4addr, _("The specified gateway IPv4 address '%(gateway)s' is not valid.") % values)
396
		gateway = values.get('gateway', ucr.get('gateway'))
397
		if gateway and not interfaces.check_ip4_reachable(gateway):
398
			_append('gateway', _("The specified gateway IPv4 address '%s' is not reachable.") % gateway)
399
399
		if values.get('ipv6/gateway'): # allow empty value
400
		if values.get('ipv6/gateway'): # allow empty value
400
			_check('ipv6/gateway', util.is_ipv6addr, _('The specified gateway IPv6 address is not valid: %s') % values.get('ipv6/gateway'))
401
			_check('ipv6/gateway', util.is_ipv6addr, _("The specified gateway IPv6 address '%(ipv6/gateway)s' is not valid.") % values)
402
		gateway = values.get('ipv6/gateway', ucr.get('ipv6/gateway'))
403
		if gateway and not interfaces.check_ip6_reachable(gateway):
404
			_append('ipv6/gateway', _("The specified gateway IPv6 address '%s' is not reachable.") % gateway)
401
405
402
		# proxy
406
		# proxy
403
		_check('proxy/http', util.is_proxy, _('The specified proxy address is not valid (e.g., http://10.201.1.1:8080): %s') % allValues.get('proxy/http', ''))
407
		_check('proxy/http', util.is_proxy, _('The specified proxy address is not valid (e.g., http://10.201.1.1:8080): %s') % allValues.get('proxy/http', ''))
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/de.po (-4 / +14 lines)
 Lines 241-253   msgstr "Die angegebenen IP-Adresse (%s) ist nicht gültig: %s" Link Here 
241
241
242
#: umc/python/setup/__init__.py:
242
#: umc/python/setup/__init__.py:
243
#, python-format
243
#, python-format
244
msgid "The specified gateway IPv4 address is not valid: %s"
244
msgid "The specified gateway IPv4 address '%(gateway)s' is not valid."
245
msgstr "Die angegebene Gateway-IPv4-Adresse ist nicht gültig: %s"
245
msgstr "Die angegebene Gateway-IPv4-Adresse '%(gateway)s' ist nicht gültig."
246
246
247
#: umc/python/setup/__init__.py:
247
#: umc/python/setup/__init__.py:
248
#, python-format
248
#, python-format
249
msgid "The specified gateway IPv6 address is not valid: %s"
249
msgid "The specified gateway IPv4 address '%s' is not reachable."
250
msgstr "Die angegebene Gateway-IPv6-Adresse is nicht gültig: %s"
250
msgstr "Die angegebene Gateway-IPv4-Adresse '%s' ist nicht erreichbar."
251
252
#: umc/python/setup/__init__.py:
253
#, python-format
254
msgid "The specified gateway IPv6 address '%(ipv6/gateway)s' is not valid."
255
msgstr "Die angegebene Gateway-IPv6-Adresse '%(ipv6/gateway)s' is nicht gültig."
256
257
#: umc/python/setup/__init__.py:
258
#, python-format
259
msgid "The specified gateway IPv6 address '%s' is not reachable."
260
msgstr "Die angegebene Gateway-IPv6-Adresse '%s' is nicht erreichbar."
251
261
252
#: umc/python/setup/__init__.py:
262
#: umc/python/setup/__init__.py:
253
#, python-format
263
#, python-format
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/network.py (-34 / +46 lines)
 Lines 61-82   class DeviceError(ValueError): Link Here 
61
		ValueError.__init__(self, msg)
61
		ValueError.__init__(self, msg)
62
62
63
63
64
class IP4Set(set):
65
	def add(self, ip):
66
		set.add(self, ipaddr.IPv4Address(ip))
67
68
	def __contains__(self, ip):
69
		return set.__contains__(self, ipaddr.IPv4Address(ip))
70
71
72
class IP6Set(set):
73
	def add(self, ip):
74
		set.add(self, ipaddr.IPv6Address(ip))
75
76
	def __contains__(self, ip):
77
		return set.__contains__(self, ipaddr.IPv6Address(ip))
78
79
80
class Interfaces(dict):
64
class Interfaces(dict):
81
	"""All network interfaces"""
65
	"""All network interfaces"""
82
66
 Lines 108-117   class Interfaces(dict): Link Here 
108
			device = Device.from_dict(values, self)
92
			device = Device.from_dict(values, self)
109
			self[device.name] = device
93
			self[device.name] = device
110
94
111
#	def finalize(self):
112
#		self.check_consistency()
113
#		return self.to_ucr()
114
115
	def to_ucr(self):
95
	def to_ucr(self):
116
		"""Returns a UCR representation of all interfaces"""
96
		"""Returns a UCR representation of all interfaces"""
117
		ucr.load()
97
		ucr.load()
 Lines 143-166   class Interfaces(dict): Link Here 
143
		self.set_device_order()
123
		self.set_device_order()
144
124
145
	def check_unique_ip4_address(self):
125
	def check_unique_ip4_address(self):
146
		all_ip4s = IP4Set()
126
		all_ip4s = set()
127
		for network, device in self.all_ip4_networks():
128
			address = network.ip
129
			if address not in all_ip4s:
130
				all_ip4s.add(address)
131
			else:
132
				raise DeviceError(_('Duplicated IP address: %r') % (address,), device.name)
133
134
	def check_ip4_reachable(self, address):
135
		try:
136
			address = ipaddr.IPv4Address(address)
137
		except ipaddr.AddressValueError:
138
			return False
139
		for network, _device in self.all_ip4_networks():
140
			if address in network:
141
				return True
142
		return False
143
144
	def all_ip4_networks(self):
147
		for device in self.values():
145
		for device in self.values():
148
			if not device.ip4dynamic:
146
			if device.ip4dynamic:
149
				for address, netmask in device.ip4:
147
				continue
150
					# check for duplicated IP's
148
			for address, netmask in device.ip4:
151
					if address in all_ip4s:
149
				yield (ipaddr.IPv4Network("%s/%s" % (address, netmask)), device)
152
						raise DeviceError(_('Duplicated IP address: %r') % (address), device.name)
153
					all_ip4s.add(address)
154
150
155
	def check_unique_ip6_address(self):
151
	def check_unique_ip6_address(self):
156
		all_ip6s = IP6Set()
152
		all_ip6s = set()
153
		for network, device in self.all_ip6_networks():
154
			address = network.ip
155
			if address not in all_ip6s:
156
				all_ip6s.add(address)
157
			else:
158
				raise DeviceError(_('Duplicated IP address: %r') % (address,), device.name)
159
160
	def check_ip6_reachable(self, address):
161
		try:
162
			address = ipaddr.IPv6Address(address)
163
		except ipaddr.AddressValueError:
164
			return False
165
		for network, _device in self.all_ip6_networks():
166
			if address in network:
167
				return True
168
		return False
169
170
	def all_ip6_networks(self):
157
		for device in self.values():
171
		for device in self.values():
158
			if not device.ip6dynamic:
172
			if device.ip6dynamic:
159
				for address, prefix, identifier in device.ip6:
173
				continue
160
					# check for duplicated IP's
174
			for address, prefix, _identifier in device.ip6:
161
					if address in all_ip6s:
175
				yield (ipaddr.IPv4Network("%s/%s" % (address, prefix)), device)
162
						raise DeviceError(_('Duplicated IP address: %r') % (address), device.name)
163
					all_ip6s.add(address)
164
176
165
	def set_device_order(self):
177
	def set_device_order(self):
166
		if not any(isinstance(device, (VLAN, Bridge, Bond)) for device in self.values()):
178
		if not any(isinstance(device, (VLAN, Bridge, Bond)) for device in self.values()):

Return to bug 32995