Index: modules/univention/admin/syntax.py =================================================================== --- modules/univention/admin/syntax.py (Revision 30248) +++ modules/univention/admin/syntax.py (Arbeitskopie) @@ -1081,14 +1081,32 @@ choices = ( ( 'ethernet', _( 'Ethernet' ) ), ( 'fddi', _( 'FDDI' ) ), ( 'token-ring', _( 'Token-Ring' ) ) ) class MAC_Address( simple ): - regex = re.compile( '^([0-9a-fA-F]{1,2}[:-]){5}[0-9a-fA-F]{1,2}$' ) - error_message = _( 'This is not a valid MAC address. It must have 6 two digit hexadecimal numbers separated by \"-\" or \":\"' ) + regexLinuxFormat = re.compile( r'^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$' ) + regexWindowsFormat = re.compile( r'^([0-9a-fA-F]{2}-){5}[0-9a-fA-F]{2}$' ) + regexRawFormat = re.compile( r'^[0-9a-fA-F]{12}$' ) + regexCiscoFormat = re.compile( r'^([0-9a-fA-F]{4}.){2}[0-9a-fA-F]{4}$' ) + 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)' ) size = 'TwoThirds' @classmethod def parse( self, text ): - simple.parse( text ) - return text.replace( '-', ':' ).lower() + if self.regexLinuxFormat.match(text) is not None: + return text.lower() + elif self.regexWindowsFormat.match(text) is not None: + return text.replace('-', ':').lower() + elif self.regexRawFormat.match(text) is not None: + temp = [] + for i in range(0, len(text)-1, 2): + temp.append(text[i:i+2]) + return ':'.join(temp).lower() + elif self.regexCiscoFormat.match(text) is not None: + tmpList = [] + tmpStr = text.translate(None, '.'))-1, 2): + for i in range(0, len(tmpStr)-1, 2): + tmpList.append(tmpStr)[i:i+2]) + return ':'.join(tmpList).lower() + else: + raise univention.admin.uexceptions.valueError( self.error_message ) class DHCP_HardwareAddress( complex ): subsyntaxes = ( ( _( 'Type' ), NetworkType ), ( _( 'Address' ), MAC_Address ) )