Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#142 cml nodes slow #144

Merged
merged 12 commits into from
Oct 31, 2023
2 changes: 1 addition & 1 deletion virl/about.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.2"
__version__ = "1.4.3"
6 changes: 6 additions & 0 deletions virl/cli/nodes/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ def nodes():
if current_lab:
lab = safe_join_existing_lab(current_lab, client)
if lab:
# Force an operational sync.
try:
lab.sync_operational_if_outdated()
except Exception:
pass

computes = {}
try:
computes = client.get_system_health()["computes"]
Expand Down
51 changes: 39 additions & 12 deletions virl/cli/views/nodes/node_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,66 @@ def node_list_table(nodes, computes):
click.secho("Here is a list of nodes in this lab")
table = list()
headers = ["ID", "Label", "Type"]
if len(computes.keys()) > 0:
if computes:
headers.append("Compute Node")

headers += ["State", "Wiped?", "L3 Address(es)"]
skip_types = []
for node in nodes:
# Skip a full operational sync per node.
node.lab.auto_sync = True
for sync in (
# "sync_statistics_if_outdated",
"sync_states_if_outdated",
"sync_l3_addresses_if_outdated",
"sync_topology_if_outdated",
):
try:
meth = getattr(node.lab, sync)
except AttributeError:
pass
else:
meth()

node.lab.auto_sync = False

tr = list()
if node.node_definition in skip_types:
continue

tr.append(node.id)
tr.append(node.label)
tr.append(node.node_definition)
if len(computes.keys()) > 0 and hasattr(node, "compute_id") and node.compute_id in computes:
tr.append(computes[node.compute_id]["hostname"])
elif len(computes.keys()) > 0:
try:
node_compute_id = node.compute_id
except AttributeError:
node_compute_id = None

if node_compute_id and node_compute_id in computes:
tr.append(computes[node_compute_id]["hostname"])
elif computes:
tr.append("Unknown")

color = "red"
if node.is_booted():
booted = node.is_booted()
if booted:
color = "green"
elif node.is_active():
color = "yellow"

tr.append(click.style(node.state, fg=color))
tr.append(node.state == "DEFINED_ON_CORE")
node_state = node.state
tr.append(click.style(node_state, fg=color))
tr.append(node_state == "DEFINED_ON_CORE")
intfs = []
if node.is_booted():
if booted:
for i in node.interfaces():
if i.discovered_ipv4:
intfs += i.discovered_ipv4
if i.discovered_ipv6:
intfs += i.discovered_ipv6
disc_ipv4 = i.discovered_ipv4
if disc_ipv4:
intfs += disc_ipv4

disc_ipv6 = i.discovered_ipv6
if disc_ipv6:
intfs += disc_ipv6

tr.append(",".join(intfs))
table.append(tr)
Expand Down