| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Script that merge a collection of catalogs into one AntaCatalog.""" |
| 5 |
|
| 6 |
from pathlib import Path |
| 7 |
|
| 8 |
from anta.catalog import AntaCatalog |
| 9 |
from anta.models import AntaTest |
| 10 |
|
| 11 |
CATALOG_SUFFIX = "-catalog.yml" |
| 12 |
CATALOG_DIR = "intended/test_catalogs/" |
| 13 |
|
| 14 |
if __name__ == "__main__": |
| 15 |
catalogs = [] |
| 16 |
for file in Path(CATALOG_DIR).glob("*" + CATALOG_SUFFIX): |
| 17 |
device = str(file).removesuffix(CATALOG_SUFFIX).removeprefix(CATALOG_DIR) |
| 18 |
print(f"Loading test catalog for device {device}") |
| 19 |
catalog = AntaCatalog.parse(file) |
| 20 |
|
| 21 |
for test in catalog.tests: |
| 22 |
test.inputs.filters = AntaTest.Input.Filters(tags={device}) |
| 23 |
catalogs.append(catalog) |
| 24 |
|
| 25 |
|
| 26 |
merged_catalog = AntaCatalog.merge_catalogs(catalogs) |
| 27 |
|
| 28 |
|
| 29 |
with Path("anta-catalog.yml").open("w") as f: |
| 30 |
f.write(merged_catalog.dump().yaml()) |