Added reload_config controller

Change-Id: I383c41e79c316921a6eca5bd723006125306319c
This commit is contained in:
aviau 2015-01-30 15:34:44 -05:00 committed by Alexandre Viau
parent 9d07d3c63b
commit 08281da553
10 changed files with 97 additions and 8 deletions

View File

@ -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

View 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

View 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.')

View File

@ -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()

View File

@ -122,6 +122,8 @@ def main(args=None):
}
)
# Reload the surveil config
cli_surveil.reload_config()
if __name__ == '__main__':
sys.exit(main())

View 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'
)

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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