From 36c1491c0bda6fcaa8809a92174fd9651a16ce37 Mon Sep 17 00:00:00 2001 From: Doug Kingston Date: Fri, 16 Feb 2024 15:36:12 -0800 Subject: [PATCH] Update variable naming to be more generic. (#33) Was next31 which was wrong for /30 and not flexible to subnet size changes. This code will now be more reusable with no loss of readability. --- portal/management/commands/assignopppair.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/portal/management/commands/assignopppair.py b/portal/management/commands/assignopppair.py index 031d044..9a58298 100644 --- a/portal/management/commands/assignopppair.py +++ b/portal/management/commands/assignopppair.py @@ -50,8 +50,8 @@ def handle(self, *args, **options): self.stderr.write("WARNING: last host (%s) is not in last subnet (%s)!" % ( last_host, last_network)) - next31 = IPv4Network(str(max(last_network, last_host) + 1) + '/30') - hosts = map(str, next31.iterhosts()) + next_subnet = IPv4Network(str(max(last_network, last_host) + 1) + '/30') + hosts = map(str, next_subnet.iterhosts()) self.stdout.write(" ".join(hosts)) if options['dry_run']: return @@ -80,6 +80,6 @@ def handle(self, *args, **options): ip.save() self.stderr.write(" " + str(ip)) subnet = Subnet() - subnet.network = next31 + subnet.network = next_subnet subnet.notes = new_host.name subnet.save()