(self, hosts: Union[List[str], List[HostPlacementSpec]])
| 368 | return NotImplemented |
| 369 | |
| 370 | def set_hosts(self, hosts: Union[List[str], List[HostPlacementSpec]]) -> None: |
| 371 | # To backpopulate the .hosts attribute when using labels or count |
| 372 | # in the orchestrator backend. |
| 373 | if all(isinstance(h, HostPlacementSpec) for h in hosts): |
| 374 | # All items are HostPlacementSpec, normalize directly. |
| 375 | host_specs = cast(List[HostPlacementSpec], hosts) |
| 376 | self.hosts = [ |
| 377 | HostPlacementSpec( |
| 378 | normalize_hostname(h.hostname), |
| 379 | h.network, |
| 380 | h.name, |
| 381 | ) |
| 382 | for h in host_specs |
| 383 | ] |
| 384 | else: |
| 385 | # Otherwise, parse from strings |
| 386 | self.hosts = [ |
| 387 | HostPlacementSpec.parse(h, require_network=False) # type: ignore |
| 388 | for h in hosts if h |
| 389 | ] |
| 390 | |
| 391 | # deprecated |
| 392 | def filter_matching_hosts(self, _get_hosts_func: Callable) -> List[str]: |
no test coverage detected