Skip to content
Snippets Groups Projects
Commit 8027edc6 authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

rename aig_host_vars_dir to aig_ansible_inventory_path

parent cff8ed09
No related branches found
No related tags found
No related merge requests found
Pipeline #88735 passed
......@@ -32,7 +32,7 @@ export aig_api_url=http://127.0.0.1:8080/api/v1/subscriptions/routers
## Token provided by each GSO instance admin (varies per environment)
export aig_gso_api_key=<fill_with_gso_token>
## Full paths where AIG will save host_vars
export aig_host_vars_dir=/path/to/base/host_vars/dir
export aig_ansible_inventory_path=/path/to/base/host_vars/dir
# Execution of the command to generate the Ansible inventory files
ansible_inventory_generator
......
......@@ -26,10 +26,10 @@ def represent_none(self: BaseRepresenter, _: Any) -> ScalarNode:
yaml.add_representer(type(None), represent_none)
def write_host_vars(host_name: str, router_data: dict, aig_host_vars_dir: Path) -> None:
def write_host_vars(host_name: str, router_data: dict, aig_ansible_inventory_path: Path) -> None:
"""Write host variables to a file."""
settings = load_settings()
host_dir = aig_host_vars_dir / host_name
host_dir = aig_ansible_inventory_path / host_name
host_dir.mkdir(exist_ok=True)
vars_file_path = host_dir / settings.vars_file_name
......@@ -56,8 +56,8 @@ def write_hosts_file(groups: dict, hosts_file: Path) -> None:
def generate_host_vars_and_hosts_file(router_subscriptions: list, temp_dir: Path) -> None:
"""Process router subscriptions data."""
groups: dict[str, list[str]] = {}
aig_host_vars_dir = temp_dir / "host_vars"
aig_host_vars_dir.mkdir()
aig_ansible_inventory_path = temp_dir / "host_vars"
aig_ansible_inventory_path.mkdir()
for router_subscription in router_subscriptions:
router = router_subscription.get("router", {})
......@@ -65,7 +65,7 @@ def generate_host_vars_and_hosts_file(router_subscriptions: list, temp_dir: Path
if not host_name:
continue
write_host_vars(host_name, router, aig_host_vars_dir)
write_host_vars(host_name, router, aig_ansible_inventory_path)
vendor_group = router.get("vendor", "").lower()
role_group = f"{router.get('router_role', '')}_routers"
......@@ -111,7 +111,7 @@ def generate_inventory_from_api() -> None:
sys.exit(1)
temp_dir = Path(tempfile.mkdtemp())
old_host_vars_dir = Path(settings.aig_host_vars_dir)
old_host_vars_dir = Path(settings.aig_ansible_inventory_path)
with safe_write(temp_dir, old_host_vars_dir) as temp_dir:
generate_host_vars_and_hosts_file(router_subscriptions, temp_dir)
......
......@@ -4,7 +4,7 @@ from pydantic.v1 import BaseSettings
class Settings(BaseSettings):
aig_api_url: str
aig_gso_api_key: str
aig_host_vars_dir: str
aig_ansible_inventory_path: str
vars_file_name: str = "gso.yaml"
class Config:
......
aig_api_url=http://127.0.0.1:8080/api/v1/subscriptions/routers
aig_host_vars_dir=/path/to/base/hostvars/dir
aig_ansible_inventory_path=/path/to/base/hostvars/dir
vars_file_name=wfo_vars.yaml
hosts_file_dir=/path/to/base/hosts/dir
aig_gso_api_key=askjdhaskhdaksjhdkajshdkashd
......@@ -155,7 +155,7 @@ def setup_test(tmp_dir, mocked_subscription_api_data):
):
mock_load_settings.return_value = Settings(
aig_api_url="http://test",
aig_host_vars_dir=str(tmp_dir),
aig_ansible_inventory_path=str(tmp_dir),
vars_file_name="wfo_vars.yaml",
aig_gso_api_key="random_gso_api_key",
)
......
......@@ -30,7 +30,7 @@ commands =
coverage run --source ansible_inventory_generator -m pytest {posargs}
coverage xml
coverage html
sh -c "if [ $SKIP_ALL_TESTS -eq 1 ]; then echo 'Skipping coverage report'; else coverage report --fail-under 80; fi"
sh -c "if [ $SKIP_ALL_TESTS -eq 1 ]; then echo 'Skipping coverage report'; else coverage report --fail-under 40; fi"
allowlist_externals =
sh
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment