Example #1
0
 def get_parser(self, prog_name):
     parser = super(ExpireObjects, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "--hours",
         type=int,
         default=24,
         help="Expires objects that have been running state for this many hours (default: 24)"
     )
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="started",
         help=(
             "Orders objects by a field ('id', 'created', 'updated', 'started', 'ended')\n"
             "Defaults to 'started' descending so the oldest objects would be expired first.\n"
             "The order can be reversed by using '-': ara expire --order=-started"
         ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 200),
         help=("Only expire the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 200.")
     )
     parser.add_argument(
         "--confirm",
         action="store_true",
         help="Confirm expiration of objects, otherwise runs without expiring any objects",
     )
     # fmt: on
     return parser
Example #2
0
 def get_parser(self, prog_name):
     parser = super(PlayList, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     # Play search arguments and ordering as per ara.api.filters.PlayFilter
     parser.add_argument(
         "--playbook",
         metavar="<playbook_id>",
         default=None,
         help=("List plays for the specified playbook"),
     )
     parser.add_argument(
         "--name",
         metavar="<name>",
         default=None,
         help=("List plays matching the provided name (full or partial)"),
     )
     parser.add_argument(
         "--uuid",
         metavar="<uuid>",
         default=None,
         help=("List plays matching the provided uuid (full or partial)"),
     )
     parser.add_argument(
         "--status",
         metavar="<status>",
         default=None,
         help=("List plays matching a specific status ('completed', 'running', 'failed')"),
     )
     parser.add_argument(
         "--long",
         action="store_true",
         default=False,
         help=("Don't truncate paths")
     )
     parser.add_argument(
         "--resolve",
         action="store_true",
         default=os.environ.get("ARA_CLI_RESOLVE", False),
         help=("Resolve IDs to identifiers (such as path or names). Defaults to ARA_CLI_RESOLVE or False")
     )
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="-started",
         help=(
             "Orders plays by a field ('id', 'created', 'updated', 'started', 'ended', 'duration')\n"
             "Defaults to '-started' descending so the most recent playbook is at the top.\n"
             "The order can be reversed by omitting the '-': ara play list --order=started"
         ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 50),
         help=("Returns the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 50.")
     )
     # fmt: on
     return parser
Example #3
0
 def get_parser(self, prog_name):
     parser = super(PlaybookList, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     # Playbook search arguments and ordering as per ara.api.filters.PlaybookFilter
     parser.add_argument(
         "--label",
         metavar="<label>",
         default=None,
         help=("List playbooks matching the provided label"),
     )
     parser.add_argument(
         "--name",
         metavar="<name>",
         default=None,
         help=(
             "List playbooks matching the provided name (full or partial)"),
     )
     parser.add_argument(
         "--path",
         metavar="<path>",
         default=None,
         help=(
             "List playbooks matching the provided path (full or partial)"),
     )
     parser.add_argument(
         "--status",
         metavar="<status>",
         default=None,
         help=
         ("List playbooks matching a specific status ('completed', 'running', 'failed')"
          ),
     )
     parser.add_argument(
         "--long",
         action="store_true",
         default=False,
         help=
         ("Don't truncate paths and include additional fields: name, plays, files, records"
          ))
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="-started",
         help=
         ("Orders playbooks by a field ('id', 'created', 'updated', 'started', 'ended', 'duration')\n"
          "Defaults to '-started' descending so the most recent playbook is at the top.\n"
          "The order can be reversed by omitting the '-': ara playbook list --order=started"
          ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 50),
         help=
         ("Returns the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 50."
          ))
     # fmt: on
     return parser
Example #4
0
 def get_parser(self, prog_name):
     parser = super(HostDelete, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "host_id",
         metavar="<host-id>",
         help="Host to delete",
     )
     # fmt: on
     return parser
Example #5
0
 def get_parser(self, prog_name):
     parser = super(RecordDelete, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "record_id",
         metavar="<record-id>",
         help="Record to delete",
     )
     # fmt: on
     return parser
Example #6
0
 def get_parser(self, prog_name):
     parser = super(PlaybookDelete, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "playbook_id",
         metavar="<playbook-id>",
         help="Playbook to delete",
     )
     # fmt: on
     return parser
Example #7
0
 def get_parser(self, prog_name):
     parser = super(TaskDelete, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "task_id",
         metavar="<task-id>",
         help="Task to delete",
     )
     # fmt: on
     return parser
Example #8
0
 def get_parser(self, prog_name):
     parser = super(PlayShow, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "play_id",
         metavar="<play-id>",
         help="Play to show",
     )
     # fmt: on
     return parser
Example #9
0
 def get_parser(self, prog_name):
     parser = super(RecordList, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     # Record search arguments and ordering as per ara.api.filters.RecordFilter
     parser.add_argument(
         "--playbook",
         metavar="<playbook_id>",
         default=None,
         help=("List records for the specified playbook"),
     )
     parser.add_argument(
         "--key",
         metavar="<key>",
         default=None,
         help=("List records matching the specified key"),
     )
     parser.add_argument("--long",
                         action="store_true",
                         default=False,
                         help=("Don't truncate paths"))
     parser.add_argument(
         "--resolve",
         action="store_true",
         default=os.environ.get("ARA_CLI_RESOLVE", False),
         help=
         ("Resolve IDs to identifiers (such as path or names). Defaults to ARA_CLI_RESOLVE or False"
          ))
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="-updated",
         help=
         ("Orders records by a field ('id', 'created', 'updated', 'key')\n"
          "Defaults to '-updated' descending so the most recent record is at the top.\n"
          "The order can be reversed by omitting the '-': ara record list --order=updated"
          ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 50),
         help=
         ("Returns the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 50."
          ))
     # fmt: on
     return parser
Example #10
0
 def get_parser(self, prog_name):
     parser = super(HostShow, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "host_id",
         metavar="<host-id>",
         help="Host to show",
     )
     parser.add_argument(
         "--with-facts",
         action="store_true",
         help=
         "Also include host facts in the response (use with '-f json' or '-f yaml')"
     )
     # fmt: on
     return parser
Example #11
0
 def get_parser(self, prog_name):
     parser = super(ResultShow, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "result_id",
         metavar="<result-id>",
         help="Result to show",
     )
     parser.add_argument(
         "--with-content",
         action="store_true",
         help=
         "Also include the result content in the response (use with '-f json' or '-f yaml')"
     )
     # fmt: on
     return parser
Example #12
0
 def get_parser(self, prog_name):
     parser = super(TaskMetrics, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "--aggregate",
         choices=["action", "name", "path"],
         default="action",
         help=(
             "Aggregate tasks by action, name or path. Defaults to action."
         ),
     )
     # Task search arguments and ordering as per ara.api.filters.TaskFilter
     parser.add_argument(
         "--playbook",
         metavar="<playbook_id>",
         default=None,
         help=("Filter for tasks for a specified playbook id"),
     )
     parser.add_argument(
         "--status",
         metavar="<status>",
         default=None,
         help=
         ("Filter for tasks matching a specific status ('completed', 'expired', 'running' or 'unknown')"
          ))
     parser.add_argument(
         "--name",
         metavar="<name>",
         default=None,
         help=(
             "Filter for tasks matching the provided name (full or partial)"
         ),
     )
     parser.add_argument(
         "--path",
         metavar="<path>",
         default=None,
         help=(
             "Filter for tasks matching the provided path (full or partial)"
         ),
     )
     parser.add_argument(
         "--action",
         metavar="<action>",
         default=None,
         help=
         ("Filter for tasks matching a specific action/ansible module (ex: 'debug', 'package', 'set_fact')"
          ),
     )
     parser.add_argument(
         "--long",
         action="store_true",
         default=False,
         help=
         ("Don't truncate paths and include additional status fields: completed, running, expired, unknown"
          ))
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="-started",
         help=
         ("Orders tasks by a field ('id', 'created', 'updated', 'started', 'ended', 'duration')\n"
          "Defaults to '-started' descending so the most recent task is at the top.\n"
          "The order can be reversed by omitting the '-': ara task metrics --order=started\n"
          "This influences the API request, not the ordering of the metrics."
          ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 1000),
         help=
         ("Return metrics for the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 1000."
          ))
     # fmt: on
     return parser
Example #13
0
 def get_parser(self, prog_name):
     parser = super(TaskList, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     # Task search arguments and ordering as per ara.api.filters.TaskFilter
     parser.add_argument(
         "--playbook",
         metavar="<playbook_id>",
         default=None,
         help=("List tasks for a specified playbook id"),
     )
     parser.add_argument(
         "--status",
         metavar="<status>",
         default=None,
         help=
         ("List tasks matching a specific status ('completed', 'running' or 'unknown')"
          ))
     parser.add_argument(
         "--name",
         metavar="<name>",
         default=None,
         help=("List tasks matching the provided name (full or partial)"),
     )
     parser.add_argument(
         "--path",
         metavar="<path>",
         default=None,
         help=("List tasks matching the provided path (full or partial)"),
     )
     parser.add_argument(
         "--action",
         metavar="<action>",
         default=None,
         help=
         ("List tasks matching a specific action/ansible module (ex: 'debug', 'package', 'set_fact')"
          ),
     )
     parser.add_argument(
         "--long",
         action="store_true",
         default=False,
         help=
         ("Don't truncate paths and include additional fields: path, lineno, handler, play"
          ))
     parser.add_argument(
         "--resolve",
         action="store_true",
         default=os.environ.get("ARA_CLI_RESOLVE", False),
         help=
         ("Resolve IDs to identifiers (such as path or names). Defaults to ARA_CLI_RESOLVE or False"
          ))
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="-started",
         help=
         ("Orders tasks by a field ('id', 'created', 'updated', 'started', 'ended', 'duration')\n"
          "Defaults to '-started' descending so the most recent task is at the top.\n"
          "The order can be reversed by omitting the '-': ara task list --order=started"
          ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 50),
         help=
         ("Returns the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 50."
          ))
     # fmt: on
     return parser
Example #14
0
 def get_parser(self, prog_name):
     parser = super(PlaybookPrune, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     parser.add_argument(
         "--days",
         type=int,
         default=31,
         help="Delete playbooks started this many days ago (default: 31)")
     # Playbook search arguments like 'ara playbook list'
     parser.add_argument(
         "--label",
         metavar="<label>",
         default=None,
         help=("Only delete playbooks matching the provided label"),
     )
     parser.add_argument(
         "--name",
         metavar="<name>",
         default=None,
         help=
         ("Only delete playbooks matching the provided name (full or partial)"
          ),
     )
     parser.add_argument(
         "--controller",
         metavar="<controller>",
         default=None,
         help=
         ("Only delete playbooks that ran from the provided controller (full or partial)"
          ),
     )
     parser.add_argument(
         "--path",
         metavar="<path>",
         default=None,
         help=
         ("Only delete only playbooks matching the provided path (full or partial)"
          ),
     )
     parser.add_argument(
         "--status",
         metavar="<status>",
         default=None,
         help=
         ("Only delete playbooks matching a specific status ('completed', 'running', 'failed')"
          ),
     )
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="started",
         help=
         ("Orders playbooks by a field ('id', 'created', 'updated', 'started', 'ended', 'duration')\n"
          "Defaults to 'started' descending so the oldest playbook would be deleted first.\n"
          "The order can be reversed by using '-': ara playbook list --order=-started"
          ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 200),
         help=
         ("Only delete the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 200."
          ))
     parser.add_argument(
         "--confirm",
         action="store_true",
         help=
         "Confirm deletion of playbooks, otherwise runs without deleting any playbook",
     )
     # fmt: on
     return parser
Example #15
0
    def get_parser(self, prog_name):
        parser = super(HostMetrics, self).get_parser(prog_name)
        parser = global_arguments(parser)
        # fmt: off
        # Host search arguments and ordering as per ara.api.filters.HostFilter
        # TODO: non-exhaustive (searching for failed, ok, unreachable, etc.)
        parser.add_argument(
            "--name",
            metavar="<name>",
            default=None,
            help=(
                "Filter for hosts matching the provided name (full or partial)"
            ),
        )
        parser.add_argument(
            "--playbook",
            metavar="<playbook_id>",
            default=None,
            help=("Filter for hosts for a specified playbook id"),
        )

        changed = parser.add_mutually_exclusive_group()
        changed.add_argument("--with-changed",
                             action="store_true",
                             default=False,
                             help=("Filter for hosts with changed results"))
        changed.add_argument("--without-changed",
                             action="store_true",
                             default=False,
                             help=("Filter out hosts without changed results"))

        failed = parser.add_mutually_exclusive_group()
        failed.add_argument("--with-failed",
                            action="store_true",
                            default=False,
                            help=("Filter for hosts with failed results"))
        failed.add_argument("--without-failed",
                            action="store_true",
                            default=False,
                            help=("Filter out hosts without failed results"))

        unreachable = parser.add_mutually_exclusive_group()
        unreachable.add_argument(
            "--with-unreachable",
            action="store_true",
            default=False,
            help=("Filter for hosts with unreachable results"))
        unreachable.add_argument(
            "--without-unreachable",
            action="store_true",
            default=False,
            help=("Filter out hosts without unreachable results"))
        parser.add_argument(
            "--order",
            metavar="<order>",
            default="-updated",
            help=
            ("Orders hosts by a field ('id', 'created', 'updated', 'name')\n"
             "Defaults to '-updated' descending so the most recent host is at the top.\n"
             "The order can be reversed by omitting the '-': ara host list --order=updated\n"
             "This influences the API request, not the ordering of the metrics."
             ),
        )
        parser.add_argument(
            "--limit",
            metavar="<limit>",
            default=os.environ.get("ARA_CLI_LIMIT", 1000),
            help=
            ("Return metrics for the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 1000."
             ))
        # fmt: on
        return parser
Example #16
0
 def get_parser(self, prog_name):
     parser = super(ResultList, self).get_parser(prog_name)
     parser = global_arguments(parser)
     # fmt: off
     # Result search arguments and ordering as per ara.api.filters.ResultFilter
     # TODO: non-exhaustive (searching for failed, ok, unreachable, etc.)
     parser.add_argument(
         "--playbook",
         metavar="<playbook_id>",
         default=None,
         help=("List results for the specified playbook"),
     )
     parser.add_argument(
         "--play",
         metavar="<play_id>",
         default=None,
         help=("List results for the specified play"),
     )
     parser.add_argument(
         "--task",
         metavar="<task_id>",
         default=None,
         help=("List results for the specified task"),
     )
     parser.add_argument(
         "--host",
         metavar="<host_id>",
         default=None,
         help=("List results for the specified host"),
     )
     parser.add_argument(
         "--status",
         metavar="<status>",
         default=None,
         help=(
             "List results matching a specific status:\n"
             "ok, failed, skipped, unreachable, changed, ignored, unknown"))
     parser.add_argument(
         "--ignore-errors",
         action="store_true",
         default=False,
         help=
         ("Return only results with 'ignore_errors: true', defaults to false"
          ))
     parser.add_argument(
         "--changed",
         action="store_true",
         default=False,
         help=("Return only changed results, defaults to false"))
     parser.add_argument(
         "--long",
         action="store_true",
         default=False,
         help=
         ("Don't truncate paths and include additional fields: changed, ignore_errors, play"
          ))
     parser.add_argument(
         "--resolve",
         action="store_true",
         default=os.environ.get("ARA_CLI_RESOLVE", False),
         help=
         ("Resolve IDs to identifiers (such as path or names). Defaults to ARA_CLI_RESOLVE or False"
          ))
     parser.add_argument(
         "--order",
         metavar="<order>",
         default="-started",
         help=
         ("Orders results by a field ('id', 'started', 'updated', 'ended', 'duration')\n"
          "Defaults to '-started' descending so the most recent result is at the top.\n"
          "The order can be reversed by omitting the '-': ara result list --order=started"
          ),
     )
     parser.add_argument(
         "--limit",
         metavar="<limit>",
         default=os.environ.get("ARA_CLI_LIMIT", 50),
         help=
         ("Returns the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 50."
          ))
     # fmt: on
     return parser
Example #17
0
    def get_parser(self, prog_name):
        parser = super(HostList, self).get_parser(prog_name)
        parser = global_arguments(parser)
        # fmt: off
        # Host search arguments and ordering as per ara.api.filters.HostFilter
        # TODO: non-exhaustive (searching for failed, ok, unreachable, etc.)
        parser.add_argument(
            "--name",
            metavar="<name>",
            default=None,
            help=("List hosts matching the provided name (full or partial)"),
        )
        parser.add_argument(
            "--playbook",
            metavar="<playbook_id>",
            default=None,
            help=("List hosts for a specified playbook id"),
        )

        changed = parser.add_mutually_exclusive_group()
        changed.add_argument("--with-changed",
                             action="store_true",
                             default=False,
                             help=("Return hosts with changed results"))
        changed.add_argument("--without-changed",
                             action="store_true",
                             default=False,
                             help=("Don't return hosts with changed results"))

        failed = parser.add_mutually_exclusive_group()
        failed.add_argument("--with-failed",
                            action="store_true",
                            default=False,
                            help=("Return hosts with failed results"))
        failed.add_argument("--without-failed",
                            action="store_true",
                            default=False,
                            help=("Don't return hosts with failed results"))

        unreachable = parser.add_mutually_exclusive_group()
        unreachable.add_argument(
            "--with-unreachable",
            action="store_true",
            default=False,
            help=("Return hosts with unreachable results"))
        unreachable.add_argument(
            "--without-unreachable",
            action="store_true",
            default=False,
            help=("Don't return hosts with unreachable results"))
        parser.add_argument(
            "--resolve",
            action="store_true",
            default=os.environ.get("ARA_CLI_RESOLVE", False),
            help=
            ("Resolve IDs to identifiers (such as path or names). Defaults to ARA_CLI_RESOLVE or False"
             ))
        parser.add_argument("--long",
                            action="store_true",
                            default=False,
                            help=("Don't truncate paths"))
        parser.add_argument(
            "--order",
            metavar="<order>",
            default="-updated",
            help=
            ("Orders hosts by a field ('id', 'created', 'updated', 'name')\n"
             "Defaults to '-updated' descending so the most recent host is at the top.\n"
             "The order can be reversed by omitting the '-': ara host list --order=updated"
             ),
        )
        parser.add_argument(
            "--limit",
            metavar="<limit>",
            default=os.environ.get("ARA_CLI_LIMIT", 50),
            help=
            ("Returns the first <limit> determined by the ordering. Defaults to ARA_CLI_LIMIT or 50."
             ))
        # fmt: on
        return parser