diff --git a/lib/cloudapi2.js b/lib/cloudapi2.js index 702ee4d..78257a8 100644 --- a/lib/cloudapi2.js +++ b/lib/cloudapi2.js @@ -31,7 +31,6 @@ var LOMStream = require('lomstream').LOMStream; var os = require('os'); var querystring = require('querystring'); var restifyClients = require('restify-clients'); -var sprintf = require('util').format; var vasync = require('vasync'); var errors = require('./errors'); @@ -105,7 +104,7 @@ function CloudAPI(options) { options.version = '*'; } if (!options.userAgent) { - options.userAgent = sprintf('triton/%s (%s-%s; node/%s)', + options.userAgent = format('triton/%s (%s-%s; node/%s)', VERSION, OS_ARCH, OS_PLATFORM, process.versions.node); } @@ -140,7 +139,7 @@ CloudAPI.prototype._getAuthHeaders = function _getAuthHeaders(callback) { return; } - headers.authorization = sprintf( + headers.authorization = format( 'Signature keyId="/%s/keys/%s",algorithm="%s",signature="%s"', self.user, sig.keyId, sig.algorithm, sig.signature); callback(null, headers); @@ -294,7 +293,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) { - var endpoint = sprintf('/%s/services', this.user); + var endpoint = format('/%s/services', this.user); this._passThrough(endpoint, opts, cb); }; @@ -305,7 +304,7 @@ CloudAPI.prototype.listServices = function listServices(opts, cb) { * `function (err, datacenters, response)` */ CloudAPI.prototype.listDatacenters = function listDatacenters(opts, cb) { - var endpoint = sprintf('/%s/datacenters', this.user); + var endpoint = format('/%s/datacenters', this.user); this._passThrough(endpoint, opts, cb); }; @@ -317,7 +316,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) { - var endpoint = sprintf('/%s', this.user); + var endpoint = format('/%s', this.user); this._passThrough(endpoint, opts, cb); }; @@ -327,7 +326,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) { - var endpoint = sprintf('/%s/keys', this.user); + var endpoint = format('/%s/keys', this.user); this._passThrough(endpoint, opts, cb); }; @@ -341,7 +340,7 @@ CloudAPI.prototype.listKeys = function listKeys(opts, cb) { * @param {Function} callback of the form `function (err, images, res)` */ CloudAPI.prototype.listImages = function listImages(opts, cb) { - var endpoint = sprintf('/%s/images', this.user); + var endpoint = format('/%s/images', this.user); this._passThrough(endpoint, opts, cb); }; @@ -372,7 +371,7 @@ CloudAPI.prototype.getImage = function getImage(options, callback) { // ---- packages CloudAPI.prototype.listPackages = function listPackages(opts, cb) { - var endpoint = sprintf('/%s/packages', this.user); + var endpoint = format('/%s/packages', this.user); this._passThrough(endpoint, opts, cb); }; @@ -407,7 +406,7 @@ CloudAPI.prototype.getMachine = function getMachine(id, cb) { assert.uuid(id, 'id'); assert.func(cb, 'cb'); - var endpoint = sprintf('/%s/machines/%s', this.user, id); + var endpoint = format('/%s/machines/%s', this.user, id); this._request(endpoint, function (err, req, res, body) { cb(err, body, res); }); @@ -425,7 +424,7 @@ CloudAPI.prototype.deleteMachine = function deleteMachine(uuid, callback) { assert.func(callback, 'callback'); var opts = { - path: sprintf('/%s/machines/%s', self.user, uuid), + path: format('/%s/machines/%s', self.user, uuid), method: 'DELETE' }; this._request(opts, function (err, req, res, body) { @@ -473,7 +472,7 @@ CloudAPI.prototype._doMachine = function _doMachine(action, uuid, callback) { assert.func(callback, 'callback'); var opts = { - path: sprintf('/%s/machines/%s', self.user, uuid), + path: format('/%s/machines/%s', self.user, uuid), method: 'POST', data: { action: action @@ -620,7 +619,7 @@ CloudAPI.prototype.machineAudit = function machineAudit(options, callback) { assert.string(options.id, 'options.id'); assert.func(callback, 'callback'); - var path = sprintf('/%s/machines/%s/audit', self.user, options.id); + var path = format('/%s/machines/%s/audit', self.user, options.id); // XXX This `client.get` block is duplicated. Add a convenience func for it: self._getAuthHeaders(function (hErr, headers) { if (hErr) {