Exemplo n.º 1
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--psk",
        help="Pre-shared key",
        type=lambda x: x if len(x) > 0 else None,
        default=None,
        dest="psk",
    )
Exemplo n.º 2
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--subscriber-id",
        help="Unique subscriber ID (default: resoto.worker)",
        default="resoto.worker",
        dest="subscriber_id",
        type=str,
    )
Exemplo n.º 3
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--web-path",
         help="Web root in browser (default: /)",
         default="/",
         dest="web_path",
         type=str,
     )
Exemplo n.º 4
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--example-region",
         help="Example Region",
         dest="example_region",
         type=str,
         default=None,
         nargs="+",
     )
Exemplo n.º 5
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--override",
         help="Override config attribute(s)",
         dest="config_override",
         type=str,
         default=[],
         nargs="+",
     )
Exemplo n.º 6
0
    def add_args(arg_parser: ArgumentParser) -> None:
        """Add args to the arg parser

        This adds the PluginLoader()'s own args.
        """
        arg_parser.add_argument(
            "--collector",
            help="Collectors to load (default: all)",
            dest="collector",
            type=str,
            default=None,
            nargs="+",
        )
Exemplo n.º 7
0
    def add_args(arg_parser: ArgumentParser) -> None:
        """Add args to the arg parser

        This adds the GraphContainer()'s own args.
        """
        arg_parser.add_argument(
            "--tag-as-metrics-label",
            help="Tag to use as metrics label",
            dest="metrics_tag_as_label",
            type=str,
            default=None,
            nargs="+",
        )
Exemplo n.º 8
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--cleanup-aws-vpcs",
         help="Cleanup AWS VPCs (default: False)",
         dest="cleanup_aws_vpcs",
         action="store_true",
         default=False,
     )
     arg_parser.add_argument(
         "--cleanup-aws-vpcs-config",
         help="Path to Cleanup AWS VPCs Plugin Config",
         default=None,
         dest="cleanup_aws_vpcs_config",
     )
Exemplo n.º 9
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--cleanup-aws-loadbalancers",
         help="Cleanup unused AWS Loadbalancers (default: False)",
         dest="cleanup_aws_loadbalancers",
         action="store_true",
         default=False,
     )
     arg_parser.add_argument(
         "--cleanup-aws-loadbalancers-age",
         help="Cleanup unused AWS Loadbalancers Age (default: 7 days)",
         default="7 days",
         dest="cleanup_aws_loadbalancers_age",
     )
Exemplo n.º 10
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--resotocore-uri",
        help="resotocore URI (default: http://localhost:8900)",
        default="http://localhost:8900",
        dest="resotocore_uri",
    )
    arg_parser.add_argument(
        "--resotocore-ws-uri",
        help="resotocore Websocket URI (default: ws://localhost:8900)",
        default="ws://localhost:8900",
        dest="resotocore_ws_uri",
    )
    arg_parser.add_argument(
        "--resotocore-graph",
        help="resotocore graph name (default: resoto)",
        default="resoto",
        dest="resotocore_graph",
    )
    arg_parser.add_argument(
        "--timeout",
        help="Metrics generation timeout in seconds (default: 300)",
        default=300,
        dest="timeout",
        type=int,
    )
Exemplo n.º 11
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--cleanup-volumes",
         help="Cleanup unused Volumes (default: False)",
         dest="cleanup_volumes",
         action="store_true",
         default=False,
     )
     arg_parser.add_argument(
         "--cleanup-volumes-age",
         help="Cleanup unused Volumes Age (default: 14 days)",
         default="14 days",
         dest="cleanup_volumes_age",
     )
Exemplo n.º 12
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--fork",
        help="Use forked process instead of threads (default: False)",
        dest="fork",
        action="store_true",
    )
    arg_parser.add_argument(
        "--pool-size",
        help="Collector thread/process pool size (default: 5)",
        dest="pool_size",
        default=5,
        type=int,
    )
Exemplo n.º 13
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--tagvalidator-config",
         help="Path to Tag Validator Config",
         default=None,
         dest="tagvalidator_config",
     )
     arg_parser.add_argument(
         "--tagvalidator-dry-run",
         help="Tag Validator Dry Run",
         dest="tagvalidator_dry_run",
         action="store_true",
         default=False,
     )
Exemplo n.º 14
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--cleanup-aws-alarms",
         help="Cleanup AWS Cloudwatch Alarms (default: False)",
         dest="cleanup_aws_alarms",
         action="store_true",
         default=False,
     )
     arg_parser.add_argument(
         "--cleanup-aws-alarms-config",
         help="Path to Cleanup AWS Cloudwatch Alarms Plugin Config",
         default=None,
         dest="cleanup_aws_alarms_config",
     )
Exemplo n.º 15
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--debug-dump-json",
        help="Dump the generated json data (default: False)",
        dest="debug_dump_json",
        action="store_true",
    )
    arg_parser.add_argument(
        "--tempdir",
        help="Directory to create temporary files in (default: system default)",
        default=None,
        dest="tempdir",
        type=str,
    )
Exemplo n.º 16
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--web-port",
         help="Web Port (default 9955)",
         default=9955,
         dest="web_port",
         type=int,
     )
     arg_parser.add_argument(
         "--web-host",
         help="IP to bind to (default: ::)",
         default="::",
         dest="web_host",
         type=str,
     )
Exemplo n.º 17
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--ignore-deferred-connections",
        help="Do not try to resolve deferred edges",
        dest="ignore_deferred_connections",
        action="store_true",
        default=False,
    )
    arg_parser.add_argument(
        "--graph-merge-kind",
        help="Resource kind to merge graph at (default: cloud)",
        dest="graph_merge_kind",
        type=str,
        choices=["cloud", "account"],
        default="cloud",
    )
Exemplo n.º 18
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--digitalocean-api-tokens",
         help="DigitalOcean API tokens for the teams to be collected",
         dest="digitalocean_api_tokens",
         type=str,
         default=[],
         nargs="+",
     )
     arg_parser.add_argument(
         "--digitalocean-spaces-access-keys",
         help="DigitalOcean Spaces access keys for the teams to be collected, separated by colons",
         dest="digitalocean_spaces_access_keys",
         type=str,
         default=[],
         nargs="+",
     )
Exemplo n.º 19
0
    def add_args(arg_parser: ArgumentParser) -> None:
        arg_parser.add_argument(
            "--vsphere-user",
            help="VSphere user name",
            dest="vsphere_user",
            type=str,
            default=None,
        )

        arg_parser.add_argument(
            "--vsphere-password",
            help="VSphere user password",
            dest="vsphere_password",
            type=str,
            default=None,
        )

        arg_parser.add_argument(
            "--vsphere-host",
            help="VSphere Host address",
            dest="vsphere_host",
            type=str,
            default=None,
        )

        arg_parser.add_argument(
            "--vsphere-port",
            help="VSphere Region",
            dest="vsphere_port",
            type=int,
            default=443,
        )

        arg_parser.add_argument(
            "--vsphere-insecure",
            help="VSphere insecure connection. Do not verify certificates",
            dest="vsphere_insecure",
            action="store_true",
        )
Exemplo n.º 20
0
def add_args(arg_parser: ArgumentParser) -> None:
    AWSPlugin.add_args(arg_parser)
    arg_parser.add_argument(
        "--aws-s3-bucket",
        help="AWS S3 Bucket (default: None)",
        dest="aws_s3_bucket",
        required=True,
        default=None,
    )
    arg_parser.add_argument(
        "--aws-s3-prefix",
        help="AWS S3 Prefix (default: None)",
        dest="aws_s3_prefix",
        type=str,
        default="",
    )
    arg_parser.add_argument(
        "--aws-s3-mtime",
        help="AWS S3 Mtime (default: None)",
        dest="aws_s3_mtime",
        type=str,
        default=None,
    )
    arg_parser.add_argument(
        "--aws-s3-pattern",
        help="AWS S3 Pattern (default: None)",
        dest="aws_s3_pattern",
        type=str,
        default=None,
    )
    arg_parser.add_argument(
        "--aws-s3-yes",
        help="AWS S3 delete without asking (default: False)",
        dest="aws_s3_yes",
        action="store_true",
        default=False,
    )
Exemplo n.º 21
0
 def add_args(arg_parser: ArgumentParser, ca_only: bool = False) -> None:
     arg_parser.add_argument(
         "--ca-cert",
         help="Path to custom CA certificate file",
         default=None,
         type=str,
         dest="ca_cert",
     )
     if not ca_only:
         arg_parser.add_argument(
             "--cert",
             help="Path to custom certificate file",
             default=None,
             type=str,
             dest="cert",
         )
         arg_parser.add_argument(
             "--cert-key",
             help="Path to custom certificate key file",
             default=None,
             type=str,
             dest="cert_key",
         )
         arg_parser.add_argument(
             "--cert-key-pass",
             help="Passphrase for certificate key file",
             default=None,
             type=str,
             dest="cert_key_pass",
         )
     arg_parser.add_argument(
         "--no-verify-certs",
         help="Turn off certificate verification",
         default=True,
         dest="verify_certs",
         action="store_false",
     )
Exemplo n.º 22
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--aws-access-key-id", help="AWS Access Key ID", dest="aws_access_key_id"
    )
    arg_parser.add_argument(
        "--aws-secret-access-key",
        help="AWS Secret Access Key",
        dest="aws_secret_access_key",
    )
    arg_parser.add_argument("--aws-role", help="AWS IAM Role", dest="aws_role")
    arg_parser.add_argument(
        "--aws-role-override",
        help="Override any stored roles (e.g. from remote graphs) (default: False)",
        dest="aws_role_override",
        action="store_true",
        default=False,
    )
Exemplo n.º 23
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--resotocore-uri",
        help="resotocore URI (default: http://localhost:8900)",
        default="http://localhost:8900",
        dest="resotocore_uri",
    )
    arg_parser.add_argument(
        "--resotocore-ws-uri",
        help="resotocore Websocket URI (default: ws://localhost:8900)",
        default="ws://localhost:8900",
        dest="resotocore_ws_uri",
    )
    arg_parser.add_argument(
        "--resotocore-graph",
        help="resotocore graph name (default: resoto)",
        default="resoto",
        dest="resotocore_graph",
    )
Exemplo n.º 24
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--cleanup",
         help="Enable cleanup of resources (default: False)",
         dest="cleanup",
         action="store_true",
         default=False,
     )
     arg_parser.add_argument(
         "--cleanup-pool-size",
         help="Cleanup thread pool size (default: 10)",
         dest="cleanup_pool_size",
         default=10,
         type=int,
     )
     arg_parser.add_argument(
         "--cleanup-dry-run",
         help="Cleanup dry run (default: False)",
         dest="cleanup_dry_run",
         action="store_true",
         default=False,
     )
Exemplo n.º 25
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--slack-bot-token",
         help="Slack Bot Token (default env $SLACK_BOT_TOKEN)",
         default=os.environ.get("SLACK_BOT_TOKEN"),
         dest="slack_bot_token",
         type=str,
     )
     arg_parser.add_argument(
         "--slack-include-archived",
         help="Include archived slack channels",
         dest="slack_include_archived",
         action="store_true",
         default=False,
     )
     arg_parser.add_argument(
         "--slack-do-not-verify-cert",
         help="Do not verify the Slack API server TLS certificate",
         dest="slack_do_not_verify_ssl",
         action="store_true",
         default=False,
     )
Exemplo n.º 26
0
 def add_args(arg_parser: ArgumentParser) -> None:
     arg_parser.add_argument(
         "--onelogin-region",
         help="OneLogin Region",
         dest="onelogin_region",
         type=str,
         default=os.environ.get("ONELOGIN_REGION", "us"),
     )
     arg_parser.add_argument(
         "--onelogin-client-id",
         help="OneLogin Client ID",
         dest="onelogin_client_id",
         type=str,
         default=os.environ.get("ONELOGIN_CLIENT_ID"),
     )
     arg_parser.add_argument(
         "--onelogin-client-secret",
         help="OneLogin Client Secret",
         dest="onelogin_client_secret",
         type=str,
         default=os.environ.get("ONELOGIN_CLIENT_SECRET"),
     )
Exemplo n.º 27
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--timeout",
        help="Collection/cleanup Timeout in seconds (default: 10800)",
        default=10800,
        dest="timeout",
        type=int,
    )
    arg_parser.add_argument(
        "--web-port",
        help="Web Port (default 9955)",
        default=9956,
        dest="web_port",
        type=int,
    )
    arg_parser.add_argument(
        "--web-host",
        help="IP to bind to (default: ::)",
        default="::",
        dest="web_host",
        type=str,
    )
Exemplo n.º 28
0
def add_args(arg_parser: ArgumentParser) -> None:
    AWSPlugin.add_args(arg_parser)
    arg_parser.add_argument(
        "--aws-s3-db",
        help="Path to local AWS S3 database file",
        dest="aws_s3_db",
        default=":memory:",
    )
    arg_parser.add_argument(
        "--aws-s3-db-debug",
        help="Debug SQL queries (default: False)",
        dest="aws_s3_db_debug",
        action="store_true",
        default=False,
    )
    arg_parser.add_argument(
        "--aws-s3-bucket",
        help="AWS S3 Bucket to collect (default: all)",
        dest="aws_s3_bucket",
        default=None,
    )
    arg_parser.add_argument(
        "--aws-s3-skip-checks",
        help="Skip SQL exists checks (default: False)",
        dest="aws_s3_skip_checks",
        action="store_true",
        default=False,
    )
    arg_parser.add_argument(
        "--aws-s3-collect",
        help="Collect from S3 (default: False)",
        dest="aws_s3_collect",
        action="store_true",
        default=False,
    )
    default_history_file = pathlib.Path.home() / ".resoto_s3_history"
    cli_history_default = None
    if default_history_file.exists():
        cli_history_default = str(default_history_file)
    arg_parser.add_argument(
        "--aws-s3-cli-history",
        help=("Path to AWS S3 CLI history file"
              " (default: None or ~/.resoto_s3_history if exists)"),
        dest="aws_s3_cli_history",
        type=str,
        default=cli_history_default,
    )
Exemplo n.º 29
0
def parse_args(args: Optional[List[str]] = None, namespace: Optional[str] = None) -> Namespace:
    def is_file(message: str) -> Callable[[str], str]:
        def check_file(path: str) -> str:
            if os.path.isfile(path):
                return path
            else:
                raise AttributeError(f"{message}: path {path} is not a directory!")

        return check_file

    def is_dir(message: str) -> Callable[[str], str]:
        def check_dir(path: str) -> str:
            if os.path.isdir(path):
                return path
            else:
                raise AttributeError(f"{message}: path {path} is not a directory!")

        return check_dir

    def is_url(message: str) -> Callable[[str], str]:
        def check_url(url: str) -> str:
            try:
                urlparse(url)
                return url
            except ValueError as ex:
                raise AttributeError(f"{message}: url {url} can not be parsed!") from ex

        return check_url

    parser = ArgumentParser(
        env_args_prefix="RESOTOCORE_",
        description="Maintains graphs of resources of any shape.",
        epilog="Keeps all the things.",
    )
    jwt_add_args(parser)
    parser.add_argument(
        "--log-level",
        default="info",
        help="Log level (default: info)",
    )
    parser.add_argument(
        "--graphdb-server",
        default="http://localhost:8529",
        dest="graphdb_server",
        help="Graph database server (default: http://localhost:8529)",
    )
    parser.add_argument(
        "--graphdb-database",
        default="resoto",
        dest="graphdb_database",
        help="Graph database name (default: resoto)",
    )
    parser.add_argument(
        "--graphdb-username",
        default="resoto",
        dest="graphdb_username",
        help="Graph database login (default: resoto)",
    )
    parser.add_argument(
        "--graphdb-password",
        default="",
        dest="graphdb_password",
        help='Graph database password (default: "")',
    )
    parser.add_argument(
        "--graphdb-root-password",
        default="",
        dest="graphdb_root_password",
        help="Graph root database password used for creating user and database if not existent.",
    )
    parser.add_argument(
        "--graphdb-bootstrap-do-not-secure",
        default=False,
        action="store_true",
        dest="graphdb_bootstrap_do_not_secure",
        help="Leave an empty root password during system setup process.",
    )
    parser.add_argument(
        "--graphdb-type",
        default="arangodb",
        dest="graphdb_type",
        help="Graph database type (default: arangodb)",
    )
    parser.add_argument(
        "--graphdb-no-ssl-verify",
        action="store_true",
        dest="graphdb_no_ssl_verify",
        help="If the connection should not be verified (default: False)",
    )
    parser.add_argument(
        "--graphdb-request-timeout",
        type=int,
        default=900,
        dest="graphdb_request_timeout",
        help="Request timeout in seconds (default: 900)",
    )
    parser.add_argument(
        "--plantuml-server",
        default="http://plantuml.resoto.org:8080",
        help="PlantUML server URI for UML image rendering.",
    )
    parser.add_argument(
        "--host",
        type=str,
        default="localhost",
        nargs="+",
        help="TCP host(s) to bind on (default: localhost)",
    )
    parser.add_argument(
        "--port",
        type=int,
        default=8900,
        help="TCP port to bind on (default: 8900)",
    )
    parser.add_argument(
        "--merge_max_wait_time_seconds",
        type=int,
        default=3600,
        help="Max waiting time to complete a merge graph action.",
    )
    parser.add_argument("--debug", default=False, action="store_true", help=argparse.SUPPRESS)
    parser.add_argument(
        "--analytics-opt-out",
        default=False,
        action="store_true",
        help="Stop collecting analytics data.",
    )
    parser.add_argument(
        "--ui-path",
        type=is_dir("can not parse --ui-dir"),
        help="The directory where the UI is installed. This directory will be served under /ui/.",
    )
    parser.add_argument(
        "--tsdb-proxy-url",
        type=is_url("can not parse --tsdb-proxy-url"),
        help="The url to the time series database. This path will be served under /tsdb/.",
    )
    parser.add_argument(
        "--tls-cert",
        type=is_file("can not parse --tls-cert"),
        help="Path to a single file in PEM format containing the certificate as well as any number "
        "of CA certificates needed to establish the certificate’s authenticity.",
    )
    parser.add_argument(
        "--tls-key",
        type=is_file("can not parse --tls-key"),
        help="Path to a file containing the private key. "
        "If not defined the private key will be taken from certfile as well.",
    )
    parser.add_argument(
        "--tls-password",
        type=str,
        help="Optional password to decrypt the private key file.",
    )
    parser.add_argument(
        "--cli-default-graph",
        type=str,
        default="resoto",
        dest="cli_default_graph",
        help="Use this graph for CLI actions, if no graph is specified explicitly.",
    )
    parser.add_argument(
        "--cli-default-section",
        type=str,
        default="reported",
        dest="cli_default_section",
        help="Use this graph section by default, if no section is specified."
        "Relative paths will be interpreted with respect to this section.",
    )
    parser.add_argument("--version", action="store_true", help="Print the version of resotocore and exit.")
    parser.add_argument(
        "--jobs",
        nargs="*",
        type=argparse.FileType("r"),
        help="Read job definitions from given file.",
    )
    parser.add_argument(
        "--start-collect-on-subscriber-connect",
        default=False,
        action="store_true",
        help="Start the collect workflow, when the first handling actor connects to the system.",
    )
    parser.add_argument(
        "---graph-update-abort-after",
        dest="graph_updates_abort_after",
        default="4h",
        type=parse_duration,
        help="If a graph update takes longer than this duration, the update is aborted.",
    )
    parsed: Namespace = parser.parse_args(args if args else [], namespace)

    if parsed.version:
        # print here on purpose, since logging is not set up yet.
        print(f"resotocore {version()}")
        sys.exit(0)

    return parsed
Exemplo n.º 30
0
def add_args(arg_parser: ArgumentParser) -> None:
    arg_parser.add_argument(
        "--resotocore-uri",
        help="resotocore URI (default: http://localhost:8900)",
        default="http://localhost:8900",
        dest="resotocore_uri",
    )
    arg_parser.add_argument(
        "--resotocore-ws-uri",
        help="resotocore Websocket URI (default: ws://localhost:8900)",
        default="ws://localhost:8900",
        dest="resotocore_ws_uri",
    )
    arg_parser.add_argument(
        "--resotocore-section",
        help=
        "All queries are interpreted with this section name. If not set, the server default is used.",
        dest="resotocore_section",
    )
    arg_parser.add_argument(
        "--resotocore-graph",
        help=
        "The name of the graph to use by default. If not set, the server default is used.",
        dest="resotocore_graph",
    )
    arg_parser.add_argument(
        "--download-directory",
        help="If files are received, they are written to this directory.",
        default=".",
        dest="download_directory",
    )
    arg_parser.add_argument(
        "--no-color",
        help=
        "Output should be rendered plain without any color escape sequences.",
        dest="no_color",
        action="store_true",
        default=False,
    )
    arg_parser.add_argument(
        "--stdin",
        help="Read from STDIN instead of opening a shell",
        dest="stdin",
        action="store_true",
        default=False,
    )