Exemple #1
0
 def write_raft_id(self):
     if self._raft_id is not None:
         templating.template_substitute(self.raft_id_file,
                                        {'raft_id': self._raft_id})
     else:
         templating.template_substitute(self.raft_id_file,
                                        {'raft_id': 'null'})
Exemple #2
0
def make_enode_id(enode, geth_address, geth_port, raft_port):
    enode_id_geth = make_enode_id_geth(enode, geth_address, geth_port)
    kwds = {'enode_id_geth': enode_id_geth, 'raft_port': raft_port}

    template_str = '$enode_id_geth&raftport=$raft_port'

    return templating.template_substitute(template_str, kwds)
Exemple #3
0
def make_enode_id_geth(enode, geth_address, geth_port):
    template_str = 'enode://$enode@$geth_address:$geth_port?discport=0'
    kwds = {
        'enode': enode,
        'geth_address': geth_address,
        'geth_port': geth_port
    }

    return templating.template_substitute(template_str, kwds)
Exemple #4
0
    def write_genesis(self):
        if self.is_initial_node(
        ):  # create genesis content for initial nodes only
            account_balances = self.prefund_accounts(
            )  # pre-fund each account of the nodes
            extra_data = self.create_extra_data(
            )  # create extra_data for raft or ibft

            self.genesis_content = templating.template_substitute(
                self.genesis_template_file, {
                    'account_balances': json.dumps(account_balances),
                    'chain_id': self._networkid,
                    'extra_data': json.dumps(extra_data)
                },
                write=False)

        self.write_genesis_file()
    def __init__(
            self,
            context,
            address,
            port=9000,  # default in quorum. needed to make config file.
            other_nodes=None):
        self.context = context
        self.address = address
        self.port = port

        other_nodes = [] if other_nodes is None else other_nodes
        self._other_nodes = ''  # moved to orchestrator

        self._url = ''  # moved to orchestrator

        self.base_dir = os.path.join(context, self.constellation_dir_name)
        self.storage_dir = os.path.join(self.base_dir, self.storage_dir_name)
        self.keys_dir = os.path.join(self.base_dir, self.keys_dir_name)

        self.config_file = os.path.join(self.base_dir, self.config_file_name)
        self.socket_file = os.path.join(self.base_dir, self.socket_file_name)
        self.log_file = os.path.join(self.base_dir, self.logs_dir_name,
                                     self.log_file_name)

        self.launch_script_file = os.path.join(self.base_dir,
                                               self.launch_script_file_name)

        self.make_keys()

        self.public_key = os.path.join(self.keys_dir, self.pub_key_file_name)
        self.private_key = os.path.join(self.keys_dir, self.pri_key_file_name)
        self.public_key_content = constellation_utils.read_constellation_key(
            self.public_key)
        self.private_key_content = constellation_utils.read_constellation_key(
            self.private_key)

        self._ptm_address = self.public_key_content

        # configuration related to this class instance
        self.build_config = {
            'network': {
                'url': self._url,
                'port': self.port,
                'othernodes': self._other_nodes
            },
            'local': {
                'ipc': self.socket_file,
                'log_file': self.log_file,
                'storage_dir': self.storage_dir
            },
            'keys': {
                'public_key': self.public_key,
                'private_key': self.private_key,
                'public_key_content': self.public_key_content,
                'private_key_content': self.private_key_content
            }
        }

        # configuration related to launching this instance of constellation, goes into a config file.
        # to be launched from within the constellation_dir_name
        self.launch_config = {
            'url':
            self._url,
            'port':
            self.port,
            'socket':
            self.socket_file_name,
            'othernodes':
            self._other_nodes,

            # relative to constellation_dir_name folder
            'publickeys':
            [os.path.join(self.keys_dir_name, self.pub_key_file_name)],
            # relative to constellation_dir_name folder
            'privatekeys':
            [os.path.join(self.keys_dir_name, self.pri_key_file_name)],
            'storage':
            self.storage_dir_name
        }

        # to launch constellation binary via cmd line. To be launched from within the constellation_dir_name.
        self.launch_params = {
            # relative to constellation_dir_name folder
            'constellation_binary':
            'constellation-node',
            'constellation_config_file':
            self.config_file_name,
            'constellation_log_file':
            os.path.join(self.logs_dir_name, self.log_file_name),
            'constellation_ipc_file':
            self.socket_file_name
        }

        # to be launched from within the constellation_dir_name. e.g nohup $binary $config_file_name 2>> $log_file
        self.launch_cmd_line = templating.template_substitute(
            '$constellation_binary $constellation_config_file 2>> $constellation_log_file',
            self.launch_params)

        self.write_launch_configuration_file()
        self.write_launch_script()
 def write_launch_script(self):
     templating.template_substitute(self.launch_script_file,
                                    self.launch_params)
 def write_launch_configuration_file(self):
     templating.template_substitute(self.config_file, self.launch_config)
Exemple #8
0
def make_enode_id2(enode_id_geth, raft_port):
    kwds = {'enode_id_geth': enode_id_geth, 'raft_port': raft_port}

    template_str = '$enode_id_geth&raftport=$raft_port'

    return templating.template_substitute(template_str, kwds)