Added config-service-show command

Change-Id: I48a6bd060c45751f9a864e3a39d736ab53b3bb1c
This commit is contained in:
aviau 2015-08-06 16:38:24 -04:00
parent c04e867dc0
commit a7e07a6c84
3 changed files with 51 additions and 0 deletions

View File

@ -88,3 +88,22 @@ class TestServices(clienttest.ClientTest):
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,
{}
)

View File

@ -57,3 +57,13 @@ class ServicesManager(surveil_manager.SurveilManager):
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

View File

@ -1437,6 +1437,28 @@ def do_config_service_delete(sc, args):
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("--exclude")
@cliutils.arg("--periods", nargs='+')