add gluster to config file

This commit is contained in:
petrucci4prez 2017-06-03 18:11:58 -04:00
parent 5b464eb02c
commit b8f918dca1
3 changed files with 20 additions and 17 deletions

View File

@ -1,5 +0,0 @@
gmail:
passwd: bwsasfxqjbookmed
recipientList:
- natedwarshuis@gmail.com
username: natedwarshuis@gmail.com

View File

@ -3,3 +3,8 @@ gmail:
recipientList: recipientList:
- example@gmail.com - example@gmail.com
username: example@gmail.com username: example@gmail.com
gluster:
server: example.com
volume: pyledriver
mountpoint: /mnt/glusterfs/pyledriver
options: backupvolfile-server=example.com

View File

@ -12,6 +12,7 @@ Logger conventions
import logging, os import logging, os
from subprocess import run, PIPE, CalledProcessError from subprocess import run, PIPE, CalledProcessError
from logging.handlers import TimedRotatingFileHandler, SMTPHandler from logging.handlers import TimedRotatingFileHandler, SMTPHandler
from config import configFile
from auxilary import mkdirSafe from auxilary import mkdirSafe
def _formatConsole(gluster = False): def _formatConsole(gluster = False):
@ -20,7 +21,7 @@ def _formatConsole(gluster = False):
''' '''
c = '' if gluster else '[CONSOLE ONLY] ' c = '' if gluster else '[CONSOLE ONLY] '
fmt = logging.Formatter('[%(name)s] [%(levelname)s] ' + c + '%(message)s') fmt = logging.Formatter('[%(name)s] [%(levelname)s] ' + c + '%(message)s')
console.setFormatter(fmt) console.setFormatter(fmt)
class GlusterFSHandler(TimedRotatingFileHandler): class GlusterFSHandler(TimedRotatingFileHandler):
''' '''
@ -94,16 +95,15 @@ rootLogger.addHandler(console)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# 3) mount glusterfs, any errors here will go to console output # 3) mount glusterfs, any errors here will go to console output
gluster = GlusterFSHandler( glusterConf = configFile['gluster']
server = '192.168.11.39',
volume = 'pyledriver',
mountpoint = '/mnt/glusterfs/pyledriver',
options = 'backupvolfile-server=192.168.11.48'
)
# 4) once gluster is mounted, add to root logger and remove "console only" warning from console if glusterConf['server'] != 'example.com':
rootLogger.addHandler(gluster) gluster = GlusterFSHandler(**glusterConf)
_formatConsole(gluster = True) rootLogger.addHandler(gluster)
_formatConsole(gluster = True)
else:
logger.error('Gluster not configured. Please update config/pyledriver.yaml')
raise SystemExit
# 5) import gmail, this must come here as it uses loggers for some of its setup # 5) import gmail, this must come here as it uses loggers for some of its setup
from gmail import gmail, GmailHandler from gmail import gmail, GmailHandler
@ -118,5 +118,8 @@ rootLogger.addHandler(gmail)
Clean up Clean up
''' '''
def unmountGluster(): def unmountGluster():
rootLogger.removeHandler(gluster) try:
_formatConsole(gluster = False) rootLogger.removeHandler(gluster)
_formatConsole(gluster = False)
except NameError:
pass