8000 fix(anta.cli): fix click options evaluation order by mtache · Pull Request #232 · aristanetworks/anta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(anta.cli): fix click options evaluation order #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions anta/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
@click.group()
@click.pass_context
@click.version_option(__version__)
@click.option("--username", show_envvar=True, help="Username to connect to EOS", required=True)
@click.option("--password", show_envvar=True, help="Password to connect to EOS", required=True)
@click.option("--timeout", show_envvar=True, default=5, help="Global connection timeout", show_default=True)
@click.option("--insecure/--secure", show_envvar=True, default=False, help="Disable SSH Host Key validation", show_default=True)
@click.option("--enable-password", show_envvar=True, help="Enable password if required to connect")
@click.option("--username", show_envvar=True, help="Username to connect to EOS", required=True, is_eager=True)
@click.option("--password", show_envvar=True, help="Password to connect to EOS", required=True, is_eager=True)
@click.option("--timeout", show_envvar=True, default=5, help="Global connection timeout", show_default=True, is_eager=True)
@click.option("--insecure/--secure", show_envvar=True, default=False, help="Disable SSH Host Key validation", show_default=True, is_eager=True)
@click.option("--enable-password", show_envvar=True, help="Enable password if required to connect", is_eager=True)
@click.option(
"--inventory",
"-i",
Expand Down
7 changes: 5 additions & 2 deletions anta/cli/utils.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import anta.loader
from anta.inventory import AntaInventory
from anta.tools.misc import exc_to_str, tb_to_str

logger = logging.getLogger(__name__)

Expand All @@ -34,7 +35,8 @@ def parse_inventory(ctx: click.Context, param: Option, value: str) -> AntaInvent
logger.info(f"Inventory {value} loaded")
return inventory
except Exception as exc: # pylint: disable=broad-exception-caught
ctx.fail(f"Unable to parse ANTA Inventory file '{value}': {str(exc)}")
logger.critical(tb_to_str(exc))
ctx.fail(f"Unable to parse ANTA Inventory file '{value}': {exc_to_str(exc)}")
return None


Expand All @@ -47,7 +49,8 @@ def setup_logging(ctx: click.Context, param: Option, value: str) -> str:
anta.loader.setup_logging(value)
return value
except Exception as exc: # pylint: disable=broad-exception-caught
ctx.fail(f"Unable to set ANTA logging level '{value}': {str(exc)}")
logger.critical(tb_to_str(exc))
ctx.fail(f"Unable to set ANTA logging level '{value}': {exc_to_str(exc)}")
return None


Expand Down
0