Univention Bugzilla – Attachment 4092 Details for
Bug 25463
Weitere MAC-Adressenformate unterstützen
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
add support for common mac address formats
syntax.diff (text/plain), 1.89 KB, created by
Lukas Walter
on 2012-01-16 08:52 CET
(
hide
)
Description:
add support for common mac address formats
Filename:
MIME Type:
Creator:
Lukas Walter
Created:
2012-01-16 08:52 CET
Size:
1.89 KB
patch
obsolete
>Index: modules/univention/admin/syntax.py >=================================================================== >--- modules/univention/admin/syntax.py (Revision 30269) >+++ 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 ) )
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 25463
:
4073
|
4074
|
4075
|
4088
|
4089
|
4092
|
4094