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

Collapse All | Expand All

(-)modules/univention/admin/syntax.py (-4 / +22 lines)
 Lines 1081-1094    Link Here 
1081
	choices = ( ( 'ethernet', _( 'Ethernet' ) ), ( 'fddi', _( 'FDDI' ) ), ( 'token-ring', _( 'Token-Ring' ) ) )
1081
	choices = ( ( 'ethernet', _( 'Ethernet' ) ), ( 'fddi', _( 'FDDI' ) ), ( 'token-ring', _( 'Token-Ring' ) ) )
1082
1082
1083
class MAC_Address( simple ):
1083
class MAC_Address( simple ):
1084
	regex = re.compile( '^([0-9a-fA-F]{1,2}[:-]){5}[0-9a-fA-F]{1,2}$' )
1084
	regexLinuxFormat = re.compile( r'^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$' )
1085
	error_message = _( 'This is not a valid MAC address. It must have 6 two digit hexadecimal numbers separated by \"-\" or \":\"' )
1085
	regexWindowsFormat = re.compile( r'^([0-9a-fA-F]{2}-){5}[0-9a-fA-F]{2}$' )
1086
	regexRawFormat = re.compile( r'^[0-9a-fA-F]{12}$' )
1087
	regexCiscoFormat = re.compile( r'^([0-9a-fA-F]{4}.){2}[0-9a-fA-F]{4}$' )
1088
	error_message = _( 'This is not a valid MAC address (valid examples are 86:f5:d1:f5:6b:3e, 23-b6-b8-1b-b0-1b, 04b02c7bdb87, 3ac6.8dcd.b12e)' )
1086
	size = 'TwoThirds'
1089
	size = 'TwoThirds'
1087
1090
1088
	@classmethod
1091
	@classmethod
1089
	def parse( self, text ):
1092
	def parse( self, text ):
1090
		simple.parse( text )
1093
		if self.regexLinuxFormat.match(text) is not None:
1091
		return text.replace( '-', ':' ).lower()
1094
			return  text.lower()
1095
		elif self.regexWindowsFormat.match(text) is not None:
1096
			return  text.replace('-', ':').lower()
1097
		elif self.regexRawFormat.match(text) is not None:
1098
			temp = []
1099
			for i in range(0, len(text)-1, 2):
1100
				temp.append(text[i:i+2])
1101
			return ':'.join(temp).lower()
1102
		elif self.regexCiscoFormat.match(text) is not None:
1103
			tmpList = []
1104
			tmpStr = text.translate(None, '.'))-1, 2):
1105
			for i in range(0, len(tmpStr)-1, 2):
1106
				tmpList.append(tmpStr)[i:i+2])
1107
			return ':'.join(tmpList).lower()
1108
		else:
1109
			raise univention.admin.uexceptions.valueError( self.error_message )
1092
1110
1093
class DHCP_HardwareAddress( complex ):
1111
class DHCP_HardwareAddress( complex ):
1094
	subsyntaxes = ( ( _( 'Type' ), NetworkType ), ( _( 'Address' ), MAC_Address ) )
1112
	subsyntaxes = ( ( _( 'Type' ), NetworkType ), ( _( 'Address' ), MAC_Address ) )

Return to bug 25463