unbound-dhcp-leases-bridge: Migrate to Python 3

Message ID 20210514115311.25256-1-michael.tremer@ipfire.org
State Accepted
Commit 96c86cf62109b048bcfac051027b9ad0ef705943
Headers
Series unbound-dhcp-leases-bridge: Migrate to Python 3 |

Commit Message

Michael Tremer May 14, 2021, 11:53 a.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 config/unbound/unbound-dhcp-leases-bridge | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Peter Müller May 14, 2021, 1:01 p.m. UTC | #1
Hello Michael,

um, isn't it necessary to update the shebang of this script as well?

Apart from that:

Acked-by: Peter Müller <peter.mueller@ipfire.org>

Thanks, and best regards,
Peter Müller


> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
>  config/unbound/unbound-dhcp-leases-bridge | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge
> index e3da4860b..2d8ef1387 100644
> --- a/config/unbound/unbound-dhcp-leases-bridge
> +++ b/config/unbound/unbound-dhcp-leases-bridge
> @@ -178,8 +178,8 @@ class UnboundDHCPLeasesBridge(object):
>  
>  		# Dump everything in the logs
>  		log.debug("Static hosts:")
> -		for hostname, addresses in hosts.items():
> -			log.debug("  %-20s : %s" % (hostname, ", ".join(addresses)))
> +		for name in hosts:
> +			log.debug("  %-20s : %s" % (name, ", ".join(hosts[name])))
>  
>  		return hosts
>  
> @@ -402,9 +402,9 @@ class Lease(object):
>  
>  		address = ipaddress.ip_address(self.ipaddr)
>  
> -		for subnet, domain in subnets.items():
> +		for subnet in subnets:
>  			if address in subnet:
> -				return domain
> +				return subnets[subnet]
>  
>  		# Fall back to localdomain if no match could be found
>  		return "localdomain"
>
  
Michael Tremer May 14, 2021, 1:08 p.m. UTC | #2
Yeah, forget this patch :)

Thanks for finding this problem.

> On 14 May 2021, at 14:01, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> Hello Michael,
> 
> um, isn't it necessary to update the shebang of this script as well?
> 
> Apart from that:
> 
> Acked-by: Peter Müller <peter.mueller@ipfire.org>
> 
> Thanks, and best regards,
> Peter Müller
> 
> 
>> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
>> ---
>> config/unbound/unbound-dhcp-leases-bridge | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge
>> index e3da4860b..2d8ef1387 100644
>> --- a/config/unbound/unbound-dhcp-leases-bridge
>> +++ b/config/unbound/unbound-dhcp-leases-bridge
>> @@ -178,8 +178,8 @@ class UnboundDHCPLeasesBridge(object):
>> 
>> 		# Dump everything in the logs
>> 		log.debug("Static hosts:")
>> -		for hostname, addresses in hosts.items():
>> -			log.debug("  %-20s : %s" % (hostname, ", ".join(addresses)))
>> +		for name in hosts:
>> +			log.debug("  %-20s : %s" % (name, ", ".join(hosts[name])))
>> 
>> 		return hosts
>> 
>> @@ -402,9 +402,9 @@ class Lease(object):
>> 
>> 		address = ipaddress.ip_address(self.ipaddr)
>> 
>> -		for subnet, domain in subnets.items():
>> +		for subnet in subnets:
>> 			if address in subnet:
>> -				return domain
>> +				return subnets[subnet]
>> 
>> 		# Fall back to localdomain if no match could be found
>> 		return "localdomain"
>>
  

Patch

diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge
index e3da4860b..2d8ef1387 100644
--- a/config/unbound/unbound-dhcp-leases-bridge
+++ b/config/unbound/unbound-dhcp-leases-bridge
@@ -178,8 +178,8 @@  class UnboundDHCPLeasesBridge(object):
 
 		# Dump everything in the logs
 		log.debug("Static hosts:")
-		for hostname, addresses in hosts.items():
-			log.debug("  %-20s : %s" % (hostname, ", ".join(addresses)))
+		for name in hosts:
+			log.debug("  %-20s : %s" % (name, ", ".join(hosts[name])))
 
 		return hosts
 
@@ -402,9 +402,9 @@  class Lease(object):
 
 		address = ipaddress.ip_address(self.ipaddr)
 
-		for subnet, domain in subnets.items():
+		for subnet in subnets:
 			if address in subnet:
-				return domain
+				return subnets[subnet]
 
 		# Fall back to localdomain if no match could be found
 		return "localdomain"