Exemplo n.º 1
0
    def load(self, dependencies):
        api = dependencies['api']
        bus_publisher = dependencies['bus_publisher']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']
        bus_consumer = dependencies['bus_consumer']
        bus_publisher = dependencies['bus_publisher']

        amid_client = AmidClient(**config['amid'])

        token_changed_subscribe(amid_client.set_token)

        queues_bus_event_handler = QueuesBusEventHandler(bus_publisher)
        queues_bus_event_handler.subscribe(bus_consumer)

        queues_service = QueueService(amid_client, queues_bus_event_handler)

        api.add_resource(QueuesResource,
                         '/queues',
                         resource_class_args=[queues_service])
        api.add_resource(QueueResource,
                         '/queues/<queue_name>',
                         resource_class_args=[queues_service])
        api.add_resource(QueueAddMemberResource,
                         '/queues/<queue_name>/add_member',
                         resource_class_args=[queues_service])
        api.add_resource(QueueRemoveMemberResource,
                         '/queues/<queue_name>/remove_member',
                         resource_class_args=[queues_service])
        api.add_resource(QueuePauseMemberResource,
                         '/queues/<queue_name>/pause_member',
                         resource_class_args=[queues_service])
Exemplo n.º 2
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        bus_publisher = dependencies['bus_publisher']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']

        amid_client = AmidClient(**config['amid'])

        token_changed_subscribe(amid_client.set_token)

        notifier = AdhocConferencesNotifier(bus_publisher)
        adhoc_conferences_service = AdhocConferencesService(amid_client, ari.client, notifier)

        startup_callback_collector = CallbackCollector()
        adhoc_conferences_stasis = AdhocConferencesStasis(ari, notifier)
        ari.client_initialized_subscribe(startup_callback_collector.new_source())
        startup_callback_collector.subscribe(adhoc_conferences_stasis.initialize)

        api.add_resource(
            UserAdhocConferencesResource,
            '/users/me/conferences/adhoc',
            resource_class_args=[adhoc_conferences_service],
        )
        api.add_resource(
            UserAdhocConferenceResource,
            '/users/me/conferences/adhoc/<adhoc_conference_id>',
            resource_class_args=[adhoc_conferences_service],
        )
        api.add_resource(
            UserAdhocConferenceParticipantResource,
            '/users/me/conferences/adhoc/<adhoc_conference_id>/participants/<call_id>',
            resource_class_args=[adhoc_conferences_service],
        )
Exemplo n.º 3
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        bus_consumer = dependencies['bus_consumer']
        bus_publisher = dependencies['bus_publisher']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']

        amid_client = AmidClient(**config['amid'])
        confd_client = ConfdClient(**config['confd'])

        token_changed_subscribe(amid_client.set_token)
        token_changed_subscribe(confd_client.set_token)

        conferences_service = ConferencesService(amid_client, ari.client, confd_client)
        notifier = ConferencesNotifier(bus_publisher)
        bus_event_handler = ConferencesBusEventHandler(confd_client, notifier, conferences_service)
        bus_event_handler.subscribe(bus_consumer)

        kwargs = {'resource_class_args': [conferences_service]}
        api.add_resource(ParticipantsResource, '/conferences/<int:conference_id>/participants', **kwargs)
        api.add_resource(ParticipantsUserResource, '/users/me/conferences/<int:conference_id>/participants', **kwargs)
        api.add_resource(ParticipantResource, '/conferences/<int:conference_id>/participants/<participant_id>', **kwargs)
        api.add_resource(ParticipantMuteResource, '/conferences/<int:conference_id>/participants/<participant_id>/mute', **kwargs)
        api.add_resource(ParticipantUnmuteResource, '/conferences/<int:conference_id>/participants/<participant_id>/unmute', **kwargs)
        api.add_resource(ConferenceRecordResource, '/conferences/<int:conference_id>/record', **kwargs)
Exemplo n.º 4
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        bus_publisher = dependencies['bus_publisher']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']

        amid_client = AmidClient(**config['amid'])
        confd_client = ConfdClient(**config['confd'])

        token_changed_subscribe(amid_client.set_token)
        token_changed_subscribe(confd_client.set_token)

        state_persistor = StatePersistor(ari.client)
        transfer_lock = TransferLock()

        transfers_service = TransfersService(amid_client, ari.client, confd_client, state_factory, state_persistor, transfer_lock)

        transfers_stasis = TransfersStasis(amid_client, ari, transfers_service, state_factory, state_persistor, config['uuid'])

        startup_callback_collector = CallbackCollector()
        ari.client_initialized_subscribe(startup_callback_collector.new_source())
        startup_callback_collector.subscribe(transfers_stasis.initialize)

        notifier = TransferNotifier(bus_publisher)

        state_factory.set_dependencies(amid_client, ari.client, notifier, transfers_service, state_persistor, transfer_lock)

        kwargs = {'resource_class_args': [transfers_service]}
        api.add_resource(TransfersResource, '/transfers', **kwargs)
        api.add_resource(TransferResource, '/transfers/<transfer_id>', **kwargs)
        api.add_resource(TransferCompleteResource, '/transfers/<transfer_id>/complete', **kwargs)
        api.add_resource(UserTransfersResource, '/users/me/transfers', **kwargs)
        api.add_resource(UserTransferResource, '/users/me/transfers/<transfer_id>', **kwargs)
        api.add_resource(UserTransferCompleteResource, '/users/me/transfers/<transfer_id>/complete', **kwargs)
Exemplo n.º 5
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']
        bus_consumer = dependencies['bus_consumer']
        bus_publisher = dependencies['bus_publisher']

        amid_client = AmidClient(**config['amid'])

        token_changed_subscribe(amid_client.set_token)

        conferences_service = ConferenceService(amid_client, ari.client)

        conferences_bus_event_handler = ConferencesBusEventHandler(bus_publisher)
        conferences_bus_event_handler.subscribe(bus_consumer)

        stasis = ConferenceAdhocStasis(ari, conferences_service)

        startup_callback_collector = CallbackCollector()
        ari.client_initialized_subscribe(startup_callback_collector.new_source())
        startup_callback_collector.subscribe(stasis.initialize)

        api.add_resource(ConferencesResource, '/conferences', resource_class_args=[conferences_service])
        api.add_resource(ConferenceResource, '/conferences/<conference_id>', resource_class_args=[conferences_service])
        api.add_resource(ConferenceResourceVerify, '/conferences/verify/<conference_id>', resource_class_args=[conferences_service])
        api.add_resource(ConferencesAdhocResource, '/conferences/adhoc', resource_class_args=[conferences_service])
        api.add_resource(ConferenceAdhocResource, '/conferences/adhoc/<conference_id>', resource_class_args=[conferences_service])
        api.add_resource(ConferenceParticipantAdhocResource, '/conferences/adhoc/<conference_id>/calls/<call_id>', resource_class_args=[conferences_service])
Exemplo n.º 6
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        bus_consumer = dependencies['bus_consumer']
        bus_publisher = dependencies['bus_publisher']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']

        amid_client = AmidClient(**config['amid'])
        confd_client = ConfdClient(**config['confd'])

        token_changed_subscribe(amid_client.set_token)
        token_changed_subscribe(confd_client.set_token)

        notifier = FaxesNotifier(bus_publisher)
        fax_service = FaxesService(amid_client, ari.client, confd_client,
                                   notifier)
        bus_event_handler = FaxesBusEventHandler(notifier)
        bus_event_handler.subscribe(bus_consumer)

        api.add_resource(FaxesResource,
                         '/faxes',
                         resource_class_args=[fax_service])
        api.add_resource(UserFaxesResource,
                         '/users/me/faxes',
                         resource_class_args=[fax_service])
Exemplo n.º 7
0
def get_amid_client():
    client = g.get('wazo_amid_client')
    if not client:
        client = g.wazo_amid_client = AmidClient(**app.config['amid'])
        client.set_token(current_user.get_id())
        client.set_tenant(current_user.get_tenant_uuid())
    add_tenant_to(client)
    return client
Exemplo n.º 8
0
 def setUp(self):
     super().setUp()
     self.amid = AmidClient(
         '127.0.0.1',
         port=self.service_port(9491, 'amid'),
         https=False,
         prefix=None,
         token=VALID_TOKEN_MULTITENANT,
     )
Exemplo n.º 9
0
 def make_amid(cls, token=VALID_TOKEN):
     try:
         port = cls.service_port(9491, 'amid')
     except NoSuchService:
         return WrongClient('amid')
     return AmidClient(
         '127.0.0.1',
         port=port,
         prefix=None,
         https=False,
         token=token,
     )
Exemplo n.º 10
0
    def load(self, dependencies):
        amid_client = AmidClient(**dependencies['config']['amid'])
        confd_client = ConfdClient(**dependencies['config']['confd'])
        token_changed_subscribe = dependencies['token_changed_subscribe']
        token_changed_subscribe(amid_client.set_token)
        token_changed_subscribe(confd_client.set_token)

        bus_consumer = dependencies['bus_consumer']

        service = BlfService(amid_client, confd_client)

        bus_event_handler = BusEventHandler(service)
        bus_event_handler.subscribe(bus_consumer)
Exemplo n.º 11
0
    def load(self, dependencies):
        app = dependencies['app']
        amid_client = AmidClient(**dependencies['config']['amid'])
        auth_client = AuthClient(**dependencies['config']['auth'])
        confd_client = ConfdClient(**dependencies['config']['confd'])
        dird_client = DirdClient(**dependencies['config']['dird'])
        token_changed_subscribe = dependencies['token_changed_subscribe']
        token_changed_subscribe(amid_client.set_token)
        token_changed_subscribe(auth_client.set_token)
        token_changed_subscribe(confd_client.set_token)
        token_changed_subscribe(dird_client.set_token)

        service = YealinkService(amid_client, confd_client)
        self.service = service

        dependencies['phone_plugins'].append(self)

        bus_consumer = dependencies['bus_consumer']
        bus_event_handler = BusEventHandler(service)
        bus_event_handler.subscribe(bus_consumer)

        directories_class_kwargs = {
            'vendor': self.vendor,
            'dird_client': dird_client,
            'auth_client': auth_client,
        }
        user_service_class_kwargs = {
            'service': service,
        }

        api = create_blueprint_api(app, '{}_plugin'.format(self.vendor),
                                   self.import_name)

        self.lookup_url = self.lookup_url_fmt.format(vendor=self.vendor)

        self.directories_lookup_url = self.directories_lookup_url_fmt.format(
            vendor=self.vendor)

        self.user_service_dnd_enable_url = self.user_service_dnd_enable_url_fmt.format(
            vendor=self.vendor)
        self.user_service_dnd_disable_url = (
            self.user_service_dnd_disable_url_fmt.format(vendor=self.vendor))
        self._add_resources(api, directories_class_kwargs)
        self._add_user_service_resources(api, user_service_class_kwargs)
Exemplo n.º 12
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        bus_publisher = dependencies['bus_publisher']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']

        amid_client = AmidClient(**config['amid'])
        confd_client = ConfdClient(**config['confd'])

        token_changed_subscribe(amid_client.set_token)
        token_changed_subscribe(confd_client.set_token)

        relocates = RelocateCollection()
        state_factory = StateFactory(state_index, amid_client, ari.client)

        notifier = RelocatesNotifier(bus_publisher)
        relocates_service = RelocatesService(amid_client, ari.client,
                                             confd_client, notifier, relocates,
                                             state_factory)

        relocates_stasis = RelocatesStasis(ari, relocates)

        startup_callback_collector = CallbackCollector()
        ari.client_initialized_subscribe(
            startup_callback_collector.new_source())
        startup_callback_collector.subscribe(relocates_stasis.initialize)

        kwargs = {'resource_class_args': [relocates_service]}
        api.add_resource(UserRelocatesResource, '/users/me/relocates',
                         **kwargs)
        api.add_resource(UserRelocateResource,
                         '/users/me/relocates/<relocate_uuid>', **kwargs)
        api.add_resource(UserRelocateCompleteResource,
                         '/users/me/relocates/<relocate_uuid>/complete',
                         **kwargs)
        api.add_resource(UserRelocateCancelResource,
                         '/users/me/relocates/<relocate_uuid>/cancel',
                         **kwargs)
Exemplo n.º 13
0
    def load(self, dependencies):
        api = dependencies['api']
        config = dependencies['config']
        dao = dependencies['dao']
        bus_consumer = dependencies['bus_consumer']
        bus_publisher = dependencies['bus_publisher']
        status_aggregator = dependencies['status_aggregator']
        status_validator.set_config(status_aggregator, config)

        notifier = PresenceNotifier(bus_publisher)
        service = PresenceService(dao, notifier)
        initialization = config['initialization']

        auth = AuthClient(**config['auth'])
        amid = AmidClient(**config['amid'])
        confd = ConfdClient(**config['confd'])
        initiator = Initiator(dao, auth, amid, confd)
        status_aggregator.add_provider(initiator.provide_status)

        if initialization['enabled']:
            thread_manager = dependencies['thread_manager']
            initiator_thread = InitiatorThread(initiator)
            thread_manager.manage(initiator_thread)

        bus_event_handler = BusEventHandler(dao, notifier)
        bus_event_handler.subscribe(bus_consumer)

        api.add_resource(PresenceListResource,
                         '/users/presences',
                         resource_class_args=[service])

        api.add_resource(
            PresenceItemResource,
            '/users/<uuid:user_uuid>/presences',
            resource_class_args=[service],
        )
Exemplo n.º 14
0
    def load(self, dependencies):
        ari = dependencies['ari']
        pubsub = dependencies['pubsub']
        bus_consumer = dependencies['bus_consumer']
        token_changed_subscribe = dependencies['token_changed_subscribe']
        config = dependencies['config']
        bus_publisher = dependencies['bus_publisher']

        amid_client = AmidClient(**config['amid'])
        token_changed_subscribe(amid_client.set_token)

        auth_client = AuthClient(**config['auth'])
        token_changed_subscribe(auth_client.set_token)

        notifier = Notifier(bus_publisher)
        service = DialMobileService(ari, notifier, amid_client, auth_client)
        stasis = DialMobileStasis(ari, service)
        event_handler = EventHandler(service)

        event_handler.subscribe(bus_consumer)
        pubsub.subscribe('stopping', lambda _: service.on_calld_stopping())
        startup_callback_collector = CallbackCollector()
        ari.client_initialized_subscribe(startup_callback_collector.new_source())
        startup_callback_collector.subscribe(stasis.initialize)
Exemplo n.º 15
0
def get_AMID_client(**config):
    global _AMID_client
    if not _AMID_client:
        _AMID_client = AmidClient(**config)
    return _AMID_client
Exemplo n.º 16
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        config = dependencies['config']
        bus_consumer = dependencies['bus_consumer']
        bus_publisher = dependencies['bus_publisher']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']
        next_token_changed_subscribe = dependencies[
            'next_token_changed_subscribe']
        pubsub = dependencies['pubsub']

        auth_client = AuthClient(**config['auth'])
        confd_client = ConfdClient(**config['confd'])
        amid_client = AmidClient(**config['amid'])

        token_changed_subscribe(amid_client.set_token)
        token_changed_subscribe(auth_client.set_token)
        token_changed_subscribe(confd_client.set_token)

        confd_apps_cache = ConfdApplicationsCache(confd_client)
        confd_apps_cache.subscribe(bus_consumer)
        moh_cache = MohCache(confd_client)
        moh_cache.subscribe(bus_consumer)

        notifier = ApplicationNotifier(bus_publisher)
        service = ApplicationService(
            ari.client,
            confd_client,
            amid_client,
            notifier,
            confd_apps_cache,
            moh_cache,
        )

        stasis = ApplicationStasis(
            ari,
            service,
            notifier,
            confd_apps_cache,
            moh_cache,
        )
        confd_is_ready_thread = ConfdIsReadyThread(confd_client)
        startup_callback_collector = CallbackCollector()
        next_token_changed_subscribe(startup_callback_collector.new_source())
        ari.client_initialized_subscribe(
            startup_callback_collector.new_source())
        confd_is_ready_thread.subscribe(
            startup_callback_collector.new_source())
        startup_callback_collector.subscribe(stasis.initialize)

        confd_apps_cache.created_subscribe(stasis.add_ari_application)
        confd_apps_cache.updated_subscribe(service.update_destination_node)
        confd_apps_cache.deleted_subscribe(stasis.remove_ari_application)

        confd_is_ready_thread.start()
        pubsub.subscribe('stopping', lambda _: confd_is_ready_thread.stop())

        api.add_resource(
            ApplicationItem,
            '/applications/<uuid:application_uuid>',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallList,
            '/applications/<uuid:application_uuid>/calls',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallItem,
            '/applications/<uuid:application_uuid>/calls/<call_id>',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallHoldStartList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/hold/start',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallHoldStopList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/hold/stop',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallMohStopList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/moh/stop',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallMohStartList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/moh/<uuid:moh_uuid>/start',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallMuteStartList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/mute/start',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallMuteStopList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/mute/stop',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallPlaybackList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/playbacks',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallSnoopList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/snoops',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallAnswer,
            '/applications/<uuid:application_uuid>/calls/<call_id>/answer',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallProgressStart,
            '/applications/<uuid:application_uuid>/calls/<call_id>/progress/start',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationCallProgressStop,
            '/applications/<uuid:application_uuid>/calls/<call_id>/progress/stop',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationNodeList,
            '/applications/<uuid:application_uuid>/nodes',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationNodeItem,
            '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationNodeCallList,
            '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>/calls',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationNodeCallUserList,
            '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>/calls/user',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationNodeCallItem,
            '/applications/<uuid:application_uuid>/nodes/<uuid:node_uuid>/calls/<call_id>',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationPlaybackItem,
            '/applications/<uuid:application_uuid>/playbacks/<uuid:playback_uuid>',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationSnoopList,
            '/applications/<uuid:application_uuid>/snoops',
            resource_class_args=[service],
        )
        api.add_resource(
            ApplicationSnoopItem,
            '/applications/<uuid:application_uuid>/snoops/<uuid:snoop_uuid>',
            resource_class_args=[service],
        )

        api.add_resource(
            ApplicationDTMFList,
            '/applications/<uuid:application_uuid>/calls/<call_id>/dtmf',
            resource_class_args=[service],
        )
Exemplo n.º 17
0
def _run(config):
    _init_signal()
    xivo_uuid = config['uuid']
    agent_dao = AgentDAOAdapter(orig_agent_dao)
    queue_dao = QueueDAOAdapter(orig_queue_dao)
    exten_features_dao = ExtenFeaturesDAOAdapter(asterisk_conf_dao)
    amid_client = AmidClient(**config['amid'])
    auth_client = AuthClient(**config['auth'])
    token_renewer = TokenRenewer(auth_client)
    token_renewer.subscribe_to_token_change(amid_client.set_token)
    token_renewer.subscribe_to_token_change(auth_client.set_token)

    bus_consumer = BusConsumer(**config['bus'])
    bus_publisher = BusPublisherWithQueue(**config['bus'], service_uuid=xivo_uuid)

    blf_manager = BLFManager(amid_client, exten_features_dao)
    queue_log_manager = QueueLogManager(queue_log_dao)

    add_to_queue_action = AddToQueueAction(amid_client, agent_status_dao)
    login_action = LoginAction(
        amid_client,
        queue_log_manager,
        blf_manager,
        agent_status_dao,
        line_dao,
        user_dao,
        agent_dao,
        bus_publisher,
    )
    pause_action = PauseAction(amid_client)
    pause_manager = PauseManager(pause_action, agent_dao)
    logoff_action = LogoffAction(
        amid_client,
        queue_log_manager,
        blf_manager,
        pause_manager,
        agent_status_dao,
        user_dao,
        agent_dao,
        bus_publisher,
    )
    remove_from_queue_action = RemoveFromQueueAction(amid_client, agent_status_dao)
    update_penalty_action = UpdatePenaltyAction(amid_client, agent_status_dao)

    add_member_manager = AddMemberManager(
        add_to_queue_action, amid_client, agent_status_dao, queue_member_dao
    )
    login_manager = LoginManager(login_action, agent_status_dao, context_dao, line_dao)
    logoff_manager = LogoffManager(logoff_action, agent_dao, agent_status_dao)
    on_agent_deleted_manager = OnAgentDeletedManager(logoff_manager, agent_status_dao)
    on_agent_updated_manager = OnAgentUpdatedManager(
        add_to_queue_action,
        remove_from_queue_action,
        update_penalty_action,
        agent_status_dao,
    )
    on_queue_added_manager = OnQueueAddedManager(add_to_queue_action, agent_status_dao)
    on_queue_deleted_manager = OnQueueDeletedManager(agent_status_dao)
    on_queue_updated_manager = OnQueueUpdatedManager(
        add_to_queue_action, remove_from_queue_action, agent_status_dao
    )
    on_queue_agent_paused_manager = OnQueueAgentPausedManager(
        agent_status_dao, user_dao, agent_dao, bus_publisher
    )
    relog_manager = RelogManager(
        login_action, logoff_action, agent_dao, agent_status_dao
    )
    remove_member_manager = RemoveMemberManager(
        remove_from_queue_action, amid_client, agent_status_dao, queue_member_dao
    )

    service_proxy = ServiceProxy()
    service_proxy.login_handler = LoginHandler(login_manager, agent_dao)
    service_proxy.logoff_handler = LogoffHandler(logoff_manager, agent_status_dao)
    service_proxy.membership_handler = MembershipHandler(
        add_member_manager, remove_member_manager, agent_dao, queue_dao
    )
    service_proxy.on_agent_handler = OnAgentHandler(
        on_agent_deleted_manager, on_agent_updated_manager, agent_dao
    )
    service_proxy.on_queue_handler = OnQueueHandler(
        on_queue_added_manager,
        on_queue_updated_manager,
        on_queue_deleted_manager,
        on_queue_agent_paused_manager,
        queue_dao,
        agent_dao,
    )
    service_proxy.pause_handler = PauseHandler(pause_manager, agent_status_dao)
    service_proxy.relog_handler = RelogHandler(relog_manager)
    service_proxy.status_handler = StatusHandler(agent_dao, agent_status_dao, xivo_uuid)

    _init_bus_consume(bus_consumer, service_proxy)

    http_iface = http.HTTPInterface(config, service_proxy, auth_client)

    service_discovery_args = [
        'wazo-agentd',
        xivo_uuid,
        config['consul'],
        config['service_discovery'],
        config['bus'],
        partial(self_check, config['rest_api']),
    ]
    try:
        with token_renewer:
            with bus_consumer, bus_publisher:
                with ServiceCatalogRegistration(*service_discovery_args):
                    http_iface.run()
    finally:
        logger.info('wazo-agentd stopping...')
Exemplo n.º 18
0
    def load(self, dependencies):
        api = dependencies['api']
        ari = dependencies['ari']
        config = dependencies['config']
        token_changed_subscribe = dependencies['token_changed_subscribe']
        bus_consumer = dependencies['bus_consumer']
        bus_publisher = dependencies['bus_publisher']

        amid_client = AmidClient(**config['amid'])

        token_changed_subscribe(amid_client.set_token)

        notifier = ConferenceAdhocNotifier(bus_publisher)

        confd_client = ConfdClient(**config['confd'])

        phoned_client = PhonedClient(**config['phoned'])

        token_changed_subscribe(confd_client.set_token)

        dial_echo_manager = DialEchoManager()

        calls_notifier = CallNotifier(bus_publisher)
        calls_service = CallsService(amid_client, config['ari']['connection'],
                                     ari.client, confd_client,
                                     dial_echo_manager, phoned_client,
                                     calls_notifier)

        conferences_service = ConferenceService(amid_client, ari.client,
                                                notifier)

        conferences_bus_event_handler = ConferencesBusEventHandler(
            ari.client, bus_publisher, calls_service, calls_notifier)
        conferences_bus_event_handler.subscribe(bus_consumer)

        stasis = ConferenceAdhocStasis(ari, conferences_service, notifier)

        startup_callback_collector = CallbackCollector()
        ari.client_initialized_subscribe(
            startup_callback_collector.new_source())
        startup_callback_collector.subscribe(stasis.initialize)

        api.add_resource(ConferencesResource,
                         '/conferences',
                         resource_class_args=[conferences_service])
        api.add_resource(ConferenceResource,
                         '/conferences/<conference_id>',
                         resource_class_args=[conferences_service])
        api.add_resource(ConferenceResourceVerify,
                         '/conferences/verify/<conference_id>',
                         resource_class_args=[conferences_service])
        api.add_resource(ConferencesAdhocResource,
                         '/users/me/conferences/adhoc',
                         resource_class_args=[conferences_service])
        api.add_resource(ConferenceAdhocResource,
                         '/users/me/conferences/adhoc/<conference_id>',
                         resource_class_args=[conferences_service])
        api.add_resource(
            ConferenceParticipantAdhocResource,
            '/users/me/conferences/adhoc/<conference_id>/participants/<call_id>',
            resource_class_args=[conferences_service])
Exemplo n.º 19
0
def setup_amid_client(context):
    context.amid_client = AmidClient(**context.wazo_config['amid'])
    context.amid_client.set_token(context.token)
    context.token_pubsub.subscribe('new-token-id',
                                   context.amid_client.set_token)