machines/list: remove duplicate query_machines_by_tags
This commit is contained in:
@@ -31,26 +31,6 @@ def list_full_machines(flake: Flake) -> dict[str, Machine]:
|
|||||||
"""
|
"""
|
||||||
machines = list_machines(flake)
|
machines = list_machines(flake)
|
||||||
|
|
||||||
return convert_inventory_to_machines(flake, machines)
|
|
||||||
|
|
||||||
|
|
||||||
def query_machines_by_tags(
|
|
||||||
flake: Flake, tags: list[str]
|
|
||||||
) -> dict[str, InventoryMachine]:
|
|
||||||
"""
|
|
||||||
Query machines by their respective tags, if multiple tags are specified
|
|
||||||
then only machines that have those respective tags specified will be listed.
|
|
||||||
It is an intersection of the tags and machines.
|
|
||||||
"""
|
|
||||||
machines = list_machines(flake)
|
|
||||||
|
|
||||||
filtered_machines = {}
|
|
||||||
for machine_name, machine in machines.items():
|
|
||||||
machine_tags = machine.get("tags", [])
|
|
||||||
if all(tag in machine_tags for tag in tags):
|
|
||||||
filtered_machines[machine_name] = machine
|
|
||||||
|
|
||||||
return filtered_machines
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user