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)
"""Plugin long output of the last check"""
services = wsme.wsattr([wtypes.text], mandatory=False)
"""The services of the host"""
@classmethod
def sample(cls):
return cls(
@ -65,5 +68,6 @@ class LiveHost(types.Base):
last_check=1429220785,
last_state_change=1429220785,
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",
"problem_has_been_acknowledged": True,
"host_name": "localhost",
"services": ["load", "cpu"],
},
{
"display_name": "test_keystone",
@ -50,6 +51,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"state_type": "HARD",
"problem_has_been_acknowledged": True,
"host_name": "test_keystone",
"services": ["apache"],
},
{
"display_name": "ws-arbiter",
@ -64,6 +66,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"state_type": "HARD",
"problem_has_been_acknowledged": True,
"host_name": "ws-arbiter",
"services": [],
},
]
self.mongoconnection.shinken_live.hosts.insert(
@ -111,6 +114,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429405764,
"state": "OK",
"acknowledged": True,
"services": ["load", "cpu"],
"host_name": "localhost"},
{"description": "test_keystone",
"address": "127.0.0.1",
@ -122,6 +126,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429405763,
"state": "OK",
"acknowledged": True,
"services": ["apache"],
"host_name": "test_keystone"},
{"description": "ws-arbiter",
"address": "127.0.0.1",
@ -133,6 +138,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429405764,
"state": "OK",
"acknowledged": True,
"services": [],
"host_name": "ws-arbiter"}]
self.assert_count_equal_backport(json.loads(response.body.decode()),
@ -170,6 +176,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
"last_check": 1429812191,
"state": "OK",
"host_name": "localhost",
"services": ["load", "cpu"],
"address": "localhost"}
self.assert_count_equal_backport(json.loads(response.body.decode()),