Skip to content

Commit e6d1b33

Browse files
committed
linting
1 parent 8cde0fe commit e6d1b33

File tree

21 files changed

+812
-596
lines changed

21 files changed

+812
-596
lines changed

.yamllint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
extends: default
33

44
ignore: |
5+
/generated-configs
56
/.git
67
/.github
78
/docs/node_modules

docker-compose.override.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
services:
23
database:
34
environment:

generators/common.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ async def load_data(self) -> None:
161161

162162
# Add juniper_firewall group if any firewall roles are present
163163
firewall_roles = {"dc_firewall", "edge_firewall"}
164-
if any(item["role"] in firewall_roles for item in self.data["design"]["elements"]):
164+
if any(
165+
item["role"] in firewall_roles for item in self.data["design"]["elements"]
166+
):
165167
roles.append("juniper_firewall")
166168

167169
await self.client.filters(
@@ -434,7 +436,9 @@ def _get_device_template_name(self, device: Any) -> str | None:
434436
if hasattr(template, "peers") and template.peers:
435437
peer = template.peers[0]
436438
if hasattr(peer, "hfid") and peer.hfid:
437-
return peer.hfid[0] if isinstance(peer.hfid, list) else peer.hfid
439+
return (
440+
peer.hfid[0] if isinstance(peer.hfid, list) else peer.hfid
441+
)
438442
except (AttributeError, IndexError, TypeError):
439443
pass
440444

@@ -458,7 +462,9 @@ async def create_oob_connections(
458462
]
459463
else:
460464
# Skip devices where we can't determine the template
461-
self.log.debug(f"Skipping {device.name.value} - could not determine template")
465+
self.log.debug(
466+
f"Skipping {device.name.value} - could not determine template"
467+
)
462468
interfaces[device.name.value] = []
463469

464470
device_key = "oob" if connection_type == "management" else "console"

objects/bootstrap/02_providers.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ spec:
3333
# USED: Colocation/datacenter provider - used in objects/pop-1.yml and objects/pop-2.yml
3434
- name: "Equinix"
3535

36-
# USED: Generic provider - used in objects/dc-arista-s.yml, objects/dc-cisco-s.yml, objects/dc-juniper-s.yml, objects/dc-sonic-border-leafs.yml, objects/dc-cisco-s-border-leafs.yml
36+
# USED: Generic provider - used in objects/dc-arista-s.yml, objects/dc-cisco-s.yml,
37+
# objects/dc-juniper-s.yml, objects/dc-sonic-border-leafs.yml,
38+
# objects/dc-cisco-s-border-leafs.yml
3739
- name: "Technology Partner"

objects/bootstrap/03_clients.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ spec:
66
data: []
77
# UNUSED: All customers are not referenced in any loaded objects
88
# The "owner" field in ASN objects references providers (OrganizationProvider), not customers
9-
# The ServiceVirtualFabric schema has a customer relationship, but no ServiceVirtualFabric objects are loaded in bootstrap
10-
# The Topology schema has an optional owner relationship, but it's not used in loaded demo scenarios
9+
# The ServiceVirtualFabric schema has a customer relationship,
10+
# but no ServiceVirtualFabric objects are loaded in bootstrap
11+
# The Topology schema has an optional owner relationship,
12+
# but it's not used in loaded demo scenarios
1113
# - name: "Customer 1"
1214
# customer_id: "CUST001"
1315
# - name: "Customer 2"

scripts/bootstrap.py

Lines changed: 91 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@
3939
import requests
4040
from rich.console import Console
4141
from rich.panel import Panel
42-
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, TimeElapsedColumn, TimeRemainingColumn
42+
from rich.progress import (
43+
Progress,
44+
SpinnerColumn,
45+
TextColumn,
46+
BarColumn,
47+
TimeElapsedColumn,
48+
TimeRemainingColumn,
49+
)
4350
from rich.rule import Rule
4451
from rich import box
4552

@@ -60,7 +67,7 @@ def check_infrahub_ready(max_retries: int = 30, sleep_time: int = 2) -> bool:
6067
style="magenta",
6168
complete_style="bright_green",
6269
finished_style="bold bright_green",
63-
pulse_style="bright_magenta"
70+
pulse_style="bright_magenta",
6471
),
6572
TextColumn("[bold bright_cyan]{task.percentage:>3.0f}%"),
6673
TextColumn("•", style="dim"),
@@ -83,37 +90,41 @@ def check_infrahub_ready(max_retries: int = 30, sleep_time: int = 2) -> bool:
8390
time.sleep(sleep_time)
8491

8592
console.print()
86-
console.print(Panel(
87-
"[red]✗ ERROR: Infrahub is not responding[/red]\n\n"
88-
"[dim]Please ensure Infrahub is running with:[/dim]\n"
89-
" [bold]uv run invoke start[/bold]\n\n"
90-
"[dim]Check container status with:[/dim]\n"
91-
" [bold]docker ps[/bold]",
92-
title="Connection Error",
93-
border_style="red",
94-
box=box.SIMPLE
95-
))
93+
console.print(
94+
Panel(
95+
"[red]✗ ERROR: Infrahub is not responding[/red]\n\n"
96+
"[dim]Please ensure Infrahub is running with:[/dim]\n"
97+
" [bold]uv run invoke start[/bold]\n\n"
98+
"[dim]Check container status with:[/dim]\n"
99+
" [bold]docker ps[/bold]",
100+
title="Connection Error",
101+
border_style="red",
102+
box=box.SIMPLE,
103+
)
104+
)
96105
return False
97106

98107

99-
def run_command(command: str, description: str, step: str, color: str = "cyan", icon: str = "") -> bool:
108+
def run_command(
109+
command: str, description: str, step: str, color: str = "cyan", icon: str = ""
110+
) -> bool:
100111
"""Run a shell command and display output."""
101112
icon_display = f"{icon} " if icon else ""
102-
console.print(f"\n[bold {color} on black]{step}[/bold {color} on black] {icon_display}[bold white]{description}[/bold white]")
113+
console.print(
114+
f"\n[bold {color} on black]{step}[/bold {color} on black] {icon_display}[bold white]{description}[/bold white]"
115+
)
103116

104117
try:
105-
subprocess.run(
106-
command,
107-
shell=True,
108-
check=True,
109-
capture_output=False,
110-
text=True
111-
)
118+
subprocess.run(command, shell=True, check=True, capture_output=False, text=True)
112119
# Use the step's color for the completion message with a colored background box and matching icon
113-
console.print(f"[bold bright_green on black]✓[/bold bright_green on black] {icon_display}[bold {color}]{description} completed[/bold {color}]")
120+
console.print(
121+
f"[bold bright_green on black]✓[/bold bright_green on black] {icon_display}[bold {color}]{description} completed[/bold {color}]"
122+
)
114123
return True
115124
except subprocess.CalledProcessError as e:
116-
console.print(f"[bold red]✗[/bold red] {icon_display}[red]Failed: {description}[/red]")
125+
console.print(
126+
f"[bold red]✗[/bold red] {icon_display}[red]Failed: {description}[/red]"
127+
)
117128
console.print(f"[dim]Error: {e}[/dim]")
118129
return False
119130

@@ -128,7 +139,7 @@ def wait_for_repository_sync(seconds: int = 120) -> None:
128139
style="yellow",
129140
complete_style="bright_green",
130141
finished_style="bold bright_green",
131-
pulse_style="bright_yellow"
142+
pulse_style="bright_yellow",
132143
),
133144
TextColumn("[bold bright_cyan]{task.percentage:>3.0f}%"),
134145
TextColumn("•", style="dim"),
@@ -143,25 +154,29 @@ def wait_for_repository_sync(seconds: int = 120) -> None:
143154
time.sleep(1)
144155
progress.update(task, advance=1)
145156

146-
console.print("[bold bright_green on black]✓[/bold bright_green on black] 🔄 [bold bright_yellow]Repository sync complete[/bold bright_yellow]\n")
157+
console.print(
158+
"[bold bright_green on black]✓[/bold bright_green on black] 🔄 [bold bright_yellow]Repository sync complete[/bold bright_yellow]\n"
159+
)
147160

148161

149162
def main(branch: str = "main") -> int:
150163
"""Main bootstrap function."""
151164
console.print()
152-
console.print(Panel(
153-
f"[bold bright_blue]🚀 Infrahub Demo Bootstrap[/bold bright_blue]\n"
154-
f"[bright_cyan]Branch:[/bright_cyan] [bold yellow]{branch}[/bold yellow]\n\n"
155-
"[dim]This will load:[/dim]\n"
156-
" [blue]•[/blue] Schemas\n"
157-
" [magenta]•[/magenta] Menu definitions\n"
158-
" [yellow]•[/yellow] Bootstrap data\n"
159-
" [green]•[/green] Security data\n"
160-
" [bright_magenta]•[/bright_magenta] Demo repository",
161-
border_style="bright_blue",
162-
box=box.SIMPLE,
163-
title="[bold bright_blue]Bootstrap Process[/bold bright_blue]"
164-
))
165+
console.print(
166+
Panel(
167+
f"[bold bright_blue]🚀 Infrahub Demo Bootstrap[/bold bright_blue]\n"
168+
f"[bright_cyan]Branch:[/bright_cyan] [bold yellow]{branch}[/bold yellow]\n\n"
169+
"[dim]This will load:[/dim]\n"
170+
" [blue]•[/blue] Schemas\n"
171+
" [magenta]•[/magenta] Menu definitions\n"
172+
" [yellow]•[/yellow] Bootstrap data\n"
173+
" [green]•[/green] Security data\n"
174+
" [bright_magenta]•[/bright_magenta] Demo repository",
175+
border_style="bright_blue",
176+
box=box.SIMPLE,
177+
title="[bold bright_blue]Bootstrap Process[/bold bright_blue]",
178+
)
179+
)
165180

166181
# Check if Infrahub is ready
167182
if not check_infrahub_ready():
@@ -173,35 +188,35 @@ def main(branch: str = "main") -> int:
173188
"description": "Loading schemas",
174189
"command": f"uv run infrahubctl schema load schemas --branch {branch}",
175190
"color": "blue",
176-
"icon": "📋"
191+
"icon": "📋",
177192
},
178193
{
179194
"step": "[2/7]",
180195
"description": "Loading menu definitions",
181196
"command": f"uv run infrahubctl menu load menu --branch {branch}",
182197
"color": "magenta",
183-
"icon": "📑"
198+
"icon": "📑",
184199
},
185200
{
186201
"step": "[3/7]",
187202
"description": "Loading bootstrap data (locations, platforms, roles, etc.)",
188203
"command": f"uv run infrahubctl object load objects/bootstrap/ --branch {branch}",
189204
"color": "yellow",
190-
"icon": "📦"
205+
"icon": "📦",
191206
},
192207
{
193208
"step": "[4/7]",
194209
"description": "Loading security data (zones, policies, rules)",
195210
"command": f"uv run infrahubctl object load objects/security/ --branch {branch}",
196211
"color": "green",
197-
"icon": "🔒"
212+
"icon": "🔒",
198213
},
199214
{
200215
"step": "[5/7]",
201216
"description": "Populating security relationships",
202217
"command": "uv run python scripts/populate_security_relationships.py",
203218
"color": "cyan",
204-
"icon": "🔗"
219+
"icon": "🔗",
205220
},
206221
]
207222

@@ -212,7 +227,7 @@ def main(branch: str = "main") -> int:
212227
step_info["description"],
213228
step_info["step"],
214229
step_info["color"],
215-
step_info["icon"]
230+
step_info["icon"],
216231
):
217232
console.print("\n[bold red]✗ Bootstrap failed![/bold red]")
218233
return 1
@@ -222,21 +237,32 @@ def main(branch: str = "main") -> int:
222237
console.print(Rule(style=f"dim {step_info['color']}"))
223238

224239
# Add repository (may already exist)
225-
console.print("\n[bold bright_magenta on black][6/7][/bold bright_magenta on black] 📚 [bold white]Adding demo repository[/bold white]")
240+
console.print(
241+
"\n[bold bright_magenta on black][6/7][/bold bright_magenta on black] 📚 [bold white]Adding demo repository[/bold white]"
242+
)
226243
result = subprocess.run(
227244
"uv run infrahubctl repository add DEMO https://github.com/opsmill/infrahub-demo.git --ref main --read-only --ref main",
228245
shell=True,
229246
capture_output=True,
230-
text=True
247+
text=True,
231248
)
232249

233250
if result.returncode == 0:
234-
console.print("[bold bright_green on black]✓[/bold bright_green on black] 📚 [bold bright_magenta]Repository added[/bold bright_magenta]")
251+
console.print(
252+
"[bold bright_green on black]✓[/bold bright_green on black] 📚 [bold bright_magenta]Repository added[/bold bright_magenta]"
253+
)
235254
else:
236-
if "already exists" in result.stderr.lower() or "already exists" in result.stdout.lower():
237-
console.print("[bold yellow on black]⚠[/bold yellow on black] 📚 [bold bright_magenta]Repository already exists, skipping...[/bold bright_magenta]")
255+
if (
256+
"already exists" in result.stderr.lower()
257+
or "already exists" in result.stdout.lower()
258+
):
259+
console.print(
260+
"[bold yellow on black]⚠[/bold yellow on black] 📚 [bold bright_magenta]Repository already exists, skipping...[/bold bright_magenta]"
261+
)
238262
else:
239-
console.print("[bold red]✗[/bold red] 📚 [red]Failed to add repository[/red]")
263+
console.print(
264+
"[bold red]✗[/bold red] 📚 [red]Failed to add repository[/red]"
265+
)
240266
console.print(f"[dim]{result.stderr}[/dim]")
241267

242268
console.print(Rule(style="dim bright_magenta"))
@@ -254,24 +280,26 @@ def main(branch: str = "main") -> int:
254280
"Event actions loading",
255281
"",
256282
"bright_cyan",
257-
"⚡"
283+
"⚡",
258284
)
259285

260286
console.print(Rule(style="dim bright_cyan"))
261287

262288
# Display completion message
263289
console.print()
264-
console.print(Panel(
265-
f"[bold bright_green]🎉 Bootstrap Complete![/bold bright_green]\n\n"
266-
f"[dim]All data has been loaded into Infrahub[/dim]\n"
267-
f"[bright_cyan]Branch:[/bright_cyan] [bold yellow]{branch}[/bold yellow]\n\n"
268-
"[bold bright_magenta]Next steps:[/bold bright_magenta]\n"
269-
" [green]•[/green] Demo a DC design: [bold bright_cyan]uv run invoke demo-dc-arista[/bold bright_cyan]\n"
270-
" [green]•[/green] Create a Proposed Change",
271-
title="[bold bright_green]✓ Success[/bold bright_green]",
272-
border_style="bright_green",
273-
box=box.SIMPLE
274-
))
290+
console.print(
291+
Panel(
292+
f"[bold bright_green]🎉 Bootstrap Complete![/bold bright_green]\n\n"
293+
f"[dim]All data has been loaded into Infrahub[/dim]\n"
294+
f"[bright_cyan]Branch:[/bright_cyan] [bold yellow]{branch}[/bold yellow]\n\n"
295+
"[bold bright_magenta]Next steps:[/bold bright_magenta]\n"
296+
" [green]•[/green] Demo a DC design: [bold bright_cyan]uv run invoke demo-dc-arista[/bold bright_cyan]\n"
297+
" [green]•[/green] Create a Proposed Change",
298+
title="[bold bright_green]✓ Success[/bold bright_green]",
299+
border_style="bright_green",
300+
box=box.SIMPLE,
301+
)
302+
)
275303

276304
return 0
277305

@@ -285,7 +313,7 @@ def main(branch: str = "main") -> int:
285313
"-b",
286314
type=str,
287315
default="main",
288-
help="Branch to load data into (default: main)"
316+
help="Branch to load data into (default: main)",
289317
)
290318
args = parser.parse_args()
291319

0 commit comments

Comments
 (0)