Esempio n. 1
0
def main():
    """ main() for subscriberdb """
    service = MagmaService('policydb', mconfigs_pb2.PolicyDB())

    # Add all servicers to the server
    chan = ServiceRegistry.get_rpc_channel('subscriberdb',
                                           ServiceRegistry.LOCAL)
    subscriberdb_stub = SubscriberDBStub(chan)
    session_servicer = SessionRpcServicer(service.mconfig, subscriberdb_stub)
    session_servicer.add_to_server(service.rpc_server)

    # Start a background thread to stream updates from the cloud
    if service.config['enable_streaming']:
        stream = StreamerClient(
            {
                'policydb': PolicyDBStreamerCallback(),
                'rule_mappings': RuleMappingsStreamerCallback(),
            },
            service.loop,
        )
        stream.start()
    else:
        logging.info('enable_streaming set to False. Streamer disabled!')

    # Run the service loop
    service.run()

    # Cleanup the service
    service.close()
Esempio n. 2
0
def main():
    """ main() for subscriberdb """
    service = MagmaService('subscriberdb')

    # Initialize a store to keep all subscriber data.
    store = SqliteStore(service.config['db_path'], loop=service.loop)

    # Initialize the processor
    processor = Processor(store, get_default_sub_profile(service),
                          service.mconfig.sub_profiles,
                          service.mconfig.lte_auth_op,
                          service.mconfig.lte_auth_amf)

    # Add all servicers to the server
    subscriberdb_servicer = SubscriberDBRpcServicer(store)
    subscriberdb_servicer.add_to_server(service.rpc_server)

    # Start a background thread to stream updates from the cloud
    if service.config['enable_streaming']:
        callback = SubscriberDBStreamerCallback(store, service.loop)
        stream = StreamerClient({"subscriberdb": callback}, service.loop)
        stream.start()
    else:
        logging.info('enable_streaming set to False. Streamer disabled!')

    # Wait until the datastore is populated by addition or resync before
    # listening for clients.
    def serve():
        # Waiting for subscribers to be added to store
        yield from store.on_ready()

        if service.config['s6a_over_grpc']:
            s6a_proxy_servicer = S6aProxyRpcServicer(processor)
            s6a_proxy_servicer.add_to_server(service.rpc_server)
        else:
            base_manager = base.BaseApplication(
                service.config['mme_realm'],
                service.config['mme_host_name'],
                service.config['mme_host_address'],
            )
            s6a_manager = _get_s6a_manager(service, processor)
            base_manager.register(s6a_manager)

            # Setup the Diameter/s6a MME
            s6a_server = service.loop.create_server(
                lambda: S6aServer(base_manager,
                                  s6a_manager,
                                  service.config['mme_realm'],
                                  service.config['mme_host_name'],
                                  loop=service.loop),
                service.config['host_address'], service.config['mme_port'])
            asyncio.ensure_future(s6a_server, loop=service.loop)

    asyncio.ensure_future(serve(), loop=service.loop)

    # Run the service loop
    service.run()

    # Cleanup the service
    service.close()
Esempio n. 3
0
def main():
    service = MagmaService('policydb', mconfigs_pb2.PolicyDB())

    apn_rules_dict = ApnRuleAssignmentsDict()
    assignments_dict = RuleAssignmentsDict()
    basenames_dict = BaseNameDict()
    rating_groups_dict = RatingGroupsDict()
    sessiond_chan = ServiceRegistry.get_rpc_channel('sessiond',
                                                    ServiceRegistry.LOCAL)
    session_mgr_stub = LocalSessionManagerStub(sessiond_chan)
    sessiond_stub = SessionProxyResponderStub(sessiond_chan)
    reauth_handler = ReAuthHandler(assignments_dict, sessiond_stub)

    # Add all servicers to the server
    session_servicer = SessionRpcServicer(service.mconfig,
                                          rating_groups_dict,
                                          basenames_dict,
                                          apn_rules_dict)
    session_servicer.add_to_server(service.rpc_server)

    orc8r_chan = ServiceRegistry.get_rpc_channel('policydb',
                                                 ServiceRegistry.CLOUD)
    policy_stub = PolicyAssignmentControllerStub(orc8r_chan)
    policy_servicer = PolicyRpcServicer(reauth_handler, basenames_dict,
                                        policy_stub)
    policy_servicer.add_to_server(service.rpc_server)

    # Start a background thread to stream updates from the cloud
    if service.config['enable_streaming']:
        stream = StreamerClient(
            {
                'policydb': PolicyDBStreamerCallback(),
                'apn_rule_mappings': ApnRuleMappingsStreamerCallback(
                    session_mgr_stub,
                    basenames_dict,
                    apn_rules_dict,
                ),
                'rule_mappings': RuleMappingsStreamerCallback(
                    reauth_handler,
                    basenames_dict,
                    assignments_dict,
                    apn_rules_dict,
                ),
                'rating_groups': RatingGroupsStreamerCallback(
                    rating_groups_dict),

            },
            service.loop,
        )
        stream.start()
    else:
        logging.info('enable_streaming set to False. Streamer disabled!')

    # Run the service loop
    service.run()

    # Cleanup the service
    service.close()
Esempio n. 4
0
def main():
    """ main() for subscriberdb """
    service = MagmaService('policydb')
    # Start a background thread to stream updates from the cloud
    callback = PolicyDBStreamerCallback(service.loop)
    stream = StreamerClient({"policydb": callback}, service.loop)
    stream.start()

    # Run the service loop
    service.run()

    # Cleanup the service
    service.close()
Esempio n. 5
0
def main():
    """ main() for subscriberdb """
    service = MagmaService('policydb')
    # Start a background thread to stream updates from the cloud
    if service.config['enable_streaming']:
        callback = PolicyDBStreamerCallback(service.loop)
        stream = StreamerClient({"policydb": callback}, service.loop)
        stream.start()
    else:
        logging.info('enable_streaming set to False. Streamer disabled!')

    # Run the service loop
    service.run()

    # Cleanup the service
    service.close()