improved netaddr mac dialect usage to leverage constructor parameter
This commit is contained in:
		
							parent
							
								
									4ae5936bdc
								
							
						
					
					
						commit
						686026d9f2
					
				
					 4 changed files with 6 additions and 12 deletions
				
			
		|  | @ -350,8 +350,7 @@ class CoreTlvDataMacAddr(CoreTlvDataObj): | |||
|         """ | ||||
|         # only use 48 bits | ||||
|         value = binascii.hexlify(value[2:]).decode() | ||||
|         mac = netaddr.EUI(value) | ||||
|         mac.dialect = netaddr.mac_unix | ||||
|         mac = netaddr.EUI(value, dialect=netaddr.mac_unix_expanded) | ||||
|         return str(mac) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -354,8 +354,7 @@ class NodeConfigDialog(Dialog): | |||
|                 error = True | ||||
|                 break | ||||
|             elif not auto_mac: | ||||
|                 mac = netaddr.EUI(mac) | ||||
|                 mac.dialect = netaddr.mac_unix_expanded | ||||
|                 mac = netaddr.EUI(mac, dialect=netaddr.mac_unix_expanded) | ||||
|                 interface.mac = str(mac) | ||||
| 
 | ||||
|         # redraw | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ class InterfaceManager: | |||
|         self.ip4_subnets = IPNetwork(f"{ip4}/{self.ip4_mask}") | ||||
|         self.ip6_subnets = IPNetwork(f"{ip6}/{self.ip6_mask}") | ||||
|         mac = self.app.guiconfig.get("mac", appconfig.DEFAULT_MAC) | ||||
|         self.mac = EUI(mac) | ||||
|         self.mac = EUI(mac, dialect=netaddr.mac_unix_expanded) | ||||
|         self.current_mac = None | ||||
|         self.current_subnets = None | ||||
|         self.used_subnets = {} | ||||
|  | @ -64,13 +64,11 @@ class InterfaceManager: | |||
| 
 | ||||
|     def reset_mac(self) -> None: | ||||
|         self.current_mac = self.mac | ||||
|         self.current_mac.dialect = netaddr.mac_unix_expanded | ||||
| 
 | ||||
|     def next_mac(self) -> str: | ||||
|         mac = str(self.current_mac) | ||||
|         value = self.current_mac.value + 1 | ||||
|         self.current_mac = EUI(value) | ||||
|         self.current_mac.dialect = netaddr.mac_unix_expanded | ||||
|         self.current_mac = EUI(value, dialect=netaddr.mac_unix_expanded) | ||||
|         return mac | ||||
| 
 | ||||
|     def next_subnets(self) -> Subnets: | ||||
|  |  | |||
|  | @ -437,8 +437,7 @@ def random_mac() -> str: | |||
|     """ | ||||
|     value = random.randint(0, 0xFFFFFF) | ||||
|     value |= 0x00163E << 24 | ||||
|     mac = netaddr.EUI(value) | ||||
|     mac.dialect = netaddr.mac_unix_expanded | ||||
|     mac = netaddr.EUI(value, dialect=netaddr.mac_unix_expanded) | ||||
|     return str(mac) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -450,8 +449,7 @@ def validate_mac(value: str) -> str: | |||
|     :return: unix formatted mac | ||||
|     """ | ||||
|     try: | ||||
|         mac = netaddr.EUI(value) | ||||
|         mac.dialect = netaddr.mac_unix_expanded | ||||
|         mac = netaddr.EUI(value, dialect=netaddr.mac_unix_expanded) | ||||
|         return str(mac) | ||||
|     except netaddr.AddrFormatError as e: | ||||
|         raise CoreError(f"invalid mac address {value}: {e}") | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue