diff --git a/alignak/daemon.py b/alignak/daemon.py index 7aa0ac233..c564a0096 100644 --- a/alignak/daemon.py +++ b/alignak/daemon.py @@ -127,6 +127,7 @@ import sys import time import json +import tempfile import resource import socket import signal @@ -654,12 +655,6 @@ def __init__(self, name, **kwargs): else: print("Daemon '%s' log file: %s" % (self.name, self.log_filename)) - # Check the log directory (and create if it does not exist) - # self.check_dir(os.path.dirname(self.log_filename)) - - # Specific monitoring log directory - # self.check_dir(os.path.join(os.path.dirname(self.log_filename), 'monitoring-log')) - if 'log_filename' not in kwargs or not kwargs['log_filename']: # Log file name is not overridden, the logger will use the configured default one if self.log_cherrypy: @@ -809,6 +804,10 @@ def check_dir(self, dir_name, create): relative to the working directory. It will return the full path of the directory + If the daemon is in very mode (arbiter -V command line) and the directory + cannot be created, then this function will return the system temporary files + directory + :param create: create if it does not exist :type create: bool @@ -857,6 +856,11 @@ def check_dir(self, dir_name, create): return dir_name except OSError as exp: + if self.verify_only and exp.errno == 13: + # In verify mode, forward directory to the /tmp + print("Exception: %s" % exp) + return tempfile.gettempdir() + if exp.errno == errno.EEXIST and os.path.isdir(dir_name): # Directory still exists... pass diff --git a/alignak/objects/checkmodulation.py b/alignak/objects/checkmodulation.py index 4396677a2..c56d63a47 100644 --- a/alignak/objects/checkmodulation.py +++ b/alignak/objects/checkmodulation.py @@ -161,23 +161,3 @@ def linkify(self, timeperiods, commands): """ self.linkify_with_timeperiods(timeperiods, 'check_period') self.linkify_with_commands(commands, 'check_command') - - def new_inner_member(self, name=None, params=None): - """Create a CheckModulation object and add it to items - - :param name: CheckModulation name - :type name: str - :param params: parameters to init CheckModulation - :type params: dict - :return: None - TODO: Remove this default mutable argument. Usually result in unexpected behavior - """ - if name is None: - name = 'Generated_checkmodulation_%s' % uuid.uuid4() - - if params is None: - params = {} - - params['checkmodulation_name'] = name - checkmodulation = CheckModulation(params) - self.add_item(checkmodulation) diff --git a/alignak/objects/contact.py b/alignak/objects/contact.py index 747a83c87..f0be09361 100644 --- a/alignak/objects/contact.py +++ b/alignak/objects/contact.py @@ -54,6 +54,7 @@ import logging from alignak.misc.serialization import unserialize from alignak.objects.item import Item +from alignak.objects.notificationway import NotificationWay from alignak.objects.commandcallitem import CommandCallItems from alignak.util import strip_and_uniq @@ -177,13 +178,6 @@ class Contact(Item): 'contact_name' ) - simple_way_parameters = ( - 'service_notification_period', 'host_notification_period', - 'service_notification_options', 'host_notification_options', - 'service_notification_commands', 'host_notification_commands', - 'min_business_impact' - ) - def __init__(self, params, parsing=True): # When deserialized, those are dict if not parsing: @@ -320,8 +314,8 @@ def want_host_notification(self, notifways, timeperiods, timestamp, state, n_typ def get_notification_commands(self, notifways, n_type, command_name=False): """Get notification commands for object type - :param notifways: list of alignak.objects.NotificationWay objects - :type notifways: NotificationWays + :param notifways: list of notification ways objects + :type notifways: alignak.objects.notificationway.NotificationWays :param n_type: object type (host or service) :type n_type: string :param command_name: True to update the inner property with the name of the command, @@ -337,10 +331,9 @@ def get_notification_commands(self, notifways, n_type, command_name=False): res.extend(notifway.get_notification_commands(n_type)) # Update inner notification commands property with command name or command + setattr(self, n_type + '_notification_commands', res) if command_name: setattr(self, n_type + '_notification_commands', [c.get_name() for c in res]) - else: - setattr(self, n_type + '_notification_commands', res) return res @@ -495,8 +488,7 @@ def explode(self, contactgroups, notificationways): for contactgroup in contact.contactgroups: contactgroups.add_member(contact.contact_name, contactgroup.strip()) - # Now create a notification way with the simple parameter of the - # contacts + # Now create a notification way with the simple parameter of the contacts for contact in self: # Fill default values for all the properties contact.fill_default() diff --git a/alignak/objects/notificationway.py b/alignak/objects/notificationway.py index 1ec5b95da..0bdc6c04b 100644 --- a/alignak/objects/notificationway.py +++ b/alignak/objects/notificationway.py @@ -54,6 +54,7 @@ """ import logging from alignak.objects.item import Item +from alignak.misc.serialization import serialize, unserialize from alignak.objects.commandcallitem import CommandCallItems from alignak.property import IntegerProp, StringProp, ListProp, FULL_STATUS @@ -153,11 +154,11 @@ def service_notifications_enabled(self): def serialize(self): res = super(NotificationWay, self).serialize() - for prop in ['service_notification_commands', 'host_notification_commands']: - if getattr(self, prop) is None: - res[prop] = None - else: - res[prop] = [elem.serialize() for elem in getattr(self, prop)] + res['service_notification_commands'] = \ + [elem.serialize() for elem in getattr(self, 'service_notification_commands')] + + res['host_notification_commands'] = \ + [elem.serialize() for elem in getattr(self, 'host_notification_commands')] return res @@ -362,16 +363,3 @@ def linkify(self, timeperiods, commands): self.linkify_with_timeperiods(timeperiods, 'host_notification_period') self.linkify_with_commands(commands, 'service_notification_commands', is_a_list=True) self.linkify_with_commands(commands, 'host_notification_commands', is_a_list=True) - - def new_inner_member(self, name, params): - """Create new instance of NotificationWay with given name and parameters - and add it to the item list - - :param name: notification way name - :type name: str - :param params: notification wat parameters - :type params: dict - :return: None - """ - params['notificationway_name'] = name - self.add_item(NotificationWay(params)) diff --git a/docker/data/alignak/etc/alignak.d/daemons.ini b/docker/data/alignak/etc/alignak.d/daemons.ini index 551a573b4..10915d1fe 100755 --- a/docker/data/alignak/etc/alignak.d/daemons.ini +++ b/docker/data/alignak/etc/alignak.d/daemons.ini @@ -22,7 +22,7 @@ name=arbiter-master ;host=127.0.0.1 ; Set the host to 0.0.0.0 to allow Arbiter WS access from another system port=7770 -; My adress for the other daemons +; My address for the other daemons ;address=127.0.0.1 ; Modules @@ -42,7 +42,7 @@ name=scheduler-master ; My listening interface ;host=127.0.0.1 port=7768 -; My adress for the other daemons +; My address for the other daemons ;address=127.0.0.1 ; Modules @@ -70,7 +70,7 @@ name=poller-master ; My listening interface ;host=127.0.0.1 port=7771 -; My adress for the other daemons +; My address for the other daemons ;address=127.0.0.1 ; Modules @@ -114,7 +114,7 @@ name=reactionner-master ; My listening interface ;host=127.0.0.1 port=7769 -; My adress for the other daemons +; My address for the other daemons ;address=127.0.0.1 ; Modules @@ -156,7 +156,7 @@ name=broker-master ; My listening interface ;host=127.0.0.1 port=7772 -; My adress for the other daemons +; My address for the other daemons ;address=127.0.0.1 ; Advanced parameters: @@ -187,7 +187,7 @@ name=receiver-master ; My listening interface ;host=127.0.0.1 port=7773 -; My adress for the other daemons +; My address for the other daemons ;address=127.0.0.1 ; Modules diff --git a/docker/data/alignak/etc/base/templates/generic-contact.cfg b/docker/data/alignak/etc/base/templates/generic-contact.cfg index a4f56d263..066e4667f 100755 --- a/docker/data/alignak/etc/base/templates/generic-contact.cfg +++ b/docker/data/alignak/etc/base/templates/generic-contact.cfg @@ -12,8 +12,8 @@ define contact{ # else the default created notification ways raise a configuration error! service_notification_period 24x7 host_notification_period 24x7 - host_notification_commands notify-host-by-log - service_notification_commands notify-service-by-log + # # # host_notification_commands notify-host-by-log + # # # service_notification_commands notify-service-by-log # Only useful for the UI... # Change this default password!!! diff --git a/docker/data/alignak/etc/realms/North/contacts/contacts.cfg b/docker/data/alignak/etc/realms/North/contacts/contacts.cfg index 19330131a..acb82a4ee 100755 --- a/docker/data/alignak/etc/realms/North/contacts/contacts.cfg +++ b/docker/data/alignak/etc/realms/North/contacts/contacts.cfg @@ -2,7 +2,7 @@ define contact{ use north-contact contact_name north-admin - alias Administrateur europe + alias Administrateur North contactgroups admins diff --git a/docker/data/alignak/etc/realms/North/hostgroups/hostgroups.cfg b/docker/data/alignak/etc/realms/North/hostgroups/hostgroups.cfg index 9aeeca4a7..52a868e49 100755 --- a/docker/data/alignak/etc/realms/North/hostgroups/hostgroups.cfg +++ b/docker/data/alignak/etc/realms/North/hostgroups/hostgroups.cfg @@ -1,10 +1,14 @@ define hostgroup{ hostgroup_name north-routers alias North routers + + realm North #members } define hostgroup{ hostgroup_name north alias North hosts + + realm North } diff --git a/docker/data/alignak/etc/realms/South/hostgroups/hostgroups.cfg b/docker/data/alignak/etc/realms/South/hostgroups/hostgroups.cfg index bfab76cfd..f79cf44c1 100755 --- a/docker/data/alignak/etc/realms/South/hostgroups/hostgroups.cfg +++ b/docker/data/alignak/etc/realms/South/hostgroups/hostgroups.cfg @@ -1,10 +1,14 @@ define hostgroup{ hostgroup_name south-routers alias South routers + + realm South #members } define hostgroup{ hostgroup_name south alias South hosts + + realm South } diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 67c577d7e..e5792b348 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -9,6 +9,7 @@ services: context: ./image-alignak args: PYTHON_BASE_VERSION: 3.6 + ALIGNAK_IMAGE_TAG: ${ALIGNAK_IMAGE_TAG} ALIGNAK_SHARE_DIR: /alignak ALIGNAK_GIT_REPO: ${ALIGNAK_GIT_REPO} env_file: @@ -90,6 +91,7 @@ services: build: context: image-alignak-ui args: + ALIGNAK_IMAGE_TAG: ${ALIGNAK_IMAGE_TAG} ALIGNAK_SHARE_DIR: /alignak SHINKEN_WEBUI_GIT_REPO: ${SHINKEN_WEBUI_GIT_REPO} SHINKEN_UI_GRAPHITE_GIT_REPO: ${SHINKEN_UI_GRAPHITE_GIT_REPO} diff --git a/docker/image-alignak-ui/Dockerfile b/docker/image-alignak-ui/Dockerfile index a706b6abc..f9f04c245 100644 --- a/docker/image-alignak-ui/Dockerfile +++ b/docker/image-alignak-ui/Dockerfile @@ -14,7 +14,7 @@ LABEL maintainer="Frédéric Mohier (frederic.mohier@alignak.net)" \ ENV DEBIAN_FRONTEND noninteractive # Run as the root user -USER root +#USER root RUN apt-get install -y --no-install-recommends \ nginx \ @@ -51,7 +51,7 @@ ENV ALIGNAK_GROUP "alignak" ENV ALIGNAK_USER "alignak" # Run as the newly created user -USER $ALIGNAK_USER +#USER $ALIGNAK_USER # Copy the Nginx global conf COPY nginx.conf /etc/nginx/ diff --git a/docker/image-alignak-ui/supervisord.conf b/docker/image-alignak-ui/supervisord.conf index 5c854c33a..1f7ed6c8f 100644 --- a/docker/image-alignak-ui/supervisord.conf +++ b/docker/image-alignak-ui/supervisord.conf @@ -7,12 +7,12 @@ pidfile=/alignak/run/supervisord.pid ; pidfile location nodaemon=true ; do not run supervisord as a daemon minfds=1024 ; number of startup file descriptors minprocs=200 ; number of process descriptors -###user=root ; default user -user=alignak +user=root ; default user +### user=alignak [program:alignak-broker] -user=alignak +### user=alignak command=/usr/local/bin/alignak-broker -n broker-master -e %(ENV_ALIGNAK_CONFIGURATION_FILE)s stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 @@ -20,7 +20,7 @@ stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 [program:nginx] -user=alignak +### user=alignak command=/usr/sbin/nginx stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 diff --git a/docker/image-alignak/Dockerfile b/docker/image-alignak/Dockerfile index cbffd6c59..9048fba9c 100644 --- a/docker/image-alignak/Dockerfile +++ b/docker/image-alignak/Dockerfile @@ -35,13 +35,13 @@ RUN pip3 install --upgrade pip setuptools # Location for the git repositories RUN mkdir -p /repos -ARG ALIGNAK_GIT_REPO=alignak-monitoring/alignak # Get the Alignak repository on develop branch -RUN echo https://github.com/$ALIGNAK_GIT_REPO +ARG ALIGNAK_GIT_REPO=alignak-monitoring/alignak +ARG ALIGNAK_GIT_BRANCH=develop RUN cd /repos && \ git clone https://github.com/$ALIGNAK_GIT_REPO && \ cd alignak && \ - git checkout develop && \ + git checkout $ALIGNAK_GIT_BRANCH && \ pip3 install -r requirements.txt && \ pip3 install . @@ -62,7 +62,7 @@ RUN chown $ALIGNAK_USER:$ALIGNAK_GROUP $ALIGNAK_SHARE_DIR RUN chmod -R 775 $ALIGNAK_SHARE_DIR # Run as the newly created user -USER $ALIGNAK_USER +#USER $ALIGNAK_USER # Run the arbiter in check mode for the configuration in the Alignak directory CMD ["alignak-arbiter", "-V", "-e", "/alignak/etc/alignak.ini" ]