CLI: Add status filtering to 'ara host list'
This adds the "--with(out)-{failed,changed,unreachable}" arguments
to 'ara host list' in order to filter hosts based on task result stats.
Change-Id: If0d61cc7d9adf962e8e6a2740660d53e3bb2799c
This commit is contained in:
@@ -35,6 +35,48 @@ class HostList(Lister):
|
||||
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(
|
||||
"--order",
|
||||
metavar="<order>",
|
||||
@@ -70,6 +112,19 @@ class HostList(Lister):
|
||||
if args.playbook is not None:
|
||||
query["playbook"] = args.playbook
|
||||
|
||||
if args.with_changed:
|
||||
query["changed__gt"] = 0
|
||||
if args.without_changed:
|
||||
query["changed__lt"] = 1
|
||||
if args.with_failed:
|
||||
query["failed__gt"] = 0
|
||||
if args.without_failed:
|
||||
query["failed__lt"] = 1
|
||||
if args.with_unreachable:
|
||||
query["unreachable__gt"] = 0
|
||||
if args.without_unreachable:
|
||||
query["unreachable__lt"] = 1
|
||||
|
||||
query["order"] = args.order
|
||||
query["limit"] = args.limit
|
||||
|
||||
|
||||
@@ -76,24 +76,31 @@ ara host list
|
||||
Their records contain the Ansible host facts as well as their stats for a
|
||||
particular playbook run.
|
||||
|
||||
Search for a specific host name across playbook runs against a local API server:
|
||||
Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ara host list --client http --server http://127.0.0.1:8000 --name localhost
|
||||
# List the latest 25 host results
|
||||
ara host list --limit 25
|
||||
|
||||
List the 100 most recently updated hosts using the offline API client:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ara host list
|
||||
|
||||
List the host results for a specific playbook and format the result in json:
|
||||
|
||||
.. code-block:: bash
|
||||
# List host records for a specific host name
|
||||
ara host list --name localhost
|
||||
|
||||
# List all the host results for a specific playbook and format the result in json
|
||||
ara host list --playbook 1 -f json
|
||||
|
||||
# Only return hosts with or without unreachable task results
|
||||
ara host list --with-unreachable
|
||||
ara host list --without-unreachable
|
||||
|
||||
# Only return hosts with or without changed task results
|
||||
ara host list --with-changed
|
||||
ara host list --without-changed
|
||||
|
||||
# Only return hosts with or without failed task results
|
||||
ara host list --with-failed
|
||||
ara host list --without-failed
|
||||
|
||||
ara host show
|
||||
-------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user