Skip to content

Commit

Permalink
Update variable naming to be more generic. (#33)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpkingston authored Feb 16, 2024
1 parent 7727034 commit 36c1491
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions portal/management/commands/assignopppair.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 36c1491

Please sign in to comment.