From f00e670edb50768e5d20439dcb603e3b50a52882 Mon Sep 17 00:00:00 2001 From: Phyrex Tsai Date: Tue, 5 Nov 2019 14:26:59 +0800 Subject: [PATCH 1/3] Update README --- README.md | 13 +++++++++---- README_KR.md | 13 +++++++++---- README_ZH.md | 13 +++++++++---- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2867c353..778a539d 100644 --- a/README.md +++ b/README.md @@ -38,22 +38,22 @@ KAIZEN is an one stop solution for dapp and dweb developer. With KAIZEN, you get - [Licence](#licence) ## 🚀 Quick Start -1. Install via npm: +STEP 1. Install via npm: ``` npm install -g kaizen-cli ``` -2. Create a project: +STEP 2. Create a project: ``` kaizen create --template react --name myproject ``` -3. Deploy smart contracts: +STEP 3. Deploy smart contracts: ``` kaizen contracts deploy --url https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20 ``` -4. Upload project to [IPFS](https://ipfs.io) or [BTFS](https://www.bittorrent.com/btfs/): +STEP 4. Upload project to [IPFS](https://ipfs.io) or [BTFS](https://www.bittorrent.com/btfs/): ``` # Upload to IPFS kaizen upload ipfs ./build @@ -61,6 +61,11 @@ kaizen upload ipfs ./build kaizen upload btfs ./build ``` +STEP 5. Hosting instance on AWS +``` +kaizen instances run nym-loopix-mixnode +``` + ## 🔨 Command Topics - [`kaizen config`](commands/config.md) - Configure KAIZEN diff --git a/README_KR.md b/README_KR.md index 55c3dc30..35941c14 100644 --- a/README_KR.md +++ b/README_KR.md @@ -37,22 +37,22 @@ - [라이센스](#licence) ## 🚀 Quick Start -1. Install via npm: +STEP 1. Install via npm: ``` npm install -g kaizen-cli ``` -2. Create a project: +STEP 2. Create a project: ``` kaizen create --template react --name myproject ``` -3. Deploy smart contracts: +STEP 3. Deploy smart contracts: ``` kaizen contracts deploy --url https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20 ``` -4. Upload project to [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/): +STEP 4. Upload project to [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/): ``` # Upload to IPFS kaizen upload ipfs ./build @@ -60,6 +60,11 @@ kaizen upload ipfs ./build kaizen upload btfs ./build ``` +STEP 5. Hosting instance on AWS +``` +kaizen instances run nym-loopix-mixnode +``` + ## 🔨 Command Topics - [`kaizen config`](commands/config.md) - Configure KAIZEN diff --git a/README_ZH.md b/README_ZH.md index 25d635de..e00cd0f9 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -37,22 +37,22 @@ KAIZEN 包括: - [許可證](#licence) ## 🚀 快速開始 -1. 透過 npm 安裝 KAIZEN: +STEP 1. 透過 npm 安裝 KAIZEN: ``` npm install -g kaizen-cli ``` -2. 創建專案: +STEP 2. 創建專案: ``` kaizen create --template react --name myproject ``` -3. 部署智能合約: +STEP 3. 部署智能合約: ``` kaizen contracts deploy --url https://github.com/PortalNetwork/kaizen-contracts/tree/master/ERC20 ``` -4. 上傳專案到 [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/): +STEP 4. 上傳專案到 [IPFS](https://ipfs.io) 或者 [BTFS](https://www.bittorrent.com/btfs/): ``` # Upload to IPFS kaizen upload ipfs ./build @@ -60,6 +60,11 @@ kaizen upload ipfs ./build kaizen upload btfs ./build ``` +STEP 5. 部署實例於 AWS 上 +``` +kaizen instances run nym-loopix-mixnode +``` + ## 🔨 指令集 - [`kaizen config`](commands/config.md) - 設定 KAIZEN From d81d6b7d8e8e40b4c43504e8d6c6b8410bcc2c30 Mon Sep 17 00:00:00 2001 From: Phyrex Tsai Date: Mon, 18 Nov 2019 15:21:03 +0800 Subject: [PATCH 2/3] Add golem --- build/components/Instances/Run/golem.js | 105 ++++++++++++ build/components/Instances/Run/index.js | 41 +++-- .../Instances/Run/nym-loopix-mixnode.js | 159 +++++++++--------- build/components/Instances/Template/index.js | 3 +- build/components/Instances/index.js | 2 +- build/lib/aws/AWSService.js | 8 +- build/lib/aws/ami.js | 6 + src/components/Instances/Run/golem.js | 48 ++++++ src/components/Instances/Run/index.js | 18 +- .../Instances/Run/nym-loopix-mixnode.js | 4 +- src/components/Instances/Template/index.js | 1 + src/components/Instances/index.js | 1 + src/lib/aws/AWSService.js | 4 +- src/lib/aws/ami.js | 6 + 14 files changed, 306 insertions(+), 100 deletions(-) create mode 100644 build/components/Instances/Run/golem.js create mode 100644 src/components/Instances/Run/golem.js diff --git a/build/components/Instances/Run/golem.js b/build/components/Instances/Run/golem.js new file mode 100644 index 00000000..689f8b1e --- /dev/null +++ b/build/components/Instances/Run/golem.js @@ -0,0 +1,105 @@ +"use strict"; + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +var Log = require('../../../lib/Log'); + +var AWSService = require('../../../lib/aws/AWSService'); + +var path = require('path'); + +var fsx = require('fs-extra'); + +module.exports = +/*#__PURE__*/ +function () { + var _ref = _asyncToGenerator( + /*#__PURE__*/ + regeneratorRuntime.mark(function _callee(instance, type) { + var kaizenrc, region, awsService, isExists, keyPair, _instance, instances, configuration; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.prev = 0; + kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc')); + region = 'us-east-1'; + + if (!kaizenrc['accessKey']) { + Log.NormalLog("Please set AWS access key by 'kaizen config set --key accessKey --value [Access Key Value]'"); + } + + if (!kaizenrc['secretKey']) { + Log.NormalLog("Please set AWS secret key by 'kaizen config set --key secretKey --value [Secret Key Value]'"); + } + + if (kaizenrc['region']) { + region = kaizenrc['region']; + } + + awsService = new AWSService(kaizenrc['accessKey'], kaizenrc['secretKey'], region); + _context.next = 9; + return awsService.isKeyPairsExists('kaizen-cli'); + + case 9: + isExists = _context.sent; + keyPair = 'kaizen-cli'; + + if (isExists) { + _context.next = 16; + break; + } + + Log.NormalLog('Creating Key Pair:\n'.underline.yellow + 'kaizen-cli.pem'.yellow); + _context.next = 15; + return awsService.createKeyPair(); + + case 15: + keyPair = _context.sent; + + case 16: + _context.next = 18; + return awsService.runInstance(_instance, type); + + case 18: + _instance = _context.sent; + instances = []; + + if (kaizenrc['instances']) { + instances = kaizenrc['instances']; + } + + instances.push(_instance); + configuration = _objectSpread({}, kaizenrc, { + "keyPair": keyPair, + "instances": instances + }); + fsx.writeJsonSync(path.resolve(__dirname, '../../../../.kaizenrc'), configuration); + _context.next = 30; + break; + + case 26: + _context.prev = 26; + _context.t0 = _context["catch"](0); + Log.ErrorLog('something went wrong!'); + console.error(_context.t0); + + case 30: + case "end": + return _context.stop(); + } + } + }, _callee, this, [[0, 26]]); + })); + + return function (_x, _x2) { + return _ref.apply(this, arguments); + }; +}(); \ No newline at end of file diff --git a/build/components/Instances/Run/index.js b/build/components/Instances/Run/index.js index fa6efc06..f45c995c 100644 --- a/build/components/Instances/Run/index.js +++ b/build/components/Instances/Run/index.js @@ -10,13 +10,19 @@ var Spinner = require('../../../lib/Spinner'); var nymLoopixMixnodeHandler = require('./nym-loopix-mixnode.js'); +var golemHandler = require('./golem.js'); + function builder(yargs) { return yargs.positional('instance', { alias: 'i', type: 'string', describe: 'instance name', require: true - }).example('kaizen instances run nym-loopix-mixnode').demandOption(['instance'], ''); + }).option('type', { + alias: 't', + type: 'string', + describe: 'instance type' + }).example('kaizen instances run nym-loopix-mixnode').example('kaizen instances run golem --type t2.xlarge').demandOption(['instance'], ''); } function handler(_x) { @@ -27,13 +33,13 @@ function _handler() { _handler = _asyncToGenerator( /*#__PURE__*/ regeneratorRuntime.mark(function _callee(argv) { - var instance; + var instance, type; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.prev = 0; - instance = argv.instance; + instance = argv.instance, type = argv.type; if (instance) { _context.next = 5; @@ -45,40 +51,51 @@ function _handler() { case 5: _context.t0 = instance; - _context.next = _context.t0 === 'nym-loopix-mixnode' ? 8 : 15; + _context.next = _context.t0 === 'nym-loopix-mixnode' ? 8 : _context.t0 === 'golem' ? 15 : 22; break; case 8: Log.NormalLog("Starting ".concat(instance, " instance, please wait a second...")); Spinner.start(); _context.next = 12; - return nymLoopixMixnodeHandler(); + return nymLoopixMixnodeHandler(instance, type); case 12: Spinner.stop(); Log.SuccessLog("Start instance ".concat(instance, " Successfully")); - return _context.abrupt("break", 16); + return _context.abrupt("break", 23); case 15: + Log.NormalLog("Starting ".concat(instance, " instance, please wait a second...")); + Spinner.start(); + _context.next = 19; + return golemHandler(instance, type); + + case 19: + Spinner.stop(); + Log.SuccessLog("Start instance ".concat(instance, " Successfully")); + return _context.abrupt("break", 23); + + case 22: Log.NormalLog('Instance not support yet'); - case 16: - _context.next = 23; + case 23: + _context.next = 30; break; - case 18: - _context.prev = 18; + case 25: + _context.prev = 25; _context.t1 = _context["catch"](0); Spinner.stop(); Log.ErrorLog('something went wrong!'); console.error(_context.t1); - case 23: + case 30: case "end": return _context.stop(); } } - }, _callee, this, [[0, 18]]); + }, _callee, this, [[0, 25]]); })); return _handler.apply(this, arguments); } diff --git a/build/components/Instances/Run/nym-loopix-mixnode.js b/build/components/Instances/Run/nym-loopix-mixnode.js index 632aaec1..689f8b1e 100644 --- a/build/components/Instances/Run/nym-loopix-mixnode.js +++ b/build/components/Instances/Run/nym-loopix-mixnode.js @@ -18,81 +18,88 @@ var fsx = require('fs-extra'); module.exports = /*#__PURE__*/ -_asyncToGenerator( -/*#__PURE__*/ -regeneratorRuntime.mark(function _callee() { - var kaizenrc, region, awsService, isExists, keyPair, instance, instances, configuration; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _context.prev = 0; - kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc')); - region = 'us-east-1'; - - if (!kaizenrc['accessKey']) { - Log.NormalLog("Please set AWS access key by 'kaizen config set --key accessKey --value [Access Key Value]'"); - } - - if (!kaizenrc['secretKey']) { - Log.NormalLog("Please set AWS secret key by 'kaizen config set --key secretKey --value [Secret Key Value]'"); - } - - if (kaizenrc['region']) { - region = kaizenrc['region']; - } - - awsService = new AWSService(kaizenrc['accessKey'], kaizenrc['secretKey'], region); - _context.next = 9; - return awsService.isKeyPairsExists('kaizen-cli'); - - case 9: - isExists = _context.sent; - keyPair = 'kaizen-cli'; - - if (isExists) { - _context.next = 16; +function () { + var _ref = _asyncToGenerator( + /*#__PURE__*/ + regeneratorRuntime.mark(function _callee(instance, type) { + var kaizenrc, region, awsService, isExists, keyPair, _instance, instances, configuration; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.prev = 0; + kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc')); + region = 'us-east-1'; + + if (!kaizenrc['accessKey']) { + Log.NormalLog("Please set AWS access key by 'kaizen config set --key accessKey --value [Access Key Value]'"); + } + + if (!kaizenrc['secretKey']) { + Log.NormalLog("Please set AWS secret key by 'kaizen config set --key secretKey --value [Secret Key Value]'"); + } + + if (kaizenrc['region']) { + region = kaizenrc['region']; + } + + awsService = new AWSService(kaizenrc['accessKey'], kaizenrc['secretKey'], region); + _context.next = 9; + return awsService.isKeyPairsExists('kaizen-cli'); + + case 9: + isExists = _context.sent; + keyPair = 'kaizen-cli'; + + if (isExists) { + _context.next = 16; + break; + } + + Log.NormalLog('Creating Key Pair:\n'.underline.yellow + 'kaizen-cli.pem'.yellow); + _context.next = 15; + return awsService.createKeyPair(); + + case 15: + keyPair = _context.sent; + + case 16: + _context.next = 18; + return awsService.runInstance(_instance, type); + + case 18: + _instance = _context.sent; + instances = []; + + if (kaizenrc['instances']) { + instances = kaizenrc['instances']; + } + + instances.push(_instance); + configuration = _objectSpread({}, kaizenrc, { + "keyPair": keyPair, + "instances": instances + }); + fsx.writeJsonSync(path.resolve(__dirname, '../../../../.kaizenrc'), configuration); + _context.next = 30; break; - } - - Log.NormalLog('Creating Key Pair:\n'.underline.yellow + 'kaizen-cli.pem'.yellow); - _context.next = 15; - return awsService.createKeyPair(); - - case 15: - keyPair = _context.sent; - - case 16: - _context.next = 18; - return awsService.runInstance('nym-loopix-mixnode'); - - case 18: - instance = _context.sent; - instances = []; - - if (kaizenrc['instances']) { - instances = kaizenrc['instances']; - } - - instances.push(instance); - configuration = _objectSpread({}, kaizenrc, { - "keyPair": keyPair, - "instances": instances - }); - fsx.writeJsonSync(path.resolve(__dirname, '../../../../.kaizenrc'), configuration); - _context.next = 30; - break; - - case 26: - _context.prev = 26; - _context.t0 = _context["catch"](0); - Log.ErrorLog('something went wrong!'); - console.error(_context.t0); - - case 30: - case "end": - return _context.stop(); + + case 26: + _context.prev = 26; + _context.t0 = _context["catch"](0); + Log.ErrorLog('something went wrong!'); + console.error(_context.t0); + + case 30: + case "end": + return _context.stop(); + } } - } - }, _callee, this, [[0, 26]]); -})); \ No newline at end of file + }, _callee, this, [[0, 26]]); + })); + + return function (_x, _x2) { + return _ref.apply(this, arguments); + }; +}(); \ No newline at end of file diff --git a/build/components/Instances/Template/index.js b/build/components/Instances/Template/index.js index b5de3299..f200d729 100644 --- a/build/components/Instances/Template/index.js +++ b/build/components/Instances/Template/index.js @@ -24,10 +24,11 @@ function _handler() { case 0: Log.NormalLog('Available instance template:'.underline.yellow); Log.NormalLog('nym-loopix-mixnode'.underline.yellow + ' - Nym is a blockchain-based privacy platform.'); + Log.NormalLog('golem'.underline.yellow + ' - Golem is computing power share platform.'); Log.NormalLog("\nTo start a instance run " + "'kaizen instances run '".yellow); Log.NormalLog("\nIt will be automatically start instance on AWS\n"); - case 4: + case 5: case "end": return _context.stop(); } diff --git a/build/components/Instances/index.js b/build/components/Instances/index.js index be620ceb..57a87538 100644 --- a/build/components/Instances/index.js +++ b/build/components/Instances/index.js @@ -11,7 +11,7 @@ function builder(yargs) { require('./Template')(yargs); - return yargs.example('kaizen instances run').example('kaizen instances template').example('kaizen instances list').demandCommand(1, '').epilogue('Available instance templates:\n\n'.underline.yellow + 'nym-loopix-mixnode'.underline.yellow + ' - Nym is a blockchain-based privacy platform.\n' + '\nRun ' + '\'kaizen instances \''.yellow + ' to deploy instances to AWS.\n'); + return yargs.example('kaizen instances run').example('kaizen instances template').example('kaizen instances list').demandCommand(1, '').epilogue('Available instance templates:\n\n'.underline.yellow + 'nym-loopix-mixnode'.underline.yellow + ' - Nym is a blockchain-based privacy platform.\n' + 'golem'.underline.yellow + ' - Golem is computing power share platform.\n' + '\nRun ' + '\'kaizen instances \''.yellow + ' to deploy instances to AWS.\n'); } function handler(_x) { diff --git a/build/lib/aws/AWSService.js b/build/lib/aws/AWSService.js index 29ead535..992bbe26 100644 --- a/build/lib/aws/AWSService.js +++ b/build/lib/aws/AWSService.js @@ -169,7 +169,7 @@ function () { value: function () { var _runInstance = _asyncToGenerator( /*#__PURE__*/ - regeneratorRuntime.mark(function _callee4(node) { + regeneratorRuntime.mark(function _callee4(node, type) { var instanceParams, ec2, instance, instanceId, instanceType, tagParams; return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { @@ -188,7 +188,7 @@ function () { case 6: instance = _context4.sent; instanceId = instance.Instances[0].InstanceId; - instanceType = instance.Instances[0].InstanceType; + instanceType = type ? type : instance.Instances[0].InstanceType; tagParams = { Resources: [instanceId], Tags: [{ @@ -221,7 +221,7 @@ function () { }, _callee4, this, [[0, 15]]); })); - return function runInstance(_x3) { + return function runInstance(_x3, _x4) { return _runInstance.apply(this, arguments); }; }() @@ -264,7 +264,7 @@ function () { }, _callee5, this, [[0, 9]]); })); - return function getInstance(_x4) { + return function getInstance(_x5) { return _getInstance.apply(this, arguments); }; }() diff --git a/build/lib/aws/ami.js b/build/lib/aws/ami.js index 769b2ed9..660907eb 100644 --- a/build/lib/aws/ami.js +++ b/build/lib/aws/ami.js @@ -48,5 +48,11 @@ exports.ami = { "InstanceType": "t2.micro", "MinCount": 1, "MaxCount": 1 + }, + "golem": { + "ImageId": "ami-09d77dc5c373f8fd6", + "InstanceType": "t2.micro", + "MinCount": 1, + "MaxCount": 1 } }; \ No newline at end of file diff --git a/src/components/Instances/Run/golem.js b/src/components/Instances/Run/golem.js new file mode 100644 index 00000000..6253c5bf --- /dev/null +++ b/src/components/Instances/Run/golem.js @@ -0,0 +1,48 @@ +const Log = require('../../../lib/Log'); +const AWSService = require('../../../lib/aws/AWSService'); +const path = require('path'); +const fsx = require('fs-extra'); + +module.exports = async function(instance, type) { + try { + const kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc')); + let region = 'us-east-1'; + if (!kaizenrc['accessKey']) { + Log.NormalLog(`Please set AWS access key by 'kaizen config set --key accessKey --value [Access Key Value]'`); + } + if (!kaizenrc['secretKey']) { + Log.NormalLog(`Please set AWS secret key by 'kaizen config set --key secretKey --value [Secret Key Value]'`); + } + if (kaizenrc['region']) { + region = kaizenrc['region']; + } + + const awsService = new AWSService(kaizenrc['accessKey'], kaizenrc['secretKey'], region); + + const isExists = await awsService.isKeyPairsExists('kaizen-cli'); + + let keyPair = 'kaizen-cli'; + if (!isExists) { + Log.NormalLog('Creating Key Pair:\n'.underline.yellow + 'kaizen-cli.pem'.yellow); + keyPair = await awsService.createKeyPair(); + } + + const instance = await awsService.runInstance(instance, type); + + let instances = []; + if (kaizenrc['instances']) { + instances = kaizenrc['instances']; + } + instances.push(instance); + + const configuration = { + ...kaizenrc, + "keyPair": keyPair, + "instances": instances + } + fsx.writeJsonSync(path.resolve(__dirname, '../../../../.kaizenrc'), configuration); + } catch (error) { + Log.ErrorLog('something went wrong!'); + console.error(error); + } +} diff --git a/src/components/Instances/Run/index.js b/src/components/Instances/Run/index.js index b77a950a..8b214a14 100644 --- a/src/components/Instances/Run/index.js +++ b/src/components/Instances/Run/index.js @@ -1,6 +1,7 @@ const Log = require('../../../lib/Log'); const Spinner = require('../../../lib/Spinner'); const nymLoopixMixnodeHandler = require('./nym-loopix-mixnode.js'); +const golemHandler = require('./golem.js'); function builder(yargs) { return yargs @@ -10,13 +11,19 @@ function builder(yargs) { describe: 'instance name', require: true }) + .option('type', { + alias: 't', + type: 'string', + describe: 'instance type' + }) .example('kaizen instances run nym-loopix-mixnode') + .example('kaizen instances run golem --type t2.xlarge') .demandOption(['instance'], ''); } async function handler(argv) { try { - const { instance } = argv; + const { instance, type } = argv; if (!instance) { Log.NormalLog('Missing instance name.\nPlease using \'kaizen instances run [instance]\''); @@ -27,7 +34,14 @@ async function handler(argv) { case 'nym-loopix-mixnode': Log.NormalLog(`Starting ${instance} instance, please wait a second...`); Spinner.start(); - await nymLoopixMixnodeHandler(); + await nymLoopixMixnodeHandler(instance, type); + Spinner.stop(); + Log.SuccessLog(`Start instance ${instance} Successfully`); + break; + case 'golem': + Log.NormalLog(`Starting ${instance} instance, please wait a second...`); + Spinner.start(); + await golemHandler(instance, type); Spinner.stop(); Log.SuccessLog(`Start instance ${instance} Successfully`); break; diff --git a/src/components/Instances/Run/nym-loopix-mixnode.js b/src/components/Instances/Run/nym-loopix-mixnode.js index 95eba572..6253c5bf 100644 --- a/src/components/Instances/Run/nym-loopix-mixnode.js +++ b/src/components/Instances/Run/nym-loopix-mixnode.js @@ -3,7 +3,7 @@ const AWSService = require('../../../lib/aws/AWSService'); const path = require('path'); const fsx = require('fs-extra'); -module.exports = async function() { +module.exports = async function(instance, type) { try { const kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc')); let region = 'us-east-1'; @@ -27,7 +27,7 @@ module.exports = async function() { keyPair = await awsService.createKeyPair(); } - const instance = await awsService.runInstance('nym-loopix-mixnode'); + const instance = await awsService.runInstance(instance, type); let instances = []; if (kaizenrc['instances']) { diff --git a/src/components/Instances/Template/index.js b/src/components/Instances/Template/index.js index 7c32c08e..749ffaf1 100644 --- a/src/components/Instances/Template/index.js +++ b/src/components/Instances/Template/index.js @@ -8,6 +8,7 @@ function builder(yargs) { async function handler(argv) { Log.NormalLog('Available instance template:'.underline.yellow); Log.NormalLog('nym-loopix-mixnode'.underline.yellow + ' - Nym is a blockchain-based privacy platform.'); + Log.NormalLog('golem'.underline.yellow + ' - Golem is computing power share platform.') Log.NormalLog("\nTo start a instance run " + "'kaizen instances run '".yellow) diff --git a/src/components/Instances/index.js b/src/components/Instances/index.js index 5064d1eb..cfc286c0 100644 --- a/src/components/Instances/index.js +++ b/src/components/Instances/index.js @@ -11,6 +11,7 @@ function builder(yargs) { .epilogue( 'Available instance templates:\n\n'.underline.yellow + 'nym-loopix-mixnode'.underline.yellow + ' - Nym is a blockchain-based privacy platform.\n' + + 'golem'.underline.yellow + ' - Golem is computing power share platform.\n' + '\nRun ' + '\'kaizen instances \''.yellow + ' to deploy instances to AWS.\n' ); diff --git a/src/lib/aws/AWSService.js b/src/lib/aws/AWSService.js index 53bd95dc..25ebdd41 100644 --- a/src/lib/aws/AWSService.js +++ b/src/lib/aws/AWSService.js @@ -58,7 +58,7 @@ class AWSService { } } - async runInstance(node) { + async runInstance(node, type) { try { // TODO choose AMI_ID, generate Key let instanceParams = ami.ami[node]; @@ -67,7 +67,7 @@ class AWSService { const ec2 = new AWS.EC2({apiVersion: '2016-11-15'}); const instance = await ec2.runInstances(instanceParams).promise(); const instanceId = instance.Instances[0].InstanceId; - const instanceType = instance.Instances[0].InstanceType; + const instanceType = (type) ? type : instance.Instances[0].InstanceType; const tagParams = {Resources: [instanceId], Tags: [ { Key: 'Name', diff --git a/src/lib/aws/ami.js b/src/lib/aws/ami.js index a855f3fb..7463ad20 100644 --- a/src/lib/aws/ami.js +++ b/src/lib/aws/ami.js @@ -46,5 +46,11 @@ exports.ami = { "InstanceType": "t2.micro", "MinCount": 1, "MaxCount": 1 + }, + "golem": { + "ImageId": "ami-09d77dc5c373f8fd6", + "InstanceType": "t2.micro", + "MinCount": 1, + "MaxCount": 1 } } \ No newline at end of file From 72e150e7c939ee57dd3579294209c87141117173 Mon Sep 17 00:00:00 2001 From: Phyrex Tsai Date: Mon, 18 Nov 2019 15:21:12 +0800 Subject: [PATCH 3/3] 0.1.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75f1cbde..65b32e54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "kaizen-cli", - "version": "0.1.1", + "version": "0.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ad9c8926..af75b5d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kaizen-cli", - "version": "0.1.1", + "version": "0.1.2", "bin": { "kaizen": "kaizen" },