-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from PhyrexTsai/master
Add instances for kaizen
- Loading branch information
Showing
30 changed files
with
758 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ kaizen upload btfs ./build | |
- [`kaizen install`](commands/install.md) - Install a KAIZEN project from GitHub | ||
- [`kaizen upload`](commands/upload.md) - Upload a KAIZEN project | ||
- [`kaizen plugins`](commands/plugins.md) - Plugin management for KAIZEN | ||
- [`kaizen instances`](commands/instances.md) - Instances management for KAIZEN | ||
- [`kaizen contracts`](commands/contracts.md) - Contract management for KAIZEN | ||
- [`kaizen blockchains`](commands/blockchains.md) - Blockchain management for KAIZEN | ||
|
||
|
@@ -107,7 +108,7 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for how to help out. | |
*Quick Start*: Check out [help wanted](https://github.com/PortalNetwork/kaizen-cli/labels/help%20wanted) or [good first issue](https://github.com/PortalNetwork/kaizen-cli/labels/good%20first%20issue) labels to find issues we want to move forward on with your help. | ||
|
||
## <a name="contact"></a>📧 Contact | ||
For any questions, please contact [email protected] or join telegram: [http://bit.ly/2XjhQV2](http://bit.ly/2XjhQV2) | ||
For any questions, please contact **[email protected]** or join telegram: [http://bit.ly/2XjhQV2](http://bit.ly/2XjhQV2) | ||
|
||
## <a name="licence"></a>🗒 Licence | ||
See [LICENSE](./LICENSE) for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ kaizen upload btfs ./build | |
- [`kaizen install`](commands/install.md) - Install a KAIZEN project from GitHub | ||
- [`kaizen upload`](commands/upload.md) - Upload a KAIZEN project | ||
- [`kaizen plugins`](commands/plugins.md) - Plugin management for KAIZEN | ||
- [`kaizen instances`](commands/instances.md) - Instances management for KAIZEN | ||
- [`kaizen contracts`](commands/contracts.md) - Contract management for KAIZEN | ||
- [`kaizen blockchains`](commands/blockchains.md) - Blockchain management for KAIZEN | ||
|
||
|
@@ -107,7 +108,7 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for how to help out. | |
*Quick Start*: Check out [help wanted](https://github.com/PortalNetwork/kaizen-cli/labels/help%20wanted) or [good first issue](https://github.com/PortalNetwork/kaizen-cli/labels/good%20first%20issue) labels to find issues we want to move forward on with your help. | ||
|
||
## <a name="contact"></a>📧 Contact | ||
For any questions, please contact [email protected] or join telegram: [http://bit.ly/2XjhQV2](http://bit.ly/2XjhQV2) | ||
For any questions, please contact **[email protected]** or join telegram: [http://bit.ly/2XjhQV2](http://bit.ly/2XjhQV2) | ||
|
||
## <a name="licence"></a>🗒 라이센스 | ||
[LICENSE](./LICENSE) 참조하기 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ kaizen upload btfs ./build | |
- [`kaizen install`](commands/install.md) - 從 GitHub 安裝已經存在的 KAIZEN | ||
- [`kaizen upload`](commands/upload.md) - 上傳 KAIZEN 專案 | ||
- [`kaizen plugins`](commands/plugins.md) - KAIZEN 插件管理功能 | ||
- [`kaizen instances`](commands/instances.md) - KAIZEN 運行實例管理功能 | ||
- [`kaizen contracts`](commands/contracts.md) - KAIZEN 智能合約管理功能 | ||
- [`kaizen blockchains`](commands/blockchains.md) - KAIZEN 區塊鏈管理功能 | ||
|
||
|
@@ -107,7 +108,7 @@ KAIZEN Faucet 支援下列區塊鏈測試網路的代幣 | |
*快速開始:您可以透過 [help wanted](https://github.com/PortalNetwork/kaizen-cli/labels/help%20wanted) 或者 [good first issue](https://github.com/PortalNetwork/kaizen-cli/labels/good%20first%20issue) 標籤找到可以參與貢獻的任務。 | ||
|
||
## <a name="contact"></a>📧 聯絡 | ||
如果您有任何問題請聯繫 [email protected] 或者加入我們的 Telegram: [http://bit.ly/2XjhQV2](http://bit.ly/2XjhQV2) | ||
如果您有任何問題請聯繫 **[email protected]** 或者加入我們的 Telegram: [http://bit.ly/2XjhQV2](http://bit.ly/2XjhQV2) | ||
|
||
## <a name="licence"></a>🗒 許可證 | ||
詳細內容請參考 [LICENSE](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"use strict"; | ||
|
||
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 path = require('path'); | ||
|
||
var fsx = require('fs-extra'); | ||
|
||
require('colors'); | ||
|
||
function builder(yargs) {} | ||
|
||
function handler(_x) { | ||
return _handler.apply(this, arguments); | ||
} | ||
|
||
function _handler() { | ||
_handler = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(argv) { | ||
var kaizenrc, i, instance; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
Log.NormalLog('AWS Instance list:'.underline.yellow); | ||
kaizenrc = fsx.readJsonSync(path.resolve(__dirname, '../../../../.kaizenrc')); | ||
|
||
if (kaizenrc['instances']) { | ||
for (i = 0; i < kaizenrc['instances'].length; i++) { | ||
instance = kaizenrc['instances'][i]; | ||
Log.NormalLog('Template: '.yellow + instance.template + ', InstanceId: '.yellow + instance.instanceId); // TODO load instance status | ||
} | ||
} else { | ||
Log.NormalLog("There's no instance running on AWS"); | ||
} | ||
|
||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
return _handler.apply(this, arguments); | ||
} | ||
|
||
module.exports = function (yargs) { | ||
var command = 'list'; | ||
var commandDescription = 'List instances of instance name'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
"use strict"; | ||
|
||
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 Spinner = require('../../../lib/Spinner'); | ||
|
||
var nymLoopixMixnodeHandler = require('./nym-loopix-mixnode.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'], ''); | ||
} | ||
|
||
function handler(_x) { | ||
return _handler.apply(this, arguments); | ||
} | ||
|
||
function _handler() { | ||
_handler = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(argv) { | ||
var instance; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.prev = 0; | ||
instance = argv.instance; | ||
|
||
if (instance) { | ||
_context.next = 5; | ||
break; | ||
} | ||
|
||
Log.NormalLog('Missing instance name.\nPlease using \'kaizen instances run [instance]\''); | ||
return _context.abrupt("return"); | ||
|
||
case 5: | ||
_context.t0 = instance; | ||
_context.next = _context.t0 === 'nym-loopix-mixnode' ? 8 : 15; | ||
break; | ||
|
||
case 8: | ||
Log.NormalLog("Starting ".concat(instance, " instance, please wait a second...")); | ||
Spinner.start(); | ||
_context.next = 12; | ||
return nymLoopixMixnodeHandler(); | ||
|
||
case 12: | ||
Spinner.stop(); | ||
Log.SuccessLog("Start instance ".concat(instance, " Successfully")); | ||
return _context.abrupt("break", 16); | ||
|
||
case 15: | ||
Log.NormalLog('Instance not support yet'); | ||
|
||
case 16: | ||
_context.next = 23; | ||
break; | ||
|
||
case 18: | ||
_context.prev = 18; | ||
_context.t1 = _context["catch"](0); | ||
Spinner.stop(); | ||
Log.ErrorLog('something went wrong!'); | ||
console.error(_context.t1); | ||
|
||
case 23: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this, [[0, 18]]); | ||
})); | ||
return _handler.apply(this, arguments); | ||
} | ||
|
||
module.exports = function (yargs) { | ||
var command = 'run [instance]'; | ||
var commandDescription = 'Run an instance on AWS'; | ||
yargs.command(command, commandDescription, builder, handler); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
"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__*/ | ||
_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; | ||
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(); | ||
} | ||
} | ||
}, _callee, this, [[0, 26]]); | ||
})); |
Oops, something went wrong.