joyent/node-triton#68 Support specifying networks at instance create time
This commit is contained in:
parent
04905ccc22
commit
adb4c851b9
@ -1,8 +1,10 @@
|
|||||||
# node-triton changelog
|
# node-triton changelog
|
||||||
|
|
||||||
## 3.5.1 (not yet released)
|
## 3.6.0 (not yet released)
|
||||||
|
|
||||||
(nothing yet)
|
- #67 Add `triton create --network,-N NETWORK ...` option for specifying
|
||||||
|
networks for instance creation. "NETWORK" is a network id, name, or
|
||||||
|
short id; or a comma-separated array of networks.
|
||||||
|
|
||||||
|
|
||||||
## 3.5.0
|
## 3.5.0
|
||||||
|
27
lib/cli.js
27
lib/cli.js
@ -152,6 +152,33 @@ var OPTIONS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ---- other support stuff
|
||||||
|
|
||||||
|
function parseCommaSepStringNoEmpties(option, optstr, arg) {
|
||||||
|
// JSSTYLED
|
||||||
|
return arg.trim().split(/\s*,\s*/g)
|
||||||
|
.filter(function (part) { return part; });
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdln.dashdash.addOptionType({
|
||||||
|
name: 'commaSepString',
|
||||||
|
takesArg: true,
|
||||||
|
helpArg: 'STRING',
|
||||||
|
parseArg: parseCommaSepStringNoEmpties
|
||||||
|
});
|
||||||
|
|
||||||
|
cmdln.dashdash.addOptionType({
|
||||||
|
name: 'arrayOfCommaSepString',
|
||||||
|
takesArg: true,
|
||||||
|
helpArg: 'STRING',
|
||||||
|
parseArg: parseCommaSepStringNoEmpties,
|
||||||
|
array: true,
|
||||||
|
arrayFlatten: true
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---- CLI class
|
//---- CLI class
|
||||||
|
|
||||||
function CLI() {
|
function CLI() {
|
||||||
|
@ -369,16 +369,24 @@ function do_create_instance(subcmd, opts, args, cb) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
function getNets(ctx, next) {
|
function getNets(ctx, next) {
|
||||||
if (!opts.networks) {
|
if (!opts.network) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
self.tritonapi.getNetworks(opts.networks, function (err, nets) {
|
// TODO: want an error or warning on no networks?
|
||||||
|
ctx.nets = [];
|
||||||
|
vasync.forEachPipeline({
|
||||||
|
inputs: opts.network,
|
||||||
|
func: function getOneNetwork(name, nextNet) {
|
||||||
|
self.tritonapi.getNetwork(name, function (err, net) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
nextNet(err);
|
||||||
|
} else {
|
||||||
|
ctx.nets.push(net);
|
||||||
|
nextNet();
|
||||||
}
|
}
|
||||||
ctx.nets = nets;
|
|
||||||
next();
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}, next);
|
||||||
},
|
},
|
||||||
function createInst(ctx, next) {
|
function createInst(ctx, next) {
|
||||||
var createOpts = {
|
var createOpts = {
|
||||||
@ -548,12 +556,14 @@ do_create_instance.options = [
|
|||||||
'(if first char is "{"), or a "@FILE" to have tags be ' +
|
'(if first char is "{"), or a "@FILE" to have tags be ' +
|
||||||
'loaded from FILE. This option can be used multiple times.'
|
'loaded from FILE. This option can be used multiple times.'
|
||||||
},
|
},
|
||||||
// XXX arrayOfCommaSepString dashdash type
|
{
|
||||||
//{
|
names: ['network', 'N'],
|
||||||
// names: ['networks', 'nets'],
|
type: 'arrayOfCommaSepString',
|
||||||
// type: 'arrayOfCommaSepString',
|
helpArg: 'NETWORK',
|
||||||
// help: 'One or more (comma-separated) networks IDs.'
|
help: 'One or more comma-separated networks (ID, name or short id). ' +
|
||||||
//},
|
'This option can be used multiple times.'
|
||||||
|
},
|
||||||
|
|
||||||
// XXX locality: near, far
|
// XXX locality: near, far
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "triton",
|
"name": "triton",
|
||||||
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
|
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
|
||||||
"version": "3.5.1",
|
"version": "3.6.0",
|
||||||
"author": "Joyent (joyent.com)",
|
"author": "Joyent (joyent.com)",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"assert-plus": "0.2.0",
|
"assert-plus": "0.2.0",
|
||||||
"backoff": "2.4.1",
|
"backoff": "2.4.1",
|
||||||
"bigspinner": "3.1.0",
|
"bigspinner": "3.1.0",
|
||||||
"bunyan": "1.5.1",
|
"bunyan": "1.5.1",
|
||||||
"cmdln": "3.3.0",
|
"cmdln": "3.4.2",
|
||||||
"dashdash": "1.10.0",
|
|
||||||
"extsprintf": "1.0.2",
|
"extsprintf": "1.0.2",
|
||||||
"lomstream": "1.1.0",
|
"lomstream": "1.1.0",
|
||||||
"mkdirp": "0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var assert = require('assert-plus');
|
var assert = require('assert-plus');
|
||||||
var dashdash = require('dashdash');
|
var cmdln = require('cmdln');
|
||||||
var format = require('util').format;
|
var format = require('util').format;
|
||||||
var test = require('tape');
|
var test = require('tape');
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ test('metadataFromOpts', function (tt) {
|
|||||||
tt.test(testName, function (t) {
|
tt.test(testName, function (t) {
|
||||||
debug('--', num);
|
debug('--', num);
|
||||||
debug('c: %j', c);
|
debug('c: %j', c);
|
||||||
var parser = new dashdash.Parser({options: OPTIONS});
|
var parser = new cmdln.dashdash.Parser({options: OPTIONS});
|
||||||
var opts = parser.parse({argv: c.argv});
|
var opts = parser.parse({argv: c.argv});
|
||||||
debug('opts: %j', opts);
|
debug('opts: %j', opts);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var assert = require('assert-plus');
|
var assert = require('assert-plus');
|
||||||
var dashdash = require('dashdash');
|
var cmdln = require('cmdln');
|
||||||
var format = require('util').format;
|
var format = require('util').format;
|
||||||
var test = require('tape');
|
var test = require('tape');
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ test('tagsFromOpts', function (tt) {
|
|||||||
tt.test(testName, function (t) {
|
tt.test(testName, function (t) {
|
||||||
debug('--', num);
|
debug('--', num);
|
||||||
debug('c: %j', c);
|
debug('c: %j', c);
|
||||||
var parser = new dashdash.Parser({options: OPTIONS});
|
var parser = new cmdln.dashdash.Parser({options: OPTIONS});
|
||||||
var opts = parser.parse({argv: c.argv});
|
var opts = parser.parse({argv: c.argv});
|
||||||
debug('opts: %j', opts);
|
debug('opts: %j', opts);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user