Esempio n. 1
0
    def __init__(self, config_path, debug, log=None, region=None):
        self.config_path = config_path
        self.config = utils.get_config(config_path)
        self.logger = utils.get_logger(__name__, self.config, debug, log)
        self.logger.debug('=> config file: %s' % config_path)
        self.debug = debug
        self.dry_run = False

        openstack = self.get_config_section('openstack')
        auth = v3.Password(auth_url=openstack['auth_url'],
                           username=openstack['username'],
                           password=openstack['password'],
                           project_name=openstack['project_name'],
                           user_domain_name=openstack['default_domain'],
                           project_domain_name=openstack['default_domain'])

        if 'keystone_cachain' in openstack:
            self.sess = session.Session(auth=auth,
                                        verify=openstack['keystone_cachain'])
        else:
            self.sess = session.Session(auth=auth)

        if region:
            self.region = region
        else:
            self.region = self.get_config('openstack', 'region')
Esempio n. 2
0
    def __init__(self, config_path, debug, log=None, region=None):
        self.config_path = config_path
        self.config = utils.get_config(config_path)
        self.logger = utils.get_logger(__name__, self.config, debug, log)
        self.logger.debug('=> config file: %s' % config_path)
        self.debug = debug
        self.dry_run = False

        openstack = self.get_config_section('openstack')
        auth = v3.Password(auth_url=openstack['auth_url'],
                           username=openstack['username'],
                           password=openstack['password'],
                           project_name=openstack['project_name'],
                           user_domain_name=openstack['default_domain'],
                           project_domain_name=openstack['default_domain'])

        if 'keystone_cachain' in openstack:
            self.sess = session.Session(auth=auth,
                                        verify=openstack['keystone_cachain'])
        else:
            self.sess = session.Session(auth=auth)

        if region:
            self.region = region
        else:
            self.region = self.get_config('openstack', 'region')
Esempio n. 3
0
 def __init__(self, config_path, debug, log=False):
     self.config_path = config_path
     self.config = utils.get_config(config_path)
     self.logger = utils.get_logger(__name__, self.config, debug, log)
     self.logger.debug('=> config file: %s', config_path)
     self.debug = debug
     self.db = self.__get_config('state', 'db')
     self.connect()
     # Make sure all tables exists
     self.__create_tables()
Esempio n. 4
0
 def __init__(self, config_path, debug=False, log=None):
     debug_level = 1 if debug else 0
     self.config_path = config_path
     self.config = utils.get_config(config_path)
     self.logger = utils.get_logger(__name__, self.config, debug, log)
     self.logger.debug('=> config file: %s' % config_path)
     self.debug = debug
     self.dry_run = False
     self.ksclient = None
     self.server = smtplib.SMTP(self.get_config('mail', 'smtp'), 25)
     self.server.set_debuglevel(debug_level)
     self.server.starttls()
Esempio n. 5
0
    def __init__(self, config_path, debug=False, version='1', log=None):
        self.config = utils.get_config(config_path)
        self.logger = utils.get_logger(__name__, self.config, debug, log)
        config = self.get_config_section('foreman')
        self.logger.debug('=> config file: %s' % config_path)
        self.logger.debug('=> foreman url: %s' % config['url'])

        self.foreman = Foreman(config['url'],
                               (config['user'], config['password']),
                               api_version=2,
                               version=version,
                               verify=False)
Esempio n. 6
0
 def __init__(self, config_path, debug=False, log=None):
     debug_level = 1 if debug else 0
     self.config_path = config_path
     self.config = utils.get_config(config_path)
     self.logger = utils.get_logger(__name__, self.config, debug, log)
     self.logger.debug('=> config file: %s' % config_path)
     self.debug = debug
     self.dry_run = False
     self.ksclient = None
     self.server = smtplib.SMTP(self.get_config('mail', 'smtp'), 25)
     self.server.set_debuglevel(debug_level)
     self.server.starttls()
Esempio n. 7
0
 def __init__(self,
              config_path,
              ldap_config='config/ldap.yaml',
              debug=False,
              log=None):
     self.config = self.load_config(config_path)
     self.logger = utils.get_logger(__name__, self.config, debug, log)
     self.logger.debug('=> config file: {}'.format(self.config_path))
     self.ldap_config = utils.load_config(ldap_config, self.logger)
     self.debug = debug
     self.dry_run = False
     self.org = None
     self.ldap = None
Esempio n. 8
0
    def __init__(self, config_path, debug, log=None):
        self.config = self.load_config(config_path)
        self.logger = utils.get_logger(__name__, self.config, debug, log)
        self.logger.debug('=> config file: {}'.format(self.config_path))
        self.dry_run = False
        self.debug = debug
        credentials = pika.PlainCredentials(
            username=self.__get_config('rabbitmq', 'username'),
            password=self.__get_config('rabbitmq', 'password'))

        parameters = pika.ConnectionParameters(
            host=self.__get_config('rabbitmq', 'host'),
            virtual_host=self.__get_config('rabbitmq', 'vhost'),
            credentials=credentials,
            connection_attempts=5,
            retry_delay=30,
            socket_timeout=10,
            blocked_connection_timeout=20,
            heartbeat_interval=10)
        self.connection = pika.BlockingConnection(parameters)
Esempio n. 9
0
    def __init__(self, config_path, debug, log=None):
        self.config = utils.get_config(config_path)
        self.logger = utils.get_logger(__name__, self.config, debug, log)
        self.logger.debug('=> config file: %s', config_path)
        self.dry_run = False
        self.debug = debug
        credentials = pika.PlainCredentials(
            username=self.__get_config('rabbitmq', 'username'),
            password=self.__get_config('rabbitmq', 'password'))

        parameters = pika.ConnectionParameters(
            host=self.__get_config('rabbitmq', 'host'),
            virtual_host=self.__get_config('rabbitmq', 'vhost'),
            credentials=credentials,
            connection_attempts=5,
            retry_delay=30,
            socket_timeout=10,
            blocked_connection_timeout=20,
            heartbeat_interval=10)
        self.connection = pika.BlockingConnection(parameters)
Esempio n. 10
0
#!/usr/bin/env python
import utils
import httplib
import statsd
from himlarcli import utils as himutils
import socket

desc = 'Do a remote check of web services'
options = utils.get_options(desc, hosts=False, debug=True)

# Himmlar config
config = himutils.get_config(options.config)
region = config.get('openstack', 'region')
logger = himutils.get_logger(__name__, config, options.debug)

# statsd
statsd_server = config.get('statsd', 'server')
statsd_port = config.get('statsd', 'port')
prefix = 'uh-iaas.%s.checks' % region
statsd = statsd.StatsClient(statsd_server, statsd_port, prefix=prefix)

# Services to check
services = himutils.load_region_config('config/checks',
                                       region=region,
                                       log=logger)

for name, check in sorted(services['checks'].iteritems()):
    if 'timeout' in check:
        timeout = check['timeout']
    else:
        timeout = 10