Esempio n. 1
0
 def test_write_log_to_file(self):
     os.remove(settings.LOG['file'])
     setup = logger.setup()
     body = 'TDD is awesome'
     event_type = 'test'
     with setup.applicationbound():
         log = logger.logger()
         log.info(event_type, body=body)
         self.assertTrue(os.path.exists(settings.LOG['file']))
         with open(settings.LOG['file'], 'r') as fd:
             text = fd.read()
             for required_info in \
                     [body, event_type, 'id',
                      'INFO', 'hivy.logger', 'timestamp']:
                 self.assertTrue(required_info in text)
Esempio n. 2
0
 def test_write_log_to_file(self):
     os.remove(settings.LOG['file'])
     setup = logger.setup()
     body = 'TDD is awesome'
     event_type = 'test'
     with setup.applicationbound():
         log = logger.logger()
         log.info(event_type, body=body)
         self.assertTrue(os.path.exists(settings.LOG['file']))
         with open(settings.LOG['file'], 'r') as fd:
             text = fd.read()
             for required_info in \
                     [body, event_type, 'id',
                      'INFO', 'hivy.logger', 'timestamp']:
                 self.assertTrue(required_info in text)
Esempio n. 3
0
  Expose Hivy server informations

  :copyright (c) 2014 Hive Tech, SAS.
  :license: Apache 2.0, see LICENSE for more details.
'''

import os
#import sh
from flask.ext import restful
from hivy import __api__
import hivy.utils as utils
import hivy.reactor.reactor as reactor
from hivy.logger import logger

log = logger(__name__)


class Status(restful.Resource):
    ''' Expose Hivy services states and versions '''

    def __init__(self):
        self.hivy_version = utils.Version()
        self.serf = reactor.Serf()
        #self.salt = sh.Command('/usr/bin/salt-master')

    def get(self):
        ''' Inspect Hivy, docker, salt-master and serf states '''
        log.info('request hivy status')
        docker_version, docker_status = utils.docker_check()
Esempio n. 4
0
 def test_get_hivy_logger(self):
     log = logger.logger('batman')
     self.assertTrue(hasattr(log, 'msg'))
     self.assertTrue(isinstance(log._logger, logbook.base.Logger))
     self.assertTrue(log._logger.name == 'batman')
Esempio n. 5
0
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
'''
  reactor subsystem
  -----------------

  Event-based, Hivy orchestrator

  :copyright (c) 2014 Garethr
  :license: Apache 2.0, see LICENSE for more details.
'''

import os
from hivy.logger import logger

log = logger('hivy.reactor.' + __name__)


class SerfHandler(object):
    ''' Wrap a serf event into a python friendly context '''
    def __init__(self):
        #TODO Payload on stdin
        #TODO All SERF_TAG_* variables
        #NOTE .get() are for testing, remove it later ?
        self.name = os.environ.get('SERF_SELF_NAME')
        self.role = os.environ.get('SERF_SELF_ROLE')
        if os.environ.get('SERF_EVENT', '') == 'user':
            self.event = os.environ.get('SERF_USER_EVENT')
        else:
            self.event = os.environ.get('SERF_EVENT', '').replace('-', '_')
Esempio n. 6
0
'''
  reactor subsystem
  -----------------

  Event-based, Hivy orchestrator

  :copyright (c) 2014 Garethr
  :license: Apache 2.0, see LICENSE for more details.
'''


import os
from hivy.logger import logger


log = logger('hivy.reactor.' + __name__)


class SerfHandler(object):
    ''' Wrap a serf event into a python friendly context '''

    def __init__(self):
        #TODO Payload on stdin
        #TODO All SERF_TAG_* variables
        #NOTE .get() are for testing, remove it later ?
        self.name = os.environ.get('SERF_SELF_NAME')
        self.role = os.environ.get('SERF_SELF_ROLE')
        if os.environ.get('SERF_EVENT', '') == 'user':
            self.event = os.environ.get('SERF_USER_EVENT')
        else:
            self.event = os.environ.get('SERF_EVENT', '').replace('-', '_')
Esempio n. 7
0
 def test_get_hivy_logger(self):
     log = logger.logger('batman')
     self.assertTrue(hasattr(log, 'msg'))
     self.assertTrue(isinstance(log._logger, logbook.base.Logger))
     self.assertTrue(log._logger.name == 'batman')