Skip to content

Commit

Permalink
fix: Vlans wiki generation
Browse files Browse the repository at this point in the history
fix: vlan calculations
fix: ls switch conf
closes: #484
closes: #483
closes: #481

Change-Id: I6f916aea084c61e032197d8aa6b7ef530bd85874
  • Loading branch information
grafuls committed Jun 12, 2024
1 parent a505700 commit c1c2e44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/quads/helpers/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import calendar
import re

from datetime import timedelta, datetime

Expand All @@ -16,8 +17,9 @@ def get_vlan(ass_obj, index, last_nic=False):
if ass_obj and ass_obj.vlan and last_nic:
return int(ass_obj.vlan.vlan_id)
else:
_cloud_id = int(re.findall(r"\d+", ass_obj.cloud.name)[0])
if ass_obj:
return calculate_vlan(ass_obj.cloud.id, ass_obj.qinq, index)
return calculate_vlan(_cloud_id, ass_obj.qinq, index)
else:
return calculate_vlan(1, 0, index)

Expand Down
2 changes: 1 addition & 1 deletion src/quads/tools/ls_switch_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def verify(args):
logger.info(f"Cloud qinq: {_assignment.qinq}")

hosts = quads.filter_hosts({"cloud": args.cloud})
if args.all:
if not args.all:
hosts = [hosts[0]]

for host in hosts:
Expand Down
15 changes: 8 additions & 7 deletions src/quads/tools/regenerate_vlans_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,19 @@ def render_vlans(markdown):
for vlan in vlans:
assignment_obj = quads.filter_assignments({"vlan_id": vlan.vlan_id})
assignment_obj = assignment_obj[0] if assignment_obj else None
if assignment_obj is None:
continue
cloud_obj = quads.filter_clouds({"name": assignment_obj.cloud.name})
cloud_obj = cloud_obj[0] if cloud_obj else None
cloud_current_count = 0
cloud_obj = None
if assignment_obj:
cloud_obj = quads.filter_clouds({"name": assignment_obj.cloud.name})
if cloud_obj:
cloud_obj = cloud_obj[0]
cloud_current_count = len(quads.get_current_schedules({"cloud": cloud_obj.name}))

vlan_id = vlan.vlan_id
ip_range = vlan.ip_range
netmask = vlan.netmask
gateway = vlan.gateway
ip_free = vlan.ip_free
cloud_current_count = len(
quads.get_current_schedules({"cloud": cloud_obj.name})
)
if assignment_obj and cloud_current_count > 0 and cloud_obj:
owner = assignment_obj.owner
ticket = assignment_obj.ticket
Expand Down

0 comments on commit c1c2e44

Please sign in to comment.