getting ready for OSS
- s/triton/tritonapi/ - s/Triton/TritonApi/ - s/CloudAPI/CloudApi/
This commit is contained in:
parent
17c7a84ace
commit
0fee17fda0
18
lib/cli.js
18
lib/cli.js
@ -20,7 +20,7 @@ var vasync = require('vasync');
|
||||
|
||||
var common = require('./common');
|
||||
var errors = require('./errors');
|
||||
var Triton = require('./triton');
|
||||
var TritonApi = require('./tritonapi');
|
||||
|
||||
|
||||
|
||||
@ -56,10 +56,10 @@ var OPTIONS = [
|
||||
|
||||
// XXX disable profile selection for now
|
||||
//{names: ['profile', 'p'], type: 'string', env: 'TRITON_PROFILE',
|
||||
// helpArg: 'NAME', help: 'Triton client profile to use.'}
|
||||
// helpArg: 'NAME', help: 'TritonApi client profile to use.'}
|
||||
|
||||
{
|
||||
group: 'CloudAPI Options'
|
||||
group: 'CloudApi Options'
|
||||
},
|
||||
// XXX SDC_USER support. I don't grok the node-smartdc/README.md discussion
|
||||
// of SDC_USER.
|
||||
@ -67,7 +67,7 @@ var OPTIONS = [
|
||||
names: ['account', 'a'],
|
||||
type: 'string',
|
||||
env: 'SDC_ACCOUNT',
|
||||
help: 'Triton account (login name)',
|
||||
help: 'TritonApi account (login name)',
|
||||
helpArg: 'ACCOUNT'
|
||||
},
|
||||
// XXX
|
||||
@ -96,7 +96,7 @@ var OPTIONS = [
|
||||
names: ['url', 'u'],
|
||||
type: 'string',
|
||||
env: 'SDC_URL',
|
||||
help: 'CloudAPI URL',
|
||||
help: 'CloudApi URL',
|
||||
helpArg: 'URL'
|
||||
},
|
||||
{
|
||||
@ -176,8 +176,8 @@ CLI.prototype.init = function (opts, args, callback) {
|
||||
this.showErrStack = true;
|
||||
}
|
||||
|
||||
this.__defineGetter__('triton', function () {
|
||||
if (self._triton === undefined) {
|
||||
this.__defineGetter__('tritonapi', function () {
|
||||
if (self._tritonapi === undefined) {
|
||||
var userConfigPath = require('./config').DEFAULT_USER_CONFIG_PATH;
|
||||
var dir = path.dirname(userConfigPath);
|
||||
var cacheDir = path.join(dir, 'cache');
|
||||
@ -212,7 +212,7 @@ CLI.prototype.init = function (opts, args, callback) {
|
||||
}
|
||||
log.trace({envProfile: envProfile}, 'envProfile');
|
||||
|
||||
self._triton = new Triton({
|
||||
self._tritonapi = new TritonApi({
|
||||
log: log,
|
||||
profileName: opts.profile,
|
||||
envProfile: envProfile,
|
||||
@ -220,7 +220,7 @@ CLI.prototype.init = function (opts, args, callback) {
|
||||
cacheDir: cacheDir
|
||||
});
|
||||
}
|
||||
return self._triton;
|
||||
return self._tritonapi;
|
||||
});
|
||||
|
||||
// Cmdln class handles `opts.help`.
|
||||
|
@ -88,7 +88,7 @@ BunyanNoopLogger.prototype.end = function () {};
|
||||
* - {Boolean} cacheSize (optional) number of cache entries (default 1k).
|
||||
* - {Boolean} cacheExpiry (optional) entry age in seconds (default 60).
|
||||
*/
|
||||
function CloudAPI(options) {
|
||||
function CloudApi(options) {
|
||||
assert.object(options, 'options');
|
||||
assert.string(options.url, 'options.url');
|
||||
assert.string(options.user || options.account, 'options.user');
|
||||
@ -120,7 +120,7 @@ function CloudAPI(options) {
|
||||
}
|
||||
|
||||
|
||||
CloudAPI.prototype._getAuthHeaders = function _getAuthHeaders(callback) {
|
||||
CloudApi.prototype._getAuthHeaders = function _getAuthHeaders(callback) {
|
||||
assert.func(callback, 'callback');
|
||||
var self = this;
|
||||
|
||||
@ -151,7 +151,7 @@ CloudAPI.prototype._getAuthHeaders = function _getAuthHeaders(callback) {
|
||||
* fields. If any of the field values are undefined or null, then they will
|
||||
* be excluded.
|
||||
*/
|
||||
CloudAPI.prototype._qs = function _qs(/* fields1, ...*/) {
|
||||
CloudApi.prototype._qs = function _qs(/* fields1, ...*/) {
|
||||
var fields = Array.prototype.slice.call(arguments);
|
||||
|
||||
var query = {};
|
||||
@ -173,14 +173,14 @@ CloudAPI.prototype._qs = function _qs(/* fields1, ...*/) {
|
||||
|
||||
|
||||
/**
|
||||
* Return an appropriate full URL *path* given an CloudAPI subpath.
|
||||
* Return an appropriate full URL *path* given an CloudApi subpath.
|
||||
* This handles prepending the API's base path, if any: e.g. if the configured
|
||||
* URL is "https://example.com/base/path".
|
||||
*
|
||||
* Optionally an object of query params can be passed in to include a query
|
||||
* string. This just calls `this._qs(...)`.
|
||||
*/
|
||||
CloudAPI.prototype._path = function _path(subpath /* , qparams, ... */) {
|
||||
CloudApi.prototype._path = function _path(subpath /* , qparams, ... */) {
|
||||
assert.string(subpath, 'subpath');
|
||||
assert.ok(subpath[0] === '/');
|
||||
|
||||
@ -200,7 +200,7 @@ CloudAPI.prototype._path = function _path(subpath /* , qparams, ... */) {
|
||||
* - {Object} data - data to be passed
|
||||
* @param {Function} callback passed via the restify client
|
||||
*/
|
||||
CloudAPI.prototype._request = function _request(options, callback) {
|
||||
CloudApi.prototype._request = function _request(options, callback) {
|
||||
var self = this;
|
||||
if (typeof (options) === 'string')
|
||||
options = {path: options};
|
||||
@ -239,7 +239,7 @@ CloudAPI.prototype._request = function _request(options, callback) {
|
||||
* A simple wrapper around making a GET request to an endpoint and
|
||||
* passing back the body returned
|
||||
*/
|
||||
CloudAPI.prototype._passThrough =
|
||||
CloudApi.prototype._passThrough =
|
||||
function _passThrough(endpoint, opts, cb) {
|
||||
if (typeof (opts) === 'function') {
|
||||
cb = opts;
|
||||
@ -264,7 +264,7 @@ function _passThrough(endpoint, opts, cb) {
|
||||
*
|
||||
* @param {Function} callback of the form `function (err, networks, response)`
|
||||
*/
|
||||
CloudAPI.prototype.listNetworks = function listNetworks(opts, cb) {
|
||||
CloudApi.prototype.listNetworks = function listNetworks(opts, cb) {
|
||||
var endpoint = format('/%s/networks', this.user);
|
||||
this._passThrough(endpoint, opts, cb);
|
||||
};
|
||||
@ -275,7 +275,7 @@ CloudAPI.prototype.listNetworks = function listNetworks(opts, cb) {
|
||||
* @param {String} - UUID
|
||||
* @param {Function} callback of the form `function (err, network, res)`
|
||||
*/
|
||||
CloudAPI.prototype.getNetwork = function getNetwork(id, cb) {
|
||||
CloudApi.prototype.getNetwork = function getNetwork(id, cb) {
|
||||
assert.uuid(id, 'id');
|
||||
assert.func(cb, 'cb');
|
||||
|
||||
@ -292,7 +292,7 @@ CloudAPI.prototype.getNetwork = function getNetwork(id, cb) {
|
||||
*
|
||||
* @param {Function} callback of the form `function (err, services, response)`
|
||||
*/
|
||||
CloudAPI.prototype.listServices = function listServices(opts, cb) {
|
||||
CloudApi.prototype.listServices = function listServices(opts, cb) {
|
||||
var endpoint = format('/%s/services', this.user);
|
||||
this._passThrough(endpoint, opts, cb);
|
||||
};
|
||||
@ -303,7 +303,7 @@ CloudAPI.prototype.listServices = function listServices(opts, cb) {
|
||||
* @param {Function} callback of the form
|
||||
* `function (err, datacenters, response)`
|
||||
*/
|
||||
CloudAPI.prototype.listDatacenters = function listDatacenters(opts, cb) {
|
||||
CloudApi.prototype.listDatacenters = function listDatacenters(opts, cb) {
|
||||
var endpoint = format('/%s/datacenters', this.user);
|
||||
this._passThrough(endpoint, opts, cb);
|
||||
};
|
||||
@ -315,7 +315,7 @@ CloudAPI.prototype.listDatacenters = function listDatacenters(opts, cb) {
|
||||
*
|
||||
* @param {Function} callback of the form `function (err, account, response)`
|
||||
*/
|
||||
CloudAPI.prototype.getAccount = function getAccount(opts, cb) {
|
||||
CloudApi.prototype.getAccount = function getAccount(opts, cb) {
|
||||
var endpoint = format('/%s', this.user);
|
||||
this._passThrough(endpoint, opts, cb);
|
||||
};
|
||||
@ -325,7 +325,7 @@ CloudAPI.prototype.getAccount = function getAccount(opts, cb) {
|
||||
*
|
||||
* @param {Function} callback of the form `function (err, keys, response)`
|
||||
*/
|
||||
CloudAPI.prototype.listKeys = function listKeys(opts, cb) {
|
||||
CloudApi.prototype.listKeys = function listKeys(opts, cb) {
|
||||
var endpoint = format('/%s/keys', this.user);
|
||||
this._passThrough(endpoint, opts, cb);
|
||||
};
|
||||
@ -339,7 +339,7 @@ CloudAPI.prototype.listKeys = function listKeys(opts, cb) {
|
||||
* XXX document this, see the api doc above :)
|
||||
* @param {Function} callback of the form `function (err, images, res)`
|
||||
*/
|
||||
CloudAPI.prototype.listImages = function listImages(opts, cb) {
|
||||
CloudApi.prototype.listImages = function listImages(opts, cb) {
|
||||
var endpoint = format('/%s/images', this.user);
|
||||
this._passThrough(endpoint, opts, cb);
|
||||
};
|
||||
@ -352,7 +352,7 @@ CloudAPI.prototype.listImages = function listImages(opts, cb) {
|
||||
* - id {UUID}
|
||||
* @param {Function} callback of the form `function (err, image, res)`
|
||||
*/
|
||||
CloudAPI.prototype.getImage = function getImage(options, callback) {
|
||||
CloudApi.prototype.getImage = function getImage(options, callback) {
|
||||
if (callback === undefined) {
|
||||
callback = options;
|
||||
options = {};
|
||||
@ -370,12 +370,12 @@ CloudAPI.prototype.getImage = function getImage(options, callback) {
|
||||
|
||||
// ---- packages
|
||||
|
||||
CloudAPI.prototype.listPackages = function listPackages(opts, cb) {
|
||||
CloudApi.prototype.listPackages = function listPackages(opts, cb) {
|
||||
var endpoint = format('/%s/packages', this.user);
|
||||
this._passThrough(endpoint, opts, cb);
|
||||
};
|
||||
|
||||
CloudAPI.prototype.getPackage = function getPackage(options, callback) {
|
||||
CloudApi.prototype.getPackage = function getPackage(options, callback) {
|
||||
if (callback === undefined) {
|
||||
callback = options;
|
||||
options = {};
|
||||
@ -402,7 +402,7 @@ CloudAPI.prototype.getPackage = function getPackage(options, callback) {
|
||||
* @param {String} uuid (required) The machine id.
|
||||
* @param {Function} callback of the form `function (err, machine, response)`
|
||||
*/
|
||||
CloudAPI.prototype.getMachine = function getMachine(id, cb) {
|
||||
CloudApi.prototype.getMachine = function getMachine(id, cb) {
|
||||
assert.uuid(id, 'id');
|
||||
assert.func(cb, 'cb');
|
||||
|
||||
@ -418,7 +418,7 @@ CloudAPI.prototype.getMachine = function getMachine(id, cb) {
|
||||
* @param {String} uuid (required) The machine id.
|
||||
* @param {Function} callback of the form `function (err, machine, response)`
|
||||
*/
|
||||
CloudAPI.prototype.deleteMachine = function deleteMachine(uuid, callback) {
|
||||
CloudApi.prototype.deleteMachine = function deleteMachine(uuid, callback) {
|
||||
var self = this;
|
||||
assert.string(uuid, 'uuid');
|
||||
assert.func(callback, 'callback');
|
||||
@ -438,7 +438,7 @@ CloudAPI.prototype.deleteMachine = function deleteMachine(uuid, callback) {
|
||||
* @param {String} uuid (required) The machine id.
|
||||
* @param {Function} callback of the form `function (err, machine, response)`
|
||||
*/
|
||||
CloudAPI.prototype.startMachine = function startMachine(uuid, callback) {
|
||||
CloudApi.prototype.startMachine = function startMachine(uuid, callback) {
|
||||
return this._doMachine('start', uuid, callback);
|
||||
};
|
||||
|
||||
@ -448,7 +448,7 @@ CloudAPI.prototype.startMachine = function startMachine(uuid, callback) {
|
||||
* @param {String} uuid (required) The machine id.
|
||||
* @param {Function} callback of the form `function (err, machine, response)`
|
||||
*/
|
||||
CloudAPI.prototype.stopMachine = function stopMachine(uuid, callback) {
|
||||
CloudApi.prototype.stopMachine = function stopMachine(uuid, callback) {
|
||||
return this._doMachine('stop', uuid, callback);
|
||||
};
|
||||
|
||||
@ -458,14 +458,14 @@ CloudAPI.prototype.stopMachine = function stopMachine(uuid, callback) {
|
||||
* @param {String} uuid (required) The machine id.
|
||||
* @param {Function} callback of the form `function (err, machine, response)`
|
||||
*/
|
||||
CloudAPI.prototype.rebootMachine = function rebootMachine(uuid, callback) {
|
||||
CloudApi.prototype.rebootMachine = function rebootMachine(uuid, callback) {
|
||||
return this._doMachine('reboot', uuid, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* internal function for start/stop/reboot
|
||||
*/
|
||||
CloudAPI.prototype._doMachine = function _doMachine(action, uuid, callback) {
|
||||
CloudApi.prototype._doMachine = function _doMachine(action, uuid, callback) {
|
||||
var self = this;
|
||||
assert.string(action, 'action');
|
||||
assert.string(uuid, 'uuid');
|
||||
@ -492,7 +492,7 @@ CloudAPI.prototype._doMachine = function _doMachine(action, uuid, callback) {
|
||||
* - {Number} interval (optional) - time in ms to poll
|
||||
* @param {Function} callback - called when state is reached or on error
|
||||
*/
|
||||
CloudAPI.prototype.waitForMachineStates =
|
||||
CloudApi.prototype.waitForMachineStates =
|
||||
function waitForMachineStates(opts, callback) {
|
||||
var self = this;
|
||||
assert.object(opts, 'opts');
|
||||
@ -527,7 +527,7 @@ CloudAPI.prototype.waitForMachineStates =
|
||||
* See document above
|
||||
* @return {LOMStream} a stream for each machine entry
|
||||
*/
|
||||
CloudAPI.prototype.createListMachinesStream =
|
||||
CloudApi.prototype.createListMachinesStream =
|
||||
function createListMachinesStream(options) {
|
||||
var self = this;
|
||||
options = options || {};
|
||||
@ -562,7 +562,7 @@ function createListMachinesStream(options) {
|
||||
* See document above
|
||||
* @param {Function} callback - called like `function (err, machines)`
|
||||
*/
|
||||
CloudAPI.prototype.listMachines = function listMachines(options, callback) {
|
||||
CloudApi.prototype.listMachines = function listMachines(options, callback) {
|
||||
if (typeof (options) === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
@ -584,7 +584,7 @@ CloudAPI.prototype.listMachines = function listMachines(options, callback) {
|
||||
};
|
||||
|
||||
|
||||
CloudAPI.prototype.createMachine = function createMachine(options, callback) {
|
||||
CloudApi.prototype.createMachine = function createMachine(options, callback) {
|
||||
assert.object(options, 'options');
|
||||
assert.optionalString(options.name, 'options.name');
|
||||
assert.uuid(options.image, 'options.image');
|
||||
@ -613,7 +613,7 @@ CloudAPI.prototype.createMachine = function createMachine(options, callback) {
|
||||
* - {String} id (required) The machine id.
|
||||
* @param {Function} callback of the form `function (err, audit, response)`
|
||||
*/
|
||||
CloudAPI.prototype.machineAudit = function machineAudit(options, callback) {
|
||||
CloudApi.prototype.machineAudit = function machineAudit(options, callback) {
|
||||
var self = this;
|
||||
assert.object(options, 'options');
|
||||
assert.string(options.id, 'options.id');
|
||||
@ -645,6 +645,6 @@ CloudAPI.prototype.machineAudit = function machineAudit(options, callback) {
|
||||
|
||||
module.exports = {
|
||||
createClient: function (options) {
|
||||
return new CloudAPI(options);
|
||||
return new CloudApi(options);
|
||||
}
|
||||
};
|
||||
|
@ -15,7 +15,7 @@ function do_account(subcmd, opts, args, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.triton.cloudapi.getAccount(function (err, account) {
|
||||
this.tritonapi.cloudapi.getAccount(function (err, account) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -27,7 +27,7 @@ function do_cloudapi(subcmd, opts, args, callback) {
|
||||
path: path
|
||||
};
|
||||
|
||||
this.triton.cloudapi._request(reqopts, function (err, req, res, body) {
|
||||
this.tritonapi.cloudapi._request(reqopts, function (err, req, res, body) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -22,13 +22,13 @@ function do_create_instance(subcmd, opts, args, callback) {
|
||||
return callback(new errors.UsageError('incorrect number of args'));
|
||||
}
|
||||
|
||||
var log = this.triton.log;
|
||||
var cloudapi = this.triton.cloudapi;
|
||||
var log = this.tritonapi.log;
|
||||
var cloudapi = this.tritonapi.cloudapi;
|
||||
|
||||
vasync.pipeline({arg: {}, funcs: [
|
||||
function getImg(ctx, next) {
|
||||
// XXX don't get the image object if it is a UUID, waste of time
|
||||
self.triton.getImage(args[0], function (err, img) {
|
||||
self.tritonapi.getImage(args[0], function (err, img) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -42,7 +42,7 @@ function do_create_instance(subcmd, opts, args, callback) {
|
||||
return next();
|
||||
}
|
||||
// XXX don't get the package object if it is a UUID, waste of time
|
||||
self.triton.getPackage(args[1], function (err, pkg) {
|
||||
self.tritonapi.getPackage(args[1], function (err, pkg) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@ -55,7 +55,7 @@ function do_create_instance(subcmd, opts, args, callback) {
|
||||
if (!opts.networks) {
|
||||
return next();
|
||||
}
|
||||
self.triton.getNetworks(opts.networks, function (err, nets) {
|
||||
self.tritonapi.getNetworks(opts.networks, function (err, nets) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ function do_datacenters(subcmd, opts, args, callback) {
|
||||
var columns = opts.o.split(',');
|
||||
var sort = opts.s.split(',');
|
||||
|
||||
this.triton.cloudapi.listDatacenters(function (err, datacenters) {
|
||||
this.tritonapi.cloudapi.listDatacenters(function (err, datacenters) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -18,7 +18,7 @@ function do_image(subcmd, opts, args, callback) {
|
||||
'incorrect number of args (%d)', args.length)));
|
||||
}
|
||||
|
||||
this.triton.getImage(args[0], function onRes(err, img) {
|
||||
this.tritonapi.getImage(args[0], function onRes(err, img) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ function do_images(subcmd, opts, args, callback) {
|
||||
listOpts.state = 'all';
|
||||
}
|
||||
|
||||
this.triton.listImages(listOpts, function onRes(err, imgs, res) {
|
||||
this.tritonapi.listImages(listOpts, function onRes(err, imgs, res) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ function do_info(subcmd, opts, args, callback) {
|
||||
var out = {};
|
||||
var i = 0;
|
||||
|
||||
this.triton.cloudapi.getAccount(cb.bind('account')); i++;
|
||||
this.triton.cloudapi.listMachines(cb.bind('machines')); i++;
|
||||
this.tritonapi.cloudapi.getAccount(cb.bind('account')); i++;
|
||||
this.tritonapi.cloudapi.listMachines(cb.bind('machines')); i++;
|
||||
|
||||
function cb(err, data) {
|
||||
if (err) {
|
||||
@ -64,7 +64,7 @@ function do_info(subcmd, opts, args, callback) {
|
||||
if (name)
|
||||
data.name = name;
|
||||
data.email = out.account.email;
|
||||
data.url = self.triton.cloudapi.url;
|
||||
data.url = self.tritonapi.cloudapi.url;
|
||||
data.totalDisk = disk;
|
||||
data.totalMemory = memory;
|
||||
|
||||
|
@ -13,7 +13,7 @@ function do_instance(subcmd, opts, args, cb) {
|
||||
return cb(new Error('invalid args: ' + args));
|
||||
}
|
||||
|
||||
this.triton.getInstance(args[0], function (err, inst) {
|
||||
this.tritonapi.getInstance(args[0], function (err, inst) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ function do_instances(subcmd, opts, args, callback) {
|
||||
|
||||
i++;
|
||||
var images;
|
||||
this.triton.listImages({useCache: true}, function (err, _images) {
|
||||
this.tritonapi.listImages({useCache: true}, function (err, _images) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -68,7 +68,7 @@ function do_instances(subcmd, opts, args, callback) {
|
||||
|
||||
i++;
|
||||
var machines;
|
||||
this.triton.cloudapi.listMachines(listOpts, function (err, _machines) {
|
||||
this.tritonapi.cloudapi.listMachines(listOpts, function (err, _machines) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -15,7 +15,7 @@ function do_keys(subcmd, opts, args, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.triton.cloudapi.listKeys(function (err, keys) {
|
||||
this.tritonapi.cloudapi.listKeys(function (err, keys) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -19,7 +19,7 @@ function do_network(subcmd, opts, args, cb) {
|
||||
'incorrect number of args (%d)', args.length)));
|
||||
}
|
||||
|
||||
this.triton.getNetwork(args[0], function (err, net) {
|
||||
this.tritonapi.getNetwork(args[0], function (err, net) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ function do_networks(subcmd, opts, args, callback) {
|
||||
|
||||
var sort = opts.s.split(',');
|
||||
|
||||
this.triton.cloudapi.listNetworks(function (err, networks) {
|
||||
this.tritonapi.cloudapi.listNetworks(function (err, networks) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -18,7 +18,7 @@ function do_package(subcmd, opts, args, callback) {
|
||||
'incorrect number of args (%d)', args.length)));
|
||||
}
|
||||
|
||||
this.triton.getPackage(args[0], function onRes(err, pkg) {
|
||||
this.tritonapi.getPackage(args[0], function onRes(err, pkg) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ function do_packages(subcmd, opts, args, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.triton.cloudapi.listPackages(listOpts, function (err, pkgs) {
|
||||
this.tritonapi.cloudapi.listPackages(listOpts, function (err, pkgs) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -26,7 +26,7 @@ function do_services(subcmd, opts, args, callback) {
|
||||
var columns = opts.o.split(',');
|
||||
var sort = opts.s.split(',');
|
||||
|
||||
this.triton.cloudapi.listServices(function (err, services) {
|
||||
this.tritonapi.cloudapi.listServices(function (err, services) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
|
@ -27,7 +27,7 @@ function do_ssh(subcmd, opts, args, callback) {
|
||||
id = id.substr(i + 1);
|
||||
}
|
||||
|
||||
this.triton.getInstance(id, function (err, inst) {
|
||||
this.tritonapi.getInstance(id, function (err, inst) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -41,7 +41,7 @@ function do_ssh(subcmd, opts, args, callback) {
|
||||
|
||||
args = ['-l', user].concat(ip).concat(args);
|
||||
|
||||
self.triton.log.info({args: args}, 'forking ssh');
|
||||
self.tritonapi.log.info({args: args}, 'forking ssh');
|
||||
var child = spawn('ssh', args, {stdio: 'inherit'});
|
||||
child.on('close', function (code) {
|
||||
process.exit(code);
|
||||
|
@ -86,7 +86,7 @@ function _do_instance(action, subcmd, opts, args, callback) {
|
||||
uuid = arg;
|
||||
go1();
|
||||
} else {
|
||||
self.triton.getInstance(arg, function (err, inst) {
|
||||
self.tritonapi.getInstance(arg, function (err, inst) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -99,7 +99,7 @@ function _do_instance(action, subcmd, opts, args, callback) {
|
||||
|
||||
function go1() {
|
||||
// called when "uuid" is set
|
||||
self.triton.cloudapi[command](uuid, function (err, body, res) {
|
||||
self.tritonapi.cloudapi[command](uuid, function (err, body, res) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -116,7 +116,7 @@ function _do_instance(action, subcmd, opts, args, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.triton.cloudapi.waitForMachineStates({
|
||||
self.tritonapi.cloudapi.waitForMachineStates({
|
||||
id: uuid,
|
||||
states: [state]
|
||||
}, function (err2, inst2, res2) {
|
||||
|
@ -33,7 +33,7 @@ function do_wait_instance(subcmd, opts, args, cb) {
|
||||
vasync.forEachParallel({
|
||||
inputs: ids,
|
||||
func: function getInst(id, nextInst) {
|
||||
self.triton.getInstance(id, function (err, inst) {
|
||||
self.tritonapi.getInstance(id, function (err, inst) {
|
||||
if (err) {
|
||||
return nextInst(err);
|
||||
}
|
||||
@ -75,7 +75,7 @@ function do_wait_instance(subcmd, opts, args, cb) {
|
||||
vasync.forEachParallel({
|
||||
inputs: idsToWaitFor,
|
||||
func: function waitForInst(id, nextInst) {
|
||||
self.triton.cloudapi.waitForMachineStates({
|
||||
self.tritonapi.cloudapi.waitForMachineStates({
|
||||
id: id,
|
||||
states: states
|
||||
}, function (err, inst, res) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
|
||||
*
|
||||
* Core Triton client driver class.
|
||||
* Core TritonApi client driver class.
|
||||
*/
|
||||
|
||||
var p = console.log;
|
||||
@ -27,10 +27,10 @@ var loadConfigSync = require('./config').loadConfigSync;
|
||||
|
||||
|
||||
|
||||
//---- Triton class
|
||||
//---- TritonApi class
|
||||
|
||||
/**
|
||||
* Create a Triton client.
|
||||
* Create a TritonApi client.
|
||||
*
|
||||
* @param options {Object}
|
||||
* - log {Bunyan Logger}
|
||||
@ -40,7 +40,7 @@ var loadConfigSync = require('./config').loadConfigSync;
|
||||
* fields will be filled in from standard SDC_* envvars.
|
||||
* ...
|
||||
*/
|
||||
function Triton(options) {
|
||||
function TritonApi(options) {
|
||||
assert.object(options, 'options');
|
||||
assert.object(options.log, 'options.log');
|
||||
assert.optionalString(options.profileName, 'options.profileName');
|
||||
@ -83,7 +83,7 @@ function Triton(options) {
|
||||
|
||||
|
||||
|
||||
Triton.prototype.getProfile = function getProfile(name) {
|
||||
TritonApi.prototype.getProfile = function getProfile(name) {
|
||||
for (var i = 0; i < this.profiles.length; i++) {
|
||||
if (this.profiles[i].name === name) {
|
||||
return this.profiles[i];
|
||||
@ -92,7 +92,8 @@ Triton.prototype.getProfile = function getProfile(name) {
|
||||
};
|
||||
|
||||
|
||||
Triton.prototype._cloudapiFromProfile = function _cloudapiFromProfile(profile) {
|
||||
TritonApi.prototype._cloudapiFromProfile =
|
||||
function _cloudapiFromProfile(profile) {
|
||||
assert.object(profile, 'profile');
|
||||
assert.string(profile.account, 'profile.account');
|
||||
assert.string(profile.keyId, 'profile.keyId');
|
||||
@ -129,7 +130,7 @@ Triton.prototype._cloudapiFromProfile = function _cloudapiFromProfile(profile) {
|
||||
/**
|
||||
* cloudapi listImages wrapper with optional caching
|
||||
*/
|
||||
Triton.prototype.listImages = function listImages(opts, cb) {
|
||||
TritonApi.prototype.listImages = function listImages(opts, cb) {
|
||||
var self = this;
|
||||
if (cb === undefined) {
|
||||
cb = opts;
|
||||
@ -208,7 +209,7 @@ Triton.prototype.listImages = function listImages(opts, cb) {
|
||||
* If there is more than one image with that name, then the latest
|
||||
* (by published_at) is returned.
|
||||
*/
|
||||
Triton.prototype.getImage = function getImage(name, cb) {
|
||||
TritonApi.prototype.getImage = function getImage(name, cb) {
|
||||
assert.string(name, 'name');
|
||||
assert.func(cb, 'cb');
|
||||
|
||||
@ -264,7 +265,7 @@ Triton.prototype.getImage = function getImage(name, cb) {
|
||||
*
|
||||
* If there is more than one package with that name, then this errors out.
|
||||
*/
|
||||
Triton.prototype.getPackage = function getPackage(name, cb) {
|
||||
TritonApi.prototype.getPackage = function getPackage(name, cb) {
|
||||
assert.string(name, 'name');
|
||||
assert.func(cb, 'cb');
|
||||
|
||||
@ -321,7 +322,7 @@ Triton.prototype.getPackage = function getPackage(name, cb) {
|
||||
*
|
||||
* If the name is ambiguous, then this errors out.
|
||||
*/
|
||||
Triton.prototype.getNetwork = function getNetwork(name, cb) {
|
||||
TritonApi.prototype.getNetwork = function getNetwork(name, cb) {
|
||||
assert.string(name, 'name');
|
||||
assert.func(cb, 'cb');
|
||||
|
||||
@ -377,7 +378,7 @@ Triton.prototype.getNetwork = function getNetwork(name, cb) {
|
||||
* @param {String} name
|
||||
* @param {Function} callback `function (err, inst)`
|
||||
*/
|
||||
Triton.prototype.getInstance = function getInstance(name, cb) {
|
||||
TritonApi.prototype.getInstance = function getInstance(name, cb) {
|
||||
var self = this;
|
||||
assert.string(name, 'name');
|
||||
assert.func(cb, 'cb');
|
||||
@ -473,4 +474,4 @@ Triton.prototype.getInstance = function getInstance(name, cb) {
|
||||
|
||||
//---- exports
|
||||
|
||||
module.exports = Triton;
|
||||
module.exports = TritonApi;
|
Reference in New Issue
Block a user