polkadot-secure-validator
Advanced tools
Comparing version 3.1.0 to 3.2.0
{ | ||
"name": "polkadot-secure-validator", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"main": "src/index.js", | ||
@@ -13,2 +13,3 @@ "repository": "https://github.com/w3f/polkadot-secure-validator", | ||
"plan": "node . plan", | ||
"update-binary": "node . update-binary", | ||
"lint": "eslint .", | ||
@@ -15,0 +16,0 @@ "pretest": "yarn lint" |
@@ -13,2 +13,3 @@ #!/usr/bin/env node | ||
const version = require('./lib/version'); | ||
const updateBinary = require('./lib/actions/updateBinary'); | ||
@@ -37,2 +38,7 @@ | ||
program | ||
.command('update-binary') | ||
.description('Update the nodes binary.') | ||
.option('-c, --config [path]', 'Path to config file.', './config/main.json') | ||
.action(updateBinary.do); | ||
@@ -39,0 +45,0 @@ program.allowUnknownOption(false); |
@@ -25,2 +25,6 @@ const { Ansible } = require('./clients/ansible'); | ||
async updateBinary() { | ||
return this.ansible.updateBinary(); | ||
} | ||
async clean() { | ||
@@ -27,0 +31,0 @@ return this.ansible.clean(); |
@@ -32,2 +32,7 @@ const path = require('path'); | ||
async updateBinary() { | ||
const inventoryPath = this._writeInventory(); | ||
return this._cmd(`main_update_binary.yml -f 30 -i "${inventoryPath}"`); | ||
} | ||
async _cmd(command, options = {}) { | ||
@@ -81,3 +86,3 @@ const actualOptions = Object.assign({}, this.options, options); | ||
polkadotAdditionalValidatorFlags, | ||
polkadotAdditionalPublicFlags, | ||
polkadotAdditionalPublicFlags | ||
}; | ||
@@ -84,0 +89,0 @@ if (this.config.nodeExporter && this.config.nodeExporter.enabled) { |
@@ -23,2 +23,7 @@ const fs = require('fs-extra'); | ||
async initNodes() { | ||
await this._initNodes('validator',this.config.validators.nodes) | ||
this.config.publicNodes && await this._initNodes('publicNode',this.config.publicNodes.nodes) | ||
} | ||
async sync(method='apply') { | ||
@@ -92,4 +97,3 @@ this._initializeTerraform(); | ||
const options = { cwd }; | ||
await this._cmd(`init -var state_project=${this.config.state.project} -backend-config=bucket=${backendConfig.bucket} -backend-config=prefix=${backendConfig.prefix}`, options); | ||
await this._initCmd(backendConfig,options); | ||
this._createVarsFile(cwd, nodes[counter], sshKey, nodeName); | ||
@@ -118,4 +122,3 @@ | ||
const options = { cwd }; | ||
await this._cmd(`init -var state_project=${this.config.state.project} -backend-config=bucket=${backendConfig.bucket} -backend-config=prefix=${backendConfig.prefix}`, options); | ||
await this._initCmd(backendConfig,options); | ||
await this._cmd('destroy -lock=false -auto-approve', options); | ||
@@ -134,2 +137,6 @@ | ||
async _initCmd(backendConfig, options) { | ||
await this._cmd(`init -var state_project=${this.config.state.project} -backend-config=bucket=${backendConfig.bucket} -backend-config=prefix=${backendConfig.prefix}`, options); | ||
} | ||
async _initState(){ | ||
@@ -183,2 +190,11 @@ const cwd = this._terraformNodeDirPath('remote-state'); | ||
async _initNodes(type,nodes,){ | ||
for (let counter = 0; counter < nodes.length; counter++) { | ||
const cwd = this._terraformNodeDirPath(type, counter); | ||
const backendConfig = this._backendConfig(type, counter); | ||
const options = { cwd }; | ||
await this._initCmd(backendConfig,options); | ||
} | ||
} | ||
_copyTerraformFiles(type, counter, provider) { | ||
@@ -185,0 +201,0 @@ const targetDirPath = this._terraformNodeDirPath(type, counter); |
@@ -14,8 +14,11 @@ const asyncUtils = require('./async.js'); | ||
await this.tf.sync('apply'); | ||
const validatorIpAddresses = await this._getValidatorIpAddresses(); | ||
const publicNodesIpAddresses = await this._getPublicNodesIpAddresses(); | ||
return { validatorIpAddresses, publicNodesIpAddresses }; | ||
} | ||
const validatorIpAddresses = await this._extractOutput('validator', this.config.validators.nodes); | ||
let publicNodesIpAddresses = []; | ||
if(this.config.publicNodes){ | ||
publicNodesIpAddresses = await this._extractOutput('publicNode', this.config.publicNodes.nodes); | ||
} | ||
async output() { | ||
await this.tf.initNodes(); | ||
const validatorIpAddresses = await this._getValidatorIpAddresses(); | ||
const publicNodesIpAddresses = await this._getPublicNodesIpAddresses(); | ||
return { validatorIpAddresses, publicNodesIpAddresses }; | ||
@@ -40,2 +43,13 @@ } | ||
} | ||
async _getValidatorIpAddresses() { | ||
return await this._extractOutput('validator', this.config.validators.nodes); | ||
} | ||
async _getPublicNodesIpAddresses() { | ||
if(this.config.publicNodes){ | ||
return await this._extractOutput('publicNode', this.config.publicNodes.nodes); | ||
} | ||
return [] | ||
} | ||
} | ||
@@ -42,0 +56,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95972
119
768