Skip to content

Commit 2f5a3db

Browse files
SIMPLE-7433 show all running nodes in compute hosts sysadmin (#146)
* SIMPLE-7433 nodes_count added to compute * SIMPLE-7433 nodes_count renamed to node_counts * Deprecated the nodes property --------- Co-authored-by: Tomas Mikuska <[email protected]>
1 parent c3f4f20 commit 2f5a3db

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

virl2_client/models/lab.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,8 @@ def update_lab_groups(
21352135
:returns: Updated objects consisting of group ID and permissions.
21362136
"""
21372137
warnings.warn(
2138-
"'Lab.update_lab_groups()' is deprecated. Use '.update_associations()' instead.",
2138+
"'Lab.update_lab_groups()' is deprecated. Use '.update_associations()'"
2139+
" instead.",
21392140
DeprecationWarning,
21402141
)
21412142
url = self._url_for("lab")

virl2_client/models/system.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import logging
2424
import time
2525
from typing import TYPE_CHECKING, Any
26+
import warnings
2627

2728
from virl2_client.exceptions import ControllerNotFound
2829

@@ -297,6 +298,7 @@ def add_compute_host_local(
297298
is_connected: bool,
298299
is_synced: bool,
299300
admission_state: str,
301+
node_counts: dict[str, int],
300302
nodes: list[str] | None = None,
301303
) -> ComputeHost:
302304
"""
@@ -310,6 +312,7 @@ def add_compute_host_local(
310312
:param is_connected: A boolean indicating if the compute host is connected.
311313
:param is_synced: A boolean indicating if the compute host is synced.
312314
:param admission_state: The admission state of the compute host.
315+
:param node_counts: Count of deployed and running nodes and orphans.
313316
:param nodes: A list of node IDs associated with the compute host.
314317
:returns: The added compute host.
315318
"""
@@ -323,6 +326,7 @@ def add_compute_host_local(
323326
is_connected,
324327
is_synced,
325328
admission_state,
329+
node_counts,
326330
nodes,
327331
)
328332
self._compute_hosts[compute_id] = new_compute_host
@@ -380,6 +384,7 @@ def __init__(
380384
is_connected: bool,
381385
is_synced: bool,
382386
admission_state: str,
387+
node_counts: dict[str, int],
383388
nodes: list[str] | None = None,
384389
):
385390
"""
@@ -394,7 +399,9 @@ def __init__(
394399
:param is_connected: Whether the compute host is connected.
395400
:param is_synced: Whether the compute host is synced.
396401
:param admission_state: The admission state of the compute host.
397-
:param nodes: The list of nodes associated with the compute host.
402+
:param node_counts: The counts of deployed and running nodes and orphans.
403+
:param nodes: DEPRECATED: replaced by node_counts.
404+
The list of node IDs associated with the compute host.
398405
"""
399406
self._system = system
400407
self._session: httpx.Client = system._session
@@ -406,6 +413,7 @@ def __init__(
406413
self._is_connected = is_connected
407414
self._is_synced = is_synced
408415
self._admission_state = admission_state
416+
self._node_counts = node_counts
409417
self._nodes = nodes if nodes is not None else []
410418

411419
def __str__(self):
@@ -461,9 +469,20 @@ def is_synced(self) -> bool:
461469
self._system.sync_compute_hosts_if_outdated()
462470
return self._is_synced
463471

472+
@property
473+
def node_counts(self) -> dict[str, int]:
474+
"""Return the counts of deployed and running nodes and orphans."""
475+
self._system.sync_compute_hosts_if_outdated()
476+
return self._node_counts
477+
464478
@property
465479
def nodes(self) -> list[str]:
466480
"""Return the list of nodes associated with the compute host."""
481+
warnings.warn(
482+
"'ComputeHost.nodes' is deprecated. Use 'ComputeHost.node_counts' or "
483+
"'ClientLibrary.get_diagnostics(DiagnosticsCategory.COMPUTES)' instead.",
484+
DeprecationWarning,
485+
)
467486
self._system.sync_compute_hosts_if_outdated()
468487
return self._nodes
469488

0 commit comments

Comments
 (0)