Added reload_config controller
Change-Id: I383c41e79c316921a6eca5bd723006125306319c
This commit is contained in:
parent
9d07d3c63b
commit
08281da553
@ -4,11 +4,11 @@ MAINTAINER Alexandre Viau <alexandre.viau@savoirfairelinux.com>
|
||||
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y vim
|
||||
RUN apt-get install -y vim supervisor
|
||||
|
||||
### Shinken
|
||||
RUN apt-get install -y python-pip
|
||||
RUN useradd shinken && pip install https://github.com/naparuba/shinken/archive/master.tar.gz
|
||||
RUN useradd shinken && pip install https://github.com/naparuba/shinken/archive/2.2-RC1.zip
|
||||
RUN apt-get install -y python-pycurl
|
||||
RUN shinken --init
|
||||
|
||||
@ -44,6 +44,9 @@ ADD tools/docker/etc/shinken /etc/shinken
|
||||
RUN chown -R root:shinken /etc/shinken
|
||||
|
||||
### Surveil
|
||||
## Package deps
|
||||
RUN apt-get install -y python3-pip python-dev libffi-dev libssl-dev
|
||||
|
||||
## Copy files
|
||||
ADD surveil /surveil/surveil
|
||||
ADD setup.cfg /surveil/setup.cfg
|
||||
@ -53,13 +56,11 @@ ADD .git /surveil/.git
|
||||
ADD README.rst surveil/README.rst
|
||||
|
||||
## Install
|
||||
RUN apt-get install -y python3-pip python-dev libffi-dev libssl-dev
|
||||
RUN pip install -r /surveil/requirements.txt
|
||||
RUN apt-get install -y git
|
||||
RUN cd surveil && python setup.py install
|
||||
|
||||
### Supervisor
|
||||
RUN apt-get -y install supervisor
|
||||
ADD tools/docker/etc/supervisor /etc/supervisor
|
||||
|
||||
# Shinken WEBUI
|
||||
|
19
surveil/api/controllers/v1/datamodel/info.py
Normal file
19
surveil/api/controllers/v1/datamodel/info.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2014 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import wsme
|
||||
|
||||
|
||||
class Info(wsme.types.Base):
|
||||
message = wsme.types.text
|
33
surveil/api/controllers/v1/reload_config.py
Normal file
33
surveil/api/controllers/v1/reload_config.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright 2014 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import pecan
|
||||
from pecan import rest
|
||||
import requests
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from surveil.api.controllers.v1.datamodel import info
|
||||
|
||||
|
||||
class ReloadConfigController(rest.RestController):
|
||||
|
||||
@wsme_pecan.wsexpose(info.Info)
|
||||
def post(self):
|
||||
"""Reloads Shinken's config."""
|
||||
|
||||
requests.post(
|
||||
pecan.request.ws_arbiter_url + "/reload"
|
||||
)
|
||||
|
||||
return info.Info(message='Arbiter reloading.')
|
@ -15,6 +15,7 @@
|
||||
from surveil.api.controllers.v1 import commands
|
||||
from surveil.api.controllers.v1 import hello
|
||||
from surveil.api.controllers.v1 import hosts
|
||||
from surveil.api.controllers.v1 import reload_config
|
||||
from surveil.api.controllers.v1 import services
|
||||
|
||||
|
||||
@ -24,3 +25,4 @@ class V1Controller(object):
|
||||
hosts = hosts.HostsController()
|
||||
commands = commands.CommandsController()
|
||||
services = services.ServicesController()
|
||||
reload_config = reload_config.ReloadConfigController()
|
||||
|
@ -122,6 +122,8 @@ def main(args=None):
|
||||
}
|
||||
)
|
||||
|
||||
# Reload the surveil config
|
||||
cli_surveil.reload_config()
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
32
surveil/tests/api/controllers/v1/test_reload_config.py
Normal file
32
surveil/tests/api/controllers/v1/test_reload_config.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Copyright 2014 - Savoir-Faire Linux inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveil.tests.api import functionalTest
|
||||
|
||||
|
||||
class TestReloadConfigController(functionalTest.FunctionalTest):
|
||||
|
||||
@httpretty.activate
|
||||
def test_reload_config(self):
|
||||
httpretty.register_uri(httpretty.POST,
|
||||
self.ws_arbiter_url + "/reload")
|
||||
|
||||
response = self.app.post("/v1/reload_config")
|
||||
self.assertEqual(response.status_int, 200)
|
||||
self.assertEqual(
|
||||
httpretty.last_request().path,
|
||||
'/reload'
|
||||
)
|
@ -35,7 +35,7 @@ define arbiter {
|
||||
# - FileTag = Tag an host if it's on a flat file
|
||||
# - CSVTag = Tag an host from the content of a CSV file
|
||||
|
||||
modules named-pipe,mongodb
|
||||
modules named-pipe,mongodb,ws-arbiter
|
||||
#modules named-pipe, mongodb, nsca, VMWare_auto_linking, ws-arbiter, Collectd, mport-landscape, SnmpBooster, AWS
|
||||
|
||||
# Enable https or not
|
||||
|
@ -1,5 +1,5 @@
|
||||
define command {
|
||||
command_name reload-shinken
|
||||
command_line sudo /etc/init.d/shinken reload
|
||||
command_line /etc/init.d/shinken reload
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
define command {
|
||||
command_name restart-shinken
|
||||
command_line sudo /etc/init.d/shinken restart
|
||||
command_line /etc/init.d/shinken restart
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ define receiver {
|
||||
# - TSCA = TSCA server
|
||||
# - ws-arbiter = WebService for pushing results to the arbiter
|
||||
# - Collectd = Receive collectd perfdata
|
||||
modules ws-arbiter
|
||||
modules
|
||||
|
||||
# Enable https or not
|
||||
use_ssl 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user