From 89d45d394fa9af574dcb48869df21aa87468c365 Mon Sep 17 00:00:00 2001 From: Attila Farkas <394097@mail.muni.cz> Date: Sun, 13 Jun 2021 19:37:10 +0200 Subject: [PATCH] Fix default output directory --- cyber_sandbox_creator/creator.py | 7 +++++-- cyber_sandbox_creator/scripts/create.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cyber_sandbox_creator/creator.py b/cyber_sandbox_creator/creator.py index 7639bf5..74f31ac 100644 --- a/cyber_sandbox_creator/creator.py +++ b/cyber_sandbox_creator/creator.py @@ -11,7 +11,8 @@ CONFIGURATION_PATH: Path = CSC_PATH / "conf/configuration.yml" FLAVORS_PATH: Path = CSC_PATH / "conf/flavors.yml" -def create(topology: Union[str, Path], output_dir: Union[str, Path], +def create(topology: Union[str, Path], + output_dir: Optional[Union[str, Path]] = None, ansible_installed: bool = False, border_router: bool = False, provisioning_dir: Optional[Union[str, Path]] = None, extra_vars: Optional[Union[str, Path]] = None, @@ -43,7 +44,9 @@ def create(topology: Union[str, Path], output_dir: Union[str, Path], raise ValueError(f"Invalid path to topology file \"{topology}\"") try: - if isinstance(output_dir, str): + if output_dir is None or not output_dir: + sandbox_path: Path = topology_path.parent / "sandbox" + elif isinstance(output_dir, str): sandbox_path: Path = Path(output_dir).resolve() elif isinstance(output_dir, Path): sandbox_path: Path = output_dir.resolve() diff --git a/cyber_sandbox_creator/scripts/create.py b/cyber_sandbox_creator/scripts/create.py index 5474975..5a660b8 100644 --- a/cyber_sandbox_creator/scripts/create.py +++ b/cyber_sandbox_creator/scripts/create.py @@ -34,7 +34,7 @@ args = parser.parse_args() if args.output_dir: output_dir: str = args.output_dir else: - output_dir: str = "sandbox" + output_dir: str = "" try: creator.create(args.topology_file, output_dir, args.ansible_installed, -- GitLab