Exemplo n.º 1
0
    def list_floatingips(self, context, region=None):
        """
        Get floating ips based on the current context from Neutron
        """
        endpoints = self._endpoints(
            service_catalog=context.service_catalog,
            service_type='network',
            endpoint_type=CONF['network_api:neutron'].endpoint_type,
            config_section='network_api:neutron',
            region=region)

        tg = threadgroup.ThreadGroup()

        failed = []
        data = []

        def _call(endpoint, region, *args, **kw):
            client = get_client(context, endpoint=endpoint)
            LOG.debug("Attempting to fetch FloatingIPs from %s @ %s",
                      endpoint, region)
            try:
                fips = client.list_floatingips(*args, **kw)
            except neutron_exceptions.Unauthorized as e:
                # NOTE: 401 might be that the user doesn't have neutron
                # activated in a particular region, we'll just log the failure
                # and go on with our lives.
                LOG.warning(_LW("Calling Neutron resulted in a 401, "
                             "please investigate."))
                LOG.exception(e)
                return
            except Exception as e:
                LOG.error(_LE('Failed calling Neutron '
                              '%(region)s - %(endpoint)s'),
                          {'region': region, 'endpoint': endpoint})
                LOG.exception(e)
                failed.append((e, endpoint, region))
                return

            for fip in fips['floatingips']:
                data.append({
                    'id': fip['id'],
                    'address': fip['floating_ip_address'],
                    'region': region
                })

            LOG.debug("Added %i FloatingIPs from %s @ %s",
                      len(data), endpoint, region)

        for endpoint, region in endpoints:
            tg.add_thread(_call, endpoint, region,
                          tenant_id=context.tenant)
        tg.wait()

        # NOTE: Sadly tg code doesn't give us a good way to handle failures.
        if failed:
            msg = 'Failed retrieving FLoatingIPs from Neutron in %s' % \
                ", ".join(['%s - %s' % (i[1], i[2]) for i in failed])
            raise exceptions.NeutronCommunicationFailure(msg)
        return data
Exemplo n.º 2
0
def setup(conf):
    tg = threadgroup.ThreadGroup()
    pt = MagnumPeriodicTasks(conf)
    tg.add_dynamic_timer(
        pt.run_periodic_tasks,
        periodic_interval_max=conf.periodic_interval_max,
        context=None)
    return tg
Exemplo n.º 3
0
 def __init__(self, threads=1000):
     self.tg = threadgroup.ThreadGroup(threads)
     LOG.info("Creating flocx-market manager service")
     self.tasks = Manager(CONF)
     self._context = ctx.RequestContext(auth_token=None,
                                        project_id=None,
                                        is_admin=True,
                                        overwrite=False)
Exemplo n.º 4
0
 def setup(self, pt_class, name, conf):
     pt = pt_class(conf, name)
     pool_size = 1
     tg = threadgroup.ThreadGroup(pool_size)
     tg.add_dynamic_timer(pt.run_periodic_tasks,
                          periodic_interval_max=1,
                          context=None)
     return tg
Exemplo n.º 5
0
    def start(self):
        LOG.info("Starting collector service...")

        self.thread_grp = threadgroup.ThreadGroup()
        self.thread_grp.add_timer(CONF.collector.periodic_interval,
                                  self.collect_usage)

        super(CollectorService, self).start()
        LOG.info("Collector service started.")
Exemplo n.º 6
0
    def __init__(self):
        super(ThreadGroupManager, self).__init__()
        self.threads = {}
        self.group = threadgroup.ThreadGroup()

        # Create dummy service task, because when there is nothing queued
        # on self.tg the process exits
        self.add_timer(cfg.CONF.scheduler.periodic_interval,
                       self._service_task)
Exemplo n.º 7
0
    def __init__(self):
        self.init_qemu_ga()
        super(ThreadGroupManager, self).__init__()
        self.threads = {}
        self.group = threadgroup.ThreadGroup()

        # Create dummy service task, because when there is nothing queued
        # on self.tg the process exits
        self.add_timer(
            CONF.introspectiveinstancemonitor.guest_monitoring_interval,
            self._service_task)
Exemplo n.º 8
0
    def __init__(self):
        super(ThreadGroupManager, self).__init__()
        self.group = threadgroup.ThreadGroup()

        # Create dummy service task, because when there is nothing queued
        # on self.tg the process exits
        self.add_timer(cfg.CONF.periodic_interval, self._service_task)

        # TODO(Yanyan Hu): Build a DB session with full privilege
        # for DB accessing in scheduler module
        self.db_session = context.RequestContext(is_admin=True)
Exemplo n.º 9
0
def start_function_mapping_handler(orchestrator):
    tg = threadgroup.ThreadGroup(1)
    engine_client = rpc.get_engine_client()

    tg.add_timer(300,
                 handle_function_service_expiration,
                 ctx=context.Context(),
                 engine_client=engine_client,
                 orchestrator=orchestrator)
    _periodic_tasks[constants.PERIODIC_FUNC_MAPPING_HANDLER] = tg

    LOG.info('Function mapping handler started.')
Exemplo n.º 10
0
    def __init__(self, engine_service, topic, version):
        super(HealthManager, self).__init__()

        self.TG = threadgroup.ThreadGroup()
        self.engine_id = engine_service.engine_id
        self.topic = topic
        self.version = version
        self.ctx = context.get_admin_context()
        self.rpc_client = rpc_client.EngineClient()
        self.rt = {
            'registries': [],
        }
Exemplo n.º 11
0
def start_job_handler():
    tg = threadgroup.ThreadGroup(1)
    engine_client = rpc.get_engine_client()

    tg.add_timer(
        3,
        handle_job,
        engine_client=engine_client,
    )
    _periodic_tasks[constants.PERIODIC_JOB_HANDLER] = tg

    LOG.info('Job handler started.')
Exemplo n.º 12
0
def setup():
    tg = threadgroup.ThreadGroup()
    pt = ExecutionExpirationPolicy(CONF)

    ctx = auth_ctx.MistralContext(user_id=None,
                                  project_id=None,
                                  auth_token=None,
                                  is_admin=True)

    tg.add_dynamic_timer(pt.run_periodic_tasks,
                         initial_delay=None,
                         periodic_interval_max=1,
                         context=ctx)
Exemplo n.º 13
0
def setup():
    tg = threadgroup.ThreadGroup()

    scheduler = CallScheduler(CONF)

    tg.add_dynamic_timer(scheduler.run_periodic_tasks,
                         initial_delay=None,
                         periodic_interval_max=1,
                         context=None)

    _schedulers[scheduler] = tg

    return tg
Exemplo n.º 14
0
    def __init__(self, engine_service, topic, version):
        super(HealthManager, self).__init__()

        self.TG = threadgroup.ThreadGroup(
            thread_pool_size=cfg.CONF.health_manager_thread_pool_size)
        self.engine_id = engine_service.engine_id
        self.topic = topic
        self.version = version
        self.ctx = context.get_admin_context()
        self.rpc_client = rpc_client.EngineClient()
        self.health_registry = RuntimeHealthRegistry(ctx=self.ctx,
                                                     engine_id=self.engine_id,
                                                     thread_group=self.TG)
Exemplo n.º 15
0
    def __init__(self, engine_client):
        coordination.Service.__init__(self, 'event_engine_group')

        self.engine_client = engine_client
        self.event_queue = six.moves.queue.Queue()
        self.handler_tg = threadgroup.ThreadGroup()

        self.event_triggers_map = defaultdict(list)
        self.exchange_topic_events_map = defaultdict(set)
        self.exchange_topic_listener_map = {}

        self.lock = threading.Lock()

        self._start_handler()
        self._start_listeners()
Exemplo n.º 16
0
def start_function_mapping_handler(engine):
    """Start function mapping handler thread.

    Function mapping handler is supposed to be running with engine service.
    """
    tg = threadgroup.ThreadGroup(1)
    tg.add_timer(
        300,
        handle_function_service_expiration,
        ctx=context.Context(),
        engine=engine,
    )
    _periodic_tasks[constants.PERIODIC_FUNC_MAPPING_HANDLER] = tg

    LOG.info('Function mapping handler started.')
Exemplo n.º 17
0
def setup():
    if CONF.periodic_enable:
        if CONF.periodic_fuzzy_delay:
            initial_delay = random.randint(0, CONF.periodic_fuzzy_delay)
            LOG.debug("Starting periodic tasks with initial delay {seconds} "
                      "seconds".format(seconds=initial_delay))
        else:
            initial_delay = None

        tg = threadgroup.ThreadGroup()
        pt = _make_periodic_tasks()
        tg.add_dynamic_timer(pt.run_periodic_tasks,
                             initial_delay=initial_delay,
                             periodic_interval_max=CONF.periodic_interval_max,
                             context=None)
Exemplo n.º 18
0
def start_job_handler():
    """Start job handler thread.

    Job handler is supposed to be running with api service.
    """
    tg = threadgroup.ThreadGroup(1)
    engine_client = rpc.get_engine_client()

    tg.add_timer(
        3,
        handle_job,
        engine_client=engine_client,
    )
    _periodic_tasks[constants.PERIODIC_JOB_HANDLER] = tg

    LOG.info('Job handler started.')
Exemplo n.º 19
0
    def __init__(self, conf, session_id, data):
        Thread.__init__(self)
        self.conf = conf
        self.session_id = session_id
        self.stopped = False
        self.thg = threadgroup.ThreadGroup()
        self.timer = {}
        self.session = self._init_session(data)
        self.hosts = []
        if "hosts" in data and data['hosts']:
            # Hosts given as input, not to be discovered in workflow
            self.hosts = self.init_hosts(self.convert(data['hosts']))
        else:
            LOG.info('%s: No hosts as input' % self.session_id)
        if "actions" in data:
            self.actions = self._init_action_plugins(data["actions"])
        else:
            self.actions = []
        self.projects = []
        self.instances = []
        self.proj_instance_actions = {}

        self.states_methods = {'MAINTENANCE': 'maintenance',
                               'SCALE_IN': 'scale_in',
                               'PREPARE_MAINTENANCE': 'prepare_maintenance',
                               'START_MAINTENANCE': 'start_maintenance',
                               'PLANNED_MAINTENANCE': 'planned_maintenance',
                               'MAINTENANCE_COMPLETE': 'maintenance_complete',
                               'MAINTENANCE_DONE': 'maintenance_done',
                               'MAINTENANCE_FAILED': 'maintenance_failed'}
        self.url = "http://%s:%s" % (conf.host, conf.port)
        self.auth = get_identity_auth(conf.workflow_user,
                                      conf.workflow_password,
                                      conf.workflow_project)
        self.auth_session = get_session(auth=self.auth)
        self.aodh = aodhclient.Client('2', self.auth_session)
        transport = messaging.get_transport(self.conf)
        self.notif_proj = messaging.Notifier(transport,
                                             'maintenance.planned',
                                             driver='messaging',
                                             topics=['notifications'])
        self.notif_proj = self.notif_proj.prepare(publisher_id='fenix')
        self.notif_admin = messaging.Notifier(transport,
                                              'maintenance.host',
                                              driver='messaging',
                                              topics=['notifications'])
        self.notif_admin = self.notif_admin.prepare(publisher_id='fenix')
Exemplo n.º 20
0
    def register_membership(self):
        """Registers group membership.

        Because this method will be invoked on each service startup almost at
        the same time, so it must be synchronized, in case all the services
        are started within same process.
        """

        service_coordinator = get_service_coordinator()

        if service_coordinator.is_active():
            service_coordinator.join_group(self.group_type)

            self._tg = threadgroup.ThreadGroup()

            self._tg.add_timer(cfg.CONF.coordination.heartbeat_interval,
                               service_coordinator.heartbeat)
Exemplo n.º 21
0
    def __init__(self):
        self.engine_client = rpc.get_engine_client()
        self.event_queue = six.moves.queue.Queue()
        self.handler_tg = threadgroup.ThreadGroup()

        self.event_triggers_map = defaultdict(list)
        self.exchange_topic_events_map = defaultdict(set)
        self.exchange_topic_listener_map = {}

        self.lock = threading.Lock()

        LOG.debug('Loading notification definitions.')

        self.notification_converter = NotificationsConverter()

        self._start_handler()
        self._start_listeners()
Exemplo n.º 22
0
def setup():
    tg = threadgroup.ThreadGroup()
    pt = ExecutionExpirationPolicy(CONF)

    _check_ignored_states_config()

    ctx = auth_ctx.MistralContext(user=None,
                                  tenant=None,
                                  auth_token=None,
                                  is_admin=True)

    tg.add_dynamic_timer(pt.run_periodic_tasks,
                         initial_delay=None,
                         periodic_interval_max=1,
                         context=ctx)

    return tg
Exemplo n.º 23
0
def setup():
    tg = threadgroup.ThreadGroup()
    pt = MistralPeriodicTasks(CONF)

    ctx = auth_ctx.MistralContext(user=None,
                                  tenant=None,
                                  auth_token=None,
                                  is_admin=True)

    tg.add_dynamic_timer(pt.run_periodic_tasks,
                         initial_delay=None,
                         periodic_interval_max=1,
                         context=ctx)

    _periodic_tasks[pt] = tg

    return tg
Exemplo n.º 24
0
def init_application():
    conf_files = _get_config_files()
    logging.register_options(cfg.CONF)
    cfg.CONF([], project='designate', default_config_files=conf_files)
    config.set_defaults()
    logging.setup(cfg.CONF, 'designate')

    policy.init()

    if not rpc.initialized():
        rpc.init(CONF)

    heartbeat = service.Heartbeat('api',
                                  threadgroup.ThreadGroup(thread_pool_size=1))
    heartbeat.start()

    conf = conf_files[0]

    return deploy.loadapp('config:%s' % conf, name='osapi_dns')
Exemplo n.º 25
0
def launch_lm(transport):
    target = messaging.Target(topic=cfg.CONF.local_manager.topic,
                              server=cfg.CONF.local_manager.host)

    local_manager = local_mgr.LocalManager()
    endpoints = [rpc.LocalManagerServer(local_manager)]

    tg = threadgroup.ThreadGroup()
    tg.add_dynamic_timer(local_manager.run_periodic_tasks,
                         initial_delay=None,
                         periodic_interval_max=None,
                         context=None)

    server = messaging.get_rpc_server(transport,
                                      target,
                                      endpoints,
                                      executor='eventlet')

    server.start()
    server.wait()
Exemplo n.º 26
0
def setup():
    if CONF.periodic_enable:
        if CONF.periodic_fuzzy_delay:
            initial_delay = random.randint(0, CONF.periodic_fuzzy_delay)
            LOG.debug("Starting periodic tasks with initial delay {seconds} "
                      "seconds".format(seconds=initial_delay))
        else:
            initial_delay = None

        tg = threadgroup.ThreadGroup()
        workers_number = (CONF.periodic_workers_number
                          if CONF.periodic_coordinator_backend_url else 1)

        for t in range(workers_number):
            pt = _make_periodic_tasks()
            tg.add_dynamic_timer(
                pt.run_periodic_tasks,
                initial_delay=initial_delay,
                periodic_interval_max=CONF.periodic_interval_max,
                context=None)
Exemplo n.º 27
0
 def __init__(self, threads=1000):
     self.tg = threadgroup.ThreadGroup(threads)
Exemplo n.º 28
0
    def __init__(self, leader_elector, *args, **kwargs):
        super(LeaderElectionService, self).__init__()
        self.leader_elector = leader_elector

        self._tg = threadgroup.ThreadGroup()
        self._stop = event.Event()
Exemplo n.º 29
0
 def __init__(self, monitor_plugins):
     self.monitor_plugins = monitor_plugins
     self.tg = threadgroup.ThreadGroup()
     self.healing_timers = []
Exemplo n.º 30
0
 def __init__(self, monitor_plugins):
     """Initialize a polling monitor."""
     self.monitor_plugins = monitor_plugins
     self.tg = threadgroup.ThreadGroup()