@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
43 lines • 1.89 kB
JavaScript
/**
* SPDX-License-Identifier: Apache-2.0
*/
import * as yaml from 'yaml';
import * as constants from './constants.js';
import { Templates } from './templates.js';
export class NodeOverridesModel {
interfaceBindings = [];
endpointOverrides = [];
constructor(nodeAliases, networkNodeServiceMap) {
nodeAliases.forEach(nodeAlias => {
const nodeId = +networkNodeServiceMap.get(nodeAlias).nodeId;
const localClusterPort = +constants.HEDERA_NODE_EXTERNAL_GOSSIP_PORT;
const localClusterHostName = Templates.renderNetworkHeadlessSvcName(nodeAlias);
this.interfaceBindings.push({ nodeId, hostname: localClusterHostName, port: localClusterPort });
// TODO future, add endpointOverrides for addresses external to cluster in multi-cluster support situation
// this.endpointOverrides.push({nodeId, hostname: externalHostname, port: externalPort});
});
}
/**
* Converts the model to YAML as expected to be consumed inside node
* @returns the raw YAML as string
*
* @example
* gossip:
* interfaceBindings:
* - { "nodeId": 0, "hostname": "10.10.10.1", "port": 1234 }
* - { "nodeId": 3, "hostname": "2001:db8:3333:4444:5555:6666:7777:8888", "port": 1237 }
* endpointOverrides:
* - { "nodeId": 5, "hostname": "10.10.10.11", "port": 1238 }
*/
toYAML() {
const gossipData = {};
if (this.interfaceBindings.length) {
gossipData.interfaceBindings = this.interfaceBindings.map(d => JSON.stringify(d));
}
if (this.endpointOverrides.length) {
gossipData.endpointOverrides = this.endpointOverrides.map(d => JSON.stringify(d));
}
return yaml.stringify({ gossip: gossipData }).replaceAll(/'/g, '');
}
}
//# sourceMappingURL=node_overrides_model.js.map