Esempio n. 1
0
def create_nodes(clients, boot_ip, bootID, poet_ip, network_name):
    print("creating clients")
    tools.update_dict(
        params.client_params, **{
            "bootnodes":
            tools.node_string(bootID, boot_ip, BOOTSTRAP_PORT, BOOTSTRAP_PORT),
            "poet-server":
            '{0}:{1}'.format(poet_ip, POET_SERVER_PORT),
            "genesis-time":
            GENESIS_TIME.isoformat('T', 'seconds')
        })

    print("running clients with args: " +
          tools.dict_to_args(params.client_params))
    jsonbaseport = 9191
    grpcbaseport = 9081
    for name, pubkey in clients.items():
        tools.update_dict(params.client_params, **{"coinbase": pubkey})
        node = client.containers.run(
            node_image,
            log_config=LogConfig(type=LogConfig.types.FLUENTD,
                                 config={
                                     'tag': 'docker.{{.ID}}',
                                     'fluentd-sub-second-precision': 'true'
                                 }),
            volumes={
                os.path.abspath(GENESIS_ACCOUNTS): {
                    'bind': params.client_params["genesis-conf"],
                    'mode': 'rw'
                }
            },
            detach=True,
            ports={
                "9090": jsonbaseport,
                "9091": grpcbaseport
            },
            network=network_name,
            name=name,
            command=tools.dict_to_args(params.client_params))
        # client.networks.get(network_name).connect(node)
        containers.append({"cont": node})
        # idxes[node.name] = i
        print(tools.bcolors.OKYELLOW + "Client created " + node.name +
              " connect wallet to json: 127.0.0.1:" + str(jsonbaseport) +
              "/gRPC 127.0.0.1:" + str(grpcbaseport) + " to access this node" +
              tools.bcolors.ENDC)
        jsonbaseport += 1
        grpcbaseport += 1
    print("Finished creating clients")
Esempio n. 2
0
def create_poet(network_name, poet_ip, bootstrap_ip):
    print("Creating poet container")
    networking_config = advclient.create_networking_config(
        {network_name: advclient.create_endpoint_config(ipv4_address=poet_ip)})
    host_cfg = advclient.create_host_config(log_config=LogConfig(
        type=LogConfig.types.FLUENTD, config={'tag': 'docker.poet_{{.ID}}'}))
    tools.update_dict(params.poet_params,
                      **{"nodeaddr": '{0}:{1}'.format(bootstrap_ip, '9091')})
    p = advclient.create_container(poet_image,
                                   host_config=host_cfg,
                                   detach=True,
                                   networking_config=networking_config,
                                   command=tools.dict_to_args(
                                       params.poet_params))
    advclient.start(p['Id'])
    return client.containers.get(p['Id'])
Esempio n. 3
0
def create_bootstrap(coinbase, network_name, bootstrap_ip, poet_ip):
    print("Creating bootstrap container")
    networking_config = advclient.create_networking_config({
        network_name:
        advclient.create_endpoint_config(ipv4_address=bootstrap_ip)
    })
    tools.update_dict(
        params.bootstrap_params, **{
            "genesis-time": GENESIS_TIME.isoformat('T', 'seconds'),
            "coinbase": coinbase,
            "poet-server": '{0}:{1}'.format(poet_ip, POET_SERVER_PORT),
            "events-url": 'tcp://0.0.0.0:{0}'.format(EVENTS_PORT)
        })

    host_cfg = advclient.create_host_config(
        log_config=LogConfig(type=LogConfig.types.FLUENTD,
                             config={'tag': 'docker.{{.ID}}'}),
        port_bindings={
            9090: 9090,
            9091: 9091,
            EVENTS_PORT: EVENTS_PORT
        },
        binds={
            os.path.abspath(GENESIS_ACCOUNTS): {
                'bind': params.client_params["genesis-conf"],
                'mode': 'rw'
            }
        })
    print("bootstrap params:", tools.dict_to_args(params.bootstrap_params))
    bts = advclient.create_container(node_image,
                                     name="bootstrap",
                                     host_config=host_cfg,
                                     detach=True,
                                     networking_config=networking_config,
                                     ports=[9090, 9091, EVENTS_PORT],
                                     command=tools.dict_to_args(
                                         params.bootstrap_params))
    advclient.start(bts['Id'])
    return client.containers.get(bts['Id'])