Added config-service-show command
Change-Id: I48a6bd060c45751f9a864e3a39d736ab53b3bb1c
This commit is contained in:
parent
c04e867dc0
commit
a7e07a6c84
@ -88,3 +88,22 @@ class TestServices(clienttest.ClientTest):
|
|||||||
body,
|
body,
|
||||||
"body"
|
"body"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@httpretty.activate
|
||||||
|
def test_get(self):
|
||||||
|
httpretty.register_uri(
|
||||||
|
httpretty.GET,
|
||||||
|
"http://localhost:5311/v2/config/hosts/host_name/" +
|
||||||
|
"services/service_description",
|
||||||
|
body="{}"
|
||||||
|
)
|
||||||
|
|
||||||
|
body = self.client.config.services.get(
|
||||||
|
host_name="host_name",
|
||||||
|
service_description="service_description"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
body,
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
@ -57,3 +57,13 @@ class ServicesManager(surveil_manager.SurveilManager):
|
|||||||
body=''
|
body=''
|
||||||
)
|
)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
def get(self, host_name, service_description):
|
||||||
|
"""Get a service."""
|
||||||
|
resp, body = self.http_client.json_request(
|
||||||
|
'/config/hosts/' + host_name +
|
||||||
|
'/services/' + service_description,
|
||||||
|
'GET',
|
||||||
|
body=''
|
||||||
|
)
|
||||||
|
return body
|
||||||
|
@ -1437,6 +1437,28 @@ def do_config_service_delete(sc, args):
|
|||||||
args.service_description)
|
args.service_description)
|
||||||
|
|
||||||
|
|
||||||
|
@cliutils.arg("--host_name", help="Name of the host")
|
||||||
|
@cliutils.arg("--service_description", help="The service_description")
|
||||||
|
def do_config_service_show(sc, args):
|
||||||
|
"""Show a config service."""
|
||||||
|
service = sc.config.services.get(args.host_name, args.service_description)
|
||||||
|
if args.json:
|
||||||
|
print(utils.json_formatter(service))
|
||||||
|
elif service:
|
||||||
|
# Specify the shown order and all the properties to display
|
||||||
|
service_properties = [
|
||||||
|
'service_description',
|
||||||
|
'use',
|
||||||
|
'host_name',
|
||||||
|
'contacts',
|
||||||
|
'register',
|
||||||
|
'name',
|
||||||
|
'passive_checks_enabled',
|
||||||
|
]
|
||||||
|
|
||||||
|
utils.print_item(service, service_properties)
|
||||||
|
|
||||||
|
|
||||||
@cliutils.arg("--timeperiod_name", help="New name of the timeperiod")
|
@cliutils.arg("--timeperiod_name", help="New name of the timeperiod")
|
||||||
@cliutils.arg("--exclude")
|
@cliutils.arg("--exclude")
|
||||||
@cliutils.arg("--periods", nargs='+')
|
@cliutils.arg("--periods", nargs='+')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user