Added host services list to status API

Change-Id: Ia062b28d315d63a2992ccf8514ca73d689fb3041
This commit is contained in:
Frédéric Vachon 2015-05-27 17:58:13 -04:00
parent ef199d09d1
commit f1576105c8
2 changed files with 12 additions and 1 deletions

View File

@ -52,6 +52,9 @@ class LiveHost(types.Base):
long_output = wsme.wsattr(wtypes.text, mandatory=False) long_output = wsme.wsattr(wtypes.text, mandatory=False)
"""Plugin long output of the last check""" """Plugin long output of the last check"""
services = wsme.wsattr([wtypes.text], mandatory=False)
"""The services of the host"""
@classmethod @classmethod
def sample(cls): def sample(cls):
return cls( return cls(
@ -65,5 +68,6 @@ class LiveHost(types.Base):
last_check=1429220785, last_check=1429220785,
last_state_change=1429220785, last_state_change=1429220785,
plugin_output='PING OK - Packet loss = 0%, RTA = 0.02 ms', plugin_output='PING OK - Packet loss = 0%, RTA = 0.02 ms',
long_output='The ping was great\nI love epic ping-pong games' long_output='The ping was great\nI love epic ping-pong games',
services=['load', 'cpu', 'disk_usage']
) )

View File

@ -36,6 +36,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"state_type": "HARD", "state_type": "HARD",
"problem_has_been_acknowledged": True, "problem_has_been_acknowledged": True,
"host_name": "localhost", "host_name": "localhost",
"services": ["load", "cpu"],
}, },
{ {
"display_name": "test_keystone", "display_name": "test_keystone",
@ -50,6 +51,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"state_type": "HARD", "state_type": "HARD",
"problem_has_been_acknowledged": True, "problem_has_been_acknowledged": True,
"host_name": "test_keystone", "host_name": "test_keystone",
"services": ["apache"],
}, },
{ {
"display_name": "ws-arbiter", "display_name": "ws-arbiter",
@ -64,6 +66,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"state_type": "HARD", "state_type": "HARD",
"problem_has_been_acknowledged": True, "problem_has_been_acknowledged": True,
"host_name": "ws-arbiter", "host_name": "ws-arbiter",
"services": [],
}, },
] ]
self.mongoconnection.shinken_live.hosts.insert( self.mongoconnection.shinken_live.hosts.insert(
@ -111,6 +114,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429405764, "last_check": 1429405764,
"state": "OK", "state": "OK",
"acknowledged": True, "acknowledged": True,
"services": ["load", "cpu"],
"host_name": "localhost"}, "host_name": "localhost"},
{"description": "test_keystone", {"description": "test_keystone",
"address": "127.0.0.1", "address": "127.0.0.1",
@ -122,6 +126,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429405763, "last_check": 1429405763,
"state": "OK", "state": "OK",
"acknowledged": True, "acknowledged": True,
"services": ["apache"],
"host_name": "test_keystone"}, "host_name": "test_keystone"},
{"description": "ws-arbiter", {"description": "ws-arbiter",
"address": "127.0.0.1", "address": "127.0.0.1",
@ -133,6 +138,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429405764, "last_check": 1429405764,
"state": "OK", "state": "OK",
"acknowledged": True, "acknowledged": True,
"services": [],
"host_name": "ws-arbiter"}] "host_name": "ws-arbiter"}]
self.assert_count_equal_backport(json.loads(response.body.decode()), self.assert_count_equal_backport(json.loads(response.body.decode()),
@ -170,6 +176,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429812191, "last_check": 1429812191,
"state": "OK", "state": "OK",
"host_name": "localhost", "host_name": "localhost",
"services": ["load", "cpu"],
"address": "localhost"} "address": "localhost"}
self.assert_count_equal_backport(json.loads(response.body.decode()), self.assert_count_equal_backport(json.loads(response.body.decode()),