diff --git a/surveil/api/controllers/v1/datamodel/checkresult.py b/surveil/api/controllers/v1/datamodel/checkresult.py index 77f7db5..4e27761 100644 --- a/surveil/api/controllers/v1/datamodel/checkresult.py +++ b/surveil/api/controllers/v1/datamodel/checkresult.py @@ -26,7 +26,7 @@ class CheckResult(types.Base): default=str(int(time.time()))) """The time the check was executed. Defaults to now.""" - return_code = wsme.wsattr(wtypes.text, mandatory=True) + return_code = wsme.wsattr(int, mandatory=True) """The return code of the check.""" output = wsme.wsattr(wtypes.text, mandatory=True) @@ -36,6 +36,6 @@ class CheckResult(types.Base): def sample(cls): return cls( time_stamp="1409087486", - return_code="0", + return_code=0, output="CPU Usage 98%|c[cpu]=98%;80;95;0;100" ) diff --git a/surveil/api/controllers/v1/datamodel/host.py b/surveil/api/controllers/v1/datamodel/host.py index 61834c6..4e239a1 100644 --- a/surveil/api/controllers/v1/datamodel/host.py +++ b/surveil/api/controllers/v1/datamodel/host.py @@ -25,7 +25,7 @@ class Host(types.Base): address = wsme.wsattr(wtypes.text, mandatory=True) """The address of the host. Normally, this is an IP address.""" - max_check_attempts = wsme.wsattr(wtypes.text, mandatory=True) + max_check_attempts = wsme.wsattr(int, mandatory=True) check_period = wsme.wsattr(wtypes.text, mandatory=True) """The time period during which active checks of this host can be made.""" @@ -36,7 +36,7 @@ class Host(types.Base): contact_groups = wsme.wsattr(wtypes.text, mandatory=True) """List of the short names of the contact groups that should be notified""" - notification_interval = wsme.wsattr(wtypes.text, mandatory=True) + notification_interval = wsme.wsattr(int, mandatory=True) notification_period = wsme.wsattr(wtypes.text, mandatory=True) @@ -45,10 +45,10 @@ class Host(types.Base): return cls( host_name="bogus-router", address="192.168.1.254", - max_check_attempts="5", + max_check_attempts=5, check_period="24x7", contacts="admin,carl", contact_groups="router-admins", - notification_interval="30", + notification_interval=30, notification_period="24x7", ) diff --git a/surveil/api/controllers/v1/datamodel/service.py b/surveil/api/controllers/v1/datamodel/service.py index 29a2450..4e678ba 100644 --- a/surveil/api/controllers/v1/datamodel/service.py +++ b/surveil/api/controllers/v1/datamodel/service.py @@ -25,15 +25,15 @@ class Service(types.Base): check_command = wsme.wsattr(wtypes.text, mandatory=True) - max_check_attempts = wsme.wsattr(wtypes.text, mandatory=True) + max_check_attempts = wsme.wsattr(int, mandatory=True) - check_interval = wsme.wsattr(wtypes.text, mandatory=True) + check_interval = wsme.wsattr(int, mandatory=True) - retry_interval = wsme.wsattr(wtypes.text, mandatory=True) + retry_interval = wsme.wsattr(int, mandatory=True) check_period = wsme.wsattr(wtypes.text, mandatory=True) - notification_interval = wsme.wsattr(wtypes.text, mandatory=True) + notification_interval = wsme.wsattr(int, mandatory=True) notification_period = wsme.wsattr(wtypes.text, mandatory=True) @@ -47,11 +47,11 @@ class Service(types.Base): host_name="sample-server", service_description="check-disk-sdb", check_command="check-disk!/dev/sdb1", - max_check_attempts="5", - check_interval="5", - retry_interval="3", + max_check_attempts=5, + check_interval=5, + retry_interval=3, check_period="24x7", - notification_interval="30", + notification_interval=3, notification_period="24x7", contacts="surveil-ptl,surveil-bob", contact_groups="linux-admins", diff --git a/surveil/tests/api/controllers/v1/test_hosts.py b/surveil/tests/api/controllers/v1/test_hosts.py index 107567d..c7eac44 100644 --- a/surveil/tests/api/controllers/v1/test_hosts.py +++ b/surveil/tests/api/controllers/v1/test_hosts.py @@ -28,21 +28,21 @@ class TestHostController(functionalTest.FunctionalTest): self.hosts = [ { "host_name": "bogus-router", "address": "192.168.1.254", - "max_check_attempts": "5", "check_period": "24x7", + "max_check_attempts": 5, "check_period": "24x7", "contacts": "admin,carl", "contact_groups": "router-admins", - "notification_interval": "30", "notification_period": "24x7" + "notification_interval": 30, "notification_period": "24x7" }, { "host_name": "bogus-router2", "address": "192.168.1.254", - "max_check_attempts": "5", "check_period": "24x7", + "max_check_attempts": 5, "check_period": "24x7", "contacts": "admin,carl", "contact_groups": "router-admins", - "notification_interval": "30", "notification_period": "24x7" + "notification_interval": 30, "notification_period": "24x7" }, { "host_name": "bogus-router333", "address": "192.168.1.254", - "max_check_attempts": "5", "check_period": "24x7", + "max_check_attempts": 5, "check_period": "24x7", "contacts": "admin,carl", "contact_groups": "router-admins", - "notification_interval": "30", "notification_period": "24x7" + "notification_interval": 30, "notification_period": "24x7" }, ] self.mongoconnection.shinken.hosts.insert( @@ -54,11 +54,11 @@ class TestHostController(functionalTest.FunctionalTest): "host_name": "bogus-router", "service_description": "service-example", "check_command": "check-disk!/dev/sdb1", - "max_check_attempts": "5", - "check_interval": "5", - "retry_interval": "3", + "max_check_attempts": 5, + "check_interval": 5, + "retry_interval": 3, "check_period": "24x7", - "notification_interval": "30", + "notification_interval": 30, "notification_period": "24x7", "contacts": "surveil-ptl,surveil-bob", "contact_groups": "linux-admins" @@ -90,11 +90,11 @@ class TestHostController(functionalTest.FunctionalTest): put_host = { u"host_name": u"bogus-router333", u"address": u"newputaddress", - u"max_check_attempts": u"222225", + u"max_check_attempts": 222225, u"check_period": u"newtimeperiod", u"contacts": u"aaa,bbb", u"contact_groups": u"newgroup", - u"notification_interval": u"newnotificationinterval", + u"notification_interval": 333, u"notification_period": u"newnotificationperiod" } response = self.app.put_json( @@ -123,11 +123,11 @@ class TestHostController(functionalTest.FunctionalTest): new_host = { "host_name": "testpost", "address": "192.168.1.254", - "max_check_attempts": "5", + "max_check_attempts": 5, "check_period": "24x7", "contacts": "admin,carl", "contact_groups": "router-admins", - "notification_interval": "30", + "notification_interval": 3, "notification_period": "24x7" } response = self.app.post_json("/v1/hosts", params=new_host) diff --git a/surveil/tests/api/controllers/v1/test_services.py b/surveil/tests/api/controllers/v1/test_services.py index 84d4139..fca1dd7 100644 --- a/surveil/tests/api/controllers/v1/test_services.py +++ b/surveil/tests/api/controllers/v1/test_services.py @@ -28,11 +28,11 @@ class TestServiceController(functionalTest.FunctionalTest): "host_name": "sample-server1", "service_description": "check-", "check_command": "check-disk!/dev/sdb1", - "max_check_attempts": "5", - "check_interval": "5", - "retry_interval": "3", + "max_check_attempts": 5, + "check_interval": 5, + "retry_interval": 3, "check_period": "24x7", - "notification_interval": "30", + "notification_interval": 30, "notification_period": "24x7", "contacts": "surveil-ptl,surveil-bob", "contact_groups": "linux-admins" @@ -41,11 +41,11 @@ class TestServiceController(functionalTest.FunctionalTest): "host_name": "sample-server2", "service_description": "check-disk-sdb", "check_command": "check-disk!/dev/sdb1", - "max_check_attempts": "5", - "check_interval": "5", - "retry_interval": "3", + "max_check_attempts": 5, + "check_interval": 5, + "retry_interval": 3, "check_period": "24x7", - "notification_interval": "30", + "notification_interval": 30, "notification_period": "24x7", "contacts": "surveil-ptl,surveil-bob", "contact_groups": "linux-admins" @@ -54,11 +54,11 @@ class TestServiceController(functionalTest.FunctionalTest): "host_name": "sample-server3", "service_description": "check-disk-sdb", "check_command": "check-disk!/dev/sdb1", - "max_check_attempts": "5", - "check_interval": "5", - "retry_interval": "3", + "max_check_attempts": 5, + "check_interval": 5, + "retry_interval": 3, "check_period": "24x7", - "notification_interval": "30", + "notification_interval": 30, "notification_period": "24x7", "contacts": "surveil-ptl,surveil-bob", "contact_groups": "linux-admins" @@ -82,11 +82,11 @@ class TestServiceController(functionalTest.FunctionalTest): "host_name": "SOMEHOSTNAME", "service_description": "check-new-thing", "check_command": "check-disk!/dev/sdb1", - "max_check_attempts": "5", - "check_interval": "5", - "retry_interval": "3", + "max_check_attempts": 5, + "check_interval": 5, + "retry_interval": 3, "check_period": "24x7", - "notification_interval": "30", + "notification_interval": 30, "notification_period": "24x7", "contacts": "surveil-ptl,surveil-bob", "contact_groups": "linux-admins"