23
23
import logging
24
24
import time
25
25
from typing import TYPE_CHECKING , Any
26
+ import warnings
26
27
27
28
from virl2_client .exceptions import ControllerNotFound
28
29
@@ -297,6 +298,7 @@ def add_compute_host_local(
297
298
is_connected : bool ,
298
299
is_synced : bool ,
299
300
admission_state : str ,
301
+ node_counts : dict [str , int ],
300
302
nodes : list [str ] | None = None ,
301
303
) -> ComputeHost :
302
304
"""
@@ -310,6 +312,7 @@ def add_compute_host_local(
310
312
:param is_connected: A boolean indicating if the compute host is connected.
311
313
:param is_synced: A boolean indicating if the compute host is synced.
312
314
:param admission_state: The admission state of the compute host.
315
+ :param node_counts: Count of deployed and running nodes and orphans.
313
316
:param nodes: A list of node IDs associated with the compute host.
314
317
:returns: The added compute host.
315
318
"""
@@ -323,6 +326,7 @@ def add_compute_host_local(
323
326
is_connected ,
324
327
is_synced ,
325
328
admission_state ,
329
+ node_counts ,
326
330
nodes ,
327
331
)
328
332
self ._compute_hosts [compute_id ] = new_compute_host
@@ -380,6 +384,7 @@ def __init__(
380
384
is_connected : bool ,
381
385
is_synced : bool ,
382
386
admission_state : str ,
387
+ node_counts : dict [str , int ],
383
388
nodes : list [str ] | None = None ,
384
389
):
385
390
"""
@@ -394,7 +399,9 @@ def __init__(
394
399
:param is_connected: Whether the compute host is connected.
395
400
:param is_synced: Whether the compute host is synced.
396
401
: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.
398
405
"""
399
406
self ._system = system
400
407
self ._session : httpx .Client = system ._session
@@ -406,6 +413,7 @@ def __init__(
406
413
self ._is_connected = is_connected
407
414
self ._is_synced = is_synced
408
415
self ._admission_state = admission_state
416
+ self ._node_counts = node_counts
409
417
self ._nodes = nodes if nodes is not None else []
410
418
411
419
def __str__ (self ):
@@ -461,9 +469,20 @@ def is_synced(self) -> bool:
461
469
self ._system .sync_compute_hosts_if_outdated ()
462
470
return self ._is_synced
463
471
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
+
464
478
@property
465
479
def nodes (self ) -> list [str ]:
466
480
"""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
+ )
467
486
self ._system .sync_compute_hosts_if_outdated ()
468
487
return self ._nodes
469
488
0 commit comments