Require authentication for all endpoints
Change-Id: I4a3adfbcbd6cd268196af6064bc8d1a1c430477b
This commit is contained in:
parent
57025d4f4b
commit
1f119d9c11
@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y vim python-pip python3-pip python-dev l
|
|||||||
RUN useradd shinken && pip install https://github.com/naparuba/shinken/archive/2.2-RC1.zip
|
RUN useradd shinken && pip install https://github.com/naparuba/shinken/archive/2.2-RC1.zip
|
||||||
|
|
||||||
# python-surveilclient (used by surveil-init)
|
# python-surveilclient (used by surveil-init)
|
||||||
RUN pip install python-surveilclient>=0.3
|
RUN pip install python-surveilclient>=0.4.1
|
||||||
|
|
||||||
# Download packs
|
# Download packs
|
||||||
RUN apt-get install -y subversion && \
|
RUN apt-get install -y subversion && \
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.actions import acknowledgement
|
from surveil.api.datamodel.actions import acknowledgement
|
||||||
from surveil.api.datamodel import info
|
from surveil.api.datamodel import info
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class AcknowledgeController(rest.RestController):
|
class AcknowledgeController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(info.Info,
|
@wsme_pecan.wsexpose(info.Info,
|
||||||
body=acknowledgement.Acknowledgement,
|
body=acknowledgement.Acknowledgement,
|
||||||
status_code=200)
|
status_code=200)
|
||||||
@ -39,6 +41,7 @@ class AcknowledgeController(rest.RestController):
|
|||||||
|
|
||||||
return info.Info(message='Acknowledgement received.')
|
return info.Info(message='Acknowledgement received.')
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(info.Info,
|
@wsme_pecan.wsexpose(info.Info,
|
||||||
body=acknowledgement.Acknowledgement,
|
body=acknowledgement.Acknowledgement,
|
||||||
status_code=200)
|
status_code=200)
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.actions import downtime
|
from surveil.api.datamodel.actions import downtime
|
||||||
from surveil.api.datamodel import info
|
from surveil.api.datamodel import info
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class DowntimeController(rest.RestController):
|
class DowntimeController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(info.Info,
|
@wsme_pecan.wsexpose(info.Info,
|
||||||
body=downtime.Downtime,
|
body=downtime.Downtime,
|
||||||
status_code=200)
|
status_code=200)
|
||||||
@ -39,6 +41,7 @@ class DowntimeController(rest.RestController):
|
|||||||
|
|
||||||
return info.Info(message='Downtime received.')
|
return info.Info(message='Downtime received.')
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(info.Info,
|
@wsme_pecan.wsexpose(info.Info,
|
||||||
body=downtime.Downtime,
|
body=downtime.Downtime,
|
||||||
status_code=200)
|
status_code=200)
|
||||||
|
@ -17,6 +17,7 @@ from pecan import rest
|
|||||||
import wsmeext.pecan as wsme_pecan
|
import wsmeext.pecan as wsme_pecan
|
||||||
|
|
||||||
from surveil.api.controllers.v1.datamodel import command
|
from surveil.api.controllers.v1.datamodel import command
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class CommandController(rest.RestController):
|
class CommandController(rest.RestController):
|
||||||
@ -25,6 +26,7 @@ class CommandController(rest.RestController):
|
|||||||
pecan.request.context['command_name'] = command_name
|
pecan.request.context['command_name'] = command_name
|
||||||
self._id = command_name
|
self._id = command_name
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(command.Command)
|
@wsme_pecan.wsexpose(command.Command)
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Returns a specific command."""
|
"""Returns a specific command."""
|
||||||
@ -33,6 +35,7 @@ class CommandController(rest.RestController):
|
|||||||
)
|
)
|
||||||
return command.Command(**c)
|
return command.Command(**c)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(None, body=command.Command, status_code=204)
|
@wsme_pecan.wsexpose(None, body=command.Command, status_code=204)
|
||||||
def put(self, data):
|
def put(self, data):
|
||||||
"""Modify this command.
|
"""Modify this command.
|
||||||
@ -49,6 +52,7 @@ class CommandController(rest.RestController):
|
|||||||
command_dict
|
command_dict
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(None, status_code=204)
|
@wsme_pecan.wsexpose(None, status_code=204)
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""Delete this command."""
|
"""Delete this command."""
|
||||||
@ -63,6 +67,7 @@ class CommandsController(rest.RestController):
|
|||||||
def _lookup(self, command_id, *remainder):
|
def _lookup(self, command_id, *remainder):
|
||||||
return CommandController(command_id), remainder
|
return CommandController(command_id), remainder
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([command.Command])
|
@wsme_pecan.wsexpose([command.Command])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all commands."""
|
"""Returns all commands."""
|
||||||
@ -71,6 +76,7 @@ class CommandsController(rest.RestController):
|
|||||||
|
|
||||||
return [command.Command(**c) for c in commands]
|
return [command.Command(**c) for c in commands]
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(command.Command,
|
@wsme_pecan.wsexpose(command.Command,
|
||||||
body=command.Command,
|
body=command.Command,
|
||||||
status_code=201)
|
status_code=201)
|
||||||
|
@ -18,6 +18,7 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import command
|
from surveil.api.datamodel.config import command
|
||||||
from surveil.api.handlers.config import command_handler
|
from surveil.api.handlers.config import command_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class CommandController(rest.RestController):
|
class CommandController(rest.RestController):
|
||||||
@ -26,6 +27,7 @@ class CommandController(rest.RestController):
|
|||||||
pecan.request.context['command_name'] = command_name
|
pecan.request.context['command_name'] = command_name
|
||||||
self._id = command_name
|
self._id = command_name
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(command.Command)
|
@wsme_pecan.wsexpose(command.Command)
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Returns a specific command."""
|
"""Returns a specific command."""
|
||||||
@ -33,6 +35,7 @@ class CommandController(rest.RestController):
|
|||||||
c = handler.get(self._id)
|
c = handler.get(self._id)
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(None, body=command.Command, status_code=204)
|
@wsme_pecan.wsexpose(None, body=command.Command, status_code=204)
|
||||||
def put(self, data):
|
def put(self, data):
|
||||||
"""Modify this command.
|
"""Modify this command.
|
||||||
@ -42,6 +45,7 @@ class CommandController(rest.RestController):
|
|||||||
handler = command_handler.CommandHandler(pecan.request)
|
handler = command_handler.CommandHandler(pecan.request)
|
||||||
handler.update(self._id, data)
|
handler.update(self._id, data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(None, status_code=204)
|
@wsme_pecan.wsexpose(None, status_code=204)
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""Delete this command."""
|
"""Delete this command."""
|
||||||
@ -55,6 +59,7 @@ class CommandsController(rest.RestController):
|
|||||||
def _lookup(self, command_id, *remainder):
|
def _lookup(self, command_id, *remainder):
|
||||||
return CommandController(command_id), remainder
|
return CommandController(command_id), remainder
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([command.Command])
|
@wsme_pecan.wsexpose([command.Command])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all commands."""
|
"""Returns all commands."""
|
||||||
@ -62,6 +67,7 @@ class CommandsController(rest.RestController):
|
|||||||
commands = handler.get_all()
|
commands = handler.get_all()
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(command.Command,
|
@wsme_pecan.wsexpose(command.Command,
|
||||||
body=command.Command,
|
body=command.Command,
|
||||||
status_code=201)
|
status_code=201)
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import contactgroup
|
from surveil.api.datamodel.config import contactgroup
|
||||||
from surveil.api.handlers.config import contactgroup_handler
|
from surveil.api.handlers.config import contactgroup_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ContactGroupsController(rest.RestController):
|
class ContactGroupsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([contactgroup.ContactGroup])
|
@wsme_pecan.wsexpose([contactgroup.ContactGroup])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all contact groups."""
|
"""Returns all contact groups."""
|
||||||
@ -30,6 +32,7 @@ class ContactGroupsController(rest.RestController):
|
|||||||
contact_groups = handler.get_all()
|
contact_groups = handler.get_all()
|
||||||
return contact_groups
|
return contact_groups
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(contactgroup.ContactGroup, unicode)
|
@wsme_pecan.wsexpose(contactgroup.ContactGroup, unicode)
|
||||||
def get_one(self, group_name):
|
def get_one(self, group_name):
|
||||||
"""Returns a contact group."""
|
"""Returns a contact group."""
|
||||||
@ -37,6 +40,7 @@ class ContactGroupsController(rest.RestController):
|
|||||||
contactgroup = handler.get(group_name)
|
contactgroup = handler.get(group_name)
|
||||||
return contactgroup
|
return contactgroup
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=contactgroup.ContactGroup, status_code=201)
|
@wsme_pecan.wsexpose(body=contactgroup.ContactGroup, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new contact group.
|
"""Create a new contact group.
|
||||||
@ -46,12 +50,14 @@ class ContactGroupsController(rest.RestController):
|
|||||||
handler = contactgroup_handler.ContactGroupHandler(pecan.request)
|
handler = contactgroup_handler.ContactGroupHandler(pecan.request)
|
||||||
handler.create(data)
|
handler.create(data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(contactgroup.ContactGroup, unicode, status_code=204)
|
@wsme_pecan.wsexpose(contactgroup.ContactGroup, unicode, status_code=204)
|
||||||
def delete(self, group_name):
|
def delete(self, group_name):
|
||||||
"""Delete a specific contact group."""
|
"""Delete a specific contact group."""
|
||||||
handler = contactgroup_handler.ContactGroupHandler(pecan.request)
|
handler = contactgroup_handler.ContactGroupHandler(pecan.request)
|
||||||
handler.delete(group_name)
|
handler.delete(group_name)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(contactgroup.ContactGroup,
|
@wsme_pecan.wsexpose(contactgroup.ContactGroup,
|
||||||
unicode,
|
unicode,
|
||||||
body=contactgroup.ContactGroup,
|
body=contactgroup.ContactGroup,
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import contact
|
from surveil.api.datamodel.config import contact
|
||||||
from surveil.api.handlers.config import contact_handler
|
from surveil.api.handlers.config import contact_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ContactsController(rest.RestController):
|
class ContactsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([contact.Contact])
|
@wsme_pecan.wsexpose([contact.Contact])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all hosts."""
|
"""Returns all hosts."""
|
||||||
@ -30,6 +32,7 @@ class ContactsController(rest.RestController):
|
|||||||
hosts = handler.get_all()
|
hosts = handler.get_all()
|
||||||
return hosts
|
return hosts
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(contact.Contact, unicode)
|
@wsme_pecan.wsexpose(contact.Contact, unicode)
|
||||||
def get_one(self, contact_name):
|
def get_one(self, contact_name):
|
||||||
"""Returns a specific contact."""
|
"""Returns a specific contact."""
|
||||||
@ -37,6 +40,7 @@ class ContactsController(rest.RestController):
|
|||||||
contact = handler.get(contact_name)
|
contact = handler.get(contact_name)
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=contact.Contact, status_code=201)
|
@wsme_pecan.wsexpose(body=contact.Contact, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new contact.
|
"""Create a new contact.
|
||||||
@ -46,12 +50,14 @@ class ContactsController(rest.RestController):
|
|||||||
handler = contact_handler.ContactHandler(pecan.request)
|
handler = contact_handler.ContactHandler(pecan.request)
|
||||||
handler.create(data)
|
handler.create(data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(contact.Contact, unicode, status_code=204)
|
@wsme_pecan.wsexpose(contact.Contact, unicode, status_code=204)
|
||||||
def delete(self, contact_name):
|
def delete(self, contact_name):
|
||||||
"""Returns a specific contact."""
|
"""Returns a specific contact."""
|
||||||
handler = contact_handler.ContactHandler(pecan.request)
|
handler = contact_handler.ContactHandler(pecan.request)
|
||||||
handler.delete(contact_name)
|
handler.delete(contact_name)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(contact.Contact,
|
@wsme_pecan.wsexpose(contact.Contact,
|
||||||
unicode,
|
unicode,
|
||||||
body=contact.Contact,
|
body=contact.Contact,
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import hostgroup
|
from surveil.api.datamodel.config import hostgroup
|
||||||
from surveil.api.handlers.config import hostgroup_handler
|
from surveil.api.handlers.config import hostgroup_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class HostGroupsController(rest.RestController):
|
class HostGroupsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([hostgroup.HostGroup])
|
@wsme_pecan.wsexpose([hostgroup.HostGroup])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all host groups."""
|
"""Returns all host groups."""
|
||||||
@ -30,6 +32,7 @@ class HostGroupsController(rest.RestController):
|
|||||||
host_groups = handler.get_all()
|
host_groups = handler.get_all()
|
||||||
return host_groups
|
return host_groups
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(hostgroup.HostGroup, unicode)
|
@wsme_pecan.wsexpose(hostgroup.HostGroup, unicode)
|
||||||
def get_one(self, group_name):
|
def get_one(self, group_name):
|
||||||
"""Returns a host group."""
|
"""Returns a host group."""
|
||||||
@ -37,6 +40,7 @@ class HostGroupsController(rest.RestController):
|
|||||||
hostgroup = handler.get(group_name)
|
hostgroup = handler.get(group_name)
|
||||||
return hostgroup
|
return hostgroup
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=hostgroup.HostGroup, status_code=201)
|
@wsme_pecan.wsexpose(body=hostgroup.HostGroup, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new host group.
|
"""Create a new host group.
|
||||||
@ -46,12 +50,14 @@ class HostGroupsController(rest.RestController):
|
|||||||
handler = hostgroup_handler.HostGroupHandler(pecan.request)
|
handler = hostgroup_handler.HostGroupHandler(pecan.request)
|
||||||
handler.create(data)
|
handler.create(data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(hostgroup.HostGroup, unicode, status_code=204)
|
@wsme_pecan.wsexpose(hostgroup.HostGroup, unicode, status_code=204)
|
||||||
def delete(self, group_name):
|
def delete(self, group_name):
|
||||||
"""Returns a specific host group."""
|
"""Returns a specific host group."""
|
||||||
handler = hostgroup_handler.HostGroupHandler(pecan.request)
|
handler = hostgroup_handler.HostGroupHandler(pecan.request)
|
||||||
handler.delete(group_name)
|
handler.delete(group_name)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(hostgroup.HostGroup,
|
@wsme_pecan.wsexpose(hostgroup.HostGroup,
|
||||||
unicode,
|
unicode,
|
||||||
body=hostgroup.HostGroup,
|
body=hostgroup.HostGroup,
|
||||||
|
@ -22,10 +22,12 @@ from surveil.api.datamodel.config import host
|
|||||||
from surveil.api.datamodel.config import service
|
from surveil.api.datamodel.config import service
|
||||||
from surveil.api.handlers.config import host_handler
|
from surveil.api.handlers.config import host_handler
|
||||||
from surveil.api.handlers.config import service_handler
|
from surveil.api.handlers.config import service_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ServiceCheckResultsSubController(rest.RestController):
|
class ServiceCheckResultsSubController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=checkresult.CheckResult, status_code=204)
|
@wsme_pecan.wsexpose(body=checkresult.CheckResult, status_code=204)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Submit a new check result.
|
"""Submit a new check result.
|
||||||
@ -52,6 +54,7 @@ class HostServiceSubController(rest.RestController):
|
|||||||
pecan.request.context['service_description'] = service_description
|
pecan.request.context['service_description'] = service_description
|
||||||
self._id = service_description
|
self._id = service_description
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(service.Service)
|
@wsme_pecan.wsexpose(service.Service)
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Returns a specific service."""
|
"""Returns a specific service."""
|
||||||
@ -62,6 +65,7 @@ class HostServiceSubController(rest.RestController):
|
|||||||
)
|
)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(None, status_code=204)
|
@wsme_pecan.wsexpose(None, status_code=204)
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""Delete a specific service."""
|
"""Delete a specific service."""
|
||||||
@ -74,6 +78,7 @@ class HostServiceSubController(rest.RestController):
|
|||||||
|
|
||||||
class HostServicesSubController(rest.RestController):
|
class HostServicesSubController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([service.Service])
|
@wsme_pecan.wsexpose([service.Service])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all services assocaited with this host."""
|
"""Returns all services assocaited with this host."""
|
||||||
@ -90,6 +95,7 @@ class HostServicesSubController(rest.RestController):
|
|||||||
|
|
||||||
class HostCheckResultsSubController(rest.RestController):
|
class HostCheckResultsSubController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=checkresult.CheckResult, status_code=204)
|
@wsme_pecan.wsexpose(body=checkresult.CheckResult, status_code=204)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Submit a new check result.
|
"""Submit a new check result.
|
||||||
@ -116,6 +122,7 @@ class HostController(rest.RestController):
|
|||||||
pecan.request.context['host_name'] = host_name
|
pecan.request.context['host_name'] = host_name
|
||||||
self._id = host_name
|
self._id = host_name
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(host.Host)
|
@wsme_pecan.wsexpose(host.Host)
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Returns a specific host."""
|
"""Returns a specific host."""
|
||||||
@ -123,6 +130,7 @@ class HostController(rest.RestController):
|
|||||||
h = handler.get(self._id)
|
h = handler.get(self._id)
|
||||||
return h
|
return h
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(None, body=host.Host, status_code=204)
|
@wsme_pecan.wsexpose(None, body=host.Host, status_code=204)
|
||||||
def put(self, data):
|
def put(self, data):
|
||||||
"""Modify this host.
|
"""Modify this host.
|
||||||
@ -132,6 +140,7 @@ class HostController(rest.RestController):
|
|||||||
handler = host_handler.HostHandler(pecan.request)
|
handler = host_handler.HostHandler(pecan.request)
|
||||||
handler.update(self._id, data)
|
handler.update(self._id, data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(None, status_code=204)
|
@wsme_pecan.wsexpose(None, status_code=204)
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""Delete this host."""
|
"""Delete this host."""
|
||||||
@ -149,6 +158,7 @@ class HostsController(rest.RestController):
|
|||||||
def _lookup(self, host_name, *remainder):
|
def _lookup(self, host_name, *remainder):
|
||||||
return HostController(host_name), remainder
|
return HostController(host_name), remainder
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([host.Host])
|
@wsme_pecan.wsexpose([host.Host])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all hosts."""
|
"""Returns all hosts."""
|
||||||
@ -156,6 +166,7 @@ class HostsController(rest.RestController):
|
|||||||
hosts = handler.get_all()
|
hosts = handler.get_all()
|
||||||
return hosts
|
return hosts
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(host.Host, body=host.Host, status_code=201)
|
@wsme_pecan.wsexpose(host.Host, body=host.Host, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new host.
|
"""Create a new host.
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import realm
|
from surveil.api.datamodel.config import realm
|
||||||
from surveil.api.handlers.config import realm_handler
|
from surveil.api.handlers.config import realm_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class RealmsController(rest.RestController):
|
class RealmsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([realm.Realm])
|
@wsme_pecan.wsexpose([realm.Realm])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all realms."""
|
"""Returns all realms."""
|
||||||
@ -30,6 +32,7 @@ class RealmsController(rest.RestController):
|
|||||||
realms = handler.get_all()
|
realms = handler.get_all()
|
||||||
return realms
|
return realms
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(realm.Realm, unicode)
|
@wsme_pecan.wsexpose(realm.Realm, unicode)
|
||||||
def get_one(self, realm_name):
|
def get_one(self, realm_name):
|
||||||
"""Returns a specific realm."""
|
"""Returns a specific realm."""
|
||||||
@ -37,6 +40,7 @@ class RealmsController(rest.RestController):
|
|||||||
realm = handler.get(realm_name)
|
realm = handler.get(realm_name)
|
||||||
return realm
|
return realm
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=realm.Realm, status_code=201)
|
@wsme_pecan.wsexpose(body=realm.Realm, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new realm.
|
"""Create a new realm.
|
||||||
@ -46,12 +50,14 @@ class RealmsController(rest.RestController):
|
|||||||
handler = realm_handler.RealmHandler(pecan.request)
|
handler = realm_handler.RealmHandler(pecan.request)
|
||||||
handler.create(data)
|
handler.create(data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(realm.Realm, unicode, status_code=204)
|
@wsme_pecan.wsexpose(realm.Realm, unicode, status_code=204)
|
||||||
def delete(self, realm_name):
|
def delete(self, realm_name):
|
||||||
"""Deletes a specific realm."""
|
"""Deletes a specific realm."""
|
||||||
handler = realm_handler.RealmHandler(pecan.request)
|
handler = realm_handler.RealmHandler(pecan.request)
|
||||||
handler.delete(realm_name)
|
handler.delete(realm_name)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(realm.Realm,
|
@wsme_pecan.wsexpose(realm.Realm,
|
||||||
unicode,
|
unicode,
|
||||||
body=realm.Realm,
|
body=realm.Realm,
|
||||||
|
@ -18,10 +18,12 @@ import requests
|
|||||||
import wsmeext.pecan as wsme_pecan
|
import wsmeext.pecan as wsme_pecan
|
||||||
|
|
||||||
from surveil.api.datamodel import info
|
from surveil.api.datamodel import info
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ReloadConfigController(rest.RestController):
|
class ReloadConfigController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(info.Info)
|
@wsme_pecan.wsexpose(info.Info)
|
||||||
def post(self):
|
def post(self):
|
||||||
"""Reloads Shinken's config."""
|
"""Reloads Shinken's config."""
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import servicegroup
|
from surveil.api.datamodel.config import servicegroup
|
||||||
from surveil.api.handlers.config import servicegroup_handler
|
from surveil.api.handlers.config import servicegroup_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ServiceGroupsController(rest.RestController):
|
class ServiceGroupsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([servicegroup.ServiceGroup])
|
@wsme_pecan.wsexpose([servicegroup.ServiceGroup])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all service groups."""
|
"""Returns all service groups."""
|
||||||
@ -30,6 +32,7 @@ class ServiceGroupsController(rest.RestController):
|
|||||||
service_groups = handler.get_all()
|
service_groups = handler.get_all()
|
||||||
return service_groups
|
return service_groups
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(servicegroup.ServiceGroup, unicode)
|
@wsme_pecan.wsexpose(servicegroup.ServiceGroup, unicode)
|
||||||
def get_one(self, group_name):
|
def get_one(self, group_name):
|
||||||
"""Returns a service group."""
|
"""Returns a service group."""
|
||||||
@ -37,6 +40,7 @@ class ServiceGroupsController(rest.RestController):
|
|||||||
servicegroup = handler.get(group_name)
|
servicegroup = handler.get(group_name)
|
||||||
return servicegroup
|
return servicegroup
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=servicegroup.ServiceGroup, status_code=201)
|
@wsme_pecan.wsexpose(body=servicegroup.ServiceGroup, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new service group.
|
"""Create a new service group.
|
||||||
@ -46,12 +50,14 @@ class ServiceGroupsController(rest.RestController):
|
|||||||
handler = servicegroup_handler.ServiceGroupHandler(pecan.request)
|
handler = servicegroup_handler.ServiceGroupHandler(pecan.request)
|
||||||
handler.create(data)
|
handler.create(data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(servicegroup.ServiceGroup, unicode, status_code=204)
|
@wsme_pecan.wsexpose(servicegroup.ServiceGroup, unicode, status_code=204)
|
||||||
def delete(self, group_name):
|
def delete(self, group_name):
|
||||||
"""Returns a specific service group."""
|
"""Returns a specific service group."""
|
||||||
handler = servicegroup_handler.ServiceGroupHandler(pecan.request)
|
handler = servicegroup_handler.ServiceGroupHandler(pecan.request)
|
||||||
handler.delete(group_name)
|
handler.delete(group_name)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(servicegroup.ServiceGroup,
|
@wsme_pecan.wsexpose(servicegroup.ServiceGroup,
|
||||||
unicode,
|
unicode,
|
||||||
body=servicegroup.ServiceGroup,
|
body=servicegroup.ServiceGroup,
|
||||||
|
@ -18,10 +18,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import service
|
from surveil.api.datamodel.config import service
|
||||||
from surveil.api.handlers.config import service_handler
|
from surveil.api.handlers.config import service_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ServicesController(rest.RestController):
|
class ServicesController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([service.Service])
|
@wsme_pecan.wsexpose([service.Service])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all services."""
|
"""Returns all services."""
|
||||||
@ -29,6 +31,7 @@ class ServicesController(rest.RestController):
|
|||||||
services = handler.get_all()
|
services = handler.get_all()
|
||||||
return services
|
return services
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(service.Service,
|
@wsme_pecan.wsexpose(service.Service,
|
||||||
body=service.Service,
|
body=service.Service,
|
||||||
status_code=201)
|
status_code=201)
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
|
|
||||||
from surveil.api.datamodel.config import timeperiod
|
from surveil.api.datamodel.config import timeperiod
|
||||||
from surveil.api.handlers.config import timeperiod_handler
|
from surveil.api.handlers.config import timeperiod_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class TimePeriodsController(rest.RestController):
|
class TimePeriodsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([timeperiod.TimePeriod])
|
@wsme_pecan.wsexpose([timeperiod.TimePeriod])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all time periods."""
|
"""Returns all time periods."""
|
||||||
@ -30,6 +32,7 @@ class TimePeriodsController(rest.RestController):
|
|||||||
time_periods = handler.get_all()
|
time_periods = handler.get_all()
|
||||||
return time_periods
|
return time_periods
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(timeperiod.TimePeriod, unicode)
|
@wsme_pecan.wsexpose(timeperiod.TimePeriod, unicode)
|
||||||
def get_one(self, timeperiod_name):
|
def get_one(self, timeperiod_name):
|
||||||
"""Returns a specific time period."""
|
"""Returns a specific time period."""
|
||||||
@ -37,6 +40,7 @@ class TimePeriodsController(rest.RestController):
|
|||||||
timeperiod = handler.get(timeperiod_name)
|
timeperiod = handler.get(timeperiod_name)
|
||||||
return timeperiod
|
return timeperiod
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(body=timeperiod.TimePeriod, status_code=201)
|
@wsme_pecan.wsexpose(body=timeperiod.TimePeriod, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new time period.
|
"""Create a new time period.
|
||||||
@ -46,12 +50,14 @@ class TimePeriodsController(rest.RestController):
|
|||||||
handler = timeperiod_handler.TimePeriodHandler(pecan.request)
|
handler = timeperiod_handler.TimePeriodHandler(pecan.request)
|
||||||
handler.create(data)
|
handler.create(data)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(timeperiod.TimePeriod, unicode, status_code=204)
|
@wsme_pecan.wsexpose(timeperiod.TimePeriod, unicode, status_code=204)
|
||||||
def delete(self, timeperiod_name):
|
def delete(self, timeperiod_name):
|
||||||
"""Returns a specific time period."""
|
"""Returns a specific time period."""
|
||||||
handler = timeperiod_handler.TimePeriodHandler(pecan.request)
|
handler = timeperiod_handler.TimePeriodHandler(pecan.request)
|
||||||
handler.delete(timeperiod_name)
|
handler.delete(timeperiod_name)
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(timeperiod.TimePeriod,
|
@wsme_pecan.wsexpose(timeperiod.TimePeriod,
|
||||||
unicode,
|
unicode,
|
||||||
body=timeperiod.TimePeriod,
|
body=timeperiod.TimePeriod,
|
||||||
|
@ -20,6 +20,7 @@ from surveil.api.controllers.v2.logs import acknowledgements
|
|||||||
from surveil.api.controllers.v2.logs import comments
|
from surveil.api.controllers.v2.logs import comments
|
||||||
from surveil.api.controllers.v2.logs import downtimes
|
from surveil.api.controllers.v2.logs import downtimes
|
||||||
from surveil.api.controllers.v2.logs import notifications
|
from surveil.api.controllers.v2.logs import notifications
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class LogsController(rest.RestController):
|
class LogsController(rest.RestController):
|
||||||
@ -29,6 +30,7 @@ class LogsController(rest.RestController):
|
|||||||
notifications = notifications.NotificationsController()
|
notifications = notifications.NotificationsController()
|
||||||
|
|
||||||
# @wsme_pecan.wsexpose([Host])
|
# @wsme_pecan.wsexpose([Host])
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all events from a specific host."""
|
"""Returns all events from a specific host."""
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
|
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class AcknowledgementsController(rest.RestController):
|
class AcknowledgementsController(rest.RestController):
|
||||||
|
|
||||||
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
||||||
# @wsme_pecan.wsexpose([Host])
|
# @wsme_pecan.wsexpose([Host])
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all acks from a specific host."""
|
"""Returns all acks from a specific host."""
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
|
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class CommentsController(rest.RestController):
|
class CommentsController(rest.RestController):
|
||||||
|
|
||||||
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
||||||
# @wsme_pecan.wsexpose([Host])
|
# @wsme_pecan.wsexpose([Host])
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all comments from a specific host."""
|
"""Returns all comments from a specific host."""
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
|
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class DowntimesController(rest.RestController):
|
class DowntimesController(rest.RestController):
|
||||||
|
|
||||||
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
||||||
# @wsme_pecan.wsexpose([Host])
|
# @wsme_pecan.wsexpose([Host])
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all downtimes from a specific host."""
|
"""Returns all downtimes from a specific host."""
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
|
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class NotificationsController(rest.RestController):
|
class NotificationsController(rest.RestController):
|
||||||
|
|
||||||
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
# curl -X GET http://127.0.0.1:8080/v2/titilambert/myproject/builds/
|
||||||
# @wsme_pecan.wsexpose([Host])
|
# @wsme_pecan.wsexpose([Host])
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all notifications from a specific host."""
|
"""Returns all notifications from a specific host."""
|
||||||
|
@ -18,10 +18,12 @@ import requests
|
|||||||
import wsmeext.pecan as wsme_pecan
|
import wsmeext.pecan as wsme_pecan
|
||||||
|
|
||||||
from surveil.api.controllers.v1.datamodel import info
|
from surveil.api.controllers.v1.datamodel import info
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ReloadConfigController(rest.RestController):
|
class ReloadConfigController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(info.Info)
|
@wsme_pecan.wsexpose(info.Info)
|
||||||
def post(self):
|
def post(self):
|
||||||
"""Reloads Shinken's config."""
|
"""Reloads Shinken's config."""
|
||||||
|
@ -17,10 +17,12 @@ from pecan import rest
|
|||||||
import wsmeext.pecan as wsme_pecan
|
import wsmeext.pecan as wsme_pecan
|
||||||
|
|
||||||
from surveil.api.controllers.v1.datamodel import service
|
from surveil.api.controllers.v1.datamodel import service
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ServicesController(rest.RestController):
|
class ServicesController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([service.Service])
|
@wsme_pecan.wsexpose([service.Service])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all services."""
|
"""Returns all services."""
|
||||||
@ -33,6 +35,7 @@ class ServicesController(rest.RestController):
|
|||||||
|
|
||||||
return [service.Service(**s) for s in services]
|
return [service.Service(**s) for s in services]
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(service.Service,
|
@wsme_pecan.wsexpose(service.Service,
|
||||||
body=service.Service,
|
body=service.Service,
|
||||||
status_code=201)
|
status_code=201)
|
||||||
|
@ -23,10 +23,12 @@ from surveil.api.datamodel.status import live_query
|
|||||||
from surveil.api.datamodel.status import live_service
|
from surveil.api.datamodel.status import live_service
|
||||||
from surveil.api.handlers.status import live_host_handler
|
from surveil.api.handlers.status import live_host_handler
|
||||||
from surveil.api.handlers.status import live_service_handler
|
from surveil.api.handlers.status import live_service_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class HostsController(rest.RestController):
|
class HostsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([live_host.LiveHost])
|
@wsme_pecan.wsexpose([live_host.LiveHost])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all hosts."""
|
"""Returns all hosts."""
|
||||||
@ -34,6 +36,7 @@ class HostsController(rest.RestController):
|
|||||||
hosts = handler.get_all()
|
hosts = handler.get_all()
|
||||||
return hosts
|
return hosts
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([live_host.LiveHost], body=live_query.LiveQuery)
|
@wsme_pecan.wsexpose([live_host.LiveHost], body=live_query.LiveQuery)
|
||||||
def post(self, query):
|
def post(self, query):
|
||||||
"""Given a LiveQuery, returns all matching hosts."""
|
"""Given a LiveQuery, returns all matching hosts."""
|
||||||
@ -48,6 +51,7 @@ class HostsController(rest.RestController):
|
|||||||
|
|
||||||
class ConfigController(rest.RestController):
|
class ConfigController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns config from a specific host."""
|
"""Returns config from a specific host."""
|
||||||
@ -67,6 +71,7 @@ class HostServiceController(rest.RestController):
|
|||||||
pecan.request.context['service_name'] = service_name
|
pecan.request.context['service_name'] = service_name
|
||||||
self.service_name = service_name
|
self.service_name = service_name
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(live_service.LiveService)
|
@wsme_pecan.wsexpose(live_service.LiveService)
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Returns a specific host service."""
|
"""Returns a specific host service."""
|
||||||
@ -91,6 +96,7 @@ class HostController(rest.RestController):
|
|||||||
pecan.request.context['host_name'] = host_name
|
pecan.request.context['host_name'] = host_name
|
||||||
self.host_name = host_name
|
self.host_name = host_name
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose(live_host.LiveHost)
|
@wsme_pecan.wsexpose(live_host.LiveHost)
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Returns a specific host."""
|
"""Returns a specific host."""
|
||||||
|
@ -16,8 +16,12 @@ import pecan
|
|||||||
from pecan import rest
|
from pecan import rest
|
||||||
|
|
||||||
|
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class MetricsController(rest.RestController):
|
class MetricsController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all metrics."""
|
"""Returns all metrics."""
|
||||||
@ -27,6 +31,7 @@ class MetricsController(rest.RestController):
|
|||||||
|
|
||||||
return '{"host_name": "NOHOSTNAME", "metrics" : "22"}'
|
return '{"host_name": "NOHOSTNAME", "metrics" : "22"}'
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def _lookup(self, *args):
|
def _lookup(self, *args):
|
||||||
props = {}
|
props = {}
|
||||||
@ -53,6 +58,7 @@ class MetricController(rest.RestController):
|
|||||||
self.sd = service_description
|
self.sd = service_description
|
||||||
self.metric = metric
|
self.metric = metric
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@pecan.expose()
|
@pecan.expose()
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Returns (specific) metrics."""
|
"""Returns (specific) metrics."""
|
||||||
|
@ -19,10 +19,12 @@ import wsmeext.pecan as wsme_pecan
|
|||||||
from surveil.api.datamodel.status import live_query
|
from surveil.api.datamodel.status import live_query
|
||||||
from surveil.api.datamodel.status import live_service
|
from surveil.api.datamodel.status import live_service
|
||||||
from surveil.api.handlers.status import live_service_handler
|
from surveil.api.handlers.status import live_service_handler
|
||||||
|
from surveil.common import util
|
||||||
|
|
||||||
|
|
||||||
class ServicesController(rest.RestController):
|
class ServicesController(rest.RestController):
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([live_service.LiveService])
|
@wsme_pecan.wsexpose([live_service.LiveService])
|
||||||
def get_all(self):
|
def get_all(self):
|
||||||
"""Returns all services."""
|
"""Returns all services."""
|
||||||
@ -30,6 +32,7 @@ class ServicesController(rest.RestController):
|
|||||||
services = handler.get_all()
|
services = handler.get_all()
|
||||||
return services
|
return services
|
||||||
|
|
||||||
|
@util.policy_enforce(['authenticated'])
|
||||||
@wsme_pecan.wsexpose([live_service.LiveService], body=live_query.LiveQuery)
|
@wsme_pecan.wsexpose([live_service.LiveService], body=live_query.LiveQuery)
|
||||||
def post(self, query):
|
def post(self, query):
|
||||||
"""Given a LiveQuery, returns all matching services."""
|
"""Given a LiveQuery, returns all matching services."""
|
||||||
|
@ -58,7 +58,9 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Reload the surveil config
|
# Reload the surveil config
|
||||||
cli_surveil = sc.Client('http://localhost:8080/v2', version='2_0')
|
cli_surveil = sc.Client('http://localhost:8080/v2',
|
||||||
|
auth_url='http://localhost:8080/v2/auth',
|
||||||
|
version='2_0')
|
||||||
|
|
||||||
cli_surveil.config.hosts.create(
|
cli_surveil.config.hosts.create(
|
||||||
use="generic-host",
|
use="generic-host",
|
||||||
|
@ -28,7 +28,7 @@ class TestAcknowledgeController(functionalTest.FunctionalTest):
|
|||||||
"host_name": "localhost"
|
"host_name": "localhost"
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.post_json("/v2/actions/acknowledge/", params=ack)
|
response = self.post_json("/v2/actions/acknowledge/", params=ack)
|
||||||
|
|
||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class TestAcknowledgeController(functionalTest.FunctionalTest):
|
|||||||
"host_name": "localhost",
|
"host_name": "localhost",
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.delete_json("/v2/actions/downtime/", params=ack)
|
response = self.delete_json("/v2/actions/downtime/", params=ack)
|
||||||
|
|
||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class TestDowntimeController(functionalTest.FunctionalTest):
|
|||||||
"duration": 86400
|
"duration": 86400
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.post_json("/v2/actions/downtime/", params=dt)
|
response = self.post_json("/v2/actions/downtime/", params=dt)
|
||||||
|
|
||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ class TestDowntimeController(functionalTest.FunctionalTest):
|
|||||||
"duration": 86400
|
"duration": 86400
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.delete_json("/v2/actions/downtime/", params=dt)
|
response = self.delete_json("/v2/actions/downtime/", params=dt)
|
||||||
|
|
||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class TestAuthController(functionalTest.FunctionalTest):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.post_json('/v2/auth/tokens', params=auth)
|
response = self.post_json('/v2/auth/tokens', params=auth)
|
||||||
|
|
||||||
expected = {
|
expected = {
|
||||||
"access": {
|
"access": {
|
||||||
|
@ -34,7 +34,7 @@ class TestCommandController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_commands(self):
|
def test_get_all_commands(self):
|
||||||
response = self.app.get('/v2/config/commands')
|
response = self.get('/v2/config/commands')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -44,7 +44,7 @@ class TestCommandController(functionalTest.FunctionalTest):
|
|||||||
|
|
||||||
def test_get_specific_command(self):
|
def test_get_specific_command(self):
|
||||||
|
|
||||||
response = self.app.get('/v2/config/commands/check_test2')
|
response = self.get('/v2/config/commands/check_test2')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -55,7 +55,7 @@ class TestCommandController(functionalTest.FunctionalTest):
|
|||||||
def test_update_command(self):
|
def test_update_command(self):
|
||||||
put_body = {"command_line": "test_put",
|
put_body = {"command_line": "test_put",
|
||||||
"command_name": "check_test2"}
|
"command_name": "check_test2"}
|
||||||
response = self.app.put_json(
|
response = self.put_json(
|
||||||
"/v2/config/commands/check_test2", params=put_body
|
"/v2/config/commands/check_test2", params=put_body
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class TestCommandController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 204)
|
self.assertEqual(response.status_int, 204)
|
||||||
|
|
||||||
def test_delete_command(self):
|
def test_delete_command(self):
|
||||||
response = self.app.delete('/v2/config/commands/check_test2')
|
response = self.delete('/v2/config/commands/check_test2')
|
||||||
|
|
||||||
expected_commands = [
|
expected_commands = [
|
||||||
{u"command_name": u"check_test1",
|
{u"command_name": u"check_test1",
|
||||||
@ -89,7 +89,7 @@ class TestCommandController(functionalTest.FunctionalTest):
|
|||||||
"command_name": "newcommand",
|
"command_name": "newcommand",
|
||||||
"command_line": "/usr/bin/newcommand -hello"
|
"command_line": "/usr/bin/newcommand -hello"
|
||||||
}
|
}
|
||||||
response = self.app.post_json(
|
response = self.post_json(
|
||||||
"/v2/config/commands",
|
"/v2/config/commands",
|
||||||
params=new_command
|
params=new_command
|
||||||
)
|
)
|
||||||
|
@ -39,7 +39,7 @@ class TestContactGroupsController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_contactgroups(self):
|
def test_get_all_contactgroups(self):
|
||||||
response = self.app.get('/v2/config/contactgroups')
|
response = self.get('/v2/config/contactgroups')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -48,7 +48,7 @@ class TestContactGroupsController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
def test_get_one_contactgroup(self):
|
def test_get_one_contactgroup(self):
|
||||||
response = self.app.get('/v2/config/contactgroups/novell-admins')
|
response = self.get('/v2/config/contactgroups/novell-admins')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -61,7 +61,7 @@ class TestContactGroupsController(functionalTest.FunctionalTest):
|
|||||||
members="marie,bob,joe",
|
members="marie,bob,joe",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.post_json('/v2/config/contactgroups', g.as_dict())
|
self.post_json('/v2/config/contactgroups', g.as_dict())
|
||||||
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
self.mongoconnection.shinken.contactgroups.find_one(g.as_dict())
|
self.mongoconnection.shinken.contactgroups.find_one(g.as_dict())
|
||||||
@ -72,7 +72,7 @@ class TestContactGroupsController(functionalTest.FunctionalTest):
|
|||||||
self.mongoconnection.shinken.contactgroups.find_one(self.groups[0])
|
self.mongoconnection.shinken.contactgroups.find_one(self.groups[0])
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.delete('/v2/config/contactgroups/novell-admins')
|
self.delete('/v2/config/contactgroups/novell-admins')
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
self.mongoconnection.shinken.contactgroups.find_one(self.groups[0])
|
self.mongoconnection.shinken.contactgroups.find_one(self.groups[0])
|
||||||
@ -86,7 +86,7 @@ class TestContactGroupsController(functionalTest.FunctionalTest):
|
|||||||
'jdoe,rtobert,tzach'
|
'jdoe,rtobert,tzach'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.put_json(
|
self.put_json(
|
||||||
'/v2/config/contactgroups/novell-admins',
|
'/v2/config/contactgroups/novell-admins',
|
||||||
{"contactgroup_name": "novell-admins",
|
{"contactgroup_name": "novell-admins",
|
||||||
"members": "updated"}
|
"members": "updated"}
|
||||||
|
@ -39,7 +39,7 @@ class TestContactsController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_contacts(self):
|
def test_get_all_contacts(self):
|
||||||
response = self.app.get('/v2/config/contacts')
|
response = self.get('/v2/config/contacts')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -48,7 +48,7 @@ class TestContactsController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
def test_get_one_contact(self):
|
def test_get_one_contact(self):
|
||||||
response = self.app.get('/v2/config/contacts/bobby')
|
response = self.get('/v2/config/contacts/bobby')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -60,7 +60,7 @@ class TestContactsController(functionalTest.FunctionalTest):
|
|||||||
contact_name='John'
|
contact_name='John'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.post_json('/v2/config/contacts', c.as_dict())
|
self.post_json('/v2/config/contacts', c.as_dict())
|
||||||
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
self.mongoconnection.shinken.contacts.find_one(c.as_dict())
|
self.mongoconnection.shinken.contacts.find_one(c.as_dict())
|
||||||
@ -71,7 +71,7 @@ class TestContactsController(functionalTest.FunctionalTest):
|
|||||||
self.mongoconnection.shinken.contacts.find_one(self.contacts[0])
|
self.mongoconnection.shinken.contacts.find_one(self.contacts[0])
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.delete('/v2/config/contacts/bobby')
|
self.delete('/v2/config/contacts/bobby')
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
self.mongoconnection.shinken.contacts.find_one(self.contacts[0])
|
self.mongoconnection.shinken.contacts.find_one(self.contacts[0])
|
||||||
@ -85,7 +85,7 @@ class TestContactsController(functionalTest.FunctionalTest):
|
|||||||
'bob@bob.com'
|
'bob@bob.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.put_json(
|
self.put_json(
|
||||||
'/v2/config/contacts/bobby',
|
'/v2/config/contacts/bobby',
|
||||||
{"contact_name": "bobby", "email": "updated@bob.com"}
|
{"contact_name": "bobby", "email": "updated@bob.com"}
|
||||||
)
|
)
|
||||||
|
@ -39,7 +39,7 @@ class TestHostGroupsController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_hostgroups(self):
|
def test_get_all_hostgroups(self):
|
||||||
response = self.app.get('/v2/config/hostgroups')
|
response = self.get('/v2/config/hostgroups')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -48,7 +48,7 @@ class TestHostGroupsController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
def test_get_one_hostgroups(self):
|
def test_get_one_hostgroups(self):
|
||||||
response = self.app.get('/v2/config/hostgroups/novell-servers')
|
response = self.get('/v2/config/hostgroups/novell-servers')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -61,7 +61,7 @@ class TestHostGroupsController(functionalTest.FunctionalTest):
|
|||||||
members="marie,bob,joe",
|
members="marie,bob,joe",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.post_json('/v2/config/hostgroups', s.as_dict())
|
self.post_json('/v2/config/hostgroups', s.as_dict())
|
||||||
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
self.mongoconnection.shinken.hostgroups.find_one(s.as_dict())
|
self.mongoconnection.shinken.hostgroups.find_one(s.as_dict())
|
||||||
@ -72,7 +72,7 @@ class TestHostGroupsController(functionalTest.FunctionalTest):
|
|||||||
self.mongoconnection.shinken.hostgroups.find_one(self.groups[0])
|
self.mongoconnection.shinken.hostgroups.find_one(self.groups[0])
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.delete('/v2/config/hostgroups/novell-servers')
|
self.delete('/v2/config/hostgroups/novell-servers')
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
self.mongoconnection.shinken.hostgroups.find_one(self.groups[0])
|
self.mongoconnection.shinken.hostgroups.find_one(self.groups[0])
|
||||||
@ -86,7 +86,7 @@ class TestHostGroupsController(functionalTest.FunctionalTest):
|
|||||||
'netware1,netware2,netware3,netware4'
|
'netware1,netware2,netware3,netware4'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.put_json(
|
self.put_json(
|
||||||
'/v2/config/hostgroups/novell-servers',
|
'/v2/config/hostgroups/novell-servers',
|
||||||
{"hostgroup_name": "novell-servers",
|
{"hostgroup_name": "novell-servers",
|
||||||
"members": "updated"}
|
"members": "updated"}
|
||||||
|
@ -70,7 +70,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_hosts(self):
|
def test_get_all_hosts(self):
|
||||||
response = self.app.get('/v2/config/hosts')
|
response = self.get('/v2/config/hosts')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -88,7 +88,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
"register": "0"}
|
"register": "0"}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
response = self.app.get('/v2/config/hosts')
|
response = self.get('/v2/config/hosts')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -97,7 +97,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
def test_get_specific_host(self):
|
def test_get_specific_host(self):
|
||||||
response = self.app.get('/v2/config/hosts/bogus-router333')
|
response = self.get('/v2/config/hosts/bogus-router333')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -116,7 +116,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
u"notification_interval": 333,
|
u"notification_interval": 333,
|
||||||
u"notification_period": u"newnotificationperiod"
|
u"notification_period": u"newnotificationperiod"
|
||||||
}
|
}
|
||||||
response = self.app.put_json(
|
response = self.put_json(
|
||||||
"/v2/config/hosts/bogus-router333", params=put_host
|
"/v2/config/hosts/bogus-router333", params=put_host
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 204)
|
self.assertEqual(response.status_int, 204)
|
||||||
|
|
||||||
def test_delete_host(self):
|
def test_delete_host(self):
|
||||||
response = self.app.delete('/v2/config/hosts/bogus-router')
|
response = self.delete('/v2/config/hosts/bogus-router')
|
||||||
|
|
||||||
mongo_hosts = [host.Host(**h) for h
|
mongo_hosts = [host.Host(**h) for h
|
||||||
in self.mongoconnection.shinken.hosts.find()]
|
in self.mongoconnection.shinken.hosts.find()]
|
||||||
@ -149,7 +149,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
"notification_interval": 3,
|
"notification_interval": 3,
|
||||||
"notification_period": "24x7"
|
"notification_period": "24x7"
|
||||||
}
|
}
|
||||||
response = self.app.post_json("/v2/config/hosts", params=new_host)
|
response = self.post_json("/v2/config/hosts", params=new_host)
|
||||||
|
|
||||||
hosts = [host.Host(**h).as_dict() for h
|
hosts = [host.Host(**h).as_dict() for h
|
||||||
in self.mongoconnection.shinken.hosts.find(None, {'_id': 0})]
|
in self.mongoconnection.shinken.hosts.find(None, {'_id': 0})]
|
||||||
@ -158,7 +158,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 201)
|
self.assertEqual(response.status_int, 201)
|
||||||
|
|
||||||
def test_get_associated_services(self):
|
def test_get_associated_services(self):
|
||||||
response = self.app.get('/v2/config/hosts/bogus-router/services')
|
response = self.get('/v2/config/hosts/bogus-router/services')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.services,
|
self.services,
|
||||||
@ -166,7 +166,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_specific_service(self):
|
def test_get_specific_service(self):
|
||||||
response = self.app.get(
|
response = self.get(
|
||||||
'/v2/config/hosts/bogus-router/services/service-example'
|
'/v2/config/hosts/bogus-router/services/service-example'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
in self.mongoconnection.shinken.services.find()]
|
in self.mongoconnection.shinken.services.find()]
|
||||||
self.assertEqual(1, len(mongo_services))
|
self.assertEqual(1, len(mongo_services))
|
||||||
|
|
||||||
self.app.delete(
|
self.delete(
|
||||||
'/v2/config/hosts/bogus-router/services/service-example'
|
'/v2/config/hosts/bogus-router/services/service-example'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
"time_stamp": "1409149234"
|
"time_stamp": "1409149234"
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.post_json(
|
response = self.post_json(
|
||||||
"/v2/config/hosts/bogus-router/services/service-example/results",
|
"/v2/config/hosts/bogus-router/services/service-example/results",
|
||||||
params=check_result
|
params=check_result
|
||||||
)
|
)
|
||||||
@ -228,8 +228,8 @@ class TestHostController(functionalTest.FunctionalTest):
|
|||||||
"time_stamp": "1409149234"
|
"time_stamp": "1409149234"
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.post_json("/v2/config/hosts/bogus-router/results",
|
response = self.post_json("/v2/config/hosts/bogus-router/results",
|
||||||
params=check_result)
|
params=check_result)
|
||||||
|
|
||||||
self.assertEqual(response.status_int, 204)
|
self.assertEqual(response.status_int, 204)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -41,7 +41,7 @@ class TestRealmsController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_realms(self):
|
def test_get_all_realms(self):
|
||||||
response = self.app.get('/v2/config/realms')
|
response = self.get('/v2/config/realms')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -50,7 +50,7 @@ class TestRealmsController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
def test_get_one_realm(self):
|
def test_get_one_realm(self):
|
||||||
response = self.app.get('/v2/config/realms/World')
|
response = self.get('/v2/config/realms/World')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -64,7 +64,7 @@ class TestRealmsController(functionalTest.FunctionalTest):
|
|||||||
default=1
|
default=1
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.post_json('/v2/config/realms', r.as_dict())
|
self.post_json('/v2/config/realms', r.as_dict())
|
||||||
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
self.mongoconnection.shinken.realms.find_one(r.as_dict())
|
self.mongoconnection.shinken.realms.find_one(r.as_dict())
|
||||||
@ -75,7 +75,7 @@ class TestRealmsController(functionalTest.FunctionalTest):
|
|||||||
self.mongoconnection.shinken.realms.find_one(self.realms[0])
|
self.mongoconnection.shinken.realms.find_one(self.realms[0])
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.delete('/v2/config/realms/World')
|
self.delete('/v2/config/realms/World')
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
self.mongoconnection.shinken.realms.find_one(self.realms[0])
|
self.mongoconnection.shinken.realms.find_one(self.realms[0])
|
||||||
@ -89,7 +89,7 @@ class TestRealmsController(functionalTest.FunctionalTest):
|
|||||||
'Europe,America,Asia'
|
'Europe,America,Asia'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.put_json(
|
self.put_json(
|
||||||
'/v2/config/realms/World',
|
'/v2/config/realms/World',
|
||||||
{"realm_name": "World",
|
{"realm_name": "World",
|
||||||
"realm_members": "updated",
|
"realm_members": "updated",
|
||||||
|
@ -24,7 +24,7 @@ class TestReloadConfigController(functionalTest.FunctionalTest):
|
|||||||
httpretty.register_uri(httpretty.POST,
|
httpretty.register_uri(httpretty.POST,
|
||||||
self.ws_arbiter_url + "/reload")
|
self.ws_arbiter_url + "/reload")
|
||||||
|
|
||||||
response = self.app.post("/v2/config/reload_config")
|
response = self.post("/v2/config/reload_config")
|
||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
httpretty.last_request().path,
|
httpretty.last_request().path,
|
||||||
|
@ -39,7 +39,7 @@ class TestServiceGroupsController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_servicegroups(self):
|
def test_get_all_servicegroups(self):
|
||||||
response = self.app.get('/v2/config/servicegroups')
|
response = self.get('/v2/config/servicegroups')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -48,7 +48,7 @@ class TestServiceGroupsController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
def test_get_one_servicegroup(self):
|
def test_get_one_servicegroup(self):
|
||||||
response = self.app.get('/v2/config/servicegroups/dbservices')
|
response = self.get('/v2/config/servicegroups/dbservices')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -61,7 +61,7 @@ class TestServiceGroupsController(functionalTest.FunctionalTest):
|
|||||||
members="marie,bob,joe",
|
members="marie,bob,joe",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.post_json('/v2/config/servicegroups', s.as_dict())
|
self.post_json('/v2/config/servicegroups', s.as_dict())
|
||||||
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
self.mongoconnection.shinken.servicegroups.find_one(s.as_dict())
|
self.mongoconnection.shinken.servicegroups.find_one(s.as_dict())
|
||||||
@ -72,7 +72,7 @@ class TestServiceGroupsController(functionalTest.FunctionalTest):
|
|||||||
self.mongoconnection.shinken.servicegroups.find_one(self.groups[0])
|
self.mongoconnection.shinken.servicegroups.find_one(self.groups[0])
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.delete('/v2/config/servicegroups/dbservices')
|
self.delete('/v2/config/servicegroups/dbservices')
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
self.mongoconnection.shinken.servicegroups.find_one(self.groups[0])
|
self.mongoconnection.shinken.servicegroups.find_one(self.groups[0])
|
||||||
@ -86,7 +86,7 @@ class TestServiceGroupsController(functionalTest.FunctionalTest):
|
|||||||
'ms1,SQL Server,ms1,SQL Serverc Agent,ms1,SQL DTC'
|
'ms1,SQL Server,ms1,SQL Serverc Agent,ms1,SQL DTC'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.put_json(
|
self.put_json(
|
||||||
'/v2/config/servicegroups/dbservices',
|
'/v2/config/servicegroups/dbservices',
|
||||||
{"servicegroup_name": "dbservices",
|
{"servicegroup_name": "dbservices",
|
||||||
"members": "updated"}
|
"members": "updated"}
|
||||||
|
@ -69,7 +69,7 @@ class TestServiceController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_services(self):
|
def test_get_all_services(self):
|
||||||
response = self.app.get('/v2/config/services')
|
response = self.get('/v2/config/services')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -94,7 +94,7 @@ class TestServiceController(functionalTest.FunctionalTest):
|
|||||||
"contact_groups": "linux-admins"}
|
"contact_groups": "linux-admins"}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
response = self.app.get('/v2/config/services')
|
response = self.get('/v2/config/services')
|
||||||
|
|
||||||
self.assert_count_equal_backport(
|
self.assert_count_equal_backport(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -116,7 +116,7 @@ class TestServiceController(functionalTest.FunctionalTest):
|
|||||||
"contacts": "surveil-ptl,surveil-bob",
|
"contacts": "surveil-ptl,surveil-bob",
|
||||||
"contact_groups": "linux-admins"
|
"contact_groups": "linux-admins"
|
||||||
}
|
}
|
||||||
response = self.app.post_json(
|
response = self.post_json(
|
||||||
"/v2/config/services",
|
"/v2/config/services",
|
||||||
params=new_service
|
params=new_service
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,7 @@ class TestTimePeriodsController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_get_all_timeperiods(self):
|
def test_get_all_timeperiods(self):
|
||||||
response = self.app.get('/v2/config/timeperiods')
|
response = self.get('/v2/config/timeperiods')
|
||||||
|
|
||||||
self.assertItemsEqual(
|
self.assertItemsEqual(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -56,7 +56,7 @@ class TestTimePeriodsController(functionalTest.FunctionalTest):
|
|||||||
self.assertEqual(response.status_int, 200)
|
self.assertEqual(response.status_int, 200)
|
||||||
|
|
||||||
def test_get_one_timeperiod(self):
|
def test_get_one_timeperiod(self):
|
||||||
response = self.app.get('/v2/config/timeperiods/nonworkhours')
|
response = self.get('/v2/config/timeperiods/nonworkhours')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(response.body.decode()),
|
json.loads(response.body.decode()),
|
||||||
@ -72,7 +72,7 @@ class TestTimePeriodsController(functionalTest.FunctionalTest):
|
|||||||
"tuesday": "pizza day"
|
"tuesday": "pizza day"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
self.app.post_json('/v2/config/timeperiods', t)
|
self.post_json('/v2/config/timeperiods', t)
|
||||||
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
self.mongoconnection.shinken.timeperiods.find_one(
|
self.mongoconnection.shinken.timeperiods.find_one(
|
||||||
@ -88,7 +88,7 @@ class TestTimePeriodsController(functionalTest.FunctionalTest):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.delete('/v2/config/timeperiods/nonworkhours')
|
self.delete('/v2/config/timeperiods/nonworkhours')
|
||||||
|
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
self.mongoconnection.shinken.timeperiods.find_one(
|
self.mongoconnection.shinken.timeperiods.find_one(
|
||||||
@ -104,7 +104,7 @@ class TestTimePeriodsController(functionalTest.FunctionalTest):
|
|||||||
'00:00-24:00'
|
'00:00-24:00'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.app.put_json(
|
self.put_json(
|
||||||
'/v2/config/timeperiods/nonworkhours',
|
'/v2/config/timeperiods/nonworkhours',
|
||||||
{"timeperiod_name": "nonworkhours",
|
{"timeperiod_name": "nonworkhours",
|
||||||
"periods": {"sunday": "updated"}}
|
"periods": {"sunday": "updated"}}
|
||||||
|
@ -104,7 +104,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
|
|||||||
"http://influxdb:8086/query",
|
"http://influxdb:8086/query",
|
||||||
body=self.influxdb_response)
|
body=self.influxdb_response)
|
||||||
|
|
||||||
response = self.app.get("/v2/status/hosts")
|
response = self.get("/v2/status/hosts")
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
{"description": "localhost",
|
{"description": "localhost",
|
||||||
@ -188,7 +188,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.post_json("/v2/status/hosts", params=query)
|
response = self.post_json("/v2/status/hosts", params=query)
|
||||||
|
|
||||||
expected = [{"host_name": "ws-arbiter", "last_check": 1429405764}]
|
expected = [{"host_name": "ws-arbiter", "last_check": 1429405764}]
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
|
|||||||
"http://influxdb:8086/query",
|
"http://influxdb:8086/query",
|
||||||
body=influx_response)
|
body=influx_response)
|
||||||
|
|
||||||
response = self.app.get("/v2/status/hosts/localhost")
|
response = self.get("/v2/status/hosts/localhost")
|
||||||
|
|
||||||
expected = {"childs": ["test_keystone"],
|
expected = {"childs": ["test_keystone"],
|
||||||
"description": "localhost",
|
"description": "localhost",
|
||||||
@ -297,7 +297,7 @@ class TestStatusHosts(functionalTest.FunctionalTest):
|
|||||||
"http://influxdb:8086/query",
|
"http://influxdb:8086/query",
|
||||||
body=influx_response)
|
body=influx_response)
|
||||||
|
|
||||||
response = self.app.get(
|
response = self.get(
|
||||||
"/v2/status/hosts/ws-arbiter/services/check-ws-arbiter"
|
"/v2/status/hosts/ws-arbiter/services/check-ws-arbiter"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class TestStatusServices(functionalTest.FunctionalTest):
|
|||||||
"http://influxdb:8086/query",
|
"http://influxdb:8086/query",
|
||||||
body=self.influxdb_response)
|
body=self.influxdb_response)
|
||||||
|
|
||||||
response = self.app.get("/v2/status/services")
|
response = self.get("/v2/status/services")
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
{'description': 'Check KeyStone service.',
|
{'description': 'Check KeyStone service.',
|
||||||
@ -161,7 +161,7 @@ class TestStatusServices(functionalTest.FunctionalTest):
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.app.post_json("/v2/status/services", params=query)
|
response = self.post_json("/v2/status/services", params=query)
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
{'host_name': 'test_keystone',
|
{'host_name': 'test_keystone',
|
||||||
|
@ -18,10 +18,10 @@ from surveil.tests.api import functionalTest
|
|||||||
class TestHelloController(functionalTest.FunctionalTest):
|
class TestHelloController(functionalTest.FunctionalTest):
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
response = self.app.get('/v2/hello')
|
response = self.get('/v2/hello')
|
||||||
self.assertEqual(response.body, b"Hello World!")
|
self.assertEqual(response.body, b"Hello World!")
|
||||||
assert response.status_int == 200
|
assert response.status_int == 200
|
||||||
|
|
||||||
def test_post_policy_forbidden(self):
|
def test_post_policy_forbidden(self):
|
||||||
with self.assertRaisesRegexp(Exception, '403 Forbidden'):
|
with self.assertRaisesRegexp(Exception, '403 Forbidden'):
|
||||||
self.app.get('/v2/hello/denied')
|
self.get('/v2/hello/denied')
|
||||||
|
@ -89,13 +89,17 @@ class FunctionalTest(base.BaseTestCase):
|
|||||||
'X-Service-Roles': 'surveil',
|
'X-Service-Roles': 'surveil',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def make_action(verb):
|
||||||
|
target = getattr(self.app, verb)
|
||||||
|
|
||||||
|
def func(*args, **kwargs):
|
||||||
|
kwargs.setdefault('headers', self.auth_headers)
|
||||||
|
return target(*args, **kwargs)
|
||||||
|
return func
|
||||||
|
|
||||||
|
for action in ('get', 'post', 'put', 'delete',
|
||||||
|
'post', 'post_json', 'put_json'):
|
||||||
|
setattr(self, action, make_action(action))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pecan.set_config({}, overwrite=True)
|
pecan.set_config({}, overwrite=True)
|
||||||
|
|
||||||
def post_json(self, *args, **kwargs):
|
|
||||||
kwargs.setdefault('headers', self.auth_headers)
|
|
||||||
return self.app.post_json(*args, **kwargs)
|
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
|
||||||
kwargs.setdefault('headers', self.auth_headers)
|
|
||||||
return self.app.get(*args, **kwargs)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user