Exemplo n.º 1
0
def make_dsenode_new_partition(node_id,
                               messaging_config=None,
                               node_rpc_endpoints=None):
    """Get new DseNode in it's own new DSE partition."""
    messaging_config = messaging_config or generate_messaging_config()
    node_rpc_endpoints = node_rpc_endpoints or []
    return dse_node.DseNode(messaging_config, node_id, node_rpc_endpoints,
                            partition_id=get_new_partition())
 def _create_node_with_services(num):
     nid = 'cbd_node%s' % num
     nodes.append(dse_node.DseNode(self.messaging_config, nid, []))
     ns = []
     for s in range(num):
         # intentionally starting different number services
         ns.append(data_service.DataService('cbd-%d_svc-%d' % (num, s)))
         nodes[-1].register_service(ns[-1])
     services.append(ns)
     return nodes[-1]
Exemplo n.º 3
0
def create2(node_id=None,
            bus_id=None,
            existing_node=None,
            policy_engine=True,
            datasources=True,
            api=True):
    """Get Congress up.

    Creates a DseNode if one is not provided and adds policy_engine,
    datasources, api to that node.

    :param node_id is node_id of DseNode to be created
    :param bus_id is partition_id of DseNode to be created
    :param existing_node is a DseNode (optional; in lieu of previous 2 params)
    :param policy_engine controls whether policy_engine is included
    :param datasources controls whether datasources are included
    :param api controls whether API is included
    :returns DseNode
    """
    # create DseNode if existing_node not given
    if existing_node is None:
        assert (not (node_id is None or bus_id is None)),\
            'params node_id and bus_id required.'
        node = dse_node.DseNode(cfg.CONF, node_id, [], partition_id=bus_id)
    else:
        assert (node_id is None and bus_id is None),\
            'params node_id and bus_id must be None when existing_node given.'
        node = existing_node

    # create services as required
    services = {}

    if datasources:
        LOG.info("Registering congress datasource services on node %s",
                 node.node_id)
        services['datasources'] = create_datasources(node)
        services['ds_manager'] = ds_manager.DSManagerService(
            api_base.DS_MANAGER_SERVICE_ID)
        node.register_service(services['ds_manager'])

    if policy_engine:
        LOG.info("Registering congress PolicyEngine service on node %s",
                 node.node_id)
        engine = create_policy_engine()
        services[api_base.ENGINE_SERVICE_ID] = engine
        node.register_service(engine)
        initialize_policy_engine(engine)

    if api:
        LOG.info("Registering congress API service on node %s", node.node_id)
        services['api'], services['api_service'] = create_api()
        node.register_service(services['api_service'])

    return services
Exemplo n.º 4
0
def make_dsenode_same_partition(existing,
                                node_id,
                                messaging_config=None,
                                node_rpc_endpoints=None):
    """Get new DseNode in the same DSE partition as existing (node or part)."""
    partition_id = (existing.partition_id if
                    isinstance(existing, dse_node.DseNode) else existing)

    messaging_config = messaging_config or generate_messaging_config()
    node_rpc_endpoints = node_rpc_endpoints or []
    return dse_node.DseNode(
        messaging_config, node_id, node_rpc_endpoints, partition_id)
Exemplo n.º 5
0
def create2(node_id=None, bus_id=None, existing_node=None,
            policy_engine=True, datasources=True, api=True):
    """Get Congress up.

    Creates a DseNode if one is not provided and adds policy_engine,
    datasources, api to that node.

    :param: node_id is node_id of DseNode to be created
    :param: bus_id is partition_id of DseNode to be created
    :param: existing_node is a DseNode (optional; in lieu of previous 2 params)
    :param: policy_engine controls whether policy_engine is included
    :param: datasources controls whether datasources are included
    :param: api controls whether API is included
    :returns: DseNode
    """
    # create DseNode if existing_node not given
    if existing_node is None:
        assert (not (node_id is None or bus_id is None)),\
            'params node_id and bus_id required.'
        node = dse_node.DseNode(cfg.CONF, node_id, [], partition_id=bus_id)
    else:
        assert (node_id is None and bus_id is None),\
            'params node_id and bus_id must be None when existing_node given.'
        node = existing_node

    # create services as required
    services = {}

    # Load all configured drivers
    dse_node.DseNode.load_drivers()

    if datasources:
        LOG.info("Registering congress datasource services on node %s",
                 node.node_id)
        services['datasources'] = create_datasources(node)
        services['ds_manager'] = ds_manager.DSManagerService(
            api_base.DS_MANAGER_SERVICE_ID)
        node.register_service(services['ds_manager'])

    if policy_engine:
        LOG.info("Registering congress PolicyEngine service on node %s",
                 node.node_id)
        engine = create_policy_engine()
        services[api_base.ENGINE_SERVICE_ID] = engine
        node.register_service(engine)
        initialize_policy_engine(engine)

        # NOTE(ekcs): library service does not depend on policy engine,
        # it is placed on the same nodes as policy engine for convenience only
        LOG.info("Registering congress policy library service on node %s",
                 node.node_id)
        library = create_policy_library_service()
        services[api_base.LIBRARY_SERVICE_ID] = library
        node.register_service(library)

    if api:
        LOG.info("Registering congress API service on node %s", node.node_id)
        services['api'], services['api_service'] = create_api()
        node.register_service(services['api_service'])

    return services
Exemplo n.º 6
0
 def __init__(self, name, bus_id=None):
     super(Server, self).__init__()
     self.name = name
     self.node = dse_node.DseNode(cfg.CONF,
                                  self.name, [],
                                  partition_id=bus_id)
Exemplo n.º 7
0
def create2(node_id=None,
            bus_id=None,
            existing_node=None,
            policy_engine=True,
            datasources=True,
            api=True):
    """Get Congress up.

    Creates a DseNode if one is not provided and adds policy_engine,
    datasources, api to that node.

    :param node_id is node_id of DseNode to be created
    :param bus_id is partition_id of DseNode to be created
    :param existing_node is a DseNode (optional; in lieu of previous 2 params)
    :param policy_engine controls whether policy_engine is included
    :param datasources controls whether datasources are included
    :param api controls whether API is included
    :returns DseNode
    """
    # create DseNode if existing_node not given
    if existing_node is None:
        assert (not (node_id is None or bus_id is None)),\
            'params node_id and bus_id required.'
        node = dse_node.DseNode(cfg.CONF, node_id, [], partition_id=bus_id)
    else:
        assert (node_id is None and bus_id is None),\
            'params node_id and bus_id must be None when existing_node given.'
        node = existing_node

    # create services as required
    services = {}
    if datasources:
        LOG.info("Registering congress datasource services on node %s",
                 node.node_id)
        services['datasources'] = create_datasources(node)

        # datasource policies would be created by respective PE's synchronizer
        # for ds in services['datasources']:
        #    try:
        #        utils.create_datasource_policy(ds, ds.name,
        #                                       api_base.ENGINE_SERVICE_ID)
        #    except (exception.BadConfig,
        #            exception.DatasourceNameInUse,
        #            exception.DriverNotFound,
        #            exception.DatasourceCreationError) as e:
        #        LOG.exception("Datasource %s creation failed. %s" % (ds, e))
        #        node.unregister_service(ds)

    if policy_engine:
        LOG.info("Registering congress PolicyEngine service on node %s",
                 node.node_id)
        services[api_base.ENGINE_SERVICE_ID] = create_policy_engine()
        node.register_service(services[api_base.ENGINE_SERVICE_ID])
        initialize_policy_engine(services[api_base.ENGINE_SERVICE_ID])

    # start synchronizer and other periodic tasks
    if policy_engine:
        services[api_base.ENGINE_SERVICE_ID].start_policy_synchronizer()
    if datasources:
        node.start_periodic_tasks()
        node.register_service(
            dse_node.DSManagerService(dse_node.DS_MANAGER_SERVICE_ID))

    if api:
        LOG.info("Registering congress API service on node %s", node.node_id)
        services['api'], services['api_service'] = create_api()
        node.register_service(services['api_service'])

    return services