提交 90b897bf 编写于 作者: C Cleber Rosa

rest-client: add server command

A command that inspects the server status and available functionality.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 a0aa6b70
# Copyright: Red Hat Inc. 2015
# Author: Cleber Rosa <cleber@redhat.com>
"""
Module that implements the actions for the CLI App when the job toplevel
command is used
"""
from avocado.restclient import connection
from avocado.restclient.cli.actions import base
@base.action
def status(app):
"""
Shows the server status
"""
data = app.connection.request("version/")
app.view.notify(event="message",
msg="Server version: %s" % data.get('version'))
@base.action
def list_brief(app):
"""
Shows the server API list
"""
try:
data = app.connection.get_api_list()
except connection.UnexpectedHttpStatusCode, e:
if e.received == 403:
app.view.notify(event="error",
msg="Error: Access Forbidden")
return False
app.view.notify(event="message",
msg="Available APIs:")
for name in data:
app.view.notify(event="message",
msg=" * %s" % name)
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2015
# Author: Cleber Rosa <cleber@redhat.com>
"""
This module has actions for the server command
"""
from avocado.restclient.cli.args import base
__all__ = ['ACTION_STATUS', 'ACTION_ARGUMENTS', 'ARGUMENTS']
#
# Arguments that are treated as actions
#
ACTION_STATUS = (('-s', '--status',),
{'help': 'shows the avocado-server status',
'action': 'store_true',
'default': False})
#
# Arguments that are treated as actions
#
ACTION_ARGUMENTS = [base.LIST_BRIEF,
ACTION_STATUS]
#
# Other arguments that will influence action behaviour
#
ARGUMENTS = []
......@@ -36,6 +36,18 @@ on them being loaded::
--username USERNAME Username to authenticate to avocado server
--password PASSWORD Password to give to avocado server
Real use of avocado depends on running avocado subcommands. This the current list
of subcommands::
server inspects the server status and available functionality
To get usage instructions for a given subcommand, run it with `--help`. Example::
$ avocado-rest-client server --help
-l, --list-brief list all records briefly
-s, --status shows the avocado-server status
FILES
=====
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册