Added status-host-show
Change-Id: Ifc8833d82e48f59bbe26a8f9d6a14c60b28d3dd9
This commit is contained in:
parent
afd68d0c77
commit
71b69daf26
|
@ -31,4 +31,18 @@ class TestHosts(clienttest.ClientTest):
|
|||
self.assertEqual(
|
||||
hosts,
|
||||
[{"host_name": "host1"}]
|
||||
)
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_get(self):
|
||||
httpretty.register_uri(
|
||||
httpretty.GET, "http://localhost:8080/v2/status/hosts/hostname",
|
||||
body='{"host_name": "host1"}'
|
||||
)
|
||||
|
||||
host = self.client.status.hosts.get("hostname")
|
||||
|
||||
self.assertEqual(
|
||||
host,
|
||||
{"host_name": "host1"}
|
||||
)
|
||||
|
|
|
@ -124,7 +124,7 @@ def do_config_host_show(sc, args):
|
|||
utils.print_item(host, hostProperties)
|
||||
|
||||
|
||||
@cliutils.arg("--host_name", help="Name of the host")
|
||||
@cliutils.arg("host_name", help="Name of the host")
|
||||
def do_config_host_delete(sc, args):
|
||||
"""Create a config host."""
|
||||
sc.config.hosts.delete(args.host_name)
|
||||
|
@ -182,8 +182,8 @@ def do_config_service_create(sc, args):
|
|||
sc.config.services.create(**service)
|
||||
|
||||
|
||||
@cliutils.arg("--host_name", help="Name of the host")
|
||||
@cliutils.arg("--service_description")
|
||||
@cliutils.arg("host_name", help="Name of the host")
|
||||
@cliutils.arg("service_description", help="The service_description")
|
||||
def do_config_service_delete(sc, args):
|
||||
"""Create a config host."""
|
||||
sc.config.services.delete(args.host_name,
|
||||
|
@ -259,6 +259,21 @@ def do_status_host_list(sc, args):
|
|||
utils.print_list(services, cols, formatters=formatters)
|
||||
|
||||
|
||||
@cliutils.arg("host_name", help="The host_name")
|
||||
def do_status_host_show(sc, args):
|
||||
host = sc.status.hosts.get(args.host_name)
|
||||
|
||||
if args.json:
|
||||
print(utils.json_formatter(host))
|
||||
elif host:
|
||||
hostProperties = [
|
||||
'host_name', 'address', 'state', 'last_check',
|
||||
'last_state_change', 'long_output', 'description', 'acknowledged',
|
||||
'plugin_output', 'services', 'childs', 'parents',
|
||||
]
|
||||
utils.print_item(host, hostProperties)
|
||||
|
||||
|
||||
def do_status_service_list(sc, args):
|
||||
"""List all status services."""
|
||||
services = sc.status.services.list()
|
||||
|
|
|
@ -24,3 +24,10 @@ class HostsManager(surveil_manager.SurveilManager):
|
|||
HostsManager.base_url, 'POST', body=live_query
|
||||
)
|
||||
return body
|
||||
|
||||
def get(self, host_name):
|
||||
"""Get a specific host."""
|
||||
resp, body = self.http_client.json_request(
|
||||
HostsManager.base_url + "/" + host_name, 'GET'
|
||||
)
|
||||
return body
|
||||
|
|
Loading…
Reference in New Issue