Skip to content

Commit

Permalink
status: check connections
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Sep 9, 2024
1 parent 0427a2f commit 371c2be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/warnet/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def copy_scenario_defaults(directory: Path):
)


def _connected():
def _connected(end="\n"):
tanks = get_mission("tank")
for tank in tanks:
# Get actual
Expand All @@ -73,11 +73,11 @@ def _connected():
if peer["connection_type"] == "manual":
actual += 1
expected = int(tank.metadata.annotations["init_peers"])
print(f"Tank {tank.metadata.name} peers expected: {expected}, actual: {actual}")
print(f"Tank {tank.metadata.name} peers expected: {expected}, actual: {actual}", end=end)
# Even if more edges are specified, bitcoind only allows
# 8 manual outbound connections
if min(8, expected) > actual:
print("Network not connected")
print("\nNetwork not connected")
return False
print("Network connected")
print("Network connected ")
return True
2 changes: 2 additions & 0 deletions src/warnet/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from rich.text import Text

from .k8s import get_mission
from .network import _connected


@click.command()
Expand Down Expand Up @@ -53,6 +54,7 @@ def status():
summary.append(f"\nTotal Tanks: {len(tanks)}", style="bold cyan")
summary.append(f" | Active Scenarios: {len(scenarios)}", style="bold green")
console.print(summary)
_connected(end="\r")


def _get_tank_status():
Expand Down

0 comments on commit 371c2be

Please sign in to comment.