"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/events/src/eventsapiconf.py" (16 Sep 2020, 2040 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "eventsapiconf.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 8.1_vs_8.2.

    1 # -*- coding: utf-8 -*-
    2 #
    3 #  Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
    4 #  This file is part of GlusterFS.
    5 #
    6 #  This file is licensed to you under your choice of the GNU Lesser
    7 #  General Public License, version 3 or any later version (LGPLv3 or
    8 #  later), or the GNU General Public License, version 2 (GPLv2), in all
    9 #  cases as published by the Free Software Foundation.
   10 #
   11 
   12 import subprocess
   13 glusterd_workdir = None
   14 
   15 # Methods
   16 def get_glusterd_workdir():
   17     global glusterd_workdir
   18     if glusterd_workdir is not None:
   19         return glusterd_workdir
   20     proc = subprocess.Popen(["gluster", "system::", "getwd"],
   21                             stdout=subprocess.PIPE, stderr=subprocess.PIPE,
   22                             universal_newlines = True)
   23     out, err = proc.communicate()
   24     if proc.returncode == 0:
   25         glusterd_workdir = out.strip()
   26     else:
   27         glusterd_workdir = "/var/lib/glusterd"
   28     return glusterd_workdir
   29 
   30 SERVER_ADDRESS = "0.0.0.0"
   31 SERVER_ADDRESSv4 = "0.0.0.0"
   32 SERVER_ADDRESSv6 = "::1"
   33 DEFAULT_CONFIG_FILE = "/usr/local/etc/glusterfs/eventsconfig.json"
   34 CUSTOM_CONFIG_FILE_TO_SYNC = "/events/config.json"
   35 CUSTOM_CONFIG_FILE = get_glusterd_workdir() + CUSTOM_CONFIG_FILE_TO_SYNC
   36 WEBHOOKS_FILE_TO_SYNC = "/events/webhooks.json"
   37 WEBHOOKS_FILE = get_glusterd_workdir() + WEBHOOKS_FILE_TO_SYNC
   38 LOG_FILE = "/var/log/glusterfs/events.log"
   39 EVENTSD = "glustereventsd"
   40 CONFIG_KEYS = ["log-level", "port", "disable-events-log"]
   41 BOOL_CONFIGS = ["disable-events-log"]
   42 INT_CONFIGS = ["port"]
   43 RESTART_CONFIGS = ["port"]
   44 EVENTS_ENABLED = 1
   45 UUID_FILE = get_glusterd_workdir() + "/glusterd.info"
   46 PID_FILE = "/var/run/glustereventsd.pid"
   47 AUTO_BOOL_ATTRIBUTES = ["force", "push-pem", "no-verify"]
   48 AUTO_INT_ATTRIBUTES = ["ssh-port"]
   49 CERTS_DIR = get_glusterd_workdir() + "/events"
   50 
   51 # Errors
   52 ERROR_SAME_CONFIG = 2
   53 ERROR_ALL_NODES_STATUS_NOT_OK = 3
   54 ERROR_PARTIAL_SUCCESS = 4
   55 ERROR_WEBHOOK_ALREADY_EXISTS = 5
   56 ERROR_WEBHOOK_NOT_EXISTS = 6
   57 ERROR_INVALID_CONFIG = 7
   58 ERROR_WEBHOOK_SYNC_FAILED = 8
   59 ERROR_CONFIG_SYNC_FAILED = 9