Skip to content

Commit

Permalink
Temporary push for save commit!
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Mohier authored and mohierf committed Dec 24, 2019
1 parent 32f1dab commit 515d589
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 76 deletions.
16 changes: 10 additions & 6 deletions alignak/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
import sys
import time
import json
import tempfile
import resource
import socket
import signal
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions alignak/objects/checkmodulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 5 additions & 13 deletions alignak/objects/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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()
Expand Down
24 changes: 6 additions & 18 deletions alignak/objects/notificationway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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))
12 changes: 6 additions & 6 deletions docker/data/alignak/etc/alignak.d/daemons.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker/data/alignak/etc/base/templates/generic-contact.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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!!!
Expand Down
2 changes: 1 addition & 1 deletion docker/data/alignak/etc/realms/North/contacts/contacts.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
define contact{
use north-contact
contact_name north-admin
alias Administrateur europe
alias Administrateur North

contactgroups admins

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions docker/image-alignak-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LABEL maintainer="Frédéric Mohier ([email protected])" \
ENV DEBIAN_FRONTEND noninteractive

# Run as the root user
USER root
#USER root

RUN apt-get install -y --no-install-recommends \
nginx \
Expand Down Expand Up @@ -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/
Expand Down
8 changes: 4 additions & 4 deletions docker/image-alignak-ui/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ 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
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
Expand Down
8 changes: 4 additions & 4 deletions docker/image-alignak/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

Expand All @@ -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" ]

0 comments on commit 515d589

Please sign in to comment.