Example #1
0
    def __init__(self):
        super(MontagneApp, self).__init__()
        self.name = self.__module__
        self.LOG = getLogger(self.__class__.__name__)
        self.app_mgr = None
        self.event_handlers = {}
        self.threads = []
        self.events = hub.Queue(128)
        self._events_sem = hub.BoundedSemaphore(self.events.maxsize)

        self.wsgi_controller = None
        self.thread(self._event_loop)

        self.is_active = True
Example #2
0
def main(args=None, prog=None):
    try:
        CONF(args=args,
             prog=prog,
             project='montagne',
             version='montagne-manager %s' % version,
             default_config_files=['/usr/local/etc/montagne/montagne.conf'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args,
             prog=prog,
             project='montagne',
             version='montagne-manager %s' % version)

    log.init_log()
    LOG = getLogger()
    LOG.setLevel(CONF.log_level)
    # read OpenStack authentication from system environment value.
    # if failed, try to read from conf file.
    credentials.set_openstack_auth()

    LOG.info('Start Montage')
    hub.patch(thread=True)
    app_mgr = ApplicationManager()

    # applications to run
    app_list = [
        NeutronClient, NovaClient, NeutronCollector, NovaCollector, Scheduler,
        NeutronNotifier, PhysicalNetworkListener
    ]

    # initiating application and add to application manager
    for app in app_list:
        try:
            app_inst = app()
        except Exception as e:
            LOG.exception(e)
            app_mgr.close()
            sys.exit(0)
        app_mgr.register_app(app_inst)

    app_mgr.run()
    app_mgr.run_service()

    try:
        hub.joinall(app_mgr.service_thread)
    except KeyboardInterrupt:
        LOG.info("Keyboard Interrupt received. "
                 "Closing Montagne application manager...")
    finally:
        app_mgr.close()
Example #3
0
import json
import inspect
from montagne.common import hub
from montagne.common.log import getLogger
from eventlet.green.urllib import request, error

LOG = getLogger(__name__)

_DEFAULT_TIME_OUT = 2


def encode(obj, charset='utf-8'):
    return json.dumps(obj).encode(charset)


def decode(byte, charset='utf-8'):
    return json.loads(byte.decode(charset))


def get(url, headers=None, decode='utf-8'):
    return _base_method(url, headers=headers, decode=decode)


def post(url, data, headers=None, decode='utf-8'):
    assert isinstance(data, bytes)
    return _base_method(url, data=data, method='POST',
                        headers=headers, decode=decode)


def put(url, data, headers=None, decode='utf-8'):
    assert isinstance(data, bytes)
Example #4
0
import os
from montagne import cfg
from montagne.common.log import getLogger

LOG = getLogger()

CONF = cfg.CONF
CONF.register_opts([
    cfg.StrOpt('auth_uri',
               default='http://localhost:5000/v2.0',
               help='Complete public Identity API endpoint'),
    cfg.StrOpt('identity_uri',
               default='http://localhost:35357',
               help='Complete admin Identity API endpoint. This should '
               'specify the unversioned root endpoint '
               'e.g. https://localhost:35357/'),
    cfg.StrOpt('admin_tenant_name',
               default='admin',
               help='Keystone service account tenant name to validate'),
    cfg.StrOpt('admin_user', default='admin',
               help='Keystone account username'),
    cfg.StrOpt('admin_password',
               secret=True,
               default='admin',
               help='Keystone account password')
],
                   group='keystone_authtoken')


def set_openstack_auth():
    try: