From 108c47cb6a7247cc79826ac12c48e6fd5aa173a4 Mon Sep 17 00:00:00 2001 From: jadchami Date: Tue, 18 Feb 2014 14:40:14 -0500 Subject: [PATCH 001/460] Update images.js Hi, there is a bug in Openstack where you cannot set the metadata of os_type as it is overwritten to None when first creating the image. This causes a problem with the timezone not being set correctly on windows machines. To solve this, I wrote a function, updateImageMeta, that allows a client to update the metadata of an image , after calling createImage function, and wanted to share it so maybe it will be in future versions of pkgcloud and help other people who might need this functionality as well. --- .../openstack/compute/client/images.js | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/compute/client/images.js b/lib/pkgcloud/openstack/compute/client/images.js index 74ee4b2c9..e89dc5ef4 100644 --- a/lib/pkgcloud/openstack/compute/client/images.js +++ b/lib/pkgcloud/openstack/compute/client/images.js @@ -137,4 +137,33 @@ exports.destroyImage = function destroyImage(image, callback) { ? callback(err) : callback(null, { ok: imageId }); }); -}; \ No newline at end of file +}; + +/** + * client.updateImageMeta + * + * @description updates image metadata + * + * @param {String|object} image the image or imageId to get + * @param meta {JSON object} + * @param callback + * @returns {*} + */ +exports.updateImageMeta = function updateImageMeta(image,meta, callback) { + var imageId = image instanceof compute.Image ? image.id : image; + + var specs= { + "metadata" : meta + }; + + return this._request({ + path: urlJoin(_urlPrefix, imageId, 'metadata' ), + method: 'POST', + body: specs + }, + function (err) { + return err + ? callback(err) + : callback(null, { ok: imageId }); + }); +}; From cd8c5214596e322d121bf1a3dfd6da2cf2415745 Mon Sep 17 00:00:00 2001 From: jadchami Date: Mon, 24 Feb 2014 15:11:59 -0500 Subject: [PATCH 002/460] Create meta-test.js --- test/common/compute/meta-test.js | 195 +++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 test/common/compute/meta-test.js diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js new file mode 100644 index 000000000..f39a6f85e --- /dev/null +++ b/test/common/compute/meta-test.js @@ -0,0 +1,195 @@ +/* +* meta-test.js: Openstack updateImageMeta() function test . +* +* (C) 2012 Nodejitsu Inc. +* +*/ + +var fs = require('fs'), + path = require('path'), + qs = require('qs'), + should = require('should'), + utile = require('utile'), + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + async = require('async'), + _ = require('underscore'), + Image = require('../../../lib/pkgcloud/core/compute/image').Image, + mock = !!process.env.MOCK; + +providers=["openstack"]; + + +providers.forEach(function (provider) { + describe('pkgcloud/common/compute/server [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'compute'), + context = {}, + authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + hock.createHock({ + port: 12345, + throwOnUnmatched: false + }, function (err, hockClient) { + server = hockClient; + next(); + }); + }, + function (next) { + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + next(); + }); + } + ], done) + }); + + it('the getImages() function should return a list of images', function(done) { + + if (mock) { + setupImagesMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.getImages(function (err, images) { + should.not.exist(err); + should.exist(images); + + context.images = images + + images.forEach(function(img) { + img.should.be.instanceOf(Image); + }); + + + authServer && authServer.done(); + server && server.done(); + + done(); + }); + }); + + + it('the updateImageMeta() method should update the image metadate', function (done) { + if (mock) { + setupMetaMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.updateImageMeta(context.images[0].id, {"os_type" : "windows"}, function (err, img) { + should.not.exist(err); + should.exist(img); + + context.currentServer = server; + + authServer && authServer.done(); + server && server.done(); + done(); + + }); + }); + + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done) + }); + + }); +}); + +function setupMetaMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata',{"metadata":{"os_type" : "windows"}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/metaResponse.json'); + } +} + + +function setupImagesMock(client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json') + } + +} + + +/** + * serverStatusReply() + * fills in the nock xml reply from the server with server name and status + * @param name - name of the server + * @param status - status to be returned in reply + * status should be: + * ReadyRole - server is RUNNING + * VMStopped - server is still PROVISIONING + * Provisioning - server is still PROVISIONING + * see lib/pkgcloud/azure/compute/server.js for more status values + * + * @return {String} - the xml reply containing the server name and status + */ +var serverStatusReply = function (name, status) { + + var template = helpers.loadFixture('azure/server-status-template.xml'), + params = {NAME: name, STATUS: status}; + + var result = _.template(template, params); + return result; +}; + +var filterPath = function (path) { + var name = PATH.basename(path); + if (path.search('embed-detail=true') !== -1) { + return '/getStatus?name=' + name; + } + + return path; +}; From 7658007a6c18c429d4aca688a8e71fb4de991bbe Mon Sep 17 00:00:00 2001 From: jadchami Date: Mon, 24 Feb 2014 15:12:32 -0500 Subject: [PATCH 003/460] Create metaResponse.json --- test/fixtures/openstack/metaResponse.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/fixtures/openstack/metaResponse.json diff --git a/test/fixtures/openstack/metaResponse.json b/test/fixtures/openstack/metaResponse.json new file mode 100644 index 000000000..fe50aee57 --- /dev/null +++ b/test/fixtures/openstack/metaResponse.json @@ -0,0 +1,5 @@ +{ + "metadata" : { + "os_type" : "windows" + } +} From 121f7b721882d3c23df1ab74630714dc401858cb Mon Sep 17 00:00:00 2001 From: jadchami Date: Tue, 4 Mar 2014 14:29:13 -0500 Subject: [PATCH 004/460] Update meta-test.js --- test/common/compute/meta-test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index f39a6f85e..6f677a258 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -81,17 +81,21 @@ providers.forEach(function (provider) { }); - it('the updateImageMeta() method should update the image metadate', function (done) { + it('the updateImageMeta() method should update the image metadata', function (done) { if (mock) { setupMetaMock(client, provider, { authServer: authServer, server: server }); } - - client.updateImageMeta(context.images[0].id, {"os_type" : "windows"}, function (err, img) { + + var testMetadata = {"os_type" : "windows"}; + + client.updateImageMeta(context.images[0].id, testMetadata, function (err, reply) { should.not.exist(err); - should.exist(img); + should.exist(reply); + should.exist(reply.metadata.os_type); + reply.metadata.os_type.should.equal('windows'); context.currentServer = server; From 24f6d1d9937b61f84206671c9dfbaebd58af1334 Mon Sep 17 00:00:00 2001 From: jadchami Date: Tue, 4 Mar 2014 14:30:04 -0500 Subject: [PATCH 005/460] Update images.js --- lib/pkgcloud/openstack/compute/client/images.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/compute/client/images.js b/lib/pkgcloud/openstack/compute/client/images.js index e89dc5ef4..572e17fb1 100644 --- a/lib/pkgcloud/openstack/compute/client/images.js +++ b/lib/pkgcloud/openstack/compute/client/images.js @@ -161,9 +161,9 @@ exports.updateImageMeta = function updateImageMeta(image,meta, callback) { method: 'POST', body: specs }, - function (err) { + function (err, resp) { return err ? callback(err) - : callback(null, { ok: imageId }); + : callback(null, resp); }); }; From e594e02b2c425a6ace5cdd3d99036464905003aa Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 11:10:39 -0700 Subject: [PATCH 006/460] Adding tests for HP's provider. --- lib/pkgcloud.js | 3 +- lib/pkgcloud/hp/index.js | 9 ++ test/common/compute/base-test.js | 34 ++++++++ test/configs/mock/hp.json | 6 ++ test/configs/providers.json | 2 +- test/fixtures/hp/creatingServer.json | 16 ++++ test/fixtures/hp/flavor1.json | 21 +++++ test/fixtures/hp/flavors.json | 23 +++++ test/fixtures/hp/image1.json | 26 ++++++ test/fixtures/hp/images.json | 28 ++++++ test/fixtures/hp/initialToken-admin.json | 16 ++++ test/fixtures/hp/initialToken.json | 16 ++++ test/fixtures/hp/no-activeTenants.json | 11 +++ test/fixtures/hp/no-tenants.json | 4 + test/fixtures/hp/realToken-admin.json | 72 ++++++++++++++++ .../hp/realToken-multiRegionVolume.json | 78 +++++++++++++++++ test/fixtures/hp/realToken-noRegion.json | 71 ++++++++++++++++ test/fixtures/hp/realToken.json | 85 +++++++++++++++++++ test/fixtures/hp/serverCreated.json | 57 +++++++++++++ test/fixtures/hp/serverCreated2.json | 63 ++++++++++++++ test/fixtures/hp/serverList.json | 48 +++++++++++ test/fixtures/hp/tenantId-admin.json | 11 +++ test/fixtures/hp/tenantId.json | 11 +++ test/fixtures/hp/versions.json | 30 +++++++ test/fixtures/versions.json | 2 +- test/helpers/index.js | 4 + 26 files changed, 744 insertions(+), 3 deletions(-) create mode 100644 lib/pkgcloud/hp/index.js create mode 100644 test/configs/mock/hp.json create mode 100644 test/fixtures/hp/creatingServer.json create mode 100644 test/fixtures/hp/flavor1.json create mode 100644 test/fixtures/hp/flavors.json create mode 100644 test/fixtures/hp/image1.json create mode 100644 test/fixtures/hp/images.json create mode 100644 test/fixtures/hp/initialToken-admin.json create mode 100644 test/fixtures/hp/initialToken.json create mode 100644 test/fixtures/hp/no-activeTenants.json create mode 100644 test/fixtures/hp/no-tenants.json create mode 100644 test/fixtures/hp/realToken-admin.json create mode 100644 test/fixtures/hp/realToken-multiRegionVolume.json create mode 100644 test/fixtures/hp/realToken-noRegion.json create mode 100644 test/fixtures/hp/realToken.json create mode 100644 test/fixtures/hp/serverCreated.json create mode 100644 test/fixtures/hp/serverCreated2.json create mode 100644 test/fixtures/hp/serverList.json create mode 100644 test/fixtures/hp/tenantId-admin.json create mode 100644 test/fixtures/hp/tenantId.json create mode 100644 test/fixtures/hp/versions.json diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index 8921d9617..f1c3a1f30 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -29,7 +29,8 @@ var providers = [ 'openstack', 'rackspace', 'redistogo', - 'telefonica' + 'telefonica', + 'hp' ]; var services = [ diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js new file mode 100644 index 000000000..2cd7883a3 --- /dev/null +++ b/lib/pkgcloud/hp/index.js @@ -0,0 +1,9 @@ +/* + * index.js: Top-level include for the HP provider. + * + * (C) 2014 HP Inc. + * + */ + +exports.compute = require('../openstack/compute'); +exports.storage = require('../openstack/storage'); diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index b50bfd976..af4a86443 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -260,6 +260,34 @@ function setupVersionMock(client, provider, servers) { .get('/v2/', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/versions.json'); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/versions.json'); + } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/datacenters', @@ -295,6 +323,12 @@ function setupFlavorMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/flavors.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/flavors/detail', + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); + } } function setupImagesMock(client, provider, servers) { diff --git a/test/configs/mock/hp.json b/test/configs/mock/hp.json new file mode 100644 index 000000000..5a48bef79 --- /dev/null +++ b/test/configs/mock/hp.json @@ -0,0 +1,6 @@ +{ + "username":"MOCK-USERNAME", + "password":"MOCK-PASSWORD", + "authUrl":"http://localhost:12346", + "region": "Calxeda-AUS1" +} diff --git a/test/configs/providers.json b/test/configs/providers.json index dda968475..beff5878f 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1 +1 @@ -["rackspace", "openstack", "joyent", "amazon", "azure", "digitalocean"] \ No newline at end of file +["rackspace", "openstack", "amazon", "azure", "digitalocean", "hp"] \ No newline at end of file diff --git a/test/fixtures/hp/creatingServer.json b/test/fixtures/hp/creatingServer.json new file mode 100644 index 000000000..76d0a187b --- /dev/null +++ b/test/fixtures/hp/creatingServer.json @@ -0,0 +1,16 @@ +{ + "server": { + "OS-DCF:diskConfig": "MANUAL", + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "bookmark" + } + ], + "adminPass": "i9SaeyU3sxKX" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/flavor1.json b/test/fixtures/hp/flavor1.json new file mode 100644 index 000000000..3d43f4df8 --- /dev/null +++ b/test/fixtures/hp/flavor1.json @@ -0,0 +1,21 @@ +{ + "flavor": { + "vcpus": 4, + "disk": 150, + "name": "m1.highbank", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ], + "rxtx_factor": 1.0, + "OS-FLV-EXT-DATA:ephemeral": 0, + "ram": 3584, + "id": "1", + "swap": "" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/flavors.json b/test/fixtures/hp/flavors.json new file mode 100644 index 000000000..1ea3d1c9e --- /dev/null +++ b/test/fixtures/hp/flavors.json @@ -0,0 +1,23 @@ +{ + "flavors": [ + { + "vcpus": 4, + "disk": 150, + "name": "m1.highbank", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ], + "rxtx_factor": 1.0, + "OS-FLV-EXT-DATA:ephemeral": 0, + "ram": 3584, + "id": "1", + "swap": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/image1.json b/test/fixtures/hp/image1.json new file mode 100644 index 000000000..ee4ba3e1c --- /dev/null +++ b/test/fixtures/hp/image1.json @@ -0,0 +1,26 @@ +{ + "image": { + "status": "ACTIVE", + "updated": "2012-07-13T15:37:58Z", + "name": "Ubuntu 12.04", + "links": [ + { + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + }, { + "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "type": "application/vnd.openstack.image", + "rel": "alternate" + } + ], + "created": "2012-07-13T15:37:54Z", + "progress": 100, + "minRam": 0, + "minDisk": 0, + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "metadata": {} + } +} \ No newline at end of file diff --git a/test/fixtures/hp/images.json b/test/fixtures/hp/images.json new file mode 100644 index 000000000..eee40a5cc --- /dev/null +++ b/test/fixtures/hp/images.json @@ -0,0 +1,28 @@ +{ + "images": [ + { + "status": "ACTIVE", + "updated": "2012-07-13T15:37:58Z", + "name": "Ubuntu 12.04", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + }, { + "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "type": "application/vnd.openstack.image", + "rel": "alternate" + } + ], + "created": "2012-07-13T15:37:54Z", + "progress": 100, + "minRam": 0, + "minDisk": 0, + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/initialToken-admin.json b/test/fixtures/hp/initialToken-admin.json new file mode 100644 index 000000000..6f49990cb --- /dev/null +++ b/test/fixtures/hp/initialToken-admin.json @@ -0,0 +1,16 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:45Z", + "id": "e93be67f91724754aeb9409c9c69d305" + }, + "serviceCatalog": {}, + "user": { + "username": "MOCK-ADMIN", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5e", + "roles": [], + "name": "MOCK-ADMIN" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/initialToken.json b/test/fixtures/hp/initialToken.json new file mode 100644 index 000000000..519ce55d2 --- /dev/null +++ b/test/fixtures/hp/initialToken.json @@ -0,0 +1,16 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:45Z", + "id": "e93be67f91724754aeb9409c9c69d304" + }, + "serviceCatalog": {}, + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/no-activeTenants.json b/test/fixtures/hp/no-activeTenants.json new file mode 100644 index 000000000..52357ae28 --- /dev/null +++ b/test/fixtures/hp/no-activeTenants.json @@ -0,0 +1,11 @@ +{ + "tenants_links": [], + "tenants": [ + { + "enabled": "false", + "description": "MOCK-USERNAME", + "name": "MOCK-USERNAME", + "id": "72e90ecb69c44d0296072ea39e537041" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/no-tenants.json b/test/fixtures/hp/no-tenants.json new file mode 100644 index 000000000..fc9c352dd --- /dev/null +++ b/test/fixtures/hp/no-tenants.json @@ -0,0 +1,4 @@ +{ + "tenants_links": [], + "tenants": [] +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken-admin.json b/test/fixtures/hp/realToken-admin.json new file mode 100644 index 000000000..855e86957 --- /dev/null +++ b/test/fixtures/hp/realToken-admin.json @@ -0,0 +1,72 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8b", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537123", + "name": "MOCK-ADMIN", + "description": "MOCK-ADMIN" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, { + "endpoints": [ + { + "adminURL": "http://localhost:12347/v2.0", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-ADMIN", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5e", + "roles": [], + "name": "MOCK-ADMIN" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken-multiRegionVolume.json b/test/fixtures/hp/realToken-multiRegionVolume.json new file mode 100644 index 000000000..63073d18d --- /dev/null +++ b/test/fixtures/hp/realToken-multiRegionVolume.json @@ -0,0 +1,78 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "MOCK-USERNAME", + "description": "MOCK-USERNAME" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + }, + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS2", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:35357/v2.0", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken-noRegion.json b/test/fixtures/hp/realToken-noRegion.json new file mode 100644 index 000000000..14904734f --- /dev/null +++ b/test/fixtures/hp/realToken-noRegion.json @@ -0,0 +1,71 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "MOCK-USERNAME", + "description": "MOCK-USERNAME" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:35357/v2.0", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json new file mode 100644 index 000000000..719d71cdc --- /dev/null +++ b/test/fixtures/hp/realToken.json @@ -0,0 +1,85 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "MOCK-USERNAME", + "description": "MOCK-USERNAME" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, + { + "endpoints": [ + { + "region": "Calxeda-AUS1", + "tenantId": "MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "publicURL": "http://localhost:12345/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" + } + ], + "name": "swift", + "type": "object-store" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:35357/v2.0", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/serverCreated.json b/test/fixtures/hp/serverCreated.json new file mode 100644 index 000000000..d719534ba --- /dev/null +++ b/test/fixtures/hp/serverCreated.json @@ -0,0 +1,57 @@ +{ + "server": { + "OS-EXT-STS:task_state": null, + "addresses": { + "private": [ + { + "version": 4, + "addr": "208.123.85.201" + } + ] + }, + "links": [ + { + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "bookmark" + } + ], + "image": { + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "user_id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-12-25T18:26:02Z", + "hostId": "c41a6390eaac457345c29655688b16ac53182ae874c69770ca36e936", + "key_name": "", + "name": "create-test-setWait", + "created": "2012-12-25T18:25:54Z", + "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "metadata": {} + } +} \ No newline at end of file diff --git a/test/fixtures/hp/serverCreated2.json b/test/fixtures/hp/serverCreated2.json new file mode 100644 index 000000000..6cbd57ba5 --- /dev/null +++ b/test/fixtures/hp/serverCreated2.json @@ -0,0 +1,63 @@ +{ + "server": { + "OS-EXT-STS:task_state": null, + "addresses": { + "private": [ + { + "version": 4, + "addr": "208.123.85.201" + } + ], + "public": [ + { + "version": 4, + "addr": "208.123.85.201" + } + ] + }, + "links": [ + { + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "bookmark" + } + ], + "image": { + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "user_id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-12-25T18:26:02Z", + "hostId": "c41a6390eaac457345c29655688b16ac53182ae874c69770ca36e936", + "key_name": "", + "name": "create-test-ids2", + "created": "2012-12-25T18:25:54Z", + "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "metadata": {} + } +} \ No newline at end of file diff --git a/test/fixtures/hp/serverList.json b/test/fixtures/hp/serverList.json new file mode 100644 index 000000000..fc8560c50 --- /dev/null +++ b/test/fixtures/hp/serverList.json @@ -0,0 +1,48 @@ +{ + "servers": [{ + "OS-EXT-STS:task_state": "deleting", + "addresses": { + "private": [{ + "version": 4, "addr": "208.123.85.203" + }] + }, + "links": [{ + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "rel": "bookmark" + }], + "image": { + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "links": [{ + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + }] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [{ + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + }] + }, + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "user_id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2013-02-14T20:24:52Z", + "hostId": "ab50598d09cc91aa5c32f6afabe30fd1ded4cf8100eb77f782dd3e19", + "key_name": "", + "name": "create-test-ids2", + "created": "2013-02-14T20:24:42Z", + "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "metadata": {} + }] +} \ No newline at end of file diff --git a/test/fixtures/hp/tenantId-admin.json b/test/fixtures/hp/tenantId-admin.json new file mode 100644 index 000000000..2153a31e9 --- /dev/null +++ b/test/fixtures/hp/tenantId-admin.json @@ -0,0 +1,11 @@ +{ + "tenants_links": [], + "tenants": [ + { + "enabled": "true", + "description": "MOCK-ADMIN", + "name": "MOCK-ADMIN", + "id": "72e90ecb69c44d0296072ea39e537123" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/tenantId.json b/test/fixtures/hp/tenantId.json new file mode 100644 index 000000000..310afd86c --- /dev/null +++ b/test/fixtures/hp/tenantId.json @@ -0,0 +1,11 @@ +{ + "tenants_links": [], + "tenants": [ + { + "enabled": "true", + "description": "MOCK-USERNAME", + "name": "MOCK-USERNAME", + "id": "72e90ecb69c44d0296072ea39e537041" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/versions.json b/test/fixtures/hp/versions.json new file mode 100644 index 000000000..893d18aee --- /dev/null +++ b/test/fixtures/hp/versions.json @@ -0,0 +1,30 @@ +{ + "version": { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "media-types": [ + { + "base": "application/xml", + "type": "application/vnd.openstack.compute+xml;version=2" + }, { + "base": "application/json", + "type": "application/vnd.openstack.compute+json;version=2" + } + ], + "id": "v1", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/", + "rel": "self" + }, { + "href": "http://docs.openstack.org/api/openstack-compute/1.1/os-compute-devguide-1.1.pdf", + "type": "application/pdf", + "rel": "describedby" + }, { + "href": "http://docs.openstack.org/api/openstack-compute/1.1/wadl/os-compute-1.1.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/versions.json b/test/fixtures/versions.json index 85a5fdf83..e23d699e0 100644 --- a/test/fixtures/versions.json +++ b/test/fixtures/versions.json @@ -1 +1 @@ -{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2012-04-01", "azure": "2012-03-01", "openstack": "v2"} \ No newline at end of file +{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2012-04-01", "azure": "2012-03-01", "openstack": "v2", "hp": "v1"} \ No newline at end of file diff --git a/test/helpers/index.js b/test/helpers/index.js index 3a10e33e4..7bd33d415 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -180,6 +180,10 @@ helpers.getOpenstackAuthResponse = function (time) { return helpers._getOpenstackStandardResponse('../fixtures/openstack/realToken.json', time); }; +helpers.gethpAuthResponse = function (time) { + return helpers._getOpenstackStandardResponse('../fixtures/hp/realToken.json', time); +}; + helpers._getOpenstackStandardResponse = function(file, time) { if (!time) { time = new Date(new Date().getTime() + (1000 * 60 * 60 * 24)); From 464dfb821fb79c278d133edca3cfe266d18aff48 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 13:39:46 -0700 Subject: [PATCH 007/460] All tests passing for HP provider. --- test/common/compute/base-test.js | 32 +++++++- test/common/compute/server-test.js | 51 ++++++++++++ test/common/storage/base-test.js | 82 +++++++++++++++++++ test/fixtures/hp/creatingServer.json | 4 +- test/fixtures/hp/flavor1.json | 4 +- test/fixtures/hp/flavors.json | 4 +- test/fixtures/hp/image1.json | 6 +- test/fixtures/hp/images.json | 6 +- test/fixtures/hp/no-activeTenants.json | 2 +- test/fixtures/hp/postContainers.json | 1 + test/fixtures/hp/preContainers.json | 1 + test/fixtures/hp/realToken-admin.json | 12 +-- .../hp/realToken-multiRegionVolume.json | 20 ++--- test/fixtures/hp/realToken-noRegion.json | 14 ++-- test/fixtures/hp/realToken.json | 14 ++-- test/fixtures/hp/serverCreated.json | 10 +-- test/fixtures/hp/serverCreated2.json | 10 +-- test/fixtures/hp/serverList.json | 10 +-- test/fixtures/hp/tenantId-admin.json | 2 +- test/fixtures/hp/tenantId.json | 2 +- 20 files changed, 224 insertions(+), 63 deletions(-) create mode 100644 test/fixtures/hp/postContainers.json create mode 100644 test/fixtures/hp/preContainers.json diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index af4a86443..82be22039 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -279,7 +279,7 @@ function setupVersionMock(client, provider, servers) { username: 'MOCK-USERNAME', password: 'MOCK-PASSWORD' }, - tenantId: '72e90ecb69c44d0296072ea39e537041' + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers.gethpAuthResponse()); @@ -325,9 +325,9 @@ function setupFlavorMock(client, provider, servers) { } else if (provider === 'hp') { servers.server - .get('/v2/72e90ecb69c44d0296072ea39e537041/flavors/detail', + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); + .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); } } @@ -372,6 +372,12 @@ function setupImagesMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/images.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail', + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); + } } function setupServerMock(client, provider, servers) { @@ -523,6 +529,21 @@ function setupServerMock(client, provider, servers) { {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers', { + server: { + name: 'create-test-setWait', + flavorRef: '1', + imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' + } + }, + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(202, __dirname + '/../../fixtures/hp/creatingServer.json') + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/serverCreated.json'); + } } function setupDestroyMock(client, provider, servers) { @@ -537,6 +558,11 @@ function setupDestroyMock(client, provider, servers) { .delete('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(204); } + else if (provider === 'hp') { + servers.server + .delete('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(204); + } else if (provider === 'digitalocean') { var account = require(__dirname + '/../../configs/mock/digitalocean'); diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index f8a5b83bc..bc01948e0 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -296,6 +296,34 @@ function setupImagesMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/images.json'); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); + } } function setupFlavorMock(client, provider, servers) { @@ -323,6 +351,11 @@ function setupFlavorMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/flavors.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); + } } function setupServerMock(client, provider, servers) { @@ -434,6 +467,14 @@ function setupServerMock(client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers', + {server: {name: 'create-test-ids2', flavorRef: '1', imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/creatingServer.json') + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); + } } function setupGetServersMock(client, provider, servers) { @@ -478,6 +519,11 @@ function setupGetServersMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/list-servers.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/serverList.json'); + } } function setupGetServerMock(client, provider, servers) { @@ -513,6 +559,11 @@ function setupGetServerMock(client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); + } } // //function batchThree(providerClient, providerName) { diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 8743288f4..9e1aa4a6e 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -512,6 +512,34 @@ function setupCreateContainerMock(provider, client, servers) { .put('/pkgcloud-test-container?restype=container') .reply(201, '', helpers.azureResponseHeaders()); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } } function setupGetContainersMock(provider, client, servers) { @@ -530,6 +558,11 @@ function setupGetContainersMock(provider, client, servers) { .get('/?comp=list') .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/postContainers.json')); + } } function setupUploadStreamMock(provider, client, servers) { @@ -550,6 +583,11 @@ function setupUploadStreamMock(provider, client, servers) { .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', "block000000000000000") .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) } + else if (provider === 'hp') { + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .reply(200) + } } function setupDownloadStreamMock(provider, client, servers) { @@ -568,6 +606,11 @@ function setupDownloadStreamMock(provider, client, servers) { .get('/pkgcloud-test-container/test-file.txt') .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2}) + } } function setupGetFileMock(provider, client, servers) { @@ -586,6 +629,11 @@ function setupGetFileMock(provider, client, servers) { .get('/pkgcloud-test-container/test-file.txt') .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})) } + if (provider === 'hp') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }) + } } function setupGetFilesMock(provider, client, servers) { @@ -608,6 +656,15 @@ function setupGetFilesMock(provider, client, servers) { .get('/pkgcloud-test-container?restype=container&comp=list') .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [{ + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + }]); + } } function setupRemoveFileMock(provider, client, servers) { @@ -626,6 +683,11 @@ function setupRemoveFileMock(provider, client, servers) { .delete('/pkgcloud-test-container/test-file.txt') .reply(202, '', helpers.azureDeleteResponseHeaders()) } + if (provider === 'hp') { + servers.server + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, ''); + } } function setupDestroyContainerMock(provider, client, servers) { @@ -658,6 +720,21 @@ function setupDestroyContainerMock(provider, client, servers) { .delete('/pkgcloud-test-container?restype=container') .reply(202, '', helpers.azureDeleteResponseHeaders()); } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } } function setupGetContainers2Mock(provider, client, servers) { @@ -676,4 +753,9 @@ function setupGetContainers2Mock(provider, client, servers) { .get('/?comp=list') .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/preContainers.json')); + } } \ No newline at end of file diff --git a/test/fixtures/hp/creatingServer.json b/test/fixtures/hp/creatingServer.json index 76d0a187b..b155f7a6b 100644 --- a/test/fixtures/hp/creatingServer.json +++ b/test/fixtures/hp/creatingServer.json @@ -4,10 +4,10 @@ "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "bookmark" } ], diff --git a/test/fixtures/hp/flavor1.json b/test/fixtures/hp/flavor1.json index 3d43f4df8..b2f3adca0 100644 --- a/test/fixtures/hp/flavor1.json +++ b/test/fixtures/hp/flavor1.json @@ -5,10 +5,10 @@ "name": "m1.highbank", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ], diff --git a/test/fixtures/hp/flavors.json b/test/fixtures/hp/flavors.json index 1ea3d1c9e..85d32b504 100644 --- a/test/fixtures/hp/flavors.json +++ b/test/fixtures/hp/flavors.json @@ -6,10 +6,10 @@ "name": "m1.highbank", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ], diff --git a/test/fixtures/hp/image1.json b/test/fixtures/hp/image1.json index ee4ba3e1c..15cb67aac 100644 --- a/test/fixtures/hp/image1.json +++ b/test/fixtures/hp/image1.json @@ -5,13 +5,13 @@ "name": "Ubuntu 12.04", "links": [ { - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" }, { - "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://10.225.0.9:9292/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "type": "application/vnd.openstack.image", "rel": "alternate" } diff --git a/test/fixtures/hp/images.json b/test/fixtures/hp/images.json index eee40a5cc..cf05cf7ec 100644 --- a/test/fixtures/hp/images.json +++ b/test/fixtures/hp/images.json @@ -6,13 +6,13 @@ "name": "Ubuntu 12.04", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" }, { - "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://10.225.0.9:9292/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "type": "application/vnd.openstack.image", "rel": "alternate" } diff --git a/test/fixtures/hp/no-activeTenants.json b/test/fixtures/hp/no-activeTenants.json index 52357ae28..bd2c911ac 100644 --- a/test/fixtures/hp/no-activeTenants.json +++ b/test/fixtures/hp/no-activeTenants.json @@ -5,7 +5,7 @@ "enabled": "false", "description": "MOCK-USERNAME", "name": "MOCK-USERNAME", - "id": "72e90ecb69c44d0296072ea39e537041" + "id": "5ACED3DC3AA740ABAA41711243CC6949" } ] } \ No newline at end of file diff --git a/test/fixtures/hp/postContainers.json b/test/fixtures/hp/postContainers.json new file mode 100644 index 000000000..8fccead0c --- /dev/null +++ b/test/fixtures/hp/postContainers.json @@ -0,0 +1 @@ +[{"count": 0, "bytes": 0, "name": "lost+found"}, {"count": 0, "bytes": 0, "name": "pkgcloud-test-container"}] diff --git a/test/fixtures/hp/preContainers.json b/test/fixtures/hp/preContainers.json new file mode 100644 index 000000000..cdb6cbc35 --- /dev/null +++ b/test/fixtures/hp/preContainers.json @@ -0,0 +1 @@ +[{"count": 0, "bytes": 0, "name": "lost+found"}] diff --git a/test/fixtures/hp/realToken-admin.json b/test/fixtures/hp/realToken-admin.json index 855e86957..3526ee0f2 100644 --- a/test/fixtures/hp/realToken-admin.json +++ b/test/fixtures/hp/realToken-admin.json @@ -14,10 +14,10 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -38,10 +38,10 @@ }, { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/realToken-multiRegionVolume.json b/test/fixtures/hp/realToken-multiRegionVolume.json index 63073d18d..88df5a1c0 100644 --- a/test/fixtures/hp/realToken-multiRegionVolume.json +++ b/test/fixtures/hp/realToken-multiRegionVolume.json @@ -5,7 +5,7 @@ "id": "4bc7c5dabf3e4a49918683437d386b8a", "tenant": { "enabled": true, - "id": "72e90ecb69c44d0296072ea39e537041", + "id": "5ACED3DC3AA740ABAA41711243CC6949", "name": "MOCK-USERNAME", "description": "MOCK-USERNAME" } @@ -14,16 +14,16 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" }, { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS2", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -44,10 +44,10 @@ }, { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/realToken-noRegion.json b/test/fixtures/hp/realToken-noRegion.json index 14904734f..484e01e2d 100644 --- a/test/fixtures/hp/realToken-noRegion.json +++ b/test/fixtures/hp/realToken-noRegion.json @@ -5,7 +5,7 @@ "id": "4bc7c5dabf3e4a49918683437d386b8a", "tenant": { "enabled": true, - "id": "72e90ecb69c44d0296072ea39e537041", + "id": "5ACED3DC3AA740ABAA41711243CC6949", "name": "MOCK-USERNAME", "description": "MOCK-USERNAME" } @@ -14,9 +14,9 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -38,9 +38,9 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041" + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 719d71cdc..2636f092e 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -5,7 +5,7 @@ "id": "4bc7c5dabf3e4a49918683437d386b8a", "tenant": { "enabled": true, - "id": "72e90ecb69c44d0296072ea39e537041", + "id": "5ACED3DC3AA740ABAA41711243CC6949", "name": "MOCK-USERNAME", "description": "MOCK-USERNAME" } @@ -14,10 +14,10 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -38,10 +38,10 @@ }, { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/serverCreated.json b/test/fixtures/hp/serverCreated.json index d719534ba..01ae03343 100644 --- a/test/fixtures/hp/serverCreated.json +++ b/test/fixtures/hp/serverCreated.json @@ -11,10 +11,10 @@ }, "links": [ { - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "bookmark" } ], @@ -22,7 +22,7 @@ "id": "506d077e-66bf-44ff-907a-588c5c79fa66", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" } ] @@ -32,7 +32,7 @@ "id": "1", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ] @@ -51,7 +51,7 @@ "key_name": "", "name": "create-test-setWait", "created": "2012-12-25T18:25:54Z", - "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "tenant_id": "5ACED3DC3AA740ABAA41711243CC6949", "metadata": {} } } \ No newline at end of file diff --git a/test/fixtures/hp/serverCreated2.json b/test/fixtures/hp/serverCreated2.json index 6cbd57ba5..ca8cadeac 100644 --- a/test/fixtures/hp/serverCreated2.json +++ b/test/fixtures/hp/serverCreated2.json @@ -17,10 +17,10 @@ }, "links": [ { - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "bookmark" } ], @@ -28,7 +28,7 @@ "id": "506d077e-66bf-44ff-907a-588c5c79fa66", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" } ] @@ -38,7 +38,7 @@ "id": "1", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ] @@ -57,7 +57,7 @@ "key_name": "", "name": "create-test-ids2", "created": "2012-12-25T18:25:54Z", - "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "tenant_id": "5ACED3DC3AA740ABAA41711243CC6949", "metadata": {} } } \ No newline at end of file diff --git a/test/fixtures/hp/serverList.json b/test/fixtures/hp/serverList.json index fc8560c50..9d34a9644 100644 --- a/test/fixtures/hp/serverList.json +++ b/test/fixtures/hp/serverList.json @@ -7,16 +7,16 @@ }] }, "links": [{ - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", "rel": "bookmark" }], "image": { "id": "506d077e-66bf-44ff-907a-588c5c79fa66", "links": [{ - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" }] }, @@ -24,7 +24,7 @@ "flavor": { "id": "1", "links": [{ - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" }] }, @@ -42,7 +42,7 @@ "key_name": "", "name": "create-test-ids2", "created": "2013-02-14T20:24:42Z", - "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "tenant_id": "5ACED3DC3AA740ABAA41711243CC6949", "metadata": {} }] } \ No newline at end of file diff --git a/test/fixtures/hp/tenantId-admin.json b/test/fixtures/hp/tenantId-admin.json index 2153a31e9..df6a207d2 100644 --- a/test/fixtures/hp/tenantId-admin.json +++ b/test/fixtures/hp/tenantId-admin.json @@ -5,7 +5,7 @@ "enabled": "true", "description": "MOCK-ADMIN", "name": "MOCK-ADMIN", - "id": "72e90ecb69c44d0296072ea39e537123" + "id": "5ACED3DC3AA740ABAA41711243CC6949" } ] } \ No newline at end of file diff --git a/test/fixtures/hp/tenantId.json b/test/fixtures/hp/tenantId.json index 310afd86c..c1025f93e 100644 --- a/test/fixtures/hp/tenantId.json +++ b/test/fixtures/hp/tenantId.json @@ -5,7 +5,7 @@ "enabled": "true", "description": "MOCK-USERNAME", "name": "MOCK-USERNAME", - "id": "72e90ecb69c44d0296072ea39e537041" + "id": "5ACED3DC3AA740ABAA41711243CC6949" } ] } \ No newline at end of file From b825f0c407769a0e66b3c26b90050c9bc7f65d0c Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 13:42:54 -0700 Subject: [PATCH 008/460] Adding joyent provider back to Providers.json --- test/configs/providers.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/configs/providers.json b/test/configs/providers.json index beff5878f..e643abe2d 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1 +1 @@ -["rackspace", "openstack", "amazon", "azure", "digitalocean", "hp"] \ No newline at end of file +["rackspace", "openstack", "joyent", "amazon", "azure", "digitalocean", "hp"] \ No newline at end of file From c01c5a32f6c4c2f9ed77bc739610956d0f3dfb5c Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 17:17:25 -0700 Subject: [PATCH 009/460] Adding documentation for HP Cloud provider --- docs/providers/hp/README.md | 76 +++++++++ docs/providers/hp/compute.md | 142 +++++++++++++++++ docs/providers/hp/storage.md | 295 +++++++++++++++++++++++++++++++++++ 3 files changed, 513 insertions(+) create mode 100644 docs/providers/hp/README.md create mode 100644 docs/providers/hp/compute.md create mode 100644 docs/providers/hp/storage.md diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md new file mode 100644 index 000000000..65f1d7b22 --- /dev/null +++ b/docs/providers/hp/README.md @@ -0,0 +1,76 @@ +## Using the HP Cloud provider in pkgcloud + +The HP Cloud provider in pkgcloud supports the following services: + +* [**Compute**](compute.md) (Cloud Servers) +* [**Storage**](storage.md) (Cloud Files) +### Getting Started with Compute + +We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. + +### Authentication + +For all of the HP Cloud services, you create a client with the same options: + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'rackspace', + username: 'your-user-name', + password: 'your-api-key' +}); +``` + +In addition to your `apiKey`, you could alternately provide your `password` as an option to `createClient`. + +### Authentication Endpoints and Regions + +All of the Rackspace `createClient` calls have a few options that can be provided: + +#### authUrl + +`authUrl` specifies the authentication endpoint used to create a token for your Rackspace client. By default, this is set to the Global endpoint: https://identity.api.rackspacecloud.com. + +##### Authenticating against the London endpoint + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'rackspace', + username: 'your-user-name', + apiKey: 'your-api-key', + authUrl: 'https://lon.identity.api.rackspacecloud.com' +}); +``` + +#### region + +`region` specifies which region of a service to use. For example, when you authenticate with the global endpoint for compute, you have the option of either `DFW`, `ORD`, or `SYD`. The default region is `DFW`. Previous pkgcloud versions did not let you specify which region you used, so all calls were against `DFW`. + +##### Specifying a custom region + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'rackspace', + username: 'your-user-name', + apiKey: 'your-api-key', + region: 'ORD' +}); +``` + +#### Tokens and Expiration + +When you make your first call to a Rackspace provider, your client is authenticated transparent to your API call. Rackspace will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. + +#### Internal URLs + +As part of the options, you can tell `pkgcloud` to use the Internal (Service Net) URLs for a service, if possible. + + ```Javascript + var client = require('pkgcloud').storage.createClient({ + provider: 'rackspace', + username: 'your-user-name', + apiKey: 'your-api-key', + useInternal: true + }); + ``` + + This setting is explicit. If you set it to true, and you have no connectivity to the internal URL for a service, your connections will timeout. diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md new file mode 100644 index 000000000..f3c724ead --- /dev/null +++ b/docs/providers/hp/compute.md @@ -0,0 +1,142 @@ +##Using the HP Cloud Compute provider + +Creating a client is straight-forward: + +``` js + var hpCompute = pkgcloud.compute.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region of identity service', + authUrl: 'https://your-identity-service' + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +**Servers** + +#### client.getServers(callback) +Lists all servers that are available to use on your HP Cloud account + +Callback returns `f(err, servers)` where `servers` is an `Array` + +#### client.createServer(options, callback) +Creates a server with the options specified + +Options are as follows: + +```js +{ + name: 'serverName', // required + flavor: 'flavor1', // required + image: 'image1', // required + personality: [] // optional +} +``` +Returns the server in the callback `f(err, server)` + +#### client.destroyServer(server, callback) +Destroys the specified server + +Takes server or serverId as an argument and returns the id of the destroyed server in the callback `f(err, serverId)` + +#### client.getServer(server, callback) +Gets specified server + +Takes server or serverId as an argument and returns the server in the callback +`f(err, server)` + +#### client.rebootServer(server, options, callback) +Reboots the specifed server with options + +Options include: + +```js +{ + type: 'HARD' // optional (defaults to 'SOFT') +} +``` +Returns callback with a confirmation + +#### client.getVersion(callback) + +Get the current version of the api returned in a callback `f(err, version)` + +#### client.getLimits(callback) + +Get the current API limits returned in a callback `f(err, limits)` + +**flavors** + +#### client.getFlavors(callback) + +Returns a list of all possible server flavors available in the callback `f(err, +flavors)` + +#### client.getFlavor(flavor, callback) +Returns the specified HP flavor of Openstack Images by ID or flavor +object in the callback `f(err, flavor)` + +**images** + +#### client.getImages(callback) +Returns a list of the images available for your account + +`f(err, images)` + +#### client.getImage(image, callback) +Returns the image specified + +`f(err, image)` + +#### client.createImage(options, callback) +Creates an Image based on a server + +Options include: + +```js +{ + name: 'imageName', // required + server: 'serverId' // required +} +``` + +Returns the newly created image + +`f(err, image)` + +#### client.destroyImage(image, callback) +Destroys the specified image and returns a confirmation + +`f(err, {ok: imageId})` + +## Volume Attachments + +Attaching a volume to a compute instance requires using a rackspace compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. + +#### client.getVolumeAttachments(server, callback) + +Gets an array of volumeAttachments for the provided server. + +`f(err, volumeAttachments)` + +#### client.getVolumeAttachmentDetails(server, attachment, callback) + +Gets the details for a provided server and attachment. `attachment` may either be the `attachmentId` or an object with `attachmentId` as a property. + +`f(err, volumeAttachment)` + +#### client.attachVolume(server, volume, callback) + +Attaches the provided `volume` to the `server`. `volume` may either be the `volumeId` or an instance of `Volume`. + +`f(err, volumeAttachment)` + +#### client.detachVolume(server, attachment, callback) + +Detaches the provided `attachment` from the server. `attachment` may either be the `attachmentId` or an object with `attachmentId` as a property. If the `volume` is mounted this call will return an err. + +`f(err)` diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md new file mode 100644 index 000000000..80f599b38 --- /dev/null +++ b/docs/providers/hp/storage.md @@ -0,0 +1,295 @@ +## Using the HP Storage provider + +* Container + * [Model](#container-model) + * [APIs](#container-apis) +* File + * [Model](#file-model) + * [APIs](#file-apis) + +Creating a client is straight-forward: + +``` js + var hpStorage = pkgcloud.storage.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region of identity service', + authUrl: 'https://your-identity-service' + }); +``` + +Learn about [more options for creating clients](README.md) in the Openstack `storage` provider. + +### Container Model + +A Container for Openstack has following properties: + +```Javascript +{ + name: 'my-container', + count: 1, // number of files in your container + bytes: 12345, // size of the container in bytes + metadata: { // key value pairs for the container + // ... + } +} +``` + +### File Model + +A File for Openstack has the following properties: + +```Javascript +{ + name: 'my-file', + container: 'my-container', // may be an instance of container if provided + size: 12345, // size of the file in bytes + contentType: 'plain/text' // Mime type for the file + lastModified: Fri Dec 14 2012 10:16:50 GMT-0800 (PST), // Last modified date of the file + etag: '1234567890abcdef', // MD5 sum of the file + metadata: {} // optional object metadata +} +``` + +### Container APIs + +* [`client.getContainers(function(err, containers) { })`](#clientgetcontainersfunctionerr-containers--) +* [`client.getContainer(container, function(err, container) { })`](#clientgetcontainercontainer-functionerr-container--) +* [`client.createContainer(container, function(err, container) { })`](#clientcreatecontainercontainer-functionerr-container--) +* [`client.destroyContainer(container, function(err, result) { })`](#clientdestroycontainercontainer-functionerr-result--) +* [`client.updateContainerMetadata(container, function(err, container) { })`](#clientupdatecontainermetadatacontainer-functionerr-container--) +* [`client.removeContainerMetadata(container, metadataToRemove, function(err, container) { })`](#clientremovecontainermetadatacontainer-metadatatoremove-functionerr-container--) + +### Container API Details + +For all of the container methods, you can pass either an instance of [`container`](#container) or the container name as `container`. For example: + +```Javascript +client.getContainer('my-container', function(err, container) { ... }); +``` + +This call is functionally equivalent to: + +```Javascript +var myContainer = new Container({ name: 'my-container' }); + +client.getContainer(myContainer, function(err, container) { ... }); +``` + +#### client.getContainers(function(err, containers) { }) + +Retreives the containers for the current client instance as an array of [`container`](#container-model) + +#### client.getContainer(container, function(err, container) { }) + +Retrieves the specified [`container`](#container-model) from the current client instance. + +#### client.createContainer(container, function(err, container) { }) + +Creates a new [`container`](#container-model) with the name from argument `container`. You can optionally provide `metadata` on the request: + +```javascript +client.createContainer({ + name: 'my-container', + metadata: { + brand: 'bmw', + model: '335i' + year: 2009 + }}, function(err, container) { + // ... + }) +``` + +#### client.destroyContainer(container, function(err, result) { }) + +Removes the [`container`](#container-model) from the storage account. If there are any files within the `container`, they will be deleted before removing the `container` on the client. `result` will be `true` on success. + +#### client.updateContainerMetadata(container, function(err, container) { }) + +Updates the metadata on the provided [`container`](#container-model) . Currently, the `updateContainer` method only adds new metadata fields. If you need to remove specific metadata properties, you should call `client.removeContainerMetadata(...)`. + +```javascript +container.metadata.color = 'red'; +client.updateContainerMetadata(container, function(err, container) { + // ... +}) +``` + +#### client.removeContainerMetadata(container, metadataToRemove, function(err, container) { }) + +Removes the keys in the `metadataToRemove` object from the stored [`container`](#container-model) metadata. + +```Javascript +client.removeContainerMetadata(container, { year: false }, function(err, c) { + // ... +}); +``` + +### File APIs + +* [`client.upload(options, function(err, result) { })`](#clientuploadoptions-functionerr-result--) +* [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) +* [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) +* [`client.getFiles(container, function(err, file) { })`](#clientgetfilescontainer-functionerr-file--) +* [`client.removeFile(container, file, function(err, result) { })`](#clientremovefilecontainer-file-functionerr-result--) +* [`client.updateFileMetadata(container, file, function(err, file) { })`](#clientupdatefilemetadatacontainer-file-functionerr-file--) + +### File API Details + +For all of the file methods, you can pass either an instance of [`container`](#container-model) or the container name as `container`. For example: + +```Javascript +client.getFile('my-container', 'my-file', function(err, file) { ... }); +``` + +This call is functionally equivalent to: + +```Javascript +var myContainer = new Container({ name: 'my-container' }); + +client.getFile(myContainer, 'my-file', function(err, file) { ... }); +``` + +#### client.upload(options, function(err, result) { }) + +Returns a writeable stream. Upload a new file to a [`container`](#container-model). `result` will be `true` on success. + +To upload a file, you need to provide an `options` argument: + +```Javascript +var options = { + // required options + container: 'my-container', // this can be either the name or an instance of container + remote: 'my-file', // name of the new file + + // optional, either stream or local + stream: myStream, // any instance of a readable stream + local: '/path/to/local/file' // a path to any local file + + // Other optional values + metadata: { // provide any number of property/values for metadata + campaign: '2012 magazine' + }, + headers: { // optionally provide raw headers to send to cloud files + 'content-type': 'application/json' + } +}; +``` + +You need not provide either `stream` or `local`. `client.upload` returns a writeable stream, so you can simply pipe directly into it from your stream. For example: + +```Javascript +var fs = require('fs'), + pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +var myFile = fs.createReadStream('/my/local/file'); + +myFile.pipe(client.upload({ + container: 'my-container', + remote: 'my-file' +}, function(err, result) { + // handle the upload result +})); +``` + +You could also upload a local file via the `local` property on `options`: + +```Javascript +var pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +client.upload({ + container: 'my-container', + remote: 'my-file', + local: '/path/to/my/file' +}, function(err, result) { + // handle the upload result +}); +``` + +This is functionally equivalent to piping from an `fs.createReadStream`, but has a simplified calling convention. + +#### client.download(options, function(err, file) { }) + +Returns a readable stream. Download a [`file`](#file-model) from a [`container`](#container-model). + +To download a file, you need to provide an `options` argument: + +```Javascript +var options = { + // required options + container: 'my-container', // this can be either the name or an instance of container + remote: 'my-file', // name of the new file + + // optional, either stream or local + stream: myStream, // any instance of a writeable stream + local: '/path/to/local/file' // the path to a local file to write to +}; +``` + +You need not provide either `stream` or `local`. `client.download` returns a readable stream, so you can simply pipe it into your writeable stream. For example: + +```Javascript +var fs = require('fs'), + pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +var myFile = fs.createWriteStream('/my/local/file'); + +client.download({ + container: 'my-container', + remote: 'my-file' +}, function(err, result) { + // handle the download result +})).pipe(myFile); +``` + +You could also download to a local file via the `local` property on `options`: + +```Javascript +var pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +client.download({ + container: 'my-container', + remote: 'my-file', + local: '/path/to/my/file' +}, function(err, result) { + // handle the download result +}); +``` + +This is functionally equivalent to piping from an `fs.createWriteStream`, but has a simplified calling convention. + +#### client.getFile(container, file, function(err, file) { }) + +Retrieves the specified [`file`](#file-model) details in the specified [`container`](#container-model) from the current client instance. + +#### client.getFiles(container, function(err, files) { }) + +Retreives an array of [`file`](#file-model) for the provided [`container`](#container-model). + +#### client.removeFile(container, file, function(err, result) { }) + +Removes the provided [`file`](#file-model) from the provided [`container`](#container-model). + +#### client.updateFileMetadata(container, file, function(err, file) { }) + +Updates the [`file`](#file-model) metadata in the the provided [`container`](#container-model). + +File metadata is completely replaced with each callt o updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`. +```javascript +file.metadata = { + campaign = '2011 website' +}; + +client.updateFileMetadata(file.container, file, function(err, file) { + // ... +}); +``` From 05a5e82f9e51c5e81becab28492ec7ab3c38b4d0 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 09:56:45 -0700 Subject: [PATCH 010/460] Change provider type to 'HP' --- docs/providers/hp/README.md | 16 ++++++++-------- docs/providers/hp/compute.md | 2 +- docs/providers/hp/storage.md | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 65f1d7b22..9a14bb167 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -14,7 +14,7 @@ For all of the HP Cloud services, you create a client with the same options: ```Javascript var client = require('pkgcloud').compute.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', password: 'your-api-key' }); @@ -24,20 +24,20 @@ In addition to your `apiKey`, you could alternately provide your `password` as a ### Authentication Endpoints and Regions -All of the Rackspace `createClient` calls have a few options that can be provided: +All of the hp `createClient` calls have a few options that can be provided: #### authUrl -`authUrl` specifies the authentication endpoint used to create a token for your Rackspace client. By default, this is set to the Global endpoint: https://identity.api.rackspacecloud.com. +`authUrl` specifies the authentication endpoint used to create a token for your hp client. By default, this is set to the Global endpoint: https://identity.api.hpcloud.com. ##### Authenticating against the London endpoint ```Javascript var client = require('pkgcloud').compute.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', apiKey: 'your-api-key', - authUrl: 'https://lon.identity.api.rackspacecloud.com' + authUrl: 'https://lon.identity.api.hpcloud.com' }); ``` @@ -49,7 +49,7 @@ var client = require('pkgcloud').compute.createClient({ ```Javascript var client = require('pkgcloud').compute.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', apiKey: 'your-api-key', region: 'ORD' @@ -58,7 +58,7 @@ var client = require('pkgcloud').compute.createClient({ #### Tokens and Expiration -When you make your first call to a Rackspace provider, your client is authenticated transparent to your API call. Rackspace will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. +When you make your first call to a hp provider, your client is authenticated transparent to your API call. hp will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. #### Internal URLs @@ -66,7 +66,7 @@ As part of the options, you can tell `pkgcloud` to use the Internal (Service Net ```Javascript var client = require('pkgcloud').storage.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', apiKey: 'your-api-key', useInternal: true diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md index f3c724ead..f79956dcb 100644 --- a/docs/providers/hp/compute.md +++ b/docs/providers/hp/compute.md @@ -115,7 +115,7 @@ Destroys the specified image and returns a confirmation ## Volume Attachments -Attaching a volume to a compute instance requires using a rackspace compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. +Attaching a volume to a compute instance requires using a hp compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. #### client.getVolumeAttachments(server, callback) diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index 80f599b38..d1406ee1f 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -183,7 +183,7 @@ You need not provide either `stream` or `local`. `client.upload` returns a write var fs = require('fs'), pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); var myFile = fs.createReadStream('/my/local/file'); @@ -200,7 +200,7 @@ You could also upload a local file via the `local` property on `options`: ```Javascript var pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); client.upload({ container: 'my-container', @@ -237,7 +237,7 @@ You need not provide either `stream` or `local`. `client.download` returns a rea var fs = require('fs'), pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); var myFile = fs.createWriteStream('/my/local/file'); @@ -254,7 +254,7 @@ You could also download to a local file via the `local` property on `options`: ```Javascript var pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); client.download({ container: 'my-container', From 50a58d8aa5345d8c866cccbfec3378f336db92ee Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:14:41 -0700 Subject: [PATCH 011/460] Adding documentation for regions in HP Cloud. --- docs/README.md | 2 ++ docs/providers/hp/README.md | 39 +++++++++++++++++++++++++----------- docs/providers/hp/compute.md | 4 ++-- docs/providers/hp/storage.md | 6 +++--- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/README.md b/docs/README.md index ab2fbbf20..700533db8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,12 +18,14 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](providers/amazon.md#using-compute) * [Azure](providers/azure.md#using-compute) * [DigitalOcean](providers/digitalocean.md#using-compute) + * [HP](providers/hp/compute.md) * [Joyent](providers/joyent.md#using-compute) * [Openstack](providers/openstack/compute.md) * [Rackspace](providers/rackspace/compute.md) * **Storage** * [Amazon](providers/amazon.md#using-storage) * [Azure](providers/azure.md#using-storage) + * [HP](providers/hp/storage.md) * [Openstack](providers/openstack/storage.md) * [Rackspace](providers/rackspace/storage.md) * **Databases** diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 9a14bb167..5b40a7a9a 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -4,6 +4,7 @@ The HP Cloud provider in pkgcloud supports the following services: * [**Compute**](compute.md) (Cloud Servers) * [**Storage**](storage.md) (Cloud Files) + ### Getting Started with Compute We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. @@ -16,34 +17,48 @@ For all of the HP Cloud services, you create a client with the same options: var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-api-key' + password: 'your-password' }); ``` -In addition to your `apiKey`, you could alternately provide your `password` as an option to `createClient`. - ### Authentication Endpoints and Regions -All of the hp `createClient` calls have a few options that can be provided: +All of the HP `createClient` calls have a few options that can be provided: #### authUrl -`authUrl` specifies the authentication endpoint used to create a token for your hp client. By default, this is set to the Global endpoint: https://identity.api.hpcloud.com. +`authUrl` specifies the authentication endpoint used to create a token for your HP client. +The HP Identity Service is currently available in two regions which can be accessed via these URLs. +See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) + +##### Authenticating against the US-West endpoint + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region-a.geo-1', + authUrl: 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/' +}); +``` -##### Authenticating against the London endpoint +##### Authenticating against the US-East endpoint ```Javascript var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - apiKey: 'your-api-key', - authUrl: 'https://lon.identity.api.hpcloud.com' + password: 'your-password', + region: 'region-b.geo-1', + authUrl: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/' }); ``` #### region -`region` specifies which region of a service to use. For example, when you authenticate with the global endpoint for compute, you have the option of either `DFW`, `ORD`, or `SYD`. The default region is `DFW`. Previous pkgcloud versions did not let you specify which region you used, so all calls were against `DFW`. +`region` specifies which region of a service to use. HP has authentication endpoints specific to each region. +Please see section above for the endpoints and regions. ##### Specifying a custom region @@ -51,14 +66,14 @@ var client = require('pkgcloud').compute.createClient({ var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - apiKey: 'your-api-key', + password: 'your-password', region: 'ORD' }); ``` #### Tokens and Expiration -When you make your first call to a hp provider, your client is authenticated transparent to your API call. hp will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. +When you make your first call to a HP provider, your client is authenticated transparent to your API call. HP will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. #### Internal URLs @@ -68,7 +83,7 @@ As part of the options, you can tell `pkgcloud` to use the Internal (Service Net var client = require('pkgcloud').storage.createClient({ provider: 'hp', username: 'your-user-name', - apiKey: 'your-api-key', + password: 'your-password', useInternal: true }); ``` diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md index f79956dcb..5568d6462 100644 --- a/docs/providers/hp/compute.md +++ b/docs/providers/hp/compute.md @@ -3,7 +3,7 @@ Creating a client is straight-forward: ``` js - var hpCompute = pkgcloud.compute.createClient({ + var HPCompute = pkgcloud.compute.createClient({ provider: 'hp', username: 'your-user-name', password: 'your-password', @@ -115,7 +115,7 @@ Destroys the specified image and returns a confirmation ## Volume Attachments -Attaching a volume to a compute instance requires using a hp compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. +Attaching a volume to a compute instance requires using a HP compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. #### client.getVolumeAttachments(server, callback) diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index d1406ee1f..894277468 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -19,11 +19,11 @@ Creating a client is straight-forward: }); ``` -Learn about [more options for creating clients](README.md) in the Openstack `storage` provider. +Learn about [more options for creating clients](README.md) in the HP `storage` provider. ### Container Model -A Container for Openstack has following properties: +A Container for HP has following properties: ```Javascript { @@ -38,7 +38,7 @@ A Container for Openstack has following properties: ### File Model -A File for Openstack has the following properties: +A File for HP has the following properties: ```Javascript { From 0142269ea1672107f74d0b30415f89904f4e8bdb Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:23:13 -0700 Subject: [PATCH 012/460] Adding links to HP documentation in Readme, updating vocabulary. --- README.md | 36 ++++++++++++++++++++---------------- docs/vocabulary.md | 4 ++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3368d4837..80037a2c1 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,13 @@ Services provided by `pkgcloud` are exposed in two ways: * **By service type:** For example, if you wanted to create an API client to communicate with a compute service you could simply: -``` js +``` js var client = require('pkgcloud').compute.createClient({ // // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -96,12 +96,14 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) + * [HP](docs/providers/hp.md#using-compute) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) * **[Storage](#storage)** * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) + * [HP](docs/providers/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) * **[Database](#databases)** @@ -127,7 +129,7 @@ The `pkgcloud.compute` service is designed to make it easy to provision and work // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -139,6 +141,7 @@ Each compute provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) +* [HP](docs/providers/hp.md#using-compute) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) @@ -174,7 +177,7 @@ To get started with a `pkgcloud.storage` client just create one: // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -185,6 +188,7 @@ Each storage provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) +* [HP](docs/providers/hp.md#using-storage) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) @@ -209,9 +213,9 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ``` js var pkgcloud = require('pkgcloud'), fs = require('fs'); - + var client = pkgcloud.storage.createClient({ /* ... */ }); - + fs.createReadStream('a-file.txt').pipe(client.upload({ container: 'a-container', remote: 'remote-file-name.txt' @@ -222,9 +226,9 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ``` js var pkgcloud = require('pkgcloud'), fs = require('fs'); - + var client = pkgcloud.storage.createClient({ /* ... */ }); - + client.download({ container: 'a-container', remote: 'remote-file-name.txt' @@ -233,7 +237,7 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ## Databases -The `pkgcloud.database` service is designed to consistently work with a variety of Database-as-a-Service (DBaaS) providers. +The `pkgcloud.database` service is designed to consistently work with a variety of Database-as-a-Service (DBaaS) providers. To get started with a `pkgcloud.storage` client just create one: @@ -243,7 +247,7 @@ To get started with a `pkgcloud.storage` client just create one: // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -285,7 +289,7 @@ To get started with a `pkgcloud.dns` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -326,7 +330,7 @@ To get started with a `pkgcloud.blockstorage` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -367,7 +371,7 @@ To get started with a `pkgcloud.loadbalancer` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -435,13 +439,13 @@ Also you can run the tests directly using `mocha` with `hock` enabled: ``` bash Linux/Mac - Mocha installed globally: $ MOCK=on mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js - + Linux/Mac - Mocha installed locally: $ MOCK=on node_modules/.bin/mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js Windows - Mocha installed globally: $ set MOCK=on&mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js - + Windows - Mocha installed locally: $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/*/*/*-test.js test/*/*/*/*-test.js ``` @@ -457,7 +461,7 @@ Linux/Mac - Mocha installed locally: Windows - Mocha installed globally: $ set MOCK=on&mocha -R spec test/iriscouch/*/*-test.js - + Windows - Mocha installed locally: $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/iriscouch/*/*-test.js diff --git a/docs/vocabulary.md b/docs/vocabulary.md index f6c2d6a33..053c545a5 100644 --- a/docs/vocabulary.md +++ b/docs/vocabulary.md @@ -13,6 +13,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis Azure Rackspace DigitalOcean + HP Server @@ -22,6 +23,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis Virtual Machine Server Droplet + Server Image @@ -31,6 +33,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis Image Image Image + Image Flavor @@ -40,6 +43,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis RoleSize Flavor Size + Flavor From e37775e336b4b31522081cbaf8b07313fe73f2e8 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:26:17 -0700 Subject: [PATCH 013/460] Fixing hyperlinks. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80037a2c1..8378a9699 100644 --- a/README.md +++ b/README.md @@ -96,14 +96,14 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) - * [HP](docs/providers/hp.md#using-compute) + * [HP](docs/providers/compute.md) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) * **[Storage](#storage)** * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) - * [HP](docs/providers/storage.md) + * [HP](docs/providers/hp/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) * **[Database](#databases)** From 8ed2f9ef297c3c07004288e6a99c9593cae8f2e4 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:28:19 -0700 Subject: [PATCH 014/460] Fixing links in top-level readme. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8378a9699..1a6c86762 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Each compute provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) -* [HP](docs/providers/hp.md#using-compute) +* [HP](docs/providers/hp/compute.md) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) @@ -188,7 +188,7 @@ Each storage provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) -* [HP](docs/providers/hp.md#using-storage) +* [HP](docs/providers/hp/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) From 7e67064656e28099af13b2dc2600ab9cb38efa3d Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:31:51 -0700 Subject: [PATCH 015/460] Adding using compute example. --- docs/providers/hp/getting-started-compute.md | 97 ++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 docs/providers/hp/getting-started-compute.md diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md new file mode 100644 index 000000000..092dda9c7 --- /dev/null +++ b/docs/providers/hp/getting-started-compute.md @@ -0,0 +1,97 @@ +# Getting started with pkgcloud & HP + +The HP node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package + +Pkgcloud currently supports Openstack Nova (compute) and Openstack Swift (storage). + +To install `pkgcloud` from the command line: + +``` +npm install pkgcloud +``` + +Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). + +## Using pkgcloud + +In this example, we're going to create a HP Cloud compute client, create two servers, and then output their details to the command line. + +*Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* + +```Javascript +var pkgcloud = require('pkgcloud'), + _ = require('underscore'); + +// create our client with your openstack credentials +var client = pkgcloud.compute.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region of identity service', + authUrl: 'https://your-identity-service' +}); + +// first we're going to get our flavors +client.getFlavors(function (err, flavors) { + if (err) { + console.dir(err); + return; + } + + // then get our base images + client.getImages(function (err, images) { + if (err) { + console.dir(err); + return; + } + + // Pick a 512MB instance flavor + var flavor = _.findWhere(flavors, { name: '512MB Standard Instance' }); + + // Pick an image based on Ubuntu 12.04 + var image = _.findWhere(images, { name: 'Ubuntu 12.04 LTS (Precise Pangolin)' }); + + // Create our first server + client.createServer({ + name: 'server1', + image: image, + flavor: flavor + }, handleServerResponse); + + // Create our second server + client.createServer({ + name: 'server2', + image: image, + flavor: flavor + }, handleServerResponse); + }); +}); + +// This function will handle our server creation, +// as well as waiting for the server to come online after we've +// created it. +function handleServerResponse(err, server) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); + + // Wait for status: ACTIVE on our server, and then callback + server.setWait({ status: 'ACTIVE' }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER INFO'); + console.log(server.name); + console.log(server.status); + console.log(server.id); + + console.log('Make sure you DELETE server: ' + server.id + + ' in order to not accrue billing charges'); + }); +} +``` From d3b58bb5b7150049508dfc97d12c239725c7008f Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:33:00 -0700 Subject: [PATCH 016/460] More links in the home page. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a6c86762..223991102 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) - * [HP](docs/providers/compute.md) + * [HP](docs/providers/hp/compute.md) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) From e1074024ebc5612421d5cdad5638cbadc9e59963 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 14:38:57 -0700 Subject: [PATCH 017/460] Adding tests for region detection and automatic identity service location. --- lib/pkgcloud/hp/client.js | 52 ++++++++++++ lib/pkgcloud/hp/compute/client/index.js | 26 ++++++ lib/pkgcloud/hp/compute/index.js | 16 ++++ lib/pkgcloud/hp/identity/hpIdentity.js | 50 +++++++++++ lib/pkgcloud/hp/identity/index.js | 9 ++ lib/pkgcloud/hp/index.js | 9 +- lib/pkgcloud/hp/storage/client/index.js | 29 +++++++ lib/pkgcloud/hp/storage/index.js | 15 ++++ test/hp/common/client-test.js | 106 ++++++++++++++++++++++++ 9 files changed, 308 insertions(+), 4 deletions(-) create mode 100644 lib/pkgcloud/hp/client.js create mode 100644 lib/pkgcloud/hp/compute/client/index.js create mode 100644 lib/pkgcloud/hp/compute/index.js create mode 100644 lib/pkgcloud/hp/identity/hpIdentity.js create mode 100644 lib/pkgcloud/hp/identity/index.js create mode 100644 lib/pkgcloud/hp/storage/client/index.js create mode 100644 lib/pkgcloud/hp/storage/index.js create mode 100644 test/hp/common/client-test.js diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js new file mode 100644 index 000000000..d89f5eb54 --- /dev/null +++ b/lib/pkgcloud/hp/client.js @@ -0,0 +1,52 @@ +/* + * client.js: Base client from which all HP clients inherit from + * + * (C) 2014 HP. + * + */ + +var utile = require('utile'), + identity = require('./identity'), + base = require('../openstack/client'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + options = options || {}; + var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1', + eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/', + westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'; + if(!options.region){ + throw new Error('region is not valid. Available regions are '+westUSRegion+' (US-West), '+eastUSRegion+'(US-East)'); + } + + if(!options.authUrl || options.authUrl.length === 0) { + if(options.region === eastUSRegion){ + options.authUrl = eastUSIdentityService; + } + else if(options.region === westUSRegion){ + options.authUrl = westUSIdentityService; + } + else{ + throw new Error('authUrl is invalid'); + } + } + + options.identity = identity.Identity; + + if (typeof options.useServiceCatalog === 'undefined') { + options.useServiceCatalog = true; + } + + base.Client.call(this, options); + + this.provider = 'hp'; +}; + +utile.inherits(Client, base.Client); + +Client.prototype._getIdentityOptions = function() { + + return _.extend({ + apiKey: this.config.apiKey + }, Client.super_.prototype._getIdentityOptions.call(this)); +}; diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js new file mode 100644 index 000000000..9bc012852 --- /dev/null +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -0,0 +1,26 @@ +/* + * client.js: Compute client for HP Cloudservers + * + * (C) 2014 HP + * Phani Raj + * + */ + +var utile = require('utile'), + hp = require('../../client'), + ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, + _ = require('underscore'); + +var Client = exports.Client = function (options) { + hp.Client.call(this, options); + debugger; + utile.mixin(this, require('../../../openstack/compute/client/flavors')); + utile.mixin(this, require('../../../openstack/compute/client/images')); + utile.mixin(this, require('../../../openstack/compute/client/servers')); + utile.mixin(this, require('../../../openstack/compute/client/extensions')); + + this.serviceType = 'compute'; +}; + +utile.inherits(Client, hp.Client); +_.extend(Client.prototype, ComputeClient.prototype); diff --git a/lib/pkgcloud/hp/compute/index.js b/lib/pkgcloud/hp/compute/index.js new file mode 100644 index 000000000..486ee5bb1 --- /dev/null +++ b/lib/pkgcloud/hp/compute/index.js @@ -0,0 +1,16 @@ + /* + * index.js: Top-level include for the Rackspace storage module + * + * (C) 2014 HP + * Phani Raj + * + */ + +exports.Client = require('./client').Client; +exports.Flavor = require('../../openstack/compute/flavor').Flavor; +exports.Image = require('../../openstack/compute/image').Image; +exports.Server = require('../../openstack/compute/server').Server; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/hp/identity/hpIdentity.js b/lib/pkgcloud/hp/identity/hpIdentity.js new file mode 100644 index 000000000..25ea38511 --- /dev/null +++ b/lib/pkgcloud/hp/identity/hpIdentity.js @@ -0,0 +1,50 @@ +/* + * hpIdentity.js: hpIdentity model + * + * (C) 2014 HP + * Phani Raj + * + */ + +var _ = require('underscore'), + identity = require('../../openstack/context'), + events = require('eventemitter2'), + Identity = identity.Identity, + util = require('util'); + +exports.Identity = HPIdentity = function (options) { + this.options = options; + this.name = 'HPIdentity'; + + this.useServiceCatalog = (typeof options.useServiceCatalog === 'boolean') + ? options.useServiceCatalog + : true; + + events.EventEmitter2.call(this, { delimiter: '::', wildcard: true }); +}; + +util.inherits(HPIdentity, events.EventEmitter2); +util.inherits(HPIdentity, Identity); + +HPIdentity.prototype._buildAuthenticationPayload = function () { + var self = this; + + HPIdentity.super_.prototype._buildAuthenticationPayload.call(this); + + this.emit('log::trace', 'Building HP Identity Auth Payload'); + + if (!self._authenticationPayload) { + // setup our inputs for authorization + // access key & secret key + if (self.options.apiKey && self.options.username) { + self._authenticationPayload = { + auth: { + 'apiAccessKeyCredentials': { + 'accessKey': self.options.username, + 'secretKey': self.options.apiKey + } + } + }; + } + } +}; diff --git a/lib/pkgcloud/hp/identity/index.js b/lib/pkgcloud/hp/identity/index.js new file mode 100644 index 000000000..9465530d1 --- /dev/null +++ b/lib/pkgcloud/hp/identity/index.js @@ -0,0 +1,9 @@ +/* + * index.js: Identity models + * + * (C) 2014 HP + * Phani Raj + * + */ + +module.exports = require('./hpIdentity'); diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js index 2cd7883a3..2b23bc93c 100644 --- a/lib/pkgcloud/hp/index.js +++ b/lib/pkgcloud/hp/index.js @@ -1,9 +1,10 @@ /* - * index.js: Top-level include for the HP provider. + * index.js: Top-level include for the HP module. * - * (C) 2014 HP Inc. + * (C) 2014 HP + * Phani Raj * */ -exports.compute = require('../openstack/compute'); -exports.storage = require('../openstack/storage'); +exports.storage = require('./storage'); +exports.compute = require('./compute'); diff --git a/lib/pkgcloud/hp/storage/client/index.js b/lib/pkgcloud/hp/storage/client/index.js new file mode 100644 index 000000000..123f31345 --- /dev/null +++ b/lib/pkgcloud/hp/storage/client/index.js @@ -0,0 +1,29 @@ +/* + * index.js: Storage client for HP Cloudservers + * + * (C) 2014 HP + * Phani Raj + * + */ + +var utile = require('utile'), + hp = require('../../client'), + StorageClient = require('../../../openstack/storage/storageClient').StorageClient, + _ = require('underscore'); + +var Client = exports.Client = function (options) { + hp.Client.call(this, options); + + this.models = { + Container: require('../../../openstack/storage/container').Container, + File: require('../../../openstack/storage/file').File + }; + + utile.mixin(this, require('../../../openstack/storage/client/containers')); + utile.mixin(this, require('../../../openstack/storage/client/files')); + + this.serviceType = 'object-store'; +}; + +utile.inherits(Client, hp.Client); +_.extend(Client.prototype, StorageClient.prototype); diff --git a/lib/pkgcloud/hp/storage/index.js b/lib/pkgcloud/hp/storage/index.js new file mode 100644 index 000000000..44df5611d --- /dev/null +++ b/lib/pkgcloud/hp/storage/index.js @@ -0,0 +1,15 @@ + /* + * index.js: Top-level include for the HP storage module + * + * (C) 2014 HP + * Phani Raj + * + */ + +exports.Client = require('./client').Client; +exports.Container = require('../../openstack/storage/container').Container; +exports.File = require('../../openstack/storage/file').File; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js new file mode 100644 index 000000000..db3c981f2 --- /dev/null +++ b/test/hp/common/client-test.js @@ -0,0 +1,106 @@ +/* +* client-test.js: Tests for pkgcloud HP client functionality. +* +* (C) 2014 Phani Raj. +* +*/ + +var should = require('should'), + async = require('async'), + hock = require('hock'), + pkgcloud = require('../../../lib/pkgcloud'), + mock = !!process.env.MOCK; + +describe('pkgcloud/hp/client', function () { + describe('Region validation', function () { + var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1'; + it('User should specify region: compute client', function() { + (function () { + pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password" + }); + }).should.throw(new Error("region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)');")); + }); + + it('User should specify region: storage client', function() { + (function () { + pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password" + }); + }).should.throw(new Error("region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)');")); + }); + + + it('User can specify custom region: storage client', function() { + var customRegionClient = pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": "mycustomregion", + "authUrl": "http://my-identity-service.com" + }); + + customRegionClient.config.should.have.property('region','mycustomregion'); + }); + + it('User can specify custom region: compute client', function() { + var customRegionClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": "mycustomregion", + "authUrl": "http://my-identity-service.com" + }); + + customRegionClient.config.should.have.property('region','mycustomregion'); + }); + + it('Client will auto-locate identity service for East US region : compute client', function() { + var eastUSClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": eastUSRegion + }); + + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + + it('Client will auto-locate identity service for East US region : storage client', function() { + var eastUSClient = pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": eastUSRegion + }); + + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + + it('Client will auto-locate identity service for West US region : compute client', function() { + var westUSClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": westUSRegion + }); + + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + + it('Client will auto-locate identity service for West US region : storage client', function() { + var westUSClient = pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": westUSRegion + }); + + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + }); +}); From 7e1de968e2aa5ffdd81c58bf1278718e5f52e364 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 14:46:23 -0700 Subject: [PATCH 018/460] Moving HP provider tests to use api key and user name. --- test/common/compute/base-test.js | 14 +++++++------- test/common/compute/server-test.js | 12 ++++++------ test/common/storage/base-test.js | 14 +++++++------- test/configs/mock/hp.json | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 82be22039..4878b2077 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -66,7 +66,7 @@ providers.forEach(function(provider) { server: server }); } - + if (errors) { client.getVersion(function (err) { err.should.be.an.instanceof(Error); @@ -264,9 +264,9 @@ function setupVersionMock(client, provider, servers) { servers.authServer .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' } } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) @@ -275,9 +275,9 @@ function setupVersionMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index bc01948e0..acddd558f 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -300,9 +300,9 @@ function setupImagesMock(client, provider, servers) { servers.authServer .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' } } }) @@ -311,9 +311,9 @@ function setupImagesMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 9e1aa4a6e..0b8c35e36 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -516,9 +516,9 @@ function setupCreateContainerMock(provider, client, servers) { servers.authServer .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' } } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) @@ -527,9 +527,9 @@ function setupCreateContainerMock(provider, client, servers) { .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } @@ -758,4 +758,4 @@ function setupGetContainers2Mock(provider, client, servers) { .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/preContainers.json')); } -} \ No newline at end of file +} diff --git a/test/configs/mock/hp.json b/test/configs/mock/hp.json index 5a48bef79..2d1a6b796 100644 --- a/test/configs/mock/hp.json +++ b/test/configs/mock/hp.json @@ -1,6 +1,6 @@ { "username":"MOCK-USERNAME", - "password":"MOCK-PASSWORD", + "apiKey": "MOCK-API-KEY", "authUrl":"http://localhost:12346", "region": "Calxeda-AUS1" } From 58a147a649f92ad9c9fe969891a5fa2f5a6ea1eb Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 14:50:34 -0700 Subject: [PATCH 019/460] Fixing auto detection of Identity service endpoint to be version agnostic. --- lib/pkgcloud/hp/client.js | 4 ++-- test/hp/common/client-test.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index d89f5eb54..d52d22228 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -13,8 +13,8 @@ var utile = require('utile'), var Client = exports.Client = function (options) { options = options || {}; var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1', - eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/', - westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'; + eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/', + westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/'; if(!options.region){ throw new Error('region is not valid. Available regions are '+westUSRegion+' (US-West), '+eastUSRegion+'(US-East)'); } diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js index db3c981f2..ecfed2627 100644 --- a/test/hp/common/client-test.js +++ b/test/hp/common/client-test.js @@ -67,7 +67,7 @@ describe('pkgcloud/hp/client', function () { "region": eastUSRegion }); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); }); it('Client will auto-locate identity service for East US region : storage client', function() { @@ -78,7 +78,7 @@ describe('pkgcloud/hp/client', function () { "region": eastUSRegion }); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); }); it('Client will auto-locate identity service for West US region : compute client', function() { @@ -89,7 +89,7 @@ describe('pkgcloud/hp/client', function () { "region": westUSRegion }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); }); it('Client will auto-locate identity service for West US region : storage client', function() { @@ -100,7 +100,7 @@ describe('pkgcloud/hp/client', function () { "region": westUSRegion }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); }); }); }); From 2581773f53465b64e59dff4fde8aab04bf31123a Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 19:25:29 -0700 Subject: [PATCH 020/460] Adding tests for secret key authentication with HP Cloud Compute client. --- test/common/storage/base-test.js | 2 +- test/configs/mock/hp.json | 2 +- test/fixtures/hp/images.json | 2 +- test/fixtures/hp/realToken-admin.json | 16 +- .../hp/realToken-multiRegionVolume.json | 18 +- test/fixtures/hp/realToken.json | 18 +- test/hp/compute/authentication-test.js | 228 ++++++++++++++++++ test/hp/macros.js | 108 +++++++++ 8 files changed, 365 insertions(+), 29 deletions(-) create mode 100644 test/hp/compute/authentication-test.js create mode 100644 test/hp/macros.js diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 0b8c35e36..5746460d9 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -534,7 +534,7 @@ function setupCreateContainerMock(provider, client, servers) { tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers.getOpenstackAuthResponse()); + .reply(200, helpers.gethpAuthResponse()); servers.server .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') diff --git a/test/configs/mock/hp.json b/test/configs/mock/hp.json index 2d1a6b796..e9081e7b2 100644 --- a/test/configs/mock/hp.json +++ b/test/configs/mock/hp.json @@ -2,5 +2,5 @@ "username":"MOCK-USERNAME", "apiKey": "MOCK-API-KEY", "authUrl":"http://localhost:12346", - "region": "Calxeda-AUS1" + "region": "region-a.geo-1" } diff --git a/test/fixtures/hp/images.json b/test/fixtures/hp/images.json index cf05cf7ec..f5f75adb9 100644 --- a/test/fixtures/hp/images.json +++ b/test/fixtures/hp/images.json @@ -25,4 +25,4 @@ "metadata": {} } ] -} \ No newline at end of file +} diff --git a/test/fixtures/hp/realToken-admin.json b/test/fixtures/hp/realToken-admin.json index 3526ee0f2..f3548289c 100644 --- a/test/fixtures/hp/realToken-admin.json +++ b/test/fixtures/hp/realToken-admin.json @@ -15,7 +15,7 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } @@ -27,11 +27,11 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:9292/v1", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:9292/v1", "publicURL": "http://image.myownendpoint.org:9292/v1" } - ], + ], "endpoints_links": [], "type": "image", "name": "glance" @@ -39,19 +39,19 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "compute", "name": "nova" }, { "endpoints": [ { "adminURL": "http://localhost:12347/v2.0", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:5000/v2.0", "publicURL": "http://identity.myownendpoint.org:5000/v2.0" } @@ -69,4 +69,4 @@ "name": "MOCK-ADMIN" } } -} \ No newline at end of file +} diff --git a/test/fixtures/hp/realToken-multiRegionVolume.json b/test/fixtures/hp/realToken-multiRegionVolume.json index 88df5a1c0..db2af928e 100644 --- a/test/fixtures/hp/realToken-multiRegionVolume.json +++ b/test/fixtures/hp/realToken-multiRegionVolume.json @@ -15,13 +15,13 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" }, { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS2", + "region": "region-b.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } @@ -33,11 +33,11 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:9292/v1", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:9292/v1", "publicURL": "http://image.myownendpoint.org:9292/v1" } - ], + ], "endpoints_links": [], "type": "image", "name": "glance" @@ -45,19 +45,19 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "compute", "name": "nova" }, { "endpoints": [ { "adminURL": "http://10.225.0.8:35357/v2.0", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:5000/v2.0", "publicURL": "http://identity.myownendpoint.org:5000/v2.0" } @@ -75,4 +75,4 @@ "name": "MOCK-USERNAME" } } -} \ No newline at end of file +} diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 2636f092e..278c3b9f1 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -15,7 +15,7 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } @@ -27,11 +27,11 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:9292/v1", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:9292/v1", "publicURL": "http://image.myownendpoint.org:9292/v1" } - ], + ], "endpoints_links": [], "type": "image", "name": "glance" @@ -39,19 +39,19 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "compute", "name": "nova" }, { "endpoints": [ { - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "tenantId": "MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", "publicURL": "http://localhost:12345/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" @@ -64,7 +64,7 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:35357/v2.0", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:5000/v2.0", "publicURL": "http://identity.myownendpoint.org:5000/v2.0" } @@ -82,4 +82,4 @@ "name": "MOCK-USERNAME" } } -} \ No newline at end of file +} diff --git a/test/hp/compute/authentication-test.js b/test/hp/compute/authentication-test.js new file mode 100644 index 000000000..6dd31b4c4 --- /dev/null +++ b/test/hp/compute/authentication-test.js @@ -0,0 +1,228 @@ +/* +* authentication-test.js: Tests for pkgcloud hp compute authentication +* +* (C) 2014 HP. +* +*/ + +var should = require('should'), + async = require('async'), + hock = require('hock'), + macros = require('../macros'), + helpers = require('../../helpers'), + mock = !!process.env.MOCK; + +describe('pkgcloud/hp/compute/authentication', function () { + var client, authServer, server; + + describe('The pkgcloud hp Compute client', function () { + + before(function (done) { + client = helpers.createClient('hp', 'compute'); + + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + hock.createHock(12346, function (err, hockClient) { + should.not.exist(err); + should.exist(hockClient); + + authServer = hockClient; + next(); + }); + }, + function (next) { + hock.createHock(12345, function (err, hockClient) { + should.not.exist(err); + should.exist(hockClient); + + server = hockClient; + next(); + }); + } + ], done); + }); + + it('should have core methods defined', function() { + macros.shouldHaveCreds(client); + }); + + describe('the auth() method with a valid username and api key', function () { + var err, res; + + beforeEach(function (done) { + + client = helpers.createClient('hp', 'compute'); + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + + client.auth(function (e) { + should.not.exist(e); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function () { + client._identity.should.be.a('object'); + }); + }); + + describe('the auth() method with an invalid username and api key', function () { + + var badClient = helpers.createClient('hp', 'compute', { + username: 'fake', + apiKey: 'data', + authUrl: 'localhost:12346', + protocol: 'http://', + region: 'custom region' + }); + + var err, res; + + beforeEach(function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'fake', + secretKey: 'data' + } + } + }) + .reply(401, { + unauthorized: { + message: 'Username or api key is invalid', code: 401 + } + }); + } + + badClient.auth(function (e) { + err = e; + authServer && authServer.done(); + done(); + }); + + }); + + it('should respond with Error code 401', function () { + should.exist(err); + // TODO resolve identity responses + }); + }); + + describe('auth tokens should expire', function () { + var tokenExpiry; + + beforeEach(function (done) { + + client = helpers.createClient('hp', 'compute'); + + client.on('log::*', function(message, obj) { + if (this.event !== 'log::trace') { + console.log(message); + console.dir(obj); + } + }); + + if (mock) { + + var response = helpers.gethpAuthResponse(new Date(new Date().getTime() + 1)); + + tokenExpiry = response.access.token.expires; + + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, response); + } + + client.auth(function (e) { + should.not.exist(e); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function () { + client._identity.should.be.a('object'); + client._identity.token.expires.toString().should.equal(tokenExpiry); + }); + + it('should expire the token and set authorized to false', function(done) { + setTimeout(function() { + client._isAuthorized().should.equal(false); + done(); + }, 5); + }); + + it('should expire the token and reauth on next call', function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + + server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); + } + + setTimeout(function () { + client._isAuthorized().should.equal(false); + client.getImages(function(err, images) { + client._isAuthorized().should.equal(true); + should.not.exist(err); + should.exist(images); + server && server.done(); + authServer && authServer.done(); + done(); + }); + }, 5); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + }); +}); diff --git a/test/hp/macros.js b/test/hp/macros.js new file mode 100644 index 000000000..89bbc1341 --- /dev/null +++ b/test/hp/macros.js @@ -0,0 +1,108 @@ +/* + * macros.js: Tests macros for Rackspace + * + * (C) 2011 Nodejitsu Inc. + * + */ + +var fs = require('fs'), + filed = require('filed'), + assert = require('../helpers/assert'), + should = require('should'), + helpers = require('../helpers'), + mock = !!process.env.MOCK; + +exports.shouldHaveCreds = function (client) { + return function () { + assert.isObject(client.config); + assert.include(client.config, 'username'); + assert.include(client.config, 'apiKey'); + + assert.isFunction(client.auth); + } +}; + +exports.shouldCreateContainer = function (client, name, message) { + message = message || "when creating a container"; + + var context = {}; + context[message] = { + topic: function () { + client.createContainer(name, this.callback); + }, + "should return a valid container": function (err, container) { + assert.isNull(err); + assert.assertContainer(container); + } + }; + + return { + "The pkgcloud Rackspace storage client": { + "the createContainer() method": context + } + }; +}; + +exports.shouldDestroyContainer = function (client, name) { + return { + "The pkgcloud Rackspace storage client": { + "the destroyContainer() method": { + topic: function () { + client.destroyContainer(name, this.callback) + }, + "should return true": function (err, success) { + assert.isTrue(success); + } + } + } + }; +}; + +exports.upload = {}; + +exports.upload.fullpath = function (client, options) { + return { + topic: function () { + client.upload(options, function () { }) + .on('end', this.callback); + }, + "should raise the `end` event": function () { + assert.isTrue(true); + } + } +}; + +exports.upload.stream = function (client, container, local, remote) { + return { + topic: function () { + client.upload({ + container: container, + remote: remote, + stream: fs.createReadStream(local), + headers: { + 'content-length': fs.statSync(local).size + } + }, function () { }).on('end', this.callback); + }, + "should raise the `end` event": function () { + assert.isTrue(true); + } + } +}; + +exports.upload.piped = function (client, container, local, remote) { + return { + topic: function () { + var ustream = client.upload({ + container: container, + remote: remote + }, function () { }); + + filed(local).pipe(ustream); + ustream.on('end', this.callback) + }, + "should raise the `end` event": function () { + assert.isTrue(true); + } + } +}; From e4ba856dbf2cc2d1b283bc911edac38102855207 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 19:31:03 -0700 Subject: [PATCH 021/460] Adding unit tests for access key authentication with HP Cloud storage service. --- test/hp/storage/authentication-test.js | 157 +++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 test/hp/storage/authentication-test.js diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js new file mode 100644 index 000000000..f902d4de7 --- /dev/null +++ b/test/hp/storage/authentication-test.js @@ -0,0 +1,157 @@ +/* +* authentication-test.js: Tests for pkgcloud hp storage authentication +* +* (C) 2010 Nodejitsu Inc. +* +*/ + +var should = require('should'), + macros = require('../macros'), + helpers = require('../../helpers'), + async = require('async'), + hock = require('hock'), + mock = !!process.env.MOCK; + +describe('pkgcloud/hp/storage/authentication', function () { + describe('The pkgcloud hp Storage client', function () { + it('should have core methods defined', function() { + var client = helpers.createClient('hp', 'storage'); + macros.shouldHaveCreds(client); + }); + + describe('the auth() method', function() { + describe('with a valid user name and api key', function() { + var authServer; + + before(function(done) { + if (!mock) { + return done(); + } + + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + done(); + }); + }); + + it('should respond with 204 and appropriate info', function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + + var client = helpers.createClient('hp', 'storage'); + + client.auth(function (err) { + should.not.exist(err); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function (done) { + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + + var client = helpers.createClient('hp', 'storage'); + + client.auth(function (err) { + should.not.exist(err); + authServer && authServer.done(); + done(); + }); + }); + + after(function(done) { + if (authServer) { + authServer.close(function () { + done(); + }); + } + else { + done(); + } + }); + }); + + describe('with an invalid user name and api key shouldn\'t authenticate', function () { + var authServer; + + before(function (done) { + if (!mock) { + return done(); + } + + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + done(); + }); + }); + + it('should respond with 401 unauthorized', function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'fake', + secretKey: 'data' + } + } + }) + .reply(401, { + unauthorized: { + message: 'accessKey or api key is invalid', code: 401 + } + }); + } + + var badClient = helpers.createClient('hp', 'compute', { + username: 'fake', + apiKey: 'data', + authUrl: 'localhost:12346', + protocol: 'http://', + region: 'region-a.geo-1' + }); + + badClient.auth(function (err, res) { + should.exist(err); + authServer && authServer.done(); + done(); + }); + }); + + after(function (done) { + if (authServer) { + authServer.close(function () { + done(); + }); + } + else { + done(); + } + }); + }); + }); + }); +}); From a9068c15711ac70281e3a22a19cdb00a2e2e6484 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 19:40:36 -0700 Subject: [PATCH 022/460] Fixing copyright header. --- test/hp/storage/authentication-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index f902d4de7..34ac0c102 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud hp storage authentication * -* (C) 2010 Nodejitsu Inc. +* (C) 2014 HP. * */ From ecec8889add270915c0e8199c0255c2f62953b96 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 09:52:02 -0700 Subject: [PATCH 023/460] Code review changes. 1. Changed Compute Server to Cloud Compute 2. Changed copyright header. 3. Changed MossCloudFs to HPCloudFS in the tests. 4. Changed Cloud storage to object storage. --- docs/providers/hp/README.md | 4 ++-- docs/providers/hp/storage.md | 4 ++-- test/common/storage/base-test.js | 24 ++++++++++++------------ test/fixtures/hp/realToken.json | 6 +++--- test/hp/compute/authentication-test.js | 2 +- test/hp/storage/authentication-test.js | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 5b40a7a9a..66b24fc7c 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -2,8 +2,8 @@ The HP Cloud provider in pkgcloud supports the following services: -* [**Compute**](compute.md) (Cloud Servers) -* [**Storage**](storage.md) (Cloud Files) +* [**Compute**](compute.md) (cloud compute) +* [**Storage**](storage.md) (object storage) ### Getting Started with Compute diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index 894277468..bafd60b2f 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -1,4 +1,4 @@ -## Using the HP Storage provider +## Using the HP Object Storage provider * Container * [Model](#container-model) @@ -283,7 +283,7 @@ Removes the provided [`file`](#file-model) from the provided [`container`](#cont Updates the [`file`](#file-model) metadata in the the provided [`container`](#container-model). -File metadata is completely replaced with each callt o updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`. +File metadata is completely replaced with each call to updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`. ```javascript file.metadata = { campaign = '2011 website' diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 5746460d9..b1ef2733c 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -433,7 +433,7 @@ providers.filter(function (provider) { }); }); -function setupCreateContainerMock(provider, client, servers) { + function setupCreateContainerMock(provider, client, servers) { if (provider === 'rackspace') { servers.authServer .post('/v2.0/tokens', { @@ -537,7 +537,7 @@ function setupCreateContainerMock(provider, client, servers) { .reply(200, helpers.gethpAuthResponse()); servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') .reply(201); } } @@ -560,7 +560,7 @@ function setupGetContainersMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/postContainers.json')); } } @@ -585,7 +585,7 @@ function setupUploadStreamMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) .reply(200) } } @@ -608,7 +608,7 @@ function setupDownloadStreamMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(200, fillerama, { 'content-length': fillerama.length + 2}) } } @@ -631,7 +631,7 @@ function setupGetFileMock(provider, client, servers) { } if (provider === 'hp') { servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') .reply(200, '', { 'content-length': fillerama.length + 2 }) } } @@ -658,7 +658,7 @@ function setupGetFilesMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') .reply(200, [{ bytes: fillerama.length, name: 'test-file.txt', @@ -685,7 +685,7 @@ function setupRemoveFileMock(provider, client, servers) { } if (provider === 'hp') { servers.server - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(204, ''); } } @@ -722,7 +722,7 @@ function setupDestroyContainerMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') .reply(200, [ { bytes: fillerama.length, @@ -730,9 +730,9 @@ function setupDestroyContainerMock(provider, client, servers) { content_type: 'text/plain' } ]) - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(204, '') - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') .reply(204); } } @@ -755,7 +755,7 @@ function setupGetContainers2Mock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/preContainers.json')); } } diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 278c3b9f1..736af37b5 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -52,9 +52,9 @@ "endpoints": [ { "region": "region-a.geo-1", - "tenantId": "MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", - "publicURL": "http://localhost:12345/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", - "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" + "tenantId": "HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "publicURL": "http://localhost:12345/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" } ], "name": "swift", diff --git a/test/hp/compute/authentication-test.js b/test/hp/compute/authentication-test.js index 6dd31b4c4..6a789627c 100644 --- a/test/hp/compute/authentication-test.js +++ b/test/hp/compute/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud hp compute authentication * -* (C) 2014 HP. +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index 34ac0c102..fb82528cd 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud hp storage authentication * -* (C) 2014 HP. +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ From f9e2d8951420ff4f52e4fbef66862eb243e22d99 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 10:06:34 -0700 Subject: [PATCH 024/460] More code review changes: 1. Updated samples to use HP flavor and image names. 2. Fixed Region names in documentation. --- docs/providers/hp/README.md | 2 +- docs/providers/hp/getting-started-compute.md | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 66b24fc7c..9fa92491b 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -67,7 +67,7 @@ var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', password: 'your-password', - region: 'ORD' + region: 'region-a.custom.corp' }); ``` diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md index 092dda9c7..e25b01949 100644 --- a/docs/providers/hp/getting-started-compute.md +++ b/docs/providers/hp/getting-started-compute.md @@ -2,7 +2,7 @@ The HP node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package -Pkgcloud currently supports Openstack Nova (compute) and Openstack Swift (storage). +Pkgcloud currently supports HP Cloud Nova (cloud compute) and HP Cloud Swift (object-storage). To install `pkgcloud` from the command line: @@ -14,7 +14,7 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). ## Using pkgcloud -In this example, we're going to create a HP Cloud compute client, create two servers, and then output their details to the command line. +In this example, we're going to create a HP Cloud Compute client, create two servers, and then output their details to the command line. *Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* @@ -45,11 +45,12 @@ client.getFlavors(function (err, flavors) { return; } - // Pick a 512MB instance flavor - var flavor = _.findWhere(flavors, { name: '512MB Standard Instance' }); + // Pick a medium instance flavor + // see here for more instance flavors: http://www.hpcloud.com/products-services/hp-cloud-compute-13_5 + var flavor = _.findWhere(flavors, { name: 'standard.medium' }); - // Pick an image based on Ubuntu 12.04 - var image = _.findWhere(images, { name: 'Ubuntu 12.04 LTS (Precise Pangolin)' }); + // Pick an image based on CentOS 6.3 + var image = _.findWhere(images, { name: 'CentOS 6.3 Server 64-bit 20130116' }); // Create our first server client.createServer({ From b342b3b371429752f19f5d6f3bb75a2746113541 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 10:46:30 -0700 Subject: [PATCH 025/460] Removed auth url auto detection for region as it would break private clouds. And will break when we introduce more regions. --- lib/pkgcloud/hp/client.js | 17 +---------- test/hp/common/client-test.js | 54 +++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index d52d22228..e0dcd071c 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -12,25 +12,10 @@ var utile = require('utile'), var Client = exports.Client = function (options) { options = options || {}; - var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1', - eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/', - westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/'; - if(!options.region){ - throw new Error('region is not valid. Available regions are '+westUSRegion+' (US-West), '+eastUSRegion+'(US-East)'); - } - if(!options.authUrl || options.authUrl.length === 0) { - if(options.region === eastUSRegion){ - options.authUrl = eastUSIdentityService; - } - else if(options.region === westUSRegion){ - options.authUrl = westUSIdentityService; - } - else{ + if(!options.authUrl){ throw new Error('authUrl is invalid'); - } } - options.identity = identity.Identity; if (typeof options.useServiceCatalog === 'undefined') { diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js index ecfed2627..1af01beca 100644 --- a/test/hp/common/client-test.js +++ b/test/hp/common/client-test.js @@ -12,6 +12,7 @@ var should = require('should'), mock = !!process.env.MOCK; describe('pkgcloud/hp/client', function () { + describe('Region validation', function () { var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1'; it('User should specify region: compute client', function() { @@ -58,49 +59,60 @@ describe('pkgcloud/hp/client', function () { customRegionClient.config.should.have.property('region','mycustomregion'); }); + }); - it('Client will auto-locate identity service for East US region : compute client', function() { - var eastUSClient = pkgcloud.compute.createClient({ + describe('Private cloud Uri resolution', function () { + var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1'; + it('Client will not resolve URI if useInternal is true : East US',function(){ + (function () { + pkgcloud.compute.createClient({ "provider": "hp", "username": "username", "password": "password", + "useInternal": true, "region": eastUSRegion }); + }).should.throw("authUrl is invalid"); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); }); - it('Client will auto-locate identity service for East US region : storage client', function() { - var eastUSClient = pkgcloud.storage.createClient({ + it('Client will not resolve URI if useInternal is true : West US',function(){ + (function () { + pkgcloud.compute.createClient({ "provider": "hp", "username": "username", "password": "password", - "region": eastUSRegion + "useInternal": true, + "region": westUSRegion }); + }).should.throw("authUrl is invalid"); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); - }); - - it('Client will auto-locate identity service for West US region : compute client', function() { - var westUSClient = pkgcloud.compute.createClient({ + it('User can specify custom url for private cloud : West US',function(){ + var privateClient = pkgcloud.compute.createClient({ "provider": "hp", "username": "username", "password": "password", + "useInternal": true, + "authUrl": "http://my-internal-identity-service.com", "region": westUSRegion }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); - }); + privateClient.config.should.have.property('authUrl','http://my-internal-identity-service.com'); + }); - it('Client will auto-locate identity service for West US region : storage client', function() { - var westUSClient = pkgcloud.storage.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "region": westUSRegion - }); + it('User can specify custom url for private cloud : East US',function(){ + var privateClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "useInternal": true, + "authUrl": "http://my-internal-identity-service.com", + "region": eastUSRegion + }); + + privateClient.config.should.have.property('authUrl','http://my-internal-identity-service.com'); + }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); }); }); }); From c9515695acb0df08d7e22f3288e8cca949789086 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 11:42:55 -0700 Subject: [PATCH 026/460] Updating documentation for HP provider. --- docs/providers/hp/README.md | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 9fa92491b..ea50d485c 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -28,8 +28,8 @@ All of the HP `createClient` calls have a few options that can be provided: #### authUrl `authUrl` specifies the authentication endpoint used to create a token for your HP client. -The HP Identity Service is currently available in two regions which can be accessed via these URLs. See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) +If you're targeting an HP Private Cloud instance, please contact your administrator for the authUrl. ##### Authenticating against the US-West endpoint @@ -57,8 +57,9 @@ var client = require('pkgcloud').compute.createClient({ #### region -`region` specifies which region of a service to use. HP has authentication endpoints specific to each region. -Please see section above for the endpoints and regions. +`region` specifies which region of a service to use. HP has services deployed in multiple regions. +See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) +If you're targeting an HP Private Cloud instance, please contact your administrator for region names. ##### Specifying a custom region @@ -74,18 +75,3 @@ var client = require('pkgcloud').compute.createClient({ #### Tokens and Expiration When you make your first call to a HP provider, your client is authenticated transparent to your API call. HP will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. - -#### Internal URLs - -As part of the options, you can tell `pkgcloud` to use the Internal (Service Net) URLs for a service, if possible. - - ```Javascript - var client = require('pkgcloud').storage.createClient({ - provider: 'hp', - username: 'your-user-name', - password: 'your-password', - useInternal: true - }); - ``` - - This setting is explicit. If you set it to true, and you have no connectivity to the internal URL for a service, your connections will timeout. From ed1ee20df05a530212392e53f4f2d4bea0a46d68 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 11:48:56 -0700 Subject: [PATCH 027/460] Updating copyright header for HP provider files. --- lib/pkgcloud/hp/client.js | 2 +- lib/pkgcloud/hp/compute/client/index.js | 2 +- lib/pkgcloud/hp/compute/index.js | 2 +- lib/pkgcloud/hp/identity/hpIdentity.js | 2 +- lib/pkgcloud/hp/identity/index.js | 2 +- lib/pkgcloud/hp/index.js | 2 +- lib/pkgcloud/hp/storage/client/index.js | 2 +- lib/pkgcloud/hp/storage/index.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index e0dcd071c..8f2d9ee1f 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all HP clients inherit from * - * (C) 2014 HP. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 9bc012852..7130ee6ce 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Compute client for HP Cloudservers * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/compute/index.js b/lib/pkgcloud/hp/compute/index.js index 486ee5bb1..0eef07471 100644 --- a/lib/pkgcloud/hp/compute/index.js +++ b/lib/pkgcloud/hp/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Rackspace storage module * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/identity/hpIdentity.js b/lib/pkgcloud/hp/identity/hpIdentity.js index 25ea38511..7070665b6 100644 --- a/lib/pkgcloud/hp/identity/hpIdentity.js +++ b/lib/pkgcloud/hp/identity/hpIdentity.js @@ -1,7 +1,7 @@ /* * hpIdentity.js: hpIdentity model * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/identity/index.js b/lib/pkgcloud/hp/identity/index.js index 9465530d1..54c592b69 100644 --- a/lib/pkgcloud/hp/identity/index.js +++ b/lib/pkgcloud/hp/identity/index.js @@ -1,7 +1,7 @@ /* * index.js: Identity models * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js index 2b23bc93c..0c6379545 100644 --- a/lib/pkgcloud/hp/index.js +++ b/lib/pkgcloud/hp/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the HP module. * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/storage/client/index.js b/lib/pkgcloud/hp/storage/client/index.js index 123f31345..cc5d8aaed 100644 --- a/lib/pkgcloud/hp/storage/client/index.js +++ b/lib/pkgcloud/hp/storage/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Storage client for HP Cloudservers * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/storage/index.js b/lib/pkgcloud/hp/storage/index.js index 44df5611d..524da3a56 100644 --- a/lib/pkgcloud/hp/storage/index.js +++ b/lib/pkgcloud/hp/storage/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the HP storage module * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ From 1411bea6ae18939ac8360170f44811cf9576dea9 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 11:51:05 -0700 Subject: [PATCH 028/460] Removing more debugger statements --- lib/pkgcloud/hp/compute/client/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 7130ee6ce..345ededed 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -13,7 +13,6 @@ var utile = require('utile'), var Client = exports.Client = function (options) { hp.Client.call(this, options); - debugger; utile.mixin(this, require('../../../openstack/compute/client/flavors')); utile.mixin(this, require('../../../openstack/compute/client/images')); utile.mixin(this, require('../../../openstack/compute/client/servers')); From 9dc13325bb187d5f65386b681215c162a7ea8935 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 30 Apr 2014 16:16:15 -0700 Subject: [PATCH 029/460] Fixing branding of HP Cloud Compute and Object storage services. --- docs/providers/hp/getting-started-compute.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md index e25b01949..9e7e3b870 100644 --- a/docs/providers/hp/getting-started-compute.md +++ b/docs/providers/hp/getting-started-compute.md @@ -2,7 +2,7 @@ The HP node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package -Pkgcloud currently supports HP Cloud Nova (cloud compute) and HP Cloud Swift (object-storage). +Pkgcloud currently supports HP Cloud Compute and HP Cloud Object Storage. To install `pkgcloud` from the command line: From 81c890c4dfc9195e6d05da46b13fef66f60143d7 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 5 May 2014 09:36:46 -0700 Subject: [PATCH 030/460] Adding QuickStart link and updating documentation. --- docs/providers/hp/README.md | 3 +++ docs/providers/hp/storage.md | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index ea50d485c..4c79b455e 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -5,6 +5,9 @@ The HP Cloud provider in pkgcloud supports the following services: * [**Compute**](compute.md) (cloud compute) * [**Storage**](storage.md) (object storage) +### Activating your HP Cloud services + +If this is your first time using HP Cloud Services, please follow [this](https://community.hpcloud.com/article/hp-public-cloud-quick-start-guide) guide to get started. ### Getting Started with Compute We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index bafd60b2f..f861d3502 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -23,7 +23,7 @@ Learn about [more options for creating clients](README.md) in the HP `storage` p ### Container Model -A Container for HP has following properties: +A Container for HP Object Storage has following properties: ```Javascript { @@ -38,7 +38,7 @@ A Container for HP has following properties: ### File Model -A File for HP has the following properties: +A File for HP Object Storage has the following properties: ```Javascript { From 6abefc6339d62fed8f75c0b320426c43daf0bcff Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 6 May 2014 09:48:59 -0700 Subject: [PATCH 031/460] Generated a new private key and updated test key. --- test/fixtures/testkey | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/fixtures/testkey b/test/fixtures/testkey index 947f4c830..9c8e8e42c 100644 --- a/test/fixtures/testkey +++ b/test/fixtures/testkey @@ -1,3 +1,8 @@ -----BEGIN RSA PRIVATE KEY----- -U29NZVRoSW5nRnVOaEVyRWFOZE90aEVyc1JhTmRvTXNDaEFyQXRFcmVz +MIIBOwIBAAJBAL6YfTXeMD+4//GFMdr4YPyXPwGv0dm791+AYyajULskbCnEMyAUslPNYA8O +WMtRiJgLSozPCcc7m79KxhOn/U0CAwEAAQJALeODCgwz67O8E8dw6Hqyxz4XEm3lhZnnBlxg +AvaBQn0o7LYVOtEZZbRfQRBdgovdoNa2jqkHGNQiR14YxT7f4QIhAOpDZJKHVy/crzfSinX9 +lwig+1SmBa1l58AgXU1LGLEFAiEA0EfU4TwtLTX7V0d4/YKKOvgDl2PdZsxi+h0tbMnMbakC +ID3qC+WyQXfT4rdlPNUMbeOI8IQh0PRQL50WsLIh++elAiEAvJrvaO6nMjOZ4FU2eMpHBlMk +XWjvSnF2h2r4gXTTi9ECIQDiA9SPQVbZRUX+OGHUerkGINj7/mPVCuc0h5qicAQV0w== -----END RSA PRIVATE KEY----- From 6d75c6e49d80f0e3cab9e075ddb94173e423f225 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 6 May 2014 09:49:51 -0700 Subject: [PATCH 032/460] Fixing test key with a new private key that is long enough to succeed signing. --- test/fixtures/testkey | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/fixtures/testkey b/test/fixtures/testkey index 947f4c830..9c8e8e42c 100644 --- a/test/fixtures/testkey +++ b/test/fixtures/testkey @@ -1,3 +1,8 @@ -----BEGIN RSA PRIVATE KEY----- -U29NZVRoSW5nRnVOaEVyRWFOZE90aEVyc1JhTmRvTXNDaEFyQXRFcmVz +MIIBOwIBAAJBAL6YfTXeMD+4//GFMdr4YPyXPwGv0dm791+AYyajULskbCnEMyAUslPNYA8O +WMtRiJgLSozPCcc7m79KxhOn/U0CAwEAAQJALeODCgwz67O8E8dw6Hqyxz4XEm3lhZnnBlxg +AvaBQn0o7LYVOtEZZbRfQRBdgovdoNa2jqkHGNQiR14YxT7f4QIhAOpDZJKHVy/crzfSinX9 +lwig+1SmBa1l58AgXU1LGLEFAiEA0EfU4TwtLTX7V0d4/YKKOvgDl2PdZsxi+h0tbMnMbakC +ID3qC+WyQXfT4rdlPNUMbeOI8IQh0PRQL50WsLIh++elAiEAvJrvaO6nMjOZ4FU2eMpHBlMk +XWjvSnF2h2r4gXTTi9ECIQDiA9SPQVbZRUX+OGHUerkGINj7/mPVCuc0h5qicAQV0w== -----END RSA PRIVATE KEY----- From 0293c3a6a51e111d21ec29cd2b26a32981052f1c Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 11:10:39 -0700 Subject: [PATCH 033/460] Adding tests for HP's provider. --- lib/pkgcloud.js | 3 +- lib/pkgcloud/hp/index.js | 9 ++ test/common/compute/base-test.js | 34 ++++++++ test/configs/mock/hp.json | 6 ++ test/configs/providers.json | 2 +- test/fixtures/hp/creatingServer.json | 16 ++++ test/fixtures/hp/flavor1.json | 21 +++++ test/fixtures/hp/flavors.json | 23 +++++ test/fixtures/hp/image1.json | 26 ++++++ test/fixtures/hp/images.json | 28 ++++++ test/fixtures/hp/initialToken-admin.json | 16 ++++ test/fixtures/hp/initialToken.json | 16 ++++ test/fixtures/hp/no-activeTenants.json | 11 +++ test/fixtures/hp/no-tenants.json | 4 + test/fixtures/hp/realToken-admin.json | 72 ++++++++++++++++ .../hp/realToken-multiRegionVolume.json | 78 +++++++++++++++++ test/fixtures/hp/realToken-noRegion.json | 71 ++++++++++++++++ test/fixtures/hp/realToken.json | 85 +++++++++++++++++++ test/fixtures/hp/serverCreated.json | 57 +++++++++++++ test/fixtures/hp/serverCreated2.json | 63 ++++++++++++++ test/fixtures/hp/serverList.json | 48 +++++++++++ test/fixtures/hp/tenantId-admin.json | 11 +++ test/fixtures/hp/tenantId.json | 11 +++ test/fixtures/hp/versions.json | 30 +++++++ test/fixtures/versions.json | 2 +- test/helpers/index.js | 4 + 26 files changed, 744 insertions(+), 3 deletions(-) create mode 100644 lib/pkgcloud/hp/index.js create mode 100644 test/configs/mock/hp.json create mode 100644 test/fixtures/hp/creatingServer.json create mode 100644 test/fixtures/hp/flavor1.json create mode 100644 test/fixtures/hp/flavors.json create mode 100644 test/fixtures/hp/image1.json create mode 100644 test/fixtures/hp/images.json create mode 100644 test/fixtures/hp/initialToken-admin.json create mode 100644 test/fixtures/hp/initialToken.json create mode 100644 test/fixtures/hp/no-activeTenants.json create mode 100644 test/fixtures/hp/no-tenants.json create mode 100644 test/fixtures/hp/realToken-admin.json create mode 100644 test/fixtures/hp/realToken-multiRegionVolume.json create mode 100644 test/fixtures/hp/realToken-noRegion.json create mode 100644 test/fixtures/hp/realToken.json create mode 100644 test/fixtures/hp/serverCreated.json create mode 100644 test/fixtures/hp/serverCreated2.json create mode 100644 test/fixtures/hp/serverList.json create mode 100644 test/fixtures/hp/tenantId-admin.json create mode 100644 test/fixtures/hp/tenantId.json create mode 100644 test/fixtures/hp/versions.json diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index 8921d9617..f1c3a1f30 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -29,7 +29,8 @@ var providers = [ 'openstack', 'rackspace', 'redistogo', - 'telefonica' + 'telefonica', + 'hp' ]; var services = [ diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js new file mode 100644 index 000000000..2cd7883a3 --- /dev/null +++ b/lib/pkgcloud/hp/index.js @@ -0,0 +1,9 @@ +/* + * index.js: Top-level include for the HP provider. + * + * (C) 2014 HP Inc. + * + */ + +exports.compute = require('../openstack/compute'); +exports.storage = require('../openstack/storage'); diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index b50bfd976..af4a86443 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -260,6 +260,34 @@ function setupVersionMock(client, provider, servers) { .get('/v2/', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/versions.json'); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/versions.json'); + } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/datacenters', @@ -295,6 +323,12 @@ function setupFlavorMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/flavors.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/flavors/detail', + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); + } } function setupImagesMock(client, provider, servers) { diff --git a/test/configs/mock/hp.json b/test/configs/mock/hp.json new file mode 100644 index 000000000..5a48bef79 --- /dev/null +++ b/test/configs/mock/hp.json @@ -0,0 +1,6 @@ +{ + "username":"MOCK-USERNAME", + "password":"MOCK-PASSWORD", + "authUrl":"http://localhost:12346", + "region": "Calxeda-AUS1" +} diff --git a/test/configs/providers.json b/test/configs/providers.json index dda968475..beff5878f 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1 +1 @@ -["rackspace", "openstack", "joyent", "amazon", "azure", "digitalocean"] \ No newline at end of file +["rackspace", "openstack", "amazon", "azure", "digitalocean", "hp"] \ No newline at end of file diff --git a/test/fixtures/hp/creatingServer.json b/test/fixtures/hp/creatingServer.json new file mode 100644 index 000000000..76d0a187b --- /dev/null +++ b/test/fixtures/hp/creatingServer.json @@ -0,0 +1,16 @@ +{ + "server": { + "OS-DCF:diskConfig": "MANUAL", + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "bookmark" + } + ], + "adminPass": "i9SaeyU3sxKX" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/flavor1.json b/test/fixtures/hp/flavor1.json new file mode 100644 index 000000000..3d43f4df8 --- /dev/null +++ b/test/fixtures/hp/flavor1.json @@ -0,0 +1,21 @@ +{ + "flavor": { + "vcpus": 4, + "disk": 150, + "name": "m1.highbank", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ], + "rxtx_factor": 1.0, + "OS-FLV-EXT-DATA:ephemeral": 0, + "ram": 3584, + "id": "1", + "swap": "" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/flavors.json b/test/fixtures/hp/flavors.json new file mode 100644 index 000000000..1ea3d1c9e --- /dev/null +++ b/test/fixtures/hp/flavors.json @@ -0,0 +1,23 @@ +{ + "flavors": [ + { + "vcpus": 4, + "disk": 150, + "name": "m1.highbank", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ], + "rxtx_factor": 1.0, + "OS-FLV-EXT-DATA:ephemeral": 0, + "ram": 3584, + "id": "1", + "swap": "" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/image1.json b/test/fixtures/hp/image1.json new file mode 100644 index 000000000..ee4ba3e1c --- /dev/null +++ b/test/fixtures/hp/image1.json @@ -0,0 +1,26 @@ +{ + "image": { + "status": "ACTIVE", + "updated": "2012-07-13T15:37:58Z", + "name": "Ubuntu 12.04", + "links": [ + { + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + }, { + "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "type": "application/vnd.openstack.image", + "rel": "alternate" + } + ], + "created": "2012-07-13T15:37:54Z", + "progress": 100, + "minRam": 0, + "minDisk": 0, + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "metadata": {} + } +} \ No newline at end of file diff --git a/test/fixtures/hp/images.json b/test/fixtures/hp/images.json new file mode 100644 index 000000000..eee40a5cc --- /dev/null +++ b/test/fixtures/hp/images.json @@ -0,0 +1,28 @@ +{ + "images": [ + { + "status": "ACTIVE", + "updated": "2012-07-13T15:37:58Z", + "name": "Ubuntu 12.04", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "self" + }, { + "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + }, { + "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "type": "application/vnd.openstack.image", + "rel": "alternate" + } + ], + "created": "2012-07-13T15:37:54Z", + "progress": 100, + "minRam": 0, + "minDisk": 0, + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/initialToken-admin.json b/test/fixtures/hp/initialToken-admin.json new file mode 100644 index 000000000..6f49990cb --- /dev/null +++ b/test/fixtures/hp/initialToken-admin.json @@ -0,0 +1,16 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:45Z", + "id": "e93be67f91724754aeb9409c9c69d305" + }, + "serviceCatalog": {}, + "user": { + "username": "MOCK-ADMIN", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5e", + "roles": [], + "name": "MOCK-ADMIN" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/initialToken.json b/test/fixtures/hp/initialToken.json new file mode 100644 index 000000000..519ce55d2 --- /dev/null +++ b/test/fixtures/hp/initialToken.json @@ -0,0 +1,16 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:45Z", + "id": "e93be67f91724754aeb9409c9c69d304" + }, + "serviceCatalog": {}, + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/no-activeTenants.json b/test/fixtures/hp/no-activeTenants.json new file mode 100644 index 000000000..52357ae28 --- /dev/null +++ b/test/fixtures/hp/no-activeTenants.json @@ -0,0 +1,11 @@ +{ + "tenants_links": [], + "tenants": [ + { + "enabled": "false", + "description": "MOCK-USERNAME", + "name": "MOCK-USERNAME", + "id": "72e90ecb69c44d0296072ea39e537041" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/no-tenants.json b/test/fixtures/hp/no-tenants.json new file mode 100644 index 000000000..fc9c352dd --- /dev/null +++ b/test/fixtures/hp/no-tenants.json @@ -0,0 +1,4 @@ +{ + "tenants_links": [], + "tenants": [] +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken-admin.json b/test/fixtures/hp/realToken-admin.json new file mode 100644 index 000000000..855e86957 --- /dev/null +++ b/test/fixtures/hp/realToken-admin.json @@ -0,0 +1,72 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8b", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537123", + "name": "MOCK-ADMIN", + "description": "MOCK-ADMIN" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, { + "endpoints": [ + { + "adminURL": "http://localhost:12347/v2.0", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-ADMIN", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5e", + "roles": [], + "name": "MOCK-ADMIN" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken-multiRegionVolume.json b/test/fixtures/hp/realToken-multiRegionVolume.json new file mode 100644 index 000000000..63073d18d --- /dev/null +++ b/test/fixtures/hp/realToken-multiRegionVolume.json @@ -0,0 +1,78 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "MOCK-USERNAME", + "description": "MOCK-USERNAME" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + }, + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS2", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:35357/v2.0", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken-noRegion.json b/test/fixtures/hp/realToken-noRegion.json new file mode 100644 index 000000000..14904734f --- /dev/null +++ b/test/fixtures/hp/realToken-noRegion.json @@ -0,0 +1,71 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "MOCK-USERNAME", + "description": "MOCK-USERNAME" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:35357/v2.0", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json new file mode 100644 index 000000000..719d71cdc --- /dev/null +++ b/test/fixtures/hp/realToken.json @@ -0,0 +1,85 @@ +{ + "access": { + "token": { + "expires": "2012-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "tenant": { + "enabled": true, + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "MOCK-USERNAME", + "description": "MOCK-USERNAME" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "volume", + "name": "volume" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:9292/v1", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:9292/v1", + "publicURL": "http://image.myownendpoint.org:9292/v1" + } + ], + "endpoints_links": [], + "type": "image", + "name": "glance" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "compute", + "name": "nova" + }, + { + "endpoints": [ + { + "region": "Calxeda-AUS1", + "tenantId": "MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "publicURL": "http://localhost:12345/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" + } + ], + "name": "swift", + "type": "object-store" + }, + { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:35357/v2.0", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:5000/v2.0", + "publicURL": "http://identity.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "identity", + "name": "keystone" + } + ], + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } +} \ No newline at end of file diff --git a/test/fixtures/hp/serverCreated.json b/test/fixtures/hp/serverCreated.json new file mode 100644 index 000000000..d719534ba --- /dev/null +++ b/test/fixtures/hp/serverCreated.json @@ -0,0 +1,57 @@ +{ + "server": { + "OS-EXT-STS:task_state": null, + "addresses": { + "private": [ + { + "version": 4, + "addr": "208.123.85.201" + } + ] + }, + "links": [ + { + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "bookmark" + } + ], + "image": { + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "user_id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-12-25T18:26:02Z", + "hostId": "c41a6390eaac457345c29655688b16ac53182ae874c69770ca36e936", + "key_name": "", + "name": "create-test-setWait", + "created": "2012-12-25T18:25:54Z", + "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "metadata": {} + } +} \ No newline at end of file diff --git a/test/fixtures/hp/serverCreated2.json b/test/fixtures/hp/serverCreated2.json new file mode 100644 index 000000000..6cbd57ba5 --- /dev/null +++ b/test/fixtures/hp/serverCreated2.json @@ -0,0 +1,63 @@ +{ + "server": { + "OS-EXT-STS:task_state": null, + "addresses": { + "private": [ + { + "version": 4, + "addr": "208.123.85.201" + } + ], + "public": [ + { + "version": 4, + "addr": "208.123.85.201" + } + ] + }, + "links": [ + { + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "rel": "bookmark" + } + ], + "image": { + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "user_id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-12-25T18:26:02Z", + "hostId": "c41a6390eaac457345c29655688b16ac53182ae874c69770ca36e936", + "key_name": "", + "name": "create-test-ids2", + "created": "2012-12-25T18:25:54Z", + "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "metadata": {} + } +} \ No newline at end of file diff --git a/test/fixtures/hp/serverList.json b/test/fixtures/hp/serverList.json new file mode 100644 index 000000000..fc8560c50 --- /dev/null +++ b/test/fixtures/hp/serverList.json @@ -0,0 +1,48 @@ +{ + "servers": [{ + "OS-EXT-STS:task_state": "deleting", + "addresses": { + "private": [{ + "version": 4, "addr": "208.123.85.203" + }] + }, + "links": [{ + "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "rel": "self" + }, { + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "rel": "bookmark" + }], + "image": { + "id": "506d077e-66bf-44ff-907a-588c5c79fa66", + "links": [{ + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "rel": "bookmark" + }] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [{ + "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "rel": "bookmark" + }] + }, + "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", + "user_id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2013-02-14T20:24:52Z", + "hostId": "ab50598d09cc91aa5c32f6afabe30fd1ded4cf8100eb77f782dd3e19", + "key_name": "", + "name": "create-test-ids2", + "created": "2013-02-14T20:24:42Z", + "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "metadata": {} + }] +} \ No newline at end of file diff --git a/test/fixtures/hp/tenantId-admin.json b/test/fixtures/hp/tenantId-admin.json new file mode 100644 index 000000000..2153a31e9 --- /dev/null +++ b/test/fixtures/hp/tenantId-admin.json @@ -0,0 +1,11 @@ +{ + "tenants_links": [], + "tenants": [ + { + "enabled": "true", + "description": "MOCK-ADMIN", + "name": "MOCK-ADMIN", + "id": "72e90ecb69c44d0296072ea39e537123" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/tenantId.json b/test/fixtures/hp/tenantId.json new file mode 100644 index 000000000..310afd86c --- /dev/null +++ b/test/fixtures/hp/tenantId.json @@ -0,0 +1,11 @@ +{ + "tenants_links": [], + "tenants": [ + { + "enabled": "true", + "description": "MOCK-USERNAME", + "name": "MOCK-USERNAME", + "id": "72e90ecb69c44d0296072ea39e537041" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/versions.json b/test/fixtures/hp/versions.json new file mode 100644 index 000000000..893d18aee --- /dev/null +++ b/test/fixtures/hp/versions.json @@ -0,0 +1,30 @@ +{ + "version": { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "media-types": [ + { + "base": "application/xml", + "type": "application/vnd.openstack.compute+xml;version=2" + }, { + "base": "application/json", + "type": "application/vnd.openstack.compute+json;version=2" + } + ], + "id": "v1", + "links": [ + { + "href": "http://compute.myownendpoint.org:8774/v2/", + "rel": "self" + }, { + "href": "http://docs.openstack.org/api/openstack-compute/1.1/os-compute-devguide-1.1.pdf", + "type": "application/pdf", + "rel": "describedby" + }, { + "href": "http://docs.openstack.org/api/openstack-compute/1.1/wadl/os-compute-1.1.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/versions.json b/test/fixtures/versions.json index 85a5fdf83..e23d699e0 100644 --- a/test/fixtures/versions.json +++ b/test/fixtures/versions.json @@ -1 +1 @@ -{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2012-04-01", "azure": "2012-03-01", "openstack": "v2"} \ No newline at end of file +{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2012-04-01", "azure": "2012-03-01", "openstack": "v2", "hp": "v1"} \ No newline at end of file diff --git a/test/helpers/index.js b/test/helpers/index.js index 3a10e33e4..7bd33d415 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -180,6 +180,10 @@ helpers.getOpenstackAuthResponse = function (time) { return helpers._getOpenstackStandardResponse('../fixtures/openstack/realToken.json', time); }; +helpers.gethpAuthResponse = function (time) { + return helpers._getOpenstackStandardResponse('../fixtures/hp/realToken.json', time); +}; + helpers._getOpenstackStandardResponse = function(file, time) { if (!time) { time = new Date(new Date().getTime() + (1000 * 60 * 60 * 24)); From 46dd9519c52eb6904685c1ddc7d0ac9fb1568d8f Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 13:39:46 -0700 Subject: [PATCH 034/460] All tests passing for HP provider. --- test/common/compute/base-test.js | 32 +++++++- test/common/compute/server-test.js | 51 ++++++++++++ test/common/storage/base-test.js | 82 +++++++++++++++++++ test/fixtures/hp/creatingServer.json | 4 +- test/fixtures/hp/flavor1.json | 4 +- test/fixtures/hp/flavors.json | 4 +- test/fixtures/hp/image1.json | 6 +- test/fixtures/hp/images.json | 6 +- test/fixtures/hp/no-activeTenants.json | 2 +- test/fixtures/hp/postContainers.json | 1 + test/fixtures/hp/preContainers.json | 1 + test/fixtures/hp/realToken-admin.json | 12 +-- .../hp/realToken-multiRegionVolume.json | 20 ++--- test/fixtures/hp/realToken-noRegion.json | 14 ++-- test/fixtures/hp/realToken.json | 14 ++-- test/fixtures/hp/serverCreated.json | 10 +-- test/fixtures/hp/serverCreated2.json | 10 +-- test/fixtures/hp/serverList.json | 10 +-- test/fixtures/hp/tenantId-admin.json | 2 +- test/fixtures/hp/tenantId.json | 2 +- 20 files changed, 224 insertions(+), 63 deletions(-) create mode 100644 test/fixtures/hp/postContainers.json create mode 100644 test/fixtures/hp/preContainers.json diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index af4a86443..82be22039 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -279,7 +279,7 @@ function setupVersionMock(client, provider, servers) { username: 'MOCK-USERNAME', password: 'MOCK-PASSWORD' }, - tenantId: '72e90ecb69c44d0296072ea39e537041' + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers.gethpAuthResponse()); @@ -325,9 +325,9 @@ function setupFlavorMock(client, provider, servers) { } else if (provider === 'hp') { servers.server - .get('/v2/72e90ecb69c44d0296072ea39e537041/flavors/detail', + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); + .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); } } @@ -372,6 +372,12 @@ function setupImagesMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/images.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail', + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); + } } function setupServerMock(client, provider, servers) { @@ -523,6 +529,21 @@ function setupServerMock(client, provider, servers) { {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers', { + server: { + name: 'create-test-setWait', + flavorRef: '1', + imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' + } + }, + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(202, __dirname + '/../../fixtures/hp/creatingServer.json') + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', + {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/serverCreated.json'); + } } function setupDestroyMock(client, provider, servers) { @@ -537,6 +558,11 @@ function setupDestroyMock(client, provider, servers) { .delete('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(204); } + else if (provider === 'hp') { + servers.server + .delete('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(204); + } else if (provider === 'digitalocean') { var account = require(__dirname + '/../../configs/mock/digitalocean'); diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index f8a5b83bc..bc01948e0 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -296,6 +296,34 @@ function setupImagesMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/images.json'); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); + } } function setupFlavorMock(client, provider, servers) { @@ -323,6 +351,11 @@ function setupFlavorMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/flavors.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); + } } function setupServerMock(client, provider, servers) { @@ -434,6 +467,14 @@ function setupServerMock(client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers', + {server: {name: 'create-test-ids2', flavorRef: '1', imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/creatingServer.json') + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); + } } function setupGetServersMock(client, provider, servers) { @@ -478,6 +519,11 @@ function setupGetServersMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/list-servers.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/serverList.json'); + } } function setupGetServerMock(client, provider, servers) { @@ -513,6 +559,11 @@ function setupGetServerMock(client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); + } } // //function batchThree(providerClient, providerName) { diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 8743288f4..9e1aa4a6e 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -512,6 +512,34 @@ function setupCreateContainerMock(provider, client, servers) { .put('/pkgcloud-test-container?restype=container') .reply(201, '', helpers.azureResponseHeaders()); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } } function setupGetContainersMock(provider, client, servers) { @@ -530,6 +558,11 @@ function setupGetContainersMock(provider, client, servers) { .get('/?comp=list') .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/postContainers.json')); + } } function setupUploadStreamMock(provider, client, servers) { @@ -550,6 +583,11 @@ function setupUploadStreamMock(provider, client, servers) { .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', "block000000000000000") .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) } + else if (provider === 'hp') { + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .reply(200) + } } function setupDownloadStreamMock(provider, client, servers) { @@ -568,6 +606,11 @@ function setupDownloadStreamMock(provider, client, servers) { .get('/pkgcloud-test-container/test-file.txt') .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2}) + } } function setupGetFileMock(provider, client, servers) { @@ -586,6 +629,11 @@ function setupGetFileMock(provider, client, servers) { .get('/pkgcloud-test-container/test-file.txt') .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})) } + if (provider === 'hp') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }) + } } function setupGetFilesMock(provider, client, servers) { @@ -608,6 +656,15 @@ function setupGetFilesMock(provider, client, servers) { .get('/pkgcloud-test-container?restype=container&comp=list') .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [{ + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + }]); + } } function setupRemoveFileMock(provider, client, servers) { @@ -626,6 +683,11 @@ function setupRemoveFileMock(provider, client, servers) { .delete('/pkgcloud-test-container/test-file.txt') .reply(202, '', helpers.azureDeleteResponseHeaders()) } + if (provider === 'hp') { + servers.server + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, ''); + } } function setupDestroyContainerMock(provider, client, servers) { @@ -658,6 +720,21 @@ function setupDestroyContainerMock(provider, client, servers) { .delete('/pkgcloud-test-container?restype=container') .reply(202, '', helpers.azureDeleteResponseHeaders()); } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } } function setupGetContainers2Mock(provider, client, servers) { @@ -676,4 +753,9 @@ function setupGetContainers2Mock(provider, client, servers) { .get('/?comp=list') .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()) } + else if (provider === 'hp') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/preContainers.json')); + } } \ No newline at end of file diff --git a/test/fixtures/hp/creatingServer.json b/test/fixtures/hp/creatingServer.json index 76d0a187b..b155f7a6b 100644 --- a/test/fixtures/hp/creatingServer.json +++ b/test/fixtures/hp/creatingServer.json @@ -4,10 +4,10 @@ "id": "5a023de8-957b-4822-ad84-8c7a9ef83c07", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "bookmark" } ], diff --git a/test/fixtures/hp/flavor1.json b/test/fixtures/hp/flavor1.json index 3d43f4df8..b2f3adca0 100644 --- a/test/fixtures/hp/flavor1.json +++ b/test/fixtures/hp/flavor1.json @@ -5,10 +5,10 @@ "name": "m1.highbank", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ], diff --git a/test/fixtures/hp/flavors.json b/test/fixtures/hp/flavors.json index 1ea3d1c9e..85d32b504 100644 --- a/test/fixtures/hp/flavors.json +++ b/test/fixtures/hp/flavors.json @@ -6,10 +6,10 @@ "name": "m1.highbank", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ], diff --git a/test/fixtures/hp/image1.json b/test/fixtures/hp/image1.json index ee4ba3e1c..15cb67aac 100644 --- a/test/fixtures/hp/image1.json +++ b/test/fixtures/hp/image1.json @@ -5,13 +5,13 @@ "name": "Ubuntu 12.04", "links": [ { - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" }, { - "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://10.225.0.9:9292/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "type": "application/vnd.openstack.image", "rel": "alternate" } diff --git a/test/fixtures/hp/images.json b/test/fixtures/hp/images.json index eee40a5cc..cf05cf7ec 100644 --- a/test/fixtures/hp/images.json +++ b/test/fixtures/hp/images.json @@ -6,13 +6,13 @@ "name": "Ubuntu 12.04", "links": [ { - "href": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "self" }, { - "href": "http://compute.myownendpoint.org:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://compute.myownendpoint.org:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" }, { - "href": "http://10.225.0.9:9292/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://10.225.0.9:9292/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "type": "application/vnd.openstack.image", "rel": "alternate" } diff --git a/test/fixtures/hp/no-activeTenants.json b/test/fixtures/hp/no-activeTenants.json index 52357ae28..bd2c911ac 100644 --- a/test/fixtures/hp/no-activeTenants.json +++ b/test/fixtures/hp/no-activeTenants.json @@ -5,7 +5,7 @@ "enabled": "false", "description": "MOCK-USERNAME", "name": "MOCK-USERNAME", - "id": "72e90ecb69c44d0296072ea39e537041" + "id": "5ACED3DC3AA740ABAA41711243CC6949" } ] } \ No newline at end of file diff --git a/test/fixtures/hp/postContainers.json b/test/fixtures/hp/postContainers.json new file mode 100644 index 000000000..8fccead0c --- /dev/null +++ b/test/fixtures/hp/postContainers.json @@ -0,0 +1 @@ +[{"count": 0, "bytes": 0, "name": "lost+found"}, {"count": 0, "bytes": 0, "name": "pkgcloud-test-container"}] diff --git a/test/fixtures/hp/preContainers.json b/test/fixtures/hp/preContainers.json new file mode 100644 index 000000000..cdb6cbc35 --- /dev/null +++ b/test/fixtures/hp/preContainers.json @@ -0,0 +1 @@ +[{"count": 0, "bytes": 0, "name": "lost+found"}] diff --git a/test/fixtures/hp/realToken-admin.json b/test/fixtures/hp/realToken-admin.json index 855e86957..3526ee0f2 100644 --- a/test/fixtures/hp/realToken-admin.json +++ b/test/fixtures/hp/realToken-admin.json @@ -14,10 +14,10 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -38,10 +38,10 @@ }, { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/realToken-multiRegionVolume.json b/test/fixtures/hp/realToken-multiRegionVolume.json index 63073d18d..88df5a1c0 100644 --- a/test/fixtures/hp/realToken-multiRegionVolume.json +++ b/test/fixtures/hp/realToken-multiRegionVolume.json @@ -5,7 +5,7 @@ "id": "4bc7c5dabf3e4a49918683437d386b8a", "tenant": { "enabled": true, - "id": "72e90ecb69c44d0296072ea39e537041", + "id": "5ACED3DC3AA740ABAA41711243CC6949", "name": "MOCK-USERNAME", "description": "MOCK-USERNAME" } @@ -14,16 +14,16 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" }, { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS2", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -44,10 +44,10 @@ }, { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/realToken-noRegion.json b/test/fixtures/hp/realToken-noRegion.json index 14904734f..484e01e2d 100644 --- a/test/fixtures/hp/realToken-noRegion.json +++ b/test/fixtures/hp/realToken-noRegion.json @@ -5,7 +5,7 @@ "id": "4bc7c5dabf3e4a49918683437d386b8a", "tenant": { "enabled": true, - "id": "72e90ecb69c44d0296072ea39e537041", + "id": "5ACED3DC3AA740ABAA41711243CC6949", "name": "MOCK-USERNAME", "description": "MOCK-USERNAME" } @@ -14,9 +14,9 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -38,9 +38,9 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://compute.myownendpoint.org:8774/v2/72e90ecb69c44d0296072ea39e537041" + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://compute.myownendpoint.org:8774/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 719d71cdc..2636f092e 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -5,7 +5,7 @@ "id": "4bc7c5dabf3e4a49918683437d386b8a", "tenant": { "enabled": true, - "id": "72e90ecb69c44d0296072ea39e537041", + "id": "5ACED3DC3AA740ABAA41711243CC6949", "name": "MOCK-USERNAME", "description": "MOCK-USERNAME" } @@ -14,10 +14,10 @@ { "endpoints": [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], @@ -38,10 +38,10 @@ }, { "endpoints": [ { - "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "region": "Calxeda-AUS1", - "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } ], "endpoints_links": [], diff --git a/test/fixtures/hp/serverCreated.json b/test/fixtures/hp/serverCreated.json index d719534ba..01ae03343 100644 --- a/test/fixtures/hp/serverCreated.json +++ b/test/fixtures/hp/serverCreated.json @@ -11,10 +11,10 @@ }, "links": [ { - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "bookmark" } ], @@ -22,7 +22,7 @@ "id": "506d077e-66bf-44ff-907a-588c5c79fa66", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" } ] @@ -32,7 +32,7 @@ "id": "1", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ] @@ -51,7 +51,7 @@ "key_name": "", "name": "create-test-setWait", "created": "2012-12-25T18:25:54Z", - "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "tenant_id": "5ACED3DC3AA740ABAA41711243CC6949", "metadata": {} } } \ No newline at end of file diff --git a/test/fixtures/hp/serverCreated2.json b/test/fixtures/hp/serverCreated2.json index 6cbd57ba5..ca8cadeac 100644 --- a/test/fixtures/hp/serverCreated2.json +++ b/test/fixtures/hp/serverCreated2.json @@ -17,10 +17,10 @@ }, "links": [ { - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07", "rel": "bookmark" } ], @@ -28,7 +28,7 @@ "id": "506d077e-66bf-44ff-907a-588c5c79fa66", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" } ] @@ -38,7 +38,7 @@ "id": "1", "links": [ { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" } ] @@ -57,7 +57,7 @@ "key_name": "", "name": "create-test-ids2", "created": "2012-12-25T18:25:54Z", - "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "tenant_id": "5ACED3DC3AA740ABAA41711243CC6949", "metadata": {} } } \ No newline at end of file diff --git a/test/fixtures/hp/serverList.json b/test/fixtures/hp/serverList.json index fc8560c50..9d34a9644 100644 --- a/test/fixtures/hp/serverList.json +++ b/test/fixtures/hp/serverList.json @@ -7,16 +7,16 @@ }] }, "links": [{ - "href": "http://208.123.85.197:8774/v2/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "href": "http://208.123.85.197:8774/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", "rel": "self" }, { - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/servers/c94e7443-6a35-4f8b-b4e5-da59881a9451", "rel": "bookmark" }], "image": { "id": "506d077e-66bf-44ff-907a-588c5c79fa66", "links": [{ - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/images/506d077e-66bf-44ff-907a-588c5c79fa66", "rel": "bookmark" }] }, @@ -24,7 +24,7 @@ "flavor": { "id": "1", "links": [{ - "href": "http://208.123.85.197:8774/72e90ecb69c44d0296072ea39e537041/flavors/1", + "href": "http://208.123.85.197:8774/5ACED3DC3AA740ABAA41711243CC6949/flavors/1", "rel": "bookmark" }] }, @@ -42,7 +42,7 @@ "key_name": "", "name": "create-test-ids2", "created": "2013-02-14T20:24:42Z", - "tenant_id": "72e90ecb69c44d0296072ea39e537041", + "tenant_id": "5ACED3DC3AA740ABAA41711243CC6949", "metadata": {} }] } \ No newline at end of file diff --git a/test/fixtures/hp/tenantId-admin.json b/test/fixtures/hp/tenantId-admin.json index 2153a31e9..df6a207d2 100644 --- a/test/fixtures/hp/tenantId-admin.json +++ b/test/fixtures/hp/tenantId-admin.json @@ -5,7 +5,7 @@ "enabled": "true", "description": "MOCK-ADMIN", "name": "MOCK-ADMIN", - "id": "72e90ecb69c44d0296072ea39e537123" + "id": "5ACED3DC3AA740ABAA41711243CC6949" } ] } \ No newline at end of file diff --git a/test/fixtures/hp/tenantId.json b/test/fixtures/hp/tenantId.json index 310afd86c..c1025f93e 100644 --- a/test/fixtures/hp/tenantId.json +++ b/test/fixtures/hp/tenantId.json @@ -5,7 +5,7 @@ "enabled": "true", "description": "MOCK-USERNAME", "name": "MOCK-USERNAME", - "id": "72e90ecb69c44d0296072ea39e537041" + "id": "5ACED3DC3AA740ABAA41711243CC6949" } ] } \ No newline at end of file From 36f6394e1b1ab4a2ebe6a0a37c372146ec80e0fe Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 13:42:54 -0700 Subject: [PATCH 035/460] Adding joyent provider back to Providers.json --- test/configs/providers.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/configs/providers.json b/test/configs/providers.json index beff5878f..e643abe2d 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1 +1 @@ -["rackspace", "openstack", "amazon", "azure", "digitalocean", "hp"] \ No newline at end of file +["rackspace", "openstack", "joyent", "amazon", "azure", "digitalocean", "hp"] \ No newline at end of file From b897db9ce75d72b5afa1e9831de88e979d3c90e3 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 25 Apr 2014 17:17:25 -0700 Subject: [PATCH 036/460] Adding documentation for HP Cloud provider --- docs/providers/hp/README.md | 76 +++++++++ docs/providers/hp/compute.md | 142 +++++++++++++++++ docs/providers/hp/storage.md | 295 +++++++++++++++++++++++++++++++++++ 3 files changed, 513 insertions(+) create mode 100644 docs/providers/hp/README.md create mode 100644 docs/providers/hp/compute.md create mode 100644 docs/providers/hp/storage.md diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md new file mode 100644 index 000000000..65f1d7b22 --- /dev/null +++ b/docs/providers/hp/README.md @@ -0,0 +1,76 @@ +## Using the HP Cloud provider in pkgcloud + +The HP Cloud provider in pkgcloud supports the following services: + +* [**Compute**](compute.md) (Cloud Servers) +* [**Storage**](storage.md) (Cloud Files) +### Getting Started with Compute + +We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. + +### Authentication + +For all of the HP Cloud services, you create a client with the same options: + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'rackspace', + username: 'your-user-name', + password: 'your-api-key' +}); +``` + +In addition to your `apiKey`, you could alternately provide your `password` as an option to `createClient`. + +### Authentication Endpoints and Regions + +All of the Rackspace `createClient` calls have a few options that can be provided: + +#### authUrl + +`authUrl` specifies the authentication endpoint used to create a token for your Rackspace client. By default, this is set to the Global endpoint: https://identity.api.rackspacecloud.com. + +##### Authenticating against the London endpoint + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'rackspace', + username: 'your-user-name', + apiKey: 'your-api-key', + authUrl: 'https://lon.identity.api.rackspacecloud.com' +}); +``` + +#### region + +`region` specifies which region of a service to use. For example, when you authenticate with the global endpoint for compute, you have the option of either `DFW`, `ORD`, or `SYD`. The default region is `DFW`. Previous pkgcloud versions did not let you specify which region you used, so all calls were against `DFW`. + +##### Specifying a custom region + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'rackspace', + username: 'your-user-name', + apiKey: 'your-api-key', + region: 'ORD' +}); +``` + +#### Tokens and Expiration + +When you make your first call to a Rackspace provider, your client is authenticated transparent to your API call. Rackspace will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. + +#### Internal URLs + +As part of the options, you can tell `pkgcloud` to use the Internal (Service Net) URLs for a service, if possible. + + ```Javascript + var client = require('pkgcloud').storage.createClient({ + provider: 'rackspace', + username: 'your-user-name', + apiKey: 'your-api-key', + useInternal: true + }); + ``` + + This setting is explicit. If you set it to true, and you have no connectivity to the internal URL for a service, your connections will timeout. diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md new file mode 100644 index 000000000..f3c724ead --- /dev/null +++ b/docs/providers/hp/compute.md @@ -0,0 +1,142 @@ +##Using the HP Cloud Compute provider + +Creating a client is straight-forward: + +``` js + var hpCompute = pkgcloud.compute.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region of identity service', + authUrl: 'https://your-identity-service' + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +**Servers** + +#### client.getServers(callback) +Lists all servers that are available to use on your HP Cloud account + +Callback returns `f(err, servers)` where `servers` is an `Array` + +#### client.createServer(options, callback) +Creates a server with the options specified + +Options are as follows: + +```js +{ + name: 'serverName', // required + flavor: 'flavor1', // required + image: 'image1', // required + personality: [] // optional +} +``` +Returns the server in the callback `f(err, server)` + +#### client.destroyServer(server, callback) +Destroys the specified server + +Takes server or serverId as an argument and returns the id of the destroyed server in the callback `f(err, serverId)` + +#### client.getServer(server, callback) +Gets specified server + +Takes server or serverId as an argument and returns the server in the callback +`f(err, server)` + +#### client.rebootServer(server, options, callback) +Reboots the specifed server with options + +Options include: + +```js +{ + type: 'HARD' // optional (defaults to 'SOFT') +} +``` +Returns callback with a confirmation + +#### client.getVersion(callback) + +Get the current version of the api returned in a callback `f(err, version)` + +#### client.getLimits(callback) + +Get the current API limits returned in a callback `f(err, limits)` + +**flavors** + +#### client.getFlavors(callback) + +Returns a list of all possible server flavors available in the callback `f(err, +flavors)` + +#### client.getFlavor(flavor, callback) +Returns the specified HP flavor of Openstack Images by ID or flavor +object in the callback `f(err, flavor)` + +**images** + +#### client.getImages(callback) +Returns a list of the images available for your account + +`f(err, images)` + +#### client.getImage(image, callback) +Returns the image specified + +`f(err, image)` + +#### client.createImage(options, callback) +Creates an Image based on a server + +Options include: + +```js +{ + name: 'imageName', // required + server: 'serverId' // required +} +``` + +Returns the newly created image + +`f(err, image)` + +#### client.destroyImage(image, callback) +Destroys the specified image and returns a confirmation + +`f(err, {ok: imageId})` + +## Volume Attachments + +Attaching a volume to a compute instance requires using a rackspace compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. + +#### client.getVolumeAttachments(server, callback) + +Gets an array of volumeAttachments for the provided server. + +`f(err, volumeAttachments)` + +#### client.getVolumeAttachmentDetails(server, attachment, callback) + +Gets the details for a provided server and attachment. `attachment` may either be the `attachmentId` or an object with `attachmentId` as a property. + +`f(err, volumeAttachment)` + +#### client.attachVolume(server, volume, callback) + +Attaches the provided `volume` to the `server`. `volume` may either be the `volumeId` or an instance of `Volume`. + +`f(err, volumeAttachment)` + +#### client.detachVolume(server, attachment, callback) + +Detaches the provided `attachment` from the server. `attachment` may either be the `attachmentId` or an object with `attachmentId` as a property. If the `volume` is mounted this call will return an err. + +`f(err)` diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md new file mode 100644 index 000000000..80f599b38 --- /dev/null +++ b/docs/providers/hp/storage.md @@ -0,0 +1,295 @@ +## Using the HP Storage provider + +* Container + * [Model](#container-model) + * [APIs](#container-apis) +* File + * [Model](#file-model) + * [APIs](#file-apis) + +Creating a client is straight-forward: + +``` js + var hpStorage = pkgcloud.storage.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region of identity service', + authUrl: 'https://your-identity-service' + }); +``` + +Learn about [more options for creating clients](README.md) in the Openstack `storage` provider. + +### Container Model + +A Container for Openstack has following properties: + +```Javascript +{ + name: 'my-container', + count: 1, // number of files in your container + bytes: 12345, // size of the container in bytes + metadata: { // key value pairs for the container + // ... + } +} +``` + +### File Model + +A File for Openstack has the following properties: + +```Javascript +{ + name: 'my-file', + container: 'my-container', // may be an instance of container if provided + size: 12345, // size of the file in bytes + contentType: 'plain/text' // Mime type for the file + lastModified: Fri Dec 14 2012 10:16:50 GMT-0800 (PST), // Last modified date of the file + etag: '1234567890abcdef', // MD5 sum of the file + metadata: {} // optional object metadata +} +``` + +### Container APIs + +* [`client.getContainers(function(err, containers) { })`](#clientgetcontainersfunctionerr-containers--) +* [`client.getContainer(container, function(err, container) { })`](#clientgetcontainercontainer-functionerr-container--) +* [`client.createContainer(container, function(err, container) { })`](#clientcreatecontainercontainer-functionerr-container--) +* [`client.destroyContainer(container, function(err, result) { })`](#clientdestroycontainercontainer-functionerr-result--) +* [`client.updateContainerMetadata(container, function(err, container) { })`](#clientupdatecontainermetadatacontainer-functionerr-container--) +* [`client.removeContainerMetadata(container, metadataToRemove, function(err, container) { })`](#clientremovecontainermetadatacontainer-metadatatoremove-functionerr-container--) + +### Container API Details + +For all of the container methods, you can pass either an instance of [`container`](#container) or the container name as `container`. For example: + +```Javascript +client.getContainer('my-container', function(err, container) { ... }); +``` + +This call is functionally equivalent to: + +```Javascript +var myContainer = new Container({ name: 'my-container' }); + +client.getContainer(myContainer, function(err, container) { ... }); +``` + +#### client.getContainers(function(err, containers) { }) + +Retreives the containers for the current client instance as an array of [`container`](#container-model) + +#### client.getContainer(container, function(err, container) { }) + +Retrieves the specified [`container`](#container-model) from the current client instance. + +#### client.createContainer(container, function(err, container) { }) + +Creates a new [`container`](#container-model) with the name from argument `container`. You can optionally provide `metadata` on the request: + +```javascript +client.createContainer({ + name: 'my-container', + metadata: { + brand: 'bmw', + model: '335i' + year: 2009 + }}, function(err, container) { + // ... + }) +``` + +#### client.destroyContainer(container, function(err, result) { }) + +Removes the [`container`](#container-model) from the storage account. If there are any files within the `container`, they will be deleted before removing the `container` on the client. `result` will be `true` on success. + +#### client.updateContainerMetadata(container, function(err, container) { }) + +Updates the metadata on the provided [`container`](#container-model) . Currently, the `updateContainer` method only adds new metadata fields. If you need to remove specific metadata properties, you should call `client.removeContainerMetadata(...)`. + +```javascript +container.metadata.color = 'red'; +client.updateContainerMetadata(container, function(err, container) { + // ... +}) +``` + +#### client.removeContainerMetadata(container, metadataToRemove, function(err, container) { }) + +Removes the keys in the `metadataToRemove` object from the stored [`container`](#container-model) metadata. + +```Javascript +client.removeContainerMetadata(container, { year: false }, function(err, c) { + // ... +}); +``` + +### File APIs + +* [`client.upload(options, function(err, result) { })`](#clientuploadoptions-functionerr-result--) +* [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) +* [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) +* [`client.getFiles(container, function(err, file) { })`](#clientgetfilescontainer-functionerr-file--) +* [`client.removeFile(container, file, function(err, result) { })`](#clientremovefilecontainer-file-functionerr-result--) +* [`client.updateFileMetadata(container, file, function(err, file) { })`](#clientupdatefilemetadatacontainer-file-functionerr-file--) + +### File API Details + +For all of the file methods, you can pass either an instance of [`container`](#container-model) or the container name as `container`. For example: + +```Javascript +client.getFile('my-container', 'my-file', function(err, file) { ... }); +``` + +This call is functionally equivalent to: + +```Javascript +var myContainer = new Container({ name: 'my-container' }); + +client.getFile(myContainer, 'my-file', function(err, file) { ... }); +``` + +#### client.upload(options, function(err, result) { }) + +Returns a writeable stream. Upload a new file to a [`container`](#container-model). `result` will be `true` on success. + +To upload a file, you need to provide an `options` argument: + +```Javascript +var options = { + // required options + container: 'my-container', // this can be either the name or an instance of container + remote: 'my-file', // name of the new file + + // optional, either stream or local + stream: myStream, // any instance of a readable stream + local: '/path/to/local/file' // a path to any local file + + // Other optional values + metadata: { // provide any number of property/values for metadata + campaign: '2012 magazine' + }, + headers: { // optionally provide raw headers to send to cloud files + 'content-type': 'application/json' + } +}; +``` + +You need not provide either `stream` or `local`. `client.upload` returns a writeable stream, so you can simply pipe directly into it from your stream. For example: + +```Javascript +var fs = require('fs'), + pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +var myFile = fs.createReadStream('/my/local/file'); + +myFile.pipe(client.upload({ + container: 'my-container', + remote: 'my-file' +}, function(err, result) { + // handle the upload result +})); +``` + +You could also upload a local file via the `local` property on `options`: + +```Javascript +var pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +client.upload({ + container: 'my-container', + remote: 'my-file', + local: '/path/to/my/file' +}, function(err, result) { + // handle the upload result +}); +``` + +This is functionally equivalent to piping from an `fs.createReadStream`, but has a simplified calling convention. + +#### client.download(options, function(err, file) { }) + +Returns a readable stream. Download a [`file`](#file-model) from a [`container`](#container-model). + +To download a file, you need to provide an `options` argument: + +```Javascript +var options = { + // required options + container: 'my-container', // this can be either the name or an instance of container + remote: 'my-file', // name of the new file + + // optional, either stream or local + stream: myStream, // any instance of a writeable stream + local: '/path/to/local/file' // the path to a local file to write to +}; +``` + +You need not provide either `stream` or `local`. `client.download` returns a readable stream, so you can simply pipe it into your writeable stream. For example: + +```Javascript +var fs = require('fs'), + pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +var myFile = fs.createWriteStream('/my/local/file'); + +client.download({ + container: 'my-container', + remote: 'my-file' +}, function(err, result) { + // handle the download result +})).pipe(myFile); +``` + +You could also download to a local file via the `local` property on `options`: + +```Javascript +var pkgcloud = require('pkgcloud'); + +var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + +client.download({ + container: 'my-container', + remote: 'my-file', + local: '/path/to/my/file' +}, function(err, result) { + // handle the download result +}); +``` + +This is functionally equivalent to piping from an `fs.createWriteStream`, but has a simplified calling convention. + +#### client.getFile(container, file, function(err, file) { }) + +Retrieves the specified [`file`](#file-model) details in the specified [`container`](#container-model) from the current client instance. + +#### client.getFiles(container, function(err, files) { }) + +Retreives an array of [`file`](#file-model) for the provided [`container`](#container-model). + +#### client.removeFile(container, file, function(err, result) { }) + +Removes the provided [`file`](#file-model) from the provided [`container`](#container-model). + +#### client.updateFileMetadata(container, file, function(err, file) { }) + +Updates the [`file`](#file-model) metadata in the the provided [`container`](#container-model). + +File metadata is completely replaced with each callt o updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`. +```javascript +file.metadata = { + campaign = '2011 website' +}; + +client.updateFileMetadata(file.container, file, function(err, file) { + // ... +}); +``` From 5f3af3b001bcd788f0810206cd4a55db7da80afd Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 09:56:45 -0700 Subject: [PATCH 037/460] Change provider type to 'HP' --- docs/providers/hp/README.md | 16 ++++++++-------- docs/providers/hp/compute.md | 2 +- docs/providers/hp/storage.md | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 65f1d7b22..9a14bb167 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -14,7 +14,7 @@ For all of the HP Cloud services, you create a client with the same options: ```Javascript var client = require('pkgcloud').compute.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', password: 'your-api-key' }); @@ -24,20 +24,20 @@ In addition to your `apiKey`, you could alternately provide your `password` as a ### Authentication Endpoints and Regions -All of the Rackspace `createClient` calls have a few options that can be provided: +All of the hp `createClient` calls have a few options that can be provided: #### authUrl -`authUrl` specifies the authentication endpoint used to create a token for your Rackspace client. By default, this is set to the Global endpoint: https://identity.api.rackspacecloud.com. +`authUrl` specifies the authentication endpoint used to create a token for your hp client. By default, this is set to the Global endpoint: https://identity.api.hpcloud.com. ##### Authenticating against the London endpoint ```Javascript var client = require('pkgcloud').compute.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', apiKey: 'your-api-key', - authUrl: 'https://lon.identity.api.rackspacecloud.com' + authUrl: 'https://lon.identity.api.hpcloud.com' }); ``` @@ -49,7 +49,7 @@ var client = require('pkgcloud').compute.createClient({ ```Javascript var client = require('pkgcloud').compute.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', apiKey: 'your-api-key', region: 'ORD' @@ -58,7 +58,7 @@ var client = require('pkgcloud').compute.createClient({ #### Tokens and Expiration -When you make your first call to a Rackspace provider, your client is authenticated transparent to your API call. Rackspace will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. +When you make your first call to a hp provider, your client is authenticated transparent to your API call. hp will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. #### Internal URLs @@ -66,7 +66,7 @@ As part of the options, you can tell `pkgcloud` to use the Internal (Service Net ```Javascript var client = require('pkgcloud').storage.createClient({ - provider: 'rackspace', + provider: 'hp', username: 'your-user-name', apiKey: 'your-api-key', useInternal: true diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md index f3c724ead..f79956dcb 100644 --- a/docs/providers/hp/compute.md +++ b/docs/providers/hp/compute.md @@ -115,7 +115,7 @@ Destroys the specified image and returns a confirmation ## Volume Attachments -Attaching a volume to a compute instance requires using a rackspace compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. +Attaching a volume to a compute instance requires using a hp compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. #### client.getVolumeAttachments(server, callback) diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index 80f599b38..d1406ee1f 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -183,7 +183,7 @@ You need not provide either `stream` or `local`. `client.upload` returns a write var fs = require('fs'), pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); var myFile = fs.createReadStream('/my/local/file'); @@ -200,7 +200,7 @@ You could also upload a local file via the `local` property on `options`: ```Javascript var pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); client.upload({ container: 'my-container', @@ -237,7 +237,7 @@ You need not provide either `stream` or `local`. `client.download` returns a rea var fs = require('fs'), pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); var myFile = fs.createWriteStream('/my/local/file'); @@ -254,7 +254,7 @@ You could also download to a local file via the `local` property on `options`: ```Javascript var pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.hp.storage.createClient({ ... }); client.download({ container: 'my-container', From 97a494a01badca8437d79fac75e99bb1a8e287d3 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:14:41 -0700 Subject: [PATCH 038/460] Adding documentation for regions in HP Cloud. --- docs/README.md | 2 ++ docs/providers/hp/README.md | 39 +++++++++++++++++++++++++----------- docs/providers/hp/compute.md | 4 ++-- docs/providers/hp/storage.md | 6 +++--- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/README.md b/docs/README.md index ab2fbbf20..700533db8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,12 +18,14 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](providers/amazon.md#using-compute) * [Azure](providers/azure.md#using-compute) * [DigitalOcean](providers/digitalocean.md#using-compute) + * [HP](providers/hp/compute.md) * [Joyent](providers/joyent.md#using-compute) * [Openstack](providers/openstack/compute.md) * [Rackspace](providers/rackspace/compute.md) * **Storage** * [Amazon](providers/amazon.md#using-storage) * [Azure](providers/azure.md#using-storage) + * [HP](providers/hp/storage.md) * [Openstack](providers/openstack/storage.md) * [Rackspace](providers/rackspace/storage.md) * **Databases** diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 9a14bb167..5b40a7a9a 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -4,6 +4,7 @@ The HP Cloud provider in pkgcloud supports the following services: * [**Compute**](compute.md) (Cloud Servers) * [**Storage**](storage.md) (Cloud Files) + ### Getting Started with Compute We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. @@ -16,34 +17,48 @@ For all of the HP Cloud services, you create a client with the same options: var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-api-key' + password: 'your-password' }); ``` -In addition to your `apiKey`, you could alternately provide your `password` as an option to `createClient`. - ### Authentication Endpoints and Regions -All of the hp `createClient` calls have a few options that can be provided: +All of the HP `createClient` calls have a few options that can be provided: #### authUrl -`authUrl` specifies the authentication endpoint used to create a token for your hp client. By default, this is set to the Global endpoint: https://identity.api.hpcloud.com. +`authUrl` specifies the authentication endpoint used to create a token for your HP client. +The HP Identity Service is currently available in two regions which can be accessed via these URLs. +See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) + +##### Authenticating against the US-West endpoint + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region-a.geo-1', + authUrl: 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/' +}); +``` -##### Authenticating against the London endpoint +##### Authenticating against the US-East endpoint ```Javascript var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - apiKey: 'your-api-key', - authUrl: 'https://lon.identity.api.hpcloud.com' + password: 'your-password', + region: 'region-b.geo-1', + authUrl: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/' }); ``` #### region -`region` specifies which region of a service to use. For example, when you authenticate with the global endpoint for compute, you have the option of either `DFW`, `ORD`, or `SYD`. The default region is `DFW`. Previous pkgcloud versions did not let you specify which region you used, so all calls were against `DFW`. +`region` specifies which region of a service to use. HP has authentication endpoints specific to each region. +Please see section above for the endpoints and regions. ##### Specifying a custom region @@ -51,14 +66,14 @@ var client = require('pkgcloud').compute.createClient({ var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - apiKey: 'your-api-key', + password: 'your-password', region: 'ORD' }); ``` #### Tokens and Expiration -When you make your first call to a hp provider, your client is authenticated transparent to your API call. hp will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. +When you make your first call to a HP provider, your client is authenticated transparent to your API call. HP will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. #### Internal URLs @@ -68,7 +83,7 @@ As part of the options, you can tell `pkgcloud` to use the Internal (Service Net var client = require('pkgcloud').storage.createClient({ provider: 'hp', username: 'your-user-name', - apiKey: 'your-api-key', + password: 'your-password', useInternal: true }); ``` diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md index f79956dcb..5568d6462 100644 --- a/docs/providers/hp/compute.md +++ b/docs/providers/hp/compute.md @@ -3,7 +3,7 @@ Creating a client is straight-forward: ``` js - var hpCompute = pkgcloud.compute.createClient({ + var HPCompute = pkgcloud.compute.createClient({ provider: 'hp', username: 'your-user-name', password: 'your-password', @@ -115,7 +115,7 @@ Destroys the specified image and returns a confirmation ## Volume Attachments -Attaching a volume to a compute instance requires using a hp compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. +Attaching a volume to a compute instance requires using a HP compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. #### client.getVolumeAttachments(server, callback) diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index d1406ee1f..894277468 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -19,11 +19,11 @@ Creating a client is straight-forward: }); ``` -Learn about [more options for creating clients](README.md) in the Openstack `storage` provider. +Learn about [more options for creating clients](README.md) in the HP `storage` provider. ### Container Model -A Container for Openstack has following properties: +A Container for HP has following properties: ```Javascript { @@ -38,7 +38,7 @@ A Container for Openstack has following properties: ### File Model -A File for Openstack has the following properties: +A File for HP has the following properties: ```Javascript { From e8696fac2522f9adf61eae85088965bbaa3f82c1 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:23:13 -0700 Subject: [PATCH 039/460] Adding links to HP documentation in Readme, updating vocabulary. --- README.md | 36 ++++++++++++++++++++---------------- docs/vocabulary.md | 4 ++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3368d4837..80037a2c1 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,13 @@ Services provided by `pkgcloud` are exposed in two ways: * **By service type:** For example, if you wanted to create an API client to communicate with a compute service you could simply: -``` js +``` js var client = require('pkgcloud').compute.createClient({ // // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -96,12 +96,14 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) + * [HP](docs/providers/hp.md#using-compute) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) * **[Storage](#storage)** * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) + * [HP](docs/providers/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) * **[Database](#databases)** @@ -127,7 +129,7 @@ The `pkgcloud.compute` service is designed to make it easy to provision and work // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -139,6 +141,7 @@ Each compute provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) +* [HP](docs/providers/hp.md#using-compute) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) @@ -174,7 +177,7 @@ To get started with a `pkgcloud.storage` client just create one: // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -185,6 +188,7 @@ Each storage provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) +* [HP](docs/providers/hp.md#using-storage) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) @@ -209,9 +213,9 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ``` js var pkgcloud = require('pkgcloud'), fs = require('fs'); - + var client = pkgcloud.storage.createClient({ /* ... */ }); - + fs.createReadStream('a-file.txt').pipe(client.upload({ container: 'a-container', remote: 'remote-file-name.txt' @@ -222,9 +226,9 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ``` js var pkgcloud = require('pkgcloud'), fs = require('fs'); - + var client = pkgcloud.storage.createClient({ /* ... */ }); - + client.download({ container: 'a-container', remote: 'remote-file-name.txt' @@ -233,7 +237,7 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ## Databases -The `pkgcloud.database` service is designed to consistently work with a variety of Database-as-a-Service (DBaaS) providers. +The `pkgcloud.database` service is designed to consistently work with a variety of Database-as-a-Service (DBaaS) providers. To get started with a `pkgcloud.storage` client just create one: @@ -243,7 +247,7 @@ To get started with a `pkgcloud.storage` client just create one: // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -285,7 +289,7 @@ To get started with a `pkgcloud.dns` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -326,7 +330,7 @@ To get started with a `pkgcloud.blockstorage` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -367,7 +371,7 @@ To get started with a `pkgcloud.loadbalancer` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -435,13 +439,13 @@ Also you can run the tests directly using `mocha` with `hock` enabled: ``` bash Linux/Mac - Mocha installed globally: $ MOCK=on mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js - + Linux/Mac - Mocha installed locally: $ MOCK=on node_modules/.bin/mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js Windows - Mocha installed globally: $ set MOCK=on&mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js - + Windows - Mocha installed locally: $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/*/*/*-test.js test/*/*/*/*-test.js ``` @@ -457,7 +461,7 @@ Linux/Mac - Mocha installed locally: Windows - Mocha installed globally: $ set MOCK=on&mocha -R spec test/iriscouch/*/*-test.js - + Windows - Mocha installed locally: $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/iriscouch/*/*-test.js diff --git a/docs/vocabulary.md b/docs/vocabulary.md index f6c2d6a33..053c545a5 100644 --- a/docs/vocabulary.md +++ b/docs/vocabulary.md @@ -13,6 +13,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis Azure Rackspace DigitalOcean + HP Server @@ -22,6 +23,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis Virtual Machine Server Droplet + Server Image @@ -31,6 +33,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis Image Image Image + Image Flavor @@ -40,6 +43,7 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis RoleSize Flavor Size + Flavor From f87de5f0253028d11a1673500e0cd1b5475765c4 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:26:17 -0700 Subject: [PATCH 040/460] Fixing hyperlinks. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80037a2c1..8378a9699 100644 --- a/README.md +++ b/README.md @@ -96,14 +96,14 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) - * [HP](docs/providers/hp.md#using-compute) + * [HP](docs/providers/compute.md) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) * **[Storage](#storage)** * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) - * [HP](docs/providers/storage.md) + * [HP](docs/providers/hp/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) * **[Database](#databases)** From a7c26d64d8c65155021375002dd92d3248ca15ac Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:28:19 -0700 Subject: [PATCH 041/460] Fixing links in top-level readme. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8378a9699..1a6c86762 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Each compute provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) -* [HP](docs/providers/hp.md#using-compute) +* [HP](docs/providers/hp/compute.md) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) @@ -188,7 +188,7 @@ Each storage provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) -* [HP](docs/providers/hp.md#using-storage) +* [HP](docs/providers/hp/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) From ec0cd4837f76797d6783188abc135a035c21a461 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:31:51 -0700 Subject: [PATCH 042/460] Adding using compute example. --- docs/providers/hp/getting-started-compute.md | 97 ++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 docs/providers/hp/getting-started-compute.md diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md new file mode 100644 index 000000000..092dda9c7 --- /dev/null +++ b/docs/providers/hp/getting-started-compute.md @@ -0,0 +1,97 @@ +# Getting started with pkgcloud & HP + +The HP node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package + +Pkgcloud currently supports Openstack Nova (compute) and Openstack Swift (storage). + +To install `pkgcloud` from the command line: + +``` +npm install pkgcloud +``` + +Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). + +## Using pkgcloud + +In this example, we're going to create a HP Cloud compute client, create two servers, and then output their details to the command line. + +*Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* + +```Javascript +var pkgcloud = require('pkgcloud'), + _ = require('underscore'); + +// create our client with your openstack credentials +var client = pkgcloud.compute.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region of identity service', + authUrl: 'https://your-identity-service' +}); + +// first we're going to get our flavors +client.getFlavors(function (err, flavors) { + if (err) { + console.dir(err); + return; + } + + // then get our base images + client.getImages(function (err, images) { + if (err) { + console.dir(err); + return; + } + + // Pick a 512MB instance flavor + var flavor = _.findWhere(flavors, { name: '512MB Standard Instance' }); + + // Pick an image based on Ubuntu 12.04 + var image = _.findWhere(images, { name: 'Ubuntu 12.04 LTS (Precise Pangolin)' }); + + // Create our first server + client.createServer({ + name: 'server1', + image: image, + flavor: flavor + }, handleServerResponse); + + // Create our second server + client.createServer({ + name: 'server2', + image: image, + flavor: flavor + }, handleServerResponse); + }); +}); + +// This function will handle our server creation, +// as well as waiting for the server to come online after we've +// created it. +function handleServerResponse(err, server) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); + + // Wait for status: ACTIVE on our server, and then callback + server.setWait({ status: 'ACTIVE' }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER INFO'); + console.log(server.name); + console.log(server.status); + console.log(server.id); + + console.log('Make sure you DELETE server: ' + server.id + + ' in order to not accrue billing charges'); + }); +} +``` From bfd59212e1a9697ac33bb4e0188515686cea3cf0 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 10:33:00 -0700 Subject: [PATCH 043/460] More links in the home page. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a6c86762..223991102 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ If a service does not have at least two providers, it is considered a *beta* int * [Amazon](docs/providers/amazon.md#using-compute) * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) - * [HP](docs/providers/compute.md) + * [HP](docs/providers/hp/compute.md) * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) From 2c494d145dae39272c0ad26b3925f63d7e705830 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 14:38:57 -0700 Subject: [PATCH 044/460] Adding tests for region detection and automatic identity service location. --- lib/pkgcloud/hp/client.js | 52 ++++++++++++ lib/pkgcloud/hp/compute/client/index.js | 26 ++++++ lib/pkgcloud/hp/compute/index.js | 16 ++++ lib/pkgcloud/hp/identity/hpIdentity.js | 50 +++++++++++ lib/pkgcloud/hp/identity/index.js | 9 ++ lib/pkgcloud/hp/index.js | 9 +- lib/pkgcloud/hp/storage/client/index.js | 29 +++++++ lib/pkgcloud/hp/storage/index.js | 15 ++++ test/hp/common/client-test.js | 106 ++++++++++++++++++++++++ 9 files changed, 308 insertions(+), 4 deletions(-) create mode 100644 lib/pkgcloud/hp/client.js create mode 100644 lib/pkgcloud/hp/compute/client/index.js create mode 100644 lib/pkgcloud/hp/compute/index.js create mode 100644 lib/pkgcloud/hp/identity/hpIdentity.js create mode 100644 lib/pkgcloud/hp/identity/index.js create mode 100644 lib/pkgcloud/hp/storage/client/index.js create mode 100644 lib/pkgcloud/hp/storage/index.js create mode 100644 test/hp/common/client-test.js diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js new file mode 100644 index 000000000..d89f5eb54 --- /dev/null +++ b/lib/pkgcloud/hp/client.js @@ -0,0 +1,52 @@ +/* + * client.js: Base client from which all HP clients inherit from + * + * (C) 2014 HP. + * + */ + +var utile = require('utile'), + identity = require('./identity'), + base = require('../openstack/client'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + options = options || {}; + var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1', + eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/', + westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'; + if(!options.region){ + throw new Error('region is not valid. Available regions are '+westUSRegion+' (US-West), '+eastUSRegion+'(US-East)'); + } + + if(!options.authUrl || options.authUrl.length === 0) { + if(options.region === eastUSRegion){ + options.authUrl = eastUSIdentityService; + } + else if(options.region === westUSRegion){ + options.authUrl = westUSIdentityService; + } + else{ + throw new Error('authUrl is invalid'); + } + } + + options.identity = identity.Identity; + + if (typeof options.useServiceCatalog === 'undefined') { + options.useServiceCatalog = true; + } + + base.Client.call(this, options); + + this.provider = 'hp'; +}; + +utile.inherits(Client, base.Client); + +Client.prototype._getIdentityOptions = function() { + + return _.extend({ + apiKey: this.config.apiKey + }, Client.super_.prototype._getIdentityOptions.call(this)); +}; diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js new file mode 100644 index 000000000..9bc012852 --- /dev/null +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -0,0 +1,26 @@ +/* + * client.js: Compute client for HP Cloudservers + * + * (C) 2014 HP + * Phani Raj + * + */ + +var utile = require('utile'), + hp = require('../../client'), + ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, + _ = require('underscore'); + +var Client = exports.Client = function (options) { + hp.Client.call(this, options); + debugger; + utile.mixin(this, require('../../../openstack/compute/client/flavors')); + utile.mixin(this, require('../../../openstack/compute/client/images')); + utile.mixin(this, require('../../../openstack/compute/client/servers')); + utile.mixin(this, require('../../../openstack/compute/client/extensions')); + + this.serviceType = 'compute'; +}; + +utile.inherits(Client, hp.Client); +_.extend(Client.prototype, ComputeClient.prototype); diff --git a/lib/pkgcloud/hp/compute/index.js b/lib/pkgcloud/hp/compute/index.js new file mode 100644 index 000000000..486ee5bb1 --- /dev/null +++ b/lib/pkgcloud/hp/compute/index.js @@ -0,0 +1,16 @@ + /* + * index.js: Top-level include for the Rackspace storage module + * + * (C) 2014 HP + * Phani Raj + * + */ + +exports.Client = require('./client').Client; +exports.Flavor = require('../../openstack/compute/flavor').Flavor; +exports.Image = require('../../openstack/compute/image').Image; +exports.Server = require('../../openstack/compute/server').Server; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/hp/identity/hpIdentity.js b/lib/pkgcloud/hp/identity/hpIdentity.js new file mode 100644 index 000000000..25ea38511 --- /dev/null +++ b/lib/pkgcloud/hp/identity/hpIdentity.js @@ -0,0 +1,50 @@ +/* + * hpIdentity.js: hpIdentity model + * + * (C) 2014 HP + * Phani Raj + * + */ + +var _ = require('underscore'), + identity = require('../../openstack/context'), + events = require('eventemitter2'), + Identity = identity.Identity, + util = require('util'); + +exports.Identity = HPIdentity = function (options) { + this.options = options; + this.name = 'HPIdentity'; + + this.useServiceCatalog = (typeof options.useServiceCatalog === 'boolean') + ? options.useServiceCatalog + : true; + + events.EventEmitter2.call(this, { delimiter: '::', wildcard: true }); +}; + +util.inherits(HPIdentity, events.EventEmitter2); +util.inherits(HPIdentity, Identity); + +HPIdentity.prototype._buildAuthenticationPayload = function () { + var self = this; + + HPIdentity.super_.prototype._buildAuthenticationPayload.call(this); + + this.emit('log::trace', 'Building HP Identity Auth Payload'); + + if (!self._authenticationPayload) { + // setup our inputs for authorization + // access key & secret key + if (self.options.apiKey && self.options.username) { + self._authenticationPayload = { + auth: { + 'apiAccessKeyCredentials': { + 'accessKey': self.options.username, + 'secretKey': self.options.apiKey + } + } + }; + } + } +}; diff --git a/lib/pkgcloud/hp/identity/index.js b/lib/pkgcloud/hp/identity/index.js new file mode 100644 index 000000000..9465530d1 --- /dev/null +++ b/lib/pkgcloud/hp/identity/index.js @@ -0,0 +1,9 @@ +/* + * index.js: Identity models + * + * (C) 2014 HP + * Phani Raj + * + */ + +module.exports = require('./hpIdentity'); diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js index 2cd7883a3..2b23bc93c 100644 --- a/lib/pkgcloud/hp/index.js +++ b/lib/pkgcloud/hp/index.js @@ -1,9 +1,10 @@ /* - * index.js: Top-level include for the HP provider. + * index.js: Top-level include for the HP module. * - * (C) 2014 HP Inc. + * (C) 2014 HP + * Phani Raj * */ -exports.compute = require('../openstack/compute'); -exports.storage = require('../openstack/storage'); +exports.storage = require('./storage'); +exports.compute = require('./compute'); diff --git a/lib/pkgcloud/hp/storage/client/index.js b/lib/pkgcloud/hp/storage/client/index.js new file mode 100644 index 000000000..123f31345 --- /dev/null +++ b/lib/pkgcloud/hp/storage/client/index.js @@ -0,0 +1,29 @@ +/* + * index.js: Storage client for HP Cloudservers + * + * (C) 2014 HP + * Phani Raj + * + */ + +var utile = require('utile'), + hp = require('../../client'), + StorageClient = require('../../../openstack/storage/storageClient').StorageClient, + _ = require('underscore'); + +var Client = exports.Client = function (options) { + hp.Client.call(this, options); + + this.models = { + Container: require('../../../openstack/storage/container').Container, + File: require('../../../openstack/storage/file').File + }; + + utile.mixin(this, require('../../../openstack/storage/client/containers')); + utile.mixin(this, require('../../../openstack/storage/client/files')); + + this.serviceType = 'object-store'; +}; + +utile.inherits(Client, hp.Client); +_.extend(Client.prototype, StorageClient.prototype); diff --git a/lib/pkgcloud/hp/storage/index.js b/lib/pkgcloud/hp/storage/index.js new file mode 100644 index 000000000..44df5611d --- /dev/null +++ b/lib/pkgcloud/hp/storage/index.js @@ -0,0 +1,15 @@ + /* + * index.js: Top-level include for the HP storage module + * + * (C) 2014 HP + * Phani Raj + * + */ + +exports.Client = require('./client').Client; +exports.Container = require('../../openstack/storage/container').Container; +exports.File = require('../../openstack/storage/file').File; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js new file mode 100644 index 000000000..db3c981f2 --- /dev/null +++ b/test/hp/common/client-test.js @@ -0,0 +1,106 @@ +/* +* client-test.js: Tests for pkgcloud HP client functionality. +* +* (C) 2014 Phani Raj. +* +*/ + +var should = require('should'), + async = require('async'), + hock = require('hock'), + pkgcloud = require('../../../lib/pkgcloud'), + mock = !!process.env.MOCK; + +describe('pkgcloud/hp/client', function () { + describe('Region validation', function () { + var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1'; + it('User should specify region: compute client', function() { + (function () { + pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password" + }); + }).should.throw(new Error("region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)');")); + }); + + it('User should specify region: storage client', function() { + (function () { + pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password" + }); + }).should.throw(new Error("region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)');")); + }); + + + it('User can specify custom region: storage client', function() { + var customRegionClient = pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": "mycustomregion", + "authUrl": "http://my-identity-service.com" + }); + + customRegionClient.config.should.have.property('region','mycustomregion'); + }); + + it('User can specify custom region: compute client', function() { + var customRegionClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": "mycustomregion", + "authUrl": "http://my-identity-service.com" + }); + + customRegionClient.config.should.have.property('region','mycustomregion'); + }); + + it('Client will auto-locate identity service for East US region : compute client', function() { + var eastUSClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": eastUSRegion + }); + + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + + it('Client will auto-locate identity service for East US region : storage client', function() { + var eastUSClient = pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": eastUSRegion + }); + + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + + it('Client will auto-locate identity service for West US region : compute client', function() { + var westUSClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": westUSRegion + }); + + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + + it('Client will auto-locate identity service for West US region : storage client', function() { + var westUSClient = pkgcloud.storage.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "region": westUSRegion + }); + + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + }); + }); +}); From ab257632d147f9dc0cf18387410ca67d6d9f9713 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 14:46:23 -0700 Subject: [PATCH 045/460] Moving HP provider tests to use api key and user name. --- test/common/compute/base-test.js | 14 +++++++------- test/common/compute/server-test.js | 12 ++++++------ test/common/storage/base-test.js | 14 +++++++------- test/configs/mock/hp.json | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 82be22039..4878b2077 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -66,7 +66,7 @@ providers.forEach(function(provider) { server: server }); } - + if (errors) { client.getVersion(function (err) { err.should.be.an.instanceof(Error); @@ -264,9 +264,9 @@ function setupVersionMock(client, provider, servers) { servers.authServer .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' } } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) @@ -275,9 +275,9 @@ function setupVersionMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index bc01948e0..acddd558f 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -300,9 +300,9 @@ function setupImagesMock(client, provider, servers) { servers.authServer .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' } } }) @@ -311,9 +311,9 @@ function setupImagesMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 9e1aa4a6e..0b8c35e36 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -516,9 +516,9 @@ function setupCreateContainerMock(provider, client, servers) { servers.authServer .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' } } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) @@ -527,9 +527,9 @@ function setupCreateContainerMock(provider, client, servers) { .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } @@ -758,4 +758,4 @@ function setupGetContainers2Mock(provider, client, servers) { .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/preContainers.json')); } -} \ No newline at end of file +} diff --git a/test/configs/mock/hp.json b/test/configs/mock/hp.json index 5a48bef79..2d1a6b796 100644 --- a/test/configs/mock/hp.json +++ b/test/configs/mock/hp.json @@ -1,6 +1,6 @@ { "username":"MOCK-USERNAME", - "password":"MOCK-PASSWORD", + "apiKey": "MOCK-API-KEY", "authUrl":"http://localhost:12346", "region": "Calxeda-AUS1" } From e476f6862728c5d461c017f9d9a25a902e001283 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 14:50:34 -0700 Subject: [PATCH 046/460] Fixing auto detection of Identity service endpoint to be version agnostic. --- lib/pkgcloud/hp/client.js | 4 ++-- test/hp/common/client-test.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index d89f5eb54..d52d22228 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -13,8 +13,8 @@ var utile = require('utile'), var Client = exports.Client = function (options) { options = options || {}; var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1', - eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/', - westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'; + eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/', + westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/'; if(!options.region){ throw new Error('region is not valid. Available regions are '+westUSRegion+' (US-West), '+eastUSRegion+'(US-East)'); } diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js index db3c981f2..ecfed2627 100644 --- a/test/hp/common/client-test.js +++ b/test/hp/common/client-test.js @@ -67,7 +67,7 @@ describe('pkgcloud/hp/client', function () { "region": eastUSRegion }); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); }); it('Client will auto-locate identity service for East US region : storage client', function() { @@ -78,7 +78,7 @@ describe('pkgcloud/hp/client', function () { "region": eastUSRegion }); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); }); it('Client will auto-locate identity service for West US region : compute client', function() { @@ -89,7 +89,7 @@ describe('pkgcloud/hp/client', function () { "region": westUSRegion }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); }); it('Client will auto-locate identity service for West US region : storage client', function() { @@ -100,7 +100,7 @@ describe('pkgcloud/hp/client', function () { "region": westUSRegion }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/'); + westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); }); }); }); From 0513c79ecfa52ceccac22282679b71fb11785464 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 19:25:29 -0700 Subject: [PATCH 047/460] Adding tests for secret key authentication with HP Cloud Compute client. --- test/common/storage/base-test.js | 2 +- test/configs/mock/hp.json | 2 +- test/fixtures/hp/images.json | 2 +- test/fixtures/hp/realToken-admin.json | 16 +- .../hp/realToken-multiRegionVolume.json | 18 +- test/fixtures/hp/realToken.json | 18 +- test/hp/compute/authentication-test.js | 228 ++++++++++++++++++ test/hp/macros.js | 108 +++++++++ 8 files changed, 365 insertions(+), 29 deletions(-) create mode 100644 test/hp/compute/authentication-test.js create mode 100644 test/hp/macros.js diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 0b8c35e36..5746460d9 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -534,7 +534,7 @@ function setupCreateContainerMock(provider, client, servers) { tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers.getOpenstackAuthResponse()); + .reply(200, helpers.gethpAuthResponse()); servers.server .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') diff --git a/test/configs/mock/hp.json b/test/configs/mock/hp.json index 2d1a6b796..e9081e7b2 100644 --- a/test/configs/mock/hp.json +++ b/test/configs/mock/hp.json @@ -2,5 +2,5 @@ "username":"MOCK-USERNAME", "apiKey": "MOCK-API-KEY", "authUrl":"http://localhost:12346", - "region": "Calxeda-AUS1" + "region": "region-a.geo-1" } diff --git a/test/fixtures/hp/images.json b/test/fixtures/hp/images.json index cf05cf7ec..f5f75adb9 100644 --- a/test/fixtures/hp/images.json +++ b/test/fixtures/hp/images.json @@ -25,4 +25,4 @@ "metadata": {} } ] -} \ No newline at end of file +} diff --git a/test/fixtures/hp/realToken-admin.json b/test/fixtures/hp/realToken-admin.json index 3526ee0f2..f3548289c 100644 --- a/test/fixtures/hp/realToken-admin.json +++ b/test/fixtures/hp/realToken-admin.json @@ -15,7 +15,7 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } @@ -27,11 +27,11 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:9292/v1", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:9292/v1", "publicURL": "http://image.myownendpoint.org:9292/v1" } - ], + ], "endpoints_links": [], "type": "image", "name": "glance" @@ -39,19 +39,19 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "compute", "name": "nova" }, { "endpoints": [ { "adminURL": "http://localhost:12347/v2.0", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:5000/v2.0", "publicURL": "http://identity.myownendpoint.org:5000/v2.0" } @@ -69,4 +69,4 @@ "name": "MOCK-ADMIN" } } -} \ No newline at end of file +} diff --git a/test/fixtures/hp/realToken-multiRegionVolume.json b/test/fixtures/hp/realToken-multiRegionVolume.json index 88df5a1c0..db2af928e 100644 --- a/test/fixtures/hp/realToken-multiRegionVolume.json +++ b/test/fixtures/hp/realToken-multiRegionVolume.json @@ -15,13 +15,13 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" }, { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS2", + "region": "region-b.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } @@ -33,11 +33,11 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:9292/v1", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:9292/v1", "publicURL": "http://image.myownendpoint.org:9292/v1" } - ], + ], "endpoints_links": [], "type": "image", "name": "glance" @@ -45,19 +45,19 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "compute", "name": "nova" }, { "endpoints": [ { "adminURL": "http://10.225.0.8:35357/v2.0", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:5000/v2.0", "publicURL": "http://identity.myownendpoint.org:5000/v2.0" } @@ -75,4 +75,4 @@ "name": "MOCK-USERNAME" } } -} \ No newline at end of file +} diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 2636f092e..278c3b9f1 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -15,7 +15,7 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8776/v1/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://volume.myownendpoint.org:8776/v1/5ACED3DC3AA740ABAA41711243CC6949" } @@ -27,11 +27,11 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:9292/v1", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:9292/v1", "publicURL": "http://image.myownendpoint.org:9292/v1" } - ], + ], "endpoints_links": [], "type": "image", "name": "glance" @@ -39,19 +39,19 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "compute", "name": "nova" }, { "endpoints": [ { - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "tenantId": "MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", "publicURL": "http://localhost:12345/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" @@ -64,7 +64,7 @@ "endpoints": [ { "adminURL": "http://10.225.0.8:35357/v2.0", - "region": "Calxeda-AUS1", + "region": "region-a.geo-1", "internalURL": "http://10.225.0.8:5000/v2.0", "publicURL": "http://identity.myownendpoint.org:5000/v2.0" } @@ -82,4 +82,4 @@ "name": "MOCK-USERNAME" } } -} \ No newline at end of file +} diff --git a/test/hp/compute/authentication-test.js b/test/hp/compute/authentication-test.js new file mode 100644 index 000000000..6dd31b4c4 --- /dev/null +++ b/test/hp/compute/authentication-test.js @@ -0,0 +1,228 @@ +/* +* authentication-test.js: Tests for pkgcloud hp compute authentication +* +* (C) 2014 HP. +* +*/ + +var should = require('should'), + async = require('async'), + hock = require('hock'), + macros = require('../macros'), + helpers = require('../../helpers'), + mock = !!process.env.MOCK; + +describe('pkgcloud/hp/compute/authentication', function () { + var client, authServer, server; + + describe('The pkgcloud hp Compute client', function () { + + before(function (done) { + client = helpers.createClient('hp', 'compute'); + + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + hock.createHock(12346, function (err, hockClient) { + should.not.exist(err); + should.exist(hockClient); + + authServer = hockClient; + next(); + }); + }, + function (next) { + hock.createHock(12345, function (err, hockClient) { + should.not.exist(err); + should.exist(hockClient); + + server = hockClient; + next(); + }); + } + ], done); + }); + + it('should have core methods defined', function() { + macros.shouldHaveCreds(client); + }); + + describe('the auth() method with a valid username and api key', function () { + var err, res; + + beforeEach(function (done) { + + client = helpers.createClient('hp', 'compute'); + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + + client.auth(function (e) { + should.not.exist(e); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function () { + client._identity.should.be.a('object'); + }); + }); + + describe('the auth() method with an invalid username and api key', function () { + + var badClient = helpers.createClient('hp', 'compute', { + username: 'fake', + apiKey: 'data', + authUrl: 'localhost:12346', + protocol: 'http://', + region: 'custom region' + }); + + var err, res; + + beforeEach(function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'fake', + secretKey: 'data' + } + } + }) + .reply(401, { + unauthorized: { + message: 'Username or api key is invalid', code: 401 + } + }); + } + + badClient.auth(function (e) { + err = e; + authServer && authServer.done(); + done(); + }); + + }); + + it('should respond with Error code 401', function () { + should.exist(err); + // TODO resolve identity responses + }); + }); + + describe('auth tokens should expire', function () { + var tokenExpiry; + + beforeEach(function (done) { + + client = helpers.createClient('hp', 'compute'); + + client.on('log::*', function(message, obj) { + if (this.event !== 'log::trace') { + console.log(message); + console.dir(obj); + } + }); + + if (mock) { + + var response = helpers.gethpAuthResponse(new Date(new Date().getTime() + 1)); + + tokenExpiry = response.access.token.expires; + + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, response); + } + + client.auth(function (e) { + should.not.exist(e); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function () { + client._identity.should.be.a('object'); + client._identity.token.expires.toString().should.equal(tokenExpiry); + }); + + it('should expire the token and set authorized to false', function(done) { + setTimeout(function() { + client._isAuthorized().should.equal(false); + done(); + }, 5); + }); + + it('should expire the token and reauth on next call', function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + + server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); + } + + setTimeout(function () { + client._isAuthorized().should.equal(false); + client.getImages(function(err, images) { + client._isAuthorized().should.equal(true); + should.not.exist(err); + should.exist(images); + server && server.done(); + authServer && authServer.done(); + done(); + }); + }, 5); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + }); +}); diff --git a/test/hp/macros.js b/test/hp/macros.js new file mode 100644 index 000000000..89bbc1341 --- /dev/null +++ b/test/hp/macros.js @@ -0,0 +1,108 @@ +/* + * macros.js: Tests macros for Rackspace + * + * (C) 2011 Nodejitsu Inc. + * + */ + +var fs = require('fs'), + filed = require('filed'), + assert = require('../helpers/assert'), + should = require('should'), + helpers = require('../helpers'), + mock = !!process.env.MOCK; + +exports.shouldHaveCreds = function (client) { + return function () { + assert.isObject(client.config); + assert.include(client.config, 'username'); + assert.include(client.config, 'apiKey'); + + assert.isFunction(client.auth); + } +}; + +exports.shouldCreateContainer = function (client, name, message) { + message = message || "when creating a container"; + + var context = {}; + context[message] = { + topic: function () { + client.createContainer(name, this.callback); + }, + "should return a valid container": function (err, container) { + assert.isNull(err); + assert.assertContainer(container); + } + }; + + return { + "The pkgcloud Rackspace storage client": { + "the createContainer() method": context + } + }; +}; + +exports.shouldDestroyContainer = function (client, name) { + return { + "The pkgcloud Rackspace storage client": { + "the destroyContainer() method": { + topic: function () { + client.destroyContainer(name, this.callback) + }, + "should return true": function (err, success) { + assert.isTrue(success); + } + } + } + }; +}; + +exports.upload = {}; + +exports.upload.fullpath = function (client, options) { + return { + topic: function () { + client.upload(options, function () { }) + .on('end', this.callback); + }, + "should raise the `end` event": function () { + assert.isTrue(true); + } + } +}; + +exports.upload.stream = function (client, container, local, remote) { + return { + topic: function () { + client.upload({ + container: container, + remote: remote, + stream: fs.createReadStream(local), + headers: { + 'content-length': fs.statSync(local).size + } + }, function () { }).on('end', this.callback); + }, + "should raise the `end` event": function () { + assert.isTrue(true); + } + } +}; + +exports.upload.piped = function (client, container, local, remote) { + return { + topic: function () { + var ustream = client.upload({ + container: container, + remote: remote + }, function () { }); + + filed(local).pipe(ustream); + ustream.on('end', this.callback) + }, + "should raise the `end` event": function () { + assert.isTrue(true); + } + } +}; From e5328a31599a64c404ebd900dc1c20dfeb170470 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 19:31:03 -0700 Subject: [PATCH 048/460] Adding unit tests for access key authentication with HP Cloud storage service. --- test/hp/storage/authentication-test.js | 157 +++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 test/hp/storage/authentication-test.js diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js new file mode 100644 index 000000000..f902d4de7 --- /dev/null +++ b/test/hp/storage/authentication-test.js @@ -0,0 +1,157 @@ +/* +* authentication-test.js: Tests for pkgcloud hp storage authentication +* +* (C) 2010 Nodejitsu Inc. +* +*/ + +var should = require('should'), + macros = require('../macros'), + helpers = require('../../helpers'), + async = require('async'), + hock = require('hock'), + mock = !!process.env.MOCK; + +describe('pkgcloud/hp/storage/authentication', function () { + describe('The pkgcloud hp Storage client', function () { + it('should have core methods defined', function() { + var client = helpers.createClient('hp', 'storage'); + macros.shouldHaveCreds(client); + }); + + describe('the auth() method', function() { + describe('with a valid user name and api key', function() { + var authServer; + + before(function(done) { + if (!mock) { + return done(); + } + + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + done(); + }); + }); + + it('should respond with 204 and appropriate info', function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + + var client = helpers.createClient('hp', 'storage'); + + client.auth(function (err) { + should.not.exist(err); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function (done) { + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + + var client = helpers.createClient('hp', 'storage'); + + client.auth(function (err) { + should.not.exist(err); + authServer && authServer.done(); + done(); + }); + }); + + after(function(done) { + if (authServer) { + authServer.close(function () { + done(); + }); + } + else { + done(); + } + }); + }); + + describe('with an invalid user name and api key shouldn\'t authenticate', function () { + var authServer; + + before(function (done) { + if (!mock) { + return done(); + } + + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + done(); + }); + }); + + it('should respond with 401 unauthorized', function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'fake', + secretKey: 'data' + } + } + }) + .reply(401, { + unauthorized: { + message: 'accessKey or api key is invalid', code: 401 + } + }); + } + + var badClient = helpers.createClient('hp', 'compute', { + username: 'fake', + apiKey: 'data', + authUrl: 'localhost:12346', + protocol: 'http://', + region: 'region-a.geo-1' + }); + + badClient.auth(function (err, res) { + should.exist(err); + authServer && authServer.done(); + done(); + }); + }); + + after(function (done) { + if (authServer) { + authServer.close(function () { + done(); + }); + } + else { + done(); + } + }); + }); + }); + }); +}); From 0885c481d8bd561b8598e19f8fd776bd822ce489 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 28 Apr 2014 19:40:36 -0700 Subject: [PATCH 049/460] Fixing copyright header. --- test/hp/storage/authentication-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index f902d4de7..34ac0c102 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud hp storage authentication * -* (C) 2010 Nodejitsu Inc. +* (C) 2014 HP. * */ From b2bf419b1e9b6f942b345ae606264fadcfbdb6ce Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 09:52:02 -0700 Subject: [PATCH 050/460] Code review changes. 1. Changed Compute Server to Cloud Compute 2. Changed copyright header. 3. Changed MossCloudFs to HPCloudFS in the tests. 4. Changed Cloud storage to object storage. --- docs/providers/hp/README.md | 4 ++-- docs/providers/hp/storage.md | 4 ++-- test/common/storage/base-test.js | 24 ++++++++++++------------ test/fixtures/hp/realToken.json | 6 +++--- test/hp/compute/authentication-test.js | 2 +- test/hp/storage/authentication-test.js | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 5b40a7a9a..66b24fc7c 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -2,8 +2,8 @@ The HP Cloud provider in pkgcloud supports the following services: -* [**Compute**](compute.md) (Cloud Servers) -* [**Storage**](storage.md) (Cloud Files) +* [**Compute**](compute.md) (cloud compute) +* [**Storage**](storage.md) (object storage) ### Getting Started with Compute diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index 894277468..bafd60b2f 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -1,4 +1,4 @@ -## Using the HP Storage provider +## Using the HP Object Storage provider * Container * [Model](#container-model) @@ -283,7 +283,7 @@ Removes the provided [`file`](#file-model) from the provided [`container`](#cont Updates the [`file`](#file-model) metadata in the the provided [`container`](#container-model). -File metadata is completely replaced with each callt o updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`. +File metadata is completely replaced with each call to updateFileMetadata. This is different than container metadata. To delete a property, just remove it from the metadata attribute on the `File` and call `updateFileMetadata`. ```javascript file.metadata = { campaign = '2011 website' diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 5746460d9..b1ef2733c 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -433,7 +433,7 @@ providers.filter(function (provider) { }); }); -function setupCreateContainerMock(provider, client, servers) { + function setupCreateContainerMock(provider, client, servers) { if (provider === 'rackspace') { servers.authServer .post('/v2.0/tokens', { @@ -537,7 +537,7 @@ function setupCreateContainerMock(provider, client, servers) { .reply(200, helpers.gethpAuthResponse()); servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') .reply(201); } } @@ -560,7 +560,7 @@ function setupGetContainersMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/postContainers.json')); } } @@ -585,7 +585,7 @@ function setupUploadStreamMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) .reply(200) } } @@ -608,7 +608,7 @@ function setupDownloadStreamMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(200, fillerama, { 'content-length': fillerama.length + 2}) } } @@ -631,7 +631,7 @@ function setupGetFileMock(provider, client, servers) { } if (provider === 'hp') { servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') .reply(200, '', { 'content-length': fillerama.length + 2 }) } } @@ -658,7 +658,7 @@ function setupGetFilesMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') .reply(200, [{ bytes: fillerama.length, name: 'test-file.txt', @@ -685,7 +685,7 @@ function setupRemoveFileMock(provider, client, servers) { } if (provider === 'hp') { servers.server - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(204, ''); } } @@ -722,7 +722,7 @@ function setupDestroyContainerMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') .reply(200, [ { bytes: fillerama.length, @@ -730,9 +730,9 @@ function setupDestroyContainerMock(provider, client, servers) { content_type: 'text/plain' } ]) - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(204, '') - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') .reply(204); } } @@ -755,7 +755,7 @@ function setupGetContainers2Mock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/preContainers.json')); } } diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 278c3b9f1..736af37b5 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -52,9 +52,9 @@ "endpoints": [ { "region": "region-a.geo-1", - "tenantId": "MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", - "publicURL": "http://localhost:12345/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", - "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" + "tenantId": "HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "publicURL": "http://localhost:12345/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00", + "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00" } ], "name": "swift", diff --git a/test/hp/compute/authentication-test.js b/test/hp/compute/authentication-test.js index 6dd31b4c4..6a789627c 100644 --- a/test/hp/compute/authentication-test.js +++ b/test/hp/compute/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud hp compute authentication * -* (C) 2014 HP. +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index 34ac0c102..fb82528cd 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud hp storage authentication * -* (C) 2014 HP. +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ From 35d6db4a4867d261024b9a09897be3f01658c9eb Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 10:06:34 -0700 Subject: [PATCH 051/460] More code review changes: 1. Updated samples to use HP flavor and image names. 2. Fixed Region names in documentation. --- docs/providers/hp/README.md | 2 +- docs/providers/hp/getting-started-compute.md | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 66b24fc7c..9fa92491b 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -67,7 +67,7 @@ var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', password: 'your-password', - region: 'ORD' + region: 'region-a.custom.corp' }); ``` diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md index 092dda9c7..e25b01949 100644 --- a/docs/providers/hp/getting-started-compute.md +++ b/docs/providers/hp/getting-started-compute.md @@ -2,7 +2,7 @@ The HP node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package -Pkgcloud currently supports Openstack Nova (compute) and Openstack Swift (storage). +Pkgcloud currently supports HP Cloud Nova (cloud compute) and HP Cloud Swift (object-storage). To install `pkgcloud` from the command line: @@ -14,7 +14,7 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). ## Using pkgcloud -In this example, we're going to create a HP Cloud compute client, create two servers, and then output their details to the command line. +In this example, we're going to create a HP Cloud Compute client, create two servers, and then output their details to the command line. *Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* @@ -45,11 +45,12 @@ client.getFlavors(function (err, flavors) { return; } - // Pick a 512MB instance flavor - var flavor = _.findWhere(flavors, { name: '512MB Standard Instance' }); + // Pick a medium instance flavor + // see here for more instance flavors: http://www.hpcloud.com/products-services/hp-cloud-compute-13_5 + var flavor = _.findWhere(flavors, { name: 'standard.medium' }); - // Pick an image based on Ubuntu 12.04 - var image = _.findWhere(images, { name: 'Ubuntu 12.04 LTS (Precise Pangolin)' }); + // Pick an image based on CentOS 6.3 + var image = _.findWhere(images, { name: 'CentOS 6.3 Server 64-bit 20130116' }); // Create our first server client.createServer({ From aab5589731a08eef9b4a36583472d62fe90674af Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 10:46:30 -0700 Subject: [PATCH 052/460] Removed auth url auto detection for region as it would break private clouds. And will break when we introduce more regions. --- lib/pkgcloud/hp/client.js | 17 +---------- test/hp/common/client-test.js | 54 +++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index d52d22228..e0dcd071c 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -12,25 +12,10 @@ var utile = require('utile'), var Client = exports.Client = function (options) { options = options || {}; - var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1', - eastUSIdentityService='https://region-b.geo-1.identity.hpcloudsvc.com:35357/', - westUSIdentityService='https://region-a.geo-1.identity.hpcloudsvc.com:35357/'; - if(!options.region){ - throw new Error('region is not valid. Available regions are '+westUSRegion+' (US-West), '+eastUSRegion+'(US-East)'); - } - if(!options.authUrl || options.authUrl.length === 0) { - if(options.region === eastUSRegion){ - options.authUrl = eastUSIdentityService; - } - else if(options.region === westUSRegion){ - options.authUrl = westUSIdentityService; - } - else{ + if(!options.authUrl){ throw new Error('authUrl is invalid'); - } } - options.identity = identity.Identity; if (typeof options.useServiceCatalog === 'undefined') { diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js index ecfed2627..1af01beca 100644 --- a/test/hp/common/client-test.js +++ b/test/hp/common/client-test.js @@ -12,6 +12,7 @@ var should = require('should'), mock = !!process.env.MOCK; describe('pkgcloud/hp/client', function () { + describe('Region validation', function () { var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1'; it('User should specify region: compute client', function() { @@ -58,49 +59,60 @@ describe('pkgcloud/hp/client', function () { customRegionClient.config.should.have.property('region','mycustomregion'); }); + }); - it('Client will auto-locate identity service for East US region : compute client', function() { - var eastUSClient = pkgcloud.compute.createClient({ + describe('Private cloud Uri resolution', function () { + var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1'; + it('Client will not resolve URI if useInternal is true : East US',function(){ + (function () { + pkgcloud.compute.createClient({ "provider": "hp", "username": "username", "password": "password", + "useInternal": true, "region": eastUSRegion }); + }).should.throw("authUrl is invalid"); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); }); - it('Client will auto-locate identity service for East US region : storage client', function() { - var eastUSClient = pkgcloud.storage.createClient({ + it('Client will not resolve URI if useInternal is true : West US',function(){ + (function () { + pkgcloud.compute.createClient({ "provider": "hp", "username": "username", "password": "password", - "region": eastUSRegion + "useInternal": true, + "region": westUSRegion }); + }).should.throw("authUrl is invalid"); - eastUSClient.config.should.have.property('authUrl','https://region-b.geo-1.identity.hpcloudsvc.com:35357/'); - }); - - it('Client will auto-locate identity service for West US region : compute client', function() { - var westUSClient = pkgcloud.compute.createClient({ + it('User can specify custom url for private cloud : West US',function(){ + var privateClient = pkgcloud.compute.createClient({ "provider": "hp", "username": "username", "password": "password", + "useInternal": true, + "authUrl": "http://my-internal-identity-service.com", "region": westUSRegion }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); - }); + privateClient.config.should.have.property('authUrl','http://my-internal-identity-service.com'); + }); - it('Client will auto-locate identity service for West US region : storage client', function() { - var westUSClient = pkgcloud.storage.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "region": westUSRegion - }); + it('User can specify custom url for private cloud : East US',function(){ + var privateClient = pkgcloud.compute.createClient({ + "provider": "hp", + "username": "username", + "password": "password", + "useInternal": true, + "authUrl": "http://my-internal-identity-service.com", + "region": eastUSRegion + }); + + privateClient.config.should.have.property('authUrl','http://my-internal-identity-service.com'); + }); - westUSClient.config.should.have.property('authUrl','https://region-a.geo-1.identity.hpcloudsvc.com:35357/'); }); }); }); From ce46af5116b345dc68e584d701a9e0cb073f203c Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 11:42:55 -0700 Subject: [PATCH 053/460] Updating documentation for HP provider. --- docs/providers/hp/README.md | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 9fa92491b..ea50d485c 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -28,8 +28,8 @@ All of the HP `createClient` calls have a few options that can be provided: #### authUrl `authUrl` specifies the authentication endpoint used to create a token for your HP client. -The HP Identity Service is currently available in two regions which can be accessed via these URLs. See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) +If you're targeting an HP Private Cloud instance, please contact your administrator for the authUrl. ##### Authenticating against the US-West endpoint @@ -57,8 +57,9 @@ var client = require('pkgcloud').compute.createClient({ #### region -`region` specifies which region of a service to use. HP has authentication endpoints specific to each region. -Please see section above for the endpoints and regions. +`region` specifies which region of a service to use. HP has services deployed in multiple regions. +See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) +If you're targeting an HP Private Cloud instance, please contact your administrator for region names. ##### Specifying a custom region @@ -74,18 +75,3 @@ var client = require('pkgcloud').compute.createClient({ #### Tokens and Expiration When you make your first call to a HP provider, your client is authenticated transparent to your API call. HP will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. - -#### Internal URLs - -As part of the options, you can tell `pkgcloud` to use the Internal (Service Net) URLs for a service, if possible. - - ```Javascript - var client = require('pkgcloud').storage.createClient({ - provider: 'hp', - username: 'your-user-name', - password: 'your-password', - useInternal: true - }); - ``` - - This setting is explicit. If you set it to true, and you have no connectivity to the internal URL for a service, your connections will timeout. From f333ecaa66e3ea4e3b7e68b8118d6c2a1a7598d1 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 11:48:56 -0700 Subject: [PATCH 054/460] Updating copyright header for HP provider files. --- lib/pkgcloud/hp/client.js | 2 +- lib/pkgcloud/hp/compute/client/index.js | 2 +- lib/pkgcloud/hp/compute/index.js | 2 +- lib/pkgcloud/hp/identity/hpIdentity.js | 2 +- lib/pkgcloud/hp/identity/index.js | 2 +- lib/pkgcloud/hp/index.js | 2 +- lib/pkgcloud/hp/storage/client/index.js | 2 +- lib/pkgcloud/hp/storage/index.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index e0dcd071c..8f2d9ee1f 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all HP clients inherit from * - * (C) 2014 HP. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 9bc012852..7130ee6ce 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Compute client for HP Cloudservers * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/compute/index.js b/lib/pkgcloud/hp/compute/index.js index 486ee5bb1..0eef07471 100644 --- a/lib/pkgcloud/hp/compute/index.js +++ b/lib/pkgcloud/hp/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Rackspace storage module * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/identity/hpIdentity.js b/lib/pkgcloud/hp/identity/hpIdentity.js index 25ea38511..7070665b6 100644 --- a/lib/pkgcloud/hp/identity/hpIdentity.js +++ b/lib/pkgcloud/hp/identity/hpIdentity.js @@ -1,7 +1,7 @@ /* * hpIdentity.js: hpIdentity model * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/identity/index.js b/lib/pkgcloud/hp/identity/index.js index 9465530d1..54c592b69 100644 --- a/lib/pkgcloud/hp/identity/index.js +++ b/lib/pkgcloud/hp/identity/index.js @@ -1,7 +1,7 @@ /* * index.js: Identity models * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js index 2b23bc93c..0c6379545 100644 --- a/lib/pkgcloud/hp/index.js +++ b/lib/pkgcloud/hp/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the HP module. * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/storage/client/index.js b/lib/pkgcloud/hp/storage/client/index.js index 123f31345..cc5d8aaed 100644 --- a/lib/pkgcloud/hp/storage/client/index.js +++ b/lib/pkgcloud/hp/storage/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Storage client for HP Cloudservers * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ diff --git a/lib/pkgcloud/hp/storage/index.js b/lib/pkgcloud/hp/storage/index.js index 44df5611d..524da3a56 100644 --- a/lib/pkgcloud/hp/storage/index.js +++ b/lib/pkgcloud/hp/storage/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the HP storage module * - * (C) 2014 HP + * (C) 2014 Hewlett-Packard Development Company, L.P. * Phani Raj * */ From 55da31957c01ad514f44ac7c94b2541ec94c9fe5 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 29 Apr 2014 11:51:05 -0700 Subject: [PATCH 055/460] Removing more debugger statements --- lib/pkgcloud/hp/compute/client/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 7130ee6ce..345ededed 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -13,7 +13,6 @@ var utile = require('utile'), var Client = exports.Client = function (options) { hp.Client.call(this, options); - debugger; utile.mixin(this, require('../../../openstack/compute/client/flavors')); utile.mixin(this, require('../../../openstack/compute/client/images')); utile.mixin(this, require('../../../openstack/compute/client/servers')); From e2ee8f18bba9f3c24d25fbe2ca4823a5acb21b48 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 30 Apr 2014 16:16:15 -0700 Subject: [PATCH 056/460] Fixing branding of HP Cloud Compute and Object storage services. --- docs/providers/hp/getting-started-compute.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md index e25b01949..9e7e3b870 100644 --- a/docs/providers/hp/getting-started-compute.md +++ b/docs/providers/hp/getting-started-compute.md @@ -2,7 +2,7 @@ The HP node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package -Pkgcloud currently supports HP Cloud Nova (cloud compute) and HP Cloud Swift (object-storage). +Pkgcloud currently supports HP Cloud Compute and HP Cloud Object Storage. To install `pkgcloud` from the command line: From d2ccefcaef631e84123c3affdf4b169633aefb92 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 5 May 2014 09:36:46 -0700 Subject: [PATCH 057/460] Adding QuickStart link and updating documentation. --- docs/providers/hp/README.md | 3 +++ docs/providers/hp/storage.md | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index ea50d485c..4c79b455e 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -5,6 +5,9 @@ The HP Cloud provider in pkgcloud supports the following services: * [**Compute**](compute.md) (cloud compute) * [**Storage**](storage.md) (object storage) +### Activating your HP Cloud services + +If this is your first time using HP Cloud Services, please follow [this](https://community.hpcloud.com/article/hp-public-cloud-quick-start-guide) guide to get started. ### Getting Started with Compute We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index bafd60b2f..f861d3502 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -23,7 +23,7 @@ Learn about [more options for creating clients](README.md) in the HP `storage` p ### Container Model -A Container for HP has following properties: +A Container for HP Object Storage has following properties: ```Javascript { @@ -38,7 +38,7 @@ A Container for HP has following properties: ### File Model -A File for HP has the following properties: +A File for HP Object Storage has the following properties: ```Javascript { From 94c2a6b39286bb0da100da7c8e4667f5f59ee305 Mon Sep 17 00:00:00 2001 From: Owen Smith Date: Fri, 2 May 2014 10:38:30 -0400 Subject: [PATCH 058/460] (fix) handleResponse being called very incorrectly in s3 multipart [storage] --- lib/pkgcloud/amazon/storage/client/files.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 9ed678faf..04c5cbc4c 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -278,9 +278,7 @@ exports.multipartUpload = function (options, callback) { 'Content-Length': Buffer.byteLength(body) }, body: body - }, function (err, body, res) { - handleResponse(err, res.statusCode == 200); - }); + }, handleResponse); } return stream; From e09f7508ec6073150efa2da90672eb2e32db6e67 Mon Sep 17 00:00:00 2001 From: Owen Smith Date: Fri, 2 May 2014 10:23:26 -0400 Subject: [PATCH 059/460] (fix) amzn container model attempts to use this.files [storage] --- lib/pkgcloud/core/storage/container.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/core/storage/container.js b/lib/pkgcloud/core/storage/container.js index 8e1c008a7..36324cc58 100644 --- a/lib/pkgcloud/core/storage/container.js +++ b/lib/pkgcloud/core/storage/container.js @@ -9,9 +9,9 @@ var utile = require('utile'), model = require('../base/model'); var Container = exports.Container = function (client, details) { - model.Model.call(this, client, details); - this.files = []; + + model.Model.call(this, client, details); }; utile.inherits(Container, model.Model); From a8d6d5b0c296eaa79422c747ef0359df6a09edaf Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 12:11:17 -0700 Subject: [PATCH 060/460] Adding signature and service for networking client in pkgcloud --- lib/pkgcloud.js | 3 +- lib/pkgcloud/openstack/index.js | 3 +- .../openstack/networking/client/index.js | 19 ++++++++++ lib/pkgcloud/openstack/networking/index.js | 12 +++++++ test/common/networking/base-test.js | 35 +++++++++++++++++++ 5 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 lib/pkgcloud/openstack/networking/client/index.js create mode 100644 lib/pkgcloud/openstack/networking/index.js create mode 100644 test/common/networking/base-test.js diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index 8921d9617..e69cff465 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -39,7 +39,8 @@ var services = [ 'database', 'dns', 'loadbalancer', - 'storage' + 'storage', + 'networking' ]; // diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index eb1d6b4bf..62e0b6c60 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -7,4 +7,5 @@ exports.compute = require('./compute'); exports.storage = require('./storage'); -exports.identity = require('./identity'); \ No newline at end of file +exports.identity = require('./identity'); +exports.networking = require('./networking'); diff --git a/lib/pkgcloud/openstack/networking/client/index.js b/lib/pkgcloud/openstack/networking/client/index.js new file mode 100644 index 000000000..29e02e059 --- /dev/null +++ b/lib/pkgcloud/openstack/networking/client/index.js @@ -0,0 +1,19 @@ +/* + * client.js: Client for Openstack networking + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + urlJoin = require('url-join'), + openstack = require('../../client'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + openstack.Client.call(this, options); + + this.serviceType = 'networking'; +}; + +utile.inherits(Client, openstack.Client); diff --git a/lib/pkgcloud/openstack/networking/index.js b/lib/pkgcloud/openstack/networking/index.js new file mode 100644 index 000000000..f930bb709 --- /dev/null +++ b/lib/pkgcloud/openstack/networking/index.js @@ -0,0 +1,12 @@ +/* + * index.js: Top-level include for the Openstack networking client. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +exports.Client = require('./client').Client; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/test/common/networking/base-test.js b/test/common/networking/base-test.js new file mode 100644 index 000000000..e3d820b06 --- /dev/null +++ b/test/common/networking/base-test.js @@ -0,0 +1,35 @@ +/* + * base-test.js: Test that should be common to all providers. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var fs = require('fs'), + path = require('path'), + should = require('should'), + qs = require('qs'), + utile = require('utile'), + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + _ = require('underscore'), + providers = require('../../configs/providers.json'), + versions = require('../../fixtures/versions.json'), + Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, + Image = require('../../../lib/pkgcloud/core/compute/image').Image, + Server = require('../../../lib/pkgcloud/core/compute/server').Server, + azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'), + pkgcloud = require('../../../lib/pkgcloud'), + mock = !!process.env.MOCK; + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].networking; +}).forEach(function(provider) { + describe('pkgcloud/common/compute/base [' + provider + ']', function () { + it('provider should implement networking client', function () { + var networkingClient = helpers.createClient(provider, 'networking'); + should.exist(networkingClient); + }); + }); + }); From 36141936fc196442d297b9a2d3329e4ab93ef65b Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 13:08:31 -0700 Subject: [PATCH 061/460] Adding prototype methods to get,create and delete networks. --- lib/pkgcloud/core/networking/network.js | 28 +++++ lib/pkgcloud/core/storage/container.js | 2 +- .../openstack/networking/client/index.js | 10 +- .../openstack/networking/client/networks.js | 114 ++++++++++++++++++ lib/pkgcloud/openstack/networking/index.js | 1 + lib/pkgcloud/openstack/networking/network.js | 28 +++++ .../openstack/networking/networkingClient.js | 90 ++++++++++++++ .../{networking => network}/base-test.js | 12 +- 8 files changed, 275 insertions(+), 10 deletions(-) create mode 100644 lib/pkgcloud/core/networking/network.js create mode 100644 lib/pkgcloud/openstack/networking/client/networks.js create mode 100644 lib/pkgcloud/openstack/networking/network.js create mode 100644 lib/pkgcloud/openstack/networking/networkingClient.js rename test/common/{networking => network}/base-test.js (57%) diff --git a/lib/pkgcloud/core/networking/network.js b/lib/pkgcloud/core/networking/network.js new file mode 100644 index 000000000..b43c22441 --- /dev/null +++ b/lib/pkgcloud/core/networking/network.js @@ -0,0 +1,28 @@ +/* + * container.js: Base container from which all pkgcloud containers inherit from + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + model = require('../base/model'); + +var Network = exports.Network = function (client, details) { + model.Model.call(this, client, details); + +}; + +utile.inherits(Network, model.Model); + +Network.prototype.create = function (callback) { + this.client.createNetwork(this.name, callback); +}; + +Network.prototype.refresh = function (callback) { + this.client.getNetwork(this, callback); +}; + +Network.prototype.destroy = function (callback) { + this.client.destroyNetwork(this.name, callback); +}; diff --git a/lib/pkgcloud/core/storage/container.js b/lib/pkgcloud/core/storage/container.js index 8e1c008a7..dfdadc69d 100644 --- a/lib/pkgcloud/core/storage/container.js +++ b/lib/pkgcloud/core/storage/container.js @@ -54,4 +54,4 @@ Container.prototype.getFiles = function (download, callback) { Container.prototype.removeFile = function (file, callback) { this.client.removeFile(this.name, file, callback); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/networking/client/index.js b/lib/pkgcloud/openstack/networking/client/index.js index 29e02e059..c4faabff0 100644 --- a/lib/pkgcloud/openstack/networking/client/index.js +++ b/lib/pkgcloud/openstack/networking/client/index.js @@ -8,12 +8,20 @@ var utile = require('utile'), urlJoin = require('url-join'), openstack = require('../../client'), + NetworkClient = require('../networkingClient').NetworkClient, _ = require('underscore'); var Client = exports.Client = function (options) { openstack.Client.call(this, options); - this.serviceType = 'networking'; + this.models = { + Network: require('../network').Network + }; + + utile.mixin(this, require('./networks')); + + this.serviceType = 'network'; }; utile.inherits(Client, openstack.Client); +_.extend(Client.prototype, NetworkClient.prototype); diff --git a/lib/pkgcloud/openstack/networking/client/networks.js b/lib/pkgcloud/openstack/networking/client/networks.js new file mode 100644 index 000000000..57207435e --- /dev/null +++ b/lib/pkgcloud/openstack/networking/client/networks.js @@ -0,0 +1,114 @@ +/* + * networks.js: Instance methods for working with networks + * for Openstack networking + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var async = require('async'), + request = require('request'), + pkgcloud = require('../../../../pkgcloud'), + _ = require('underscore'); + +/** + * client.getNetworks + * + * @description get the list of networks for an account + * + * @param {object|Function} options + * @param {Number} [options.limit] the number of records to return + * @param {String} [options.marker] Marker value. Operation returns object names that are greater than this value. + * @param {String} [options.end_marker] Operation returns object names that are less than this value. + * @param {Function} callback + */ +exports.getNetworks = function (options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var getNetworkOpts = { + path: '', + qs: _.extend({ + format: 'json' + }, _.pick(options, ['limit', 'marker', 'end_marker'])) + }; + + this._request(getNetworkOpts, function (err, body) { + if (err) { + return callback(err); + } + else if (!body || !(body instanceof Array)) { + return new Error('Malformed API Response'); + } + + return callback(null, body.map(function (network) { + return new self.models.Network(self, network); + })); + }); +}; + +/** + * client.getNetwork + * + * @description get the details for a specific network + * + * @param {String|object} network the network or networkName + * @param callback + */ +exports.getNetwork = function (network, callback) { + var networkName = network instanceof this.models.Network ? network.name : network, + self = this; + + this._request({ + method: 'HEAD', + network: networkName + }, function (err, body, res) { + if (err) { + return callback(err); + } + + var details = _.extend({}, body, { + name: networkName, + count: parseInt(res.headers['x-network-object-count'], 10), + bytes: parseInt(res.headers['x-network-bytes-used'], 10) + }); + + details.metadata = self.deserializeMetadata(self.CONTAINER_META_PREFIX, res.headers); + + callback(null, new self.models.Network(self, details)); + }); +}; + +/** + * client.createNetwork + * + * @description create a new network + * + * @param {object} options + * @param {String} options.name the name of the new network + * @param {object} [options.metadata] optional metadata about the network + * @param callback + */ +exports.createNetwork = function (options, callback) { + var networkName = typeof options === 'object' ? options.name : options, + self = this; + + var createNetworkOpts = { + method: 'PUT', + network: networkName + }; + + if (options.metadata) { + createNetworkOpts.headers = self.serializeMetadata(self.CONTAINER_META_PREFIX, options.metadata); + } + + this._request(createNetworkOpts, function (err) { + return err + ? callback(err) + : callback(null, new self.models.Network(self, { name: networkName, metadata: options.metadata })); + }); +}; diff --git a/lib/pkgcloud/openstack/networking/index.js b/lib/pkgcloud/openstack/networking/index.js index f930bb709..20bba5b65 100644 --- a/lib/pkgcloud/openstack/networking/index.js +++ b/lib/pkgcloud/openstack/networking/index.js @@ -6,6 +6,7 @@ */ exports.Client = require('./client').Client; +exports.Network = require('./network').Network; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/openstack/networking/network.js b/lib/pkgcloud/openstack/networking/network.js new file mode 100644 index 000000000..08dbecf7b --- /dev/null +++ b/lib/pkgcloud/openstack/networking/network.js @@ -0,0 +1,28 @@ +/* + * container.js: Openstack Object Storage Container + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + base = require('../../core/networking/network'), + _ = require('underscore'); + +var Network = exports.Network = function Network(client, details) { + base.Network.call(this, client, details); +}; + +Network.prototype._setProperties = function (details) { + this.name = details.name || this.name; + this.ttl = details.ttl || this.ttl; + this.logRetention = details.logRetention || this.logRetention; + this.count = details.count || this.count || 0 + this.bytes = details.bytes || this.bytes || 0; + this.metadata = details.metadata || this.metadata || {}; +}; + +Network.prototype.toJSON = function () { + return _.pick(this, ['name', 'ttl', 'logRetention', 'count', + 'bytes', 'metadata']); +}; diff --git a/lib/pkgcloud/openstack/networking/networkingClient.js b/lib/pkgcloud/openstack/networking/networkingClient.js new file mode 100644 index 000000000..70618ea04 --- /dev/null +++ b/lib/pkgcloud/openstack/networking/networkingClient.js @@ -0,0 +1,90 @@ +/* + * storageClient.js: A base NetworkClient for Openstack networking clients + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var urlJoin = require('url-join'), + _ = require('underscore'); + +const CONTAINER_META_PREFIX = 'x-container-meta-'; +const CONTAINER_REMOVE_META_PREFIX = 'x-remove-container-meta-'; +const OBJECT_META_PREFIX = 'x-object-meta-'; +const OBJECT_REMOVE_META_PREFIX = 'x-object-remove-meta-'; + +var Client = exports.NetworkClient = function () { + this.serviceType = 'network'; +} + +/** + * client._getUrl + * + * @description get the url for the current storage service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function (options) { + options = options || {}; + + var fragment = ''; + + if (options.container) { + fragment = encodeURIComponent(options.container); + } + + if (options.path) { + fragment = urlJoin(fragment, options.path.split('/').map(encodeURIComponent).join('/')); + } + + var serviceUrl = options.serviceType ? this._identity.getServiceEndpointUrl({ + serviceType: options.serviceType, + region: this.region + }) : this._serviceUrl; + + if (fragment === '' || fragment === '/') { + return serviceUrl; + } + + return urlJoin(serviceUrl, fragment); + +}; + +Client.prototype.serializeMetadata = function (prefix, metadata) { + + if (!metadata) { + return {}; + } + + var serializedMetadata = {}; + + _.keys(metadata).forEach(function (key) { + serializedMetadata[prefix + key] = metadata[key]; + }); + + return serializedMetadata; +}; + +Client.prototype.deserializeMetadata = function (prefix, metadata) { + + if (!metadata) { + return {}; + } + + var deserializedMetadata = {}; + + _.keys(metadata).forEach(function (key) { + if (key.indexOf(prefix) !== -1) { + deserializedMetadata[key.split(prefix)[1]] = metadata[key]; + } + }); + + return deserializedMetadata; +}; + +Client.prototype.CONTAINER_META_PREFIX = CONTAINER_META_PREFIX; +Client.prototype.CONTAINER_REMOVE_META_PREFIX = CONTAINER_REMOVE_META_PREFIX; +Client.prototype.OBJECT_META_PREFIX = OBJECT_META_PREFIX; +Client.prototype.OBJECT_REMOVE_META_PREFIX = OBJECT_REMOVE_META_PREFIX; diff --git a/test/common/networking/base-test.js b/test/common/network/base-test.js similarity index 57% rename from test/common/networking/base-test.js rename to test/common/network/base-test.js index e3d820b06..4fee50f4e 100644 --- a/test/common/networking/base-test.js +++ b/test/common/network/base-test.js @@ -16,20 +16,16 @@ var fs = require('fs'), _ = require('underscore'), providers = require('../../configs/providers.json'), versions = require('../../fixtures/versions.json'), - Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, - Image = require('../../../lib/pkgcloud/core/compute/image').Image, - Server = require('../../../lib/pkgcloud/core/compute/server').Server, - azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'), pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].networking; + return !!helpers.pkgcloud.providers[provider].network; }).forEach(function(provider) { - describe('pkgcloud/common/compute/base [' + provider + ']', function () { + describe.only('pkgcloud/common/network/base [' + provider + ']', function () { it('provider should implement networking client', function () { - var networkingClient = helpers.createClient(provider, 'networking'); - should.exist(networkingClient); + var networkClient = helpers.createClient(provider, 'network'); + should.exist(networkClient); }); }); }); From 8f619042e454cec6bd5be76a3921ed48c15b488d Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 7 May 2014 13:44:17 -0700 Subject: [PATCH 062/460] Adding method documentation for tempUrl --- .../storage/client/cdn-containers.js | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index de99d991c..c64c7d09a 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -314,7 +314,15 @@ exports._getCdnContainerDetails = function(container, callback) { }); }; -exports.setTempUrlMetadataKey = function(key, callback) { +/** + * client.setTemporaryUrlKey + * + * @description set a temporaryUrl key on the current account + * + * @param {String} key the secret key to be used in hmac signing temporary urls + * @param callback + */ +exports.setTemporaryUrlKey = function(key, callback) { this._request({ method: 'POST', headers: { @@ -325,10 +333,24 @@ exports.setTempUrlMetadataKey = function(key, callback) { }); }; +/** + * client.generateTempUrl + * + * @description create a temporary url for GET/PUT to a cloud files container + * + * @param {String|object} container the container or container name for the url + * @param {String|object} file the file or fileName for the url + * @param {String} method either GET or PUT + * @param {Number} time expiry for the url in seconds (from now) + * @param {String} key the secret key to be used for signing the url + * @param callback + */ exports.generateTempUrl = function(container, file, method, time, key, callback) { - var self = this, split = '/v1'; - - time = parseInt(time); + var containerName = container instanceof this.models.Container ? container.name : container, + fileName = file instanceof this.models.File ? file.name : file, + time = typeof time === 'number' ? time : parseInt(time), + self = this, + split = '/v1'; // We have to be authed to make sure we have the service catalog // this is required to validate the service url @@ -352,10 +374,10 @@ exports.generateTempUrl = function(container, file, method, time, key, callback) // construct our hmac signature var expiry = parseInt(new Date().getTime() / 1000) + time, url = self._getUrl({ - container: container, - path: file + container: containerName, + path: fileName }), - hmac_body = method + '\n' + expiry + '\n' + split + url.split(split)[1]; + hmac_body = method.toUpperCase() + '\n' + expiry + '\n' + split + url.split(split)[1]; var hash = crypto.createHmac('sha1', key).update(hmac_body).digest('hex'); From ba7db351b1f0fcf7838477cf7f9bf8dd7c49a303 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 15:49:34 -0700 Subject: [PATCH 063/460] Enabling network provider base tests. --- lib/pkgcloud.js | 2 +- lib/pkgcloud/openstack/index.js | 2 +- lib/pkgcloud/openstack/networking/networkingClient.js | 2 +- test/common/network/base-test.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index e69cff465..b1046a21c 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -40,7 +40,7 @@ var services = [ 'dns', 'loadbalancer', 'storage', - 'networking' + 'network' ]; // diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index 62e0b6c60..abafa8a94 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -8,4 +8,4 @@ exports.compute = require('./compute'); exports.storage = require('./storage'); exports.identity = require('./identity'); -exports.networking = require('./networking'); +exports.network = require('./networking'); diff --git a/lib/pkgcloud/openstack/networking/networkingClient.js b/lib/pkgcloud/openstack/networking/networkingClient.js index 70618ea04..16add4733 100644 --- a/lib/pkgcloud/openstack/networking/networkingClient.js +++ b/lib/pkgcloud/openstack/networking/networkingClient.js @@ -15,7 +15,7 @@ const OBJECT_REMOVE_META_PREFIX = 'x-object-remove-meta-'; var Client = exports.NetworkClient = function () { this.serviceType = 'network'; -} +}; /** * client._getUrl diff --git a/test/common/network/base-test.js b/test/common/network/base-test.js index 4fee50f4e..65cfecdb5 100644 --- a/test/common/network/base-test.js +++ b/test/common/network/base-test.js @@ -22,7 +22,7 @@ var fs = require('fs'), providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].network; }).forEach(function(provider) { - describe.only('pkgcloud/common/network/base [' + provider + ']', function () { + describe('pkgcloud/common/network/base [' + provider + ']', function () { it('provider should implement networking client', function () { var networkClient = helpers.createClient(provider, 'network'); should.exist(networkClient); From ffa5b910adb431e20a7046e44700d404958eeb6a Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 16:00:58 -0700 Subject: [PATCH 064/460] Adding tests for signatures of getNetworks and createNetwork --- test/common/network/signature-test.js | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/common/network/signature-test.js diff --git a/test/common/network/signature-test.js b/test/common/network/signature-test.js new file mode 100644 index 000000000..e21aed166 --- /dev/null +++ b/test/common/network/signature-test.js @@ -0,0 +1,42 @@ +/* + * signature-test.js: Test that shared methods meet some expectations for arguments. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var should = require('should'), + providers = require('../../configs/providers.json'), + helpers = require('../../helpers'), + _ = require('underscore'); + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + + describe('pkgcloud/common/network/signatures [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'); + + it('client.getNetworks should take 2 arguments', function () { + client.getNetworks.should.be.a('function'); + client.getNetworks.should.have.length(2); + }); + + it('client.getNetwork should take 2 arguments', function () { + client.getNetwork.should.be.a('function'); + client.getNetwork.should.have.length(2); + }); + + it('client.getNetworks should take at least 1 argument', function () { + client.getNetworks.should.be.a('function'); + should.ok(client.getNetworks.length >= 1); + }); + + it('client.createNetwork should take 2 arguments', function () { + client.createNetwork.should.be.a('function'); + client.createNetwork.should.have.length(2); + }); + + }); +}); From ff4c5465e9a630e8374fd64212c172d20335e57b Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 16:50:11 -0700 Subject: [PATCH 065/460] Getnetworks is working now, tests on their way. --- lib/pkgcloud/core/base/client.js | 1 - lib/pkgcloud/openstack/client.js | 4 -- .../openstack/networking/client/networks.js | 8 ++- lib/pkgcloud/openstack/networking/network.js | 15 +++--- .../openstack/networking/networkingClient.js | 50 ++----------------- .../openstack/storage/client/containers.js | 2 +- 6 files changed, 16 insertions(+), 64 deletions(-) diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index 490380a14..c0dd01622 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -42,7 +42,6 @@ utile.inherits(Client, events.EventEmitter2); */ Client.prototype._request = function (options, callback) { var self = this; - var requestOptions = {}; requestOptions.method = options.method || 'GET'; diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index aa91fea63..9f2c7b5b8 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -170,14 +170,10 @@ Client.prototype.auth = function (callback) { Client.prototype._request = function (options, callback) { var self = this; - if (!self._isAuthorized()) { self.emit('log::trace', 'Not-Authenticated, inlining Auth...'); var buf = through().pause(); - - self.auth(function (err) { - if (err) { self.emit('log::error', 'Error with inline authentication', err); return errs.handle(err, callback); diff --git a/lib/pkgcloud/openstack/networking/client/networks.js b/lib/pkgcloud/openstack/networking/client/networks.js index 57207435e..6ce853900 100644 --- a/lib/pkgcloud/openstack/networking/client/networks.js +++ b/lib/pkgcloud/openstack/networking/client/networks.js @@ -31,7 +31,7 @@ exports.getNetworks = function (options, callback) { } var getNetworkOpts = { - path: '', + path: '/v2.0/networks', qs: _.extend({ format: 'json' }, _.pick(options, ['limit', 'marker', 'end_marker'])) @@ -41,11 +41,11 @@ exports.getNetworks = function (options, callback) { if (err) { return callback(err); } - else if (!body || !(body instanceof Array)) { + else if (!body ||!body.networks || !(body.networks instanceof Array)) { return new Error('Malformed API Response'); } - return callback(null, body.map(function (network) { + return callback(null, body.networks.map(function (network) { return new self.models.Network(self, network); })); }); @@ -77,8 +77,6 @@ exports.getNetwork = function (network, callback) { bytes: parseInt(res.headers['x-network-bytes-used'], 10) }); - details.metadata = self.deserializeMetadata(self.CONTAINER_META_PREFIX, res.headers); - callback(null, new self.models.Network(self, details)); }); }; diff --git a/lib/pkgcloud/openstack/networking/network.js b/lib/pkgcloud/openstack/networking/network.js index 08dbecf7b..ef039f0aa 100644 --- a/lib/pkgcloud/openstack/networking/network.js +++ b/lib/pkgcloud/openstack/networking/network.js @@ -15,14 +15,15 @@ var Network = exports.Network = function Network(client, details) { Network.prototype._setProperties = function (details) { this.name = details.name || this.name; - this.ttl = details.ttl || this.ttl; - this.logRetention = details.logRetention || this.logRetention; - this.count = details.count || this.count || 0 - this.bytes = details.bytes || this.bytes || 0; - this.metadata = details.metadata || this.metadata || {}; + this.status = details.status || this.status; + this.admin_state_up = details.admin_state_up || this.admin_state_up; + this.id = details.id || this.id; + this.shared = details.shared || this.shared || 0; + this.tenant_id = details.tenant_id || this.tenant_id; + this.subnets = details.subnets || this.subnets; }; Network.prototype.toJSON = function () { - return _.pick(this, ['name', 'ttl', 'logRetention', 'count', - 'bytes', 'metadata']); + return _.pick(this, ['name', 'id', 'status', 'shared', + 'tenant_id', 'subnets']); }; diff --git a/lib/pkgcloud/openstack/networking/networkingClient.js b/lib/pkgcloud/openstack/networking/networkingClient.js index 16add4733..1617ec446 100644 --- a/lib/pkgcloud/openstack/networking/networkingClient.js +++ b/lib/pkgcloud/openstack/networking/networkingClient.js @@ -1,5 +1,5 @@ /* - * storageClient.js: A base NetworkClient for Openstack networking clients + * networkingClient.js: A base NetworkClient for Openstack networking clients * * (C) 2014 Hewlett-Packard Development Company, L.P. * @@ -8,11 +8,6 @@ var urlJoin = require('url-join'), _ = require('underscore'); -const CONTAINER_META_PREFIX = 'x-container-meta-'; -const CONTAINER_REMOVE_META_PREFIX = 'x-remove-container-meta-'; -const OBJECT_META_PREFIX = 'x-object-meta-'; -const OBJECT_REMOVE_META_PREFIX = 'x-object-remove-meta-'; - var Client = exports.NetworkClient = function () { this.serviceType = 'network'; }; @@ -20,7 +15,7 @@ var Client = exports.NetworkClient = function () { /** * client._getUrl * - * @description get the url for the current storage service + * @description get the url for the current network service * * @param options * @returns {exports|*} @@ -31,8 +26,8 @@ Client.prototype._getUrl = function (options) { var fragment = ''; - if (options.container) { - fragment = encodeURIComponent(options.container); + if (options.network) { + fragment = encodeURIComponent(options.network); } if (options.path) { @@ -51,40 +46,3 @@ Client.prototype._getUrl = function (options) { return urlJoin(serviceUrl, fragment); }; - -Client.prototype.serializeMetadata = function (prefix, metadata) { - - if (!metadata) { - return {}; - } - - var serializedMetadata = {}; - - _.keys(metadata).forEach(function (key) { - serializedMetadata[prefix + key] = metadata[key]; - }); - - return serializedMetadata; -}; - -Client.prototype.deserializeMetadata = function (prefix, metadata) { - - if (!metadata) { - return {}; - } - - var deserializedMetadata = {}; - - _.keys(metadata).forEach(function (key) { - if (key.indexOf(prefix) !== -1) { - deserializedMetadata[key.split(prefix)[1]] = metadata[key]; - } - }); - - return deserializedMetadata; -}; - -Client.prototype.CONTAINER_META_PREFIX = CONTAINER_META_PREFIX; -Client.prototype.CONTAINER_REMOVE_META_PREFIX = CONTAINER_REMOVE_META_PREFIX; -Client.prototype.OBJECT_META_PREFIX = OBJECT_META_PREFIX; -Client.prototype.OBJECT_REMOVE_META_PREFIX = OBJECT_REMOVE_META_PREFIX; diff --git a/lib/pkgcloud/openstack/storage/client/containers.js b/lib/pkgcloud/openstack/storage/client/containers.js index 53325b27f..d37b99dfa 100644 --- a/lib/pkgcloud/openstack/storage/client/containers.js +++ b/lib/pkgcloud/openstack/storage/client/containers.js @@ -38,7 +38,7 @@ exports.getContainers = function (options, callback) { format: 'json' }, _.pick(options, ['limit', 'marker', 'end_marker'])) }; - + ; this._request(getContainerOpts, function (err, body) { if (err) { return callback(err); From 06b6acec745595a980a73dbbdc47f1dd217256f4 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 17:44:18 -0700 Subject: [PATCH 066/460] Renaming "networking" to "network" --- lib/pkgcloud/core/{networking => network}/network.js | 0 lib/pkgcloud/openstack/index.js | 2 +- lib/pkgcloud/openstack/{networking => network}/client/index.js | 2 +- .../openstack/{networking => network}/client/networks.js | 0 lib/pkgcloud/openstack/{networking => network}/index.js | 0 lib/pkgcloud/openstack/{networking => network}/network.js | 2 +- .../networkingClient.js => network/networkClient.js} | 0 7 files changed, 3 insertions(+), 3 deletions(-) rename lib/pkgcloud/core/{networking => network}/network.js (100%) rename lib/pkgcloud/openstack/{networking => network}/client/index.js (89%) rename lib/pkgcloud/openstack/{networking => network}/client/networks.js (100%) rename lib/pkgcloud/openstack/{networking => network}/index.js (100%) rename lib/pkgcloud/openstack/{networking => network}/network.js (94%) rename lib/pkgcloud/openstack/{networking/networkingClient.js => network/networkClient.js} (100%) diff --git a/lib/pkgcloud/core/networking/network.js b/lib/pkgcloud/core/network/network.js similarity index 100% rename from lib/pkgcloud/core/networking/network.js rename to lib/pkgcloud/core/network/network.js diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index abafa8a94..03a07b0f9 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -8,4 +8,4 @@ exports.compute = require('./compute'); exports.storage = require('./storage'); exports.identity = require('./identity'); -exports.network = require('./networking'); +exports.network = require('./network'); diff --git a/lib/pkgcloud/openstack/networking/client/index.js b/lib/pkgcloud/openstack/network/client/index.js similarity index 89% rename from lib/pkgcloud/openstack/networking/client/index.js rename to lib/pkgcloud/openstack/network/client/index.js index c4faabff0..afac27eb0 100644 --- a/lib/pkgcloud/openstack/networking/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -8,7 +8,7 @@ var utile = require('utile'), urlJoin = require('url-join'), openstack = require('../../client'), - NetworkClient = require('../networkingClient').NetworkClient, + NetworkClient = require('../networkClient').NetworkClient, _ = require('underscore'); var Client = exports.Client = function (options) { diff --git a/lib/pkgcloud/openstack/networking/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js similarity index 100% rename from lib/pkgcloud/openstack/networking/client/networks.js rename to lib/pkgcloud/openstack/network/client/networks.js diff --git a/lib/pkgcloud/openstack/networking/index.js b/lib/pkgcloud/openstack/network/index.js similarity index 100% rename from lib/pkgcloud/openstack/networking/index.js rename to lib/pkgcloud/openstack/network/index.js diff --git a/lib/pkgcloud/openstack/networking/network.js b/lib/pkgcloud/openstack/network/network.js similarity index 94% rename from lib/pkgcloud/openstack/networking/network.js rename to lib/pkgcloud/openstack/network/network.js index ef039f0aa..7e057ade4 100644 --- a/lib/pkgcloud/openstack/networking/network.js +++ b/lib/pkgcloud/openstack/network/network.js @@ -6,7 +6,7 @@ */ var utile = require('utile'), - base = require('../../core/networking/network'), + base = require('../../core/network/network'), _ = require('underscore'); var Network = exports.Network = function Network(client, details) { diff --git a/lib/pkgcloud/openstack/networking/networkingClient.js b/lib/pkgcloud/openstack/network/networkClient.js similarity index 100% rename from lib/pkgcloud/openstack/networking/networkingClient.js rename to lib/pkgcloud/openstack/network/networkClient.js From 9b801a31f99b56df8c1c660c8fe8a4f875aacce8 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 18:20:11 -0700 Subject: [PATCH 067/460] getNetwork is working now. --- lib/pkgcloud/core/base/client.js | 6 +++++- .../openstack/network/client/networks.js | 21 +++++++++---------- .../openstack/network/networkClient.js | 1 + 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index c0dd01622..943280096 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -70,6 +70,10 @@ Client.prototype._request = function (options, callback) { } } + if (options.network) { + requestOptions.signingUrl = '/' + options.network + '/'; + } + function sendRequest(opts) { // @@ -149,7 +153,7 @@ Client.prototype._defaultRequestHandler = function (callback) { if (err) { return callback(err); } - + var statusCode = res.statusCode.toString(), err2; diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 6ce853900..680d9fd65 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -9,6 +9,7 @@ var async = require('async'), request = require('request'), pkgcloud = require('../../../../pkgcloud'), + urlJoin = require('url-join'); _ = require('underscore'); /** @@ -60,24 +61,22 @@ exports.getNetworks = function (options, callback) { * @param callback */ exports.getNetwork = function (network, callback) { - var networkName = network instanceof this.models.Network ? network.name : network, + var networkName = network instanceof this.models.Network ? network.id : network, self = this; - + self.emit('log::trace', 'Getting details for network', networkName); this._request({ - method: 'HEAD', - network: networkName + path: urlJoin('/v2.0/networks',networkName), + method: 'GET' }, function (err, body, res) { if (err) { return callback(err); } - var details = _.extend({}, body, { - name: networkName, - count: parseInt(res.headers['x-network-object-count'], 10), - bytes: parseInt(res.headers['x-network-bytes-used'], 10) - }); - - callback(null, new self.models.Network(self, details)); + if (!body ||!body.network) { + return new Error('Malformed API Response'); + } + + callback(null, new self.models.Network(self, body.network)); }); }; diff --git a/lib/pkgcloud/openstack/network/networkClient.js b/lib/pkgcloud/openstack/network/networkClient.js index 1617ec446..9c14f19a4 100644 --- a/lib/pkgcloud/openstack/network/networkClient.js +++ b/lib/pkgcloud/openstack/network/networkClient.js @@ -30,6 +30,7 @@ Client.prototype._getUrl = function (options) { fragment = encodeURIComponent(options.network); } + if (options.path) { fragment = urlJoin(fragment, options.path.split('/').map(encodeURIComponent).join('/')); } From 54d697869fb9427fb0dd1ea8aa5ef240c77bc96a Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 7 May 2014 18:47:03 -0700 Subject: [PATCH 068/460] createNetwork is working now. --- lib/pkgcloud/core/base/client.js | 4 ++-- .../openstack/network/client/networks.js | 19 ++++++++----------- .../openstack/network/networkClient.js | 4 +++- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index 943280096..276829f18 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -70,7 +70,7 @@ Client.prototype._request = function (options, callback) { } } - if (options.network) { + if (options.network && options.method ==='GET') { requestOptions.signingUrl = '/' + options.network + '/'; } @@ -153,7 +153,7 @@ Client.prototype._defaultRequestHandler = function (callback) { if (err) { return callback(err); } - + var statusCode = res.statusCode.toString(), err2; diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 680d9fd65..1f5a7658d 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -75,7 +75,7 @@ exports.getNetwork = function (network, callback) { if (!body ||!body.network) { return new Error('Malformed API Response'); } - + callback(null, new self.models.Network(self, body.network)); }); }; @@ -87,25 +87,22 @@ exports.getNetwork = function (network, callback) { * * @param {object} options * @param {String} options.name the name of the new network - * @param {object} [options.metadata] optional metadata about the network * @param callback */ exports.createNetwork = function (options, callback) { - var networkName = typeof options === 'object' ? options.name : options, + var network = typeof options === 'object' ? options : { 'name' : options}, self = this; var createNetworkOpts = { - method: 'PUT', - network: networkName + method: 'POST', + path: '/v2.0/networks', + body: { 'network' : network} }; - if (options.metadata) { - createNetworkOpts.headers = self.serializeMetadata(self.CONTAINER_META_PREFIX, options.metadata); - } - - this._request(createNetworkOpts, function (err) { + self.emit('log::trace', 'Creating network', network); + this._request(createNetworkOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.Network(self, { name: networkName, metadata: options.metadata })); + : callback(null, new self.models.Network(self, body.network)); }); }; diff --git a/lib/pkgcloud/openstack/network/networkClient.js b/lib/pkgcloud/openstack/network/networkClient.js index 9c14f19a4..27d1f1a8c 100644 --- a/lib/pkgcloud/openstack/network/networkClient.js +++ b/lib/pkgcloud/openstack/network/networkClient.js @@ -27,7 +27,9 @@ Client.prototype._getUrl = function (options) { var fragment = ''; if (options.network) { - fragment = encodeURIComponent(options.network); + if(options.method === 'GET') { + fragment = encodeURIComponent(options.network); + } } From ff02acf8d4ef16734697c2c6073a3269f7e3b62c Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 12:23:22 -0700 Subject: [PATCH 069/460] Adding tests for getNetworks, getNetwork and createNetwork --- test/common/network/network-test.js | 236 +++++++++++++++++++ test/fixtures/openstack/network.json | 18 ++ test/fixtures/openstack/networks.json | 34 +++ test/fixtures/openstack/realToken-admin.json | 12 + test/fixtures/openstack/realToken.json | 12 + 5 files changed, 312 insertions(+) create mode 100644 test/common/network/network-test.js create mode 100644 test/fixtures/openstack/network.json create mode 100644 test/fixtures/openstack/networks.json diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js new file mode 100644 index 000000000..cb5d33561 --- /dev/null +++ b/test/common/network/network-test.js @@ -0,0 +1,236 @@ +/* +* server-test.js: Test that should be common to all providers. +* +* (C) 2012 Nodejitsu Inc. +* +*/ + +var fs = require('fs'), + path = require('path'), + qs = require('qs'), + should = require('should'), + utile = require('utile'), + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + async = require('async'), + _ = require('underscore'), + providers = require('../../configs/providers.json'), + Network = require('../../../lib/pkgcloud/core/network/network').Network, + mock = !!process.env.MOCK; + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/networks [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + hock.createHock({ + port: 12345, + throwOnUnmatched: false + }, function (err, hockClient) { + server = hockClient; + next(); + }); + }, + function (next) { + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + next(); + }); + } + ], done) + }); + + it('the getNetworks() function should return a list of networks', function(done) { + + if (mock) { + setupNetworksMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.getNetworks(function (err, networks) { + should.not.exist(err); + should.exist(networks); + + context.networks = networks; + + authServer && authServer.done(); + server && server.done(); + + done(); + }); + }); + + it.skip('the createServer() method with image and flavor should create a server', function (done) { + var m = mock ? .1 : 10; + + if (mock) { + setupServerMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.createServer(utile.mixin({ + name: 'create-test-ids2', + image: context.images[0].id, + flavor: context.flavors[0].id + }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + + srv1.setWait({ status: srv1.STATUS.running }, 100 * m, function (err, srv2) { + should.not.exist(err); + should.exist(srv2); + srv2.should.be.instanceOf(Server); + srv2.name.should.equal('create-test-ids2'); + srv2.imageId.should.equal(context.images[0].id); + + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + }); + + it('the getNetwork() method should get a network instance', function (done) { + if (mock) { + setupGetNetworkMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.getNetwork(context.networks[0].id, function (err, network) { + should.not.exist(err); + should.exist(network); + + context.currentNetwork = network; + + authServer && authServer.done(); + server && server.done(); + done(); + + }); + }); + + it.skip('the destroyServer() method should delete a server instance', function (done) { + if (mock) { + setupRebootMock(client, provider, { + authServer: authServer, + server: server + }); + } + + context.currentServer.reboot(function (err) { + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done) + }); + + }); +}); + +function setupNetworksMock(client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/networks.json'); + } +} + +function setupServerMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/servers', + {server: {name: 'create-test-ids2', flavorRef: '1', imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/creatingServer.json') + .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); + } +} + +function setupGetServersMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/detail') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverList.json'); + } +} + +function setupGetNetworkMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } +} + +var serverStatusReply = function (name, status) { + + var template = helpers.loadFixture('azure/server-status-template.xml'), + params = {NAME: name, STATUS: status}; + + var result = _.template(template, params); + return result; +}; + +var filterPath = function (path) { + var name = PATH.basename(path); + if (path.search('embed-detail=true') !== -1) { + return '/getStatus?name=' + name; + } + + return path; +}; diff --git a/test/fixtures/openstack/network.json b/test/fixtures/openstack/network.json new file mode 100644 index 000000000..1b127c396 --- /dev/null +++ b/test/fixtures/openstack/network.json @@ -0,0 +1,18 @@ +{ + "network": + { + "status":"ACTIVE", + "subnets":[ + "54d6f61d-db07-451c-9ab3-b9609b6b6f0b" + ], + "name":"private-network", + "provider:physical_network":null, + "admin_state_up":true, + "tenant_id":"4fd44f30292945e481c7b8a0c8908869", + "provider:network_type":"local", + "router:external":true, + "shared":true, + "id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", + "provider:segmentation_id":null + } +} \ No newline at end of file diff --git a/test/fixtures/openstack/networks.json b/test/fixtures/openstack/networks.json new file mode 100644 index 000000000..a895f1523 --- /dev/null +++ b/test/fixtures/openstack/networks.json @@ -0,0 +1,34 @@ +{ + "networks":[ + { + "status":"ACTIVE", + "subnets":[ + "54d6f61d-db07-451c-9ab3-b9609b6b6f0b" + ], + "name":"private-network", + "provider:physical_network":null, + "admin_state_up":true, + "tenant_id":"4fd44f30292945e481c7b8a0c8908869", + "provider:network_type":"local", + "router:external":true, + "shared":true, + "id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", + "provider:segmentation_id":null + }, + { + "status":"ACTIVE", + "subnets":[ + "08eae331-0402-425a-923c-34f7cfe39c1b" + ], + "name":"private", + "provider:physical_network":null, + "admin_state_up":true, + "tenant_id":"26a7980765d0414dbc1fc1f88cdb7e6e", + "provider:network_type":"local", + "router:external":true, + "shared":true, + "id":"db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "provider:segmentation_id":null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/openstack/realToken-admin.json b/test/fixtures/openstack/realToken-admin.json index 855e86957..beed16ba3 100644 --- a/test/fixtures/openstack/realToken-admin.json +++ b/test/fixtures/openstack/realToken-admin.json @@ -59,6 +59,18 @@ "endpoints_links": [], "type": "identity", "name": "keystone" + }, { + "endpoints": [ + { + "adminURL": "http://localhost:12347/v2.0", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:9000/v2.0", + "publicURL": "http://network.myownendpoint.org:5000/v2.0" + } + ], + "endpoints_links": [], + "type": "network", + "name": "network" } ], "user": { diff --git a/test/fixtures/openstack/realToken.json b/test/fixtures/openstack/realToken.json index 719d71cdc..89d1d2ec8 100644 --- a/test/fixtures/openstack/realToken.json +++ b/test/fixtures/openstack/realToken.json @@ -47,6 +47,18 @@ "endpoints_links": [], "type": "compute", "name": "nova" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "network", + "name": "neutron" }, { "endpoints": [ From c3c3bef67096734a8a13917527d106fe92c4ef2b Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 13:12:50 -0700 Subject: [PATCH 070/460] Added test for createNetwork --- test/common/network/network-test.js | 57 +++++++++-------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index cb5d33561..f831a1b8e 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -1,7 +1,7 @@ /* -* server-test.js: Test that should be common to all providers. +* network-test.js: Test that should be common to all providers. * -* (C) 2012 Nodejitsu Inc. +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ @@ -50,7 +50,7 @@ providers.filter(function (provider) { next(); }); } - ], done) + ], done); }); it('the getNetworks() function should return a list of networks', function(done) { @@ -75,35 +75,24 @@ providers.filter(function (provider) { }); }); - it.skip('the createServer() method with image and flavor should create a server', function (done) { - var m = mock ? .1 : 10; + it('the createNetwork() method should create a network', function (done) { + var m = mock ? 0.1 : 10; if (mock) { - setupServerMock(client, provider, { + setupNetworkMock(client, provider, { authServer: authServer, server: server }); } - client.createServer(utile.mixin({ - name: 'create-test-ids2', - image: context.images[0].id, - flavor: context.flavors[0].id - }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { + client.createNetwork(utile.mixin({ + name: 'create-test-ids2' + }), function (err, network) { should.not.exist(err); - should.exist(srv1); - - srv1.setWait({ status: srv1.STATUS.running }, 100 * m, function (err, srv2) { - should.not.exist(err); - should.exist(srv2); - srv2.should.be.instanceOf(Server); - srv2.name.should.equal('create-test-ids2'); - srv2.imageId.should.equal(context.images[0].id); - - authServer && authServer.done(); - server && server.done(); - done(); - }); + should.exist(network); + authServer && authServer.done(); + server && server.done(); + done(); }); }); @@ -153,7 +142,7 @@ providers.filter(function (provider) { function (next) { server.close(next); } - ], done) + ], done); }); }); @@ -190,22 +179,12 @@ function setupNetworksMock(client, provider, servers) { } } -function setupServerMock(client, provider, servers) { - if (provider === 'openstack') { - servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/servers', - {server: {name: 'create-test-ids2', flavorRef: '1', imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66'}}) - .replyWithFile(202, __dirname + '/../../fixtures/openstack/creatingServer.json') - .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); - } -} - -function setupGetServersMock(client, provider, servers) { +function setupNetworkMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/detail') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverList.json'); + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', + {network: {name: 'create-test-ids2'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); } } From 4b2126ede633419742f20023a138950c7936a131 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 14:22:01 -0700 Subject: [PATCH 071/460] Added destroyNetwork method and fixed inheritance of the Network model instances. --- lib/pkgcloud/core/network/network.js | 8 +- .../openstack/network/client/networks.js | 26 +++++- lib/pkgcloud/openstack/network/network.js | 2 + test/common/network/network-test.js | 92 ++++++++++++++++--- 4 files changed, 109 insertions(+), 19 deletions(-) diff --git a/lib/pkgcloud/core/network/network.js b/lib/pkgcloud/core/network/network.js index b43c22441..8bb5a9f2f 100644 --- a/lib/pkgcloud/core/network/network.js +++ b/lib/pkgcloud/core/network/network.js @@ -1,5 +1,5 @@ /* - * container.js: Base container from which all pkgcloud containers inherit from + * network.js: Base network from which all pkgcloud networks inherit. * * (C) 2014 Hewlett-Packard Development Company, L.P. * @@ -19,10 +19,6 @@ Network.prototype.create = function (callback) { this.client.createNetwork(this.name, callback); }; -Network.prototype.refresh = function (callback) { - this.client.getNetwork(this, callback); -}; - Network.prototype.destroy = function (callback) { - this.client.destroyNetwork(this.name, callback); + this.client.destroyNetwork(this.id, callback); }; diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 1f5a7658d..c4fc798fc 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -9,7 +9,7 @@ var async = require('async'), request = require('request'), pkgcloud = require('../../../../pkgcloud'), - urlJoin = require('url-join'); + urlJoin = require('url-join'), _ = require('underscore'); /** @@ -106,3 +106,27 @@ exports.createNetwork = function (options, callback) { : callback(null, new self.models.Network(self, body.network)); }); }; + +/** + * client.destroyNetwork + * + * @description Delete a specific network + * + * @param {String|object} network the network or network ID + * @param callback + */ +exports.destroyNetwork = function (network, callback) { + var networkId = network instanceof this.models.Network ? network.id : network, + self = this; + self.emit('log::trace', 'Deleting network', networkId); + debugger; + this._request({ + path: urlJoin('/v2.0/networks',networkId), + method: 'DELETE' + }, function (err, body, res) { + if (err) { + return callback(err); + } + callback(null, true); + }); +}; diff --git a/lib/pkgcloud/openstack/network/network.js b/lib/pkgcloud/openstack/network/network.js index 7e057ade4..9d3a9f1f4 100644 --- a/lib/pkgcloud/openstack/network/network.js +++ b/lib/pkgcloud/openstack/network/network.js @@ -13,6 +13,8 @@ var Network = exports.Network = function Network(client, details) { base.Network.call(this, client, details); }; +utile.inherits(Network, base.Network); + Network.prototype._setProperties = function (details) { this.name = details.name || this.name; this.status = details.status || this.status; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index f831a1b8e..1d9caa60a 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -17,7 +17,8 @@ var fs = require('fs'), _ = require('underscore'), providers = require('../../configs/providers.json'), Network = require('../../../lib/pkgcloud/core/network/network').Network, - mock = !!process.env.MOCK; + mock = !!process.env.MOCK, + urlJoin = require('url-join'); providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].network; @@ -75,6 +76,28 @@ providers.filter(function (provider) { }); }); + it('the getNetwork() method should get a network instance', function (done) { + if (mock) { + setupGetNetworkMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.getNetwork(context.networks[0].id, function (err, network) { + should.not.exist(err); + should.exist(network); + network.should.be.an.instanceOf(Network); + network.should.have.property('id', context.networks[0].id); + context.currentNetwork = network; + + authServer && authServer.done(); + server && server.done(); + done(); + + }); + }); + it('the createNetwork() method should create a network', function (done) { var m = mock ? 0.1 : 10; @@ -96,36 +119,55 @@ providers.filter(function (provider) { }); }); - it('the getNetwork() method should get a network instance', function (done) { + it('the destroyNetwork() method should delete a network', function (done) { if (mock) { - setupGetNetworkMock(client, provider, { + setupDestroyNetworkMock(client, provider, { authServer: authServer, server: server - }); + }, context.currentNetwork); } - client.getNetwork(context.networks[0].id, function (err, network) { + context.currentNetwork.destroy(function (err) { should.not.exist(err); - should.exist(network); + done(); + }); + }); - context.currentNetwork = network; + it('the network.Create() method should create a network', function (done) { + var m = mock ? 0.1 : 10; + if (mock) { + setupNetworkModelCreateMock(client, provider, { + authServer: authServer, + server: server + }); + } + + var network = new Network(client); + network.name= "model created network"; + network.create(function (err, createdNetwork) { + should.not.exist(err); + should.exist(createdNetwork); authServer && authServer.done(); server && server.done(); done(); - }); }); - it.skip('the destroyServer() method should delete a server instance', function (done) { + it('the network.destroy() method should delete a network', function (done) { + var network = new Network(client); + network.name = "model deleted network"; + network.id = "THISISANETWORKID"; + if (mock) { - setupRebootMock(client, provider, { + setupModelDestroyedNetworkMock(client, provider, { authServer: authServer, server: server - }); + }, network); } - context.currentServer.reboot(function (err) { + network.destroy(function (err) { + should.not.exist(err); done(); }); }); @@ -148,6 +190,23 @@ providers.filter(function (provider) { }); }); +function setupDestroyNetworkMock(client,provider,servers,currentNetwork){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } +} + + +function setupModelDestroyedNetworkMock(client,provider,servers,currentNetwork){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } +} + function setupNetworksMock(client, provider, servers) { if (provider === 'openstack') { servers.authServer @@ -188,6 +247,15 @@ function setupNetworkMock(client, provider, servers) { } } +function setupNetworkModelCreateMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', + {network: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); + } +} + function setupGetNetworkMock(client, provider, servers) { if (provider === 'openstack') { servers.server From b863a861537f87d6f89bb926ba4cadaf9de3bbe3 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 14:31:00 -0700 Subject: [PATCH 072/460] Added network.refresh method and tests. --- lib/pkgcloud/core/network/network.js | 4 ++++ test/common/network/network-test.js | 31 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/pkgcloud/core/network/network.js b/lib/pkgcloud/core/network/network.js index 8bb5a9f2f..40bc79568 100644 --- a/lib/pkgcloud/core/network/network.js +++ b/lib/pkgcloud/core/network/network.js @@ -19,6 +19,10 @@ Network.prototype.create = function (callback) { this.client.createNetwork(this.name, callback); }; +Network.prototype.refresh = function (callback) { + this.client.getNetwork(this.id, callback); +}; + Network.prototype.destroy = function (callback) { this.client.destroyNetwork(this.id, callback); }; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 1d9caa60a..b52d0231b 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -154,6 +154,29 @@ providers.filter(function (provider) { }); }); + it('the network.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var network = new Network(client); + network.id = "d32019d3-bc6e-4319-9c1d-6722fc136a22"; + + if (mock) { + setupRefreshNetworkMock(client, provider, { + authServer: authServer, + server: server + }, network); + } + + network.refresh(function (err, refreshedNetwork) { + should.not.exist(err); + should.exist(refreshedNetwork); + refreshedNetwork.should.have.property('name', 'private-network'); + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + it('the network.destroy() method should delete a network', function (done) { var network = new Network(client); network.name = "model deleted network"; @@ -247,6 +270,14 @@ function setupNetworkMock(client, provider, servers) { } } +function setupRefreshNetworkMock(client, provider, servers, network) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks',network.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } +} + function setupNetworkModelCreateMock(client, provider, servers) { if (provider === 'openstack') { servers.server From a9d71e40587bd47a80a664c855f951942a6e56d4 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 15:43:27 -0700 Subject: [PATCH 073/460] Added updateNetwork method and tests. --- lib/pkgcloud/core/network/network.js | 5 ++- .../openstack/network/client/networks.js | 25 +++++++++++++ lib/pkgcloud/openstack/network/index.js | 2 +- lib/pkgcloud/openstack/network/network.js | 4 +-- test/common/network/network-test.js | 36 ++++++++++++++++--- 5 files changed, 63 insertions(+), 9 deletions(-) diff --git a/lib/pkgcloud/core/network/network.js b/lib/pkgcloud/core/network/network.js index 40bc79568..621f3560e 100644 --- a/lib/pkgcloud/core/network/network.js +++ b/lib/pkgcloud/core/network/network.js @@ -10,7 +10,6 @@ var utile = require('utile'), var Network = exports.Network = function (client, details) { model.Model.call(this, client, details); - }; utile.inherits(Network, model.Model); @@ -23,6 +22,10 @@ Network.prototype.refresh = function (callback) { this.client.getNetwork(this.id, callback); }; +Network.prototype.update = function (callback) { + this.client.updateNetwork(this, callback); +}; + Network.prototype.destroy = function (callback) { this.client.destroyNetwork(this.id, callback); }; diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index c4fc798fc..9953c739f 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -107,6 +107,31 @@ exports.createNetwork = function (options, callback) { }); }; +/** + * client.updateNetwork + * + * @description update a new network + * + * @param {object} options + * @param callback + */ +exports.updateNetwork = function (network, callback) { + var self = this, networkToUpdate = network instanceof this.models.Network ? network.toJSON() : network; + var createNetworkOpts = { + method: 'PUT', + path: urlJoin('/v2.0/networks', networkToUpdate.id), + contentType: 'application/json', + body: { 'network' : networkToUpdate} + }; + + self.emit('log::trace', 'Creating network', network); + this._request(createNetworkOpts, function (err,body) { + return err + ? callback(err) + : callback(null, new self.models.Network(self, body.network)); + }); +}; + /** * client.destroyNetwork * diff --git a/lib/pkgcloud/openstack/network/index.js b/lib/pkgcloud/openstack/network/index.js index 20bba5b65..1853e089b 100644 --- a/lib/pkgcloud/openstack/network/index.js +++ b/lib/pkgcloud/openstack/network/index.js @@ -5,7 +5,7 @@ * */ -exports.Client = require('./client').Client; +exports.Client = require('./client').Client; exports.Network = require('./network').Network; exports.createClient = function (options) { diff --git a/lib/pkgcloud/openstack/network/network.js b/lib/pkgcloud/openstack/network/network.js index 9d3a9f1f4..c445d25a4 100644 --- a/lib/pkgcloud/openstack/network/network.js +++ b/lib/pkgcloud/openstack/network/network.js @@ -1,5 +1,5 @@ /* - * container.js: Openstack Object Storage Container + * network.js: Openstack Network object. * * (C) 2014 Hewlett-Packard Development Company, L.P. * @@ -27,5 +27,5 @@ Network.prototype._setProperties = function (details) { Network.prototype.toJSON = function () { return _.pick(this, ['name', 'id', 'status', 'shared', - 'tenant_id', 'subnets']); + 'tenant_id', 'subnets']); }; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index b52d0231b..874446633 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -127,13 +127,31 @@ providers.filter(function (provider) { }, context.currentNetwork); } - context.currentNetwork.destroy(function (err) { + client.destroyNetwork(context.currentNetwork, function (err) { should.not.exist(err); done(); }); }); - it('the network.Create() method should create a network', function (done) { + it('the updateNetwork() method should update a network', function (done) { + + var networkToUpdate = { id : context.currentNetwork.id, admin_state_up : false}; + networkToUpdate.id = context.currentNetwork.id; + networkToUpdate.admin_state_up = false; + if (mock) { + setupUpdateNetworkMock(client, provider, { + authServer: authServer, + server: server + }, networkToUpdate); + } + + client.updateNetwork(networkToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the network.create() method should create a network', function (done) { var m = mock ? 0.1 : 10; if (mock) { @@ -213,7 +231,7 @@ providers.filter(function (provider) { }); }); -function setupDestroyNetworkMock(client,provider,servers,currentNetwork){ +function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) @@ -221,8 +239,16 @@ function setupDestroyNetworkMock(client,provider,servers,currentNetwork){ } } +function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ + if (provider === 'openstack') { + servers.server + .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id), + { network: { id: currentNetwork.id, admin_state_up: false }}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } +} -function setupModelDestroyedNetworkMock(client,provider,servers,currentNetwork){ +function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) @@ -266,7 +292,7 @@ function setupNetworkMock(client, provider, servers) { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', {network: {name: 'create-test-ids2'}}) - .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); + .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); } } From 2630b1efb4e1cd6e53866c8fcf8150d0ad7d50a7 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 15:56:08 -0700 Subject: [PATCH 074/460] Added documentation for Openstack network provider --- docs/README.md | 2 + docs/providers/openstack/compute.md | 2 +- docs/providers/openstack/network.md | 62 +++++++++++++++++++ .../openstack/network/client/networks.js | 8 +-- 4 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 docs/providers/openstack/network.md diff --git a/docs/README.md b/docs/README.md index ab2fbbf20..0661534e1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -38,3 +38,5 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](providers/rackspace/blockstorage.md) * **Load Balancers** *(beta)* * [Rackspace](providers/rackspace/loadbalancer.md) +* **Networking** *(beta)* + * [Openstack](providers/openstack/network.md) diff --git a/docs/providers/openstack/compute.md b/docs/providers/openstack/compute.md index 4e64e39a5..3b107dafd 100644 --- a/docs/providers/openstack/compute.md +++ b/docs/providers/openstack/compute.md @@ -138,4 +138,4 @@ Attaches the provided `volume` to the `server`. `volume` may either be the `volu Detaches the provided `attachment` from the server. `attachment` may either be the `attachmentId` or an object with `attachmentId` as a property. If the `volume` is mounted this call will return an err. -`f(err)` \ No newline at end of file +`f(err)` diff --git a/docs/providers/openstack/network.md b/docs/providers/openstack/network.md new file mode 100644 index 000000000..8173d03e0 --- /dev/null +++ b/docs/providers/openstack/network.md @@ -0,0 +1,62 @@ +##Using the Openstack Network provider + +Creating a client is straight-forward: + +``` js + var openstack = pkgcloud.network.createClient({ + provider: 'openstack', + username: 'your-user-name', + password: 'your-password', + authUrl: 'https://your-identity-service' + }); +``` +### API Methods + +**Networks** + +#### client.getNetworks(callback) +Lists all networks that are available to use on your Openstack account + +Callback returns `f(err, networks)` where `networks` is an `Array` + +#### client.createNetwork(options, callback) +Creates a network with the options specified + +Options are as follows: + +```js +{ + name: 'networkName', // optional + admin_state_up : true, // optional + shared : true, // optional, Admin only + tenant_id : '' // optional, Admin only +} +``` +Returns the network in the callback `f(err, network)` + +#### client.updateNetwork(options, callback) +Updates a network with the options specified + +Options are as follows: + +```js +{ + id : '', // required + name: 'networkName', // optional + admin_state_up : true, // optional + shared : true, // optional, Admin only + tenant_id : '' // optional, Admin only +} +``` +Returns the network in the callback `f(err, network)` + +#### client.destroyNetwork(network, callback) +Destroys the specified network + +Takes network or networkId as an argument and returns the id of the destroyed network in the callback `f(err, networkId)` + +#### client.getNetwork(network, callback) +Gets specified network + +Takes network or networkId as an argument and returns the network in the callback +`f(err, network)` diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 9953c739f..7084fbd65 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -61,11 +61,11 @@ exports.getNetworks = function (options, callback) { * @param callback */ exports.getNetwork = function (network, callback) { - var networkName = network instanceof this.models.Network ? network.id : network, + var networkId = network instanceof this.models.Network ? network.id : network, self = this; - self.emit('log::trace', 'Getting details for network', networkName); + self.emit('log::trace', 'Getting details for network', networkId); this._request({ - path: urlJoin('/v2.0/networks',networkName), + path: urlJoin('/v2.0/networks',networkId), method: 'GET' }, function (err, body, res) { if (err) { @@ -152,6 +152,6 @@ exports.destroyNetwork = function (network, callback) { if (err) { return callback(err); } - callback(null, true); + callback(null, networkId); }); }; From 690b8fe833040cfea20d87ec4bf48ca6d137d4c8 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 16:05:25 -0700 Subject: [PATCH 075/460] Adding links on the homepage for network provider. --- README.md | 69 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3368d4837..b7dd14313 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ pkgcloud is a standard library for node.js that abstracts away differences among * [DNS](#dns----beta) *(beta)* * [Block Storage](#block-storage----beta) *(beta)* * [Load Balancers](#load-balancers----beta) *(beta)* +* [Network](#network----beta) *(beta)* * _Fine Print_ * [Installation](#installation) * [Tests](#tests) @@ -39,6 +40,7 @@ Currently there are six service types which are handled by pkgcloud: * [DNS](#dns----beta) *(beta)* * [Block Storage](#block-storage----beta) *(beta)* * [Load Balancers](#load-balancers----beta) *(beta)* +* [Network](#dns----beta) *(beta)* In our [Roadmap](#roadmap), we plan to add support for more services, such as Queueing, Monitoring, and more. Additionally, we plan to implement more providers for the *beta* services, thus moving them out of *beta*. @@ -49,13 +51,13 @@ Services provided by `pkgcloud` are exposed in two ways: * **By service type:** For example, if you wanted to create an API client to communicate with a compute service you could simply: -``` js +``` js var client = require('pkgcloud').compute.createClient({ // // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -116,6 +118,8 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](docs/providers/rackspace/blockstorage.md) * **[Load Balancers](#load-balancers----beta)** *(beta)* * [Rackspace](docs/providers/rackspace/loadbalancer.md) +* **[Network](#network----beta)** *(beta)* + * [Openstack](docs/providers/openstack/network.md) ## Compute @@ -127,7 +131,7 @@ The `pkgcloud.compute` service is designed to make it easy to provision and work // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -174,7 +178,7 @@ To get started with a `pkgcloud.storage` client just create one: // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -209,9 +213,9 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ``` js var pkgcloud = require('pkgcloud'), fs = require('fs'); - + var client = pkgcloud.storage.createClient({ /* ... */ }); - + fs.createReadStream('a-file.txt').pipe(client.upload({ container: 'a-container', remote: 'remote-file-name.txt' @@ -222,9 +226,9 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ``` js var pkgcloud = require('pkgcloud'), fs = require('fs'); - + var client = pkgcloud.storage.createClient({ /* ... */ }); - + client.download({ container: 'a-container', remote: 'remote-file-name.txt' @@ -233,7 +237,7 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio ## Databases -The `pkgcloud.database` service is designed to consistently work with a variety of Database-as-a-Service (DBaaS) providers. +The `pkgcloud.database` service is designed to consistently work with a variety of Database-as-a-Service (DBaaS) providers. To get started with a `pkgcloud.storage` client just create one: @@ -243,7 +247,7 @@ To get started with a `pkgcloud.storage` client just create one: // The name of the provider (e.g. "joyent") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -285,7 +289,7 @@ To get started with a `pkgcloud.dns` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -326,7 +330,7 @@ To get started with a `pkgcloud.blockstorage` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -367,7 +371,7 @@ To get started with a `pkgcloud.loadbalancer` client just create one: // The name of the provider (e.g. "rackspace") // provider: 'provider-name', - + // // ... Provider specific credentials // @@ -393,6 +397,39 @@ Each instance of `pkgcloud.loadbalancer.Client` returned from `pkgcloud.loadbala * `client.updateNode(loadBalancer, node, function (err) { })` * `client.removeNode(loadBalancer, node, function (err) { })` +## Network -- Beta + +##### Note: Network is considered Beta until there are multiple providers; presently only Rackspace are supported. + +The `pkgcloud.network` service is designed to make it easy to create and manage networks. + +To get started with a `pkgcloud.network` client just create one: + +``` js + var client = require('pkgcloud').network.createClient({ + // + // The name of the provider (e.g. "openstack") + // + provider: 'provider-name', + + // + // ... Provider specific credentials + // + }); +``` + +#### Providers + +* [Openstack](docs/providers/openstack/network.md) +Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.createClient` has a set of uniform APIs: + +### Volume +* `client.getNetworks(options, function (err, networks) { })` +* `client.getNetwork(network, function (err, network) { })` +* `client.createNetwork(options, function (err, network) { })` +* `client.updateNetwork(network, function (err, network) { })` +* `client.deleteNetwork(network, function (err, networkId) { })` + ## Installation ``` bash @@ -435,13 +472,13 @@ Also you can run the tests directly using `mocha` with `hock` enabled: ``` bash Linux/Mac - Mocha installed globally: $ MOCK=on mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js - + Linux/Mac - Mocha installed locally: $ MOCK=on node_modules/.bin/mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js Windows - Mocha installed globally: $ set MOCK=on&mocha -R spec test/*/*/*-test.js test/*/*/*/*-test.js - + Windows - Mocha installed locally: $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/*/*/*-test.js test/*/*/*/*-test.js ``` @@ -457,7 +494,7 @@ Linux/Mac - Mocha installed locally: Windows - Mocha installed globally: $ set MOCK=on&mocha -R spec test/iriscouch/*/*-test.js - + Windows - Mocha installed locally: $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/iriscouch/*/*-test.js From 6bbec17afa76c0dd7cf931d965ea2b670baa0c29 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 16:07:37 -0700 Subject: [PATCH 076/460] s/Rackspace/Openstack --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7dd14313..9d8a1ca0e 100644 --- a/README.md +++ b/README.md @@ -399,7 +399,7 @@ Each instance of `pkgcloud.loadbalancer.Client` returned from `pkgcloud.loadbala ## Network -- Beta -##### Note: Network is considered Beta until there are multiple providers; presently only Rackspace are supported. +##### Note: Network is considered Beta until there are multiple providers; presently only Openstack providers are supported. The `pkgcloud.network` service is designed to make it easy to create and manage networks. From 0f657a28e443d8ef6e585b80d4cab477bbf1eebe Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 16:09:20 -0700 Subject: [PATCH 077/460] Fixing lines --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9d8a1ca0e..e7dc8d455 100644 --- a/README.md +++ b/README.md @@ -421,6 +421,7 @@ To get started with a `pkgcloud.network` client just create one: #### Providers * [Openstack](docs/providers/openstack/network.md) + Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.createClient` has a set of uniform APIs: ### Volume From 10ddcf3e2bb8822a3b391280244c40aa3eafb33b Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 21:58:56 -0700 Subject: [PATCH 078/460] Minor fixes for networking client. Added support for working with Subnets --- lib/pkgcloud.js | 3 +- lib/pkgcloud/core/network/subnet.js | 31 ++ .../openstack/network/client/index.js | 4 +- .../openstack/network/client/networks.js | 17 +- .../openstack/network/client/subnets.js | 153 +++++++++ lib/pkgcloud/openstack/network/index.js | 1 + lib/pkgcloud/openstack/network/subnet.js | 33 ++ test/common/network/network-test.js | 2 +- test/common/network/subnet-test.js | 322 ++++++++++++++++++ test/fixtures/openstack/subnet.json | 20 ++ test/fixtures/openstack/subnets.json | 40 +++ 11 files changed, 611 insertions(+), 15 deletions(-) create mode 100644 lib/pkgcloud/core/network/subnet.js create mode 100644 lib/pkgcloud/openstack/network/client/subnets.js create mode 100644 lib/pkgcloud/openstack/network/subnet.js create mode 100644 test/common/network/subnet-test.js create mode 100644 test/fixtures/openstack/subnet.json create mode 100644 test/fixtures/openstack/subnets.json diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index b1046a21c..deb1a1cd8 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -40,7 +40,8 @@ var services = [ 'dns', 'loadbalancer', 'storage', - 'network' + 'network', + 'subnet' ]; // diff --git a/lib/pkgcloud/core/network/subnet.js b/lib/pkgcloud/core/network/subnet.js new file mode 100644 index 000000000..dbd065dd9 --- /dev/null +++ b/lib/pkgcloud/core/network/subnet.js @@ -0,0 +1,31 @@ +/* + * network.js: Base subnet from which all pkgcloud subnet inherit. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + model = require('../base/model'); + +var Subnet = exports.Subnet = function (client, details) { + model.Model.call(this, client, details); +}; + +utile.inherits(Subnet, model.Model); + +Subnet.prototype.create = function (callback) { + this.client.createSubnet(this.name, callback); +}; + +Subnet.prototype.refresh = function (callback) { + this.client.getSubnet(this.id, callback); +}; + +Subnet.prototype.update = function (callback) { + this.client.updateSubnet(this, callback); +}; + +Subnet.prototype.destroy = function (callback) { + this.client.destroySubnet(this.id, callback); +}; diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index afac27eb0..c56fed2ea 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -15,10 +15,12 @@ var Client = exports.Client = function (options) { openstack.Client.call(this, options); this.models = { - Network: require('../network').Network + Network: require('../network').Network, + Subnet: require('../subnet').Subnet }; utile.mixin(this, require('./networks')); + utile.mixin(this, require('./subnets')); this.serviceType = 'network'; }; diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 7084fbd65..138a66d31 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -18,9 +18,6 @@ var async = require('async'), * @description get the list of networks for an account * * @param {object|Function} options - * @param {Number} [options.limit] the number of records to return - * @param {String} [options.marker] Marker value. Operation returns object names that are greater than this value. - * @param {String} [options.end_marker] Operation returns object names that are less than this value. * @param {Function} callback */ exports.getNetworks = function (options, callback) { @@ -32,17 +29,14 @@ exports.getNetworks = function (options, callback) { } var getNetworkOpts = { - path: '/v2.0/networks', - qs: _.extend({ - format: 'json' - }, _.pick(options, ['limit', 'marker', 'end_marker'])) + path: '/v2.0/networks' }; this._request(getNetworkOpts, function (err, body) { if (err) { return callback(err); } - else if (!body ||!body.networks || !(body.networks instanceof Array)) { + else if (!body || !body.networks || !(body.networks instanceof Array)) { return new Error('Malformed API Response'); } @@ -57,7 +51,7 @@ exports.getNetworks = function (options, callback) { * * @description get the details for a specific network * - * @param {String|object} network the network or networkName + * @param {String|object} network the network or networkId * @param callback */ exports.getNetwork = function (network, callback) { @@ -65,7 +59,7 @@ exports.getNetwork = function (network, callback) { self = this; self.emit('log::trace', 'Getting details for network', networkId); this._request({ - path: urlJoin('/v2.0/networks',networkId), + path: urlJoin('/v2.0/networks', networkId), method: 'GET' }, function (err, body, res) { if (err) { @@ -110,7 +104,7 @@ exports.createNetwork = function (options, callback) { /** * client.updateNetwork * - * @description update a new network + * @description update an existing network * * @param {object} options * @param callback @@ -144,7 +138,6 @@ exports.destroyNetwork = function (network, callback) { var networkId = network instanceof this.models.Network ? network.id : network, self = this; self.emit('log::trace', 'Deleting network', networkId); - debugger; this._request({ path: urlJoin('/v2.0/networks',networkId), method: 'DELETE' diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js new file mode 100644 index 000000000..e5ee3204f --- /dev/null +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -0,0 +1,153 @@ +/* + * networks.js: Instance methods for working with networks + * for Openstack networking + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var async = require('async'), + request = require('request'), + pkgcloud = require('../../../../pkgcloud'), + urlJoin = require('url-join'), + _ = require('underscore'); + +/** + * client.getSubnets + * + * @description get the list of networks for an account + * + * @param {object|Function} options + * @param {Number} [options.limit] the number of records to return + * @param {String} [options.marker] Marker value. Operation returns object names that are greater than this value. + * @param {String} [options.end_marker] Operation returns object names that are less than this value. + * @param {Function} callback + */ +exports.getSubnets = function (options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var getSubnetOpts = { + path: '/v2.0/subnets', + }; + + this._request(getSubnetOpts, function (err, body) { + if (err) { + return callback(err); + } + else if (!body ||!body.subnets || !(body.subnets instanceof Array)) { + return new Error('Malformed API Response'); + } + + return callback(null, body.subnets.map(function (subnet) { + return new self.models.Subnet(self, subnet); + })); + }); +}; + +/** + * client.getSubnet + * + * @description get the details for a specific network + * + * @param {String|object} subnet the subnet or subnetId + * @param callback + */ +exports.getSubnet = function (subnet, callback) { + var subnetId = subnet instanceof this.models.Subnet ? subnet.id : subnet, + self = this; + self.emit('log::trace', 'Getting details for subnet', subnetId); + this._request({ + path: urlJoin('/v2.0/subnets', subnetId), + method: 'GET' + }, function (err, body, res) { + if (err) { + return callback(err); + } + + if (!body || !body.subnet) { + return new Error('Malformed API Response'); + } + + callback(null, new self.models.Subnet(self, body.subnet)); + }); +}; + +/** + * client.createSubnet + * + * @description create a new subnet + * + * @param {object} options + * @param {String} options.name the name of the new subnet + * @param callback + */ +exports.createSubnet = function (options, callback) { + var subnet = typeof options === 'object' ? options : { 'name' : options}, + self = this; + + var createSubnetOpts = { + method: 'POST', + path: '/v2.0/subnets', + body: { 'subnet' : subnet} + }; + + self.emit('log::trace', 'Creating subnet', subnet); + this._request(createSubnetOpts, function (err,body) { + return err + ? callback(err) + : callback(null, new self.models.Subnet(self, body.subnet)); + }); +}; + +/** + * client.updateSubnet + * + * @description update an existing subnet + * + * @param {object} options + * @param callback + */ +exports.updateSubnet = function (subnet, callback) { + var self = this, subnetToUpdate = subnet instanceof this.models.Subnet ? subnet.toJSON() : subnet; + var updateSubnetOpts = { + method: 'PUT', + path: urlJoin('/v2.0/subnets', subnetToUpdate.id), + contentType: 'application/json', + body: { 'subnet' : subnetToUpdate} + }; + + self.emit('log::trace', 'Updating subnet', subnet); + this._request(updateSubnetOpts, function (err,body) { + return err + ? callback(err) + : callback(null, new self.models.Subnet(self, body.subnet)); + }); +}; + +/** + * client.destroySubnet + * + * @description Delete a specific network + * + * @param {String|object} subnet the subnet or subnet ID + * @param callback + */ +exports.destroySubnet = function (subnet, callback) { + var subnetId = subnet instanceof this.models.Subnet ? subnet.id : subnet, + self = this; + self.emit('log::trace', 'Deleting subnet', subnetId); + this._request({ + path: urlJoin('/v2.0/subnets',subnetId), + method: 'DELETE' + }, function (err, body, res) { + if (err) { + return callback(err); + } + callback(null, subnetId); + }); +}; diff --git a/lib/pkgcloud/openstack/network/index.js b/lib/pkgcloud/openstack/network/index.js index 1853e089b..b9d069670 100644 --- a/lib/pkgcloud/openstack/network/index.js +++ b/lib/pkgcloud/openstack/network/index.js @@ -7,6 +7,7 @@ exports.Client = require('./client').Client; exports.Network = require('./network').Network; +exports.Subnet = require('./subnet').Subnet; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/openstack/network/subnet.js b/lib/pkgcloud/openstack/network/subnet.js new file mode 100644 index 000000000..3ff7b7e30 --- /dev/null +++ b/lib/pkgcloud/openstack/network/subnet.js @@ -0,0 +1,33 @@ +/* + * network.js: Openstack Subnet object. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + base = require('../../core/network/subnet'), + _ = require('underscore'); + +var Subnet = exports.Subnet = function Subnet(client, details) { + base.Subnet.call(this, client, details); +}; + +utile.inherits(Subnet, base.Subnet); + +Subnet.prototype._setProperties = function (details) { + this.name = details.name || this.name; + this.enable_dhcp = details.enable_dhcp || this.enable_dhcp; + this.network_id = details.network_id || this.network_id; + this.id = details.id || this.id; + this.ip_version = details.ip_version || this.ip_version; + this.tenant_id = details.tenant_id || this.tenant_id; + this.gateway_ip = details.gateway_ip || this.gateway_ip; + this.cidr = details.cidr || this.cidr; + this.dns_nameservers = details.dns_nameservers || this.dns_nameservers; +}; + +Subnet.prototype.toJSON = function () { + return _.pick(this, ['name', 'id', 'network_id', 'ip_version', + 'tenant_id', 'gateway_ip', 'dns_nameservers']); +}; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 874446633..a4ed61b44 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -282,7 +282,7 @@ function setupNetworksMock(client, provider, servers) { .reply(200, helpers.getOpenstackAuthResponse()); servers.server - .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks?format=json') + .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks') .replyWithFile(200, __dirname + '/../../fixtures/openstack/networks.json'); } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js new file mode 100644 index 000000000..a1ea60f34 --- /dev/null +++ b/test/common/network/subnet-test.js @@ -0,0 +1,322 @@ +/* +* subnet-test.js: Test that should be common to all providers. +* +* (C) 2014 Hewlett-Packard Development Company, L.P. +* +*/ + +var fs = require('fs'), + path = require('path'), + qs = require('qs'), + should = require('should'), + utile = require('utile'), + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + async = require('async'), + _ = require('underscore'), + providers = require('../../configs/providers.json'), + Subnet = require('../../../lib/pkgcloud/core/network/subnet').Subnet, + mock = !!process.env.MOCK, + urlJoin = require('url-join'); + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/subnets [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + hock.createHock({ + port: 12345, + throwOnUnmatched: false + }, function (err, hockClient) { + server = hockClient; + next(); + }); + }, + function (next) { + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + next(); + }); + } + ], done); + }); + + it('the getSubnets() function should return a list of subnets', function(done) { + + if (mock) { + setupSubnetsMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.getSubnets(function (err, subnets) { + should.not.exist(err); + should.exist(subnets); + + context.subnets = subnets; + + authServer && authServer.done(); + server && server.done(); + + done(); + }); + }); + + it('the getSubnet() method should get a subnet instance', function (done) { + if (mock) { + setupGetSubnetMock(client, provider, { + authServer: authServer, + server: server + },context.subnets[0]); + } + + client.getSubnet(context.subnets[0].id, function (err, subnet) { + should.not.exist(err); + should.exist(subnet); + subnet.should.be.an.instanceOf(Subnet); + subnet.should.have.property('id', context.subnets[0].id); + context.currentSubnet = subnet; + + authServer && authServer.done(); + server && server.done(); + done(); + + }); + }); + + it('the createSubnet() method should create a subnet', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupCreateSubnetMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.createSubnet({ + name: 'create-test-ids2' + }, function (err, subnet) { + should.not.exist(err); + should.exist(subnet); + subnet.should.be.an.instanceOf(Subnet); + + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + + it('the destroySubnet() method should delete a subnet', function (done) { + if (mock) { + setupDestroySubnetMock(client, provider, { + authServer: authServer, + server: server + }, context.currentSubnet); + } + + client.destroySubnet(context.currentSubnet, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updateSubnet() method should update a subnet', function (done) { + + var subnetToUpdate = { id : context.currentSubnet.id, enable_dhcp : false}; + if (mock) { + setupUpdateSubnetMock(client, provider, { + authServer: authServer, + server: server + }, subnetToUpdate); + } + + client.updateSubnet(subnetToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the subnet.create() method should create a subnet', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupSubnetModelCreateMock(client, provider, { + authServer: authServer, + server: server + }); + } + + var subnet = new Subnet(client); + subnet.name= "model created network"; + subnet.create(function (err, createdSubnet) { + should.not.exist(err); + should.exist(createdSubnet); + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + + it('the subnet.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var subnet = new Subnet(client); + subnet.id = "d32019d3-bc6e-4319-9c1d-6722fc136a22"; + + if (mock) { + setupRefreshSubnetMock(client, provider, { + authServer: authServer, + server: server + }, subnet); + } + + subnet.refresh(function (err, refreshedSubnet) { + should.not.exist(err); + should.exist(refreshedSubnet); + refreshedSubnet.should.have.property('name', 'my_subnet'); + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + + it('the subnet.destroy() method should delete a subnet', function (done) { + var subnet = new Subnet(client); + subnet.name = "model deleted subnet"; + subnet.id = "THISISANETWORKID"; + + if (mock) { + setupModelDestroyedSubnetMock(client, provider, { + authServer: authServer, + server: server + }, subnet); + } + + subnet.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + + }); +}); + +function setupDestroySubnetMock(client, provider, servers, currentSubnet){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } +} + +function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ + if (provider === 'openstack') { + servers.server + .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id), + { subnet: { id: currentSubnet.id, enable_dhcp: false }}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } +} + +function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } +} + +function setupSubnetsMock(client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnets.json'); + } +} + +function setupCreateSubnetMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', + {subnet: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); + } +} + +function setupRefreshSubnetMock(client, provider, servers, subnet) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', subnet.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } +} + +function setupSubnetModelCreateMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', + {subnet: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); + } +} + +function setupGetSubnetMock(client, provider, servers, currentSubnet) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } +} diff --git a/test/fixtures/openstack/subnet.json b/test/fixtures/openstack/subnet.json new file mode 100644 index 000000000..b369ffe98 --- /dev/null +++ b/test/fixtures/openstack/subnet.json @@ -0,0 +1,20 @@ +{ + "subnet": { + "name": "my_subnet", + "enable_dhcp": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.0.0.1", + "cidr": "192.0.0.0/8", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} diff --git a/test/fixtures/openstack/subnets.json b/test/fixtures/openstack/subnets.json new file mode 100644 index 000000000..2c5ba82ab --- /dev/null +++ b/test/fixtures/openstack/subnets.json @@ -0,0 +1,40 @@ +{ + "subnets": [ + { + "name": "private-subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "10.0.0.1", + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + }, + { + "name": "my_subnet", + "enable_dhcp": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.0.0.1", + "cidr": "192.0.0.0/8", + "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b" + } + ] +} From ab0475caa23bff54d4a91e71ee14759fd80be31d Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 22:10:39 -0700 Subject: [PATCH 079/460] Adding documentation for Subnet client. --- README.md | 10 ++++- docs/providers/openstack/network.md | 61 +++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e7dc8d455..a421e332e 100644 --- a/README.md +++ b/README.md @@ -424,13 +424,21 @@ To get started with a `pkgcloud.network` client just create one: Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.createClient` has a set of uniform APIs: -### Volume +### Networks * `client.getNetworks(options, function (err, networks) { })` * `client.getNetwork(network, function (err, network) { })` * `client.createNetwork(options, function (err, network) { })` * `client.updateNetwork(network, function (err, network) { })` * `client.deleteNetwork(network, function (err, networkId) { })` + +### Subnets +* `client.getSubnets(options, function (err, subnets) { })` +* `client.getSubnet(subnet, function (err, subnet) { })` +* `client.createSubnet(options, function (err, subnet) { })` +* `client.updateSubnet(subnet, function (err, subnet) { })` +* `client.deleteSubnet(subnet, function (err, subnetId) { })` + ## Installation ``` bash diff --git a/docs/providers/openstack/network.md b/docs/providers/openstack/network.md index 8173d03e0..f2ea377b4 100644 --- a/docs/providers/openstack/network.md +++ b/docs/providers/openstack/network.md @@ -19,6 +19,12 @@ Lists all networks that are available to use on your Openstack account Callback returns `f(err, networks)` where `networks` is an `Array` +#### client.getNetwork(network, callback) +Gets specified network + +Takes network or networkId as an argument and returns the network in the callback +`f(err, network)` + #### client.createNetwork(options, callback) Creates a network with the options specified @@ -55,8 +61,55 @@ Destroys the specified network Takes network or networkId as an argument and returns the id of the destroyed network in the callback `f(err, networkId)` -#### client.getNetwork(network, callback) -Gets specified network +**Subnets** -Takes network or networkId as an argument and returns the network in the callback -`f(err, network)` +#### client.getSubnets(callback) +Lists all subnets that are available to use on your Openstack account + +Callback returns `f(err, subnets)` where `subnets` is an `Array` + +#### client.getSubnet(subnet, callback) +Gets specified subnet + +Takes subnet or subnetId as an argument and returns the subnet in the callback +`f(err, subnet)` + +#### client.createSubnet(options, callback) +Creates a subnet with the options specified + +Options are as follows: + +```js +{ + name: 'subnetName', // optional + network_id : '', // required, The ID of the attached network. + shared : true, // optional, Admin only + tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only + gateway_ip : 'gateway ip address', // optional,The gateway IP address. + enable_dhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. +} +``` +Returns the subnet in the callback `f(err, subnet)` + +#### client.updateSubnet(options, callback) +Updates a subnet with the options specified + +Options are as follows: + +```js +{ + id : '', // required + name: 'subnetName', // optional + network_id : '', // required, The ID of the attached network. + shared : true, // optional, Admin only + tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only + gateway_ip : 'gateway ip address', // optional,The gateway IP address. + enable_dhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. +} +``` +Returns the subnet in the callback `f(err, subnet)` + +#### client.destroySubnet(subnet, callback) +Destroys the specified subnet + +Takes subnet or subnetId as an argument and returns the id of the destroyed subnet in the callback `f(err, subnetId)` From 7b86079b5adff28b1929dcdb7bb70a4a665e2892 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Thu, 8 May 2014 22:18:09 -0700 Subject: [PATCH 080/460] subnet is not a top level service. --- lib/pkgcloud.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index deb1a1cd8..b1046a21c 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -40,8 +40,7 @@ var services = [ 'dns', 'loadbalancer', 'storage', - 'network', - 'subnet' + 'network' ]; // From 074b0f7f500147b3e38ba167bc4b820fae772c74 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 9 May 2014 09:04:53 -0700 Subject: [PATCH 081/460] Adding support for Ports in the pkgcloud network provider. --- lib/pkgcloud/core/network/port.js | 31 ++ lib/pkgcloud/core/network/subnet.js | 2 +- .../openstack/network/client/index.js | 4 +- .../openstack/network/client/ports.js | 150 ++++++++ lib/pkgcloud/openstack/network/index.js | 1 + lib/pkgcloud/openstack/network/port.js | 39 +++ test/common/network/port-test.js | 322 ++++++++++++++++++ test/fixtures/openstack/port.json | 30 ++ test/fixtures/openstack/ports.json | 60 ++++ 9 files changed, 637 insertions(+), 2 deletions(-) create mode 100644 lib/pkgcloud/core/network/port.js create mode 100644 lib/pkgcloud/openstack/network/client/ports.js create mode 100644 lib/pkgcloud/openstack/network/port.js create mode 100644 test/common/network/port-test.js create mode 100644 test/fixtures/openstack/port.json create mode 100644 test/fixtures/openstack/ports.json diff --git a/lib/pkgcloud/core/network/port.js b/lib/pkgcloud/core/network/port.js new file mode 100644 index 000000000..8560098d0 --- /dev/null +++ b/lib/pkgcloud/core/network/port.js @@ -0,0 +1,31 @@ +/* + * port.js: Base network from which all pkgcloud ports inherit. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + model = require('../base/model'); + +var Port = exports.Port = function (client, details) { + model.Model.call(this, client, details); +}; + +utile.inherits(Port, model.Model); + +Port.prototype.create = function (callback) { + this.client.createPort(this.name, callback); +}; + +Port.prototype.refresh = function (callback) { + this.client.getPort(this.id, callback); +}; + +Port.prototype.update = function (callback) { + this.client.updatePort(this, callback); +}; + +Port.prototype.destroy = function (callback) { + this.client.destroyPort(this.id, callback); +}; diff --git a/lib/pkgcloud/core/network/subnet.js b/lib/pkgcloud/core/network/subnet.js index dbd065dd9..ccee30a21 100644 --- a/lib/pkgcloud/core/network/subnet.js +++ b/lib/pkgcloud/core/network/subnet.js @@ -1,5 +1,5 @@ /* - * network.js: Base subnet from which all pkgcloud subnet inherit. + * subnet.js: Base subnet from which all pkgcloud subnet inherit. * * (C) 2014 Hewlett-Packard Development Company, L.P. * diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index c56fed2ea..3966831ec 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -16,11 +16,13 @@ var Client = exports.Client = function (options) { this.models = { Network: require('../network').Network, - Subnet: require('../subnet').Subnet + Subnet: require('../subnet').Subnet, + Port: require('../port').Port }; utile.mixin(this, require('./networks')); utile.mixin(this, require('./subnets')); + utile.mixin(this, require('./ports')); this.serviceType = 'network'; }; diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js new file mode 100644 index 000000000..56914c2e7 --- /dev/null +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -0,0 +1,150 @@ +/* + * ports.js: Instance methods for working with ports + * for Openstack porting + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var async = require('async'), + request = require('request'), + pkgcloud = require('../../../../pkgcloud'), + urlJoin = require('url-join'), + _ = require('underscore'); + +/** + * client.getPorts + * + * @description get the list of ports for an account + * + * @param {object|Function} options + * @param {Function} callback + */ +exports.getPorts = function (options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var getPortOpts = { + path: '/v2.0/ports' + }; + + this._request(getPortOpts, function (err, body) { + if (err) { + return callback(err); + } + else if (!body || !body.ports || !(body.ports instanceof Array)) { + return new Error('Malformed API Response'); + } + + return callback(null, body.ports.map(function (port) { + return new self.models.Port(self, port); + })); + }); +}; + +/** + * client.getPort + * + * @description get the details for a specific port + * + * @param {String|object} port the port or portId + * @param callback + */ +exports.getPort = function (port, callback) { + var portId = port instanceof this.models.Port ? port.id : port, + self = this; + self.emit('log::trace', 'Getting details for port', portId); + this._request({ + path: urlJoin('/v2.0/ports', portId), + method: 'GET' + }, function (err, body, res) { + if (err) { + return callback(err); + } + + if (!body ||!body.port) { + return new Error('Malformed API Response'); + } + + callback(null, new self.models.Port(self, body.port)); + }); +}; + +/** + * client.createPort + * + * @description create a new port + * + * @param {object} options + * @param {String} options.name the name of the new port + * @param callback + */ +exports.createPort = function (options, callback) { + var port = typeof options === 'object' ? options : { 'name' : options}, + self = this; + + var createPortOpts = { + method: 'POST', + path: '/v2.0/ports', + body: { 'port' : port} + }; + + self.emit('log::trace', 'Creating port', port); + this._request(createPortOpts, function (err,body) { + return err + ? callback(err) + : callback(null, new self.models.Port(self, body.port)); + }); +}; + +/** + * client.updatePort + * + * @description update an existing port + * + * @param {object} options + * @param callback + */ +exports.updatePort = function (port, callback) { + var self = this, portToUpdate = port instanceof this.models.Port ? port.toJSON() : port; + var createPortOpts = { + method: 'PUT', + path: urlJoin('/v2.0/ports', portToUpdate.id), + contentType: 'application/json', + body: { 'port' : portToUpdate} + }; + + self.emit('log::trace', 'Creating port', port); + this._request(createPortOpts, function (err,body) { + return err + ? callback(err) + : callback(null, new self.models.Port(self, body.port)); + }); +}; + +/** + * client.destroyPort + * + * @description Delete a specific port + * + * @param {String|object} port the port or port ID + * @param callback + */ +exports.destroyPort = function (port, callback) { + var portId = port instanceof this.models.Port ? port.id : port, + self = this; + self.emit('log::trace', 'Deleting port', portId); + this._request({ + path: urlJoin('/v2.0/ports',portId), + method: 'DELETE' + }, function (err, body, res) { + if (err) { + return callback(err); + } + callback(null, portId); + }); +}; diff --git a/lib/pkgcloud/openstack/network/index.js b/lib/pkgcloud/openstack/network/index.js index b9d069670..a4ab73aee 100644 --- a/lib/pkgcloud/openstack/network/index.js +++ b/lib/pkgcloud/openstack/network/index.js @@ -8,6 +8,7 @@ exports.Client = require('./client').Client; exports.Network = require('./network').Network; exports.Subnet = require('./subnet').Subnet; +exports.Port = require('./port').Port; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/openstack/network/port.js b/lib/pkgcloud/openstack/network/port.js new file mode 100644 index 000000000..2a334a6cf --- /dev/null +++ b/lib/pkgcloud/openstack/network/port.js @@ -0,0 +1,39 @@ +/* + * network.js: Openstack Port object. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + base = require('../../core/network/port'), + _ = require('underscore'); + +var Port = exports.Port = function Port(client, details) { + base.Port.call(this, client, details); +}; + +utile.inherits(Port, base.Port); + +Port.prototype._setProperties = function (details) { + + this.status = details.status || this.status; + this.name = details.name || this.name; + this.allowed_address_pairs = details.allowed_address_pairs || this.allowed_address_pairs; + this.admin_state_up = details.admin_state_up || this.admin_state_up; + this.network_id = details.network_id || this.network_id; + this.tenant_id = details.tenant_id || this.tenant_id; + this.extra_dhcp_opts = details.extra_dhcp_opts || this.extra_dhcp_opts; + this.device_owner = details.device_owner || this.device_owner; + this.mac_address = details.mac_address || this.mac_address; + this.fixed_ips = details.fixed_ips || this.fixed_ips; + this.id = details.id || this.id; + this.security_groups = details.security_groups || this.security_groups; + this.device_id = details.device_id || this.device_id; +}; + +Port.prototype.toJSON = function () { + return _.pick(this, ['status', 'name', 'allowed_address_pairs', 'admin_state_up', + 'network_id', 'tenant_id', 'extra_dhcp_opts', 'device_owner', + 'mac_address', 'fixed_ips', 'id', 'security_groups', 'device_id']); +}; diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js new file mode 100644 index 000000000..217ab2fdf --- /dev/null +++ b/test/common/network/port-test.js @@ -0,0 +1,322 @@ +/* +* port-test.js: Test that should be common to all providers. +* +* (C) 2014 Hewlett-Packard Development Company, L.P. +* +*/ + +var fs = require('fs'), + path = require('path'), + qs = require('qs'), + should = require('should'), + utile = require('utile'), + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + async = require('async'), + _ = require('underscore'), + providers = require('../../configs/providers.json'), + Port = require('../../../lib/pkgcloud/core/network/port').Port, + mock = !!process.env.MOCK, + urlJoin = require('url-join'); + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/ports [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + hock.createHock({ + port: 12345, + throwOnUnmatched: false + }, function (err, hockClient) { + server = hockClient; + next(); + }); + }, + function (next) { + hock.createHock(12346, function (err, hockClient) { + authServer = hockClient; + next(); + }); + } + ], done); + }); + + it('the getPorts() function should return a list of ports', function(done) { + + if (mock) { + setupPortsMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.getPorts(function (err, ports) { + should.not.exist(err); + should.exist(ports); + + context.ports = ports; + + authServer && authServer.done(); + server && server.done(); + + done(); + }); + }); + + it('the getPort() method should get a port instance', function (done) { + if (mock) { + setupGetPortMock(client, provider, { + authServer: authServer, + server: server + }, context.ports[0]); + } + + client.getPort(context.ports[0].id, function (err, port) { + should.not.exist(err); + should.exist(port); + port.should.be.an.instanceOf(Port); + port.should.have.property('id', context.ports[0].id); + context.currentPort = port; + + authServer && authServer.done(); + server && server.done(); + done(); + + }); + }); + + it('the createPort() method should create a port', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupCreatePortMock(client, provider, { + authServer: authServer, + server: server + }); + } + + client.createPort({ + name: 'create-test-ids2' + }, function (err, port) { + should.not.exist(err); + should.exist(port); + port.should.be.an.instanceOf(Port); + + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + + it('the destroyPort() method should delete a port', function (done) { + if (mock) { + setupDestroyPortMock(client, provider, { + authServer: authServer, + server: server + }, context.currentPort); + } + + client.destroyPort(context.currentPort, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updatePort() method should update a port', function (done) { + + var portToUpdate = { id : context.currentPort.id, enable_dhcp : false}; + if (mock) { + setupUpdatePortMock(client, provider, { + authServer: authServer, + server: server + }, portToUpdate); + } + + client.updatePort(portToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the port.create() method should create a port', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupPortModelCreateMock(client, provider, { + authServer: authServer, + server: server + }); + } + + var port = new Port(client); + port.name= "model created network"; + port.create(function (err, createdPort) { + should.not.exist(err); + should.exist(createdPort); + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + + it('the port.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var port = new Port(client); + port.id = context.ports[0].id; + + if (mock) { + setupRefreshPortMock(client, provider, { + authServer: authServer, + server: server + }, port); + } + + port.refresh(function (err, refreshedPort) { + should.not.exist(err); + should.exist(refreshedPort); + refreshedPort.should.have.property('name', 'my_port'); + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + + it('the port.destroy() method should delete a port', function (done) { + var port = new Port(client); + port.name = "model deleted port"; + port.id = "THISISANETWORKID"; + + if (mock) { + setupModelDestroyedPortMock(client, provider, { + authServer: authServer, + server: server + }, port); + } + + port.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + + }); +}); + +function setupDestroyPortMock(client, provider, servers, currentPort){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } +} + +function setupUpdatePortMock(client, provider, servers, currentPort){ + if (provider === 'openstack') { + servers.server + .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id), + { port: { id: currentPort.id, enable_dhcp: false }}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } +} + +function setupModelDestroyedPortMock(client, provider, servers, currentPort){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } +} + +function setupPortsMock(client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/ports.json'); + } +} + +function setupCreatePortMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', + {port: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); + } +} + +function setupRefreshPortMock(client, provider, servers, port) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', port.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } +} + +function setupPortModelCreateMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', + {port: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); + } +} + +function setupGetPortMock(client, provider, servers, currentPort) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } +} diff --git a/test/fixtures/openstack/port.json b/test/fixtures/openstack/port.json new file mode 100644 index 000000000..5260c87ad --- /dev/null +++ b/test/fixtures/openstack/port.json @@ -0,0 +1,30 @@ +{ + "port": { + "status": "ACTIVE", + "binding:host_id": "devstack", + "name": "my_port", + "allowed_address_pairs": [], + "admin_state_up": true, + "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3", + "tenant_id": "", + "extra_dhcp_opts": [], + "binding:vif_details": { + "port_filter": true, + "ovs_hybrid_plug": true + }, + "binding:vif_type": "ovs", + "device_owner": "network:router_gateway", + "mac_address": "fa:16:3e:58:42:ed", + "binding:profile": {}, + "binding:vnic_type": "normal", + "fixed_ips": [ + { + "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", + "ip_address": "172.24.4.2" + } + ], + "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b", + "security_groups": [], + "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824" + } +} diff --git a/test/fixtures/openstack/ports.json b/test/fixtures/openstack/ports.json new file mode 100644 index 000000000..779e056bf --- /dev/null +++ b/test/fixtures/openstack/ports.json @@ -0,0 +1,60 @@ +{ + "ports": [ + { + "status": "ACTIVE", + "binding:host_id": "devstack", + "name": "", + "allowed_address_pairs": [], + "admin_state_up": true, + "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3", + "tenant_id": "", + "extra_dhcp_opts": [], + "binding:vif_details": { + "port_filter": true, + "ovs_hybrid_plug": true + }, + "binding:vif_type": "ovs", + "device_owner": "network:router_gateway", + "mac_address": "fa:16:3e:58:42:ed", + "binding:profile": {}, + "binding:vnic_type": "normal", + "fixed_ips": [ + { + "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", + "ip_address": "172.24.4.2" + } + ], + "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b", + "security_groups": [], + "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824" + }, + { + "status": "ACTIVE", + "binding:host_id": "devstack", + "name": "", + "allowed_address_pairs": [], + "admin_state_up": true, + "network_id": "f27aa545-cbdd-4907-b0c6-c9e8b039dcc2", + "tenant_id": "d397de8a63f341818f198abb0966f6f3", + "extra_dhcp_opts": [], + "binding:vif_details": { + "port_filter": true, + "ovs_hybrid_plug": true + }, + "binding:vif_type": "ovs", + "device_owner": "network:router_interface", + "mac_address": "fa:16:3e:bb:3c:e4", + "binding:profile": {}, + "binding:vnic_type": "normal", + "fixed_ips": [ + { + "subnet_id": "288bf4a1-51ba-43b6-9d0a-520e9005db17", + "ip_address": "10.0.0.1" + } + ], + "id": "f71a6703-d6de-4be1-a91a-a570ede1d159", + "security_groups": [], + "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824" + } + ] +} From 1a97d496639fea0a80bb43eaeac4d35cc2ac8639 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 9 May 2014 09:13:03 -0700 Subject: [PATCH 082/460] Added support for managing Ports in pkgcloud network provider. --- README.md | 7 ++++ docs/providers/openstack/network.md | 57 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/README.md b/README.md index a421e332e..c0f459c8c 100644 --- a/README.md +++ b/README.md @@ -439,6 +439,13 @@ Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.creat * `client.updateSubnet(subnet, function (err, subnet) { })` * `client.deleteSubnet(subnet, function (err, subnetId) { })` +### Ports +* `client.getPorts(options, function (err, ports) { })` +* `client.getPort(port, function (err, port) { })` +* `client.createPort(options, function (err, port) { })` +* `client.updatePort(port, function (err, port) { })` +* `client.deletePort(port, function (err, portId) { })` + ## Installation ``` bash diff --git a/docs/providers/openstack/network.md b/docs/providers/openstack/network.md index f2ea377b4..ca8932890 100644 --- a/docs/providers/openstack/network.md +++ b/docs/providers/openstack/network.md @@ -113,3 +113,60 @@ Returns the subnet in the callback `f(err, subnet)` Destroys the specified subnet Takes subnet or subnetId as an argument and returns the id of the destroyed subnet in the callback `f(err, subnetId)` + +**Ports** + +#### client.getPorts(callback) +Lists all ports that are available to use on your Openstack account + +Callback returns `f(err, ports)` where `ports` is an `Array` + +#### client.getPort(port, callback) +Gets specified port + +Takes port or portId as an argument and returns the port in the callback +`f(err, port)` + +#### client.createPort(options, callback) +Creates a port with the options specified + +Options are as follows: + +```js +{ + name: 'portName', // optional + admin_state_up : true, // optional, The administrative status of the router. Admin-only + network_id : '', // required, The ID of the attached network. + status : 'text status', // optional, The status of the port. + tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only + mac_address: 'mac address' // optional + fixed_ips : ['ip address1', 'ip address 2'], // optional. + security_groups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. +} +``` +Returns the port in the callback `f(err, port)` + +#### client.updatePort(options, callback) +Updates a port with the options specified + +Options are as follows: + +```js +{ + id : '', // required + name: 'portName', // optional + admin_state_up : true, // optional, The administrative status of the router. Admin-only + network_id : '', // required, The ID of the attached network. + status : 'text status', // optional, The status of the port. + tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only + mac_address: 'mac address' // optional + fixed_ips : ['ip address1', 'ip address 2'], // optional. + security_groups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. +} +``` +Returns the port in the callback `f(err, port)` + +#### client.destroyPort(port, callback) +Destroys the specified port + +Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)` From ed61dcd8d76ea3ee2aabed58049bf4ae3d1b9df6 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 9 May 2014 17:44:13 -0700 Subject: [PATCH 083/460] Used camelCase for multi word property names, updated tests. --- lib/.jshintrc | 9 + lib/log.txt | 3245 +++++++++++++++++ .../openstack/network/client/networks.js | 31 +- .../openstack/network/client/ports.js | 42 +- .../openstack/network/client/subnets.js | 33 +- lib/pkgcloud/openstack/network/network.js | 8 +- lib/pkgcloud/openstack/network/port.js | 26 +- lib/pkgcloud/openstack/network/subnet.js | 18 +- test/common/network/network-test.js | 10 +- test/common/network/port-test.js | 9 +- test/common/network/subnet-test.js | 11 +- 11 files changed, 3394 insertions(+), 48 deletions(-) create mode 100644 lib/.jshintrc create mode 100644 lib/log.txt diff --git a/lib/.jshintrc b/lib/.jshintrc new file mode 100644 index 000000000..913aba821 --- /dev/null +++ b/lib/.jshintrc @@ -0,0 +1,9 @@ +{ + "camelcase": true, + "expr": false, + "laxbreak": false, + "immed": false, + "node": true, + "indent": true, + "strict": false +} diff --git a/lib/log.txt b/lib/log.txt new file mode 100644 index 000000000..a2ec02b3a --- /dev/null +++ b/lib/log.txt @@ -0,0 +1,3245 @@ +pkgcloud.js, line 51, character 7: Expected 'hidden' at column 5, not column 7. +hidden = '_' + name; +pkgcloud/amazon/client.js, line 9, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/amazon/client.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../core/base'); +pkgcloud/amazon/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/flavor'); +pkgcloud/amazon/compute/flavor.js, line 36, character 28: Expected '{' and instead saw 'throw'. +if (!Flavor.options[id]) throw new TypeError('No such AWS Flavor: ' + id); +pkgcloud/amazon/compute/flavor.js, line 36, character 28: Expected 'throw' at column 3, not column 28. +if (!Flavor.options[id]) throw new TypeError('No such AWS Flavor: ' + id); +pkgcloud/amazon/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/image'); +pkgcloud/amazon/compute/server.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/server'); +pkgcloud/amazon/compute/server.js, line 23, character 7: Expected 'case' at column 5, not column 7. +case 'PENDING': +pkgcloud/amazon/compute/server.js, line 24, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.provisioning; +pkgcloud/amazon/compute/server.js, line 25, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/amazon/compute/server.js, line 26, character 7: Expected 'case' at column 5, not column 7. +case 'RUNNING': +pkgcloud/amazon/compute/server.js, line 27, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.running; +pkgcloud/amazon/compute/server.js, line 28, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/amazon/compute/server.js, line 29, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPING': +pkgcloud/amazon/compute/server.js, line 30, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPED': +pkgcloud/amazon/compute/server.js, line 31, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.stopped; +pkgcloud/amazon/compute/server.js, line 32, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/amazon/compute/server.js, line 33, character 7: Expected 'case' at column 5, not column 7. +case 'TERMINATED': +pkgcloud/amazon/compute/server.js, line 34, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.terminated; +pkgcloud/amazon/compute/server.js, line 35, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/amazon/compute/server.js, line 36, character 7: Expected 'default' at column 5, not column 7. +default: +pkgcloud/amazon/compute/server.js, line 37, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.unknown; +pkgcloud/amazon/compute/server.js, line 38, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/amazon/compute/server.js, line 42, character 21: Expected an identifier and instead saw 'private' (a reserved word). +var addresses = { private: [], public: [] }; +pkgcloud/amazon/compute/server.js, line 42, character 34: Expected an identifier and instead saw 'public' (a reserved word). +var addresses = { private: [], public: [] }; +pkgcloud/amazon/compute/server.js, line 46, character 17: Expected an identifier and instead saw 'public' (a reserved word). +addresses.public.push(details[prop]); +pkgcloud/amazon/compute/server.js, line 52, character 17: Expected an identifier and instead saw 'private' (a reserved word). +addresses.private.push(details[prop]); +pkgcloud/amazon/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/amazon/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.amazon.compute; +pkgcloud/amazon/compute/client/groups.js, line 7, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'); +pkgcloud/amazon/compute/client/groups.js, line 107, character 113: Line too long. +// - http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html +pkgcloud/amazon/compute/client/groups.js, line 125, character 11: Unexpected space between 'rules' and ','. +rules , +pkgcloud/amazon/compute/client/groups.js, line 142, character 113: Line too long. +// - http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html +pkgcloud/amazon/compute/client/groups.js, line 160, character 11: Unexpected space between 'rules' and ','. +rules , +pkgcloud/amazon/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/amazon/compute/client/images.js, line 9, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/amazon/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.amazon.compute; +pkgcloud/amazon/compute/client/images.js, line 26, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/amazon/compute/client/images.js, line 32, character 10: Move 'var' declarations to the top of the function. +for (var i = 0; i < options.owners.length; i++) { +pkgcloud/amazon/compute/client/images.js, line 32, character 10: Stopping. (24% scanned). + +pkgcloud/amazon/compute/client/index.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/amazon/compute/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/amazon/compute/client/index.js, line 11, character 5: Expected 'xml2js' at column 3, not column 5. +xml2js = require('xml2js'), +pkgcloud/amazon/compute/client/index.js, line 12, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth'), +pkgcloud/amazon/compute/client/index.js, line 13, character 5: Expected 'amazon' at column 3, not column 5. +amazon = require('../../client'); +pkgcloud/amazon/compute/client/index.js, line 31, character 50: 'query' is already defined. +Client.prototype._query = function query(action, query, callback) { +pkgcloud/amazon/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'); +pkgcloud/amazon/compute/client/servers.js, line 8, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/amazon/compute/client/servers.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/amazon/compute/client/servers.js, line 10, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/amazon/compute/client/servers.js, line 11, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/amazon/compute/client/servers.js, line 12, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.amazon.compute; +pkgcloud/amazon/compute/client/servers.js, line 22, character 28: Expected exactly one space between 'function' and '('. +process.nextTick(function() { +pkgcloud/amazon/compute/client/servers.js, line 51, character 34: Expected '{' at column 5, not column 34. +'DescribeInstanceAttribute', { +pkgcloud/amazon/compute/client/servers.js, line 74, character 6: Expected ')' at column 3, not column 6. +}); +pkgcloud/amazon/compute/client/servers.js, line 110, character 15: Expected 'return' at column 13, not column 15. +return new compute.Server(self, server); +pkgcloud/amazon/compute/client/servers.js, line 111, character 13: Expected '}' at column 11, not column 13. +}), res); +pkgcloud/amazon/compute/client/servers.js, line 137, character 7: Expected 'meta' at column 5, not column 7. +meta = { name: options.name || '' }, +pkgcloud/amazon/compute/client/servers.js, line 138, character 7: Expected 'createOptions' at column 5, not column 7. +createOptions = { +pkgcloud/amazon/compute/client/servers.js, line 139, character 9: Expected 'UserData' at column 7, not column 9. +UserData: new Buffer(JSON.stringify(meta)).toString('base64'), +pkgcloud/amazon/compute/client/servers.js, line 140, character 9: Expected 'MinCount' at column 7, not column 9. +MinCount: 1, +pkgcloud/amazon/compute/client/servers.js, line 141, character 9: Expected 'MaxCount' at column 7, not column 9. +MaxCount: 1 +pkgcloud/amazon/compute/client/servers.js, line 142, character 7: Expected '}' at column 5, not column 7. +}, +pkgcloud/amazon/compute/client/servers.js, line 143, character 7: Expected 'securityGroup' at column 5, not column 7. +securityGroup, +pkgcloud/amazon/compute/client/servers.js, line 144, character 7: Expected 'securityGroupId' at column 5, not column 7. +securityGroupId; +pkgcloud/amazon/compute/client/servers.js, line 155, character 49: ['SecurityGroup'] is better written in dot notation. +securityGroup = this.securityGroup || options['SecurityGroup']; +pkgcloud/amazon/compute/client/servers.js, line 157, character 19: ['SecurityGroup'] is better written in dot notation. +createOptions['SecurityGroup'] = securityGroup; +pkgcloud/amazon/compute/client/servers.js, line 160, character 53: ['SecurityGroupId'] is better written in dot notation. +securityGroupId = this.securityGroupId || options['SecurityGroupId']; +pkgcloud/amazon/compute/client/servers.js, line 162, character 19: ['SecurityGroupId'] is better written in dot notation. +createOptions['SecurityGroupId'] = securityGroupId; +pkgcloud/amazon/compute/client/servers.js, line 233, character 7: Expected 'serverId' at column 5, not column 7. +serverId = server instanceof base.Server ? server.id : server; +pkgcloud/amazon/compute/client/servers.js, line 264, character 18: Expected '{' and instead saw 'return'. +if (err) return callback(err); +pkgcloud/amazon/compute/client/servers.js, line 264, character 18: Expected 'return' at column 9, not column 18. +if (err) return callback(err); +pkgcloud/amazon/storage/container.js, line 9, character 5: Expected 'storage' at column 3, not column 5. +storage = require('../storage'), +pkgcloud/amazon/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/storage/container'); +pkgcloud/amazon/storage/file.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/storage/file'); +pkgcloud/amazon/storage/utils.js, line 2, character 5: Expected 'Stream' at column 3, not column 5. +Stream = require('stream').Stream; +pkgcloud/amazon/storage/utils.js, line 31, character 9: Expected 'parts' at column 7, not column 9. +parts = []; +pkgcloud/amazon/storage/utils.js, line 34, character 32: Expected '{' and instead saw 'return'. +if (total >= this.chunk) return true; +pkgcloud/amazon/storage/utils.js, line 34, character 32: Expected 'return' at column 7, not column 32. +if (total >= this.chunk) return true; +pkgcloud/amazon/storage/utils.js, line 39, character 6: Don't make functions within a loop. +}, this); +pkgcloud/amazon/storage/utils.js, line 43, character 11: Combine this with the previous 'var' statement. +var last = parts[parts.length - 1], +pkgcloud/amazon/storage/utils.js, line 44, character 11: Expected 'splitPos' at column 9, not column 11. +splitPos = last.length - total + this.chunk, +pkgcloud/amazon/storage/utils.js, line 45, character 11: Expected 'head' at column 9, not column 11. +head = last.slice(0, splitPos), +pkgcloud/amazon/storage/utils.js, line 46, character 11: Expected 'tail' at column 9, not column 11. +tail = last.slice(splitPos); +pkgcloud/amazon/storage/utils.js, line 58, character 20: Expected '{' and instead saw 'return'. +if (this.paused) return false; +pkgcloud/amazon/storage/utils.js, line 58, character 20: Expected 'return' at column 3, not column 20. +if (this.paused) return false; +pkgcloud/amazon/storage/utils.js, line 62, character 19: Expected '{' and instead saw 'return'. +if (this.ended) return; +pkgcloud/amazon/storage/utils.js, line 62, character 19: Expected 'return' at column 3, not column 19. +if (this.ended) return; +pkgcloud/amazon/storage/utils.js, line 84, character 20: Expected '{' and instead saw 'return'. +if (this.paused) return; +pkgcloud/amazon/storage/utils.js, line 84, character 20: Expected 'return' at column 3, not column 20. +if (this.paused) return; +pkgcloud/amazon/storage/utils.js, line 89, character 21: Expected '{' and instead saw 'return'. +if (!this.paused) return; +pkgcloud/amazon/storage/utils.js, line 89, character 21: Expected 'return' at column 3, not column 21. +if (!this.paused) return; +pkgcloud/amazon/storage/client/containers.js, line 101, character 11: Expected 'method' at column 9, not column 11. +method: 'DELETE', +pkgcloud/amazon/storage/client/containers.js, line 102, character 11: Expected 'container' at column 9, not column 11. +container: containerName +pkgcloud/amazon/storage/client/containers.js, line 103, character 9: Expected '}' at column 7, not column 9. +}, function (err, body, res) { +pkgcloud/amazon/storage/client/containers.js, line 104, character 11: Expected 'return' at column 9, not column 11. +return err +pkgcloud/amazon/storage/client/containers.js, line 106, character 45: Expected '===' and instead saw '=='. +: callback(null, res.statusCode == 204); +pkgcloud/amazon/storage/client/containers.js, line 107, character 9: Expected '}' at column 7, not column 9. +} +pkgcloud/amazon/storage/client/containers.js, line 108, character 7: Expected ')' at column 9, not column 7. +); +pkgcloud/amazon/storage/client/files.js, line 9, character 5: Expected 'filed' at column 3, not column 5. +filed = require('filed'), +pkgcloud/amazon/storage/client/files.js, line 10, character 5: Expected 'mime' at column 3, not column 5. +mime = require('mime'), +pkgcloud/amazon/storage/client/files.js, line 11, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/amazon/storage/client/files.js, line 12, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/amazon/storage/client/files.js, line 13, character 5: Expected 'qs' at column 3, not column 5. +qs = require('querystring'), +pkgcloud/amazon/storage/client/files.js, line 14, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/storage'), +pkgcloud/amazon/storage/client/files.js, line 15, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/amazon/storage/client/files.js, line 16, character 5: Expected 'storage' at column 3, not column 5. +storage = pkgcloud.providers.amazon.storage; +pkgcloud/amazon/storage/client/files.js, line 18, character 1: Expected an identifier and instead saw 'const'. +const MAX_UPLOAD = 5 * 1024 * 1024 * 1024; +pkgcloud/amazon/storage/client/files.js, line 18, character 1: Stopping. (4% scanned). + +pkgcloud/amazon/storage/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/amazon/storage/client/index.js, line 10, character 5: Expected 'xml2js' at column 3, not column 5. +xml2js = require('xml2js'), +pkgcloud/amazon/storage/client/index.js, line 11, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth'), +pkgcloud/amazon/storage/client/index.js, line 12, character 5: Expected 'amazon' at column 3, not column 5. +amazon = require('../../client'); +pkgcloud/azure/client.js, line 9, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/azure/client.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../core/base'); +pkgcloud/azure/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/flavor'); +pkgcloud/azure/compute/flavor.js, line 28, character 28: Expected '{' and instead saw 'throw'. +if (!Flavor.options[id]) throw new TypeError('No such Azure Flavor: ' + id); +pkgcloud/azure/compute/flavor.js, line 28, character 28: Expected 'throw' at column 3, not column 28. +if (!Flavor.options[id]) throw new TypeError('No such Azure Flavor: ' + id); +pkgcloud/azure/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/image'); +pkgcloud/azure/compute/server.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/server'); +pkgcloud/azure/compute/server.js, line 29, character 126: Line too long. +//console.log("Status: " + details.Status + ' RoleInstanceList: ' + roleInstance ? roleInstance.InstanceStatus : 'UNKNOWN'); +pkgcloud/azure/compute/server.js, line 31, character 110: Line too long. +// azure can return an inconsistent RoleInstance status (not in azure rest api docs) so we check everything. +pkgcloud/azure/compute/server.js, line 32, character 114: Line too long. +// an azure vm has a complicated state machine. We need to check the status of both the deployment and the role. +pkgcloud/azure/compute/server.js, line 33, character 122: Line too long. +// azure first starts a deployment and then starts a role. The role seems to go through STOPPEDVM, PROVISIONING and then +pkgcloud/azure/compute/server.js, line 35, character 123: Line too long. +// Note: since azureAPI has to wait until azure responds to our createServer request, we most likely will miss all of the +pkgcloud/azure/compute/server.js, line 41, character 7: Expected 'case' at column 5, not column 7. +case 'PROVISIONING': +pkgcloud/azure/compute/server.js, line 42, character 7: Expected 'case' at column 5, not column 7. +case 'CREATINGVM': +pkgcloud/azure/compute/server.js, line 43, character 7: Expected 'case' at column 5, not column 7. +case 'STARTINGVM': +pkgcloud/azure/compute/server.js, line 44, character 7: Expected 'case' at column 5, not column 7. +case 'CREATINGROLE': +pkgcloud/azure/compute/server.js, line 45, character 7: Expected 'case' at column 5, not column 7. +case 'STARTINGROLE': +pkgcloud/azure/compute/server.js, line 46, character 7: Expected 'case' at column 5, not column 7. +case 'RESTARTINGROLE': +pkgcloud/azure/compute/server.js, line 47, character 7: Expected 'case' at column 5, not column 7. +case 'BUSYROLE': +pkgcloud/azure/compute/server.js, line 48, character 7: Expected 'case' at column 5, not column 7. +case 'INITIALIZING': +pkgcloud/azure/compute/server.js, line 49, character 7: Expected 'case' at column 5, not column 7. +case 'BUSY': +pkgcloud/azure/compute/server.js, line 50, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.provisioning; +pkgcloud/azure/compute/server.js, line 51, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/azure/compute/server.js, line 52, character 7: Expected 'case' at column 5, not column 7. +case 'READYROLE': +pkgcloud/azure/compute/server.js, line 53, character 7: Expected 'case' at column 5, not column 7. +case 'READY': +pkgcloud/azure/compute/server.js, line 54, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.running; +pkgcloud/azure/compute/server.js, line 55, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/azure/compute/server.js, line 56, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPING': +pkgcloud/azure/compute/server.js, line 57, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPED': +pkgcloud/azure/compute/server.js, line 58, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPINGROLE': +pkgcloud/azure/compute/server.js, line 59, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPINGVM': +pkgcloud/azure/compute/server.js, line 60, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPEDVM': +pkgcloud/azure/compute/server.js, line 61, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.stopped; +pkgcloud/azure/compute/server.js, line 62, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/azure/compute/server.js, line 63, character 7: Expected 'case' at column 5, not column 7. +case 'DELETINGVM': +pkgcloud/azure/compute/server.js, line 64, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.terminated; +pkgcloud/azure/compute/server.js, line 65, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/azure/compute/server.js, line 66, character 7: Expected 'case' at column 5, not column 7. +case 'ROLESTATEUNKNOWN': +pkgcloud/azure/compute/server.js, line 67, character 7: Expected 'case' at column 5, not column 7. +case 'UNKNOWN': +pkgcloud/azure/compute/server.js, line 68, character 7: Empty case. +default: +pkgcloud/azure/compute/server.js, line 68, character 7: Expected 'default' at column 5, not column 7. +default: +pkgcloud/azure/compute/server.js, line 69, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.unknown; +pkgcloud/azure/compute/server.js, line 70, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/azure/compute/server.js, line 75, character 7: Expected 'case' at column 5, not column 7. +case 'STARTING': +pkgcloud/azure/compute/server.js, line 76, character 7: Expected 'case' at column 5, not column 7. +case 'DEPLOYING': +pkgcloud/azure/compute/server.js, line 77, character 7: Expected 'case' at column 5, not column 7. +case 'PROVISIONING': +pkgcloud/azure/compute/server.js, line 78, character 7: Expected 'case' at column 5, not column 7. +case 'RUNNINGTRANSITIONING': +pkgcloud/azure/compute/server.js, line 79, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.provisioning; +pkgcloud/azure/compute/server.js, line 80, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/azure/compute/server.js, line 81, character 7: Expected 'case' at column 5, not column 7. +case 'RUNNING': +pkgcloud/azure/compute/server.js, line 82, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.running; +pkgcloud/azure/compute/server.js, line 83, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/azure/compute/server.js, line 84, character 7: Expected 'case' at column 5, not column 7. +case 'SUSPENDING': +pkgcloud/azure/compute/server.js, line 85, character 7: Expected 'case' at column 5, not column 7. +case 'SUSPENDED': +pkgcloud/azure/compute/server.js, line 86, character 7: Expected 'case' at column 5, not column 7. +case 'SUSPENDEDTRANSITIONING': +pkgcloud/azure/compute/server.js, line 87, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.stopped; +pkgcloud/azure/compute/server.js, line 87, character 9: Too many errors. (70% scanned). + +pkgcloud/azure/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/azure/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.azure.compute; +pkgcloud/azure/compute/client/images.js, line 33, character 11: Expected 'return' at column 9, not column 11. +return new compute.Image(self, image); +pkgcloud/azure/compute/client/images.js, line 34, character 9: Expected '}' at column 7, not column 9. +}), res); +pkgcloud/azure/compute/client/images.js, line 79, character 23: Expected a conditional expression and instead saw an assignment. +options || (options = {}); +pkgcloud/azure/compute/client/images.js, line 79, character 27: Expected an assignment or function call and instead saw an expression. +options || (options = {}); +pkgcloud/azure/compute/client/images.js, line 81, character 22: Expected '{' and instead saw 'throw'. +if (!options.name) throw new TypeError('`name` is a required option'); +pkgcloud/azure/compute/client/images.js, line 81, character 22: Expected 'throw' at column 3, not column 22. +if (!options.name) throw new TypeError('`name` is a required option'); +pkgcloud/azure/compute/client/images.js, line 82, character 24: Expected '{' and instead saw 'throw'. +if (!options.server) throw new TypeError('`server` is a required option'); +pkgcloud/azure/compute/client/images.js, line 82, character 24: Expected 'throw' at column 3, not column 24. +if (!options.server) throw new TypeError('`server` is a required option'); +pkgcloud/azure/compute/client/images.js, line 106, character 7: Expected 'imageId' at column 5, not column 7. +imageId = image instanceof base.Image ? image.id : image, +pkgcloud/azure/compute/client/images.js, line 107, character 7: Expected 'path' at column 5, not column 7. +path = self.config.subscriptionId + '/services/images/' + imageId; +pkgcloud/azure/compute/client/index.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/azure/compute/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/azure/compute/client/index.js, line 11, character 5: Expected 'https' at column 3, not column 5. +https = require('https'), +pkgcloud/azure/compute/client/index.js, line 12, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth'), +pkgcloud/azure/compute/client/index.js, line 13, character 5: Expected 'azureApi' at column 3, not column 5. +azureApi = require('../../utils/azureApi.js'), +pkgcloud/azure/compute/client/index.js, line 14, character 5: Expected 'xml2JSON' at column 3, not column 5. +xml2JSON = require('../../utils/xml2json.js').xml2JSON, +pkgcloud/azure/compute/client/index.js, line 15, character 5: Expected 'azure' at column 3, not column 5. +azure = require('../../client'); +pkgcloud/azure/compute/client/index.js, line 52, character 50: 'query' is already defined. +Client.prototype._query = function query(action, query, callback) { +pkgcloud/azure/compute/client/index.js, line 88, character 9: Expected 'callback' at column 11, not column 9. +callback(err) : +pkgcloud/azure/compute/client/index.js, line 89, character 9: Expected 'callback' at column 11, not column 9. +callback(null, data, res); +pkgcloud/azure/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'); +pkgcloud/azure/compute/client/servers.js, line 46, character 7: Expected 'servers' at column 5, not column 7. +servers = []; +pkgcloud/azure/compute/client/servers.js, line 68, character 7: Expected 'serverId' at column 5, not column 7. +serverId = server instanceof base.Server ? server.id : server; +pkgcloud/azure/database/client/databases.js, line 34, character 16: ['name'] is better written in dot notation. +if (!options['name']) { +pkgcloud/azure/database/client/databases.js, line 74, character 3: Expected ')' at column 5, not column 3. +); +pkgcloud/azure/database/client/databases.js, line 78, character 104: Line too long. +// ### @callback {Function} Continuation to respond to when complete. Returns array of Database objects. +pkgcloud/azure/database/client/databases.js, line 81, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/azure/database/client/databases.js, line 113, character 10: 'encodeTableUriComponent' was used before it was defined. +path = encodeTableUriComponent("Tables('" + id + "')"); +pkgcloud/azure/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/azure/database/client/index.js, line 10, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth'), +pkgcloud/azure/database/client/index.js, line 11, character 5: Expected 'azureApi' at column 3, not column 5. +azureApi = require('../../utils/azureApi.js'), +pkgcloud/azure/database/client/index.js, line 12, character 5: Expected 'xml2JSON' at column 3, not column 5. +xml2JSON = require('../../utils/xml2json.js').xml2JSON, +pkgcloud/azure/database/client/index.js, line 13, character 5: Expected 'azure' at column 3, not column 5. +azure = require('../../client'); +pkgcloud/azure/storage/container.js, line 9, character 5: Expected 'storage' at column 3, not column 5. +storage = require('../storage'), +pkgcloud/azure/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/storage/container'); +pkgcloud/azure/storage/file.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/storage/file'); +pkgcloud/azure/storage/file.js, line 23, character 110: Line too long. +this.size = (properties && properties['Content-Length']) ? parseInt(properties['Content-Length'], 10) : 0; +pkgcloud/azure/storage/utils.js, line 2, character 5: Expected 'Stream' at column 3, not column 5. +Stream = require('stream').Stream; +pkgcloud/azure/storage/utils.js, line 30, character 9: Expected 'parts' at column 7, not column 9. +parts = []; +pkgcloud/azure/storage/utils.js, line 33, character 32: Expected '{' and instead saw 'return'. +if (total >= this.chunk) return true; +pkgcloud/azure/storage/utils.js, line 33, character 32: Expected 'return' at column 7, not column 32. +if (total >= this.chunk) return true; +pkgcloud/azure/storage/utils.js, line 38, character 6: Don't make functions within a loop. +}, this); +pkgcloud/azure/storage/utils.js, line 42, character 11: Combine this with the previous 'var' statement. +var last = parts[parts.length - 1], +pkgcloud/azure/storage/utils.js, line 43, character 11: Expected 'splitPos' at column 9, not column 11. +splitPos = last.length - total + this.chunk, +pkgcloud/azure/storage/utils.js, line 44, character 11: Expected 'head' at column 9, not column 11. +head = last.slice(0, splitPos), +pkgcloud/azure/storage/utils.js, line 45, character 11: Expected 'tail' at column 9, not column 11. +tail = last.slice(splitPos); +pkgcloud/azure/storage/utils.js, line 57, character 20: Expected '{' and instead saw 'return'. +if (this.paused) return false; +pkgcloud/azure/storage/utils.js, line 57, character 20: Expected 'return' at column 3, not column 20. +if (this.paused) return false; +pkgcloud/azure/storage/utils.js, line 61, character 19: Expected '{' and instead saw 'return'. +if (this.ended) return; +pkgcloud/azure/storage/utils.js, line 61, character 19: Expected 'return' at column 3, not column 19. +if (this.ended) return; +pkgcloud/azure/storage/utils.js, line 83, character 20: Expected '{' and instead saw 'return'. +if (this.paused) return; +pkgcloud/azure/storage/utils.js, line 83, character 20: Expected 'return' at column 3, not column 20. +if (this.paused) return; +pkgcloud/azure/storage/utils.js, line 88, character 21: Expected '{' and instead saw 'return'. +if (!this.paused) return; +pkgcloud/azure/storage/utils.js, line 88, character 21: Expected 'return' at column 3, not column 21. +if (!this.paused) return; +pkgcloud/azure/storage/client/containers.js, line 9, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/azure/storage/client/containers.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/storage'), +pkgcloud/azure/storage/client/containers.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/azure/storage/client/containers.js, line 12, character 5: Expected 'storage' at column 3, not column 5. +storage = pkgcloud.providers.azure.storage; +pkgcloud/azure/storage/client/containers.js, line 49, character 7: Expected 'self' at column 5, not column 7. +self = this, +pkgcloud/azure/storage/client/containers.js, line 50, character 7: Expected 'options' at column 5, not column 7. +options; +pkgcloud/azure/storage/client/containers.js, line 80, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/azure/storage/client/containers.js, line 108, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/azure/storage/client/containers.js, line 119, character 39: Expected '===' and instead saw '=='. +: callback(null, res.statusCode == 202); +pkgcloud/azure/storage/client/containers.js, line 120, character 4: Expected '}' at column 3, not column 4. +}); +pkgcloud/azure/storage/client/files.js, line 37, character 12: Missing space between ':' and 'DELETE'. +method:'DELETE', +pkgcloud/azure/storage/client/files.js, line 42, character 39: Expected '===' and instead saw '=='. +: callback(null, res.statusCode == 202); +pkgcloud/azure/storage/client/files.js, line 63, character 7: Expected 'success' at column 5, not column 7. +success = callback ? onUpload : null, +pkgcloud/azure/storage/client/files.js, line 64, character 7: Expected 'path' at column 5, not column 7. +path, +pkgcloud/azure/storage/client/files.js, line 65, character 7: Expected 'rstream' at column 5, not column 7. +rstream, +pkgcloud/azure/storage/client/files.js, line 66, character 7: Expected 'lstream' at column 5, not column 7. +lstream; +pkgcloud/azure/storage/client/files.js, line 78, character 3: Expected exactly one space between '}' and 'else'. +else if (options.stream) { +pkgcloud/azure/storage/client/files.js, line 78, character 3: Expected 'else' at column 5, not column 3. +else if (options.stream) { +pkgcloud/azure/storage/client/files.js, line 94, character 6: Expected ';' and instead saw '}'. +} +pkgcloud/azure/storage/client/files.js, line 111, character 16: Expected '{' and instead saw 'lstream'. +if (lstream) lstream.pipe(rstream); +pkgcloud/azure/storage/client/files.js, line 111, character 16: Expected 'lstream' at column 3, not column 16. +if (lstream) lstream.pipe(rstream); +pkgcloud/azure/storage/client/files.js, line 117, character 33: Expected 'String' and instead saw ''''. +return "block" + ((1e15 + a + "").slice(-b)); +pkgcloud/azure/storage/client/files.js, line 148, character 9: Combine this with the previous 'var' statement. +var rstream = self.upload(options, next); +pkgcloud/azure/storage/client/files.js, line 162, character 7: Expected 'body' at column 5, not column 7. +body, +pkgcloud/azure/storage/client/files.js, line 163, character 7: Expected 'path' at column 5, not column 7. +path, +pkgcloud/azure/storage/client/files.js, line 164, character 7: Expected 'qs' at column 5, not column 7. +qs; +pkgcloud/azure/storage/client/files.js, line 190, character 8: Move 'var' declarations to the top of the function. +for (var i = 0; i < numBlocks; i++) { +pkgcloud/azure/storage/client/files.js, line 190, character 8: Stopping. (64% scanned). + +pkgcloud/azure/storage/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/azure/storage/client/index.js, line 10, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth'), +pkgcloud/azure/storage/client/index.js, line 11, character 5: Expected 'azureApi' at column 3, not column 5. +azureApi = require('../../utils/azureApi.js'), +pkgcloud/azure/storage/client/index.js, line 12, character 5: Expected 'xml2JSON' at column 3, not column 5. +xml2JSON = require('../../utils/xml2json.js').xml2JSON, +pkgcloud/azure/storage/client/index.js, line 13, character 5: Expected 'azure' at column 3, not column 5. +azure = require('../../client'); +pkgcloud/azure/utils/azureApi.js, line 66, character 7: 'validateCreateOptions' was used before it was defined. +validateCreateOptions(options, client.config, next); +pkgcloud/azure/utils/azureApi.js, line 69, character 7: 'getHostedServiceProperties' was used before it was defined. +getHostedServiceProperties(client, options.name, next); +pkgcloud/azure/utils/azureApi.js, line 75, character 9: 'createHostedService' was used before it was defined. +createHostedService(client, options, function (err, service) { +pkgcloud/azure/utils/azureApi.js, line 89, character 7: 'getOSImage' was used before it was defined. +getOSImage(client, options.image, function (err, res) { +pkgcloud/azure/utils/azureApi.js, line 108, character 106: Line too long. +addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { +pkgcloud/azure/utils/azureApi.js, line 108, character 9: 'addCertificate' was used before it was defined. +addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { +pkgcloud/azure/utils/azureApi.js, line 117, character 7: 'createVM' was used before it was defined. +createVM(client, options, vmOptions, next); +pkgcloud/azure/utils/azureApi.js, line 121, character 7: 'getServer' was used before it was defined. +getServer(client, options.name, next); +pkgcloud/azure/utils/azureApi.js, line 131, character 3: Expected ')' at column 5, not column 3. +); +pkgcloud/azure/utils/azureApi.js, line 137, character 5: Expected 'case' at column 3, not column 5. +case 'linux': +pkgcloud/azure/utils/azureApi.js, line 138, character 7: Expected 'createLinuxVM' at column 5, not column 7. +createLinuxVM(client, options, vmOptions, callback); +pkgcloud/azure/utils/azureApi.js, line 138, character 7: 'createLinuxVM' was used before it was defined. +createLinuxVM(client, options, vmOptions, callback); +pkgcloud/azure/utils/azureApi.js, line 139, character 7: Expected 'break' at column 5, not column 7. +break; +pkgcloud/azure/utils/azureApi.js, line 140, character 5: Expected 'case' at column 3, not column 5. +case 'windows': +pkgcloud/azure/utils/azureApi.js, line 141, character 7: Expected 'createWindowsVM' at column 5, not column 7. +createWindowsVM(client, options, vmOptions, callback); +pkgcloud/azure/utils/azureApi.js, line 141, character 7: 'createWindowsVM' was used before it was defined. +createWindowsVM(client, options, vmOptions, callback); +pkgcloud/azure/utils/azureApi.js, line 142, character 7: Expected 'break' at column 5, not column 7. +break; +pkgcloud/azure/utils/azureApi.js, line 143, character 5: Expected 'default' at column 3, not column 5. +default: +pkgcloud/azure/utils/azureApi.js, line 144, character 7: Expected 'callback' at column 5, not column 7. +callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); +pkgcloud/azure/utils/azureApi.js, line 145, character 7: Expected 'break' at column 5, not column 7. +break; +pkgcloud/azure/utils/azureApi.js, line 165, character 7: Combine this with the previous 'var' statement. +var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); +pkgcloud/azure/utils/azureApi.js, line 166, character 7: Combine this with the previous 'var' statement. +var label = new Buffer(options.name).toString('base64'); +pkgcloud/azure/utils/azureApi.js, line 168, character 7: Combine this with the previous 'var' statement. +var configParams = { +pkgcloud/azure/utils/azureApi.js, line 182, character 3: 'makeTemplateRequest' was used before it was defined. +makeTemplateRequest(client, path, 'linuxDeployment.xml', configParams, callback); +pkgcloud/azure/utils/azureApi.js, line 187, character 7: Combine this with the previous 'var' statement. +var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); +pkgcloud/azure/utils/azureApi.js, line 188, character 7: Combine this with the previous 'var' statement. +var label = new Buffer(options.name).toString('base64'); +pkgcloud/azure/utils/azureApi.js, line 190, character 7: Combine this with the previous 'var' statement. +var configParams = { +pkgcloud/azure/utils/azureApi.js, line 201, character 3: 'makeTemplateRequest' was used before it was defined. +makeTemplateRequest(client, path, 'windowsDeployment.xml', configParams, callback); +pkgcloud/azure/utils/azureApi.js, line 205, character 128: Line too long. +// /services/hostedservices//deployments//roleinstances//operations +pkgcloud/azure/utils/azureApi.js, line 211, character 7: Combine this with the previous 'var' statement. +var configParams = { +pkgcloud/azure/utils/azureApi.js, line 215, character 3: 'makeTemplateRequest' was used before it was defined. +makeTemplateRequest(client, path, 'captureRole.xml', configParams, callback); +pkgcloud/azure/utils/azureApi.js, line 222, character 7: Combine this with the previous 'var' statement. +var configParams = { +pkgcloud/azure/utils/azureApi.js, line 226, character 3: 'makeTemplateRequest' was used before it was defined. +makeTemplateRequest(client, path, 'deleteImage.xml', configParams, callback); +pkgcloud/azure/utils/azureApi.js, line 251, character 3: 'getServersFromService' was used before it was defined. +getServersFromService(client, serverName, function (err, servers) { +pkgcloud/azure/utils/azureApi.js, line 253, character 34: Use the || operator. +? callback(err, servers[0] ? servers[0] : null) +pkgcloud/azure/utils/azureApi.js, line 263, character 7: 'getHostedServices' was used before it was defined. +getHostedServices(client, next); +pkgcloud/azure/utils/azureApi.js, line 267, character 7: 'getServersFromServices' was used before it was defined. +getServersFromServices(client, hostedServices, next); +pkgcloud/azure/utils/azureApi.js, line 272, character 3: Expected ')' at column 5, not column 3. +); +pkgcloud/azure/utils/azureApi.js, line 289, character 15: ['accept'] is better written in dot notation. +headers['accept'] = 'application/xml'; +pkgcloud/azure/utils/azureApi.js, line 300, character 9: 'pollRequestStatus' was used before it was defined. +pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, next); +pkgcloud/azure/utils/azureApi.js, line 306, character 3: Expected ')' at column 5, not column 3. +); +pkgcloud/azure/utils/azureApi.js, line 311, character 7: Combine this with the previous 'var' statement. +var params = { +pkgcloud/azure/utils/azureApi.js, line 323, character 167: Line too long. +* POST https://management.core.windows.net//services/hostedservices//deployments//roleinstances//operations +pkgcloud/azure/utils/azureApi.js, line 338, character 167: Line too long. +* POST https://management.core.windows.net//services/hostedservices//deployments//roleinstances//operations +pkgcloud/azure/utils/azureApi.js, line 354, character 7: Combine this with the previous 'var' statement. +var params = { +pkgcloud/azure/utils/azureApi.js, line 363, character 104: Line too long. +// DELETE https://management.core.windows.net//services/hostedservices/ +pkgcloud/azure/utils/azureApi.js, line 374, character 5: 'pollRequestStatus' was used before it was defined. +pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); +pkgcloud/azure/utils/azureApi.js, line 404, character 132: Line too long. +* DELETE https://management.core.windows.net//services/hostedservices//deployments/ +pkgcloud/azure/utils/azureApi.js, line 405, character 104: Line too long. +* Because Delete Deployment is an asynchronous operation, it always returns status code 202 (Accept). +pkgcloud/azure/utils/azureApi.js, line 407, character 102: Line too long. +* Because Delete Deployment is an asynchronous operation, it always returns status code 202 (Accept). +pkgcloud/azure/utils/azureApi.js, line 407, character 102: Too many errors. (58% scanned). + +pkgcloud/azure/utils/cert.js, line 74, character 7: Combine this with the previous 'var' statement. +var endCert = '\n' + pem.indexOf(END_CERT); +pkgcloud/azure/utils/cert.js, line 79, character 7: Combine this with the previous 'var' statement. +var certBase64 = pem.substring(beginCert, endCert); +pkgcloud/azure/utils/cert.js, line 82, character 7: Combine this with the previous 'var' statement. +var cert = new Buffer(certBase64, 'base64'); +pkgcloud/azure/utils/cert.js, line 83, character 7: Combine this with the previous 'var' statement. +var sha1 = crypto.createHash('sha1'); +pkgcloud/azure/utils/constants.js, line 1, character 0: Unsafe character. +/** +pkgcloud/azure/utils/constants.js, line 17, character 1: Read only. +exports = module.exports; +pkgcloud/azure/utils/hmacsha256sign.js, line 1, character 0: Unsafe character. +/** +pkgcloud/azure/utils/hmacsha256sign.js, line 20, character 1: Read only. +exports = module.exports = HmacSha256Sign; +pkgcloud/azure/utils/hmacsha256sign.js, line 20, character 28: 'HmacSha256Sign' was used before it was defined. +exports = module.exports = HmacSha256Sign; +pkgcloud/azure/utils/sharedkey.js, line 1, character 0: Unsafe character. +/** +pkgcloud/azure/utils/sharedkey.js, line 27, character 1: Expected 'exports' at column 3, not column 1. +exports = module.exports = SharedKey; +pkgcloud/azure/utils/sharedkey.js, line 27, character 28: 'SharedKey' was used before it was defined. +exports = module.exports = SharedKey; +pkgcloud/azure/utils/sharedkey.js, line 66, character 7: Combine this with the previous 'var' statement. +var stringToSign = +pkgcloud/azure/utils/sharedkey.js, line 68, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.CONTENT_ENCODING]) + +pkgcloud/azure/utils/sharedkey.js, line 69, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.CONTENT_LANGUAGE]) + +pkgcloud/azure/utils/sharedkey.js, line 70, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.CONTENT_LENGTH]) + +pkgcloud/azure/utils/sharedkey.js, line 71, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.CONTENT_MD5]) + +pkgcloud/azure/utils/sharedkey.js, line 72, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.CONTENT_TYPE]) + +pkgcloud/azure/utils/sharedkey.js, line 73, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.DATE]) + +pkgcloud/azure/utils/sharedkey.js, line 74, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.IF_MODIFIED_SINCE]) + +pkgcloud/azure/utils/sharedkey.js, line 75, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.IF_MATCH]) + +pkgcloud/azure/utils/sharedkey.js, line 76, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.IF_NONE_MATCH]) + +pkgcloud/azure/utils/sharedkey.js, line 77, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.IF_UNMODIFIED_SINCE]) + +pkgcloud/azure/utils/sharedkey.js, line 78, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.RANGE]) + +pkgcloud/azure/utils/sharedkey.js, line 79, character 7: Expected 'this' at column 5, not column 7. +this._getCanonicalizedHeaders(req) + +pkgcloud/azure/utils/sharedkey.js, line 80, character 7: Expected 'this' at column 5, not column 7. +this._getCanonicalizedResource(req); +pkgcloud/azure/utils/sharedkey.js, line 82, character 7: Combine this with the previous 'var' statement. +var signature = this.signer.sign(stringToSign); +pkgcloud/azure/utils/sharedkey.js, line 98, character 7: Combine this with the previous 'var' statement. +var canonicalizedResource = '/' + this.storageAccount; +pkgcloud/azure/utils/sharedkey.js, line 107, character 9: Combine this with the previous 'var' statement. +var queryStringValues = req.qs; +pkgcloud/azure/utils/sharedkey.js, line 111, character 11: Combine this with the previous 'var' statement. +var paramNames = []; +pkgcloud/azure/utils/sharedkey.js, line 112, character 12: Move 'var' declarations to the top of the function. +for (var n in queryStringValues) { +pkgcloud/azure/utils/sharedkey.js, line 112, character 12: Stopping. (69% scanned). + +pkgcloud/azure/utils/sharedkeytable.js, line 18, character 5: Expected 'HeaderConstants' at column 3, not column 5. +HeaderConstants = require('./constants').HeaderConstants, +pkgcloud/azure/utils/sharedkeytable.js, line 19, character 5: Expected 'azureApi' at column 3, not column 5. +azureApi = require('../utils/azureApi'), +pkgcloud/azure/utils/sharedkeytable.js, line 20, character 5: Expected 'URL' at column 3, not column 5. +URL = require('url'); +pkgcloud/azure/utils/sharedkeytable.js, line 23, character 1: Read only. +exports = module.exports = SharedKeyTable; +pkgcloud/azure/utils/sharedkeytable.js, line 23, character 28: 'SharedKeyTable' was used before it was defined. +exports = module.exports = SharedKeyTable; +pkgcloud/azure/utils/sharedkeytable.js, line 56, character 15: ['accept'] is better written in dot notation. +req.headers['accept'] = 'application/atom+xml;charset="utf-8"'; +pkgcloud/azure/utils/sharedkeytable.js, line 62, character 7: Combine this with the previous 'var' statement. +var stringToSign = +pkgcloud/azure/utils/sharedkeytable.js, line 64, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.CONTENT_MD5]) + +pkgcloud/azure/utils/sharedkeytable.js, line 65, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.CONTENT_TYPE]) + +pkgcloud/azure/utils/sharedkeytable.js, line 66, character 7: Expected 'getvalueToAppend' at column 5, not column 7. +getvalueToAppend(req.headers[HeaderConstants.DATE_HEADER]) + +pkgcloud/azure/utils/sharedkeytable.js, line 67, character 7: Expected 'this' at column 5, not column 7. +this._getCanonicalizedResource(req); +pkgcloud/azure/utils/sharedkeytable.js, line 69, character 15: ['DataServiceVersion'] is better written in dot notation. +req.headers['DataServiceVersion'] = '1.0;NetFx'; +pkgcloud/azure/utils/sharedkeytable.js, line 70, character 15: ['MaxDataServiceVersion'] is better written in dot notation. +req.headers['MaxDataServiceVersion'] = '2.0;NetFx'; +pkgcloud/azure/utils/sharedkeytable.js, line 87, character 7: Combine this with the previous 'var' statement. +var canonicalizedResource = '/' + this.storageAccount; +pkgcloud/azure/utils/sharedkeytable.js, line 94, character 9: Combine this with the previous 'var' statement. +var u = URL.parse(req.path[1], true); +pkgcloud/azure/utils/sharedkeytable.js, line 95, character 9: Combine this with the previous 'var' statement. +var queryStringValues = u.query; +pkgcloud/azure/utils/sharedkeytable.js, line 98, character 29: ['comp'] is better written in dot notation. +if (queryStringValues['comp']) { +pkgcloud/azure/utils/sharedkeytable.js, line 99, character 63: ['comp'] is better written in dot notation. +canonicalizedResource += '?comp=' + queryStringValues['comp']; +pkgcloud/azure/utils/xml2json.js, line 28, character 7: Combine this with the previous 'var' statement. +var parser = new xml2js.Parser({normalize: false, trim: false}); +pkgcloud/common/auth.js, line 9, character 5: Expected 'awsSignature' at column 3, not column 5. +awsSignature = require('./aws-signature'), +pkgcloud/common/auth.js, line 10, character 5: Expected 'azureSignature' at column 3, not column 5. +azureSignature = require('./azure-signature'), +pkgcloud/common/auth.js, line 11, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'); +pkgcloud/common/aws-signature.js, line 9, character 5: Expected 'qs' at column 3, not column 5. +qs = require('querystring'), +pkgcloud/common/aws-signature.js, line 10, character 5: Expected 'crypto' at column 3, not column 5. +crypto = require('crypto'); +pkgcloud/common/aws-signature.js, line 13, character 17: Expected '{' and instead saw 'options'. +if (!options) options = {}; +pkgcloud/common/aws-signature.js, line 13, character 17: Expected 'options' at column 3, not column 17. +if (!options) options = {}; +pkgcloud/common/aws-signature.js, line 24, character 9: Expected 'req' at column 7, not column 9. +req.method, '\n', +pkgcloud/common/aws-signature.js, line 25, character 9: Expected 'this' at column 7, not column 9. +this.serversUrl, '\n', +pkgcloud/common/aws-signature.js, line 26, character 9: Expected '/' at column 7, not column 9. +'/', '\n' +pkgcloud/common/aws-signature.js, line 27, character 7: Expected ']' at column 5, not column 7. +], +pkgcloud/common/aws-signature.js, line 28, character 7: Expected 'query' at column 5, not column 7. +query = req.body; +pkgcloud/common/aws-signature.js, line 34, character 40: Missing '()'. +query.Timestamp = new Date(+new Date + 36e5 * 30).toISOString(); +pkgcloud/common/aws-signature.js, line 37, character 18: Expected '{' and instead saw 'signatureString'. +if (i !== 0) signatureString.push('&'); +pkgcloud/common/aws-signature.js, line 37, character 18: Expected 'signatureString' at column 5, not column 18. +if (i !== 0) signatureString.push('&'); +pkgcloud/common/aws-signature.js, line 41, character 7: Combine this with the previous 'var' statement. +var toSign = signatureString.join(''); +pkgcloud/common/aws-signature.js, line 51, character 7: Expected 'sha256' at column 5, not column 7. +'sha256', +pkgcloud/common/aws-signature.js, line 52, character 7: Expected 'options' at column 5, not column 7. +options.key +pkgcloud/common/aws-signature.js, line 58, character 3: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/common/aws-signature.js, line 58, character 3: Expected 'else' at column 5, not column 3. +else { +pkgcloud/common/aws-signature.js, line 59, character 5: Expected 'req' at column 7, not column 5. +req.qs = { +pkgcloud/common/aws-signature.js, line 60, character 7: Expected 'Action' at column 9, not column 7. +Action: query.Action +pkgcloud/common/aws-signature.js, line 61, character 5: Expected '}' at column 7, not column 5. +}; +pkgcloud/common/aws-signature.js, line 62, character 3: Expected '}' at column 5, not column 3. +} +pkgcloud/common/aws-signature.js, line 75, character 17: Expected '{' and instead saw 'options'. +if (!options) options = {}; +pkgcloud/common/aws-signature.js, line 75, character 17: Expected 'options' at column 3, not column 17. +if (!options) options = {}; +pkgcloud/common/aws-signature.js, line 93, character 7: Combine this with the previous 'var' statement. +var now = new Date(), +pkgcloud/common/aws-signature.js, line 94, character 7: Expected 'signatureString' at column 5, not column 7. +signatureString = [ +pkgcloud/common/aws-signature.js, line 95, character 9: Expected 'req' at column 7, not column 9. +req.method || 'GET', '\n', +pkgcloud/common/aws-signature.js, line 96, character 9: Expected 'headers' at column 7, not column 9. +headers['content-md5'] || '', '\n', +pkgcloud/common/aws-signature.js, line 97, character 9: Expected 'headers' at column 7, not column 9. +headers['content-type'] || '', '\n', +pkgcloud/common/aws-signature.js, line 98, character 9: Expected 'now' at column 7, not column 9. +now.toUTCString(), '\n' +pkgcloud/common/aws-signature.js, line 99, character 7: Expected ']' at column 5, not column 7. +]; +pkgcloud/common/aws-signature.js, line 111, character 3: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/common/aws-signature.js, line 111, character 3: Expected 'else' at column 5, not column 3. +else { +pkgcloud/common/aws-signature.js, line 112, character 5: Expected 'signatureString' at column 7, not column 5. +signatureString.push(req.path); +pkgcloud/common/aws-signature.js, line 113, character 3: Expected '}' at column 5, not column 3. +} +pkgcloud/common/aws-signature.js, line 115, character 7: Combine this with the previous 'var' statement. +var signature = crypto.createHmac( +pkgcloud/common/aws-signature.js, line 118, character 3: Expected ')' at column 5, not column 3. +).update(signatureString.join('')).digest('base64'); +pkgcloud/common/azure-signature.js, line 36, character 15: ['accept'] is better written in dot notation. +req.headers['accept'] = 'application/xml'; +pkgcloud/common/http-signature.js, line 12, character 5: Expected 'crypto' at column 3, not column 5. +crypto = require('crypto'), +pkgcloud/common/http-signature.js, line 13, character 5: Expected 'http' at column 3, not column 5. +http = require('http'); +pkgcloud/common/http-signature.js, line 60, character 7: Expected 'months' at column 5, not column 7. +months, +pkgcloud/common/http-signature.js, line 61, character 7: Expected 'days' at column 5, not column 7. +days; +pkgcloud/common/http-signature.js, line 107, character 9: Expected 'alg' at column 7, not column 9. +alg = options.algorithm.match(/(hmac|rsa)-(\w+)/), +pkgcloud/common/http-signature.js, line 108, character 9: Expected 'signature' at column 7, not column 9. +signature, +pkgcloud/common/http-signature.js, line 109, character 9: Expected 'signer' at column 7, not column 9. +signer, +pkgcloud/common/http-signature.js, line 110, character 9: Expected 'hmac' at column 7, not column 9. +hmac; +pkgcloud/core/base/client.js, line 9, character 5: Expected 'events' at column 3, not column 5. +events = require('eventemitter2'), +pkgcloud/core/base/client.js, line 10, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/core/base/client.js, line 11, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/core/base/client.js, line 12, character 5: Expected 'qs' at column 3, not column 5. +qs = require('qs'), +pkgcloud/core/base/client.js, line 13, character 5: Expected 'common' at column 3, not column 5. +common = require('../../common'), +pkgcloud/core/base/client.js, line 14, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../pkgcloud'), +pkgcloud/core/base/client.js, line 15, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'); +pkgcloud/core/base/client.js, line 45, character 7: Combine this with the previous 'var' statement. +var requestOptions = {}; +pkgcloud/core/base/client.js, line 73, character 44: Missing space between '===' and 'GET'. +if (options.network && options.method ==='GET') { +pkgcloud/core/base/client.js, line 85, character 12: Move 'var' declarations to the top of the function. +for (var i = 0; i < self.before.length; i++) { +pkgcloud/core/base/client.js, line 85, character 12: Stopping. (43% scanned). + +pkgcloud/core/base/model.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'); +pkgcloud/core/base/model.js, line 44, character 7: Expected 'start' at column 5, not column 7. +start = Date.now(), +pkgcloud/core/base/model.js, line 45, character 7: Expected 'fired' at column 5, not column 7. +fired = false, +pkgcloud/core/base/model.js, line 46, character 7: Expected 'equalCheckId' at column 5, not column 7. +equalCheckId, +pkgcloud/core/base/model.js, line 47, character 7: Expected 'current' at column 5, not column 7. +current; +pkgcloud/core/base/model.js, line 69, character 11: Expected 'keys' at column 9, not column 11. +keys = Object.keys(attributes); +pkgcloud/core/base/model.js, line 74, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/core/base/model.js, line 74, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/core/base/model.js, line 75, character 9: Expected 'for' at column 11, not column 9. +for (var i = 0; i < keys.length; i++) { +pkgcloud/core/base/model.js, line 75, character 14: Move 'var' declarations to the top of the function. +for (var i = 0; i < keys.length; i++) { +pkgcloud/core/base/model.js, line 75, character 14: Stopping. (75% scanned). + +pkgcloud/core/compute/flavor.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/compute/image.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/compute/index.js, line 34, character 5: Unexpected 'else' after 'return'. +return server.adminPass; +pkgcloud/core/compute/index.js, line 36, character 3: Expected exactly one space between '}' and 'else'. +else if (server.metadata) { +pkgcloud/core/compute/index.js, line 36, character 3: Expected 'else' at column 5, not column 3. +else if (server.metadata) { +pkgcloud/core/compute/index.js, line 37, character 28: ['root'] is better written in dot notation. +return server.metadata['root']; +pkgcloud/core/compute/index.js, line 57, character 7: Expected 'isPrivate' at column 5, not column 7. +isPrivate = options.isPrivate || exports.isPrivate, +pkgcloud/core/compute/index.js, line 58, character 7: Expected 'interfaces' at column 5, not column 7. +interfaces, +pkgcloud/core/compute/index.js, line 59, character 7: Expected 'addresses' at column 5, not column 7. +addresses, +pkgcloud/core/compute/index.js, line 60, character 7: Expected 'networks' at column 5, not column 7. +networks, +pkgcloud/core/compute/index.js, line 61, character 7: Expected 'pub' at column 5, not column 7. +pub; +pkgcloud/core/compute/index.js, line 74, character 5: Unexpected 'else' after 'return'. +return !pub.length +pkgcloud/core/compute/index.js, line 78, character 3: Expected exactly one space between '}' and 'else'. +else if (server.addresses.public || server.addresses.private) { +pkgcloud/core/compute/index.js, line 78, character 3: Expected 'else' at column 5, not column 3. +else if (server.addresses.public || server.addresses.private) { +pkgcloud/core/compute/index.js, line 78, character 29: Expected an identifier and instead saw 'public' (a reserved word). +else if (server.addresses.public || server.addresses.private) { +pkgcloud/core/compute/index.js, line 78, character 56: Expected an identifier and instead saw 'private' (a reserved word). +else if (server.addresses.public || server.addresses.private) { +pkgcloud/core/compute/index.js, line 94, character 29: Expected an identifier and instead saw 'public' (a reserved word). +return server.addresses.public.length +pkgcloud/core/compute/index.js, line 95, character 26: Expected an identifier and instead saw 'public' (a reserved word). +? server.addresses.public[0] +pkgcloud/core/compute/index.js, line 96, character 26: Expected an identifier and instead saw 'private' (a reserved word). +: server.addresses.private[0]; +pkgcloud/core/compute/index.js, line 94, character 5: Unexpected 'else' after 'return'. +return server.addresses.public.length +pkgcloud/core/compute/index.js, line 98, character 3: Expected exactly one space between '}' and 'else'. +else if (server.addresses) { +pkgcloud/core/compute/index.js, line 98, character 3: Expected 'else' at column 5, not column 3. +else if (server.addresses) { +pkgcloud/core/compute/index.js, line 116, character 48: Expected ';' and instead saw '}'. +.map(function (info) { return info.addr }) +pkgcloud/core/compute/index.js, line 122, character 11: Expected exactly one space between '}' and 'else'. +else if (isPrivate(addr)) { +pkgcloud/core/compute/index.js, line 122, character 11: Expected 'else' at column 13, not column 11. +else if (isPrivate(addr)) { +pkgcloud/core/compute/index.js, line 128, character 10: Expected an identifier and instead saw 'public' (a reserved word). +}, { public: [], private: [] }); +pkgcloud/core/compute/index.js, line 128, character 22: Expected an identifier and instead saw 'private' (a reserved word). +}, { public: [], private: [] }); +pkgcloud/core/compute/server.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'), +pkgcloud/core/compute/server.js, line 10, character 5: Expected 'computeStatus' at column 3, not column 5. +computeStatus = require('../../common/status').compute; +pkgcloud/core/compute/server.js, line 21, character 15: Expected '{' and instead saw 'self'. +if (!err) self._setProperties(server.original); +pkgcloud/core/compute/server.js, line 21, character 15: Expected 'self' at column 5, not column 15. +if (!err) self._setProperties(server.original); +pkgcloud/core/dns/record.js, line 11, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/dns/record.js, line 19, character 35: Expected exactly one space between 'function' and '('. +Record.prototype.create = function(callback) { +pkgcloud/core/dns/record.js, line 23, character 32: Expected exactly one space between 'function' and '('. +Record.prototype.get = function(callback) { +pkgcloud/core/dns/record.js, line 27, character 35: Expected exactly one space between 'function' and '('. +Record.prototype.update = function(callback) { +pkgcloud/core/dns/record.js, line 31, character 36: Expected exactly one space between 'function' and '('. +Record.prototype.destroy = function(callback) { +pkgcloud/core/dns/zone.js, line 11, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/loadbalancer/loadbalancer.js, line 11, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/loadbalancer/node.js, line 11, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/network/network.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/network/port.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/network/subnet.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/storage/container.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'); +pkgcloud/core/storage/file.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/core/storage/file.js, line 10, character 5: Expected 'model' at column 3, not column 5. +model = require('../base/model'), +pkgcloud/core/storage/file.js, line 11, character 5: Expected 'storage' at column 3, not column 5. +storage = require('../storage'); +pkgcloud/digitalocean/client.js, line 9, character 5: Expected 'fs' at column 3, not column 5. +fs = require('fs'), +pkgcloud/digitalocean/client.js, line 10, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../common/auth'), +pkgcloud/digitalocean/client.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../core/base'); +pkgcloud/digitalocean/client.js, line 30, character 1: Unexpected '(space)'. + +pkgcloud/digitalocean/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/flavor'); +pkgcloud/digitalocean/compute/flavor.js, line 22, character 1: Unexpected '(space)'. + +pkgcloud/digitalocean/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/image'); +pkgcloud/digitalocean/compute/server.js, line 9, character 5: Expected 'compute' at column 3, not column 5. +compute = require('../../core/compute'), +pkgcloud/digitalocean/compute/server.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/server'); +pkgcloud/digitalocean/compute/server.js, line 24, character 5: Expected an identifier and instead saw 'public' (a reserved word). +public: [details.ip_address], +pkgcloud/digitalocean/compute/server.js, line 25, character 5: Expected an identifier and instead saw 'private' (a reserved word). +private: [] +pkgcloud/digitalocean/compute/server.js, line 29, character 5: Expected 'case' at column 3, not column 5. +case 'ACTIVE': +pkgcloud/digitalocean/compute/server.js, line 30, character 7: Expected 'this' at column 5, not column 7. +this.status = "RUNNING"; +pkgcloud/digitalocean/compute/server.js, line 31, character 7: Expected 'break' at column 5, not column 7. +break; +pkgcloud/digitalocean/compute/server.js, line 32, character 5: Expected 'case' at column 3, not column 5. +case 'NEW': +pkgcloud/digitalocean/compute/server.js, line 33, character 5: Empty case. +default: +pkgcloud/digitalocean/compute/server.js, line 33, character 5: Expected 'default' at column 3, not column 5. +default: +pkgcloud/digitalocean/compute/server.js, line 34, character 7: Expected 'this' at column 5, not column 7. +this.status = 'PROVISIONING'; +pkgcloud/digitalocean/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/digitalocean/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.digitalocean.compute; +pkgcloud/digitalocean/compute/client/flavors.js, line 27, character 1: Unexpected '(space)'. + +pkgcloud/digitalocean/compute/client/flavors.js, line 30, character 14: Unexpected '(space)'. +}), res); +pkgcloud/digitalocean/compute/client/flavors.js, line 45, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/digitalocean/compute/client/flavors.js, line 55, character 24: Expected '===' and instead saw '=='. +return flavor.id == flavorId; +pkgcloud/digitalocean/compute/client/flavors.js, line 57, character 1: Unexpected '(space)'. + +pkgcloud/digitalocean/compute/client/flavors.js, line 60, character 28: 'Flavor' was used before it was defined. +: callback(null, new Flavor(self, flavor)); +pkgcloud/digitalocean/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/digitalocean/compute/client/images.js, line 9, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/digitalocean/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.digitalocean.compute; +pkgcloud/digitalocean/compute/client/images.js, line 44, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/digitalocean/compute/client/images.js, line 44, character 22: Unexpected '(space)'. +self = this; +pkgcloud/digitalocean/compute/client/images.js, line 82, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/digitalocean/compute/client/images.js, line 82, character 22: Unexpected '(space)'. +self = this; +pkgcloud/digitalocean/compute/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/digitalocean/compute/client/index.js, line 10, character 5: Expected 'digitalocean' at column 3, not column 5. +digitalocean = require('../../client'); +pkgcloud/digitalocean/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'); +pkgcloud/digitalocean/compute/client/keys.js, line 83, character 43: Unexpected ','. +path: '/ssh_keys/' + name + '/destroy', +pkgcloud/digitalocean/compute/client/servers.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/digitalocean/compute/client/servers.js, line 9, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/digitalocean/compute/client/servers.js, line 10, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/digitalocean/compute/client/servers.js, line 11, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.digitalocean.compute; +pkgcloud/digitalocean/compute/client/servers.js, line 97, character 7: Expected 'createOptions' at column 5, not column 7. +createOptions = { +pkgcloud/digitalocean/compute/client/servers.js, line 98, character 9: Expected 'path' at column 7, not column 9. +path: '/droplets/new', +pkgcloud/digitalocean/compute/client/servers.js, line 99, character 9: Expected 'qs' at column 7, not column 9. +qs: {} +pkgcloud/digitalocean/compute/client/servers.js, line 100, character 7: Expected '}' at column 5, not column 7. +}; +pkgcloud/digitalocean/compute/client/servers.js, line 128, character 3: Expected exactly one space between '}' and 'else'. +else if (options.keynames) { +pkgcloud/digitalocean/compute/client/servers.js, line 128, character 3: Expected 'else' at column 5, not column 3. +else if (options.keynames) { +pkgcloud/digitalocean/compute/client/servers.js, line 154, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/digitalocean/compute/client/servers.js, line 182, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/iriscouch/database/client/index.js, line 9, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/iriscouch/database/client/index.js, line 10, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/iriscouch/database/client/index.js, line 11, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'); +pkgcloud/iriscouch/database/client/index.js, line 29, character 14: ['first_name'] is better written in dot notation. +if (!attrs['first_name'] || !attrs['last_name']) { +pkgcloud/iriscouch/database/client/index.js, line 29, character 38: ['last_name'] is better written in dot notation. +if (!attrs['first_name'] || !attrs['last_name']) { +pkgcloud/iriscouch/database/client/index.js, line 35, character 14: ['subdomain'] is better written in dot notation. +if (!attrs['subdomain'] || !attrs['email']) { +pkgcloud/iriscouch/database/client/index.js, line 35, character 37: ['email'] is better written in dot notation. +if (!attrs['subdomain'] || !attrs['email']) { +pkgcloud/iriscouch/database/client/index.js, line 42, character 13: ['type'] is better written in dot notation. +if (attrs['type'] && attrs['type'] === 'redis' && !attrs['password']) { +pkgcloud/iriscouch/database/client/index.js, line 42, character 30: ['type'] is better written in dot notation. +if (attrs['type'] && attrs['type'] === 'redis' && !attrs['password']) { +pkgcloud/iriscouch/database/client/index.js, line 42, character 60: ['password'] is better written in dot notation. +if (attrs['type'] && attrs['type'] === 'redis' && !attrs['password']) { +pkgcloud/iriscouch/database/client/index.js, line 51, character 20: ['type'] is better written in dot notation. +_id: ((attrs['type'] && +pkgcloud/iriscouch/database/client/index.js, line 52, character 15: ['type'] is better written in dot notation. +attrs['type'] === 'redis') ? "Redis/" : "Server/") + attrs.subdomain, +pkgcloud/iriscouch/database/client/index.js, line 60, character 3: Expected '}' at column 5, not column 3. +}; +pkgcloud/iriscouch/database/client/index.js, line 63, character 13: ['type'] is better written in dot notation. +if (attrs['type'] && attrs['type'] === 'redis') { +pkgcloud/iriscouch/database/client/index.js, line 63, character 30: ['type'] is better written in dot notation. +if (attrs['type'] && attrs['type'] === 'redis') { +pkgcloud/iriscouch/database/client/index.js, line 64, character 37: ['password'] is better written in dot notation. +couch.creation.password = attrs['password']; +pkgcloud/iriscouch/database/client/index.js, line 64, character 29: Weird assignment. +couch.creation.password = attrs['password']; +pkgcloud/iriscouch/database/client/index.js, line 67, character 7: Combine this with the previous 'var' statement. +var options = { +pkgcloud/iriscouch/database/client/index.js, line 85, character 36: Expected ';' and instead saw '}'. +try { body = JSON.parse(body) } +pkgcloud/iriscouch/database/client/index.js, line 86, character 7: Expected exactly one space between '}' and 'catch'. +catch (ex) { } +pkgcloud/iriscouch/database/client/index.js, line 86, character 7: Expected 'catch' at column 9, not column 7. +catch (ex) { } +pkgcloud/iriscouch/database/client/index.js, line 92, character 111: Line too long. +// For Redis we dont have any polling method yet, so just trust on iriscouch for provisioning correctly +pkgcloud/iriscouch/database/client/index.js, line 94, character 19: ['type'] is better written in dot notation. +if (attrs['type'] && attrs['type'] === 'redis') { +pkgcloud/iriscouch/database/client/index.js, line 94, character 36: ['type'] is better written in dot notation. +if (attrs['type'] && attrs['type'] === 'redis') { +pkgcloud/iriscouch/database/client/index.js, line 102, character 65: ['password'] is better written in dot notation. +password: subdomain + '.redis.irstack.com:' + attrs['password'] +pkgcloud/iriscouch/database/client/index.js, line 115, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/iriscouch/database/client/index.js, line 115, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/iriscouch/database/client/index.js, line 116, character 9: Expected 'callback' at column 11, not column 9. +callback("There was an issue creating the couch", { "created": false }); +pkgcloud/iriscouch/database/client/index.js, line 117, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/iriscouch/database/client/index.js, line 119, character 105: Line too long. +else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { +pkgcloud/iriscouch/database/client/index.js, line 119, character 5: Expected exactly one space between '}' and 'else'. +else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { +pkgcloud/iriscouch/database/client/index.js, line 119, character 5: Expected 'else' at column 7, not column 5. +else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { +pkgcloud/iriscouch/database/client/index.js, line 122, character 5: Expected exactly one space between '}' and 'else'. +else if (response.statusCode === 409) { +pkgcloud/iriscouch/database/client/index.js, line 122, character 5: Expected 'else' at column 7, not column 5. +else if (response.statusCode === 409) { +pkgcloud/iriscouch/database/client/index.js, line 125, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/iriscouch/database/client/index.js, line 125, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/iriscouch/database/client/index.js, line 126, character 7: Expected 'callback' at column 9, not column 7. +callback("unknown error", { "created": false }); +pkgcloud/iriscouch/database/client/index.js, line 127, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/iriscouch/database/client/index.js, line 154, character 7: Expected 'maxAttempts' at column 5, not column 7. +maxAttempts = 20, +pkgcloud/iriscouch/database/client/index.js, line 155, character 7: Expected 'count' at column 5, not column 7. +count = 0, +pkgcloud/iriscouch/database/client/index.js, line 156, character 7: Expected 'options' at column 5, not column 7. +options = { +pkgcloud/iriscouch/database/client/index.js, line 157, character 9: Expected 'uri' at column 7, not column 9. +uri : this._getCouchPollingUrl(couchName), +pkgcloud/iriscouch/database/client/index.js, line 158, character 9: Expected 'method' at column 7, not column 9. +method : 'GET', +pkgcloud/iriscouch/database/client/index.js, line 159, character 9: Expected 'followRedirect' at column 7, not column 9. +followRedirect: false, +pkgcloud/iriscouch/database/client/index.js, line 160, character 9: Expected 'headers' at column 7, not column 9. +headers: { +pkgcloud/iriscouch/database/client/index.js, line 161, character 11: Expected 'Content-Type' at column 9, not column 11. +'Content-Type': 'application/json', +pkgcloud/iriscouch/database/client/index.js, line 162, character 11: Expected 'User-Agent' at column 9, not column 11. +'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version) +pkgcloud/iriscouch/database/client/index.js, line 163, character 9: Expected '}' at column 7, not column 9. +} +pkgcloud/iriscouch/database/client/index.js, line 164, character 7: Expected '}' at column 5, not column 7. +}, +pkgcloud/iriscouch/database/client/index.js, line 166, character 3: Expected 't' at column 5, not column 3. +t = function () { +pkgcloud/iriscouch/database/client/index.js, line 166, character 3: Too many errors. (86% scanned). + +pkgcloud/joyent/client.js, line 9, character 5: Expected 'fs' at column 3, not column 5. +fs = require('fs'), +pkgcloud/joyent/client.js, line 10, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../common/auth'), +pkgcloud/joyent/client.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../core/base'); +pkgcloud/joyent/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/flavor'); +pkgcloud/joyent/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/image'); +pkgcloud/joyent/compute/server.js, line 9, character 5: Expected 'compute' at column 3, not column 5. +compute = require('../../core/compute'), +pkgcloud/joyent/compute/server.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/server'), +pkgcloud/joyent/compute/server.js, line 11, character 5: Expected 'computeStatus' at column 3, not column 5. +computeStatus = require('../../common/status').compute; +pkgcloud/joyent/compute/server.js, line 25, character 7: Expected 'case' at column 5, not column 7. +case 'PROVISIONING': +pkgcloud/joyent/compute/server.js, line 26, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.provisioning; +pkgcloud/joyent/compute/server.js, line 27, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/joyent/compute/server.js, line 28, character 7: Expected 'case' at column 5, not column 7. +case 'RUNNING': +pkgcloud/joyent/compute/server.js, line 29, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.running; +pkgcloud/joyent/compute/server.js, line 30, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/joyent/compute/server.js, line 31, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPING': +pkgcloud/joyent/compute/server.js, line 32, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPED': +pkgcloud/joyent/compute/server.js, line 33, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.stopped; +pkgcloud/joyent/compute/server.js, line 34, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/joyent/compute/server.js, line 35, character 7: Expected 'default' at column 5, not column 7. +default: +pkgcloud/joyent/compute/server.js, line 36, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.unknown; +pkgcloud/joyent/compute/server.js, line 37, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/joyent/compute/server.js, line 45, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/joyent/compute/server.js, line 45, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/joyent/compute/server.js, line 46, character 7: Expected 'all' at column 9, not column 7. +all['public'].push(addr); +pkgcloud/joyent/compute/server.js, line 47, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/joyent/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/joyent/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.joyent.compute; +pkgcloud/joyent/compute/client/flavors.js, line 27, character 11: Expected 'return' at column 9, not column 11. +return new compute.Flavor(self, result); +pkgcloud/joyent/compute/client/flavors.js, line 28, character 9: Expected '}' at column 7, not column 9. +}), res); +pkgcloud/joyent/compute/client/flavors.js, line 43, character 7: Expected 'flavorId' at column 5, not column 7. +flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; +pkgcloud/joyent/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/joyent/compute/client/images.js, line 9, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/joyent/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.joyent.compute; +pkgcloud/joyent/compute/client/images.js, line 27, character 11: Expected 'return' at column 9, not column 11. +return new compute.Image(self, result); +pkgcloud/joyent/compute/client/images.js, line 28, character 9: Expected '}' at column 7, not column 9. +}), res); +pkgcloud/joyent/compute/client/images.js, line 42, character 7: Expected 'imageId' at column 5, not column 7. +imageId = image instanceof base.Image ? image.id : image; +pkgcloud/joyent/compute/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/joyent/compute/client/index.js, line 10, character 5: Expected 'joyent' at column 3, not column 5. +joyent = require('../../client'); +pkgcloud/joyent/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'); +pkgcloud/joyent/compute/client/servers.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/joyent/compute/client/servers.js, line 9, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/joyent/compute/client/servers.js, line 10, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/joyent/compute/client/servers.js, line 11, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.joyent.compute; +pkgcloud/joyent/compute/client/servers.js, line 23, character 7: Expected 'return' at column 5, not column 7. +return err +pkgcloud/joyent/compute/client/servers.js, line 37, character 65: Expected 'callback' at column 5, not column 65. +errs.create({message: "Joyent's API is not rate limited"}), callback); +pkgcloud/joyent/compute/client/servers.js, line 37, character 73: Expected ')' at column 3, not column 73. +errs.create({message: "Joyent's API is not rate limited"}), callback); +pkgcloud/joyent/compute/client/servers.js, line 66, character 13: Expected 'return' at column 11, not column 13. +return new compute.Server(self, result); +pkgcloud/joyent/compute/client/servers.js, line 67, character 11: Expected '}' at column 9, not column 11. +}), res); +pkgcloud/joyent/compute/client/servers.js, line 95, character 7: Expected 'createOptions' at column 5, not column 7. +createOptions = { +pkgcloud/joyent/compute/client/servers.js, line 96, character 9: Expected 'method' at column 7, not column 9. +method: 'POST', +pkgcloud/joyent/compute/client/servers.js, line 97, character 9: Expected 'path' at column 7, not column 9. +path: this.account + '/machines', +pkgcloud/joyent/compute/client/servers.js, line 98, character 9: Expected 'body' at column 7, not column 9. +body: options +pkgcloud/joyent/compute/client/servers.js, line 99, character 7: Expected '}' at column 5, not column 7. +}; +pkgcloud/joyent/compute/client/servers.js, line 143, character 7: Combine this with the previous 'var' statement. +var self = this; +pkgcloud/joyent/compute/client/servers.js, line 145, character 7: Combine this with the previous 'var' statement. +var stopOptions = { +pkgcloud/joyent/compute/client/servers.js, line 157, character 11: Combine this with the previous 'var' statement. +var done = false; +pkgcloud/joyent/compute/client/servers.js, line 158, character 7: Function statements should not be placed in blocks. Use a function expression or move the statement to the top of the outer function. +function check() { +pkgcloud/joyent/compute/client/servers.js, line 159, character 19: Expected '{' and instead saw 'return'. +if (done) return; +pkgcloud/joyent/compute/client/servers.js, line 159, character 19: Expected 'return' at column 9, not column 19. +if (done) return; +pkgcloud/joyent/compute/client/servers.js, line 161, character 26: Expected '{' and instead saw 'return'. +if (checks <= 0) return; +pkgcloud/joyent/compute/client/servers.js, line 161, character 26: Expected 'return' at column 9, not column 26. +if (checks <= 0) return; +pkgcloud/joyent/compute/client/servers.js, line 164, character 11: 'finish' was used before it was defined. +finish(new Error('Machine unresponsive to STOP')); +pkgcloud/joyent/compute/client/servers.js, line 173, character 54: Expected ';' and instead saw '}'. +if (err) { return callback && callback(err) } +pkgcloud/joyent/compute/client/servers.js, line 176, character 13: 'finish' was used before it was defined. +finish(); +pkgcloud/joyent/compute/client/servers.js, line 185, character 7: Unexpected 'else' after 'return'. +return; +pkgcloud/joyent/compute/client/servers.js, line 187, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/joyent/compute/client/servers.js, line 187, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/joyent/compute/client/servers.js, line 188, character 7: Expected 'finish' at column 9, not column 7. +finish(); +pkgcloud/joyent/compute/client/servers.js, line 188, character 7: 'finish' was used before it was defined. +finish(); +pkgcloud/joyent/compute/client/servers.js, line 189, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/joyent/compute/client/servers.js, line 191, character 14: 'finish' was used before it was defined. +function finish() { +pkgcloud/joyent/compute/client/servers.js, line 215, character 7: Expected 'serverId' at column 5, not column 7. +serverId = server instanceof base.Server ? server.id : server; +pkgcloud/joyent/compute/client/servers.js, line 218, character 7: Expected 'path' at column 5, not column 7. +path: this.account + '/machines/' + serverId +pkgcloud/joyent/compute/client/servers.js, line 219, character 5: Expected '}' at column 3, not column 5. +}, function (err, body, res) { +pkgcloud/joyent/compute/client/servers.js, line 220, character 7: Expected 'return' at column 5, not column 7. +return err +pkgcloud/joyent/compute/client/servers.js, line 236, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/mongohq/database/client/databases.js, line 8, character 2: Expected 'var' at column 1, not column 2. +var errs = require('errs'), +pkgcloud/mongohq/database/client/databases.js, line 9, character 6: Expected 'url' at column 3, not column 6. +url = require('url'); +pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Expected ';' and instead saw ','. +dbname = info.pathname.replace('/', ''), +pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Expected ',' at column 3, not column 42. +dbname = info.pathname.replace('/', ''), +pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Expected an identifier and instead saw ','. +dbname = info.pathname.replace('/', ''), +pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Stopping. (19% scanned). + +pkgcloud/mongohq/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/mongohq/database/client/index.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/base'), +pkgcloud/mongohq/database/client/index.js, line 11, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth'), +pkgcloud/mongohq/database/client/index.js, line 12, character 5: Expected 'url' at column 3, not column 5. +url = require('url'), +pkgcloud/mongohq/database/client/index.js, line 13, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/mongohq/database/client/index.js, line 14, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'); +pkgcloud/mongolab/database/client/accounts.js, line 9, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'); +pkgcloud/mongolab/database/client/accounts.js, line 15, character 119: Line too long. +// #### options['password'] {string} Password for the account (Optional), If not specify so mongolab will generate one. +pkgcloud/mongolab/database/client/accounts.js, line 25, character 16: ['name'] is better written in dot notation. +if (!options['name']) { +pkgcloud/mongolab/database/client/accounts.js, line 31, character 16: ['email'] is better written in dot notation. +if (!options['email']) { +pkgcloud/mongolab/database/client/accounts.js, line 38, character 133: Line too long. +// https://objectlabs.jira.com/wiki/display/partners/MongoLab+Partner+Integration+API#MongoLabPartnerIntegrationAPI-Createaccount.1 +pkgcloud/mongolab/database/client/accounts.js, line 40, character 36: ['email'] is better written in dot notation. +var adminUser = { email: options['email'] }; +pkgcloud/mongolab/database/client/accounts.js, line 42, character 15: ['password'] is better written in dot notation. +if (options['password']) { +pkgcloud/mongolab/database/client/accounts.js, line 43, character 31: ['password'] is better written in dot notation. +if (/[+\d]/g.test(options['password'])) { +pkgcloud/mongolab/database/client/accounts.js, line 44, character 17: ['password'] is better written in dot notation. +adminUser['password'] = options['password']; +pkgcloud/mongolab/database/client/accounts.js, line 44, character 39: ['password'] is better written in dot notation. +adminUser['password'] = options['password']; +pkgcloud/mongolab/database/client/accounts.js, line 52, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/mongolab/database/client/accounts.js, line 56, character 44: ['name'] is better written in dot notation. +name: [this.config.username, options['name']].join('_'), +pkgcloud/mongolab/database/client/accounts.js, line 98, character 11: Expected 'return' at column 9, not column 11. +return account.adminUser; +pkgcloud/mongolab/database/client/accounts.js, line 99, character 9: Expected '}' at column 7, not column 9. +})); +pkgcloud/mongolab/database/client/databases.js, line 9, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/mongolab/database/client/databases.js, line 10, character 5: Expected 'qs' at column 3, not column 5. +qs = require('querystring'), +pkgcloud/mongolab/database/client/databases.js, line 11, character 5: Expected 'url' at column 3, not column 5. +url = require('url'); +pkgcloud/mongolab/database/client/databases.js, line 25, character 7: Combine this with the previous 'var' statement. +var database = { +pkgcloud/mongolab/database/client/databases.js, line 51, character 16: ['name'] is better written in dot notation. +if (!options['name']) { +pkgcloud/mongolab/database/client/databases.js, line 57, character 16: ['owner'] is better written in dot notation. +if (!options['owner']) { +pkgcloud/mongolab/database/client/databases.js, line 63, character 16: ['plan'] is better written in dot notation. +if (!options['plan']) { +pkgcloud/mongolab/database/client/databases.js, line 64, character 13: ['plan'] is better written in dot notation. +options['plan'] = 'free'; +pkgcloud/mongolab/database/client/databases.js, line 69, character 31: ['owner'] is better written in dot notation. +var databaseName = [options['owner'], options['name']].join('_'); +pkgcloud/mongolab/database/client/databases.js, line 69, character 49: ['name'] is better written in dot notation. +var databaseName = [options['owner'], options['name']].join('_'); +pkgcloud/mongolab/database/client/databases.js, line 75, character 7: Combine this with the previous 'var' statement. +var account = options['owner']; +pkgcloud/mongolab/database/client/databases.js, line 75, character 25: ['owner'] is better written in dot notation. +var account = options['owner']; +pkgcloud/mongolab/database/client/databases.js, line 77, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/mongolab/database/client/databases.js, line 82, character 21: ['plan'] is better written in dot notation. +plan: options['plan'], +pkgcloud/mongolab/database/client/databases.js, line 83, character 25: ['owner'] is better written in dot notation. +username: options['owner'], +pkgcloud/mongolab/database/client/databases.js, line 119, character 128: Line too long. +// https://objectlabs.jira.com/wiki/display/partners/MongoLab+Partner+Integration+API#MongoLabPartnerIntegrationAPI-Viewdatabase +pkgcloud/mongolab/database/client/databases.js, line 133, character 16: ['name'] is better written in dot notation. +if (!options['name']) { +pkgcloud/mongolab/database/client/databases.js, line 140, character 16: ['owner'] is better written in dot notation. +if (!options['owner']) { +pkgcloud/mongolab/database/client/databases.js, line 146, character 35: ['owner'] is better written in dot notation. +var path = ['accounts', options['owner'], 'databases', options['name']].join('/'); +pkgcloud/mongolab/database/client/databases.js, line 146, character 66: ['name'] is better written in dot notation. +var path = ['accounts', options['owner'], 'databases', options['name']].join('/'); +pkgcloud/mongolab/database/client/databases.js, line 169, character 16: ['name'] is better written in dot notation. +if (!options['name']) { +pkgcloud/mongolab/database/client/databases.js, line 176, character 16: ['owner'] is better written in dot notation. +if (!options['owner']) { +pkgcloud/mongolab/database/client/databases.js, line 184, character 32: ['owner'] is better written in dot notation. +path: ['accounts', options['owner'], 'databases', options['name']].join('/') +pkgcloud/mongolab/database/client/databases.js, line 184, character 63: ['name'] is better written in dot notation. +path: ['accounts', options['owner'], 'databases', options['name']].join('/') +pkgcloud/mongolab/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/mongolab/database/client/index.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/base'), +pkgcloud/mongolab/database/client/index.js, line 11, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth'); +pkgcloud/mongolab/database/client/index.js, line 44, character 7: Use the || operator. +? this.config.username +pkgcloud/openstack/client.js, line 9, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/openstack/client.js, line 10, character 5: Expected 'through' at column 3, not column 5. +through = require('through'), +pkgcloud/openstack/client.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../core/base'), +pkgcloud/openstack/client.js, line 12, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/openstack/client.js, line 13, character 5: Expected 'context' at column 3, not column 5. +context = require('./context'); +pkgcloud/openstack/client.js, line 62, character 39: Expected exactly one space between 'function' and '('. +this._identity.on('log::*', function(message, object) { +pkgcloud/openstack/client.js, line 71, character 48: Expected exactly one space between 'function' and '('. +Client.prototype._getIdentityOptions = function() { +pkgcloud/openstack/client.js, line 81, character 3: Expected exactly one space between '}' and 'else'. +else if (this.config.tenantName) { +pkgcloud/openstack/client.js, line 81, character 3: Expected 'else' at column 5, not column 3. +else if (this.config.tenantName) { +pkgcloud/openstack/client.js, line 128, character 36: Expected exactly one space between 'function' and '('. +self._identity.authorize(function(err) { +pkgcloud/openstack/client.js, line 150, character 5: Expected exactly one space between '}' and 'catch'. +catch (e) { +pkgcloud/openstack/client.js, line 150, character 5: Expected 'catch' at column 7, not column 5. +catch (e) { +pkgcloud/openstack/client.js, line 151, character 7: Expected 'self' at column 9, not column 7. +self.emit('log::error', 'Unable to select endpoint for service', { +pkgcloud/openstack/client.js, line 152, character 9: Expected 'error' at column 11, not column 9. +error: e.toString(), +pkgcloud/openstack/client.js, line 153, character 9: Expected 'options' at column 11, not column 9. +options: options +pkgcloud/openstack/client.js, line 154, character 7: Expected '}' at column 9, not column 7. +}); +pkgcloud/openstack/client.js, line 155, character 7: Expected 'callback' at column 9, not column 7. +callback(e); +pkgcloud/openstack/client.js, line 156, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/client.js, line 175, character 9: Combine this with the previous 'var' statement. +var buf = through().pause(); +pkgcloud/openstack/client.js, line 188, character 7: Expected exactly one space between '}' and 'else'. +else if (options.download) { +pkgcloud/openstack/client.js, line 188, character 7: Expected 'else' at column 9, not column 7. +else if (options.download) { +pkgcloud/openstack/client.js, line 195, character 5: Unexpected 'else' after 'return'. +return buf; +pkgcloud/openstack/client.js, line 197, character 3: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/client.js, line 197, character 3: Expected 'else' at column 5, not column 3. +else { +pkgcloud/openstack/client.js, line 198, character 5: Expected 'self' at column 7, not column 5. +self.emit('log::trace', 'Creating Authenticated Request'); +pkgcloud/openstack/client.js, line 199, character 5: Expected 'return' at column 7, not column 5. +return Client.super_.prototype._request.call(self, options, callback); +pkgcloud/openstack/client.js, line 200, character 3: Expected '}' at column 5, not column 3. +} +pkgcloud/openstack/client.js, line 205, character 7: Expected 'authorized' at column 5, not column 7. +authorized = false; +pkgcloud/openstack/client.js, line 207, character 131: Line too long. +if (!self._serviceUrl || !self._identity || !self._identity.token || !self._identity.token.id || !self._identity.token.expires) { +pkgcloud/openstack/client.js, line 210, character 107: Line too long. +else if (self._identity.token.expires.getTime() - new Date().getTime() > self.config.earlyTokenTimeout) { +pkgcloud/openstack/client.js, line 210, character 3: Expected exactly one space between '}' and 'else'. +else if (self._identity.token.expires.getTime() - new Date().getTime() > self.config.earlyTokenTimeout) { +pkgcloud/openstack/client.js, line 210, character 3: Expected 'else' at column 5, not column 3. +else if (self._identity.token.expires.getTime() - new Date().getTime() > self.config.earlyTokenTimeout) { +pkgcloud/openstack/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/flavor'); +pkgcloud/openstack/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/image'); +pkgcloud/openstack/compute/server.js, line 9, character 5: Expected 'compute' at column 3, not column 5. +compute = require('../../core/compute'), +pkgcloud/openstack/compute/server.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/compute/server'), +pkgcloud/openstack/compute/server.js, line 11, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/compute/server.js, line 27, character 7: Expected 'case' at column 5, not column 7. +case 'BUILD': +pkgcloud/openstack/compute/server.js, line 28, character 7: Expected 'case' at column 5, not column 7. +case 'REBUILD': +pkgcloud/openstack/compute/server.js, line 29, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.provisioning; +pkgcloud/openstack/compute/server.js, line 30, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/openstack/compute/server.js, line 31, character 7: Expected 'case' at column 5, not column 7. +case 'ACTIVE': +pkgcloud/openstack/compute/server.js, line 32, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.running; +pkgcloud/openstack/compute/server.js, line 33, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/openstack/compute/server.js, line 34, character 7: Expected 'case' at column 5, not column 7. +case 'SUSPENDED': +pkgcloud/openstack/compute/server.js, line 35, character 7: Expected 'case' at column 5, not column 7. +case 'SHUTOFF': +pkgcloud/openstack/compute/server.js, line 36, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.stopped; +pkgcloud/openstack/compute/server.js, line 37, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/openstack/compute/server.js, line 38, character 7: Expected 'case' at column 5, not column 7. +case 'REBOOT': +pkgcloud/openstack/compute/server.js, line 39, character 7: Expected 'case' at column 5, not column 7. +case 'HARD_REBOOT': +pkgcloud/openstack/compute/server.js, line 40, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.reboot; +pkgcloud/openstack/compute/server.js, line 41, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/openstack/compute/server.js, line 42, character 7: Expected 'case' at column 5, not column 7. +case 'QUEUE_RESIZE': +pkgcloud/openstack/compute/server.js, line 43, character 7: Expected 'case' at column 5, not column 7. +case 'PREP_RESIZE': +pkgcloud/openstack/compute/server.js, line 44, character 7: Expected 'case' at column 5, not column 7. +case 'RESIZE': +pkgcloud/openstack/compute/server.js, line 45, character 7: Expected 'case' at column 5, not column 7. +case 'VERIFY_RESIZE': +pkgcloud/openstack/compute/server.js, line 46, character 7: Expected 'case' at column 5, not column 7. +case 'SHARE_IP': +pkgcloud/openstack/compute/server.js, line 47, character 7: Expected 'case' at column 5, not column 7. +case 'SHARE_IP_NO_CONFIG': +pkgcloud/openstack/compute/server.js, line 48, character 7: Expected 'case' at column 5, not column 7. +case 'DELETE_IP': +pkgcloud/openstack/compute/server.js, line 49, character 7: Expected 'case' at column 5, not column 7. +case 'PASSWORD': +pkgcloud/openstack/compute/server.js, line 50, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.updating; +pkgcloud/openstack/compute/server.js, line 51, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/openstack/compute/server.js, line 52, character 7: Expected 'case' at column 5, not column 7. +case 'RESCUE': +pkgcloud/openstack/compute/server.js, line 53, character 7: Expected 'case' at column 5, not column 7. +case 'ERROR': +pkgcloud/openstack/compute/server.js, line 54, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.error; +pkgcloud/openstack/compute/server.js, line 55, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/openstack/compute/server.js, line 56, character 7: Expected 'default' at column 5, not column 7. +default: +pkgcloud/openstack/compute/server.js, line 57, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.unknown; +pkgcloud/openstack/compute/server.js, line 58, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/openstack/compute/server.js, line 76, character 61: Expected an identifier and instead saw 'public' (a reserved word). +if (Object.keys(this.addresses).length && !this.addresses.public +pkgcloud/openstack/compute/server.js, line 77, character 5: Expected '&&' at column 7, not column 5. +&& !this.addresses.private) { +pkgcloud/openstack/compute/server.js, line 77, character 24: Expected an identifier and instead saw 'private' (a reserved word). +&& !this.addresses.private) { +pkgcloud/openstack/compute/server.js, line 83, character 47: Expected an identifier and instead saw 'interface' (a reserved word). +Object.keys(interfaces).map(function (interface) { +pkgcloud/openstack/compute/server.js, line 84, character 29: Expected an identifier and instead saw 'interface'. +return interfaces[interface].addr; +pkgcloud/openstack/compute/server.js, line 84, character 29: Stopping. (58% scanned). + +pkgcloud/openstack/compute/client/flavors.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/openstack/compute/client/flavors.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.openstack.compute; +pkgcloud/openstack/compute/client/flavors.js, line 22, character 30: Expected exactly one space between 'function' and '('. +exports.getFlavors = function(callback) { +pkgcloud/openstack/compute/client/flavors.js, line 32, character 7: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/openstack/compute/client/flavors.js, line 34, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/compute/client/flavors.js, line 34, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/openstack/compute/client/flavors.js, line 35, character 7: Expected 'return' at column 9, not column 7. +return callback(null, body.flavors.map(function (result) { +pkgcloud/openstack/compute/client/flavors.js, line 36, character 9: Expected 'return' at column 11, not column 9. +return new compute.Flavor(self, result); +pkgcloud/openstack/compute/client/flavors.js, line 37, character 7: Expected '}' at column 9, not column 7. +})); +pkgcloud/openstack/compute/client/flavors.js, line 38, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/compute/client/flavors.js, line 53, character 7: Expected 'flavorId' at column 5, not column 7. +flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; +pkgcloud/openstack/compute/client/flavors.js, line 62, character 7: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/openstack/compute/client/flavors.js, line 64, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/compute/client/flavors.js, line 64, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/openstack/compute/client/flavors.js, line 65, character 7: Expected 'return' at column 9, not column 7. +return callback(null, new compute.Flavor(self, body.flavor)); +pkgcloud/openstack/compute/client/flavors.js, line 66, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/openstack/compute/client/images.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.openstack.compute; +pkgcloud/openstack/compute/client/images.js, line 36, character 20: Unexpected space between '!' and 'body'. +if (!body || ! body.images) { +pkgcloud/openstack/compute/client/images.js, line 37, character 7: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/openstack/compute/client/images.js, line 39, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/compute/client/images.js, line 39, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/openstack/compute/client/images.js, line 40, character 7: Expected 'return' at column 9, not column 7. +return callback(null, body.images.map(function (result) { +pkgcloud/openstack/compute/client/images.js, line 41, character 9: Expected 'return' at column 11, not column 9. +return new compute.Image(self, result); +pkgcloud/openstack/compute/client/images.js, line 42, character 7: Expected '}' at column 9, not column 7. +})); +pkgcloud/openstack/compute/client/images.js, line 43, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/compute/client/images.js, line 58, character 7: Expected 'imageId' at column 5, not column 7. +imageId = image instanceof base.Image ? image.id : image; +pkgcloud/openstack/compute/client/images.js, line 67, character 7: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/openstack/compute/client/images.js, line 69, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/compute/client/images.js, line 69, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/openstack/compute/client/images.js, line 70, character 7: Expected 'return' at column 9, not column 7. +return callback(null, new compute.Image(self, body.image)); +pkgcloud/openstack/compute/client/images.js, line 71, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/compute/client/images.js, line 89, character 7: Expected 'serverId' at column 5, not column 7. +serverId; +pkgcloud/openstack/compute/client/images.js, line 95, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/openstack/compute/client/images.js, line 110, character 16: Expected exactly one space between 'function' and '('. +}, function(err, body) { +pkgcloud/openstack/compute/client/images.js, line 115, character 9: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/openstack/compute/client/images.js, line 117, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/compute/client/images.js, line 117, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/openstack/compute/client/images.js, line 118, character 9: Expected 'return' at column 11, not column 9. +return callback(null, new compute.Image(self, body.image)); +pkgcloud/openstack/compute/client/images.js, line 119, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/openstack/compute/client/images.js, line 137, character 7: Expected 'path' at column 5, not column 7. +path: urlJoin(_urlPrefix, imageId), +pkgcloud/openstack/compute/client/images.js, line 138, character 7: Expected 'method' at column 5, not column 7. +method: 'DELETE' +pkgcloud/openstack/compute/client/images.js, line 139, character 5: Expected '}' at column 3, not column 5. +}, +pkgcloud/openstack/compute/client/images.js, line 144, character 3: Expected '}' at column 5, not column 3. +}); +pkgcloud/openstack/compute/client/index.js, line 9, character 5: Expected 'openstack' at column 3, not column 5. +openstack = require('../../client'), +pkgcloud/openstack/compute/client/index.js, line 10, character 5: Expected 'ComputeClient' at column 3, not column 5. +ComputeClient = require('../computeClient').ComputeClient, +pkgcloud/openstack/compute/client/index.js, line 11, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/compute/client/servers.js, line 8, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/compute'), +pkgcloud/openstack/compute/client/servers.js, line 9, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/openstack/compute/client/servers.js, line 10, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/openstack/compute/client/servers.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/compute/client/servers.js, line 12, character 5: Expected 'util' at column 3, not column 5. +util = require('util'), +pkgcloud/openstack/compute/client/servers.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'), +pkgcloud/openstack/compute/client/servers.js, line 14, character 5: Expected 'Server' at column 3, not column 5. +Server = require('../server').Server, +pkgcloud/openstack/compute/client/servers.js, line 15, character 5: Expected 'compute' at column 3, not column 5. +compute = pkgcloud.providers.openstack.compute; +pkgcloud/openstack/compute/client/servers.js, line 30, character 35: Expected exactly one space between 'function' and '('. +exports._doServerAction = function(server, body, callback) { +pkgcloud/openstack/compute/client/servers.js, line 32, character 7: Expected 'serverId' at column 5, not column 7. +serverId = server instanceof Server ? server.id : server; +pkgcloud/openstack/compute/client/servers.js, line 34, character 7: Combine this with the previous 'var' statement. +var actionOptions = { +pkgcloud/openstack/compute/client/servers.js, line 62, character 7: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/openstack/compute/client/servers.js, line 80, character 7: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/openstack/compute/client/servers.js, line 82, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/compute/client/servers.js, line 82, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/openstack/compute/client/servers.js, line 83, character 7: Expected 'return' at column 9, not column 7. +return callback(null, body.servers.map(function (result) { +pkgcloud/openstack/compute/client/servers.js, line 84, character 9: Expected 'return' at column 11, not column 9. +return new compute.Server(self, result); +pkgcloud/openstack/compute/client/servers.js, line 85, character 7: Expected '}' at column 9, not column 7. +})); +pkgcloud/openstack/compute/client/servers.js, line 86, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/compute/client/servers.js, line 115, character 8: 'validateProperties' was used before it was defined. +if (!validateProperties(['flavor', 'image', 'name'], details, +pkgcloud/openstack/compute/client/servers.js, line 116, character 5: Expected 'options.%s is a required argument.' at column 7, not column 5. +'options.%s is a required argument.', callback)) { +pkgcloud/openstack/compute/client/servers.js, line 184, character 7: Expected 'serverId' at column 5, not column 7. +serverId = server instanceof base.Server ? server.id : server; +pkgcloud/openstack/compute/client/servers.js, line 193, character 7: Unexpected 'else' after 'return'. +return new Error('Unexpected empty response'); +pkgcloud/openstack/compute/client/servers.js, line 195, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/compute/client/servers.js, line 195, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/openstack/compute/client/servers.js, line 196, character 7: Expected 'callback' at column 9, not column 7. +callback(null, new compute.Server(self, body.server), res); +pkgcloud/openstack/compute/client/servers.js, line 197, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/compute/client/servers.js, line 351, character 7: Combine this with the previous 'var' statement. +var options = { +pkgcloud/openstack/compute/client/servers.js, line 379, character 15: Expected exactly one space between 'typeof' and '('. +if (typeof(options[item]) === 'undefined') { +pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'); +pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 42, character 41: Expected exactly one space between 'function' and '('. +exports.allocateNewFloatingIp = function(pool, callback) { +pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 58, character 41: Expected exactly one space between 'function' and '('. +return this._request(options, function(err, body) { +pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 74, character 33: Expected exactly one space between 'function' and '('. +exports.getFloatingIp = function(floatingIp, callback) { +pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 118, character 88: Expected ';' and instead saw 'return'. +var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp +pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 140, character 88: Expected ';' and instead saw 'return'. +var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp +pkgcloud/openstack/compute/client/extensions/index.js, line 14, character 26: Expected exactly one space between 'function' and '('. +getExtensions: function(callback) { +pkgcloud/openstack/compute/client/extensions/keys.js, line 45, character 3: Expected exactly one space between '}' and 'else'. +else if (options.key) { +pkgcloud/openstack/compute/client/extensions/keys.js, line 45, character 3: Expected 'else' at column 5, not column 3. +else if (options.key) { +pkgcloud/openstack/compute/client/extensions/networks-base.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/compute/client/extensions/networks-base.js, line 14, character 42: Expected exactly one space between 'function' and '('. +exports.createNetworkExtension = function(prefix) { +pkgcloud/openstack/compute/client/extensions/networks-base.js, line 66, character 102: Line too long. +* @param {String} [options.bridge_interface] The bridge is connected to this interface. +pkgcloud/openstack/compute/client/extensions/networks-base.js, line 239, character 4: Expected ';' and instead saw '}'. +} +pkgcloud/openstack/compute/client/extensions/networks.js, line 12, character 5: Expected 'networks' at column 3, not column 5. +networks = require('./networks-base'); +pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 9, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'), +pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 10, character 5: Expected 'async' at column 3, not column 5. +async = require('async'); +pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 48, character 29: ['security_group_rule'] is better written in dot notation. +: callback(null, body['security_group_rule'], res); +pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 61, character 28: Expected exactly one space between 'function' and '('. +exports.addRules = function(rules, callback) { +pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 64, character 40: Expected exactly one space between 'function' and '('. +async.forEachLimit(rules, 5, function(rule, next) { +pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 65, character 32: Expected exactly one space between 'function' and '('. +self.addRule(rule, function(err, rule) { +pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 74, character 14: Expected exactly one space between 'function' and '('. +}, function(err) { +pkgcloud/openstack/compute/client/extensions/security-groups.js, line 32, character 29: ['security_groups'] is better written in dot notation. +: callback(null, body['security_groups'], res); +pkgcloud/openstack/compute/client/extensions/security-groups.js, line 41, character 103: Line too long. +* @param {object|String} options The object (or securityGroup to generate) for the new group +pkgcloud/openstack/compute/client/extensions/security-groups.js, line 65, character 29: ['security_group'] is better written in dot notation. +: callback(null, body['security_group']); +pkgcloud/openstack/compute/client/extensions/servers.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'); +pkgcloud/openstack/compute/client/extensions/servers.js, line 25, character 5: Expected 'return' at column 3, not column 5. +return this._doServerAction(server, +pkgcloud/openstack/compute/client/extensions/servers.js, line 28, character 13: Expected 'return' at column 7, not column 13. +return callback(err); +pkgcloud/openstack/compute/client/extensions/servers.js, line 42, character 5: Expected 'return' at column 3, not column 5. +return this._doServerAction(server, +pkgcloud/openstack/compute/client/extensions/servers.js, line 45, character 13: Expected 'return' at column 7, not column 13. +return callback(err); +pkgcloud/openstack/compute/client/extensions/servers.js, line 46, character 9: Expected '}' at column 5, not column 9. +}); +pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'); +pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 14, character 5: Expected '_extension' at column 3, not column 5. +_extension = 'os-volume_attachments'; +pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 25, character 40: Expected exactly one space between 'function' and '('. +exports.getVolumeAttachments = function(server, callback) { +pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 49, character 7: Expected 'attachmentId' at column 5, not column 7. +attachmentId = (typeof attachment === 'object') ? attachment.id : attachment; +pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 70, character 32: Expected exactly one space between 'function' and '('. +exports.detachVolume = function(server, attachment, callback) { +pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 72, character 7: Expected 'attachmentId' at column 5, not column 7. +attachmentId = (typeof attachment === 'object') ? attachment.id : attachment; +pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 94, character 7: Expected 'volumeId' at column 5, not column 7. +volumeId = (typeof volume === 'object') ? volume.id : volume; +pkgcloud/openstack/context/identity.js, line 10, character 5: Expected 'events' at column 3, not column 5. +events = require('eventemitter2'), +pkgcloud/openstack/context/identity.js, line 11, character 5: Expected 'fs' at column 3, not column 5. +fs = require('fs'), +pkgcloud/openstack/context/identity.js, line 12, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/openstack/context/identity.js, line 13, character 5: Expected 'ServiceCatalog' at column 3, not column 5. +ServiceCatalog = require('./serviceCatalog').ServiceCatalog, +pkgcloud/openstack/context/identity.js, line 14, character 5: Expected 'svcCat' at column 3, not column 5. +svcCat = require('./serviceCatalog'), +pkgcloud/openstack/context/identity.js, line 15, character 5: Expected 'url' at column 3, not column 5. +url = require('url'), +pkgcloud/openstack/context/identity.js, line 16, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/openstack/context/identity.js, line 17, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/context/identity.js, line 18, character 5: Expected 'util' at column 3, not column 5. +util = require('util'), +pkgcloud/openstack/context/identity.js, line 19, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../pkgcloud'), +pkgcloud/openstack/context/identity.js, line 20, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'); +pkgcloud/openstack/context/identity.js, line 80, character 7: Combine this with the previous 'var' statement. +var authenticationOptions = { +pkgcloud/openstack/context/identity.js, line 103, character 3: Expected exactly one space between '}' and 'else'. +else if (self.options.tenantName) { +pkgcloud/openstack/context/identity.js, line 103, character 3: Expected 'else' at column 5, not column 3. +else if (self.options.tenantName) { +pkgcloud/openstack/context/identity.js, line 116, character 16: 'getError' was used before it was defined. +var err2 = getError(err, response, body); +pkgcloud/openstack/context/identity.js, line 132, character 7: 'getTenantId' was used before it was defined. +getTenantId(urlJoin(options.url || self.options.url, '/v2.0/tenants'), body.access.token.id); +pkgcloud/openstack/context/identity.js, line 134, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/context/identity.js, line 134, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/openstack/context/identity.js, line 135, character 7: Expected 'try' at column 9, not column 7. +try { +pkgcloud/openstack/context/identity.js, line 136, character 9: Expected 'self' at column 11, not column 9. +self._parseIdentityResponse(body); +pkgcloud/openstack/context/identity.js, line 137, character 9: Expected 'callback' at column 11, not column 9. +callback(); +pkgcloud/openstack/context/identity.js, line 138, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/openstack/context/identity.js, line 139, character 7: Expected exactly one space between '}' and 'catch'. +catch (e) { +pkgcloud/openstack/context/identity.js, line 139, character 7: Expected 'catch' at column 11, not column 7. +catch (e) { +pkgcloud/openstack/context/identity.js, line 140, character 9: Expected 'callback' at column 13, not column 9. +callback(e); +pkgcloud/openstack/context/identity.js, line 141, character 7: Expected '}' at column 11, not column 7. +} +pkgcloud/openstack/context/identity.js, line 142, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/openstack/context/identity.js, line 158, character 29: Use the || operator. +return callback(err ? err : new Error('Unable to find tenants')); +pkgcloud/openstack/context/identity.js, line 204, character 3: Expected exactly one space between '}' and 'else'. +else if (self.options.token && (self.options.tenantId || self.options.tenantName)) { +pkgcloud/openstack/context/identity.js, line 204, character 3: Expected 'else' at column 5, not column 3. +else if (self.options.token && (self.options.tenantId || self.options.tenantName)) { +pkgcloud/openstack/context/identity.js, line 230, character 1: Unexpected '(space)'. + +pkgcloud/openstack/context/identity.js, line 237, character 6: Expected 'self' at column 5, not column 6. +self.serviceCatalog = new ServiceCatalog(data.access.serviceCatalog); +pkgcloud/openstack/context/identity.js, line 247, character 5: Unexpected 'else' after 'return'. +return this.serviceCatalog.getServiceEndpointUrl(options); +pkgcloud/openstack/context/identity.js, line 249, character 3: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/context/identity.js, line 249, character 3: Expected 'else' at column 5, not column 3. +else { +pkgcloud/openstack/context/identity.js, line 250, character 5: Expected 'return' at column 7, not column 5. +return this.options.url; +pkgcloud/openstack/context/identity.js, line 251, character 3: Expected '}' at column 5, not column 3. +} +pkgcloud/openstack/context/service.js, line 64, character 32: 'matchRegion' was used before it was defined. +if (!endpoint.region || !matchRegion(endpoint.region, options.region)) { +pkgcloud/openstack/context/service.js, line 68, character 13: 'getUrl' was used before it was defined. +url = getUrl(endpoint); +pkgcloud/openstack/context/service.js, line 71, character 3: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/context/service.js, line 71, character 3: Expected 'else' at column 5, not column 3. +else { +pkgcloud/openstack/context/service.js, line 72, character 5: Expected '_' at column 7, not column 5. +_.each(self.endpoints, function(endpoint) { +pkgcloud/openstack/context/service.js, line 72, character 36: Expected exactly one space between 'function' and '('. +_.each(self.endpoints, function(endpoint) { +pkgcloud/openstack/context/service.js, line 74, character 7: Expected 'if' at column 9, not column 7. +if (url) { +pkgcloud/openstack/context/service.js, line 75, character 9: Expected 'return' at column 11, not column 9. +return; +pkgcloud/openstack/context/service.js, line 76, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/openstack/context/service.js, line 79, character 7: Expected 'if' at column 9, not column 7. +if (!endpoint.region) { +pkgcloud/openstack/context/service.js, line 80, character 9: Expected 'url' at column 11, not column 9. +url = getUrl(endpoint); +pkgcloud/openstack/context/service.js, line 80, character 15: 'getUrl' was used before it was defined. +url = getUrl(endpoint); +pkgcloud/openstack/context/service.js, line 81, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/openstack/context/service.js, line 82, character 5: Expected '}' at column 7, not column 5. +}); +pkgcloud/openstack/context/service.js, line 83, character 3: Expected '}' at column 5, not column 3. +} +pkgcloud/openstack/context/service.js, line 97, character 7: Expected 'options' at column 11, not column 7. +options.useInternal : false; +pkgcloud/openstack/context/service.js, line 102, character 9: Expected 'endpoint' at column 11, not column 9. +endpoint.adminURL : endpoint.publicURL); +pkgcloud/openstack/context/service.js, line 116, character 5: Unexpected 'else' after 'return'. +return true; +pkgcloud/openstack/context/service.js, line 118, character 3: Expected exactly one space between '}' and 'else'. +else if ((!a && b) || (a && !b)) { +pkgcloud/openstack/context/service.js, line 118, character 3: Expected 'else' at column 5, not column 3. +else if ((!a && b) || (a && !b)) { +pkgcloud/openstack/context/serviceCatalog.js, line 10, character 5: Expected 'Service' at column 3, not column 5. +Service = require('./service').Service, +pkgcloud/openstack/context/serviceCatalog.js, line 11, character 5: Expected 'async' at column 3, not column 5. +async = require('async'), +pkgcloud/openstack/context/serviceCatalog.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/context/serviceCatalog.js, line 37, character 58: Expected exactly one space between 'function' and '('. +ServiceCatalog.prototype.getServiceEndpointUrl = function(options) { +pkgcloud/openstack/context/serviceCatalog.js, line 40, character 7: Combine this with the previous 'var' statement. +var _endpoint = null; +pkgcloud/openstack/context/serviceCatalog.js, line 42, character 33: Expected exactly one space between 'function' and '('. +_.each(self.services, function(service) { +pkgcloud/openstack/context/serviceCatalog.js, line 51, character 5: Unexpected 'else' after 'return'. +return _endpoint; +pkgcloud/openstack/context/serviceCatalog.js, line 53, character 3: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/openstack/context/serviceCatalog.js, line 53, character 3: Expected 'else' at column 5, not column 3. +else { +pkgcloud/openstack/context/serviceCatalog.js, line 54, character 5: Expected 'throw' at column 7, not column 5. +throw new Error('Unable to find matching endpoint for requested service'); +pkgcloud/openstack/context/serviceCatalog.js, line 55, character 3: Expected '}' at column 5, not column 3. +} +pkgcloud/openstack/identity/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/identity/client/index.js, line 11, character 5: Expected 'openstack' at column 3, not column 5. +openstack = require('../../client'), +pkgcloud/openstack/identity/client/index.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/identity/client/index.js, line 80, character 114: Line too long. +* This is an administrative API that allows a admin to get detailed information about the specified tenant by ID +pkgcloud/openstack/identity/client/index.js, line 94, character 45: Use the || operator. +path: urlJoin('/v2.0/tenants', tenantId ? tenantId : '') +pkgcloud/openstack/network/network.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/network/network'), +pkgcloud/openstack/network/network.js, line 10, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/network.js, line 30, character 3: Expected 'tenant_id' at column 5, not column 3. +'tenant_id', 'subnets']); +pkgcloud/openstack/network/networkClient.js, line 9, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/networkClient.js, line 30, character 7: Expected exactly one space between 'if' and '('. +if(options.method === 'GET') { +pkgcloud/openstack/network/networkClient.js, line 40, character 7: Combine this with the previous 'var' statement. +var serviceUrl = options.serviceType ? this._identity.getServiceEndpointUrl({ +pkgcloud/openstack/network/port.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/network/port'), +pkgcloud/openstack/network/port.js, line 10, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/port.js, line 37, character 3: Expected 'network_id' at column 5, not column 3. +'network_id', 'tenant_id', 'extra_dhcp_opts', 'device_owner', +pkgcloud/openstack/network/port.js, line 38, character 3: Expected 'mac_address' at column 5, not column 3. +'mac_address', 'fixed_ips', 'id', 'security_groups', 'device_id']); +pkgcloud/openstack/network/subnet.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/network/subnet'), +pkgcloud/openstack/network/subnet.js, line 10, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/subnet.js, line 32, character 3: Expected 'tenant_id' at column 5, not column 3. +'tenant_id', 'gateway_ip', 'dns_nameservers']); +pkgcloud/openstack/network/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/network/client/index.js, line 10, character 5: Expected 'openstack' at column 3, not column 5. +openstack = require('../../client'), +pkgcloud/openstack/network/client/index.js, line 11, character 5: Expected 'NetworkClient' at column 3, not column 5. +NetworkClient = require('../networkClient').NetworkClient, +pkgcloud/openstack/network/client/index.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/client/networks.js, line 10, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/openstack/network/client/networks.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/openstack/network/client/networks.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/network/client/networks.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/client/networks.js, line 31, character 7: Combine this with the previous 'var' statement. +var getNetworkOpts = { +pkgcloud/openstack/network/client/networks.js, line 37, character 7: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/openstack/network/client/networks.js, line 39, character 5: Expected exactly one space between '}' and 'else'. +else if (!body || !body.networks || !(body.networks instanceof Array)) { +pkgcloud/openstack/network/client/networks.js, line 39, character 5: Expected 'else' at column 7, not column 5. +else if (!body || !body.networks || !(body.networks instanceof Array)) { +pkgcloud/openstack/network/client/networks.js, line 69, character 17: Missing space between '||' and '!'. +if (!body ||!body.network) { +pkgcloud/openstack/network/client/networks.js, line 88, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/openstack/network/client/networks.js, line 90, character 7: Combine this with the previous 'var' statement. +var createNetworkOpts = { +pkgcloud/openstack/network/client/networks.js, line 97, character 50: Missing space between ',' and 'body'. +this._request(createNetworkOpts, function (err,body) { +pkgcloud/openstack/network/client/networks.js, line 113, character 105: Line too long. +var self = this, networkToUpdate = network instanceof this.models.Network ? network.toJSON() : network; +pkgcloud/openstack/network/client/networks.js, line 114, character 7: Combine this with the previous 'var' statement. +var createNetworkOpts = { +pkgcloud/openstack/network/client/networks.js, line 122, character 50: Missing space between ',' and 'body'. +this._request(createNetworkOpts, function (err,body) { +pkgcloud/openstack/network/client/networks.js, line 142, character 36: Missing space between ',' and 'networkId'. +path: urlJoin('/v2.0/networks',networkId), +pkgcloud/openstack/network/client/ports.js, line 10, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/openstack/network/client/ports.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/openstack/network/client/ports.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/network/client/ports.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/client/ports.js, line 31, character 7: Combine this with the previous 'var' statement. +var getPortOpts = { +pkgcloud/openstack/network/client/ports.js, line 37, character 7: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/openstack/network/client/ports.js, line 39, character 5: Expected exactly one space between '}' and 'else'. +else if (!body || !body.ports || !(body.ports instanceof Array)) { +pkgcloud/openstack/network/client/ports.js, line 39, character 5: Expected 'else' at column 7, not column 5. +else if (!body || !body.ports || !(body.ports instanceof Array)) { +pkgcloud/openstack/network/client/ports.js, line 69, character 17: Missing space between '||' and '!'. +if (!body ||!body.port) { +pkgcloud/openstack/network/client/ports.js, line 88, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/openstack/network/client/ports.js, line 90, character 7: Combine this with the previous 'var' statement. +var createPortOpts = { +pkgcloud/openstack/network/client/ports.js, line 97, character 47: Missing space between ',' and 'body'. +this._request(createPortOpts, function (err,body) { +pkgcloud/openstack/network/client/ports.js, line 114, character 7: Combine this with the previous 'var' statement. +var createPortOpts = { +pkgcloud/openstack/network/client/ports.js, line 122, character 47: Missing space between ',' and 'body'. +this._request(createPortOpts, function (err,body) { +pkgcloud/openstack/network/client/ports.js, line 142, character 33: Missing space between ',' and 'portId'. +path: urlJoin('/v2.0/ports',portId), +pkgcloud/openstack/network/client/subnets.js, line 10, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/openstack/network/client/subnets.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/openstack/network/client/subnets.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/network/client/subnets.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/network/client/subnets.js, line 22, character 126: Line too long. +* @param {String} [options.marker] Marker value. Operation returns object names that are greater than this value. +pkgcloud/openstack/network/client/subnets.js, line 23, character 113: Line too long. +* @param {String} [options.end_marker] Operation returns object names that are less than this value. +pkgcloud/openstack/network/client/subnets.js, line 34, character 7: Combine this with the previous 'var' statement. +var getSubnetOpts = { +pkgcloud/openstack/network/client/subnets.js, line 35, character 26: Unexpected ','. +path: '/v2.0/subnets', +pkgcloud/openstack/network/client/subnets.js, line 36, character 4: Expected '}' at column 3, not column 4. +}; +pkgcloud/openstack/network/client/subnets.js, line 40, character 7: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/openstack/network/client/subnets.js, line 42, character 5: Expected exactly one space between '}' and 'else'. +else if (!body ||!body.subnets || !(body.subnets instanceof Array)) { +pkgcloud/openstack/network/client/subnets.js, line 42, character 5: Expected 'else' at column 7, not column 5. +else if (!body ||!body.subnets || !(body.subnets instanceof Array)) { +pkgcloud/openstack/network/client/subnets.js, line 42, character 22: Missing space between '||' and '!'. +else if (!body ||!body.subnets || !(body.subnets instanceof Array)) { +pkgcloud/openstack/network/client/subnets.js, line 91, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/openstack/network/client/subnets.js, line 93, character 7: Combine this with the previous 'var' statement. +var createSubnetOpts = { +pkgcloud/openstack/network/client/subnets.js, line 100, character 49: Missing space between ',' and 'body'. +this._request(createSubnetOpts, function (err,body) { +pkgcloud/openstack/network/client/subnets.js, line 117, character 7: Combine this with the previous 'var' statement. +var updateSubnetOpts = { +pkgcloud/openstack/network/client/subnets.js, line 125, character 49: Missing space between ',' and 'body'. +this._request(updateSubnetOpts, function (err,body) { +pkgcloud/openstack/network/client/subnets.js, line 145, character 35: Missing space between ',' and 'subnetId'. +path: urlJoin('/v2.0/subnets',subnetId), +pkgcloud/openstack/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/storage/container'), +pkgcloud/openstack/storage/container.js, line 11, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/storage/container.js, line 31, character 48: Expected ';' and instead saw 'this'. +this.count = details.count || this.count || 0 +pkgcloud/openstack/storage/file.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/storage/file'); +pkgcloud/openstack/storage/file.js, line 47, character 57: ['content_type'] is better written in dot notation. +this.contentType = details['content-type'] || details['content_type'] || null; +pkgcloud/openstack/storage/file.js, line 51, character 15: ['last_modified'] is better written in dot notation. +: details['last_modified'] +pkgcloud/openstack/storage/file.js, line 52, character 24: ['last_modified'] is better written in dot notation. +? new Date(details['last_modified']) +pkgcloud/openstack/storage/file.js, line 57, character 15: ['bytes'] is better written in dot notation. +: details['bytes'] +pkgcloud/openstack/storage/file.js, line 58, character 24: ['bytes'] is better written in dot notation. +? parseInt(details['bytes'], 10) +pkgcloud/openstack/storage/file.js, line 63, character 15: Expected a conditional expression and instead saw an assignment. +if (match = header.match(/x-object-meta-(\w+)/i)) { +pkgcloud/openstack/storage/storageClient.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/storage/storageClient.js, line 14, character 1: Expected an identifier and instead saw 'const'. +const CONTAINER_META_PREFIX = 'x-container-meta-'; +pkgcloud/openstack/storage/storageClient.js, line 14, character 1: Stopping. (14% scanned). + +pkgcloud/openstack/storage/client/containers.js, line 11, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/openstack/storage/client/containers.js, line 13, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/openstack/storage/client/containers.js, line 14, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/openstack/storage/client/containers.js, line 23, character 126: Line too long. +* @param {String} [options.marker] Marker value. Operation returns object names that are greater than this value. +pkgcloud/openstack/storage/client/containers.js, line 24, character 113: Line too long. +* @param {String} [options.end_marker] Operation returns object names that are less than this value. +pkgcloud/openstack/storage/client/containers.js, line 35, character 7: Combine this with the previous 'var' statement. +var getContainerOpts = { +pkgcloud/openstack/storage/client/containers.js, line 41, character 3: Unexpected ';'. +; +pkgcloud/openstack/storage/client/containers.js, line 41, character 3: Unexpected space between ';' and ';'. +; +pkgcloud/openstack/storage/client/containers.js, line 41, character 3: Expected ';' at column 5, not column 3. +; +pkgcloud/openstack/storage/client/containers.js, line 44, character 7: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/openstack/storage/client/containers.js, line 46, character 5: Expected exactly one space between '}' and 'else'. +else if (!body || !(body instanceof Array)) { +pkgcloud/openstack/storage/client/containers.js, line 46, character 5: Expected 'else' at column 7, not column 5. +else if (!body || !(body instanceof Array)) { +pkgcloud/openstack/storage/client/containers.js, line 47, character 49: Expected ';' and instead saw '}'. +return new Error('Malformed API Response') +pkgcloud/openstack/storage/client/containers.js, line 100, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/openstack/storage/client/containers.js, line 102, character 7: Combine this with the previous 'var' statement. +var createContainerOpts = { +pkgcloud/openstack/storage/client/containers.js, line 108, character 103: Line too long. +createContainerOpts.headers = self.serializeMetadata(self.CONTAINER_META_PREFIX, options.metadata); +pkgcloud/openstack/storage/client/containers.js, line 114, character 109: Line too long. +: callback(null, new self.models.Container(self, { name: containerName, metadata: options.metadata })); +pkgcloud/openstack/storage/client/containers.js, line 154, character 44: Expected exactly one space between 'function' and '('. +exports._updateContainerMetadata = function(container, metadata, callback) { +pkgcloud/openstack/storage/client/containers.js, line 161, character 7: Combine this with the previous 'var' statement. +var updateContainerOpts = { +pkgcloud/openstack/storage/client/containers.js, line 191, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/openstack/storage/client/containers.js, line 206, character 18: Expected exactly one space between 'function' and '('. +}, function(err) { +pkgcloud/openstack/storage/client/files.js, line 10, character 5: Expected 'filed' at column 3, not column 5. +filed = require('filed'), +pkgcloud/openstack/storage/client/files.js, line 11, character 5: Expected 'mime' at column 3, not column 5. +mime = require('mime'), +pkgcloud/openstack/storage/client/files.js, line 12, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/openstack/storage/client/files.js, line 13, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/openstack/storage/client/files.js, line 14, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/storage'), +pkgcloud/openstack/storage/client/files.js, line 15, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/openstack/storage/client/files.js, line 16, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'), +pkgcloud/openstack/storage/client/files.js, line 17, character 5: Expected 'storage' at column 3, not column 5. +storage = pkgcloud.providers.openstack.storage; +pkgcloud/openstack/storage/client/files.js, line 30, character 7: Expected 'fileName' at column 5, not column 7. +fileName = file instanceof this.models.File ? file.name : file; +pkgcloud/openstack/storage/client/files.js, line 33, character 7: Expected 'method' at column 5, not column 7. +method: 'DELETE', +pkgcloud/openstack/storage/client/files.js, line 34, character 7: Expected 'container' at column 5, not column 7. +container: containerName, +pkgcloud/openstack/storage/client/files.js, line 35, character 7: Expected 'path' at column 5, not column 7. +path: fileName +pkgcloud/openstack/storage/client/files.js, line 36, character 5: Expected '}' at column 3, not column 5. +}, function(err) { +pkgcloud/openstack/storage/client/files.js, line 36, character 16: Expected exactly one space between 'function' and '('. +}, function(err) { +pkgcloud/openstack/storage/client/files.js, line 37, character 7: Expected 'return' at column 5, not column 7. +return err +pkgcloud/openstack/storage/client/files.js, line 40, character 5: Expected '}' at column 3, not column 5. +} +pkgcloud/openstack/storage/client/files.js, line 41, character 3: Expected ')' at column 5, not column 3. +); +pkgcloud/openstack/storage/client/files.js, line 56, character 104: Line too long. +* @param {Stream} [options.stream] optionally explicitly provide the stream instead of pipe +pkgcloud/openstack/storage/client/files.js, line 79, character 7: Expected 'success' at column 5, not column 7. +success = callback ? onUpload : null, +pkgcloud/openstack/storage/client/files.js, line 80, character 7: Expected 'self' at column 5, not column 7. +self = this, +pkgcloud/openstack/storage/client/files.js, line 81, character 7: Expected 'apiStream' at column 5, not column 7. +apiStream, +pkgcloud/openstack/storage/client/files.js, line 82, character 7: Expected 'inputStream' at column 5, not column 7. +inputStream, +pkgcloud/openstack/storage/client/files.js, line 83, character 7: Expected 'uploadOptions' at column 5, not column 7. +uploadOptions; +pkgcloud/openstack/storage/client/files.js, line 101, character 3: Expected exactly one space between '}' and 'else'. +else if (options.stream) { +pkgcloud/openstack/storage/client/files.js, line 101, character 3: Expected 'else' at column 5, not column 3. +else if (options.stream) { +pkgcloud/openstack/storage/client/files.js, line 118, character 40: Expected exactly one space between 'function' and '('. +inputStream.on('response', function(response) { +pkgcloud/openstack/storage/client/files.js, line 122, character 8: Expected ';' and instead saw '}'. +} +pkgcloud/openstack/storage/client/files.js, line 151, character 104: Line too long. +* @param {Stream} [options.stream] optionally explicitly provide the stream instead of pipe +pkgcloud/openstack/storage/client/files.js, line 157, character 7: Expected 'success' at column 5, not column 7. +success = callback ? onDownload : null, +pkgcloud/openstack/storage/client/files.js, line 157, character 28: 'onDownload' was used before it was defined. +success = callback ? onDownload : null, +pkgcloud/openstack/storage/client/files.js, line 158, character 7: Expected 'container' at column 5, not column 7. +container = options.container, +pkgcloud/openstack/storage/client/files.js, line 159, character 7: Expected 'inputStream' at column 5, not column 7. +inputStream, +pkgcloud/openstack/storage/client/files.js, line 160, character 7: Expected 'apiStream' at column 5, not column 7. +apiStream; +pkgcloud/openstack/storage/client/files.js, line 166, character 12: 'onDownload' was used before it was defined. +function onDownload(err, body, res) { +pkgcloud/openstack/storage/client/files.js, line 170, character 11: Expected 'container' at column 9, not column 11. +container: container, +pkgcloud/openstack/storage/client/files.js, line 171, character 11: Expected 'name' at column 9, not column 11. +name: options.remote +pkgcloud/openstack/storage/client/files.js, line 172, character 9: Expected '}' at column 7, not column 9. +}))); +pkgcloud/openstack/storage/client/files.js, line 182, character 3: Expected exactly one space between '}' and 'else'. +else if (options.stream) { +pkgcloud/openstack/storage/client/files.js, line 182, character 3: Expected 'else' at column 5, not column 3. +else if (options.stream) { +pkgcloud/openstack/storage/client/files.js, line 210, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/openstack/storage/client/files.js, line 223, character 11: Expected 'container' at column 9, not column 11. +container: container, +pkgcloud/openstack/storage/client/files.js, line 224, character 11: Expected 'name' at column 9, not column 11. +name: file +pkgcloud/openstack/storage/client/files.js, line 225, character 9: Expected '}' at column 7, not column 9. +}))); +pkgcloud/openstack/storage/client/files.js, line 232, character 115: Line too long. +* @description get the list of files in a container. Returns at most 10,000 files if options.limit is unspecified. +pkgcloud/openstack/storage/client/files.js, line 238, character 105: Line too long. +* @param {String} [options.marker] the id of the first record to return in the current query +pkgcloud/openstack/storage/client/files.js, line 254, character 107: Line too long. +// Limit is specified and is >10k. Abstract the aggregation of files (cloudfiles returns max 10k at once) +pkgcloud/openstack/storage/client/files.js, line 255, character 7: Combine this with the previous 'var' statement. +var files = []; +pkgcloud/openstack/storage/client/files.js, line 258, character 7: Combine this with the previous 'var' statement. +var remainingLimit = options.limit; +pkgcloud/openstack/storage/client/files.js, line 261, character 7: Combine this with the previous 'var' statement. +var getFilesCallback = function(err, someFiles) { +pkgcloud/openstack/storage/client/files.js, line 261, character 34: Expected exactly one space between 'function' and '('. +var getFilesCallback = function(err, someFiles) { +pkgcloud/openstack/storage/client/files.js, line 261, character 34: Too many errors. (73% scanned). + +pkgcloud/openstack/storage/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/openstack/storage/client/index.js, line 11, character 5: Expected 'openstack' at column 3, not column 5. +openstack = require('../../client'), +pkgcloud/openstack/storage/client/index.js, line 12, character 5: Expected 'StorageClient' at column 3, not column 5. +StorageClient = require('../storageClient').StorageClient, +pkgcloud/openstack/storage/client/index.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/client.js, line 9, character 5: Expected 'identity' at column 3, not column 5. +identity = require('./identity'), +pkgcloud/rackspace/client.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../openstack/client'), +pkgcloud/rackspace/client.js, line 11, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/client.js, line 30, character 48: Expected exactly one space between 'function' and '('. +Client.prototype._getIdentityOptions = function() { +pkgcloud/rackspace/blockstorage/snapshot.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/base'), +pkgcloud/rackspace/blockstorage/snapshot.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/blockstorage/snapshot.js, line 23, character 39: ['display_name'] is better written in dot notation. +this.name = details.name || details['display_name']; +pkgcloud/rackspace/blockstorage/snapshot.js, line 24, character 53: ['display_description'] is better written in dot notation. +this.description = details.description || details['display_description']; +pkgcloud/rackspace/blockstorage/snapshot.js, line 25, character 28: ['created_at'] is better written in dot notation. +this.createdAt = details['created_at']; +pkgcloud/rackspace/blockstorage/snapshot.js, line 26, character 27: ['volume_id'] is better written in dot notation. +this.volumeId = details['volume_id']; +pkgcloud/rackspace/blockstorage/snapshot.js, line 32, character 108: Line too long. +return _.pick(this, ['id', 'status', 'name', 'description', 'createdAt', 'size', 'volumeId', 'metadata']); +pkgcloud/rackspace/blockstorage/volume.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/base'), +pkgcloud/rackspace/blockstorage/volume.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/blockstorage/volume.js, line 23, character 39: ['display_name'] is better written in dot notation. +this.name = details.name || details['display_name']; +pkgcloud/rackspace/blockstorage/volume.js, line 24, character 53: ['display_description'] is better written in dot notation. +this.description = details.description || details['display_description']; +pkgcloud/rackspace/blockstorage/volume.js, line 25, character 28: ['created_at'] is better written in dot notation. +this.createdAt = details['created_at']; +pkgcloud/rackspace/blockstorage/volume.js, line 27, character 51: ['volume_type'] is better written in dot notation. +this.volumeType = details.volumeType || details['volume_type']; +pkgcloud/rackspace/blockstorage/volume.js, line 29, character 51: ['snapshot_id'] is better written in dot notation. +this.snapshotId = details.snapshotId || details['snapshot_id']; +pkgcloud/rackspace/blockstorage/volumetype.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/base'), +pkgcloud/rackspace/blockstorage/volumetype.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/blockstorage/volumetype.js, line 26, character 39: Expected exactly one space between 'function' and '('. +VolumeType.prototype.toJSON = function() { +pkgcloud/rackspace/blockstorage/client/index.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/blockstorage/client/index.js, line 12, character 5: Expected 'rackspace' at column 3, not column 5. +rackspace = require('../../client'); +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 11, character 5: Expected 'Snapshot' at column 3, not column 5. +Snapshot = require('../snapshot').Snapshot, +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'); +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 28, character 7: Expected 'path' at column 5, not column 7. +path = _urlPrefix; +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 33, character 3: Expected exactly one space between '}' and 'else'. +else if ((typeof options === 'boolean') && (options)) { +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 33, character 3: Expected 'else' at column 5, not column 3. +else if ((typeof options === 'boolean') && (options)) { +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 43, character 7: Expected 'return' at column 9, not column 7. +return new Snapshot(self, data); +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 44, character 5: Expected '}' at column 7, not column 5. +}), res); +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 59, character 7: Expected 'snapshotId' at column 5, not column 7. +snapshotId = snapshot instanceof Snapshot ? snapshot.id : snapshot; +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 83, character 34: Expected exactly one space between 'function' and '('. +exports.createSnapshot = function(details, callback) { +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 86, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 99, character 40: Expected exactly one space between 'function' and '('. +self._request(createOptions, function(err, body, res) { +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 120, character 7: Expected 'snapshotId' at column 5, not column 7. +snapshotId = snapshot instanceof Snapshot ? snapshot.id : snapshot; +pkgcloud/rackspace/blockstorage/client/snapshots.js, line 122, character 7: Combine this with the previous 'var' statement. +var updateOptions = { +pkgcloud/rackspace/blockstorage/client/volumes.js, line 11, character 5: Expected 'Volume' at column 3, not column 5. +Volume = require('../volume').Volume, +pkgcloud/rackspace/blockstorage/client/volumes.js, line 12, character 5: Expected 'VolumeType' at column 3, not column 5. +VolumeType = require('../volumetype').VolumeType, +pkgcloud/rackspace/blockstorage/client/volumes.js, line 13, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'); +pkgcloud/rackspace/blockstorage/client/volumes.js, line 29, character 7: Expected 'path' at column 5, not column 7. +path = _urlPrefix; +pkgcloud/rackspace/blockstorage/client/volumes.js, line 34, character 3: Expected exactly one space between '}' and 'else'. +else if ((typeof options === 'boolean') && (options)) { +pkgcloud/rackspace/blockstorage/client/volumes.js, line 34, character 3: Expected 'else' at column 5, not column 3. +else if ((typeof options === 'boolean') && (options)) { +pkgcloud/rackspace/blockstorage/client/volumes.js, line 44, character 7: Expected 'return' at column 9, not column 7. +return new Volume(self, data); +pkgcloud/rackspace/blockstorage/client/volumes.js, line 45, character 5: Expected '}' at column 7, not column 5. +}), res); +pkgcloud/rackspace/blockstorage/client/volumes.js, line 88, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/rackspace/blockstorage/client/volumes.js, line 101, character 31: ['volume_type'] is better written in dot notation. +createOptions.body.volume['volume_type'] = +pkgcloud/rackspace/blockstorage/client/volumes.js, line 108, character 31: ['snapshot_id'] is better written in dot notation. +createOptions.body.volume['snapshot_id'] = options.snapshotId; +pkgcloud/rackspace/blockstorage/client/volumes.js, line 131, character 7: Expected 'volumeId' at column 5, not column 7. +volumeId = volume instanceof Volume ? volume.id : volume; +pkgcloud/rackspace/blockstorage/client/volumes.js, line 133, character 7: Combine this with the previous 'var' statement. +var updateOptions = { +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 11, character 5: Expected 'VolumeType' at column 3, not column 5. +VolumeType = require('../volumetype').VolumeType, +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'); +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 24, character 34: Expected exactly one space between 'function' and '('. +exports.getVolumeTypes = function(callback) { +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 31, character 29: ['volume_types'] is better written in dot notation. +: callback(null, body['volume_types'].map(function (data) { +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 32, character 7: Expected 'return' at column 9, not column 7. +return new VolumeType(self, data); +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 33, character 5: Expected '}' at column 7, not column 5. +}), res); +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 49, character 7: Combine this with the previous 'var' statement. +var self = this; +pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 55, character 50: ['volume_type'] is better written in dot notation. +: callback(null, new VolumeType(self, body['volume_type'])); +pkgcloud/rackspace/compute/server.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../openstack/compute/server'); +pkgcloud/rackspace/compute/client/index.js, line 9, character 5: Expected 'rackspace' at column 3, not column 5. +rackspace = require('../../client'), +pkgcloud/rackspace/compute/client/index.js, line 10, character 5: Expected 'ComputeClient' at column 3, not column 5. +ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, +pkgcloud/rackspace/compute/client/index.js, line 11, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 16, character 5: Expected '_extension' at column 3, not column 5. +_extension = 'os-virtual-interfacesv2'; +pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 50, character 7: Expected 'networkId' at column 5, not column 7. +networkId = (typeof network === 'object') ? network.id : network; +pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 79, character 7: Expected 'networkId' at column 5, not column 7. +networkId = (typeof network === 'object') ? network.id : network; +pkgcloud/rackspace/database/database.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../../core/base/model'); +pkgcloud/rackspace/database/database.js, line 25, character 29: Expected '{' and instead saw 'this'. +if (details.characterSet) this.characterSet = details.characterSet; +pkgcloud/rackspace/database/database.js, line 25, character 29: Expected 'this' at column 3, not column 29. +if (details.characterSet) this.characterSet = details.characterSet; +pkgcloud/rackspace/database/database.js, line 26, character 26: Expected '{' and instead saw 'this'. +if (details.collation) this.collation = details.collation; +pkgcloud/rackspace/database/database.js, line 26, character 26: Expected 'this' at column 3, not column 26. +if (details.collation) this.collation = details.collation; +pkgcloud/rackspace/database/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. +base = require('../../openstack/compute/flavor'); +pkgcloud/rackspace/database/instance.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../../core/base/model'), +pkgcloud/rackspace/database/instance.js, line 10, character 5: Expected 'computeStatus' at column 3, not column 5. +computeStatus = require('../../common/status').compute; +pkgcloud/rackspace/database/instance.js, line 30, character 36: Use the || operator. +details.state = (details.status) ? details.status : details.state; +pkgcloud/rackspace/database/instance.js, line 34, character 7: Expected 'case' at column 5, not column 7. +case 'PROVISIONING': +pkgcloud/rackspace/database/instance.js, line 35, character 7: Expected 'case' at column 5, not column 7. +case 'BUILD': +pkgcloud/rackspace/database/instance.js, line 36, character 7: Expected 'case' at column 5, not column 7. +case 'REBOOT': +pkgcloud/rackspace/database/instance.js, line 37, character 7: Expected 'case' at column 5, not column 7. +case 'RESIZE': +pkgcloud/rackspace/database/instance.js, line 38, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.provisioning; +pkgcloud/rackspace/database/instance.js, line 39, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/rackspace/database/instance.js, line 40, character 7: Expected 'case' at column 5, not column 7. +case 'RUNNING': +pkgcloud/rackspace/database/instance.js, line 41, character 7: Expected 'case' at column 5, not column 7. +case 'ACTIVE': // Change for keep consistency +pkgcloud/rackspace/database/instance.js, line 42, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.running; +pkgcloud/rackspace/database/instance.js, line 43, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/rackspace/database/instance.js, line 44, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPING': +pkgcloud/rackspace/database/instance.js, line 45, character 7: Expected 'case' at column 5, not column 7. +case 'STOPPED': +pkgcloud/rackspace/database/instance.js, line 46, character 7: Expected 'case' at column 5, not column 7. +case 'SHUTDOWN': +pkgcloud/rackspace/database/instance.js, line 47, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.stopped; +pkgcloud/rackspace/database/instance.js, line 48, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/rackspace/database/instance.js, line 49, character 7: Expected 'case' at column 5, not column 7. +case 'FAILED': +pkgcloud/rackspace/database/instance.js, line 50, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.error; +pkgcloud/rackspace/database/instance.js, line 51, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/rackspace/database/instance.js, line 52, character 7: Expected 'default' at column 5, not column 7. +default: +pkgcloud/rackspace/database/instance.js, line 53, character 9: Expected 'this' at column 7, not column 9. +this.status = this.STATUS.unknown; +pkgcloud/rackspace/database/instance.js, line 54, character 9: Expected 'break' at column 7, not column 9. +break; +pkgcloud/rackspace/database/user.js, line 9, character 5: Expected 'model' at column 3, not column 5. +model = require('../../core/base/model'); +pkgcloud/rackspace/database/client/databases.js, line 9, character 5: Expected 'Database' at column 3, not column 5. +Database = pkgcloud.providers.rackspace.database.Database, +pkgcloud/rackspace/database/client/databases.js, line 10, character 5: Expected 'Instance' at column 3, not column 5. +Instance = pkgcloud.providers.rackspace.database.Instance, +pkgcloud/rackspace/database/client/databases.js, line 11, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/rackspace/database/client/databases.js, line 12, character 5: Expected 'qs' at column 3, not column 5. +qs = require('querystring'); +pkgcloud/rackspace/database/client/databases.js, line 18, character 117: Line too long. +// #### options['instance'] {string | Object} The instance could be the ID or a instance of Instance class (required) +pkgcloud/rackspace/database/client/databases.js, line 19, character 101: Line too long. +// #### options['character_set'] {string} Should be a valid CharacterSet for mysql. Default to 'utf8' +pkgcloud/rackspace/database/client/databases.js, line 20, character 101: Line too long. +// #### options['collate'] {string} Should be a valid Collate for mysql. Default to 'utf8_general_ci' +pkgcloud/rackspace/database/client/databases.js, line 21, character 120: Line too long. +// For more info about character_set and collate for mysql see http://dev.mysql.com/doc/refman/5.6/en/charset-mysql.html +pkgcloud/rackspace/database/client/databases.js, line 32, character 16: ['name'] is better written in dot notation. +if (!options['name']) { +pkgcloud/rackspace/database/client/databases.js, line 38, character 16: ['instance'] is better written in dot notation. +if (!options['instance']) { +pkgcloud/rackspace/database/client/databases.js, line 46, character 106: Line too long. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 46, character 7: Combine this with the previous 'var' statement. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 46, character 28: ['instance'] is better written in dot notation. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 46, character 70: ['instance'] is better written in dot notation. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 46, character 95: ['instance'] is better written in dot notation. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 49, character 7: Combine this with the previous 'var' statement. +var reqDatabase = { name: options['name'] }; +pkgcloud/rackspace/database/client/databases.js, line 49, character 37: ['name'] is better written in dot notation. +var reqDatabase = { name: options['name'] }; +pkgcloud/rackspace/database/client/databases.js, line 52, character 26: ['character_set'] is better written in dot notation. +if (options && options['character_set']) { +pkgcloud/rackspace/database/client/databases.js, line 53, character 17: ['character_set'] is better written in dot notation. +reqDatabase['character_set'] = options['character_set']; +pkgcloud/rackspace/database/client/databases.js, line 53, character 44: ['character_set'] is better written in dot notation. +reqDatabase['character_set'] = options['character_set']; +pkgcloud/rackspace/database/client/databases.js, line 56, character 26: ['collate'] is better written in dot notation. +if (options && options['collate']) { +pkgcloud/rackspace/database/client/databases.js, line 57, character 17: ['collate'] is better written in dot notation. +reqDatabase['collate'] = options['collate']; +pkgcloud/rackspace/database/client/databases.js, line 57, character 38: ['collate'] is better written in dot notation. +reqDatabase['collate'] = options['collate']; +pkgcloud/rackspace/database/client/databases.js, line 60, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/rackspace/database/client/databases.js, line 77, character 117: Line too long. +// #### options['instance'] {string | Object} The instance could be the ID or a instance of Instance class (required) +pkgcloud/rackspace/database/client/databases.js, line 83, character 7: Expected 'completeUrl' at column 5, not column 7. +completeUrl = {}, +pkgcloud/rackspace/database/client/databases.js, line 84, character 7: Expected 'requestOptions' at column 5, not column 7. +requestOptions = {}; +pkgcloud/rackspace/database/client/databases.js, line 92, character 16: ['instance'] is better written in dot notation. +if (!options['instance']) { +pkgcloud/rackspace/database/client/databases.js, line 106, character 106: Line too long. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 106, character 7: Combine this with the previous 'var' statement. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 106, character 28: ['instance'] is better written in dot notation. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 106, character 70: ['instance'] is better written in dot notation. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 106, character 95: ['instance'] is better written in dot notation. +var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; +pkgcloud/rackspace/database/client/databases.js, line 128, character 107: Line too long. +// #### @database {string | Object} The database could be the ID or a instance of Database class (required) +pkgcloud/rackspace/database/client/databases.js, line 129, character 107: Line too long. +// #### @instance {string | Object} The instance could be the ID or a instance of Instance class (required) +pkgcloud/rackspace/database/client/databases.js, line 146, character 7: Combine this with the previous 'var' statement. +var databaseName = database instanceof Database ? database.name : database; +pkgcloud/rackspace/database/client/flavors.js, line 9, character 5: Expected 'Flavor' at column 3, not column 5. +Flavor = pkgcloud.providers.rackspace.database.Flavor; +pkgcloud/rackspace/database/client/flavors.js, line 28, character 11: Expected 'return' at column 9, not column 11. +return new Flavor(self, result); +pkgcloud/rackspace/database/client/flavors.js, line 29, character 9: Expected '}' at column 7, not column 9. +})); +pkgcloud/rackspace/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/database/client/index.js, line 10, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/rackspace/database/client/index.js, line 11, character 5: Expected 'rackspace' at column 3, not column 5. +rackspace = require('../../client'), +pkgcloud/rackspace/database/client/index.js, line 12, character 5: Expected 'auth' at column 3, not column 5. +auth = require('../../../common/auth.js'), +pkgcloud/rackspace/database/client/index.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/database/client/instances.js, line 9, character 5: Expected 'Flavor' at column 3, not column 5. +Flavor = pkgcloud.providers.rackspace.database.Flavor, +pkgcloud/rackspace/database/client/instances.js, line 10, character 5: Expected 'Instance' at column 3, not column 5. +Instance = pkgcloud.providers.rackspace.database.Instance, +pkgcloud/rackspace/database/client/instances.js, line 11, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/rackspace/database/client/instances.js, line 12, character 5: Expected 'qs' at column 3, not column 5. +qs = require('querystring'); +pkgcloud/rackspace/database/client/instances.js, line 18, character 118: Line too long. +// #### options['flavor'] {string | Object} Should be the HREF for the flavor or a instance of Flavor class (required) +pkgcloud/rackspace/database/client/instances.js, line 20, character 111: Line too long. +// #### options['databases'] {array} Array of strings with database names to create when the instance is ready. +pkgcloud/rackspace/database/client/instances.js, line 24, character 7: Expected 'flavorRef' at column 5, not column 7. +flavorRef, +pkgcloud/rackspace/database/client/instances.js, line 25, character 7: Expected 'size' at column 5, not column 7. +size; +pkgcloud/rackspace/database/client/instances.js, line 34, character 16: ['name'] is better written in dot notation. +if (!options['name']) { +pkgcloud/rackspace/database/client/instances.js, line 40, character 16: ['flavor'] is better written in dot notation. +if (!options['flavor']) { +pkgcloud/rackspace/database/client/instances.js, line 47, character 26: ['databases'] is better written in dot notation. +if (options && options['databases'] && +pkgcloud/rackspace/database/client/instances.js, line 48, character 22: ['databases'] is better written in dot notation. +typeof options['databases'] === 'array' && +pkgcloud/rackspace/database/client/instances.js, line 49, character 15: ['databases'] is better written in dot notation. +options['databases'].length > 0) { +pkgcloud/rackspace/database/client/instances.js, line 50, character 13: ['databases'] is better written in dot notation. +options['databases'].forEach(function (item, idx) { +pkgcloud/rackspace/database/client/instances.js, line 53, character 17: ['databases'] is better written in dot notation. +options['databases'][idx] = { +pkgcloud/rackspace/database/client/instances.js, line 63, character 26: ['size'] is better written in dot notation. +if (options && options['size']) { +pkgcloud/rackspace/database/client/instances.js, line 65, character 24: ['size'] is better written in dot notation. +if (typeof options['size'] !== 'number') { +pkgcloud/rackspace/database/client/instances.js, line 70, character 21: ['size'] is better written in dot notation. +size = (options['size'] > 0 && options['size'] < 9) ? options['size'] : 1; +pkgcloud/rackspace/database/client/instances.js, line 70, character 44: ['size'] is better written in dot notation. +size = (options['size'] > 0 && options['size'] < 9) ? options['size'] : 1; +pkgcloud/rackspace/database/client/instances.js, line 70, character 67: ['size'] is better written in dot notation. +size = (options['size'] > 0 && options['size'] < 9) ? options['size'] : 1; +pkgcloud/rackspace/database/client/instances.js, line 75, character 26: ['flavor'] is better written in dot notation. +if (options && options['flavor']) { +pkgcloud/rackspace/database/client/instances.js, line 76, character 25: ['flavor'] is better written in dot notation. +flavorRef = options['flavor'] instanceof Flavor ? options['flavor'].href : options['flavor']; +pkgcloud/rackspace/database/client/instances.js, line 76, character 63: ['flavor'] is better written in dot notation. +flavorRef = options['flavor'] instanceof Flavor ? options['flavor'].href : options['flavor']; +pkgcloud/rackspace/database/client/instances.js, line 76, character 88: ['flavor'] is better written in dot notation. +flavorRef = options['flavor'] instanceof Flavor ? options['flavor'].href : options['flavor']; +pkgcloud/rackspace/database/client/instances.js, line 79, character 7: Combine this with the previous 'var' statement. +var createOptions = { +pkgcloud/rackspace/database/client/instances.js, line 84, character 23: ['name'] is better written in dot notation. +name: options['name'], +pkgcloud/rackspace/database/client/instances.js, line 86, character 28: ['databases'] is better written in dot notation. +databases: options['databases'] || [], +pkgcloud/rackspace/database/client/instances.js, line 106, character 7: Expected 'completeUrl' at column 5, not column 7. +completeUrl = {}, +pkgcloud/rackspace/database/client/instances.js, line 107, character 7: Expected 'requestOptions' at column 5, not column 7. +requestOptions = {}; +pkgcloud/rackspace/database/client/instances.js, line 177, character 7: Combine this with the previous 'var' statement. +var instanceId = instance instanceof Instance ? instance.id : instance; +pkgcloud/rackspace/database/client/instances.js, line 201, character 7: Combine this with the previous 'var' statement. +var restartOptions = { +pkgcloud/rackspace/database/client/instances.js, line 250, character 7: Combine this with the previous 'var' statement. +var resizeOptions = { +pkgcloud/rackspace/database/client/instances.js, line 300, character 7: Combine this with the previous 'var' statement. +var resizeOptions = { +pkgcloud/rackspace/database/client/users.js, line 9, character 5: Expected 'Database' at column 3, not column 5. +Database = pkgcloud.providers.rackspace.database.Database, +pkgcloud/rackspace/database/client/users.js, line 10, character 5: Expected 'Instance' at column 3, not column 5. +Instance = pkgcloud.providers.rackspace.database.Instance, +pkgcloud/rackspace/database/client/users.js, line 11, character 5: Expected 'User' at column 3, not column 5. +User = pkgcloud.providers.rackspace.database.User, +pkgcloud/rackspace/database/client/users.js, line 12, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/rackspace/database/client/users.js, line 13, character 5: Expected 'async' at column 3, not column 5. +async = require('async'), +pkgcloud/rackspace/database/client/users.js, line 14, character 5: Expected 'qs' at column 3, not column 5. +qs = require('querystring'); +pkgcloud/rackspace/database/client/users.js, line 22, character 112: Line too long. +// #### options['databases'] {string | array} Name or instances of databases that the user can access (required) +pkgcloud/rackspace/database/client/users.js, line 23, character 134: Line too long. +// #### options['instance'] {string | Object} The instance could be the ID for the instance or a instance of Instance class (required) +pkgcloud/rackspace/database/client/users.js, line 26, character 7: Expected 'users' at column 5, not column 7. +users = [], +pkgcloud/rackspace/database/client/users.js, line 27, character 7: Expected 'regex' at column 5, not column 7. +regex = /^\s|^\?|^@|^#| \w* \d* |'|"|`|;|,|\\|\/| \s$/, +pkgcloud/rackspace/database/client/users.js, line 28, character 7: Expected 'instanceId' at column 5, not column 7. +instanceId, +pkgcloud/rackspace/database/client/users.js, line 29, character 7: Expected 'count' at column 5, not column 7. +count = 0; +pkgcloud/rackspace/database/client/users.js, line 40, character 10: Move 'var' declarations to the top of the function. +for (var i = 0; i < options.length; i++) { +pkgcloud/rackspace/database/client/users.js, line 40, character 10: Stopping. (14% scanned). + +pkgcloud/rackspace/dns/record.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/dns/record'), +pkgcloud/rackspace/dns/record.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/dns/status.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/base/model'); +pkgcloud/rackspace/dns/status.js, line 29, character 7: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/status.js, line 36, character 7: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/dns/status.js, line 38, character 5: Expected exactly one space between '}' and 'else'. +else if (!body) { +pkgcloud/rackspace/dns/status.js, line 38, character 5: Expected 'else' at column 7, not column 5. +else if (!body) { +pkgcloud/rackspace/dns/zone.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/dns/zone'), +pkgcloud/rackspace/dns/zone.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/dns/client/index.js, line 11, character 5: Expected 'rackspace' at column 3, not column 5. +rackspace = require('../../client'), +pkgcloud/rackspace/dns/client/index.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/dns/client/index.js, line 13, character 5: Expected 'Status' at column 3, not column 5. +Status = require('../status').Status, +pkgcloud/rackspace/dns/client/index.js, line 14, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/dns/client/index.js, line 43, character 42: Expected exactly one space between 'function' and '('. +Client.prototype._asyncRequest = function(options, callback) { +pkgcloud/rackspace/dns/client/records.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/dns/client/records.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/rackspace/dns/client/records.js, line 13, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/rackspace/dns/client/records.js, line 14, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'), +pkgcloud/rackspace/dns/client/records.js, line 15, character 5: Expected 'dns' at column 3, not column 5. +dns = pkgcloud.providers.rackspace.dns; +pkgcloud/rackspace/dns/client/records.js, line 18, character 5: Expected '_recordFragment' at column 3, not column 5. +_recordFragment = 'records'; +pkgcloud/rackspace/dns/client/records.js, line 30, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone; +pkgcloud/rackspace/dns/client/records.js, line 32, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/records.js, line 37, character 9: Expected exactly one space between 'if' and '('. +if(err) { +pkgcloud/rackspace/dns/client/records.js, line 38, character 9: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/dns/client/records.js, line 41, character 7: Expected exactly one space between '}' and 'else'. +else if (!body || !body.records) { +pkgcloud/rackspace/dns/client/records.js, line 41, character 7: Expected 'else' at column 9, not column 7. +else if (!body || !body.records) { +pkgcloud/rackspace/dns/client/records.js, line 42, character 9: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/rackspace/dns/client/records.js, line 45, character 7: Expected exactly one space between '}' and 'else'. +else{ +pkgcloud/rackspace/dns/client/records.js, line 45, character 7: Expected 'else' at column 9, not column 7. +else{ +pkgcloud/rackspace/dns/client/records.js, line 45, character 11: Expected exactly one space between 'else' and '{'. +else{ +pkgcloud/rackspace/dns/client/records.js, line 45, character 11: Missing space between 'else' and '{'. +else{ +pkgcloud/rackspace/dns/client/records.js, line 46, character 9: Expected 'return' at column 11, not column 9. +return callback(null, body.records.map(function (record) { +pkgcloud/rackspace/dns/client/records.js, line 47, character 11: Expected 'return' at column 13, not column 11. +return new dns.Record(self, record); +pkgcloud/rackspace/dns/client/records.js, line 48, character 9: Expected '}' at column 11, not column 9. +}), res); +pkgcloud/rackspace/dns/client/records.js, line 49, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/rackspace/dns/client/records.js, line 62, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone, +pkgcloud/rackspace/dns/client/records.js, line 63, character 9: Expected 'recordId' at column 7, not column 9. +recordId = record instanceof dns.Record ? record.id : record; +pkgcloud/rackspace/dns/client/records.js, line 65, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/records.js, line 94, character 9: Expected 'data' at column 7, not column 9. +data = [], +pkgcloud/rackspace/dns/client/records.js, line 95, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone; +pkgcloud/rackspace/dns/client/records.js, line 124, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/records.js, line 132, character 48: Expected exactly one space between 'function' and '('. +self._asyncRequest(requestOptions, function(err, result) { +pkgcloud/rackspace/dns/client/records.js, line 137, character 15: Expected 'return' at column 13, not column 15. +return new dns.Record(self, record); +pkgcloud/rackspace/dns/client/records.js, line 138, character 13: Expected '}' at column 11, not column 13. +}) +pkgcloud/rackspace/dns/client/records.js, line 151, character 50: Expected exactly one space between 'function' and '('. +this.createRecords(zone, [ record ], function(err, records) { +pkgcloud/rackspace/dns/client/records.js, line 167, character 9: Expected 'data' at column 7, not column 9. +data = [], +pkgcloud/rackspace/dns/client/records.js, line 168, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone; +pkgcloud/rackspace/dns/client/records.js, line 196, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/records.js, line 208, character 9: Expected 'return' at column 11, not column 9. +return new dns.Record(self, record); +pkgcloud/rackspace/dns/client/records.js, line 209, character 7: Expected '}' at column 9, not column 7. +})); +pkgcloud/rackspace/dns/client/records.js, line 222, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone, +pkgcloud/rackspace/dns/client/records.js, line 223, character 9: Expected 'recordId' at column 7, not column 9. +recordId = record instanceof dns.Record ? record.id : record; +pkgcloud/rackspace/dns/client/records.js, line 225, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/records.js, line 244, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone; +pkgcloud/rackspace/dns/client/records.js, line 246, character 9: Combine this with the previous 'var' statement. +var ids = _.map(records, function(record) { +pkgcloud/rackspace/dns/client/records.js, line 246, character 38: Expected exactly one space between 'function' and '('. +var ids = _.map(records, function(record) { +pkgcloud/rackspace/dns/client/records.js, line 253, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/dns/client/zones.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/rackspace/dns/client/zones.js, line 13, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/rackspace/dns/client/zones.js, line 14, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'), +pkgcloud/rackspace/dns/client/zones.js, line 15, character 5: Expected 'dns' at column 3, not column 5. +dns = pkgcloud.providers.rackspace.dns; +pkgcloud/rackspace/dns/client/zones.js, line 32, character 15: Expected exactly one space between 'typeof' and '('. +if (typeof(details) === 'function') { +pkgcloud/rackspace/dns/client/zones.js, line 37, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 48, character 9: Expected 'return' at column 11, not column 9. +return new dns.Zone(self, result); +pkgcloud/rackspace/dns/client/zones.js, line 49, character 7: Expected '}' at column 9, not column 7. +}), res); +pkgcloud/rackspace/dns/client/zones.js, line 63, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone; +pkgcloud/rackspace/dns/client/zones.js, line 89, character 9: Unexpected 'else' after 'return'. +return callback(err, zones[0]); +pkgcloud/rackspace/dns/client/zones.js, line 91, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/rackspace/dns/client/zones.js, line 91, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/rackspace/dns/client/zones.js, line 92, character 9: Expected 'return' at column 11, not column 9. +return callback(new Error('Unexpected error when creating single zone'), zones); +pkgcloud/rackspace/dns/client/zones.js, line 93, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/rackspace/dns/client/zones.js, line 108, character 9: Combine this with the previous 'var' statement. +var listOfZones = []; +pkgcloud/rackspace/dns/client/zones.js, line 111, character 30: Expected '{' and instead saw 'throw'. +if (!zone[required]) throw new Error('details.' + +pkgcloud/rackspace/dns/client/zones.js, line 111, character 30: Expected 'throw' at column 9, not column 30. +if (!zone[required]) throw new Error('details.' + +pkgcloud/rackspace/dns/client/zones.js, line 120, character 29: Expected exactly one space between 'typeof' and '('. +if (zone.ttl && typeof(zone.ttl) === 'number' && zone.ttl >= 300) { +pkgcloud/rackspace/dns/client/zones.js, line 131, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 144, character 7: Expected '}' at column 9, not column 7. +})); +pkgcloud/rackspace/dns/client/zones.js, line 163, character 31: Expected '{' and instead saw 'throw'. +if (!details[required]) throw new Error('details.' + +pkgcloud/rackspace/dns/client/zones.js, line 163, character 31: Expected 'throw' at column 7, not column 31. +if (!details[required]) throw new Error('details.' + +pkgcloud/rackspace/dns/client/zones.js, line 172, character 9: Combine this with the previous 'var' statement. +var importedZone = { +pkgcloud/rackspace/dns/client/zones.js, line 177, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 190, character 9: Expected 'return' at column 11, not column 9. +return new dns.Zone(self, domain); +pkgcloud/rackspace/dns/client/zones.js, line 191, character 7: Expected '}' at column 9, not column 7. +})[0]); +pkgcloud/rackspace/dns/client/zones.js, line 207, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 239, character 9: Combine this with the previous 'var' statement. +var data = []; +pkgcloud/rackspace/dns/client/zones.js, line 256, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 264, character 48: Expected exactly one space between 'function' and '('. +self._asyncRequest(requestOptions, function(err) { +pkgcloud/rackspace/dns/client/zones.js, line 290, character 15: Expected exactly one space between 'typeof' and '('. +if (typeof(options) === 'function') { +pkgcloud/rackspace/dns/client/zones.js, line 295, character 9: Combine this with the previous 'var' statement. +var zoneIds = []; +pkgcloud/rackspace/dns/client/zones.js, line 301, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/rackspace/dns/client/zones.js, line 301, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/rackspace/dns/client/zones.js, line 302, character 9: Expected 'zoneIds' at column 11, not column 9. +zoneIds.push(zone); +pkgcloud/rackspace/dns/client/zones.js, line 303, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/rackspace/dns/client/zones.js, line 306, character 9: Combine this with the previous 'var' statement. +var deleteSubzones = typeof options.deleteSubzones === 'boolean' +pkgcloud/rackspace/dns/client/zones.js, line 313, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 315, character 29: Expected exactly one space between 'function' and '('. +zoneIds.map(function(z) { return 'id=' + z }).join('&') + +pkgcloud/rackspace/dns/client/zones.js, line 315, character 51: Expected ';' and instead saw '}'. +zoneIds.map(function(z) { return 'id=' + z }).join('&') + +pkgcloud/rackspace/dns/client/zones.js, line 320, character 48: Expected exactly one space between 'function' and '('. +self._asyncRequest(requestOptions, function(err) { +pkgcloud/rackspace/dns/client/zones.js, line 335, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone; +pkgcloud/rackspace/dns/client/zones.js, line 337, character 15: Expected exactly one space between 'typeof' and '('. +if (typeof(options) === 'function') { +pkgcloud/rackspace/dns/client/zones.js, line 341, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 349, character 8: Expected ';' and instead saw '}'. +} +pkgcloud/rackspace/dns/client/zones.js, line 390, character 9: Expected 'zoneId' at column 7, not column 9. +zoneId = zone instanceof dns.Zone ? zone.id : zone; +pkgcloud/rackspace/dns/client/zones.js, line 392, character 15: Expected exactly one space between 'typeof' and '('. +if (typeof(options) === 'function') { +pkgcloud/rackspace/dns/client/zones.js, line 397, character 9: Combine this with the previous 'var' statement. +var requestOptions = { +pkgcloud/rackspace/dns/client/zones.js, line 406, character 5: Expected 'modifyEmailAddress' at column 7, not column 5. +'modifyEmailAddress', 'modifyRecordData'])); +pkgcloud/rackspace/dns/client/zones.js, line 406, character 5: Too many errors. (92% scanned). + +pkgcloud/rackspace/identity/rackspaceIdentity.js, line 16, character 20: 'RackspaceIdentity' was used before it was defined. +exports.Identity = RackspaceIdentity = function (options) { +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/loadbalancer/loadbalancer'), +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 45, character 42: Expected exactly one space between 'function' and '('. +LoadBalancer.prototype.refresh = function(callback) { +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 58, character 43: Expected exactly one space between 'function' and '('. +LoadBalancer.prototype.getNodes = function(callback) { +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 62, character 42: Expected exactly one space between 'function' and '('. +LoadBalancer.prototype.addNode = function(node, callback) { +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 66, character 43: Expected exactly one space between 'function' and '('. +LoadBalancer.prototype.addNodes = function(nodes, callback) { +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 70, character 45: Expected exactly one space between 'function' and '('. +LoadBalancer.prototype.updateNode = function(node, callback) { +pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 78, character 46: Expected exactly one space between 'function' and '('. +LoadBalancer.prototype.removeNodes = function(nodes, callback) { +pkgcloud/rackspace/loadbalancer/node.js, line 11, character 5: Expected 'base' at column 3, not column 5. +base = require('../../core/loadbalancer/node'), +pkgcloud/rackspace/loadbalancer/node.js, line 12, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/loadbalancer/node.js, line 25, character 7: Missing radix parameter. +? parseInt(details.loadBalancerId) : details.loadBalancerId; +pkgcloud/rackspace/loadbalancer/protocols.js, line 17, character 6: Expected 'DNS_UDP' at column 3, not column 6. +}, DNS_UDP: { +pkgcloud/rackspace/loadbalancer/virtualip.js, line 12, character 82: Expected ';' and instead saw '}'. +throw new Error('VirtualIp must be constructed with at-least basic details.') +pkgcloud/rackspace/loadbalancer/client/index.js, line 11, character 5: Expected 'rackspace' at column 3, not column 5. +rackspace = require('../../client'), +pkgcloud/rackspace/loadbalancer/client/index.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/loadbalancer/client/index.js, line 13, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 13, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 14, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'), +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 15, character 5: Expected 'lb' at column 3, not column 5. +lb = pkgcloud.providers.rackspace.loadbalancer; +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 31, character 9: Expected 'requestOptions' at column 7, not column 9. +requestOptions = { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 32, character 11: Expected 'path' at column 9, not column 11. +path: _urlPrefix +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 33, character 5: Expected '}' at column 7, not column 5. +}; +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 42, character 9: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 45, character 7: Expected exactly one space between '}' and 'else'. +else if (!body || !body.loadBalancers) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 45, character 7: Expected 'else' at column 9, not column 7. +else if (!body || !body.loadBalancers) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 46, character 9: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 49, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 49, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 50, character 9: Expected 'return' at column 11, not column 9. +return callback(null, body.loadBalancers.map(function (loadBalancer) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 51, character 11: Expected 'return' at column 13, not column 11. +return new lb.LoadBalancer(self, loadBalancer); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 52, character 9: Expected '}' at column 11, not column 9. +})); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 53, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 66, character 28: Expected exactly one space between 'function' and '('. +getLoadBalancer: function(loadBalancer, callback) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 68, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 75, character 9: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 78, character 7: Expected exactly one space between '}' and 'else'. +else if (!body || !body.loadBalancer) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 78, character 7: Expected 'else' at column 9, not column 7. +else if (!body || !body.loadBalancer) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 79, character 9: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 82, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 82, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 83, character 9: Expected 'return' at column 11, not column 9. +return callback(null, new lb.LoadBalancer(self, body.loadBalancer)); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 84, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 95, character 108: Line too long. +* http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/Create_Load_Balancer-d1e1635.html +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 110, character 31: Expected exactly one space between 'function' and '('. +createLoadBalancer: function(details, callback) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 112, character 9: Expected 'createOptions' at column 7, not column 9. +createOptions = { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 113, character 11: Expected 'path' at column 9, not column 11. +path: _urlPrefix, +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 114, character 11: Expected 'method' at column 9, not column 11. +method: 'POST', +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 115, character 11: Expected 'body' at column 9, not column 11. +body: { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 116, character 13: Expected 'name' at column 11, not column 13. +name: details.name, +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 117, character 13: Expected 'nodes' at column 11, not column 13. +nodes: details.nodes || [], +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 118, character 13: Expected 'protocol' at column 11, not column 13. +protocol: details.protocol ? details.protocol.name : '', +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 119, character 13: Expected 'port' at column 11, not column 13. +port: details.protocol ? details.protocol.port : '', +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 120, character 13: Expected 'virtualIps' at column 11, not column 13. +virtualIps: details.virtualIps +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 121, character 11: Expected '}' at column 9, not column 11. +} +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 122, character 9: Expected '}' at column 7, not column 9. +}; +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 129, character 9: Combine this with the previous 'var' statement. +var validationErrors = validateLbInputs(createOptions.body); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 129, character 28: 'validateLbInputs' was used before it was defined. +var validationErrors = validateLbInputs(createOptions.body); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 132, character 102: Line too long. +return callback(new Error('Errors validating inputs for createLoadBalancer', validationErrors)); +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 135, character 42: Expected exactly one space between 'function' and '('. +self._request(createOptions, function(err, body) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 182, character 31: Expected exactly one space between 'function' and '('. +deleteLoadBalancer: function(loadBalancer, callback) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 184, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 274, character 25: Expected exactly one space between 'function' and '('. +getSSLConfig: function(loadBalancer, callback) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 276, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 303, character 28: Expected exactly one space between 'function' and '('. +updateSSLConfig: function(loadBalancer, details, callback) { +pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 303, character 28: Too many errors. (25% scanned). + +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../../lib/pkgcloud'), +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 13, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'), +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 14, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'), +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 15, character 5: Expected 'lb' at column 3, not column 5. +lb = pkgcloud.providers.rackspace.loadbalancer; +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 31, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 38, character 9: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 41, character 7: Expected exactly one space between '}' and 'else'. +else if (!body || !body.nodes) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 41, character 7: Expected 'else' at column 9, not column 7. +else if (!body || !body.nodes) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 42, character 9: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 45, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 45, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 46, character 9: Expected 'return' at column 11, not column 9. +return callback(null, body.nodes.map(function (node) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 47, character 11: Expected 'return' at column 13, not column 11. +return new lb.Node(self, +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 48, character 13: Expected '_' at column 15, not column 13. +_.extend(node, { loadBalancerId: loadBalancerId })); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 49, character 9: Expected '}' at column 11, not column 9. +}), res); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 50, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 57, character 137: Line too long. +* @description add a node or array of nodes to the provided load balancer. Each of the addresses must be unique to this load balancer. +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 73, character 21: Expected exactly one space between 'function' and '('. +addNodes: function(loadBalancer, nodes, callback) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 75, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 82, character 9: Combine this with the previous 'var' statement. +var postOptions = { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 88, character 51: Expected exactly one space between 'function' and '('. +postOptions.body.nodes = _.map(nodes, function(node) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 94, character 9: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 97, character 7: Expected exactly one space between '}' and 'else'. +else if (!body || !body.nodes) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 97, character 7: Expected 'else' at column 9, not column 7. +else if (!body || !body.nodes) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 98, character 9: Unexpected 'else' after 'return'. +return callback(new Error('Unexpected empty response')); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 101, character 7: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 101, character 7: Expected 'else' at column 9, not column 7. +else { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 102, character 9: Expected 'return' at column 11, not column 9. +return callback(null, body.nodes.map(function (node) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 103, character 11: Expected 'return' at column 13, not column 11. +return new lb.Node(self, +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 104, character 13: Expected '_' at column 15, not column 13. +_.extend(node, { loadBalancerId: loadBalancerId })); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 105, character 9: Expected '}' at column 11, not column 9. +}), res); +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 106, character 7: Expected '}' at column 9, not column 7. +} +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 119, character 23: Expected exactly one space between 'function' and '('. +updateNode: function(loadBalancer, node, callback) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 121, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 150, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 152, character 9: Expected 'nodeId' at column 7, not column 9. +nodeId = +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 174, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 183, character 9: Combine this with the previous 'var' statement. +var list = nodes.map(function (item) { +pkgcloud/rackspace/loadbalancer/client/nodes.js, line 206, character 9: Expected 'loadBalancerId' at column 7, not column 9. +loadBalancerId = +pkgcloud/rackspace/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. +base = require('../../openstack/storage/container'), +pkgcloud/rackspace/storage/container.js, line 11, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/storage/client/archive.js, line 10, character 5: Expected 'filed' at column 3, not column 5. +filed = require('filed'); +pkgcloud/rackspace/storage/client/archive.js, line 20, character 27: Expected exactly one space between 'function' and '('. +exports.extract = function(options, callback) { +pkgcloud/rackspace/storage/client/archive.js, line 22, character 1: Unexpected '(space)'. + +pkgcloud/rackspace/storage/client/archive.js, line 27, character 1: Unexpected '(space)'. + +pkgcloud/rackspace/storage/client/archive.js, line 40, character 1: Unexpected '(space)'. + +pkgcloud/rackspace/storage/client/archive.js, line 45, character 3: Expected exactly one space between '}' and 'else'. +else if (options.stream) { +pkgcloud/rackspace/storage/client/archive.js, line 45, character 3: Expected 'else' at column 5, not column 3. +else if (options.stream) { +pkgcloud/rackspace/storage/client/archive.js, line 50, character 40: Expected exactly one space between 'function' and '('. +inputStream.on('response', function(response) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 21, character 105: Line too long. +* @param {String} [options.marker] the id of the first record to return in the current query +pkgcloud/rackspace/storage/client/cdn-containers.js, line 32, character 7: Combine this with the previous 'var' statement. +var getContainerOpts = { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 41, character 7: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 43, character 5: Expected exactly one space between '}' and 'else'. +else if (!body || !(body instanceof Array)) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 43, character 5: Expected 'else' at column 7, not column 5. +else if (!body || !(body instanceof Array)) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 44, character 49: Expected ';' and instead saw '}'. +return new Error('Malformed API Response') +pkgcloud/rackspace/storage/client/cdn-containers.js, line 48, character 7: Unexpected 'else' after 'return'. +return callback(null, body.map(function (container) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 52, character 5: Expected exactly one space between '}' and 'else'. +else { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 52, character 5: Expected 'else' at column 7, not column 5. +else { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 53, character 7: Expected 'var' at column 9, not column 7. +var containers = []; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 55, character 7: Expected 'async' at column 9, not column 7. +async.forEachLimit(body, 10, function (c, next) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 56, character 9: Expected 'var' at column 11, not column 9. +var container = new self.models.Container(self, c); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 58, character 9: Expected 'containers' at column 11, not column 9. +containers.push(container); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 59, character 9: Expected 'container' at column 11, not column 9. +container.refreshCdnDetails(function (err) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 60, character 11: Expected 'if' at column 13, not column 11. +if (err) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 61, character 13: Expected 'return' at column 15, not column 13. +return next(err); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 62, character 11: Expected '}' at column 13, not column 11. +} +pkgcloud/rackspace/storage/client/cdn-containers.js, line 63, character 11: Expected 'next' at column 13, not column 11. +next(); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 64, character 9: Expected '}' at column 11, not column 9. +}) +pkgcloud/rackspace/storage/client/cdn-containers.js, line 64, character 11: Expected ';' and instead saw '}'. +}) +pkgcloud/rackspace/storage/client/cdn-containers.js, line 65, character 7: Expected '}' at column 9, not column 7. +}, function (err) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 66, character 9: Expected 'callback' at column 11, not column 9. +callback(err, containers); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 67, character 7: Expected '}' at column 9, not column 7. +}); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 68, character 5: Expected '}' at column 7, not column 5. +} +pkgcloud/rackspace/storage/client/cdn-containers.js, line 117, character 105: Line too long. +* @param {String} [options.marker] the id of the first record to return in the current query +pkgcloud/rackspace/storage/client/cdn-containers.js, line 118, character 108: Line too long. +* @param {String} [options.end_marker] the id of the last record to return in the current query +pkgcloud/rackspace/storage/client/cdn-containers.js, line 119, character 102: Line too long. +* @param {boolean} [options.enabled_only] only get containers which are cdn enabled = true +pkgcloud/rackspace/storage/client/cdn-containers.js, line 130, character 7: Combine this with the previous 'var' statement. +var getContainerOpts = { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 139, character 25: ['enabled_only'] is better written in dot notation. +getContainerOpts.qs['enabled_only'] = options.cdnOnly; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 150, character 7: Expected 'container' at column 9, not column 7. +container.cdnEnabled = container.cdn_enabled == 'true'; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 150, character 52: Expected '===' and instead saw '=='. +container.cdnEnabled = container.cdn_enabled == 'true'; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 151, character 7: Expected 'container' at column 9, not column 7. +container.logRetention = container.log_retention == 'true'; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 151, character 56: Expected '===' and instead saw '=='. +container.logRetention = container.log_retention == 'true'; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 152, character 7: Expected 'container' at column 9, not column 7. +container.cdnUri = container.cdn_uri; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 153, character 7: Expected 'container' at column 9, not column 7. +container.cdnSslUri = container.cdn_ssl_uri; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 155, character 7: Expected 'return' at column 9, not column 7. +return new self.models.Container(self, container); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 156, character 5: Expected '}' at column 7, not column 5. +})); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 172, character 51: Expected exactly one space between 'function' and '('. +this._getCdnContainerDetails(container, function(err, details) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 185, character 101: Line too long. +* @param {object|boolean} options an object with options, or boolean to just enable/disable +pkgcloud/rackspace/storage/client/cdn-containers.js, line 192, character 7: Expected 'containerName' at column 5, not column 7. +containerName = container instanceof self.models.Container ? container.name : container, +pkgcloud/rackspace/storage/client/cdn-containers.js, line 193, character 7: Expected 'enabled' at column 5, not column 7. +enabled = typeof options === 'boolean' ? options : options.enabled; +pkgcloud/rackspace/storage/client/cdn-containers.js, line 201, character 7: Combine this with the previous 'var' statement. +var cdnOpts = { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 214, character 34: Expected exactly one space between 'function' and '('. +self._request(cdnOpts, function(err) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 219, character 46: Expected exactly one space between 'function' and '('. +self.getContainer(containerName, function(err, container) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 243, character 7: Combine this with the previous 'var' statement. +var cdnOpts = { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 280, character 43: Expected exactly one space between 'function' and '('. +exports._getCdnContainerDetails = function(container, callback) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 289, character 16: Confusing use of '!'. +if (err && !(err.statusCode === 404)) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 290, character 7: Unexpected 'else' after 'return'. +return callback(err); +pkgcloud/rackspace/storage/client/cdn-containers.js, line 292, character 5: Expected exactly one space between '}' and 'else'. +else if (err) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 292, character 5: Expected 'else' at column 7, not column 5. +else if (err) { +pkgcloud/rackspace/storage/client/cdn-containers.js, line 292, character 5: Too many errors. (92% scanned). + +pkgcloud/rackspace/storage/client/files.js, line 10, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/rackspace/storage/client/files.js, line 11, character 5: Expected 'utile' at column 3, not column 5. +utile = require('utile'), +pkgcloud/rackspace/storage/client/files.js, line 12, character 5: Expected 'base' at column 3, not column 5. +base = require('../../../core/storage'), +pkgcloud/rackspace/storage/client/files.js, line 13, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/rackspace/storage/client/files.js, line 14, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/rackspace/storage/client/files.js, line 32, character 3: Expected exactly one space between '}' and 'else'. +else if (typeof emails === 'string') { +pkgcloud/rackspace/storage/client/files.js, line 32, character 3: Expected 'else' at column 5, not column 3. +else if (typeof emails === 'string') { +pkgcloud/rackspace/storage/client/files.js, line 36, character 7: Combine this with the previous 'var' statement. +var purgeOptions = { +pkgcloud/rackspace/storage/client/files.js, line 49, character 7: Expected 'return' at column 5, not column 7. +return err +pkgcloud/rackspace/storage/client/files.js, line 52, character 5: Expected '}' at column 3, not column 5. +} +pkgcloud/rackspace/storage/client/files.js, line 53, character 3: Expected ')' at column 5, not column 3. +); +pkgcloud/rackspace/storage/client/index.js, line 9, character 5: Expected 'rackspace' at column 3, not column 5. +rackspace = require('../../client'), +pkgcloud/rackspace/storage/client/index.js, line 10, character 5: Expected 'StorageClient' at column 3, not column 5. +StorageClient = require('../../../openstack/storage/storageClient').StorageClient, +pkgcloud/rackspace/storage/client/index.js, line 11, character 5: Expected '_' at column 3, not column 5. +_ = require('underscore'); +pkgcloud/redistogo/database/client/index.js, line 9, character 5: Expected 'request' at column 3, not column 5. +request = require('request'), +pkgcloud/redistogo/database/client/index.js, line 10, character 5: Expected 'pkgcloud' at column 3, not column 5. +pkgcloud = require('../../../../pkgcloud'), +pkgcloud/redistogo/database/client/index.js, line 11, character 5: Expected 'errs' at column 3, not column 5. +errs = require('errs'); +pkgcloud/redistogo/database/client/index.js, line 36, character 29: Expected '===' and instead saw '=='. +if (response.statusCode == 401 || response.statusCode == 403) { +pkgcloud/redistogo/database/client/index.js, line 36, character 59: Expected '===' and instead saw '=='. +if (response.statusCode == 401 || response.statusCode == 403) { +pkgcloud/redistogo/database/client/index.js, line 49, character 7: Unexpected 'else' after 'return'. +return callback(null, database); +pkgcloud/redistogo/database/client/index.js, line 68, character 14: ['plan'] is better written in dot notation. +if (!attrs['plan']) { +pkgcloud/redistogo/database/client/index.js, line 69, character 11: ['plan'] is better written in dot notation. +attrs['plan'] = 'nano'; +pkgcloud/redistogo/database/client/index.js, line 96, character 7: Expected 'path' at column 5, not column 7. +path = '/instances', +pkgcloud/redistogo/database/client/index.js, line 97, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/redistogo/database/client/index.js, line 122, character 7: Expected 'path' at column 5, not column 7. +path = '/instances/' + id, +pkgcloud/redistogo/database/client/index.js, line 123, character 7: Expected 'self' at column 5, not column 7. +self = this; +pkgcloud/redistogo/database/client/index.js, line 140, character 124: Line too long. +uri: 'redis://nodejitsu:' + response.password + '@' + response.label.split('-')[0] + '.redistogo.com:' + response.port, +pkgcloud/telefonica/compute/client.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. +urlJoin = require('url-join'), +pkgcloud/telefonica/compute/client.js, line 10, character 5: Expected 'joyent' at column 3, not column 5. +joyent = require('../../joyent/compute'); +pkgcloud/telefonica/compute/client.js, line 29, character 5: Expected 'options' at column 9, not column 5. +options : options.path)); +1622 errors diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 138a66d31..81615ef2e 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -87,6 +87,8 @@ exports.createNetwork = function (options, callback) { var network = typeof options === 'object' ? options : { 'name' : options}, self = this; + network = _convertNetworkToWireFormat(network); + var createNetworkOpts = { method: 'POST', path: '/v2.0/networks', @@ -110,16 +112,19 @@ exports.createNetwork = function (options, callback) { * @param callback */ exports.updateNetwork = function (network, callback) { - var self = this, networkToUpdate = network instanceof this.models.Network ? network.toJSON() : network; - var createNetworkOpts = { + var self = this, + networkId = network.id, + networkToUpdate = _convertNetworkToWireFormat(network); + + var updateNetworkOpts = { method: 'PUT', - path: urlJoin('/v2.0/networks', networkToUpdate.id), + path: urlJoin('/v2.0/networks', networkId), contentType: 'application/json', body: { 'network' : networkToUpdate} }; - self.emit('log::trace', 'Creating network', network); - this._request(createNetworkOpts, function (err,body) { + self.emit('log::trace', 'Updating network', networkId); + this._request(updateNetworkOpts, function (err,body) { return err ? callback(err) : callback(null, new self.models.Network(self, body.network)); @@ -148,3 +153,19 @@ exports.destroyNetwork = function (network, callback) { callback(null, networkId); }); }; + +/** + * _convertNetworkToWireFormat + * + * @description convert Network instance into its wire representation. + * + * @param {object} details the Network instance. + */ +_convertNetworkToWireFormat = function (details){ + var wireFormat = {}; + wireFormat.admin_state_up = details.admin_state_up || details.adminStateUp; + wireFormat.name = details.name; + wireFormat.shared = details.shared; + wireFormat.tenant_id = details.tenantId || details.tenant_id; + return wireFormat; +}; diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index 56914c2e7..dd9e13ba0 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -87,6 +87,10 @@ exports.createPort = function (options, callback) { var port = typeof options === 'object' ? options : { 'name' : options}, self = this; + if(port instanceof this.models.Port) { + port = _convertPortToWireFormat(port); + } + var createPortOpts = { method: 'POST', path: '/v2.0/ports', @@ -110,16 +114,22 @@ exports.createPort = function (options, callback) { * @param callback */ exports.updatePort = function (port, callback) { - var self = this, portToUpdate = port instanceof this.models.Port ? port.toJSON() : port; - var createPortOpts = { + var self = this, + portId = port.id; + + if(port instanceof this.models.Port) { + port = _convertPortToWireFormat(port); + } + + var updatePortOpts = { method: 'PUT', - path: urlJoin('/v2.0/ports', portToUpdate.id), + path: urlJoin('/v2.0/ports', portId), contentType: 'application/json', - body: { 'port' : portToUpdate} + body: { 'port' : port} }; - self.emit('log::trace', 'Creating port', port); - this._request(createPortOpts, function (err,body) { + self.emit('log::trace', 'Updating port', port); + this._request(updatePortOpts, function (err,body) { return err ? callback(err) : callback(null, new self.models.Port(self, body.port)); @@ -148,3 +158,23 @@ exports.destroyPort = function (port, callback) { callback(null, portId); }); }; + +/** + * _convertPortToWireFormat + * + * @description convert Port instance into its wire representation. + * + * @param {object} details the Port instance. + */ +_convertPortToWireFormat = function (details){ + var wireFormat = {}; + wireFormat.status = details.status; + wireFormat.name = details.name; + wireFormat.admin_state_up = details.admin_state_up || details.adminStateUp; + wireFormat.tenant_id = details.tenant_id || details.tenantId; + wireFormat.mac_address = details.mac_address || details.macAddress; + wireFormat.fixed_ips = details.fixed_ips || details.fixedIps; + wireFormat.security_groups = details.security_groups || details.securityGroups; + wireFormat.network_id = details.network_id || details.networkId; + return wireFormat; +}; diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index e5ee3204f..3b31d9317 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -90,6 +90,8 @@ exports.createSubnet = function (options, callback) { var subnet = typeof options === 'object' ? options : { 'name' : options}, self = this; + subnet = _convertSubnetToWireFormat(subnet); + var createSubnetOpts = { method: 'POST', path: '/v2.0/subnets', @@ -113,15 +115,18 @@ exports.createSubnet = function (options, callback) { * @param callback */ exports.updateSubnet = function (subnet, callback) { - var self = this, subnetToUpdate = subnet instanceof this.models.Subnet ? subnet.toJSON() : subnet; + var self = this, + subnetId = subnet.id, + subnetToUpdate = _convertSubnetToWireFormat(subnet); + var updateSubnetOpts = { method: 'PUT', - path: urlJoin('/v2.0/subnets', subnetToUpdate.id), + path: urlJoin('/v2.0/subnets', subnetId), contentType: 'application/json', body: { 'subnet' : subnetToUpdate} }; - self.emit('log::trace', 'Updating subnet', subnet); + self.emit('log::trace', 'Updating subnet', subnetId); this._request(updateSubnetOpts, function (err,body) { return err ? callback(err) @@ -151,3 +156,25 @@ exports.destroySubnet = function (subnet, callback) { callback(null, subnetId); }); }; + +/** + * _convertSubnetToWireFormat + * + * @description convert Subnet instance into its wire representation. + * + * @param {object} details the Subnet instance. + */ +_convertSubnetToWireFormat = function (details){ + + var wireFormat = {}; + wireFormat.name = details.name; + wireFormat.network_id = details.networkId || details.network_id; + wireFormat.tenant_id = details.tenantId || details.tenant_id; + wireFormat.allocation_pools = details.allocationPools || details.allocation_pools; + wireFormat.gateway_ip = details.gatewayIp || details.gateway_ip; + wireFormat.ip_version = details.ipVersion || details.ip_version; + wireFormat.cidr = details.cidr; + wireFormat.enable_dhcp = details.enable_dhcp == null ? details.enableDhcp : details.enable_dhcp; + + return wireFormat; +}; diff --git a/lib/pkgcloud/openstack/network/network.js b/lib/pkgcloud/openstack/network/network.js index c445d25a4..c4a03ae44 100644 --- a/lib/pkgcloud/openstack/network/network.js +++ b/lib/pkgcloud/openstack/network/network.js @@ -18,14 +18,14 @@ utile.inherits(Network, base.Network); Network.prototype._setProperties = function (details) { this.name = details.name || this.name; this.status = details.status || this.status; - this.admin_state_up = details.admin_state_up || this.admin_state_up; + this.adminStateUp = details.admin_state_up || this.adminStateUp; this.id = details.id || this.id; this.shared = details.shared || this.shared || 0; - this.tenant_id = details.tenant_id || this.tenant_id; + this.tenantId = details.tenant_id || this.tenantId; this.subnets = details.subnets || this.subnets; }; Network.prototype.toJSON = function () { - return _.pick(this, ['name', 'id', 'status', 'shared', - 'tenant_id', 'subnets']); + return _.pick(this, ['name', 'id', 'adminStateUp', 'status', 'shared', + 'tenantId', 'subnets']); }; diff --git a/lib/pkgcloud/openstack/network/port.js b/lib/pkgcloud/openstack/network/port.js index 2a334a6cf..f7f99f015 100644 --- a/lib/pkgcloud/openstack/network/port.js +++ b/lib/pkgcloud/openstack/network/port.js @@ -19,21 +19,21 @@ Port.prototype._setProperties = function (details) { this.status = details.status || this.status; this.name = details.name || this.name; - this.allowed_address_pairs = details.allowed_address_pairs || this.allowed_address_pairs; - this.admin_state_up = details.admin_state_up || this.admin_state_up; - this.network_id = details.network_id || this.network_id; - this.tenant_id = details.tenant_id || this.tenant_id; - this.extra_dhcp_opts = details.extra_dhcp_opts || this.extra_dhcp_opts; - this.device_owner = details.device_owner || this.device_owner; - this.mac_address = details.mac_address || this.mac_address; - this.fixed_ips = details.fixed_ips || this.fixed_ips; + this.allowedAddressPairs = details.allowed_address_pairs || this.allowedAddressPairs; + this.adminStateUp = details.admin_state_up || this.adminStateUp; + this.networkId = details.network_id || this.networkId; + this.tenantId = details.tenant_id || this.tenantId; + this.extraDhcpOpts = details.extra_dhcp_opts || this.extraDhcpOpts; + this.deviceOwner = details.device_owner || this.deviceOwner; + this.macAddress = details.mac_address || this.macAddress; + this.fixedIps = details.fixed_ips || this.fixedIps; this.id = details.id || this.id; - this.security_groups = details.security_groups || this.security_groups; - this.device_id = details.device_id || this.device_id; + this.securityGroups = details.security_groups || this.securityGroups; + this.deviceId = details.device_id || this.deviceId; }; Port.prototype.toJSON = function () { - return _.pick(this, ['status', 'name', 'allowed_address_pairs', 'admin_state_up', - 'network_id', 'tenant_id', 'extra_dhcp_opts', 'device_owner', - 'mac_address', 'fixed_ips', 'id', 'security_groups', 'device_id']); + return _.pick(this, ['status', 'name', 'allowedAddressPairs', 'adminStateUp', + 'networkId', 'tenantId', 'extraDhcpOpts', 'deviceOwner', + 'macAddress', 'fixedIps', 'id', 'securityGroups', 'deviceId']); }; diff --git a/lib/pkgcloud/openstack/network/subnet.js b/lib/pkgcloud/openstack/network/subnet.js index 3ff7b7e30..8feaf1f87 100644 --- a/lib/pkgcloud/openstack/network/subnet.js +++ b/lib/pkgcloud/openstack/network/subnet.js @@ -17,17 +17,19 @@ utile.inherits(Subnet, base.Subnet); Subnet.prototype._setProperties = function (details) { this.name = details.name || this.name; - this.enable_dhcp = details.enable_dhcp || this.enable_dhcp; - this.network_id = details.network_id || this.network_id; + this.enableDhcp = details.enable_dhcp || this.enableDhcp; + this.networkId = details.network_id || this.networkId; this.id = details.id || this.id; - this.ip_version = details.ip_version || this.ip_version; - this.tenant_id = details.tenant_id || this.tenant_id; - this.gateway_ip = details.gateway_ip || this.gateway_ip; + this.ipVersion = details.ip_version || this.ipVersion; + this.tenantId = details.tenant_id || this.tenantId; + this.gatewayIp = details.gateway_ip || this.gatewayIp; this.cidr = details.cidr || this.cidr; - this.dns_nameservers = details.dns_nameservers || this.dns_nameservers; + this.dnsNameServers = details.dns_nameservers || this.dnsNameServers; + this.hostRoutes = details.host_routes || this.hostRoutes; + this.allocationPools = details.allocation_pools || this.allocationPools; }; Subnet.prototype.toJSON = function () { - return _.pick(this, ['name', 'id', 'network_id', 'ip_version', - 'tenant_id', 'gateway_ip', 'dns_nameservers']); + return _.pick(this, ['name', 'id', 'networkId', 'ipVersion', + 'tenantId', 'gatewayIp', 'dnsNameServers', 'allocationPools', 'hostRoutes']); }; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index a4ed61b44..bd6ce8243 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -135,9 +135,9 @@ providers.filter(function (provider) { it('the updateNetwork() method should update a network', function (done) { - var networkToUpdate = { id : context.currentNetwork.id, admin_state_up : false}; - networkToUpdate.id = context.currentNetwork.id; - networkToUpdate.admin_state_up = false; + var networkToUpdate = context.currentNetwork; + networkToUpdate.adminStateUp = false; + if (mock) { setupUpdateNetworkMock(client, provider, { authServer: authServer, @@ -162,7 +162,7 @@ providers.filter(function (provider) { } var network = new Network(client); - network.name= "model created network"; + network.name = "model created network"; network.create(function (err, createdNetwork) { should.not.exist(err); should.exist(createdNetwork); @@ -243,7 +243,7 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id), - { network: { id: currentNetwork.id, admin_state_up: false }}) + {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } } diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 217ab2fdf..45e9b8e7c 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -137,7 +137,9 @@ providers.filter(function (provider) { it('the updatePort() method should update a port', function (done) { - var portToUpdate = { id : context.currentPort.id, enable_dhcp : false}; + var portToUpdate = context.currentPort; + portToUpdate.adminStateUp = false; + if (mock) { setupUpdatePortMock(client, provider, { authServer: authServer, @@ -243,7 +245,10 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id), - { port: { id: currentPort.id, enable_dhcp: false }}) + {"port":{"status":"ACTIVE","name":"my_port","admin_state_up":false,"mac_address":"fa:16:3e:58:42:ed", + "fixed_ips":[{"subnet_id":"008ba151-0b8c-4a67-98b5-0d2b87666062","ip_address":"172.24.4.2"}], + "security_groups":[],"network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3"} + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index a1ea60f34..1531ff115 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -137,7 +137,9 @@ providers.filter(function (provider) { it('the updateSubnet() method should update a subnet', function (done) { - var subnetToUpdate = { id : context.currentSubnet.id, enable_dhcp : false}; + var subnetToUpdate = context.currentSubnet; + subnetToUpdate.enableDhcp = false; + if (mock) { setupUpdateSubnetMock(client, provider, { authServer: authServer, @@ -243,7 +245,12 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id), - { subnet: { id: currentSubnet.id, enable_dhcp: false }}) + {"subnet":{"name":"my_subnet", + "network_id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id":"4fd44f30292945e481c7b8a0c8908869", + "allocation_pools":[{"start":"192.0.0.2","end":"192.255.255.254"}], + "gateway_ip":"192.0.0.1","ip_version":4,"cidr":"192.0.0.0/8", + "enable_dhcp":false}}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } } From 988b459062a1f9ad5850fcdf498b1e9145bc9432 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 9 May 2014 17:46:44 -0700 Subject: [PATCH 084/460] Responding to Code Review feedback. --- lib/pkgcloud.js | 4 ++-- lib/pkgcloud/core/base/client.js | 6 +----- lib/pkgcloud/openstack/network/networkClient.js | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index b1046a21c..e314ca270 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -39,8 +39,8 @@ var services = [ 'database', 'dns', 'loadbalancer', - 'storage', - 'network' + 'network', + 'storage' ]; // diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index 276829f18..489028069 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -69,11 +69,7 @@ Client.prototype._request = function (options, callback) { requestOptions.signingUrl += '?' + qs.stringify(options.qs); } } - - if (options.network && options.method ==='GET') { - requestOptions.signingUrl = '/' + options.network + '/'; - } - + function sendRequest(opts) { // diff --git a/lib/pkgcloud/openstack/network/networkClient.js b/lib/pkgcloud/openstack/network/networkClient.js index 27d1f1a8c..653b91561 100644 --- a/lib/pkgcloud/openstack/network/networkClient.js +++ b/lib/pkgcloud/openstack/network/networkClient.js @@ -23,7 +23,6 @@ var Client = exports.NetworkClient = function () { */ Client.prototype._getUrl = function (options) { options = options || {}; - var fragment = ''; if (options.network) { @@ -32,7 +31,6 @@ Client.prototype._getUrl = function (options) { } } - if (options.path) { fragment = urlJoin(fragment, options.path.split('/').map(encodeURIComponent).join('/')); } From 7a81721679b54b75d4ad358602ad2433c4cdf4be Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 9 May 2014 17:47:46 -0700 Subject: [PATCH 085/460] Removing local jshint options file. --- lib/.jshintrc | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 lib/.jshintrc diff --git a/lib/.jshintrc b/lib/.jshintrc deleted file mode 100644 index 913aba821..000000000 --- a/lib/.jshintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "camelcase": true, - "expr": false, - "laxbreak": false, - "immed": false, - "node": true, - "indent": true, - "strict": false -} From 3adb135c58ee62697adcd81c94a3ccb1b1b3c77b Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 9 May 2014 17:48:52 -0700 Subject: [PATCH 086/460] Removing local log file. --- lib/log.txt | 3245 --------------------------------------------------- 1 file changed, 3245 deletions(-) delete mode 100644 lib/log.txt diff --git a/lib/log.txt b/lib/log.txt deleted file mode 100644 index a2ec02b3a..000000000 --- a/lib/log.txt +++ /dev/null @@ -1,3245 +0,0 @@ -pkgcloud.js, line 51, character 7: Expected 'hidden' at column 5, not column 7. -hidden = '_' + name; -pkgcloud/amazon/client.js, line 9, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/amazon/client.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../core/base'); -pkgcloud/amazon/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/flavor'); -pkgcloud/amazon/compute/flavor.js, line 36, character 28: Expected '{' and instead saw 'throw'. -if (!Flavor.options[id]) throw new TypeError('No such AWS Flavor: ' + id); -pkgcloud/amazon/compute/flavor.js, line 36, character 28: Expected 'throw' at column 3, not column 28. -if (!Flavor.options[id]) throw new TypeError('No such AWS Flavor: ' + id); -pkgcloud/amazon/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/image'); -pkgcloud/amazon/compute/server.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/server'); -pkgcloud/amazon/compute/server.js, line 23, character 7: Expected 'case' at column 5, not column 7. -case 'PENDING': -pkgcloud/amazon/compute/server.js, line 24, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.provisioning; -pkgcloud/amazon/compute/server.js, line 25, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/amazon/compute/server.js, line 26, character 7: Expected 'case' at column 5, not column 7. -case 'RUNNING': -pkgcloud/amazon/compute/server.js, line 27, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.running; -pkgcloud/amazon/compute/server.js, line 28, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/amazon/compute/server.js, line 29, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPING': -pkgcloud/amazon/compute/server.js, line 30, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPED': -pkgcloud/amazon/compute/server.js, line 31, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.stopped; -pkgcloud/amazon/compute/server.js, line 32, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/amazon/compute/server.js, line 33, character 7: Expected 'case' at column 5, not column 7. -case 'TERMINATED': -pkgcloud/amazon/compute/server.js, line 34, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.terminated; -pkgcloud/amazon/compute/server.js, line 35, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/amazon/compute/server.js, line 36, character 7: Expected 'default' at column 5, not column 7. -default: -pkgcloud/amazon/compute/server.js, line 37, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.unknown; -pkgcloud/amazon/compute/server.js, line 38, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/amazon/compute/server.js, line 42, character 21: Expected an identifier and instead saw 'private' (a reserved word). -var addresses = { private: [], public: [] }; -pkgcloud/amazon/compute/server.js, line 42, character 34: Expected an identifier and instead saw 'public' (a reserved word). -var addresses = { private: [], public: [] }; -pkgcloud/amazon/compute/server.js, line 46, character 17: Expected an identifier and instead saw 'public' (a reserved word). -addresses.public.push(details[prop]); -pkgcloud/amazon/compute/server.js, line 52, character 17: Expected an identifier and instead saw 'private' (a reserved word). -addresses.private.push(details[prop]); -pkgcloud/amazon/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/amazon/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.amazon.compute; -pkgcloud/amazon/compute/client/groups.js, line 7, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'); -pkgcloud/amazon/compute/client/groups.js, line 107, character 113: Line too long. -// - http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html -pkgcloud/amazon/compute/client/groups.js, line 125, character 11: Unexpected space between 'rules' and ','. -rules , -pkgcloud/amazon/compute/client/groups.js, line 142, character 113: Line too long. -// - http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html -pkgcloud/amazon/compute/client/groups.js, line 160, character 11: Unexpected space between 'rules' and ','. -rules , -pkgcloud/amazon/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/amazon/compute/client/images.js, line 9, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/amazon/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.amazon.compute; -pkgcloud/amazon/compute/client/images.js, line 26, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/amazon/compute/client/images.js, line 32, character 10: Move 'var' declarations to the top of the function. -for (var i = 0; i < options.owners.length; i++) { -pkgcloud/amazon/compute/client/images.js, line 32, character 10: Stopping. (24% scanned). - -pkgcloud/amazon/compute/client/index.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/amazon/compute/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/amazon/compute/client/index.js, line 11, character 5: Expected 'xml2js' at column 3, not column 5. -xml2js = require('xml2js'), -pkgcloud/amazon/compute/client/index.js, line 12, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth'), -pkgcloud/amazon/compute/client/index.js, line 13, character 5: Expected 'amazon' at column 3, not column 5. -amazon = require('../../client'); -pkgcloud/amazon/compute/client/index.js, line 31, character 50: 'query' is already defined. -Client.prototype._query = function query(action, query, callback) { -pkgcloud/amazon/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'); -pkgcloud/amazon/compute/client/servers.js, line 8, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/amazon/compute/client/servers.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/amazon/compute/client/servers.js, line 10, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/amazon/compute/client/servers.js, line 11, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/amazon/compute/client/servers.js, line 12, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.amazon.compute; -pkgcloud/amazon/compute/client/servers.js, line 22, character 28: Expected exactly one space between 'function' and '('. -process.nextTick(function() { -pkgcloud/amazon/compute/client/servers.js, line 51, character 34: Expected '{' at column 5, not column 34. -'DescribeInstanceAttribute', { -pkgcloud/amazon/compute/client/servers.js, line 74, character 6: Expected ')' at column 3, not column 6. -}); -pkgcloud/amazon/compute/client/servers.js, line 110, character 15: Expected 'return' at column 13, not column 15. -return new compute.Server(self, server); -pkgcloud/amazon/compute/client/servers.js, line 111, character 13: Expected '}' at column 11, not column 13. -}), res); -pkgcloud/amazon/compute/client/servers.js, line 137, character 7: Expected 'meta' at column 5, not column 7. -meta = { name: options.name || '' }, -pkgcloud/amazon/compute/client/servers.js, line 138, character 7: Expected 'createOptions' at column 5, not column 7. -createOptions = { -pkgcloud/amazon/compute/client/servers.js, line 139, character 9: Expected 'UserData' at column 7, not column 9. -UserData: new Buffer(JSON.stringify(meta)).toString('base64'), -pkgcloud/amazon/compute/client/servers.js, line 140, character 9: Expected 'MinCount' at column 7, not column 9. -MinCount: 1, -pkgcloud/amazon/compute/client/servers.js, line 141, character 9: Expected 'MaxCount' at column 7, not column 9. -MaxCount: 1 -pkgcloud/amazon/compute/client/servers.js, line 142, character 7: Expected '}' at column 5, not column 7. -}, -pkgcloud/amazon/compute/client/servers.js, line 143, character 7: Expected 'securityGroup' at column 5, not column 7. -securityGroup, -pkgcloud/amazon/compute/client/servers.js, line 144, character 7: Expected 'securityGroupId' at column 5, not column 7. -securityGroupId; -pkgcloud/amazon/compute/client/servers.js, line 155, character 49: ['SecurityGroup'] is better written in dot notation. -securityGroup = this.securityGroup || options['SecurityGroup']; -pkgcloud/amazon/compute/client/servers.js, line 157, character 19: ['SecurityGroup'] is better written in dot notation. -createOptions['SecurityGroup'] = securityGroup; -pkgcloud/amazon/compute/client/servers.js, line 160, character 53: ['SecurityGroupId'] is better written in dot notation. -securityGroupId = this.securityGroupId || options['SecurityGroupId']; -pkgcloud/amazon/compute/client/servers.js, line 162, character 19: ['SecurityGroupId'] is better written in dot notation. -createOptions['SecurityGroupId'] = securityGroupId; -pkgcloud/amazon/compute/client/servers.js, line 233, character 7: Expected 'serverId' at column 5, not column 7. -serverId = server instanceof base.Server ? server.id : server; -pkgcloud/amazon/compute/client/servers.js, line 264, character 18: Expected '{' and instead saw 'return'. -if (err) return callback(err); -pkgcloud/amazon/compute/client/servers.js, line 264, character 18: Expected 'return' at column 9, not column 18. -if (err) return callback(err); -pkgcloud/amazon/storage/container.js, line 9, character 5: Expected 'storage' at column 3, not column 5. -storage = require('../storage'), -pkgcloud/amazon/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/storage/container'); -pkgcloud/amazon/storage/file.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/storage/file'); -pkgcloud/amazon/storage/utils.js, line 2, character 5: Expected 'Stream' at column 3, not column 5. -Stream = require('stream').Stream; -pkgcloud/amazon/storage/utils.js, line 31, character 9: Expected 'parts' at column 7, not column 9. -parts = []; -pkgcloud/amazon/storage/utils.js, line 34, character 32: Expected '{' and instead saw 'return'. -if (total >= this.chunk) return true; -pkgcloud/amazon/storage/utils.js, line 34, character 32: Expected 'return' at column 7, not column 32. -if (total >= this.chunk) return true; -pkgcloud/amazon/storage/utils.js, line 39, character 6: Don't make functions within a loop. -}, this); -pkgcloud/amazon/storage/utils.js, line 43, character 11: Combine this with the previous 'var' statement. -var last = parts[parts.length - 1], -pkgcloud/amazon/storage/utils.js, line 44, character 11: Expected 'splitPos' at column 9, not column 11. -splitPos = last.length - total + this.chunk, -pkgcloud/amazon/storage/utils.js, line 45, character 11: Expected 'head' at column 9, not column 11. -head = last.slice(0, splitPos), -pkgcloud/amazon/storage/utils.js, line 46, character 11: Expected 'tail' at column 9, not column 11. -tail = last.slice(splitPos); -pkgcloud/amazon/storage/utils.js, line 58, character 20: Expected '{' and instead saw 'return'. -if (this.paused) return false; -pkgcloud/amazon/storage/utils.js, line 58, character 20: Expected 'return' at column 3, not column 20. -if (this.paused) return false; -pkgcloud/amazon/storage/utils.js, line 62, character 19: Expected '{' and instead saw 'return'. -if (this.ended) return; -pkgcloud/amazon/storage/utils.js, line 62, character 19: Expected 'return' at column 3, not column 19. -if (this.ended) return; -pkgcloud/amazon/storage/utils.js, line 84, character 20: Expected '{' and instead saw 'return'. -if (this.paused) return; -pkgcloud/amazon/storage/utils.js, line 84, character 20: Expected 'return' at column 3, not column 20. -if (this.paused) return; -pkgcloud/amazon/storage/utils.js, line 89, character 21: Expected '{' and instead saw 'return'. -if (!this.paused) return; -pkgcloud/amazon/storage/utils.js, line 89, character 21: Expected 'return' at column 3, not column 21. -if (!this.paused) return; -pkgcloud/amazon/storage/client/containers.js, line 101, character 11: Expected 'method' at column 9, not column 11. -method: 'DELETE', -pkgcloud/amazon/storage/client/containers.js, line 102, character 11: Expected 'container' at column 9, not column 11. -container: containerName -pkgcloud/amazon/storage/client/containers.js, line 103, character 9: Expected '}' at column 7, not column 9. -}, function (err, body, res) { -pkgcloud/amazon/storage/client/containers.js, line 104, character 11: Expected 'return' at column 9, not column 11. -return err -pkgcloud/amazon/storage/client/containers.js, line 106, character 45: Expected '===' and instead saw '=='. -: callback(null, res.statusCode == 204); -pkgcloud/amazon/storage/client/containers.js, line 107, character 9: Expected '}' at column 7, not column 9. -} -pkgcloud/amazon/storage/client/containers.js, line 108, character 7: Expected ')' at column 9, not column 7. -); -pkgcloud/amazon/storage/client/files.js, line 9, character 5: Expected 'filed' at column 3, not column 5. -filed = require('filed'), -pkgcloud/amazon/storage/client/files.js, line 10, character 5: Expected 'mime' at column 3, not column 5. -mime = require('mime'), -pkgcloud/amazon/storage/client/files.js, line 11, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/amazon/storage/client/files.js, line 12, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/amazon/storage/client/files.js, line 13, character 5: Expected 'qs' at column 3, not column 5. -qs = require('querystring'), -pkgcloud/amazon/storage/client/files.js, line 14, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/storage'), -pkgcloud/amazon/storage/client/files.js, line 15, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/amazon/storage/client/files.js, line 16, character 5: Expected 'storage' at column 3, not column 5. -storage = pkgcloud.providers.amazon.storage; -pkgcloud/amazon/storage/client/files.js, line 18, character 1: Expected an identifier and instead saw 'const'. -const MAX_UPLOAD = 5 * 1024 * 1024 * 1024; -pkgcloud/amazon/storage/client/files.js, line 18, character 1: Stopping. (4% scanned). - -pkgcloud/amazon/storage/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/amazon/storage/client/index.js, line 10, character 5: Expected 'xml2js' at column 3, not column 5. -xml2js = require('xml2js'), -pkgcloud/amazon/storage/client/index.js, line 11, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth'), -pkgcloud/amazon/storage/client/index.js, line 12, character 5: Expected 'amazon' at column 3, not column 5. -amazon = require('../../client'); -pkgcloud/azure/client.js, line 9, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/azure/client.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../core/base'); -pkgcloud/azure/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/flavor'); -pkgcloud/azure/compute/flavor.js, line 28, character 28: Expected '{' and instead saw 'throw'. -if (!Flavor.options[id]) throw new TypeError('No such Azure Flavor: ' + id); -pkgcloud/azure/compute/flavor.js, line 28, character 28: Expected 'throw' at column 3, not column 28. -if (!Flavor.options[id]) throw new TypeError('No such Azure Flavor: ' + id); -pkgcloud/azure/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/image'); -pkgcloud/azure/compute/server.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/server'); -pkgcloud/azure/compute/server.js, line 29, character 126: Line too long. -//console.log("Status: " + details.Status + ' RoleInstanceList: ' + roleInstance ? roleInstance.InstanceStatus : 'UNKNOWN'); -pkgcloud/azure/compute/server.js, line 31, character 110: Line too long. -// azure can return an inconsistent RoleInstance status (not in azure rest api docs) so we check everything. -pkgcloud/azure/compute/server.js, line 32, character 114: Line too long. -// an azure vm has a complicated state machine. We need to check the status of both the deployment and the role. -pkgcloud/azure/compute/server.js, line 33, character 122: Line too long. -// azure first starts a deployment and then starts a role. The role seems to go through STOPPEDVM, PROVISIONING and then -pkgcloud/azure/compute/server.js, line 35, character 123: Line too long. -// Note: since azureAPI has to wait until azure responds to our createServer request, we most likely will miss all of the -pkgcloud/azure/compute/server.js, line 41, character 7: Expected 'case' at column 5, not column 7. -case 'PROVISIONING': -pkgcloud/azure/compute/server.js, line 42, character 7: Expected 'case' at column 5, not column 7. -case 'CREATINGVM': -pkgcloud/azure/compute/server.js, line 43, character 7: Expected 'case' at column 5, not column 7. -case 'STARTINGVM': -pkgcloud/azure/compute/server.js, line 44, character 7: Expected 'case' at column 5, not column 7. -case 'CREATINGROLE': -pkgcloud/azure/compute/server.js, line 45, character 7: Expected 'case' at column 5, not column 7. -case 'STARTINGROLE': -pkgcloud/azure/compute/server.js, line 46, character 7: Expected 'case' at column 5, not column 7. -case 'RESTARTINGROLE': -pkgcloud/azure/compute/server.js, line 47, character 7: Expected 'case' at column 5, not column 7. -case 'BUSYROLE': -pkgcloud/azure/compute/server.js, line 48, character 7: Expected 'case' at column 5, not column 7. -case 'INITIALIZING': -pkgcloud/azure/compute/server.js, line 49, character 7: Expected 'case' at column 5, not column 7. -case 'BUSY': -pkgcloud/azure/compute/server.js, line 50, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.provisioning; -pkgcloud/azure/compute/server.js, line 51, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/azure/compute/server.js, line 52, character 7: Expected 'case' at column 5, not column 7. -case 'READYROLE': -pkgcloud/azure/compute/server.js, line 53, character 7: Expected 'case' at column 5, not column 7. -case 'READY': -pkgcloud/azure/compute/server.js, line 54, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.running; -pkgcloud/azure/compute/server.js, line 55, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/azure/compute/server.js, line 56, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPING': -pkgcloud/azure/compute/server.js, line 57, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPED': -pkgcloud/azure/compute/server.js, line 58, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPINGROLE': -pkgcloud/azure/compute/server.js, line 59, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPINGVM': -pkgcloud/azure/compute/server.js, line 60, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPEDVM': -pkgcloud/azure/compute/server.js, line 61, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.stopped; -pkgcloud/azure/compute/server.js, line 62, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/azure/compute/server.js, line 63, character 7: Expected 'case' at column 5, not column 7. -case 'DELETINGVM': -pkgcloud/azure/compute/server.js, line 64, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.terminated; -pkgcloud/azure/compute/server.js, line 65, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/azure/compute/server.js, line 66, character 7: Expected 'case' at column 5, not column 7. -case 'ROLESTATEUNKNOWN': -pkgcloud/azure/compute/server.js, line 67, character 7: Expected 'case' at column 5, not column 7. -case 'UNKNOWN': -pkgcloud/azure/compute/server.js, line 68, character 7: Empty case. -default: -pkgcloud/azure/compute/server.js, line 68, character 7: Expected 'default' at column 5, not column 7. -default: -pkgcloud/azure/compute/server.js, line 69, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.unknown; -pkgcloud/azure/compute/server.js, line 70, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/azure/compute/server.js, line 75, character 7: Expected 'case' at column 5, not column 7. -case 'STARTING': -pkgcloud/azure/compute/server.js, line 76, character 7: Expected 'case' at column 5, not column 7. -case 'DEPLOYING': -pkgcloud/azure/compute/server.js, line 77, character 7: Expected 'case' at column 5, not column 7. -case 'PROVISIONING': -pkgcloud/azure/compute/server.js, line 78, character 7: Expected 'case' at column 5, not column 7. -case 'RUNNINGTRANSITIONING': -pkgcloud/azure/compute/server.js, line 79, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.provisioning; -pkgcloud/azure/compute/server.js, line 80, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/azure/compute/server.js, line 81, character 7: Expected 'case' at column 5, not column 7. -case 'RUNNING': -pkgcloud/azure/compute/server.js, line 82, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.running; -pkgcloud/azure/compute/server.js, line 83, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/azure/compute/server.js, line 84, character 7: Expected 'case' at column 5, not column 7. -case 'SUSPENDING': -pkgcloud/azure/compute/server.js, line 85, character 7: Expected 'case' at column 5, not column 7. -case 'SUSPENDED': -pkgcloud/azure/compute/server.js, line 86, character 7: Expected 'case' at column 5, not column 7. -case 'SUSPENDEDTRANSITIONING': -pkgcloud/azure/compute/server.js, line 87, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.stopped; -pkgcloud/azure/compute/server.js, line 87, character 9: Too many errors. (70% scanned). - -pkgcloud/azure/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/azure/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.azure.compute; -pkgcloud/azure/compute/client/images.js, line 33, character 11: Expected 'return' at column 9, not column 11. -return new compute.Image(self, image); -pkgcloud/azure/compute/client/images.js, line 34, character 9: Expected '}' at column 7, not column 9. -}), res); -pkgcloud/azure/compute/client/images.js, line 79, character 23: Expected a conditional expression and instead saw an assignment. -options || (options = {}); -pkgcloud/azure/compute/client/images.js, line 79, character 27: Expected an assignment or function call and instead saw an expression. -options || (options = {}); -pkgcloud/azure/compute/client/images.js, line 81, character 22: Expected '{' and instead saw 'throw'. -if (!options.name) throw new TypeError('`name` is a required option'); -pkgcloud/azure/compute/client/images.js, line 81, character 22: Expected 'throw' at column 3, not column 22. -if (!options.name) throw new TypeError('`name` is a required option'); -pkgcloud/azure/compute/client/images.js, line 82, character 24: Expected '{' and instead saw 'throw'. -if (!options.server) throw new TypeError('`server` is a required option'); -pkgcloud/azure/compute/client/images.js, line 82, character 24: Expected 'throw' at column 3, not column 24. -if (!options.server) throw new TypeError('`server` is a required option'); -pkgcloud/azure/compute/client/images.js, line 106, character 7: Expected 'imageId' at column 5, not column 7. -imageId = image instanceof base.Image ? image.id : image, -pkgcloud/azure/compute/client/images.js, line 107, character 7: Expected 'path' at column 5, not column 7. -path = self.config.subscriptionId + '/services/images/' + imageId; -pkgcloud/azure/compute/client/index.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/azure/compute/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/azure/compute/client/index.js, line 11, character 5: Expected 'https' at column 3, not column 5. -https = require('https'), -pkgcloud/azure/compute/client/index.js, line 12, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth'), -pkgcloud/azure/compute/client/index.js, line 13, character 5: Expected 'azureApi' at column 3, not column 5. -azureApi = require('../../utils/azureApi.js'), -pkgcloud/azure/compute/client/index.js, line 14, character 5: Expected 'xml2JSON' at column 3, not column 5. -xml2JSON = require('../../utils/xml2json.js').xml2JSON, -pkgcloud/azure/compute/client/index.js, line 15, character 5: Expected 'azure' at column 3, not column 5. -azure = require('../../client'); -pkgcloud/azure/compute/client/index.js, line 52, character 50: 'query' is already defined. -Client.prototype._query = function query(action, query, callback) { -pkgcloud/azure/compute/client/index.js, line 88, character 9: Expected 'callback' at column 11, not column 9. -callback(err) : -pkgcloud/azure/compute/client/index.js, line 89, character 9: Expected 'callback' at column 11, not column 9. -callback(null, data, res); -pkgcloud/azure/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'); -pkgcloud/azure/compute/client/servers.js, line 46, character 7: Expected 'servers' at column 5, not column 7. -servers = []; -pkgcloud/azure/compute/client/servers.js, line 68, character 7: Expected 'serverId' at column 5, not column 7. -serverId = server instanceof base.Server ? server.id : server; -pkgcloud/azure/database/client/databases.js, line 34, character 16: ['name'] is better written in dot notation. -if (!options['name']) { -pkgcloud/azure/database/client/databases.js, line 74, character 3: Expected ')' at column 5, not column 3. -); -pkgcloud/azure/database/client/databases.js, line 78, character 104: Line too long. -// ### @callback {Function} Continuation to respond to when complete. Returns array of Database objects. -pkgcloud/azure/database/client/databases.js, line 81, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/azure/database/client/databases.js, line 113, character 10: 'encodeTableUriComponent' was used before it was defined. -path = encodeTableUriComponent("Tables('" + id + "')"); -pkgcloud/azure/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/azure/database/client/index.js, line 10, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth'), -pkgcloud/azure/database/client/index.js, line 11, character 5: Expected 'azureApi' at column 3, not column 5. -azureApi = require('../../utils/azureApi.js'), -pkgcloud/azure/database/client/index.js, line 12, character 5: Expected 'xml2JSON' at column 3, not column 5. -xml2JSON = require('../../utils/xml2json.js').xml2JSON, -pkgcloud/azure/database/client/index.js, line 13, character 5: Expected 'azure' at column 3, not column 5. -azure = require('../../client'); -pkgcloud/azure/storage/container.js, line 9, character 5: Expected 'storage' at column 3, not column 5. -storage = require('../storage'), -pkgcloud/azure/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/storage/container'); -pkgcloud/azure/storage/file.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/storage/file'); -pkgcloud/azure/storage/file.js, line 23, character 110: Line too long. -this.size = (properties && properties['Content-Length']) ? parseInt(properties['Content-Length'], 10) : 0; -pkgcloud/azure/storage/utils.js, line 2, character 5: Expected 'Stream' at column 3, not column 5. -Stream = require('stream').Stream; -pkgcloud/azure/storage/utils.js, line 30, character 9: Expected 'parts' at column 7, not column 9. -parts = []; -pkgcloud/azure/storage/utils.js, line 33, character 32: Expected '{' and instead saw 'return'. -if (total >= this.chunk) return true; -pkgcloud/azure/storage/utils.js, line 33, character 32: Expected 'return' at column 7, not column 32. -if (total >= this.chunk) return true; -pkgcloud/azure/storage/utils.js, line 38, character 6: Don't make functions within a loop. -}, this); -pkgcloud/azure/storage/utils.js, line 42, character 11: Combine this with the previous 'var' statement. -var last = parts[parts.length - 1], -pkgcloud/azure/storage/utils.js, line 43, character 11: Expected 'splitPos' at column 9, not column 11. -splitPos = last.length - total + this.chunk, -pkgcloud/azure/storage/utils.js, line 44, character 11: Expected 'head' at column 9, not column 11. -head = last.slice(0, splitPos), -pkgcloud/azure/storage/utils.js, line 45, character 11: Expected 'tail' at column 9, not column 11. -tail = last.slice(splitPos); -pkgcloud/azure/storage/utils.js, line 57, character 20: Expected '{' and instead saw 'return'. -if (this.paused) return false; -pkgcloud/azure/storage/utils.js, line 57, character 20: Expected 'return' at column 3, not column 20. -if (this.paused) return false; -pkgcloud/azure/storage/utils.js, line 61, character 19: Expected '{' and instead saw 'return'. -if (this.ended) return; -pkgcloud/azure/storage/utils.js, line 61, character 19: Expected 'return' at column 3, not column 19. -if (this.ended) return; -pkgcloud/azure/storage/utils.js, line 83, character 20: Expected '{' and instead saw 'return'. -if (this.paused) return; -pkgcloud/azure/storage/utils.js, line 83, character 20: Expected 'return' at column 3, not column 20. -if (this.paused) return; -pkgcloud/azure/storage/utils.js, line 88, character 21: Expected '{' and instead saw 'return'. -if (!this.paused) return; -pkgcloud/azure/storage/utils.js, line 88, character 21: Expected 'return' at column 3, not column 21. -if (!this.paused) return; -pkgcloud/azure/storage/client/containers.js, line 9, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/azure/storage/client/containers.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/storage'), -pkgcloud/azure/storage/client/containers.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/azure/storage/client/containers.js, line 12, character 5: Expected 'storage' at column 3, not column 5. -storage = pkgcloud.providers.azure.storage; -pkgcloud/azure/storage/client/containers.js, line 49, character 7: Expected 'self' at column 5, not column 7. -self = this, -pkgcloud/azure/storage/client/containers.js, line 50, character 7: Expected 'options' at column 5, not column 7. -options; -pkgcloud/azure/storage/client/containers.js, line 80, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/azure/storage/client/containers.js, line 108, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/azure/storage/client/containers.js, line 119, character 39: Expected '===' and instead saw '=='. -: callback(null, res.statusCode == 202); -pkgcloud/azure/storage/client/containers.js, line 120, character 4: Expected '}' at column 3, not column 4. -}); -pkgcloud/azure/storage/client/files.js, line 37, character 12: Missing space between ':' and 'DELETE'. -method:'DELETE', -pkgcloud/azure/storage/client/files.js, line 42, character 39: Expected '===' and instead saw '=='. -: callback(null, res.statusCode == 202); -pkgcloud/azure/storage/client/files.js, line 63, character 7: Expected 'success' at column 5, not column 7. -success = callback ? onUpload : null, -pkgcloud/azure/storage/client/files.js, line 64, character 7: Expected 'path' at column 5, not column 7. -path, -pkgcloud/azure/storage/client/files.js, line 65, character 7: Expected 'rstream' at column 5, not column 7. -rstream, -pkgcloud/azure/storage/client/files.js, line 66, character 7: Expected 'lstream' at column 5, not column 7. -lstream; -pkgcloud/azure/storage/client/files.js, line 78, character 3: Expected exactly one space between '}' and 'else'. -else if (options.stream) { -pkgcloud/azure/storage/client/files.js, line 78, character 3: Expected 'else' at column 5, not column 3. -else if (options.stream) { -pkgcloud/azure/storage/client/files.js, line 94, character 6: Expected ';' and instead saw '}'. -} -pkgcloud/azure/storage/client/files.js, line 111, character 16: Expected '{' and instead saw 'lstream'. -if (lstream) lstream.pipe(rstream); -pkgcloud/azure/storage/client/files.js, line 111, character 16: Expected 'lstream' at column 3, not column 16. -if (lstream) lstream.pipe(rstream); -pkgcloud/azure/storage/client/files.js, line 117, character 33: Expected 'String' and instead saw ''''. -return "block" + ((1e15 + a + "").slice(-b)); -pkgcloud/azure/storage/client/files.js, line 148, character 9: Combine this with the previous 'var' statement. -var rstream = self.upload(options, next); -pkgcloud/azure/storage/client/files.js, line 162, character 7: Expected 'body' at column 5, not column 7. -body, -pkgcloud/azure/storage/client/files.js, line 163, character 7: Expected 'path' at column 5, not column 7. -path, -pkgcloud/azure/storage/client/files.js, line 164, character 7: Expected 'qs' at column 5, not column 7. -qs; -pkgcloud/azure/storage/client/files.js, line 190, character 8: Move 'var' declarations to the top of the function. -for (var i = 0; i < numBlocks; i++) { -pkgcloud/azure/storage/client/files.js, line 190, character 8: Stopping. (64% scanned). - -pkgcloud/azure/storage/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/azure/storage/client/index.js, line 10, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth'), -pkgcloud/azure/storage/client/index.js, line 11, character 5: Expected 'azureApi' at column 3, not column 5. -azureApi = require('../../utils/azureApi.js'), -pkgcloud/azure/storage/client/index.js, line 12, character 5: Expected 'xml2JSON' at column 3, not column 5. -xml2JSON = require('../../utils/xml2json.js').xml2JSON, -pkgcloud/azure/storage/client/index.js, line 13, character 5: Expected 'azure' at column 3, not column 5. -azure = require('../../client'); -pkgcloud/azure/utils/azureApi.js, line 66, character 7: 'validateCreateOptions' was used before it was defined. -validateCreateOptions(options, client.config, next); -pkgcloud/azure/utils/azureApi.js, line 69, character 7: 'getHostedServiceProperties' was used before it was defined. -getHostedServiceProperties(client, options.name, next); -pkgcloud/azure/utils/azureApi.js, line 75, character 9: 'createHostedService' was used before it was defined. -createHostedService(client, options, function (err, service) { -pkgcloud/azure/utils/azureApi.js, line 89, character 7: 'getOSImage' was used before it was defined. -getOSImage(client, options.image, function (err, res) { -pkgcloud/azure/utils/azureApi.js, line 108, character 106: Line too long. -addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { -pkgcloud/azure/utils/azureApi.js, line 108, character 9: 'addCertificate' was used before it was defined. -addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { -pkgcloud/azure/utils/azureApi.js, line 117, character 7: 'createVM' was used before it was defined. -createVM(client, options, vmOptions, next); -pkgcloud/azure/utils/azureApi.js, line 121, character 7: 'getServer' was used before it was defined. -getServer(client, options.name, next); -pkgcloud/azure/utils/azureApi.js, line 131, character 3: Expected ')' at column 5, not column 3. -); -pkgcloud/azure/utils/azureApi.js, line 137, character 5: Expected 'case' at column 3, not column 5. -case 'linux': -pkgcloud/azure/utils/azureApi.js, line 138, character 7: Expected 'createLinuxVM' at column 5, not column 7. -createLinuxVM(client, options, vmOptions, callback); -pkgcloud/azure/utils/azureApi.js, line 138, character 7: 'createLinuxVM' was used before it was defined. -createLinuxVM(client, options, vmOptions, callback); -pkgcloud/azure/utils/azureApi.js, line 139, character 7: Expected 'break' at column 5, not column 7. -break; -pkgcloud/azure/utils/azureApi.js, line 140, character 5: Expected 'case' at column 3, not column 5. -case 'windows': -pkgcloud/azure/utils/azureApi.js, line 141, character 7: Expected 'createWindowsVM' at column 5, not column 7. -createWindowsVM(client, options, vmOptions, callback); -pkgcloud/azure/utils/azureApi.js, line 141, character 7: 'createWindowsVM' was used before it was defined. -createWindowsVM(client, options, vmOptions, callback); -pkgcloud/azure/utils/azureApi.js, line 142, character 7: Expected 'break' at column 5, not column 7. -break; -pkgcloud/azure/utils/azureApi.js, line 143, character 5: Expected 'default' at column 3, not column 5. -default: -pkgcloud/azure/utils/azureApi.js, line 144, character 7: Expected 'callback' at column 5, not column 7. -callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); -pkgcloud/azure/utils/azureApi.js, line 145, character 7: Expected 'break' at column 5, not column 7. -break; -pkgcloud/azure/utils/azureApi.js, line 165, character 7: Combine this with the previous 'var' statement. -var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); -pkgcloud/azure/utils/azureApi.js, line 166, character 7: Combine this with the previous 'var' statement. -var label = new Buffer(options.name).toString('base64'); -pkgcloud/azure/utils/azureApi.js, line 168, character 7: Combine this with the previous 'var' statement. -var configParams = { -pkgcloud/azure/utils/azureApi.js, line 182, character 3: 'makeTemplateRequest' was used before it was defined. -makeTemplateRequest(client, path, 'linuxDeployment.xml', configParams, callback); -pkgcloud/azure/utils/azureApi.js, line 187, character 7: Combine this with the previous 'var' statement. -var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); -pkgcloud/azure/utils/azureApi.js, line 188, character 7: Combine this with the previous 'var' statement. -var label = new Buffer(options.name).toString('base64'); -pkgcloud/azure/utils/azureApi.js, line 190, character 7: Combine this with the previous 'var' statement. -var configParams = { -pkgcloud/azure/utils/azureApi.js, line 201, character 3: 'makeTemplateRequest' was used before it was defined. -makeTemplateRequest(client, path, 'windowsDeployment.xml', configParams, callback); -pkgcloud/azure/utils/azureApi.js, line 205, character 128: Line too long. -// /services/hostedservices//deployments//roleinstances//operations -pkgcloud/azure/utils/azureApi.js, line 211, character 7: Combine this with the previous 'var' statement. -var configParams = { -pkgcloud/azure/utils/azureApi.js, line 215, character 3: 'makeTemplateRequest' was used before it was defined. -makeTemplateRequest(client, path, 'captureRole.xml', configParams, callback); -pkgcloud/azure/utils/azureApi.js, line 222, character 7: Combine this with the previous 'var' statement. -var configParams = { -pkgcloud/azure/utils/azureApi.js, line 226, character 3: 'makeTemplateRequest' was used before it was defined. -makeTemplateRequest(client, path, 'deleteImage.xml', configParams, callback); -pkgcloud/azure/utils/azureApi.js, line 251, character 3: 'getServersFromService' was used before it was defined. -getServersFromService(client, serverName, function (err, servers) { -pkgcloud/azure/utils/azureApi.js, line 253, character 34: Use the || operator. -? callback(err, servers[0] ? servers[0] : null) -pkgcloud/azure/utils/azureApi.js, line 263, character 7: 'getHostedServices' was used before it was defined. -getHostedServices(client, next); -pkgcloud/azure/utils/azureApi.js, line 267, character 7: 'getServersFromServices' was used before it was defined. -getServersFromServices(client, hostedServices, next); -pkgcloud/azure/utils/azureApi.js, line 272, character 3: Expected ')' at column 5, not column 3. -); -pkgcloud/azure/utils/azureApi.js, line 289, character 15: ['accept'] is better written in dot notation. -headers['accept'] = 'application/xml'; -pkgcloud/azure/utils/azureApi.js, line 300, character 9: 'pollRequestStatus' was used before it was defined. -pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, next); -pkgcloud/azure/utils/azureApi.js, line 306, character 3: Expected ')' at column 5, not column 3. -); -pkgcloud/azure/utils/azureApi.js, line 311, character 7: Combine this with the previous 'var' statement. -var params = { -pkgcloud/azure/utils/azureApi.js, line 323, character 167: Line too long. -* POST https://management.core.windows.net//services/hostedservices//deployments//roleinstances//operations -pkgcloud/azure/utils/azureApi.js, line 338, character 167: Line too long. -* POST https://management.core.windows.net//services/hostedservices//deployments//roleinstances//operations -pkgcloud/azure/utils/azureApi.js, line 354, character 7: Combine this with the previous 'var' statement. -var params = { -pkgcloud/azure/utils/azureApi.js, line 363, character 104: Line too long. -// DELETE https://management.core.windows.net//services/hostedservices/ -pkgcloud/azure/utils/azureApi.js, line 374, character 5: 'pollRequestStatus' was used before it was defined. -pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); -pkgcloud/azure/utils/azureApi.js, line 404, character 132: Line too long. -* DELETE https://management.core.windows.net//services/hostedservices//deployments/ -pkgcloud/azure/utils/azureApi.js, line 405, character 104: Line too long. -* Because Delete Deployment is an asynchronous operation, it always returns status code 202 (Accept). -pkgcloud/azure/utils/azureApi.js, line 407, character 102: Line too long. -* Because Delete Deployment is an asynchronous operation, it always returns status code 202 (Accept). -pkgcloud/azure/utils/azureApi.js, line 407, character 102: Too many errors. (58% scanned). - -pkgcloud/azure/utils/cert.js, line 74, character 7: Combine this with the previous 'var' statement. -var endCert = '\n' + pem.indexOf(END_CERT); -pkgcloud/azure/utils/cert.js, line 79, character 7: Combine this with the previous 'var' statement. -var certBase64 = pem.substring(beginCert, endCert); -pkgcloud/azure/utils/cert.js, line 82, character 7: Combine this with the previous 'var' statement. -var cert = new Buffer(certBase64, 'base64'); -pkgcloud/azure/utils/cert.js, line 83, character 7: Combine this with the previous 'var' statement. -var sha1 = crypto.createHash('sha1'); -pkgcloud/azure/utils/constants.js, line 1, character 0: Unsafe character. -/** -pkgcloud/azure/utils/constants.js, line 17, character 1: Read only. -exports = module.exports; -pkgcloud/azure/utils/hmacsha256sign.js, line 1, character 0: Unsafe character. -/** -pkgcloud/azure/utils/hmacsha256sign.js, line 20, character 1: Read only. -exports = module.exports = HmacSha256Sign; -pkgcloud/azure/utils/hmacsha256sign.js, line 20, character 28: 'HmacSha256Sign' was used before it was defined. -exports = module.exports = HmacSha256Sign; -pkgcloud/azure/utils/sharedkey.js, line 1, character 0: Unsafe character. -/** -pkgcloud/azure/utils/sharedkey.js, line 27, character 1: Expected 'exports' at column 3, not column 1. -exports = module.exports = SharedKey; -pkgcloud/azure/utils/sharedkey.js, line 27, character 28: 'SharedKey' was used before it was defined. -exports = module.exports = SharedKey; -pkgcloud/azure/utils/sharedkey.js, line 66, character 7: Combine this with the previous 'var' statement. -var stringToSign = -pkgcloud/azure/utils/sharedkey.js, line 68, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.CONTENT_ENCODING]) + -pkgcloud/azure/utils/sharedkey.js, line 69, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.CONTENT_LANGUAGE]) + -pkgcloud/azure/utils/sharedkey.js, line 70, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.CONTENT_LENGTH]) + -pkgcloud/azure/utils/sharedkey.js, line 71, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.CONTENT_MD5]) + -pkgcloud/azure/utils/sharedkey.js, line 72, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.CONTENT_TYPE]) + -pkgcloud/azure/utils/sharedkey.js, line 73, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.DATE]) + -pkgcloud/azure/utils/sharedkey.js, line 74, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.IF_MODIFIED_SINCE]) + -pkgcloud/azure/utils/sharedkey.js, line 75, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.IF_MATCH]) + -pkgcloud/azure/utils/sharedkey.js, line 76, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.IF_NONE_MATCH]) + -pkgcloud/azure/utils/sharedkey.js, line 77, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.IF_UNMODIFIED_SINCE]) + -pkgcloud/azure/utils/sharedkey.js, line 78, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.RANGE]) + -pkgcloud/azure/utils/sharedkey.js, line 79, character 7: Expected 'this' at column 5, not column 7. -this._getCanonicalizedHeaders(req) + -pkgcloud/azure/utils/sharedkey.js, line 80, character 7: Expected 'this' at column 5, not column 7. -this._getCanonicalizedResource(req); -pkgcloud/azure/utils/sharedkey.js, line 82, character 7: Combine this with the previous 'var' statement. -var signature = this.signer.sign(stringToSign); -pkgcloud/azure/utils/sharedkey.js, line 98, character 7: Combine this with the previous 'var' statement. -var canonicalizedResource = '/' + this.storageAccount; -pkgcloud/azure/utils/sharedkey.js, line 107, character 9: Combine this with the previous 'var' statement. -var queryStringValues = req.qs; -pkgcloud/azure/utils/sharedkey.js, line 111, character 11: Combine this with the previous 'var' statement. -var paramNames = []; -pkgcloud/azure/utils/sharedkey.js, line 112, character 12: Move 'var' declarations to the top of the function. -for (var n in queryStringValues) { -pkgcloud/azure/utils/sharedkey.js, line 112, character 12: Stopping. (69% scanned). - -pkgcloud/azure/utils/sharedkeytable.js, line 18, character 5: Expected 'HeaderConstants' at column 3, not column 5. -HeaderConstants = require('./constants').HeaderConstants, -pkgcloud/azure/utils/sharedkeytable.js, line 19, character 5: Expected 'azureApi' at column 3, not column 5. -azureApi = require('../utils/azureApi'), -pkgcloud/azure/utils/sharedkeytable.js, line 20, character 5: Expected 'URL' at column 3, not column 5. -URL = require('url'); -pkgcloud/azure/utils/sharedkeytable.js, line 23, character 1: Read only. -exports = module.exports = SharedKeyTable; -pkgcloud/azure/utils/sharedkeytable.js, line 23, character 28: 'SharedKeyTable' was used before it was defined. -exports = module.exports = SharedKeyTable; -pkgcloud/azure/utils/sharedkeytable.js, line 56, character 15: ['accept'] is better written in dot notation. -req.headers['accept'] = 'application/atom+xml;charset="utf-8"'; -pkgcloud/azure/utils/sharedkeytable.js, line 62, character 7: Combine this with the previous 'var' statement. -var stringToSign = -pkgcloud/azure/utils/sharedkeytable.js, line 64, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.CONTENT_MD5]) + -pkgcloud/azure/utils/sharedkeytable.js, line 65, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.CONTENT_TYPE]) + -pkgcloud/azure/utils/sharedkeytable.js, line 66, character 7: Expected 'getvalueToAppend' at column 5, not column 7. -getvalueToAppend(req.headers[HeaderConstants.DATE_HEADER]) + -pkgcloud/azure/utils/sharedkeytable.js, line 67, character 7: Expected 'this' at column 5, not column 7. -this._getCanonicalizedResource(req); -pkgcloud/azure/utils/sharedkeytable.js, line 69, character 15: ['DataServiceVersion'] is better written in dot notation. -req.headers['DataServiceVersion'] = '1.0;NetFx'; -pkgcloud/azure/utils/sharedkeytable.js, line 70, character 15: ['MaxDataServiceVersion'] is better written in dot notation. -req.headers['MaxDataServiceVersion'] = '2.0;NetFx'; -pkgcloud/azure/utils/sharedkeytable.js, line 87, character 7: Combine this with the previous 'var' statement. -var canonicalizedResource = '/' + this.storageAccount; -pkgcloud/azure/utils/sharedkeytable.js, line 94, character 9: Combine this with the previous 'var' statement. -var u = URL.parse(req.path[1], true); -pkgcloud/azure/utils/sharedkeytable.js, line 95, character 9: Combine this with the previous 'var' statement. -var queryStringValues = u.query; -pkgcloud/azure/utils/sharedkeytable.js, line 98, character 29: ['comp'] is better written in dot notation. -if (queryStringValues['comp']) { -pkgcloud/azure/utils/sharedkeytable.js, line 99, character 63: ['comp'] is better written in dot notation. -canonicalizedResource += '?comp=' + queryStringValues['comp']; -pkgcloud/azure/utils/xml2json.js, line 28, character 7: Combine this with the previous 'var' statement. -var parser = new xml2js.Parser({normalize: false, trim: false}); -pkgcloud/common/auth.js, line 9, character 5: Expected 'awsSignature' at column 3, not column 5. -awsSignature = require('./aws-signature'), -pkgcloud/common/auth.js, line 10, character 5: Expected 'azureSignature' at column 3, not column 5. -azureSignature = require('./azure-signature'), -pkgcloud/common/auth.js, line 11, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'); -pkgcloud/common/aws-signature.js, line 9, character 5: Expected 'qs' at column 3, not column 5. -qs = require('querystring'), -pkgcloud/common/aws-signature.js, line 10, character 5: Expected 'crypto' at column 3, not column 5. -crypto = require('crypto'); -pkgcloud/common/aws-signature.js, line 13, character 17: Expected '{' and instead saw 'options'. -if (!options) options = {}; -pkgcloud/common/aws-signature.js, line 13, character 17: Expected 'options' at column 3, not column 17. -if (!options) options = {}; -pkgcloud/common/aws-signature.js, line 24, character 9: Expected 'req' at column 7, not column 9. -req.method, '\n', -pkgcloud/common/aws-signature.js, line 25, character 9: Expected 'this' at column 7, not column 9. -this.serversUrl, '\n', -pkgcloud/common/aws-signature.js, line 26, character 9: Expected '/' at column 7, not column 9. -'/', '\n' -pkgcloud/common/aws-signature.js, line 27, character 7: Expected ']' at column 5, not column 7. -], -pkgcloud/common/aws-signature.js, line 28, character 7: Expected 'query' at column 5, not column 7. -query = req.body; -pkgcloud/common/aws-signature.js, line 34, character 40: Missing '()'. -query.Timestamp = new Date(+new Date + 36e5 * 30).toISOString(); -pkgcloud/common/aws-signature.js, line 37, character 18: Expected '{' and instead saw 'signatureString'. -if (i !== 0) signatureString.push('&'); -pkgcloud/common/aws-signature.js, line 37, character 18: Expected 'signatureString' at column 5, not column 18. -if (i !== 0) signatureString.push('&'); -pkgcloud/common/aws-signature.js, line 41, character 7: Combine this with the previous 'var' statement. -var toSign = signatureString.join(''); -pkgcloud/common/aws-signature.js, line 51, character 7: Expected 'sha256' at column 5, not column 7. -'sha256', -pkgcloud/common/aws-signature.js, line 52, character 7: Expected 'options' at column 5, not column 7. -options.key -pkgcloud/common/aws-signature.js, line 58, character 3: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/common/aws-signature.js, line 58, character 3: Expected 'else' at column 5, not column 3. -else { -pkgcloud/common/aws-signature.js, line 59, character 5: Expected 'req' at column 7, not column 5. -req.qs = { -pkgcloud/common/aws-signature.js, line 60, character 7: Expected 'Action' at column 9, not column 7. -Action: query.Action -pkgcloud/common/aws-signature.js, line 61, character 5: Expected '}' at column 7, not column 5. -}; -pkgcloud/common/aws-signature.js, line 62, character 3: Expected '}' at column 5, not column 3. -} -pkgcloud/common/aws-signature.js, line 75, character 17: Expected '{' and instead saw 'options'. -if (!options) options = {}; -pkgcloud/common/aws-signature.js, line 75, character 17: Expected 'options' at column 3, not column 17. -if (!options) options = {}; -pkgcloud/common/aws-signature.js, line 93, character 7: Combine this with the previous 'var' statement. -var now = new Date(), -pkgcloud/common/aws-signature.js, line 94, character 7: Expected 'signatureString' at column 5, not column 7. -signatureString = [ -pkgcloud/common/aws-signature.js, line 95, character 9: Expected 'req' at column 7, not column 9. -req.method || 'GET', '\n', -pkgcloud/common/aws-signature.js, line 96, character 9: Expected 'headers' at column 7, not column 9. -headers['content-md5'] || '', '\n', -pkgcloud/common/aws-signature.js, line 97, character 9: Expected 'headers' at column 7, not column 9. -headers['content-type'] || '', '\n', -pkgcloud/common/aws-signature.js, line 98, character 9: Expected 'now' at column 7, not column 9. -now.toUTCString(), '\n' -pkgcloud/common/aws-signature.js, line 99, character 7: Expected ']' at column 5, not column 7. -]; -pkgcloud/common/aws-signature.js, line 111, character 3: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/common/aws-signature.js, line 111, character 3: Expected 'else' at column 5, not column 3. -else { -pkgcloud/common/aws-signature.js, line 112, character 5: Expected 'signatureString' at column 7, not column 5. -signatureString.push(req.path); -pkgcloud/common/aws-signature.js, line 113, character 3: Expected '}' at column 5, not column 3. -} -pkgcloud/common/aws-signature.js, line 115, character 7: Combine this with the previous 'var' statement. -var signature = crypto.createHmac( -pkgcloud/common/aws-signature.js, line 118, character 3: Expected ')' at column 5, not column 3. -).update(signatureString.join('')).digest('base64'); -pkgcloud/common/azure-signature.js, line 36, character 15: ['accept'] is better written in dot notation. -req.headers['accept'] = 'application/xml'; -pkgcloud/common/http-signature.js, line 12, character 5: Expected 'crypto' at column 3, not column 5. -crypto = require('crypto'), -pkgcloud/common/http-signature.js, line 13, character 5: Expected 'http' at column 3, not column 5. -http = require('http'); -pkgcloud/common/http-signature.js, line 60, character 7: Expected 'months' at column 5, not column 7. -months, -pkgcloud/common/http-signature.js, line 61, character 7: Expected 'days' at column 5, not column 7. -days; -pkgcloud/common/http-signature.js, line 107, character 9: Expected 'alg' at column 7, not column 9. -alg = options.algorithm.match(/(hmac|rsa)-(\w+)/), -pkgcloud/common/http-signature.js, line 108, character 9: Expected 'signature' at column 7, not column 9. -signature, -pkgcloud/common/http-signature.js, line 109, character 9: Expected 'signer' at column 7, not column 9. -signer, -pkgcloud/common/http-signature.js, line 110, character 9: Expected 'hmac' at column 7, not column 9. -hmac; -pkgcloud/core/base/client.js, line 9, character 5: Expected 'events' at column 3, not column 5. -events = require('eventemitter2'), -pkgcloud/core/base/client.js, line 10, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/core/base/client.js, line 11, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/core/base/client.js, line 12, character 5: Expected 'qs' at column 3, not column 5. -qs = require('qs'), -pkgcloud/core/base/client.js, line 13, character 5: Expected 'common' at column 3, not column 5. -common = require('../../common'), -pkgcloud/core/base/client.js, line 14, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../pkgcloud'), -pkgcloud/core/base/client.js, line 15, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'); -pkgcloud/core/base/client.js, line 45, character 7: Combine this with the previous 'var' statement. -var requestOptions = {}; -pkgcloud/core/base/client.js, line 73, character 44: Missing space between '===' and 'GET'. -if (options.network && options.method ==='GET') { -pkgcloud/core/base/client.js, line 85, character 12: Move 'var' declarations to the top of the function. -for (var i = 0; i < self.before.length; i++) { -pkgcloud/core/base/client.js, line 85, character 12: Stopping. (43% scanned). - -pkgcloud/core/base/model.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'); -pkgcloud/core/base/model.js, line 44, character 7: Expected 'start' at column 5, not column 7. -start = Date.now(), -pkgcloud/core/base/model.js, line 45, character 7: Expected 'fired' at column 5, not column 7. -fired = false, -pkgcloud/core/base/model.js, line 46, character 7: Expected 'equalCheckId' at column 5, not column 7. -equalCheckId, -pkgcloud/core/base/model.js, line 47, character 7: Expected 'current' at column 5, not column 7. -current; -pkgcloud/core/base/model.js, line 69, character 11: Expected 'keys' at column 9, not column 11. -keys = Object.keys(attributes); -pkgcloud/core/base/model.js, line 74, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/core/base/model.js, line 74, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/core/base/model.js, line 75, character 9: Expected 'for' at column 11, not column 9. -for (var i = 0; i < keys.length; i++) { -pkgcloud/core/base/model.js, line 75, character 14: Move 'var' declarations to the top of the function. -for (var i = 0; i < keys.length; i++) { -pkgcloud/core/base/model.js, line 75, character 14: Stopping. (75% scanned). - -pkgcloud/core/compute/flavor.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/compute/image.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/compute/index.js, line 34, character 5: Unexpected 'else' after 'return'. -return server.adminPass; -pkgcloud/core/compute/index.js, line 36, character 3: Expected exactly one space between '}' and 'else'. -else if (server.metadata) { -pkgcloud/core/compute/index.js, line 36, character 3: Expected 'else' at column 5, not column 3. -else if (server.metadata) { -pkgcloud/core/compute/index.js, line 37, character 28: ['root'] is better written in dot notation. -return server.metadata['root']; -pkgcloud/core/compute/index.js, line 57, character 7: Expected 'isPrivate' at column 5, not column 7. -isPrivate = options.isPrivate || exports.isPrivate, -pkgcloud/core/compute/index.js, line 58, character 7: Expected 'interfaces' at column 5, not column 7. -interfaces, -pkgcloud/core/compute/index.js, line 59, character 7: Expected 'addresses' at column 5, not column 7. -addresses, -pkgcloud/core/compute/index.js, line 60, character 7: Expected 'networks' at column 5, not column 7. -networks, -pkgcloud/core/compute/index.js, line 61, character 7: Expected 'pub' at column 5, not column 7. -pub; -pkgcloud/core/compute/index.js, line 74, character 5: Unexpected 'else' after 'return'. -return !pub.length -pkgcloud/core/compute/index.js, line 78, character 3: Expected exactly one space between '}' and 'else'. -else if (server.addresses.public || server.addresses.private) { -pkgcloud/core/compute/index.js, line 78, character 3: Expected 'else' at column 5, not column 3. -else if (server.addresses.public || server.addresses.private) { -pkgcloud/core/compute/index.js, line 78, character 29: Expected an identifier and instead saw 'public' (a reserved word). -else if (server.addresses.public || server.addresses.private) { -pkgcloud/core/compute/index.js, line 78, character 56: Expected an identifier and instead saw 'private' (a reserved word). -else if (server.addresses.public || server.addresses.private) { -pkgcloud/core/compute/index.js, line 94, character 29: Expected an identifier and instead saw 'public' (a reserved word). -return server.addresses.public.length -pkgcloud/core/compute/index.js, line 95, character 26: Expected an identifier and instead saw 'public' (a reserved word). -? server.addresses.public[0] -pkgcloud/core/compute/index.js, line 96, character 26: Expected an identifier and instead saw 'private' (a reserved word). -: server.addresses.private[0]; -pkgcloud/core/compute/index.js, line 94, character 5: Unexpected 'else' after 'return'. -return server.addresses.public.length -pkgcloud/core/compute/index.js, line 98, character 3: Expected exactly one space between '}' and 'else'. -else if (server.addresses) { -pkgcloud/core/compute/index.js, line 98, character 3: Expected 'else' at column 5, not column 3. -else if (server.addresses) { -pkgcloud/core/compute/index.js, line 116, character 48: Expected ';' and instead saw '}'. -.map(function (info) { return info.addr }) -pkgcloud/core/compute/index.js, line 122, character 11: Expected exactly one space between '}' and 'else'. -else if (isPrivate(addr)) { -pkgcloud/core/compute/index.js, line 122, character 11: Expected 'else' at column 13, not column 11. -else if (isPrivate(addr)) { -pkgcloud/core/compute/index.js, line 128, character 10: Expected an identifier and instead saw 'public' (a reserved word). -}, { public: [], private: [] }); -pkgcloud/core/compute/index.js, line 128, character 22: Expected an identifier and instead saw 'private' (a reserved word). -}, { public: [], private: [] }); -pkgcloud/core/compute/server.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'), -pkgcloud/core/compute/server.js, line 10, character 5: Expected 'computeStatus' at column 3, not column 5. -computeStatus = require('../../common/status').compute; -pkgcloud/core/compute/server.js, line 21, character 15: Expected '{' and instead saw 'self'. -if (!err) self._setProperties(server.original); -pkgcloud/core/compute/server.js, line 21, character 15: Expected 'self' at column 5, not column 15. -if (!err) self._setProperties(server.original); -pkgcloud/core/dns/record.js, line 11, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/dns/record.js, line 19, character 35: Expected exactly one space between 'function' and '('. -Record.prototype.create = function(callback) { -pkgcloud/core/dns/record.js, line 23, character 32: Expected exactly one space between 'function' and '('. -Record.prototype.get = function(callback) { -pkgcloud/core/dns/record.js, line 27, character 35: Expected exactly one space between 'function' and '('. -Record.prototype.update = function(callback) { -pkgcloud/core/dns/record.js, line 31, character 36: Expected exactly one space between 'function' and '('. -Record.prototype.destroy = function(callback) { -pkgcloud/core/dns/zone.js, line 11, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/loadbalancer/loadbalancer.js, line 11, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/loadbalancer/node.js, line 11, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/network/network.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/network/port.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/network/subnet.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/storage/container.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'); -pkgcloud/core/storage/file.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/core/storage/file.js, line 10, character 5: Expected 'model' at column 3, not column 5. -model = require('../base/model'), -pkgcloud/core/storage/file.js, line 11, character 5: Expected 'storage' at column 3, not column 5. -storage = require('../storage'); -pkgcloud/digitalocean/client.js, line 9, character 5: Expected 'fs' at column 3, not column 5. -fs = require('fs'), -pkgcloud/digitalocean/client.js, line 10, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../common/auth'), -pkgcloud/digitalocean/client.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../core/base'); -pkgcloud/digitalocean/client.js, line 30, character 1: Unexpected '(space)'. - -pkgcloud/digitalocean/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/flavor'); -pkgcloud/digitalocean/compute/flavor.js, line 22, character 1: Unexpected '(space)'. - -pkgcloud/digitalocean/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/image'); -pkgcloud/digitalocean/compute/server.js, line 9, character 5: Expected 'compute' at column 3, not column 5. -compute = require('../../core/compute'), -pkgcloud/digitalocean/compute/server.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/server'); -pkgcloud/digitalocean/compute/server.js, line 24, character 5: Expected an identifier and instead saw 'public' (a reserved word). -public: [details.ip_address], -pkgcloud/digitalocean/compute/server.js, line 25, character 5: Expected an identifier and instead saw 'private' (a reserved word). -private: [] -pkgcloud/digitalocean/compute/server.js, line 29, character 5: Expected 'case' at column 3, not column 5. -case 'ACTIVE': -pkgcloud/digitalocean/compute/server.js, line 30, character 7: Expected 'this' at column 5, not column 7. -this.status = "RUNNING"; -pkgcloud/digitalocean/compute/server.js, line 31, character 7: Expected 'break' at column 5, not column 7. -break; -pkgcloud/digitalocean/compute/server.js, line 32, character 5: Expected 'case' at column 3, not column 5. -case 'NEW': -pkgcloud/digitalocean/compute/server.js, line 33, character 5: Empty case. -default: -pkgcloud/digitalocean/compute/server.js, line 33, character 5: Expected 'default' at column 3, not column 5. -default: -pkgcloud/digitalocean/compute/server.js, line 34, character 7: Expected 'this' at column 5, not column 7. -this.status = 'PROVISIONING'; -pkgcloud/digitalocean/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/digitalocean/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.digitalocean.compute; -pkgcloud/digitalocean/compute/client/flavors.js, line 27, character 1: Unexpected '(space)'. - -pkgcloud/digitalocean/compute/client/flavors.js, line 30, character 14: Unexpected '(space)'. -}), res); -pkgcloud/digitalocean/compute/client/flavors.js, line 45, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/digitalocean/compute/client/flavors.js, line 55, character 24: Expected '===' and instead saw '=='. -return flavor.id == flavorId; -pkgcloud/digitalocean/compute/client/flavors.js, line 57, character 1: Unexpected '(space)'. - -pkgcloud/digitalocean/compute/client/flavors.js, line 60, character 28: 'Flavor' was used before it was defined. -: callback(null, new Flavor(self, flavor)); -pkgcloud/digitalocean/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/digitalocean/compute/client/images.js, line 9, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/digitalocean/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.digitalocean.compute; -pkgcloud/digitalocean/compute/client/images.js, line 44, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/digitalocean/compute/client/images.js, line 44, character 22: Unexpected '(space)'. -self = this; -pkgcloud/digitalocean/compute/client/images.js, line 82, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/digitalocean/compute/client/images.js, line 82, character 22: Unexpected '(space)'. -self = this; -pkgcloud/digitalocean/compute/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/digitalocean/compute/client/index.js, line 10, character 5: Expected 'digitalocean' at column 3, not column 5. -digitalocean = require('../../client'); -pkgcloud/digitalocean/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'); -pkgcloud/digitalocean/compute/client/keys.js, line 83, character 43: Unexpected ','. -path: '/ssh_keys/' + name + '/destroy', -pkgcloud/digitalocean/compute/client/servers.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/digitalocean/compute/client/servers.js, line 9, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/digitalocean/compute/client/servers.js, line 10, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/digitalocean/compute/client/servers.js, line 11, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.digitalocean.compute; -pkgcloud/digitalocean/compute/client/servers.js, line 97, character 7: Expected 'createOptions' at column 5, not column 7. -createOptions = { -pkgcloud/digitalocean/compute/client/servers.js, line 98, character 9: Expected 'path' at column 7, not column 9. -path: '/droplets/new', -pkgcloud/digitalocean/compute/client/servers.js, line 99, character 9: Expected 'qs' at column 7, not column 9. -qs: {} -pkgcloud/digitalocean/compute/client/servers.js, line 100, character 7: Expected '}' at column 5, not column 7. -}; -pkgcloud/digitalocean/compute/client/servers.js, line 128, character 3: Expected exactly one space between '}' and 'else'. -else if (options.keynames) { -pkgcloud/digitalocean/compute/client/servers.js, line 128, character 3: Expected 'else' at column 5, not column 3. -else if (options.keynames) { -pkgcloud/digitalocean/compute/client/servers.js, line 154, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/digitalocean/compute/client/servers.js, line 182, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/iriscouch/database/client/index.js, line 9, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/iriscouch/database/client/index.js, line 10, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/iriscouch/database/client/index.js, line 11, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'); -pkgcloud/iriscouch/database/client/index.js, line 29, character 14: ['first_name'] is better written in dot notation. -if (!attrs['first_name'] || !attrs['last_name']) { -pkgcloud/iriscouch/database/client/index.js, line 29, character 38: ['last_name'] is better written in dot notation. -if (!attrs['first_name'] || !attrs['last_name']) { -pkgcloud/iriscouch/database/client/index.js, line 35, character 14: ['subdomain'] is better written in dot notation. -if (!attrs['subdomain'] || !attrs['email']) { -pkgcloud/iriscouch/database/client/index.js, line 35, character 37: ['email'] is better written in dot notation. -if (!attrs['subdomain'] || !attrs['email']) { -pkgcloud/iriscouch/database/client/index.js, line 42, character 13: ['type'] is better written in dot notation. -if (attrs['type'] && attrs['type'] === 'redis' && !attrs['password']) { -pkgcloud/iriscouch/database/client/index.js, line 42, character 30: ['type'] is better written in dot notation. -if (attrs['type'] && attrs['type'] === 'redis' && !attrs['password']) { -pkgcloud/iriscouch/database/client/index.js, line 42, character 60: ['password'] is better written in dot notation. -if (attrs['type'] && attrs['type'] === 'redis' && !attrs['password']) { -pkgcloud/iriscouch/database/client/index.js, line 51, character 20: ['type'] is better written in dot notation. -_id: ((attrs['type'] && -pkgcloud/iriscouch/database/client/index.js, line 52, character 15: ['type'] is better written in dot notation. -attrs['type'] === 'redis') ? "Redis/" : "Server/") + attrs.subdomain, -pkgcloud/iriscouch/database/client/index.js, line 60, character 3: Expected '}' at column 5, not column 3. -}; -pkgcloud/iriscouch/database/client/index.js, line 63, character 13: ['type'] is better written in dot notation. -if (attrs['type'] && attrs['type'] === 'redis') { -pkgcloud/iriscouch/database/client/index.js, line 63, character 30: ['type'] is better written in dot notation. -if (attrs['type'] && attrs['type'] === 'redis') { -pkgcloud/iriscouch/database/client/index.js, line 64, character 37: ['password'] is better written in dot notation. -couch.creation.password = attrs['password']; -pkgcloud/iriscouch/database/client/index.js, line 64, character 29: Weird assignment. -couch.creation.password = attrs['password']; -pkgcloud/iriscouch/database/client/index.js, line 67, character 7: Combine this with the previous 'var' statement. -var options = { -pkgcloud/iriscouch/database/client/index.js, line 85, character 36: Expected ';' and instead saw '}'. -try { body = JSON.parse(body) } -pkgcloud/iriscouch/database/client/index.js, line 86, character 7: Expected exactly one space between '}' and 'catch'. -catch (ex) { } -pkgcloud/iriscouch/database/client/index.js, line 86, character 7: Expected 'catch' at column 9, not column 7. -catch (ex) { } -pkgcloud/iriscouch/database/client/index.js, line 92, character 111: Line too long. -// For Redis we dont have any polling method yet, so just trust on iriscouch for provisioning correctly -pkgcloud/iriscouch/database/client/index.js, line 94, character 19: ['type'] is better written in dot notation. -if (attrs['type'] && attrs['type'] === 'redis') { -pkgcloud/iriscouch/database/client/index.js, line 94, character 36: ['type'] is better written in dot notation. -if (attrs['type'] && attrs['type'] === 'redis') { -pkgcloud/iriscouch/database/client/index.js, line 102, character 65: ['password'] is better written in dot notation. -password: subdomain + '.redis.irstack.com:' + attrs['password'] -pkgcloud/iriscouch/database/client/index.js, line 115, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/iriscouch/database/client/index.js, line 115, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/iriscouch/database/client/index.js, line 116, character 9: Expected 'callback' at column 11, not column 9. -callback("There was an issue creating the couch", { "created": false }); -pkgcloud/iriscouch/database/client/index.js, line 117, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/iriscouch/database/client/index.js, line 119, character 105: Line too long. -else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { -pkgcloud/iriscouch/database/client/index.js, line 119, character 5: Expected exactly one space between '}' and 'else'. -else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { -pkgcloud/iriscouch/database/client/index.js, line 119, character 5: Expected 'else' at column 7, not column 5. -else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { -pkgcloud/iriscouch/database/client/index.js, line 122, character 5: Expected exactly one space between '}' and 'else'. -else if (response.statusCode === 409) { -pkgcloud/iriscouch/database/client/index.js, line 122, character 5: Expected 'else' at column 7, not column 5. -else if (response.statusCode === 409) { -pkgcloud/iriscouch/database/client/index.js, line 125, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/iriscouch/database/client/index.js, line 125, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/iriscouch/database/client/index.js, line 126, character 7: Expected 'callback' at column 9, not column 7. -callback("unknown error", { "created": false }); -pkgcloud/iriscouch/database/client/index.js, line 127, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/iriscouch/database/client/index.js, line 154, character 7: Expected 'maxAttempts' at column 5, not column 7. -maxAttempts = 20, -pkgcloud/iriscouch/database/client/index.js, line 155, character 7: Expected 'count' at column 5, not column 7. -count = 0, -pkgcloud/iriscouch/database/client/index.js, line 156, character 7: Expected 'options' at column 5, not column 7. -options = { -pkgcloud/iriscouch/database/client/index.js, line 157, character 9: Expected 'uri' at column 7, not column 9. -uri : this._getCouchPollingUrl(couchName), -pkgcloud/iriscouch/database/client/index.js, line 158, character 9: Expected 'method' at column 7, not column 9. -method : 'GET', -pkgcloud/iriscouch/database/client/index.js, line 159, character 9: Expected 'followRedirect' at column 7, not column 9. -followRedirect: false, -pkgcloud/iriscouch/database/client/index.js, line 160, character 9: Expected 'headers' at column 7, not column 9. -headers: { -pkgcloud/iriscouch/database/client/index.js, line 161, character 11: Expected 'Content-Type' at column 9, not column 11. -'Content-Type': 'application/json', -pkgcloud/iriscouch/database/client/index.js, line 162, character 11: Expected 'User-Agent' at column 9, not column 11. -'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version) -pkgcloud/iriscouch/database/client/index.js, line 163, character 9: Expected '}' at column 7, not column 9. -} -pkgcloud/iriscouch/database/client/index.js, line 164, character 7: Expected '}' at column 5, not column 7. -}, -pkgcloud/iriscouch/database/client/index.js, line 166, character 3: Expected 't' at column 5, not column 3. -t = function () { -pkgcloud/iriscouch/database/client/index.js, line 166, character 3: Too many errors. (86% scanned). - -pkgcloud/joyent/client.js, line 9, character 5: Expected 'fs' at column 3, not column 5. -fs = require('fs'), -pkgcloud/joyent/client.js, line 10, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../common/auth'), -pkgcloud/joyent/client.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../core/base'); -pkgcloud/joyent/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/flavor'); -pkgcloud/joyent/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/image'); -pkgcloud/joyent/compute/server.js, line 9, character 5: Expected 'compute' at column 3, not column 5. -compute = require('../../core/compute'), -pkgcloud/joyent/compute/server.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/server'), -pkgcloud/joyent/compute/server.js, line 11, character 5: Expected 'computeStatus' at column 3, not column 5. -computeStatus = require('../../common/status').compute; -pkgcloud/joyent/compute/server.js, line 25, character 7: Expected 'case' at column 5, not column 7. -case 'PROVISIONING': -pkgcloud/joyent/compute/server.js, line 26, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.provisioning; -pkgcloud/joyent/compute/server.js, line 27, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/joyent/compute/server.js, line 28, character 7: Expected 'case' at column 5, not column 7. -case 'RUNNING': -pkgcloud/joyent/compute/server.js, line 29, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.running; -pkgcloud/joyent/compute/server.js, line 30, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/joyent/compute/server.js, line 31, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPING': -pkgcloud/joyent/compute/server.js, line 32, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPED': -pkgcloud/joyent/compute/server.js, line 33, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.stopped; -pkgcloud/joyent/compute/server.js, line 34, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/joyent/compute/server.js, line 35, character 7: Expected 'default' at column 5, not column 7. -default: -pkgcloud/joyent/compute/server.js, line 36, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.unknown; -pkgcloud/joyent/compute/server.js, line 37, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/joyent/compute/server.js, line 45, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/joyent/compute/server.js, line 45, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/joyent/compute/server.js, line 46, character 7: Expected 'all' at column 9, not column 7. -all['public'].push(addr); -pkgcloud/joyent/compute/server.js, line 47, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/joyent/compute/client/flavors.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/joyent/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.joyent.compute; -pkgcloud/joyent/compute/client/flavors.js, line 27, character 11: Expected 'return' at column 9, not column 11. -return new compute.Flavor(self, result); -pkgcloud/joyent/compute/client/flavors.js, line 28, character 9: Expected '}' at column 7, not column 9. -}), res); -pkgcloud/joyent/compute/client/flavors.js, line 43, character 7: Expected 'flavorId' at column 5, not column 7. -flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; -pkgcloud/joyent/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/joyent/compute/client/images.js, line 9, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/joyent/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.joyent.compute; -pkgcloud/joyent/compute/client/images.js, line 27, character 11: Expected 'return' at column 9, not column 11. -return new compute.Image(self, result); -pkgcloud/joyent/compute/client/images.js, line 28, character 9: Expected '}' at column 7, not column 9. -}), res); -pkgcloud/joyent/compute/client/images.js, line 42, character 7: Expected 'imageId' at column 5, not column 7. -imageId = image instanceof base.Image ? image.id : image; -pkgcloud/joyent/compute/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/joyent/compute/client/index.js, line 10, character 5: Expected 'joyent' at column 3, not column 5. -joyent = require('../../client'); -pkgcloud/joyent/compute/client/keys.js, line 9, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'); -pkgcloud/joyent/compute/client/servers.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/joyent/compute/client/servers.js, line 9, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/joyent/compute/client/servers.js, line 10, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/joyent/compute/client/servers.js, line 11, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.joyent.compute; -pkgcloud/joyent/compute/client/servers.js, line 23, character 7: Expected 'return' at column 5, not column 7. -return err -pkgcloud/joyent/compute/client/servers.js, line 37, character 65: Expected 'callback' at column 5, not column 65. -errs.create({message: "Joyent's API is not rate limited"}), callback); -pkgcloud/joyent/compute/client/servers.js, line 37, character 73: Expected ')' at column 3, not column 73. -errs.create({message: "Joyent's API is not rate limited"}), callback); -pkgcloud/joyent/compute/client/servers.js, line 66, character 13: Expected 'return' at column 11, not column 13. -return new compute.Server(self, result); -pkgcloud/joyent/compute/client/servers.js, line 67, character 11: Expected '}' at column 9, not column 11. -}), res); -pkgcloud/joyent/compute/client/servers.js, line 95, character 7: Expected 'createOptions' at column 5, not column 7. -createOptions = { -pkgcloud/joyent/compute/client/servers.js, line 96, character 9: Expected 'method' at column 7, not column 9. -method: 'POST', -pkgcloud/joyent/compute/client/servers.js, line 97, character 9: Expected 'path' at column 7, not column 9. -path: this.account + '/machines', -pkgcloud/joyent/compute/client/servers.js, line 98, character 9: Expected 'body' at column 7, not column 9. -body: options -pkgcloud/joyent/compute/client/servers.js, line 99, character 7: Expected '}' at column 5, not column 7. -}; -pkgcloud/joyent/compute/client/servers.js, line 143, character 7: Combine this with the previous 'var' statement. -var self = this; -pkgcloud/joyent/compute/client/servers.js, line 145, character 7: Combine this with the previous 'var' statement. -var stopOptions = { -pkgcloud/joyent/compute/client/servers.js, line 157, character 11: Combine this with the previous 'var' statement. -var done = false; -pkgcloud/joyent/compute/client/servers.js, line 158, character 7: Function statements should not be placed in blocks. Use a function expression or move the statement to the top of the outer function. -function check() { -pkgcloud/joyent/compute/client/servers.js, line 159, character 19: Expected '{' and instead saw 'return'. -if (done) return; -pkgcloud/joyent/compute/client/servers.js, line 159, character 19: Expected 'return' at column 9, not column 19. -if (done) return; -pkgcloud/joyent/compute/client/servers.js, line 161, character 26: Expected '{' and instead saw 'return'. -if (checks <= 0) return; -pkgcloud/joyent/compute/client/servers.js, line 161, character 26: Expected 'return' at column 9, not column 26. -if (checks <= 0) return; -pkgcloud/joyent/compute/client/servers.js, line 164, character 11: 'finish' was used before it was defined. -finish(new Error('Machine unresponsive to STOP')); -pkgcloud/joyent/compute/client/servers.js, line 173, character 54: Expected ';' and instead saw '}'. -if (err) { return callback && callback(err) } -pkgcloud/joyent/compute/client/servers.js, line 176, character 13: 'finish' was used before it was defined. -finish(); -pkgcloud/joyent/compute/client/servers.js, line 185, character 7: Unexpected 'else' after 'return'. -return; -pkgcloud/joyent/compute/client/servers.js, line 187, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/joyent/compute/client/servers.js, line 187, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/joyent/compute/client/servers.js, line 188, character 7: Expected 'finish' at column 9, not column 7. -finish(); -pkgcloud/joyent/compute/client/servers.js, line 188, character 7: 'finish' was used before it was defined. -finish(); -pkgcloud/joyent/compute/client/servers.js, line 189, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/joyent/compute/client/servers.js, line 191, character 14: 'finish' was used before it was defined. -function finish() { -pkgcloud/joyent/compute/client/servers.js, line 215, character 7: Expected 'serverId' at column 5, not column 7. -serverId = server instanceof base.Server ? server.id : server; -pkgcloud/joyent/compute/client/servers.js, line 218, character 7: Expected 'path' at column 5, not column 7. -path: this.account + '/machines/' + serverId -pkgcloud/joyent/compute/client/servers.js, line 219, character 5: Expected '}' at column 3, not column 5. -}, function (err, body, res) { -pkgcloud/joyent/compute/client/servers.js, line 220, character 7: Expected 'return' at column 5, not column 7. -return err -pkgcloud/joyent/compute/client/servers.js, line 236, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/mongohq/database/client/databases.js, line 8, character 2: Expected 'var' at column 1, not column 2. -var errs = require('errs'), -pkgcloud/mongohq/database/client/databases.js, line 9, character 6: Expected 'url' at column 3, not column 6. -url = require('url'); -pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Expected ';' and instead saw ','. -dbname = info.pathname.replace('/', ''), -pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Expected ',' at column 3, not column 42. -dbname = info.pathname.replace('/', ''), -pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Expected an identifier and instead saw ','. -dbname = info.pathname.replace('/', ''), -pkgcloud/mongohq/database/client/databases.js, line 20, character 42: Stopping. (19% scanned). - -pkgcloud/mongohq/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/mongohq/database/client/index.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/base'), -pkgcloud/mongohq/database/client/index.js, line 11, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth'), -pkgcloud/mongohq/database/client/index.js, line 12, character 5: Expected 'url' at column 3, not column 5. -url = require('url'), -pkgcloud/mongohq/database/client/index.js, line 13, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/mongohq/database/client/index.js, line 14, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'); -pkgcloud/mongolab/database/client/accounts.js, line 9, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'); -pkgcloud/mongolab/database/client/accounts.js, line 15, character 119: Line too long. -// #### options['password'] {string} Password for the account (Optional), If not specify so mongolab will generate one. -pkgcloud/mongolab/database/client/accounts.js, line 25, character 16: ['name'] is better written in dot notation. -if (!options['name']) { -pkgcloud/mongolab/database/client/accounts.js, line 31, character 16: ['email'] is better written in dot notation. -if (!options['email']) { -pkgcloud/mongolab/database/client/accounts.js, line 38, character 133: Line too long. -// https://objectlabs.jira.com/wiki/display/partners/MongoLab+Partner+Integration+API#MongoLabPartnerIntegrationAPI-Createaccount.1 -pkgcloud/mongolab/database/client/accounts.js, line 40, character 36: ['email'] is better written in dot notation. -var adminUser = { email: options['email'] }; -pkgcloud/mongolab/database/client/accounts.js, line 42, character 15: ['password'] is better written in dot notation. -if (options['password']) { -pkgcloud/mongolab/database/client/accounts.js, line 43, character 31: ['password'] is better written in dot notation. -if (/[+\d]/g.test(options['password'])) { -pkgcloud/mongolab/database/client/accounts.js, line 44, character 17: ['password'] is better written in dot notation. -adminUser['password'] = options['password']; -pkgcloud/mongolab/database/client/accounts.js, line 44, character 39: ['password'] is better written in dot notation. -adminUser['password'] = options['password']; -pkgcloud/mongolab/database/client/accounts.js, line 52, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/mongolab/database/client/accounts.js, line 56, character 44: ['name'] is better written in dot notation. -name: [this.config.username, options['name']].join('_'), -pkgcloud/mongolab/database/client/accounts.js, line 98, character 11: Expected 'return' at column 9, not column 11. -return account.adminUser; -pkgcloud/mongolab/database/client/accounts.js, line 99, character 9: Expected '}' at column 7, not column 9. -})); -pkgcloud/mongolab/database/client/databases.js, line 9, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/mongolab/database/client/databases.js, line 10, character 5: Expected 'qs' at column 3, not column 5. -qs = require('querystring'), -pkgcloud/mongolab/database/client/databases.js, line 11, character 5: Expected 'url' at column 3, not column 5. -url = require('url'); -pkgcloud/mongolab/database/client/databases.js, line 25, character 7: Combine this with the previous 'var' statement. -var database = { -pkgcloud/mongolab/database/client/databases.js, line 51, character 16: ['name'] is better written in dot notation. -if (!options['name']) { -pkgcloud/mongolab/database/client/databases.js, line 57, character 16: ['owner'] is better written in dot notation. -if (!options['owner']) { -pkgcloud/mongolab/database/client/databases.js, line 63, character 16: ['plan'] is better written in dot notation. -if (!options['plan']) { -pkgcloud/mongolab/database/client/databases.js, line 64, character 13: ['plan'] is better written in dot notation. -options['plan'] = 'free'; -pkgcloud/mongolab/database/client/databases.js, line 69, character 31: ['owner'] is better written in dot notation. -var databaseName = [options['owner'], options['name']].join('_'); -pkgcloud/mongolab/database/client/databases.js, line 69, character 49: ['name'] is better written in dot notation. -var databaseName = [options['owner'], options['name']].join('_'); -pkgcloud/mongolab/database/client/databases.js, line 75, character 7: Combine this with the previous 'var' statement. -var account = options['owner']; -pkgcloud/mongolab/database/client/databases.js, line 75, character 25: ['owner'] is better written in dot notation. -var account = options['owner']; -pkgcloud/mongolab/database/client/databases.js, line 77, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/mongolab/database/client/databases.js, line 82, character 21: ['plan'] is better written in dot notation. -plan: options['plan'], -pkgcloud/mongolab/database/client/databases.js, line 83, character 25: ['owner'] is better written in dot notation. -username: options['owner'], -pkgcloud/mongolab/database/client/databases.js, line 119, character 128: Line too long. -// https://objectlabs.jira.com/wiki/display/partners/MongoLab+Partner+Integration+API#MongoLabPartnerIntegrationAPI-Viewdatabase -pkgcloud/mongolab/database/client/databases.js, line 133, character 16: ['name'] is better written in dot notation. -if (!options['name']) { -pkgcloud/mongolab/database/client/databases.js, line 140, character 16: ['owner'] is better written in dot notation. -if (!options['owner']) { -pkgcloud/mongolab/database/client/databases.js, line 146, character 35: ['owner'] is better written in dot notation. -var path = ['accounts', options['owner'], 'databases', options['name']].join('/'); -pkgcloud/mongolab/database/client/databases.js, line 146, character 66: ['name'] is better written in dot notation. -var path = ['accounts', options['owner'], 'databases', options['name']].join('/'); -pkgcloud/mongolab/database/client/databases.js, line 169, character 16: ['name'] is better written in dot notation. -if (!options['name']) { -pkgcloud/mongolab/database/client/databases.js, line 176, character 16: ['owner'] is better written in dot notation. -if (!options['owner']) { -pkgcloud/mongolab/database/client/databases.js, line 184, character 32: ['owner'] is better written in dot notation. -path: ['accounts', options['owner'], 'databases', options['name']].join('/') -pkgcloud/mongolab/database/client/databases.js, line 184, character 63: ['name'] is better written in dot notation. -path: ['accounts', options['owner'], 'databases', options['name']].join('/') -pkgcloud/mongolab/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/mongolab/database/client/index.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/base'), -pkgcloud/mongolab/database/client/index.js, line 11, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth'); -pkgcloud/mongolab/database/client/index.js, line 44, character 7: Use the || operator. -? this.config.username -pkgcloud/openstack/client.js, line 9, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/openstack/client.js, line 10, character 5: Expected 'through' at column 3, not column 5. -through = require('through'), -pkgcloud/openstack/client.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../core/base'), -pkgcloud/openstack/client.js, line 12, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/openstack/client.js, line 13, character 5: Expected 'context' at column 3, not column 5. -context = require('./context'); -pkgcloud/openstack/client.js, line 62, character 39: Expected exactly one space between 'function' and '('. -this._identity.on('log::*', function(message, object) { -pkgcloud/openstack/client.js, line 71, character 48: Expected exactly one space between 'function' and '('. -Client.prototype._getIdentityOptions = function() { -pkgcloud/openstack/client.js, line 81, character 3: Expected exactly one space between '}' and 'else'. -else if (this.config.tenantName) { -pkgcloud/openstack/client.js, line 81, character 3: Expected 'else' at column 5, not column 3. -else if (this.config.tenantName) { -pkgcloud/openstack/client.js, line 128, character 36: Expected exactly one space between 'function' and '('. -self._identity.authorize(function(err) { -pkgcloud/openstack/client.js, line 150, character 5: Expected exactly one space between '}' and 'catch'. -catch (e) { -pkgcloud/openstack/client.js, line 150, character 5: Expected 'catch' at column 7, not column 5. -catch (e) { -pkgcloud/openstack/client.js, line 151, character 7: Expected 'self' at column 9, not column 7. -self.emit('log::error', 'Unable to select endpoint for service', { -pkgcloud/openstack/client.js, line 152, character 9: Expected 'error' at column 11, not column 9. -error: e.toString(), -pkgcloud/openstack/client.js, line 153, character 9: Expected 'options' at column 11, not column 9. -options: options -pkgcloud/openstack/client.js, line 154, character 7: Expected '}' at column 9, not column 7. -}); -pkgcloud/openstack/client.js, line 155, character 7: Expected 'callback' at column 9, not column 7. -callback(e); -pkgcloud/openstack/client.js, line 156, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/client.js, line 175, character 9: Combine this with the previous 'var' statement. -var buf = through().pause(); -pkgcloud/openstack/client.js, line 188, character 7: Expected exactly one space between '}' and 'else'. -else if (options.download) { -pkgcloud/openstack/client.js, line 188, character 7: Expected 'else' at column 9, not column 7. -else if (options.download) { -pkgcloud/openstack/client.js, line 195, character 5: Unexpected 'else' after 'return'. -return buf; -pkgcloud/openstack/client.js, line 197, character 3: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/client.js, line 197, character 3: Expected 'else' at column 5, not column 3. -else { -pkgcloud/openstack/client.js, line 198, character 5: Expected 'self' at column 7, not column 5. -self.emit('log::trace', 'Creating Authenticated Request'); -pkgcloud/openstack/client.js, line 199, character 5: Expected 'return' at column 7, not column 5. -return Client.super_.prototype._request.call(self, options, callback); -pkgcloud/openstack/client.js, line 200, character 3: Expected '}' at column 5, not column 3. -} -pkgcloud/openstack/client.js, line 205, character 7: Expected 'authorized' at column 5, not column 7. -authorized = false; -pkgcloud/openstack/client.js, line 207, character 131: Line too long. -if (!self._serviceUrl || !self._identity || !self._identity.token || !self._identity.token.id || !self._identity.token.expires) { -pkgcloud/openstack/client.js, line 210, character 107: Line too long. -else if (self._identity.token.expires.getTime() - new Date().getTime() > self.config.earlyTokenTimeout) { -pkgcloud/openstack/client.js, line 210, character 3: Expected exactly one space between '}' and 'else'. -else if (self._identity.token.expires.getTime() - new Date().getTime() > self.config.earlyTokenTimeout) { -pkgcloud/openstack/client.js, line 210, character 3: Expected 'else' at column 5, not column 3. -else if (self._identity.token.expires.getTime() - new Date().getTime() > self.config.earlyTokenTimeout) { -pkgcloud/openstack/compute/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/flavor'); -pkgcloud/openstack/compute/image.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/image'); -pkgcloud/openstack/compute/server.js, line 9, character 5: Expected 'compute' at column 3, not column 5. -compute = require('../../core/compute'), -pkgcloud/openstack/compute/server.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/compute/server'), -pkgcloud/openstack/compute/server.js, line 11, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/compute/server.js, line 27, character 7: Expected 'case' at column 5, not column 7. -case 'BUILD': -pkgcloud/openstack/compute/server.js, line 28, character 7: Expected 'case' at column 5, not column 7. -case 'REBUILD': -pkgcloud/openstack/compute/server.js, line 29, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.provisioning; -pkgcloud/openstack/compute/server.js, line 30, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/openstack/compute/server.js, line 31, character 7: Expected 'case' at column 5, not column 7. -case 'ACTIVE': -pkgcloud/openstack/compute/server.js, line 32, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.running; -pkgcloud/openstack/compute/server.js, line 33, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/openstack/compute/server.js, line 34, character 7: Expected 'case' at column 5, not column 7. -case 'SUSPENDED': -pkgcloud/openstack/compute/server.js, line 35, character 7: Expected 'case' at column 5, not column 7. -case 'SHUTOFF': -pkgcloud/openstack/compute/server.js, line 36, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.stopped; -pkgcloud/openstack/compute/server.js, line 37, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/openstack/compute/server.js, line 38, character 7: Expected 'case' at column 5, not column 7. -case 'REBOOT': -pkgcloud/openstack/compute/server.js, line 39, character 7: Expected 'case' at column 5, not column 7. -case 'HARD_REBOOT': -pkgcloud/openstack/compute/server.js, line 40, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.reboot; -pkgcloud/openstack/compute/server.js, line 41, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/openstack/compute/server.js, line 42, character 7: Expected 'case' at column 5, not column 7. -case 'QUEUE_RESIZE': -pkgcloud/openstack/compute/server.js, line 43, character 7: Expected 'case' at column 5, not column 7. -case 'PREP_RESIZE': -pkgcloud/openstack/compute/server.js, line 44, character 7: Expected 'case' at column 5, not column 7. -case 'RESIZE': -pkgcloud/openstack/compute/server.js, line 45, character 7: Expected 'case' at column 5, not column 7. -case 'VERIFY_RESIZE': -pkgcloud/openstack/compute/server.js, line 46, character 7: Expected 'case' at column 5, not column 7. -case 'SHARE_IP': -pkgcloud/openstack/compute/server.js, line 47, character 7: Expected 'case' at column 5, not column 7. -case 'SHARE_IP_NO_CONFIG': -pkgcloud/openstack/compute/server.js, line 48, character 7: Expected 'case' at column 5, not column 7. -case 'DELETE_IP': -pkgcloud/openstack/compute/server.js, line 49, character 7: Expected 'case' at column 5, not column 7. -case 'PASSWORD': -pkgcloud/openstack/compute/server.js, line 50, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.updating; -pkgcloud/openstack/compute/server.js, line 51, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/openstack/compute/server.js, line 52, character 7: Expected 'case' at column 5, not column 7. -case 'RESCUE': -pkgcloud/openstack/compute/server.js, line 53, character 7: Expected 'case' at column 5, not column 7. -case 'ERROR': -pkgcloud/openstack/compute/server.js, line 54, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.error; -pkgcloud/openstack/compute/server.js, line 55, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/openstack/compute/server.js, line 56, character 7: Expected 'default' at column 5, not column 7. -default: -pkgcloud/openstack/compute/server.js, line 57, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.unknown; -pkgcloud/openstack/compute/server.js, line 58, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/openstack/compute/server.js, line 76, character 61: Expected an identifier and instead saw 'public' (a reserved word). -if (Object.keys(this.addresses).length && !this.addresses.public -pkgcloud/openstack/compute/server.js, line 77, character 5: Expected '&&' at column 7, not column 5. -&& !this.addresses.private) { -pkgcloud/openstack/compute/server.js, line 77, character 24: Expected an identifier and instead saw 'private' (a reserved word). -&& !this.addresses.private) { -pkgcloud/openstack/compute/server.js, line 83, character 47: Expected an identifier and instead saw 'interface' (a reserved word). -Object.keys(interfaces).map(function (interface) { -pkgcloud/openstack/compute/server.js, line 84, character 29: Expected an identifier and instead saw 'interface'. -return interfaces[interface].addr; -pkgcloud/openstack/compute/server.js, line 84, character 29: Stopping. (58% scanned). - -pkgcloud/openstack/compute/client/flavors.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/openstack/compute/client/flavors.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/compute/client/flavors.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.openstack.compute; -pkgcloud/openstack/compute/client/flavors.js, line 22, character 30: Expected exactly one space between 'function' and '('. -exports.getFlavors = function(callback) { -pkgcloud/openstack/compute/client/flavors.js, line 32, character 7: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/openstack/compute/client/flavors.js, line 34, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/compute/client/flavors.js, line 34, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/openstack/compute/client/flavors.js, line 35, character 7: Expected 'return' at column 9, not column 7. -return callback(null, body.flavors.map(function (result) { -pkgcloud/openstack/compute/client/flavors.js, line 36, character 9: Expected 'return' at column 11, not column 9. -return new compute.Flavor(self, result); -pkgcloud/openstack/compute/client/flavors.js, line 37, character 7: Expected '}' at column 9, not column 7. -})); -pkgcloud/openstack/compute/client/flavors.js, line 38, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/compute/client/flavors.js, line 53, character 7: Expected 'flavorId' at column 5, not column 7. -flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; -pkgcloud/openstack/compute/client/flavors.js, line 62, character 7: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/openstack/compute/client/flavors.js, line 64, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/compute/client/flavors.js, line 64, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/openstack/compute/client/flavors.js, line 65, character 7: Expected 'return' at column 9, not column 7. -return callback(null, new compute.Flavor(self, body.flavor)); -pkgcloud/openstack/compute/client/flavors.js, line 66, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/compute/client/images.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/openstack/compute/client/images.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/compute/client/images.js, line 10, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.openstack.compute; -pkgcloud/openstack/compute/client/images.js, line 36, character 20: Unexpected space between '!' and 'body'. -if (!body || ! body.images) { -pkgcloud/openstack/compute/client/images.js, line 37, character 7: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/openstack/compute/client/images.js, line 39, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/compute/client/images.js, line 39, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/openstack/compute/client/images.js, line 40, character 7: Expected 'return' at column 9, not column 7. -return callback(null, body.images.map(function (result) { -pkgcloud/openstack/compute/client/images.js, line 41, character 9: Expected 'return' at column 11, not column 9. -return new compute.Image(self, result); -pkgcloud/openstack/compute/client/images.js, line 42, character 7: Expected '}' at column 9, not column 7. -})); -pkgcloud/openstack/compute/client/images.js, line 43, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/compute/client/images.js, line 58, character 7: Expected 'imageId' at column 5, not column 7. -imageId = image instanceof base.Image ? image.id : image; -pkgcloud/openstack/compute/client/images.js, line 67, character 7: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/openstack/compute/client/images.js, line 69, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/compute/client/images.js, line 69, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/openstack/compute/client/images.js, line 70, character 7: Expected 'return' at column 9, not column 7. -return callback(null, new compute.Image(self, body.image)); -pkgcloud/openstack/compute/client/images.js, line 71, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/compute/client/images.js, line 89, character 7: Expected 'serverId' at column 5, not column 7. -serverId; -pkgcloud/openstack/compute/client/images.js, line 95, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/openstack/compute/client/images.js, line 110, character 16: Expected exactly one space between 'function' and '('. -}, function(err, body) { -pkgcloud/openstack/compute/client/images.js, line 115, character 9: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/openstack/compute/client/images.js, line 117, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/compute/client/images.js, line 117, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/openstack/compute/client/images.js, line 118, character 9: Expected 'return' at column 11, not column 9. -return callback(null, new compute.Image(self, body.image)); -pkgcloud/openstack/compute/client/images.js, line 119, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/openstack/compute/client/images.js, line 137, character 7: Expected 'path' at column 5, not column 7. -path: urlJoin(_urlPrefix, imageId), -pkgcloud/openstack/compute/client/images.js, line 138, character 7: Expected 'method' at column 5, not column 7. -method: 'DELETE' -pkgcloud/openstack/compute/client/images.js, line 139, character 5: Expected '}' at column 3, not column 5. -}, -pkgcloud/openstack/compute/client/images.js, line 144, character 3: Expected '}' at column 5, not column 3. -}); -pkgcloud/openstack/compute/client/index.js, line 9, character 5: Expected 'openstack' at column 3, not column 5. -openstack = require('../../client'), -pkgcloud/openstack/compute/client/index.js, line 10, character 5: Expected 'ComputeClient' at column 3, not column 5. -ComputeClient = require('../computeClient').ComputeClient, -pkgcloud/openstack/compute/client/index.js, line 11, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/compute/client/servers.js, line 8, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/compute'), -pkgcloud/openstack/compute/client/servers.js, line 9, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/openstack/compute/client/servers.js, line 10, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/openstack/compute/client/servers.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/compute/client/servers.js, line 12, character 5: Expected 'util' at column 3, not column 5. -util = require('util'), -pkgcloud/openstack/compute/client/servers.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'), -pkgcloud/openstack/compute/client/servers.js, line 14, character 5: Expected 'Server' at column 3, not column 5. -Server = require('../server').Server, -pkgcloud/openstack/compute/client/servers.js, line 15, character 5: Expected 'compute' at column 3, not column 5. -compute = pkgcloud.providers.openstack.compute; -pkgcloud/openstack/compute/client/servers.js, line 30, character 35: Expected exactly one space between 'function' and '('. -exports._doServerAction = function(server, body, callback) { -pkgcloud/openstack/compute/client/servers.js, line 32, character 7: Expected 'serverId' at column 5, not column 7. -serverId = server instanceof Server ? server.id : server; -pkgcloud/openstack/compute/client/servers.js, line 34, character 7: Combine this with the previous 'var' statement. -var actionOptions = { -pkgcloud/openstack/compute/client/servers.js, line 62, character 7: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/openstack/compute/client/servers.js, line 80, character 7: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/openstack/compute/client/servers.js, line 82, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/compute/client/servers.js, line 82, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/openstack/compute/client/servers.js, line 83, character 7: Expected 'return' at column 9, not column 7. -return callback(null, body.servers.map(function (result) { -pkgcloud/openstack/compute/client/servers.js, line 84, character 9: Expected 'return' at column 11, not column 9. -return new compute.Server(self, result); -pkgcloud/openstack/compute/client/servers.js, line 85, character 7: Expected '}' at column 9, not column 7. -})); -pkgcloud/openstack/compute/client/servers.js, line 86, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/compute/client/servers.js, line 115, character 8: 'validateProperties' was used before it was defined. -if (!validateProperties(['flavor', 'image', 'name'], details, -pkgcloud/openstack/compute/client/servers.js, line 116, character 5: Expected 'options.%s is a required argument.' at column 7, not column 5. -'options.%s is a required argument.', callback)) { -pkgcloud/openstack/compute/client/servers.js, line 184, character 7: Expected 'serverId' at column 5, not column 7. -serverId = server instanceof base.Server ? server.id : server; -pkgcloud/openstack/compute/client/servers.js, line 193, character 7: Unexpected 'else' after 'return'. -return new Error('Unexpected empty response'); -pkgcloud/openstack/compute/client/servers.js, line 195, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/compute/client/servers.js, line 195, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/openstack/compute/client/servers.js, line 196, character 7: Expected 'callback' at column 9, not column 7. -callback(null, new compute.Server(self, body.server), res); -pkgcloud/openstack/compute/client/servers.js, line 197, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/compute/client/servers.js, line 351, character 7: Combine this with the previous 'var' statement. -var options = { -pkgcloud/openstack/compute/client/servers.js, line 379, character 15: Expected exactly one space between 'typeof' and '('. -if (typeof(options[item]) === 'undefined') { -pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'); -pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 42, character 41: Expected exactly one space between 'function' and '('. -exports.allocateNewFloatingIp = function(pool, callback) { -pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 58, character 41: Expected exactly one space between 'function' and '('. -return this._request(options, function(err, body) { -pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 74, character 33: Expected exactly one space between 'function' and '('. -exports.getFloatingIp = function(floatingIp, callback) { -pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 118, character 88: Expected ';' and instead saw 'return'. -var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp -pkgcloud/openstack/compute/client/extensions/floating-ips.js, line 140, character 88: Expected ';' and instead saw 'return'. -var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp -pkgcloud/openstack/compute/client/extensions/index.js, line 14, character 26: Expected exactly one space between 'function' and '('. -getExtensions: function(callback) { -pkgcloud/openstack/compute/client/extensions/keys.js, line 45, character 3: Expected exactly one space between '}' and 'else'. -else if (options.key) { -pkgcloud/openstack/compute/client/extensions/keys.js, line 45, character 3: Expected 'else' at column 5, not column 3. -else if (options.key) { -pkgcloud/openstack/compute/client/extensions/networks-base.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/compute/client/extensions/networks-base.js, line 14, character 42: Expected exactly one space between 'function' and '('. -exports.createNetworkExtension = function(prefix) { -pkgcloud/openstack/compute/client/extensions/networks-base.js, line 66, character 102: Line too long. -* @param {String} [options.bridge_interface] The bridge is connected to this interface. -pkgcloud/openstack/compute/client/extensions/networks-base.js, line 239, character 4: Expected ';' and instead saw '}'. -} -pkgcloud/openstack/compute/client/extensions/networks.js, line 12, character 5: Expected 'networks' at column 3, not column 5. -networks = require('./networks-base'); -pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 9, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'), -pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 10, character 5: Expected 'async' at column 3, not column 5. -async = require('async'); -pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 48, character 29: ['security_group_rule'] is better written in dot notation. -: callback(null, body['security_group_rule'], res); -pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 61, character 28: Expected exactly one space between 'function' and '('. -exports.addRules = function(rules, callback) { -pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 64, character 40: Expected exactly one space between 'function' and '('. -async.forEachLimit(rules, 5, function(rule, next) { -pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 65, character 32: Expected exactly one space between 'function' and '('. -self.addRule(rule, function(err, rule) { -pkgcloud/openstack/compute/client/extensions/security-group-rules.js, line 74, character 14: Expected exactly one space between 'function' and '('. -}, function(err) { -pkgcloud/openstack/compute/client/extensions/security-groups.js, line 32, character 29: ['security_groups'] is better written in dot notation. -: callback(null, body['security_groups'], res); -pkgcloud/openstack/compute/client/extensions/security-groups.js, line 41, character 103: Line too long. -* @param {object|String} options The object (or securityGroup to generate) for the new group -pkgcloud/openstack/compute/client/extensions/security-groups.js, line 65, character 29: ['security_group'] is better written in dot notation. -: callback(null, body['security_group']); -pkgcloud/openstack/compute/client/extensions/servers.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'); -pkgcloud/openstack/compute/client/extensions/servers.js, line 25, character 5: Expected 'return' at column 3, not column 5. -return this._doServerAction(server, -pkgcloud/openstack/compute/client/extensions/servers.js, line 28, character 13: Expected 'return' at column 7, not column 13. -return callback(err); -pkgcloud/openstack/compute/client/extensions/servers.js, line 42, character 5: Expected 'return' at column 3, not column 5. -return this._doServerAction(server, -pkgcloud/openstack/compute/client/extensions/servers.js, line 45, character 13: Expected 'return' at column 7, not column 13. -return callback(err); -pkgcloud/openstack/compute/client/extensions/servers.js, line 46, character 9: Expected '}' at column 5, not column 9. -}); -pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'); -pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 14, character 5: Expected '_extension' at column 3, not column 5. -_extension = 'os-volume_attachments'; -pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 25, character 40: Expected exactly one space between 'function' and '('. -exports.getVolumeAttachments = function(server, callback) { -pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 49, character 7: Expected 'attachmentId' at column 5, not column 7. -attachmentId = (typeof attachment === 'object') ? attachment.id : attachment; -pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 70, character 32: Expected exactly one space between 'function' and '('. -exports.detachVolume = function(server, attachment, callback) { -pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 72, character 7: Expected 'attachmentId' at column 5, not column 7. -attachmentId = (typeof attachment === 'object') ? attachment.id : attachment; -pkgcloud/openstack/compute/client/extensions/volume-attachments.js, line 94, character 7: Expected 'volumeId' at column 5, not column 7. -volumeId = (typeof volume === 'object') ? volume.id : volume; -pkgcloud/openstack/context/identity.js, line 10, character 5: Expected 'events' at column 3, not column 5. -events = require('eventemitter2'), -pkgcloud/openstack/context/identity.js, line 11, character 5: Expected 'fs' at column 3, not column 5. -fs = require('fs'), -pkgcloud/openstack/context/identity.js, line 12, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/openstack/context/identity.js, line 13, character 5: Expected 'ServiceCatalog' at column 3, not column 5. -ServiceCatalog = require('./serviceCatalog').ServiceCatalog, -pkgcloud/openstack/context/identity.js, line 14, character 5: Expected 'svcCat' at column 3, not column 5. -svcCat = require('./serviceCatalog'), -pkgcloud/openstack/context/identity.js, line 15, character 5: Expected 'url' at column 3, not column 5. -url = require('url'), -pkgcloud/openstack/context/identity.js, line 16, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/openstack/context/identity.js, line 17, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/context/identity.js, line 18, character 5: Expected 'util' at column 3, not column 5. -util = require('util'), -pkgcloud/openstack/context/identity.js, line 19, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../pkgcloud'), -pkgcloud/openstack/context/identity.js, line 20, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'); -pkgcloud/openstack/context/identity.js, line 80, character 7: Combine this with the previous 'var' statement. -var authenticationOptions = { -pkgcloud/openstack/context/identity.js, line 103, character 3: Expected exactly one space between '}' and 'else'. -else if (self.options.tenantName) { -pkgcloud/openstack/context/identity.js, line 103, character 3: Expected 'else' at column 5, not column 3. -else if (self.options.tenantName) { -pkgcloud/openstack/context/identity.js, line 116, character 16: 'getError' was used before it was defined. -var err2 = getError(err, response, body); -pkgcloud/openstack/context/identity.js, line 132, character 7: 'getTenantId' was used before it was defined. -getTenantId(urlJoin(options.url || self.options.url, '/v2.0/tenants'), body.access.token.id); -pkgcloud/openstack/context/identity.js, line 134, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/context/identity.js, line 134, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/openstack/context/identity.js, line 135, character 7: Expected 'try' at column 9, not column 7. -try { -pkgcloud/openstack/context/identity.js, line 136, character 9: Expected 'self' at column 11, not column 9. -self._parseIdentityResponse(body); -pkgcloud/openstack/context/identity.js, line 137, character 9: Expected 'callback' at column 11, not column 9. -callback(); -pkgcloud/openstack/context/identity.js, line 138, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/openstack/context/identity.js, line 139, character 7: Expected exactly one space between '}' and 'catch'. -catch (e) { -pkgcloud/openstack/context/identity.js, line 139, character 7: Expected 'catch' at column 11, not column 7. -catch (e) { -pkgcloud/openstack/context/identity.js, line 140, character 9: Expected 'callback' at column 13, not column 9. -callback(e); -pkgcloud/openstack/context/identity.js, line 141, character 7: Expected '}' at column 11, not column 7. -} -pkgcloud/openstack/context/identity.js, line 142, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/openstack/context/identity.js, line 158, character 29: Use the || operator. -return callback(err ? err : new Error('Unable to find tenants')); -pkgcloud/openstack/context/identity.js, line 204, character 3: Expected exactly one space between '}' and 'else'. -else if (self.options.token && (self.options.tenantId || self.options.tenantName)) { -pkgcloud/openstack/context/identity.js, line 204, character 3: Expected 'else' at column 5, not column 3. -else if (self.options.token && (self.options.tenantId || self.options.tenantName)) { -pkgcloud/openstack/context/identity.js, line 230, character 1: Unexpected '(space)'. - -pkgcloud/openstack/context/identity.js, line 237, character 6: Expected 'self' at column 5, not column 6. -self.serviceCatalog = new ServiceCatalog(data.access.serviceCatalog); -pkgcloud/openstack/context/identity.js, line 247, character 5: Unexpected 'else' after 'return'. -return this.serviceCatalog.getServiceEndpointUrl(options); -pkgcloud/openstack/context/identity.js, line 249, character 3: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/context/identity.js, line 249, character 3: Expected 'else' at column 5, not column 3. -else { -pkgcloud/openstack/context/identity.js, line 250, character 5: Expected 'return' at column 7, not column 5. -return this.options.url; -pkgcloud/openstack/context/identity.js, line 251, character 3: Expected '}' at column 5, not column 3. -} -pkgcloud/openstack/context/service.js, line 64, character 32: 'matchRegion' was used before it was defined. -if (!endpoint.region || !matchRegion(endpoint.region, options.region)) { -pkgcloud/openstack/context/service.js, line 68, character 13: 'getUrl' was used before it was defined. -url = getUrl(endpoint); -pkgcloud/openstack/context/service.js, line 71, character 3: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/context/service.js, line 71, character 3: Expected 'else' at column 5, not column 3. -else { -pkgcloud/openstack/context/service.js, line 72, character 5: Expected '_' at column 7, not column 5. -_.each(self.endpoints, function(endpoint) { -pkgcloud/openstack/context/service.js, line 72, character 36: Expected exactly one space between 'function' and '('. -_.each(self.endpoints, function(endpoint) { -pkgcloud/openstack/context/service.js, line 74, character 7: Expected 'if' at column 9, not column 7. -if (url) { -pkgcloud/openstack/context/service.js, line 75, character 9: Expected 'return' at column 11, not column 9. -return; -pkgcloud/openstack/context/service.js, line 76, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/openstack/context/service.js, line 79, character 7: Expected 'if' at column 9, not column 7. -if (!endpoint.region) { -pkgcloud/openstack/context/service.js, line 80, character 9: Expected 'url' at column 11, not column 9. -url = getUrl(endpoint); -pkgcloud/openstack/context/service.js, line 80, character 15: 'getUrl' was used before it was defined. -url = getUrl(endpoint); -pkgcloud/openstack/context/service.js, line 81, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/openstack/context/service.js, line 82, character 5: Expected '}' at column 7, not column 5. -}); -pkgcloud/openstack/context/service.js, line 83, character 3: Expected '}' at column 5, not column 3. -} -pkgcloud/openstack/context/service.js, line 97, character 7: Expected 'options' at column 11, not column 7. -options.useInternal : false; -pkgcloud/openstack/context/service.js, line 102, character 9: Expected 'endpoint' at column 11, not column 9. -endpoint.adminURL : endpoint.publicURL); -pkgcloud/openstack/context/service.js, line 116, character 5: Unexpected 'else' after 'return'. -return true; -pkgcloud/openstack/context/service.js, line 118, character 3: Expected exactly one space between '}' and 'else'. -else if ((!a && b) || (a && !b)) { -pkgcloud/openstack/context/service.js, line 118, character 3: Expected 'else' at column 5, not column 3. -else if ((!a && b) || (a && !b)) { -pkgcloud/openstack/context/serviceCatalog.js, line 10, character 5: Expected 'Service' at column 3, not column 5. -Service = require('./service').Service, -pkgcloud/openstack/context/serviceCatalog.js, line 11, character 5: Expected 'async' at column 3, not column 5. -async = require('async'), -pkgcloud/openstack/context/serviceCatalog.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/context/serviceCatalog.js, line 37, character 58: Expected exactly one space between 'function' and '('. -ServiceCatalog.prototype.getServiceEndpointUrl = function(options) { -pkgcloud/openstack/context/serviceCatalog.js, line 40, character 7: Combine this with the previous 'var' statement. -var _endpoint = null; -pkgcloud/openstack/context/serviceCatalog.js, line 42, character 33: Expected exactly one space between 'function' and '('. -_.each(self.services, function(service) { -pkgcloud/openstack/context/serviceCatalog.js, line 51, character 5: Unexpected 'else' after 'return'. -return _endpoint; -pkgcloud/openstack/context/serviceCatalog.js, line 53, character 3: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/openstack/context/serviceCatalog.js, line 53, character 3: Expected 'else' at column 5, not column 3. -else { -pkgcloud/openstack/context/serviceCatalog.js, line 54, character 5: Expected 'throw' at column 7, not column 5. -throw new Error('Unable to find matching endpoint for requested service'); -pkgcloud/openstack/context/serviceCatalog.js, line 55, character 3: Expected '}' at column 5, not column 3. -} -pkgcloud/openstack/identity/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/identity/client/index.js, line 11, character 5: Expected 'openstack' at column 3, not column 5. -openstack = require('../../client'), -pkgcloud/openstack/identity/client/index.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/identity/client/index.js, line 80, character 114: Line too long. -* This is an administrative API that allows a admin to get detailed information about the specified tenant by ID -pkgcloud/openstack/identity/client/index.js, line 94, character 45: Use the || operator. -path: urlJoin('/v2.0/tenants', tenantId ? tenantId : '') -pkgcloud/openstack/network/network.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/network/network'), -pkgcloud/openstack/network/network.js, line 10, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/network.js, line 30, character 3: Expected 'tenant_id' at column 5, not column 3. -'tenant_id', 'subnets']); -pkgcloud/openstack/network/networkClient.js, line 9, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/networkClient.js, line 30, character 7: Expected exactly one space between 'if' and '('. -if(options.method === 'GET') { -pkgcloud/openstack/network/networkClient.js, line 40, character 7: Combine this with the previous 'var' statement. -var serviceUrl = options.serviceType ? this._identity.getServiceEndpointUrl({ -pkgcloud/openstack/network/port.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/network/port'), -pkgcloud/openstack/network/port.js, line 10, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/port.js, line 37, character 3: Expected 'network_id' at column 5, not column 3. -'network_id', 'tenant_id', 'extra_dhcp_opts', 'device_owner', -pkgcloud/openstack/network/port.js, line 38, character 3: Expected 'mac_address' at column 5, not column 3. -'mac_address', 'fixed_ips', 'id', 'security_groups', 'device_id']); -pkgcloud/openstack/network/subnet.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/network/subnet'), -pkgcloud/openstack/network/subnet.js, line 10, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/subnet.js, line 32, character 3: Expected 'tenant_id' at column 5, not column 3. -'tenant_id', 'gateway_ip', 'dns_nameservers']); -pkgcloud/openstack/network/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/network/client/index.js, line 10, character 5: Expected 'openstack' at column 3, not column 5. -openstack = require('../../client'), -pkgcloud/openstack/network/client/index.js, line 11, character 5: Expected 'NetworkClient' at column 3, not column 5. -NetworkClient = require('../networkClient').NetworkClient, -pkgcloud/openstack/network/client/index.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/client/networks.js, line 10, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/openstack/network/client/networks.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/openstack/network/client/networks.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/network/client/networks.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/client/networks.js, line 31, character 7: Combine this with the previous 'var' statement. -var getNetworkOpts = { -pkgcloud/openstack/network/client/networks.js, line 37, character 7: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/openstack/network/client/networks.js, line 39, character 5: Expected exactly one space between '}' and 'else'. -else if (!body || !body.networks || !(body.networks instanceof Array)) { -pkgcloud/openstack/network/client/networks.js, line 39, character 5: Expected 'else' at column 7, not column 5. -else if (!body || !body.networks || !(body.networks instanceof Array)) { -pkgcloud/openstack/network/client/networks.js, line 69, character 17: Missing space between '||' and '!'. -if (!body ||!body.network) { -pkgcloud/openstack/network/client/networks.js, line 88, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/openstack/network/client/networks.js, line 90, character 7: Combine this with the previous 'var' statement. -var createNetworkOpts = { -pkgcloud/openstack/network/client/networks.js, line 97, character 50: Missing space between ',' and 'body'. -this._request(createNetworkOpts, function (err,body) { -pkgcloud/openstack/network/client/networks.js, line 113, character 105: Line too long. -var self = this, networkToUpdate = network instanceof this.models.Network ? network.toJSON() : network; -pkgcloud/openstack/network/client/networks.js, line 114, character 7: Combine this with the previous 'var' statement. -var createNetworkOpts = { -pkgcloud/openstack/network/client/networks.js, line 122, character 50: Missing space between ',' and 'body'. -this._request(createNetworkOpts, function (err,body) { -pkgcloud/openstack/network/client/networks.js, line 142, character 36: Missing space between ',' and 'networkId'. -path: urlJoin('/v2.0/networks',networkId), -pkgcloud/openstack/network/client/ports.js, line 10, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/openstack/network/client/ports.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/openstack/network/client/ports.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/network/client/ports.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/client/ports.js, line 31, character 7: Combine this with the previous 'var' statement. -var getPortOpts = { -pkgcloud/openstack/network/client/ports.js, line 37, character 7: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/openstack/network/client/ports.js, line 39, character 5: Expected exactly one space between '}' and 'else'. -else if (!body || !body.ports || !(body.ports instanceof Array)) { -pkgcloud/openstack/network/client/ports.js, line 39, character 5: Expected 'else' at column 7, not column 5. -else if (!body || !body.ports || !(body.ports instanceof Array)) { -pkgcloud/openstack/network/client/ports.js, line 69, character 17: Missing space between '||' and '!'. -if (!body ||!body.port) { -pkgcloud/openstack/network/client/ports.js, line 88, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/openstack/network/client/ports.js, line 90, character 7: Combine this with the previous 'var' statement. -var createPortOpts = { -pkgcloud/openstack/network/client/ports.js, line 97, character 47: Missing space between ',' and 'body'. -this._request(createPortOpts, function (err,body) { -pkgcloud/openstack/network/client/ports.js, line 114, character 7: Combine this with the previous 'var' statement. -var createPortOpts = { -pkgcloud/openstack/network/client/ports.js, line 122, character 47: Missing space between ',' and 'body'. -this._request(createPortOpts, function (err,body) { -pkgcloud/openstack/network/client/ports.js, line 142, character 33: Missing space between ',' and 'portId'. -path: urlJoin('/v2.0/ports',portId), -pkgcloud/openstack/network/client/subnets.js, line 10, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/openstack/network/client/subnets.js, line 11, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/openstack/network/client/subnets.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/network/client/subnets.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/network/client/subnets.js, line 22, character 126: Line too long. -* @param {String} [options.marker] Marker value. Operation returns object names that are greater than this value. -pkgcloud/openstack/network/client/subnets.js, line 23, character 113: Line too long. -* @param {String} [options.end_marker] Operation returns object names that are less than this value. -pkgcloud/openstack/network/client/subnets.js, line 34, character 7: Combine this with the previous 'var' statement. -var getSubnetOpts = { -pkgcloud/openstack/network/client/subnets.js, line 35, character 26: Unexpected ','. -path: '/v2.0/subnets', -pkgcloud/openstack/network/client/subnets.js, line 36, character 4: Expected '}' at column 3, not column 4. -}; -pkgcloud/openstack/network/client/subnets.js, line 40, character 7: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/openstack/network/client/subnets.js, line 42, character 5: Expected exactly one space between '}' and 'else'. -else if (!body ||!body.subnets || !(body.subnets instanceof Array)) { -pkgcloud/openstack/network/client/subnets.js, line 42, character 5: Expected 'else' at column 7, not column 5. -else if (!body ||!body.subnets || !(body.subnets instanceof Array)) { -pkgcloud/openstack/network/client/subnets.js, line 42, character 22: Missing space between '||' and '!'. -else if (!body ||!body.subnets || !(body.subnets instanceof Array)) { -pkgcloud/openstack/network/client/subnets.js, line 91, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/openstack/network/client/subnets.js, line 93, character 7: Combine this with the previous 'var' statement. -var createSubnetOpts = { -pkgcloud/openstack/network/client/subnets.js, line 100, character 49: Missing space between ',' and 'body'. -this._request(createSubnetOpts, function (err,body) { -pkgcloud/openstack/network/client/subnets.js, line 117, character 7: Combine this with the previous 'var' statement. -var updateSubnetOpts = { -pkgcloud/openstack/network/client/subnets.js, line 125, character 49: Missing space between ',' and 'body'. -this._request(updateSubnetOpts, function (err,body) { -pkgcloud/openstack/network/client/subnets.js, line 145, character 35: Missing space between ',' and 'subnetId'. -path: urlJoin('/v2.0/subnets',subnetId), -pkgcloud/openstack/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/storage/container'), -pkgcloud/openstack/storage/container.js, line 11, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/storage/container.js, line 31, character 48: Expected ';' and instead saw 'this'. -this.count = details.count || this.count || 0 -pkgcloud/openstack/storage/file.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/storage/file'); -pkgcloud/openstack/storage/file.js, line 47, character 57: ['content_type'] is better written in dot notation. -this.contentType = details['content-type'] || details['content_type'] || null; -pkgcloud/openstack/storage/file.js, line 51, character 15: ['last_modified'] is better written in dot notation. -: details['last_modified'] -pkgcloud/openstack/storage/file.js, line 52, character 24: ['last_modified'] is better written in dot notation. -? new Date(details['last_modified']) -pkgcloud/openstack/storage/file.js, line 57, character 15: ['bytes'] is better written in dot notation. -: details['bytes'] -pkgcloud/openstack/storage/file.js, line 58, character 24: ['bytes'] is better written in dot notation. -? parseInt(details['bytes'], 10) -pkgcloud/openstack/storage/file.js, line 63, character 15: Expected a conditional expression and instead saw an assignment. -if (match = header.match(/x-object-meta-(\w+)/i)) { -pkgcloud/openstack/storage/storageClient.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/storage/storageClient.js, line 14, character 1: Expected an identifier and instead saw 'const'. -const CONTAINER_META_PREFIX = 'x-container-meta-'; -pkgcloud/openstack/storage/storageClient.js, line 14, character 1: Stopping. (14% scanned). - -pkgcloud/openstack/storage/client/containers.js, line 11, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/openstack/storage/client/containers.js, line 13, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/openstack/storage/client/containers.js, line 14, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/openstack/storage/client/containers.js, line 23, character 126: Line too long. -* @param {String} [options.marker] Marker value. Operation returns object names that are greater than this value. -pkgcloud/openstack/storage/client/containers.js, line 24, character 113: Line too long. -* @param {String} [options.end_marker] Operation returns object names that are less than this value. -pkgcloud/openstack/storage/client/containers.js, line 35, character 7: Combine this with the previous 'var' statement. -var getContainerOpts = { -pkgcloud/openstack/storage/client/containers.js, line 41, character 3: Unexpected ';'. -; -pkgcloud/openstack/storage/client/containers.js, line 41, character 3: Unexpected space between ';' and ';'. -; -pkgcloud/openstack/storage/client/containers.js, line 41, character 3: Expected ';' at column 5, not column 3. -; -pkgcloud/openstack/storage/client/containers.js, line 44, character 7: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/openstack/storage/client/containers.js, line 46, character 5: Expected exactly one space between '}' and 'else'. -else if (!body || !(body instanceof Array)) { -pkgcloud/openstack/storage/client/containers.js, line 46, character 5: Expected 'else' at column 7, not column 5. -else if (!body || !(body instanceof Array)) { -pkgcloud/openstack/storage/client/containers.js, line 47, character 49: Expected ';' and instead saw '}'. -return new Error('Malformed API Response') -pkgcloud/openstack/storage/client/containers.js, line 100, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/openstack/storage/client/containers.js, line 102, character 7: Combine this with the previous 'var' statement. -var createContainerOpts = { -pkgcloud/openstack/storage/client/containers.js, line 108, character 103: Line too long. -createContainerOpts.headers = self.serializeMetadata(self.CONTAINER_META_PREFIX, options.metadata); -pkgcloud/openstack/storage/client/containers.js, line 114, character 109: Line too long. -: callback(null, new self.models.Container(self, { name: containerName, metadata: options.metadata })); -pkgcloud/openstack/storage/client/containers.js, line 154, character 44: Expected exactly one space between 'function' and '('. -exports._updateContainerMetadata = function(container, metadata, callback) { -pkgcloud/openstack/storage/client/containers.js, line 161, character 7: Combine this with the previous 'var' statement. -var updateContainerOpts = { -pkgcloud/openstack/storage/client/containers.js, line 191, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/openstack/storage/client/containers.js, line 206, character 18: Expected exactly one space between 'function' and '('. -}, function(err) { -pkgcloud/openstack/storage/client/files.js, line 10, character 5: Expected 'filed' at column 3, not column 5. -filed = require('filed'), -pkgcloud/openstack/storage/client/files.js, line 11, character 5: Expected 'mime' at column 3, not column 5. -mime = require('mime'), -pkgcloud/openstack/storage/client/files.js, line 12, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/openstack/storage/client/files.js, line 13, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/openstack/storage/client/files.js, line 14, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/storage'), -pkgcloud/openstack/storage/client/files.js, line 15, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/openstack/storage/client/files.js, line 16, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'), -pkgcloud/openstack/storage/client/files.js, line 17, character 5: Expected 'storage' at column 3, not column 5. -storage = pkgcloud.providers.openstack.storage; -pkgcloud/openstack/storage/client/files.js, line 30, character 7: Expected 'fileName' at column 5, not column 7. -fileName = file instanceof this.models.File ? file.name : file; -pkgcloud/openstack/storage/client/files.js, line 33, character 7: Expected 'method' at column 5, not column 7. -method: 'DELETE', -pkgcloud/openstack/storage/client/files.js, line 34, character 7: Expected 'container' at column 5, not column 7. -container: containerName, -pkgcloud/openstack/storage/client/files.js, line 35, character 7: Expected 'path' at column 5, not column 7. -path: fileName -pkgcloud/openstack/storage/client/files.js, line 36, character 5: Expected '}' at column 3, not column 5. -}, function(err) { -pkgcloud/openstack/storage/client/files.js, line 36, character 16: Expected exactly one space between 'function' and '('. -}, function(err) { -pkgcloud/openstack/storage/client/files.js, line 37, character 7: Expected 'return' at column 5, not column 7. -return err -pkgcloud/openstack/storage/client/files.js, line 40, character 5: Expected '}' at column 3, not column 5. -} -pkgcloud/openstack/storage/client/files.js, line 41, character 3: Expected ')' at column 5, not column 3. -); -pkgcloud/openstack/storage/client/files.js, line 56, character 104: Line too long. -* @param {Stream} [options.stream] optionally explicitly provide the stream instead of pipe -pkgcloud/openstack/storage/client/files.js, line 79, character 7: Expected 'success' at column 5, not column 7. -success = callback ? onUpload : null, -pkgcloud/openstack/storage/client/files.js, line 80, character 7: Expected 'self' at column 5, not column 7. -self = this, -pkgcloud/openstack/storage/client/files.js, line 81, character 7: Expected 'apiStream' at column 5, not column 7. -apiStream, -pkgcloud/openstack/storage/client/files.js, line 82, character 7: Expected 'inputStream' at column 5, not column 7. -inputStream, -pkgcloud/openstack/storage/client/files.js, line 83, character 7: Expected 'uploadOptions' at column 5, not column 7. -uploadOptions; -pkgcloud/openstack/storage/client/files.js, line 101, character 3: Expected exactly one space between '}' and 'else'. -else if (options.stream) { -pkgcloud/openstack/storage/client/files.js, line 101, character 3: Expected 'else' at column 5, not column 3. -else if (options.stream) { -pkgcloud/openstack/storage/client/files.js, line 118, character 40: Expected exactly one space between 'function' and '('. -inputStream.on('response', function(response) { -pkgcloud/openstack/storage/client/files.js, line 122, character 8: Expected ';' and instead saw '}'. -} -pkgcloud/openstack/storage/client/files.js, line 151, character 104: Line too long. -* @param {Stream} [options.stream] optionally explicitly provide the stream instead of pipe -pkgcloud/openstack/storage/client/files.js, line 157, character 7: Expected 'success' at column 5, not column 7. -success = callback ? onDownload : null, -pkgcloud/openstack/storage/client/files.js, line 157, character 28: 'onDownload' was used before it was defined. -success = callback ? onDownload : null, -pkgcloud/openstack/storage/client/files.js, line 158, character 7: Expected 'container' at column 5, not column 7. -container = options.container, -pkgcloud/openstack/storage/client/files.js, line 159, character 7: Expected 'inputStream' at column 5, not column 7. -inputStream, -pkgcloud/openstack/storage/client/files.js, line 160, character 7: Expected 'apiStream' at column 5, not column 7. -apiStream; -pkgcloud/openstack/storage/client/files.js, line 166, character 12: 'onDownload' was used before it was defined. -function onDownload(err, body, res) { -pkgcloud/openstack/storage/client/files.js, line 170, character 11: Expected 'container' at column 9, not column 11. -container: container, -pkgcloud/openstack/storage/client/files.js, line 171, character 11: Expected 'name' at column 9, not column 11. -name: options.remote -pkgcloud/openstack/storage/client/files.js, line 172, character 9: Expected '}' at column 7, not column 9. -}))); -pkgcloud/openstack/storage/client/files.js, line 182, character 3: Expected exactly one space between '}' and 'else'. -else if (options.stream) { -pkgcloud/openstack/storage/client/files.js, line 182, character 3: Expected 'else' at column 5, not column 3. -else if (options.stream) { -pkgcloud/openstack/storage/client/files.js, line 210, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/openstack/storage/client/files.js, line 223, character 11: Expected 'container' at column 9, not column 11. -container: container, -pkgcloud/openstack/storage/client/files.js, line 224, character 11: Expected 'name' at column 9, not column 11. -name: file -pkgcloud/openstack/storage/client/files.js, line 225, character 9: Expected '}' at column 7, not column 9. -}))); -pkgcloud/openstack/storage/client/files.js, line 232, character 115: Line too long. -* @description get the list of files in a container. Returns at most 10,000 files if options.limit is unspecified. -pkgcloud/openstack/storage/client/files.js, line 238, character 105: Line too long. -* @param {String} [options.marker] the id of the first record to return in the current query -pkgcloud/openstack/storage/client/files.js, line 254, character 107: Line too long. -// Limit is specified and is >10k. Abstract the aggregation of files (cloudfiles returns max 10k at once) -pkgcloud/openstack/storage/client/files.js, line 255, character 7: Combine this with the previous 'var' statement. -var files = []; -pkgcloud/openstack/storage/client/files.js, line 258, character 7: Combine this with the previous 'var' statement. -var remainingLimit = options.limit; -pkgcloud/openstack/storage/client/files.js, line 261, character 7: Combine this with the previous 'var' statement. -var getFilesCallback = function(err, someFiles) { -pkgcloud/openstack/storage/client/files.js, line 261, character 34: Expected exactly one space between 'function' and '('. -var getFilesCallback = function(err, someFiles) { -pkgcloud/openstack/storage/client/files.js, line 261, character 34: Too many errors. (73% scanned). - -pkgcloud/openstack/storage/client/index.js, line 10, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/openstack/storage/client/index.js, line 11, character 5: Expected 'openstack' at column 3, not column 5. -openstack = require('../../client'), -pkgcloud/openstack/storage/client/index.js, line 12, character 5: Expected 'StorageClient' at column 3, not column 5. -StorageClient = require('../storageClient').StorageClient, -pkgcloud/openstack/storage/client/index.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/client.js, line 9, character 5: Expected 'identity' at column 3, not column 5. -identity = require('./identity'), -pkgcloud/rackspace/client.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../openstack/client'), -pkgcloud/rackspace/client.js, line 11, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/client.js, line 30, character 48: Expected exactly one space between 'function' and '('. -Client.prototype._getIdentityOptions = function() { -pkgcloud/rackspace/blockstorage/snapshot.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/base'), -pkgcloud/rackspace/blockstorage/snapshot.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/blockstorage/snapshot.js, line 23, character 39: ['display_name'] is better written in dot notation. -this.name = details.name || details['display_name']; -pkgcloud/rackspace/blockstorage/snapshot.js, line 24, character 53: ['display_description'] is better written in dot notation. -this.description = details.description || details['display_description']; -pkgcloud/rackspace/blockstorage/snapshot.js, line 25, character 28: ['created_at'] is better written in dot notation. -this.createdAt = details['created_at']; -pkgcloud/rackspace/blockstorage/snapshot.js, line 26, character 27: ['volume_id'] is better written in dot notation. -this.volumeId = details['volume_id']; -pkgcloud/rackspace/blockstorage/snapshot.js, line 32, character 108: Line too long. -return _.pick(this, ['id', 'status', 'name', 'description', 'createdAt', 'size', 'volumeId', 'metadata']); -pkgcloud/rackspace/blockstorage/volume.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/base'), -pkgcloud/rackspace/blockstorage/volume.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/blockstorage/volume.js, line 23, character 39: ['display_name'] is better written in dot notation. -this.name = details.name || details['display_name']; -pkgcloud/rackspace/blockstorage/volume.js, line 24, character 53: ['display_description'] is better written in dot notation. -this.description = details.description || details['display_description']; -pkgcloud/rackspace/blockstorage/volume.js, line 25, character 28: ['created_at'] is better written in dot notation. -this.createdAt = details['created_at']; -pkgcloud/rackspace/blockstorage/volume.js, line 27, character 51: ['volume_type'] is better written in dot notation. -this.volumeType = details.volumeType || details['volume_type']; -pkgcloud/rackspace/blockstorage/volume.js, line 29, character 51: ['snapshot_id'] is better written in dot notation. -this.snapshotId = details.snapshotId || details['snapshot_id']; -pkgcloud/rackspace/blockstorage/volumetype.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/base'), -pkgcloud/rackspace/blockstorage/volumetype.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/blockstorage/volumetype.js, line 26, character 39: Expected exactly one space between 'function' and '('. -VolumeType.prototype.toJSON = function() { -pkgcloud/rackspace/blockstorage/client/index.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/blockstorage/client/index.js, line 12, character 5: Expected 'rackspace' at column 3, not column 5. -rackspace = require('../../client'); -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 11, character 5: Expected 'Snapshot' at column 3, not column 5. -Snapshot = require('../snapshot').Snapshot, -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'); -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 28, character 7: Expected 'path' at column 5, not column 7. -path = _urlPrefix; -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 33, character 3: Expected exactly one space between '}' and 'else'. -else if ((typeof options === 'boolean') && (options)) { -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 33, character 3: Expected 'else' at column 5, not column 3. -else if ((typeof options === 'boolean') && (options)) { -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 43, character 7: Expected 'return' at column 9, not column 7. -return new Snapshot(self, data); -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 44, character 5: Expected '}' at column 7, not column 5. -}), res); -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 59, character 7: Expected 'snapshotId' at column 5, not column 7. -snapshotId = snapshot instanceof Snapshot ? snapshot.id : snapshot; -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 83, character 34: Expected exactly one space between 'function' and '('. -exports.createSnapshot = function(details, callback) { -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 86, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 99, character 40: Expected exactly one space between 'function' and '('. -self._request(createOptions, function(err, body, res) { -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 120, character 7: Expected 'snapshotId' at column 5, not column 7. -snapshotId = snapshot instanceof Snapshot ? snapshot.id : snapshot; -pkgcloud/rackspace/blockstorage/client/snapshots.js, line 122, character 7: Combine this with the previous 'var' statement. -var updateOptions = { -pkgcloud/rackspace/blockstorage/client/volumes.js, line 11, character 5: Expected 'Volume' at column 3, not column 5. -Volume = require('../volume').Volume, -pkgcloud/rackspace/blockstorage/client/volumes.js, line 12, character 5: Expected 'VolumeType' at column 3, not column 5. -VolumeType = require('../volumetype').VolumeType, -pkgcloud/rackspace/blockstorage/client/volumes.js, line 13, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'); -pkgcloud/rackspace/blockstorage/client/volumes.js, line 29, character 7: Expected 'path' at column 5, not column 7. -path = _urlPrefix; -pkgcloud/rackspace/blockstorage/client/volumes.js, line 34, character 3: Expected exactly one space between '}' and 'else'. -else if ((typeof options === 'boolean') && (options)) { -pkgcloud/rackspace/blockstorage/client/volumes.js, line 34, character 3: Expected 'else' at column 5, not column 3. -else if ((typeof options === 'boolean') && (options)) { -pkgcloud/rackspace/blockstorage/client/volumes.js, line 44, character 7: Expected 'return' at column 9, not column 7. -return new Volume(self, data); -pkgcloud/rackspace/blockstorage/client/volumes.js, line 45, character 5: Expected '}' at column 7, not column 5. -}), res); -pkgcloud/rackspace/blockstorage/client/volumes.js, line 88, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/rackspace/blockstorage/client/volumes.js, line 101, character 31: ['volume_type'] is better written in dot notation. -createOptions.body.volume['volume_type'] = -pkgcloud/rackspace/blockstorage/client/volumes.js, line 108, character 31: ['snapshot_id'] is better written in dot notation. -createOptions.body.volume['snapshot_id'] = options.snapshotId; -pkgcloud/rackspace/blockstorage/client/volumes.js, line 131, character 7: Expected 'volumeId' at column 5, not column 7. -volumeId = volume instanceof Volume ? volume.id : volume; -pkgcloud/rackspace/blockstorage/client/volumes.js, line 133, character 7: Combine this with the previous 'var' statement. -var updateOptions = { -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 11, character 5: Expected 'VolumeType' at column 3, not column 5. -VolumeType = require('../volumetype').VolumeType, -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'); -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 24, character 34: Expected exactly one space between 'function' and '('. -exports.getVolumeTypes = function(callback) { -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 31, character 29: ['volume_types'] is better written in dot notation. -: callback(null, body['volume_types'].map(function (data) { -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 32, character 7: Expected 'return' at column 9, not column 7. -return new VolumeType(self, data); -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 33, character 5: Expected '}' at column 7, not column 5. -}), res); -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 49, character 7: Combine this with the previous 'var' statement. -var self = this; -pkgcloud/rackspace/blockstorage/client/volumetypes.js, line 55, character 50: ['volume_type'] is better written in dot notation. -: callback(null, new VolumeType(self, body['volume_type'])); -pkgcloud/rackspace/compute/server.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../openstack/compute/server'); -pkgcloud/rackspace/compute/client/index.js, line 9, character 5: Expected 'rackspace' at column 3, not column 5. -rackspace = require('../../client'), -pkgcloud/rackspace/compute/client/index.js, line 10, character 5: Expected 'ComputeClient' at column 3, not column 5. -ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, -pkgcloud/rackspace/compute/client/index.js, line 11, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 16, character 5: Expected '_extension' at column 3, not column 5. -_extension = 'os-virtual-interfacesv2'; -pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 50, character 7: Expected 'networkId' at column 5, not column 7. -networkId = (typeof network === 'object') ? network.id : network; -pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js, line 79, character 7: Expected 'networkId' at column 5, not column 7. -networkId = (typeof network === 'object') ? network.id : network; -pkgcloud/rackspace/database/database.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../../core/base/model'); -pkgcloud/rackspace/database/database.js, line 25, character 29: Expected '{' and instead saw 'this'. -if (details.characterSet) this.characterSet = details.characterSet; -pkgcloud/rackspace/database/database.js, line 25, character 29: Expected 'this' at column 3, not column 29. -if (details.characterSet) this.characterSet = details.characterSet; -pkgcloud/rackspace/database/database.js, line 26, character 26: Expected '{' and instead saw 'this'. -if (details.collation) this.collation = details.collation; -pkgcloud/rackspace/database/database.js, line 26, character 26: Expected 'this' at column 3, not column 26. -if (details.collation) this.collation = details.collation; -pkgcloud/rackspace/database/flavor.js, line 9, character 5: Expected 'base' at column 3, not column 5. -base = require('../../openstack/compute/flavor'); -pkgcloud/rackspace/database/instance.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../../core/base/model'), -pkgcloud/rackspace/database/instance.js, line 10, character 5: Expected 'computeStatus' at column 3, not column 5. -computeStatus = require('../../common/status').compute; -pkgcloud/rackspace/database/instance.js, line 30, character 36: Use the || operator. -details.state = (details.status) ? details.status : details.state; -pkgcloud/rackspace/database/instance.js, line 34, character 7: Expected 'case' at column 5, not column 7. -case 'PROVISIONING': -pkgcloud/rackspace/database/instance.js, line 35, character 7: Expected 'case' at column 5, not column 7. -case 'BUILD': -pkgcloud/rackspace/database/instance.js, line 36, character 7: Expected 'case' at column 5, not column 7. -case 'REBOOT': -pkgcloud/rackspace/database/instance.js, line 37, character 7: Expected 'case' at column 5, not column 7. -case 'RESIZE': -pkgcloud/rackspace/database/instance.js, line 38, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.provisioning; -pkgcloud/rackspace/database/instance.js, line 39, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/rackspace/database/instance.js, line 40, character 7: Expected 'case' at column 5, not column 7. -case 'RUNNING': -pkgcloud/rackspace/database/instance.js, line 41, character 7: Expected 'case' at column 5, not column 7. -case 'ACTIVE': // Change for keep consistency -pkgcloud/rackspace/database/instance.js, line 42, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.running; -pkgcloud/rackspace/database/instance.js, line 43, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/rackspace/database/instance.js, line 44, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPING': -pkgcloud/rackspace/database/instance.js, line 45, character 7: Expected 'case' at column 5, not column 7. -case 'STOPPED': -pkgcloud/rackspace/database/instance.js, line 46, character 7: Expected 'case' at column 5, not column 7. -case 'SHUTDOWN': -pkgcloud/rackspace/database/instance.js, line 47, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.stopped; -pkgcloud/rackspace/database/instance.js, line 48, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/rackspace/database/instance.js, line 49, character 7: Expected 'case' at column 5, not column 7. -case 'FAILED': -pkgcloud/rackspace/database/instance.js, line 50, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.error; -pkgcloud/rackspace/database/instance.js, line 51, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/rackspace/database/instance.js, line 52, character 7: Expected 'default' at column 5, not column 7. -default: -pkgcloud/rackspace/database/instance.js, line 53, character 9: Expected 'this' at column 7, not column 9. -this.status = this.STATUS.unknown; -pkgcloud/rackspace/database/instance.js, line 54, character 9: Expected 'break' at column 7, not column 9. -break; -pkgcloud/rackspace/database/user.js, line 9, character 5: Expected 'model' at column 3, not column 5. -model = require('../../core/base/model'); -pkgcloud/rackspace/database/client/databases.js, line 9, character 5: Expected 'Database' at column 3, not column 5. -Database = pkgcloud.providers.rackspace.database.Database, -pkgcloud/rackspace/database/client/databases.js, line 10, character 5: Expected 'Instance' at column 3, not column 5. -Instance = pkgcloud.providers.rackspace.database.Instance, -pkgcloud/rackspace/database/client/databases.js, line 11, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/rackspace/database/client/databases.js, line 12, character 5: Expected 'qs' at column 3, not column 5. -qs = require('querystring'); -pkgcloud/rackspace/database/client/databases.js, line 18, character 117: Line too long. -// #### options['instance'] {string | Object} The instance could be the ID or a instance of Instance class (required) -pkgcloud/rackspace/database/client/databases.js, line 19, character 101: Line too long. -// #### options['character_set'] {string} Should be a valid CharacterSet for mysql. Default to 'utf8' -pkgcloud/rackspace/database/client/databases.js, line 20, character 101: Line too long. -// #### options['collate'] {string} Should be a valid Collate for mysql. Default to 'utf8_general_ci' -pkgcloud/rackspace/database/client/databases.js, line 21, character 120: Line too long. -// For more info about character_set and collate for mysql see http://dev.mysql.com/doc/refman/5.6/en/charset-mysql.html -pkgcloud/rackspace/database/client/databases.js, line 32, character 16: ['name'] is better written in dot notation. -if (!options['name']) { -pkgcloud/rackspace/database/client/databases.js, line 38, character 16: ['instance'] is better written in dot notation. -if (!options['instance']) { -pkgcloud/rackspace/database/client/databases.js, line 46, character 106: Line too long. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 46, character 7: Combine this with the previous 'var' statement. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 46, character 28: ['instance'] is better written in dot notation. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 46, character 70: ['instance'] is better written in dot notation. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 46, character 95: ['instance'] is better written in dot notation. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 49, character 7: Combine this with the previous 'var' statement. -var reqDatabase = { name: options['name'] }; -pkgcloud/rackspace/database/client/databases.js, line 49, character 37: ['name'] is better written in dot notation. -var reqDatabase = { name: options['name'] }; -pkgcloud/rackspace/database/client/databases.js, line 52, character 26: ['character_set'] is better written in dot notation. -if (options && options['character_set']) { -pkgcloud/rackspace/database/client/databases.js, line 53, character 17: ['character_set'] is better written in dot notation. -reqDatabase['character_set'] = options['character_set']; -pkgcloud/rackspace/database/client/databases.js, line 53, character 44: ['character_set'] is better written in dot notation. -reqDatabase['character_set'] = options['character_set']; -pkgcloud/rackspace/database/client/databases.js, line 56, character 26: ['collate'] is better written in dot notation. -if (options && options['collate']) { -pkgcloud/rackspace/database/client/databases.js, line 57, character 17: ['collate'] is better written in dot notation. -reqDatabase['collate'] = options['collate']; -pkgcloud/rackspace/database/client/databases.js, line 57, character 38: ['collate'] is better written in dot notation. -reqDatabase['collate'] = options['collate']; -pkgcloud/rackspace/database/client/databases.js, line 60, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/rackspace/database/client/databases.js, line 77, character 117: Line too long. -// #### options['instance'] {string | Object} The instance could be the ID or a instance of Instance class (required) -pkgcloud/rackspace/database/client/databases.js, line 83, character 7: Expected 'completeUrl' at column 5, not column 7. -completeUrl = {}, -pkgcloud/rackspace/database/client/databases.js, line 84, character 7: Expected 'requestOptions' at column 5, not column 7. -requestOptions = {}; -pkgcloud/rackspace/database/client/databases.js, line 92, character 16: ['instance'] is better written in dot notation. -if (!options['instance']) { -pkgcloud/rackspace/database/client/databases.js, line 106, character 106: Line too long. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 106, character 7: Combine this with the previous 'var' statement. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 106, character 28: ['instance'] is better written in dot notation. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 106, character 70: ['instance'] is better written in dot notation. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 106, character 95: ['instance'] is better written in dot notation. -var instanceId = options['instance'] instanceof Instance ? options['instance'].id : options['instance']; -pkgcloud/rackspace/database/client/databases.js, line 128, character 107: Line too long. -// #### @database {string | Object} The database could be the ID or a instance of Database class (required) -pkgcloud/rackspace/database/client/databases.js, line 129, character 107: Line too long. -// #### @instance {string | Object} The instance could be the ID or a instance of Instance class (required) -pkgcloud/rackspace/database/client/databases.js, line 146, character 7: Combine this with the previous 'var' statement. -var databaseName = database instanceof Database ? database.name : database; -pkgcloud/rackspace/database/client/flavors.js, line 9, character 5: Expected 'Flavor' at column 3, not column 5. -Flavor = pkgcloud.providers.rackspace.database.Flavor; -pkgcloud/rackspace/database/client/flavors.js, line 28, character 11: Expected 'return' at column 9, not column 11. -return new Flavor(self, result); -pkgcloud/rackspace/database/client/flavors.js, line 29, character 9: Expected '}' at column 7, not column 9. -})); -pkgcloud/rackspace/database/client/index.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/database/client/index.js, line 10, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/rackspace/database/client/index.js, line 11, character 5: Expected 'rackspace' at column 3, not column 5. -rackspace = require('../../client'), -pkgcloud/rackspace/database/client/index.js, line 12, character 5: Expected 'auth' at column 3, not column 5. -auth = require('../../../common/auth.js'), -pkgcloud/rackspace/database/client/index.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/database/client/instances.js, line 9, character 5: Expected 'Flavor' at column 3, not column 5. -Flavor = pkgcloud.providers.rackspace.database.Flavor, -pkgcloud/rackspace/database/client/instances.js, line 10, character 5: Expected 'Instance' at column 3, not column 5. -Instance = pkgcloud.providers.rackspace.database.Instance, -pkgcloud/rackspace/database/client/instances.js, line 11, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/rackspace/database/client/instances.js, line 12, character 5: Expected 'qs' at column 3, not column 5. -qs = require('querystring'); -pkgcloud/rackspace/database/client/instances.js, line 18, character 118: Line too long. -// #### options['flavor'] {string | Object} Should be the HREF for the flavor or a instance of Flavor class (required) -pkgcloud/rackspace/database/client/instances.js, line 20, character 111: Line too long. -// #### options['databases'] {array} Array of strings with database names to create when the instance is ready. -pkgcloud/rackspace/database/client/instances.js, line 24, character 7: Expected 'flavorRef' at column 5, not column 7. -flavorRef, -pkgcloud/rackspace/database/client/instances.js, line 25, character 7: Expected 'size' at column 5, not column 7. -size; -pkgcloud/rackspace/database/client/instances.js, line 34, character 16: ['name'] is better written in dot notation. -if (!options['name']) { -pkgcloud/rackspace/database/client/instances.js, line 40, character 16: ['flavor'] is better written in dot notation. -if (!options['flavor']) { -pkgcloud/rackspace/database/client/instances.js, line 47, character 26: ['databases'] is better written in dot notation. -if (options && options['databases'] && -pkgcloud/rackspace/database/client/instances.js, line 48, character 22: ['databases'] is better written in dot notation. -typeof options['databases'] === 'array' && -pkgcloud/rackspace/database/client/instances.js, line 49, character 15: ['databases'] is better written in dot notation. -options['databases'].length > 0) { -pkgcloud/rackspace/database/client/instances.js, line 50, character 13: ['databases'] is better written in dot notation. -options['databases'].forEach(function (item, idx) { -pkgcloud/rackspace/database/client/instances.js, line 53, character 17: ['databases'] is better written in dot notation. -options['databases'][idx] = { -pkgcloud/rackspace/database/client/instances.js, line 63, character 26: ['size'] is better written in dot notation. -if (options && options['size']) { -pkgcloud/rackspace/database/client/instances.js, line 65, character 24: ['size'] is better written in dot notation. -if (typeof options['size'] !== 'number') { -pkgcloud/rackspace/database/client/instances.js, line 70, character 21: ['size'] is better written in dot notation. -size = (options['size'] > 0 && options['size'] < 9) ? options['size'] : 1; -pkgcloud/rackspace/database/client/instances.js, line 70, character 44: ['size'] is better written in dot notation. -size = (options['size'] > 0 && options['size'] < 9) ? options['size'] : 1; -pkgcloud/rackspace/database/client/instances.js, line 70, character 67: ['size'] is better written in dot notation. -size = (options['size'] > 0 && options['size'] < 9) ? options['size'] : 1; -pkgcloud/rackspace/database/client/instances.js, line 75, character 26: ['flavor'] is better written in dot notation. -if (options && options['flavor']) { -pkgcloud/rackspace/database/client/instances.js, line 76, character 25: ['flavor'] is better written in dot notation. -flavorRef = options['flavor'] instanceof Flavor ? options['flavor'].href : options['flavor']; -pkgcloud/rackspace/database/client/instances.js, line 76, character 63: ['flavor'] is better written in dot notation. -flavorRef = options['flavor'] instanceof Flavor ? options['flavor'].href : options['flavor']; -pkgcloud/rackspace/database/client/instances.js, line 76, character 88: ['flavor'] is better written in dot notation. -flavorRef = options['flavor'] instanceof Flavor ? options['flavor'].href : options['flavor']; -pkgcloud/rackspace/database/client/instances.js, line 79, character 7: Combine this with the previous 'var' statement. -var createOptions = { -pkgcloud/rackspace/database/client/instances.js, line 84, character 23: ['name'] is better written in dot notation. -name: options['name'], -pkgcloud/rackspace/database/client/instances.js, line 86, character 28: ['databases'] is better written in dot notation. -databases: options['databases'] || [], -pkgcloud/rackspace/database/client/instances.js, line 106, character 7: Expected 'completeUrl' at column 5, not column 7. -completeUrl = {}, -pkgcloud/rackspace/database/client/instances.js, line 107, character 7: Expected 'requestOptions' at column 5, not column 7. -requestOptions = {}; -pkgcloud/rackspace/database/client/instances.js, line 177, character 7: Combine this with the previous 'var' statement. -var instanceId = instance instanceof Instance ? instance.id : instance; -pkgcloud/rackspace/database/client/instances.js, line 201, character 7: Combine this with the previous 'var' statement. -var restartOptions = { -pkgcloud/rackspace/database/client/instances.js, line 250, character 7: Combine this with the previous 'var' statement. -var resizeOptions = { -pkgcloud/rackspace/database/client/instances.js, line 300, character 7: Combine this with the previous 'var' statement. -var resizeOptions = { -pkgcloud/rackspace/database/client/users.js, line 9, character 5: Expected 'Database' at column 3, not column 5. -Database = pkgcloud.providers.rackspace.database.Database, -pkgcloud/rackspace/database/client/users.js, line 10, character 5: Expected 'Instance' at column 3, not column 5. -Instance = pkgcloud.providers.rackspace.database.Instance, -pkgcloud/rackspace/database/client/users.js, line 11, character 5: Expected 'User' at column 3, not column 5. -User = pkgcloud.providers.rackspace.database.User, -pkgcloud/rackspace/database/client/users.js, line 12, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/rackspace/database/client/users.js, line 13, character 5: Expected 'async' at column 3, not column 5. -async = require('async'), -pkgcloud/rackspace/database/client/users.js, line 14, character 5: Expected 'qs' at column 3, not column 5. -qs = require('querystring'); -pkgcloud/rackspace/database/client/users.js, line 22, character 112: Line too long. -// #### options['databases'] {string | array} Name or instances of databases that the user can access (required) -pkgcloud/rackspace/database/client/users.js, line 23, character 134: Line too long. -// #### options['instance'] {string | Object} The instance could be the ID for the instance or a instance of Instance class (required) -pkgcloud/rackspace/database/client/users.js, line 26, character 7: Expected 'users' at column 5, not column 7. -users = [], -pkgcloud/rackspace/database/client/users.js, line 27, character 7: Expected 'regex' at column 5, not column 7. -regex = /^\s|^\?|^@|^#| \w* \d* |'|"|`|;|,|\\|\/| \s$/, -pkgcloud/rackspace/database/client/users.js, line 28, character 7: Expected 'instanceId' at column 5, not column 7. -instanceId, -pkgcloud/rackspace/database/client/users.js, line 29, character 7: Expected 'count' at column 5, not column 7. -count = 0; -pkgcloud/rackspace/database/client/users.js, line 40, character 10: Move 'var' declarations to the top of the function. -for (var i = 0; i < options.length; i++) { -pkgcloud/rackspace/database/client/users.js, line 40, character 10: Stopping. (14% scanned). - -pkgcloud/rackspace/dns/record.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/dns/record'), -pkgcloud/rackspace/dns/record.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/dns/status.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/base/model'); -pkgcloud/rackspace/dns/status.js, line 29, character 7: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/status.js, line 36, character 7: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/dns/status.js, line 38, character 5: Expected exactly one space between '}' and 'else'. -else if (!body) { -pkgcloud/rackspace/dns/status.js, line 38, character 5: Expected 'else' at column 7, not column 5. -else if (!body) { -pkgcloud/rackspace/dns/zone.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/dns/zone'), -pkgcloud/rackspace/dns/zone.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/dns/client/index.js, line 11, character 5: Expected 'rackspace' at column 3, not column 5. -rackspace = require('../../client'), -pkgcloud/rackspace/dns/client/index.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/dns/client/index.js, line 13, character 5: Expected 'Status' at column 3, not column 5. -Status = require('../status').Status, -pkgcloud/rackspace/dns/client/index.js, line 14, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/dns/client/index.js, line 43, character 42: Expected exactly one space between 'function' and '('. -Client.prototype._asyncRequest = function(options, callback) { -pkgcloud/rackspace/dns/client/records.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/dns/client/records.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/rackspace/dns/client/records.js, line 13, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/rackspace/dns/client/records.js, line 14, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'), -pkgcloud/rackspace/dns/client/records.js, line 15, character 5: Expected 'dns' at column 3, not column 5. -dns = pkgcloud.providers.rackspace.dns; -pkgcloud/rackspace/dns/client/records.js, line 18, character 5: Expected '_recordFragment' at column 3, not column 5. -_recordFragment = 'records'; -pkgcloud/rackspace/dns/client/records.js, line 30, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone; -pkgcloud/rackspace/dns/client/records.js, line 32, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/records.js, line 37, character 9: Expected exactly one space between 'if' and '('. -if(err) { -pkgcloud/rackspace/dns/client/records.js, line 38, character 9: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/dns/client/records.js, line 41, character 7: Expected exactly one space between '}' and 'else'. -else if (!body || !body.records) { -pkgcloud/rackspace/dns/client/records.js, line 41, character 7: Expected 'else' at column 9, not column 7. -else if (!body || !body.records) { -pkgcloud/rackspace/dns/client/records.js, line 42, character 9: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/rackspace/dns/client/records.js, line 45, character 7: Expected exactly one space between '}' and 'else'. -else{ -pkgcloud/rackspace/dns/client/records.js, line 45, character 7: Expected 'else' at column 9, not column 7. -else{ -pkgcloud/rackspace/dns/client/records.js, line 45, character 11: Expected exactly one space between 'else' and '{'. -else{ -pkgcloud/rackspace/dns/client/records.js, line 45, character 11: Missing space between 'else' and '{'. -else{ -pkgcloud/rackspace/dns/client/records.js, line 46, character 9: Expected 'return' at column 11, not column 9. -return callback(null, body.records.map(function (record) { -pkgcloud/rackspace/dns/client/records.js, line 47, character 11: Expected 'return' at column 13, not column 11. -return new dns.Record(self, record); -pkgcloud/rackspace/dns/client/records.js, line 48, character 9: Expected '}' at column 11, not column 9. -}), res); -pkgcloud/rackspace/dns/client/records.js, line 49, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/rackspace/dns/client/records.js, line 62, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone, -pkgcloud/rackspace/dns/client/records.js, line 63, character 9: Expected 'recordId' at column 7, not column 9. -recordId = record instanceof dns.Record ? record.id : record; -pkgcloud/rackspace/dns/client/records.js, line 65, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/records.js, line 94, character 9: Expected 'data' at column 7, not column 9. -data = [], -pkgcloud/rackspace/dns/client/records.js, line 95, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone; -pkgcloud/rackspace/dns/client/records.js, line 124, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/records.js, line 132, character 48: Expected exactly one space between 'function' and '('. -self._asyncRequest(requestOptions, function(err, result) { -pkgcloud/rackspace/dns/client/records.js, line 137, character 15: Expected 'return' at column 13, not column 15. -return new dns.Record(self, record); -pkgcloud/rackspace/dns/client/records.js, line 138, character 13: Expected '}' at column 11, not column 13. -}) -pkgcloud/rackspace/dns/client/records.js, line 151, character 50: Expected exactly one space between 'function' and '('. -this.createRecords(zone, [ record ], function(err, records) { -pkgcloud/rackspace/dns/client/records.js, line 167, character 9: Expected 'data' at column 7, not column 9. -data = [], -pkgcloud/rackspace/dns/client/records.js, line 168, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone; -pkgcloud/rackspace/dns/client/records.js, line 196, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/records.js, line 208, character 9: Expected 'return' at column 11, not column 9. -return new dns.Record(self, record); -pkgcloud/rackspace/dns/client/records.js, line 209, character 7: Expected '}' at column 9, not column 7. -})); -pkgcloud/rackspace/dns/client/records.js, line 222, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone, -pkgcloud/rackspace/dns/client/records.js, line 223, character 9: Expected 'recordId' at column 7, not column 9. -recordId = record instanceof dns.Record ? record.id : record; -pkgcloud/rackspace/dns/client/records.js, line 225, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/records.js, line 244, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone; -pkgcloud/rackspace/dns/client/records.js, line 246, character 9: Combine this with the previous 'var' statement. -var ids = _.map(records, function(record) { -pkgcloud/rackspace/dns/client/records.js, line 246, character 38: Expected exactly one space between 'function' and '('. -var ids = _.map(records, function(record) { -pkgcloud/rackspace/dns/client/records.js, line 253, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/dns/client/zones.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/rackspace/dns/client/zones.js, line 13, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/rackspace/dns/client/zones.js, line 14, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'), -pkgcloud/rackspace/dns/client/zones.js, line 15, character 5: Expected 'dns' at column 3, not column 5. -dns = pkgcloud.providers.rackspace.dns; -pkgcloud/rackspace/dns/client/zones.js, line 32, character 15: Expected exactly one space between 'typeof' and '('. -if (typeof(details) === 'function') { -pkgcloud/rackspace/dns/client/zones.js, line 37, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 48, character 9: Expected 'return' at column 11, not column 9. -return new dns.Zone(self, result); -pkgcloud/rackspace/dns/client/zones.js, line 49, character 7: Expected '}' at column 9, not column 7. -}), res); -pkgcloud/rackspace/dns/client/zones.js, line 63, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone; -pkgcloud/rackspace/dns/client/zones.js, line 89, character 9: Unexpected 'else' after 'return'. -return callback(err, zones[0]); -pkgcloud/rackspace/dns/client/zones.js, line 91, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/rackspace/dns/client/zones.js, line 91, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/rackspace/dns/client/zones.js, line 92, character 9: Expected 'return' at column 11, not column 9. -return callback(new Error('Unexpected error when creating single zone'), zones); -pkgcloud/rackspace/dns/client/zones.js, line 93, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/rackspace/dns/client/zones.js, line 108, character 9: Combine this with the previous 'var' statement. -var listOfZones = []; -pkgcloud/rackspace/dns/client/zones.js, line 111, character 30: Expected '{' and instead saw 'throw'. -if (!zone[required]) throw new Error('details.' + -pkgcloud/rackspace/dns/client/zones.js, line 111, character 30: Expected 'throw' at column 9, not column 30. -if (!zone[required]) throw new Error('details.' + -pkgcloud/rackspace/dns/client/zones.js, line 120, character 29: Expected exactly one space between 'typeof' and '('. -if (zone.ttl && typeof(zone.ttl) === 'number' && zone.ttl >= 300) { -pkgcloud/rackspace/dns/client/zones.js, line 131, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 144, character 7: Expected '}' at column 9, not column 7. -})); -pkgcloud/rackspace/dns/client/zones.js, line 163, character 31: Expected '{' and instead saw 'throw'. -if (!details[required]) throw new Error('details.' + -pkgcloud/rackspace/dns/client/zones.js, line 163, character 31: Expected 'throw' at column 7, not column 31. -if (!details[required]) throw new Error('details.' + -pkgcloud/rackspace/dns/client/zones.js, line 172, character 9: Combine this with the previous 'var' statement. -var importedZone = { -pkgcloud/rackspace/dns/client/zones.js, line 177, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 190, character 9: Expected 'return' at column 11, not column 9. -return new dns.Zone(self, domain); -pkgcloud/rackspace/dns/client/zones.js, line 191, character 7: Expected '}' at column 9, not column 7. -})[0]); -pkgcloud/rackspace/dns/client/zones.js, line 207, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 239, character 9: Combine this with the previous 'var' statement. -var data = []; -pkgcloud/rackspace/dns/client/zones.js, line 256, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 264, character 48: Expected exactly one space between 'function' and '('. -self._asyncRequest(requestOptions, function(err) { -pkgcloud/rackspace/dns/client/zones.js, line 290, character 15: Expected exactly one space between 'typeof' and '('. -if (typeof(options) === 'function') { -pkgcloud/rackspace/dns/client/zones.js, line 295, character 9: Combine this with the previous 'var' statement. -var zoneIds = []; -pkgcloud/rackspace/dns/client/zones.js, line 301, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/rackspace/dns/client/zones.js, line 301, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/rackspace/dns/client/zones.js, line 302, character 9: Expected 'zoneIds' at column 11, not column 9. -zoneIds.push(zone); -pkgcloud/rackspace/dns/client/zones.js, line 303, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/rackspace/dns/client/zones.js, line 306, character 9: Combine this with the previous 'var' statement. -var deleteSubzones = typeof options.deleteSubzones === 'boolean' -pkgcloud/rackspace/dns/client/zones.js, line 313, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 315, character 29: Expected exactly one space between 'function' and '('. -zoneIds.map(function(z) { return 'id=' + z }).join('&') + -pkgcloud/rackspace/dns/client/zones.js, line 315, character 51: Expected ';' and instead saw '}'. -zoneIds.map(function(z) { return 'id=' + z }).join('&') + -pkgcloud/rackspace/dns/client/zones.js, line 320, character 48: Expected exactly one space between 'function' and '('. -self._asyncRequest(requestOptions, function(err) { -pkgcloud/rackspace/dns/client/zones.js, line 335, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone; -pkgcloud/rackspace/dns/client/zones.js, line 337, character 15: Expected exactly one space between 'typeof' and '('. -if (typeof(options) === 'function') { -pkgcloud/rackspace/dns/client/zones.js, line 341, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 349, character 8: Expected ';' and instead saw '}'. -} -pkgcloud/rackspace/dns/client/zones.js, line 390, character 9: Expected 'zoneId' at column 7, not column 9. -zoneId = zone instanceof dns.Zone ? zone.id : zone; -pkgcloud/rackspace/dns/client/zones.js, line 392, character 15: Expected exactly one space between 'typeof' and '('. -if (typeof(options) === 'function') { -pkgcloud/rackspace/dns/client/zones.js, line 397, character 9: Combine this with the previous 'var' statement. -var requestOptions = { -pkgcloud/rackspace/dns/client/zones.js, line 406, character 5: Expected 'modifyEmailAddress' at column 7, not column 5. -'modifyEmailAddress', 'modifyRecordData'])); -pkgcloud/rackspace/dns/client/zones.js, line 406, character 5: Too many errors. (92% scanned). - -pkgcloud/rackspace/identity/rackspaceIdentity.js, line 16, character 20: 'RackspaceIdentity' was used before it was defined. -exports.Identity = RackspaceIdentity = function (options) { -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/loadbalancer/loadbalancer'), -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 45, character 42: Expected exactly one space between 'function' and '('. -LoadBalancer.prototype.refresh = function(callback) { -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 58, character 43: Expected exactly one space between 'function' and '('. -LoadBalancer.prototype.getNodes = function(callback) { -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 62, character 42: Expected exactly one space between 'function' and '('. -LoadBalancer.prototype.addNode = function(node, callback) { -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 66, character 43: Expected exactly one space between 'function' and '('. -LoadBalancer.prototype.addNodes = function(nodes, callback) { -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 70, character 45: Expected exactly one space between 'function' and '('. -LoadBalancer.prototype.updateNode = function(node, callback) { -pkgcloud/rackspace/loadbalancer/loadbalancer.js, line 78, character 46: Expected exactly one space between 'function' and '('. -LoadBalancer.prototype.removeNodes = function(nodes, callback) { -pkgcloud/rackspace/loadbalancer/node.js, line 11, character 5: Expected 'base' at column 3, not column 5. -base = require('../../core/loadbalancer/node'), -pkgcloud/rackspace/loadbalancer/node.js, line 12, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/loadbalancer/node.js, line 25, character 7: Missing radix parameter. -? parseInt(details.loadBalancerId) : details.loadBalancerId; -pkgcloud/rackspace/loadbalancer/protocols.js, line 17, character 6: Expected 'DNS_UDP' at column 3, not column 6. -}, DNS_UDP: { -pkgcloud/rackspace/loadbalancer/virtualip.js, line 12, character 82: Expected ';' and instead saw '}'. -throw new Error('VirtualIp must be constructed with at-least basic details.') -pkgcloud/rackspace/loadbalancer/client/index.js, line 11, character 5: Expected 'rackspace' at column 3, not column 5. -rackspace = require('../../client'), -pkgcloud/rackspace/loadbalancer/client/index.js, line 12, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/loadbalancer/client/index.js, line 13, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 13, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 14, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'), -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 15, character 5: Expected 'lb' at column 3, not column 5. -lb = pkgcloud.providers.rackspace.loadbalancer; -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 31, character 9: Expected 'requestOptions' at column 7, not column 9. -requestOptions = { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 32, character 11: Expected 'path' at column 9, not column 11. -path: _urlPrefix -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 33, character 5: Expected '}' at column 7, not column 5. -}; -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 42, character 9: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 45, character 7: Expected exactly one space between '}' and 'else'. -else if (!body || !body.loadBalancers) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 45, character 7: Expected 'else' at column 9, not column 7. -else if (!body || !body.loadBalancers) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 46, character 9: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 49, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 49, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 50, character 9: Expected 'return' at column 11, not column 9. -return callback(null, body.loadBalancers.map(function (loadBalancer) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 51, character 11: Expected 'return' at column 13, not column 11. -return new lb.LoadBalancer(self, loadBalancer); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 52, character 9: Expected '}' at column 11, not column 9. -})); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 53, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 66, character 28: Expected exactly one space between 'function' and '('. -getLoadBalancer: function(loadBalancer, callback) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 68, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 75, character 9: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 78, character 7: Expected exactly one space between '}' and 'else'. -else if (!body || !body.loadBalancer) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 78, character 7: Expected 'else' at column 9, not column 7. -else if (!body || !body.loadBalancer) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 79, character 9: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 82, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 82, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 83, character 9: Expected 'return' at column 11, not column 9. -return callback(null, new lb.LoadBalancer(self, body.loadBalancer)); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 84, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 95, character 108: Line too long. -* http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/Create_Load_Balancer-d1e1635.html -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 110, character 31: Expected exactly one space between 'function' and '('. -createLoadBalancer: function(details, callback) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 112, character 9: Expected 'createOptions' at column 7, not column 9. -createOptions = { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 113, character 11: Expected 'path' at column 9, not column 11. -path: _urlPrefix, -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 114, character 11: Expected 'method' at column 9, not column 11. -method: 'POST', -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 115, character 11: Expected 'body' at column 9, not column 11. -body: { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 116, character 13: Expected 'name' at column 11, not column 13. -name: details.name, -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 117, character 13: Expected 'nodes' at column 11, not column 13. -nodes: details.nodes || [], -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 118, character 13: Expected 'protocol' at column 11, not column 13. -protocol: details.protocol ? details.protocol.name : '', -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 119, character 13: Expected 'port' at column 11, not column 13. -port: details.protocol ? details.protocol.port : '', -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 120, character 13: Expected 'virtualIps' at column 11, not column 13. -virtualIps: details.virtualIps -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 121, character 11: Expected '}' at column 9, not column 11. -} -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 122, character 9: Expected '}' at column 7, not column 9. -}; -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 129, character 9: Combine this with the previous 'var' statement. -var validationErrors = validateLbInputs(createOptions.body); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 129, character 28: 'validateLbInputs' was used before it was defined. -var validationErrors = validateLbInputs(createOptions.body); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 132, character 102: Line too long. -return callback(new Error('Errors validating inputs for createLoadBalancer', validationErrors)); -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 135, character 42: Expected exactly one space between 'function' and '('. -self._request(createOptions, function(err, body) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 182, character 31: Expected exactly one space between 'function' and '('. -deleteLoadBalancer: function(loadBalancer, callback) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 184, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 274, character 25: Expected exactly one space between 'function' and '('. -getSSLConfig: function(loadBalancer, callback) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 276, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 303, character 28: Expected exactly one space between 'function' and '('. -updateSSLConfig: function(loadBalancer, details, callback) { -pkgcloud/rackspace/loadbalancer/client/loadbalancers.js, line 303, character 28: Too many errors. (25% scanned). - -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 11, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 12, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../../lib/pkgcloud'), -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 13, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'), -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 14, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'), -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 15, character 5: Expected 'lb' at column 3, not column 5. -lb = pkgcloud.providers.rackspace.loadbalancer; -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 31, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 38, character 9: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 41, character 7: Expected exactly one space between '}' and 'else'. -else if (!body || !body.nodes) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 41, character 7: Expected 'else' at column 9, not column 7. -else if (!body || !body.nodes) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 42, character 9: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 45, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 45, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 46, character 9: Expected 'return' at column 11, not column 9. -return callback(null, body.nodes.map(function (node) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 47, character 11: Expected 'return' at column 13, not column 11. -return new lb.Node(self, -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 48, character 13: Expected '_' at column 15, not column 13. -_.extend(node, { loadBalancerId: loadBalancerId })); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 49, character 9: Expected '}' at column 11, not column 9. -}), res); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 50, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 57, character 137: Line too long. -* @description add a node or array of nodes to the provided load balancer. Each of the addresses must be unique to this load balancer. -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 73, character 21: Expected exactly one space between 'function' and '('. -addNodes: function(loadBalancer, nodes, callback) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 75, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 82, character 9: Combine this with the previous 'var' statement. -var postOptions = { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 88, character 51: Expected exactly one space between 'function' and '('. -postOptions.body.nodes = _.map(nodes, function(node) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 94, character 9: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 97, character 7: Expected exactly one space between '}' and 'else'. -else if (!body || !body.nodes) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 97, character 7: Expected 'else' at column 9, not column 7. -else if (!body || !body.nodes) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 98, character 9: Unexpected 'else' after 'return'. -return callback(new Error('Unexpected empty response')); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 101, character 7: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 101, character 7: Expected 'else' at column 9, not column 7. -else { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 102, character 9: Expected 'return' at column 11, not column 9. -return callback(null, body.nodes.map(function (node) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 103, character 11: Expected 'return' at column 13, not column 11. -return new lb.Node(self, -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 104, character 13: Expected '_' at column 15, not column 13. -_.extend(node, { loadBalancerId: loadBalancerId })); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 105, character 9: Expected '}' at column 11, not column 9. -}), res); -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 106, character 7: Expected '}' at column 9, not column 7. -} -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 119, character 23: Expected exactly one space between 'function' and '('. -updateNode: function(loadBalancer, node, callback) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 121, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 150, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 152, character 9: Expected 'nodeId' at column 7, not column 9. -nodeId = -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 174, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 183, character 9: Combine this with the previous 'var' statement. -var list = nodes.map(function (item) { -pkgcloud/rackspace/loadbalancer/client/nodes.js, line 206, character 9: Expected 'loadBalancerId' at column 7, not column 9. -loadBalancerId = -pkgcloud/rackspace/storage/container.js, line 10, character 5: Expected 'base' at column 3, not column 5. -base = require('../../openstack/storage/container'), -pkgcloud/rackspace/storage/container.js, line 11, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/storage/client/archive.js, line 10, character 5: Expected 'filed' at column 3, not column 5. -filed = require('filed'); -pkgcloud/rackspace/storage/client/archive.js, line 20, character 27: Expected exactly one space between 'function' and '('. -exports.extract = function(options, callback) { -pkgcloud/rackspace/storage/client/archive.js, line 22, character 1: Unexpected '(space)'. - -pkgcloud/rackspace/storage/client/archive.js, line 27, character 1: Unexpected '(space)'. - -pkgcloud/rackspace/storage/client/archive.js, line 40, character 1: Unexpected '(space)'. - -pkgcloud/rackspace/storage/client/archive.js, line 45, character 3: Expected exactly one space between '}' and 'else'. -else if (options.stream) { -pkgcloud/rackspace/storage/client/archive.js, line 45, character 3: Expected 'else' at column 5, not column 3. -else if (options.stream) { -pkgcloud/rackspace/storage/client/archive.js, line 50, character 40: Expected exactly one space between 'function' and '('. -inputStream.on('response', function(response) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 21, character 105: Line too long. -* @param {String} [options.marker] the id of the first record to return in the current query -pkgcloud/rackspace/storage/client/cdn-containers.js, line 32, character 7: Combine this with the previous 'var' statement. -var getContainerOpts = { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 41, character 7: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 43, character 5: Expected exactly one space between '}' and 'else'. -else if (!body || !(body instanceof Array)) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 43, character 5: Expected 'else' at column 7, not column 5. -else if (!body || !(body instanceof Array)) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 44, character 49: Expected ';' and instead saw '}'. -return new Error('Malformed API Response') -pkgcloud/rackspace/storage/client/cdn-containers.js, line 48, character 7: Unexpected 'else' after 'return'. -return callback(null, body.map(function (container) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 52, character 5: Expected exactly one space between '}' and 'else'. -else { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 52, character 5: Expected 'else' at column 7, not column 5. -else { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 53, character 7: Expected 'var' at column 9, not column 7. -var containers = []; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 55, character 7: Expected 'async' at column 9, not column 7. -async.forEachLimit(body, 10, function (c, next) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 56, character 9: Expected 'var' at column 11, not column 9. -var container = new self.models.Container(self, c); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 58, character 9: Expected 'containers' at column 11, not column 9. -containers.push(container); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 59, character 9: Expected 'container' at column 11, not column 9. -container.refreshCdnDetails(function (err) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 60, character 11: Expected 'if' at column 13, not column 11. -if (err) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 61, character 13: Expected 'return' at column 15, not column 13. -return next(err); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 62, character 11: Expected '}' at column 13, not column 11. -} -pkgcloud/rackspace/storage/client/cdn-containers.js, line 63, character 11: Expected 'next' at column 13, not column 11. -next(); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 64, character 9: Expected '}' at column 11, not column 9. -}) -pkgcloud/rackspace/storage/client/cdn-containers.js, line 64, character 11: Expected ';' and instead saw '}'. -}) -pkgcloud/rackspace/storage/client/cdn-containers.js, line 65, character 7: Expected '}' at column 9, not column 7. -}, function (err) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 66, character 9: Expected 'callback' at column 11, not column 9. -callback(err, containers); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 67, character 7: Expected '}' at column 9, not column 7. -}); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 68, character 5: Expected '}' at column 7, not column 5. -} -pkgcloud/rackspace/storage/client/cdn-containers.js, line 117, character 105: Line too long. -* @param {String} [options.marker] the id of the first record to return in the current query -pkgcloud/rackspace/storage/client/cdn-containers.js, line 118, character 108: Line too long. -* @param {String} [options.end_marker] the id of the last record to return in the current query -pkgcloud/rackspace/storage/client/cdn-containers.js, line 119, character 102: Line too long. -* @param {boolean} [options.enabled_only] only get containers which are cdn enabled = true -pkgcloud/rackspace/storage/client/cdn-containers.js, line 130, character 7: Combine this with the previous 'var' statement. -var getContainerOpts = { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 139, character 25: ['enabled_only'] is better written in dot notation. -getContainerOpts.qs['enabled_only'] = options.cdnOnly; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 150, character 7: Expected 'container' at column 9, not column 7. -container.cdnEnabled = container.cdn_enabled == 'true'; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 150, character 52: Expected '===' and instead saw '=='. -container.cdnEnabled = container.cdn_enabled == 'true'; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 151, character 7: Expected 'container' at column 9, not column 7. -container.logRetention = container.log_retention == 'true'; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 151, character 56: Expected '===' and instead saw '=='. -container.logRetention = container.log_retention == 'true'; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 152, character 7: Expected 'container' at column 9, not column 7. -container.cdnUri = container.cdn_uri; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 153, character 7: Expected 'container' at column 9, not column 7. -container.cdnSslUri = container.cdn_ssl_uri; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 155, character 7: Expected 'return' at column 9, not column 7. -return new self.models.Container(self, container); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 156, character 5: Expected '}' at column 7, not column 5. -})); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 172, character 51: Expected exactly one space between 'function' and '('. -this._getCdnContainerDetails(container, function(err, details) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 185, character 101: Line too long. -* @param {object|boolean} options an object with options, or boolean to just enable/disable -pkgcloud/rackspace/storage/client/cdn-containers.js, line 192, character 7: Expected 'containerName' at column 5, not column 7. -containerName = container instanceof self.models.Container ? container.name : container, -pkgcloud/rackspace/storage/client/cdn-containers.js, line 193, character 7: Expected 'enabled' at column 5, not column 7. -enabled = typeof options === 'boolean' ? options : options.enabled; -pkgcloud/rackspace/storage/client/cdn-containers.js, line 201, character 7: Combine this with the previous 'var' statement. -var cdnOpts = { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 214, character 34: Expected exactly one space between 'function' and '('. -self._request(cdnOpts, function(err) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 219, character 46: Expected exactly one space between 'function' and '('. -self.getContainer(containerName, function(err, container) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 243, character 7: Combine this with the previous 'var' statement. -var cdnOpts = { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 280, character 43: Expected exactly one space between 'function' and '('. -exports._getCdnContainerDetails = function(container, callback) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 289, character 16: Confusing use of '!'. -if (err && !(err.statusCode === 404)) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 290, character 7: Unexpected 'else' after 'return'. -return callback(err); -pkgcloud/rackspace/storage/client/cdn-containers.js, line 292, character 5: Expected exactly one space between '}' and 'else'. -else if (err) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 292, character 5: Expected 'else' at column 7, not column 5. -else if (err) { -pkgcloud/rackspace/storage/client/cdn-containers.js, line 292, character 5: Too many errors. (92% scanned). - -pkgcloud/rackspace/storage/client/files.js, line 10, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/rackspace/storage/client/files.js, line 11, character 5: Expected 'utile' at column 3, not column 5. -utile = require('utile'), -pkgcloud/rackspace/storage/client/files.js, line 12, character 5: Expected 'base' at column 3, not column 5. -base = require('../../../core/storage'), -pkgcloud/rackspace/storage/client/files.js, line 13, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/rackspace/storage/client/files.js, line 14, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/rackspace/storage/client/files.js, line 32, character 3: Expected exactly one space between '}' and 'else'. -else if (typeof emails === 'string') { -pkgcloud/rackspace/storage/client/files.js, line 32, character 3: Expected 'else' at column 5, not column 3. -else if (typeof emails === 'string') { -pkgcloud/rackspace/storage/client/files.js, line 36, character 7: Combine this with the previous 'var' statement. -var purgeOptions = { -pkgcloud/rackspace/storage/client/files.js, line 49, character 7: Expected 'return' at column 5, not column 7. -return err -pkgcloud/rackspace/storage/client/files.js, line 52, character 5: Expected '}' at column 3, not column 5. -} -pkgcloud/rackspace/storage/client/files.js, line 53, character 3: Expected ')' at column 5, not column 3. -); -pkgcloud/rackspace/storage/client/index.js, line 9, character 5: Expected 'rackspace' at column 3, not column 5. -rackspace = require('../../client'), -pkgcloud/rackspace/storage/client/index.js, line 10, character 5: Expected 'StorageClient' at column 3, not column 5. -StorageClient = require('../../../openstack/storage/storageClient').StorageClient, -pkgcloud/rackspace/storage/client/index.js, line 11, character 5: Expected '_' at column 3, not column 5. -_ = require('underscore'); -pkgcloud/redistogo/database/client/index.js, line 9, character 5: Expected 'request' at column 3, not column 5. -request = require('request'), -pkgcloud/redistogo/database/client/index.js, line 10, character 5: Expected 'pkgcloud' at column 3, not column 5. -pkgcloud = require('../../../../pkgcloud'), -pkgcloud/redistogo/database/client/index.js, line 11, character 5: Expected 'errs' at column 3, not column 5. -errs = require('errs'); -pkgcloud/redistogo/database/client/index.js, line 36, character 29: Expected '===' and instead saw '=='. -if (response.statusCode == 401 || response.statusCode == 403) { -pkgcloud/redistogo/database/client/index.js, line 36, character 59: Expected '===' and instead saw '=='. -if (response.statusCode == 401 || response.statusCode == 403) { -pkgcloud/redistogo/database/client/index.js, line 49, character 7: Unexpected 'else' after 'return'. -return callback(null, database); -pkgcloud/redistogo/database/client/index.js, line 68, character 14: ['plan'] is better written in dot notation. -if (!attrs['plan']) { -pkgcloud/redistogo/database/client/index.js, line 69, character 11: ['plan'] is better written in dot notation. -attrs['plan'] = 'nano'; -pkgcloud/redistogo/database/client/index.js, line 96, character 7: Expected 'path' at column 5, not column 7. -path = '/instances', -pkgcloud/redistogo/database/client/index.js, line 97, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/redistogo/database/client/index.js, line 122, character 7: Expected 'path' at column 5, not column 7. -path = '/instances/' + id, -pkgcloud/redistogo/database/client/index.js, line 123, character 7: Expected 'self' at column 5, not column 7. -self = this; -pkgcloud/redistogo/database/client/index.js, line 140, character 124:[0m Line too long. -uri: 'redis://nodejitsu:' + response.password + '@' + response.label.split('-')[0] + '.redistogo.com:' + response.port, -pkgcloud/telefonica/compute/client.js, line 9, character 5: Expected 'urlJoin' at column 3, not column 5. -urlJoin = require('url-join'), -pkgcloud/telefonica/compute/client.js, line 10, character 5: Expected 'joyent' at column 3, not column 5. -joyent = require('../../joyent/compute'); -pkgcloud/telefonica/compute/client.js, line 29, character 5: Expected 'options' at column 9, not column 5. -options : options.path)); -1622 errors From 31ecc20544c2f8bada36325383eafc8f0a8ad72f Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 9 May 2014 17:50:16 -0700 Subject: [PATCH 087/460] Fixing Ports.js to always convert to wire format. --- lib/pkgcloud/openstack/network/client/ports.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index dd9e13ba0..44b2295de 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -87,9 +87,7 @@ exports.createPort = function (options, callback) { var port = typeof options === 'object' ? options : { 'name' : options}, self = this; - if(port instanceof this.models.Port) { - port = _convertPortToWireFormat(port); - } + port = _convertPortToWireFormat(port); var createPortOpts = { method: 'POST', @@ -117,10 +115,7 @@ exports.updatePort = function (port, callback) { var self = this, portId = port.id; - if(port instanceof this.models.Port) { - port = _convertPortToWireFormat(port); - } - + port = _convertPortToWireFormat(port); var updatePortOpts = { method: 'PUT', path: urlJoin('/v2.0/ports', portId), From 1becbd275977662ee1427cd37177b2067671d159 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 12 May 2014 10:23:54 -0700 Subject: [PATCH 088/460] Fixing spacing of if( statement and adding tests for deleting with id. --- docs/providers/openstack/network.md | 56 +++++++++---------- .../openstack/network/networkClient.js | 2 +- test/common/network/network-test.js | 14 +++++ test/common/network/port-test.js | 14 +++++ test/common/network/subnet-test.js | 14 +++++ 5 files changed, 71 insertions(+), 29 deletions(-) diff --git a/docs/providers/openstack/network.md b/docs/providers/openstack/network.md index ca8932890..a778fdc7f 100644 --- a/docs/providers/openstack/network.md +++ b/docs/providers/openstack/network.md @@ -7,7 +7,7 @@ Creating a client is straight-forward: provider: 'openstack', username: 'your-user-name', password: 'your-password', - authUrl: 'https://your-identity-service' + authUrl: 'https://yourIdentity-service' }); ``` ### API Methods @@ -33,9 +33,9 @@ Options are as follows: ```js { name: 'networkName', // optional - admin_state_up : true, // optional + adminStateUp : true, // optional shared : true, // optional, Admin only - tenant_id : '' // optional, Admin only + tenantId : 'tenantId' // optional, Admin only } ``` Returns the network in the callback `f(err, network)` @@ -47,11 +47,11 @@ Options are as follows: ```js { - id : '', // required + id : 'networkId', // required name: 'networkName', // optional - admin_state_up : true, // optional + adminStateUp : true, // optional shared : true, // optional, Admin only - tenant_id : '' // optional, Admin only + tenantId : 'tenantId' // optional, Admin only } ``` Returns the network in the callback `f(err, network)` @@ -82,11 +82,11 @@ Options are as follows: ```js { name: 'subnetName', // optional - network_id : '', // required, The ID of the attached network. + networkId : 'networkId', // required, The ID of the attached network. shared : true, // optional, Admin only - tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only - gateway_ip : 'gateway ip address', // optional,The gateway IP address. - enable_dhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + gatewayIp : 'gateway ip address', // optional,The gateway IP address. + enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. } ``` Returns the subnet in the callback `f(err, subnet)` @@ -98,13 +98,13 @@ Options are as follows: ```js { - id : '', // required + id : 'subnetId', // required name: 'subnetName', // optional - network_id : '', // required, The ID of the attached network. + networkId : 'networkId', // required, The ID of the attached network. shared : true, // optional, Admin only - tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only - gateway_ip : 'gateway ip address', // optional,The gateway IP address. - enable_dhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + gatewayIp : 'gateway ip address', // optional,The gateway IP address. + enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. } ``` Returns the subnet in the callback `f(err, subnet)` @@ -135,13 +135,13 @@ Options are as follows: ```js { name: 'portName', // optional - admin_state_up : true, // optional, The administrative status of the router. Admin-only - network_id : '', // required, The ID of the attached network. + adminStateUp : true, // optional, The administrative status of the router. Admin-only + networkId : 'networkId', // required, The ID of the attached network. status : 'text status', // optional, The status of the port. - tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only - mac_address: 'mac address' // optional - fixed_ips : ['ip address1', 'ip address 2'], // optional. - security_groups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + macAddress: 'mac address' // optional + fixedIps : ['ip address1', 'ip address 2'], // optional. + securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. } ``` Returns the port in the callback `f(err, port)` @@ -153,15 +153,15 @@ Options are as follows: ```js { - id : '', // required + id : 'portId', // required name: 'portName', // optional - admin_state_up : true, // optional, The administrative status of the router. Admin-only - network_id : '', // required, The ID of the attached network. + adminStateUp : true, // optional, The administrative status of the router. Admin-only + networkId : 'networkId', // required, The ID of the attached network. status : 'text status', // optional, The status of the port. - tenant_id : '' // optional, The ID of the tenant who owns the network. Admin-only - mac_address: 'mac address' // optional - fixed_ips : ['ip address1', 'ip address 2'], // optional. - security_groups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + macAddress: 'mac address' // optional + fixedIps : ['ip address1', 'ip address 2'], // optional. + securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. } ``` Returns the port in the callback `f(err, port)` diff --git a/lib/pkgcloud/openstack/network/networkClient.js b/lib/pkgcloud/openstack/network/networkClient.js index 653b91561..3b31be306 100644 --- a/lib/pkgcloud/openstack/network/networkClient.js +++ b/lib/pkgcloud/openstack/network/networkClient.js @@ -26,7 +26,7 @@ Client.prototype._getUrl = function (options) { var fragment = ''; if (options.network) { - if(options.method === 'GET') { + if (options.method === 'GET') { fragment = encodeURIComponent(options.network); } } diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index bd6ce8243..c5a62621a 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -133,6 +133,20 @@ providers.filter(function (provider) { }); }); + it('the destroyNetwork() method should take an id, delete a network', function (done) { + if (mock) { + setupDestroyNetworkMock(client, provider, { + authServer: authServer, + server: server + }, context.currentNetwork); + } + + client.destroyNetwork(context.currentNetwork.id, function (err) { + should.not.exist(err); + done(); + }); + }); + it('the updateNetwork() method should update a network', function (done) { var networkToUpdate = context.currentNetwork; diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 45e9b8e7c..c4ab16a86 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -135,6 +135,20 @@ providers.filter(function (provider) { }); }); + it('the destroyPort() method should take an id, delete a port', function (done) { + if (mock) { + setupDestroyPortMock(client, provider, { + authServer: authServer, + server: server + }, context.currentPort); + } + + client.destroyPort(context.currentPort.id, function (err) { + should.not.exist(err); + done(); + }); + }); + it('the updatePort() method should update a port', function (done) { var portToUpdate = context.currentPort; diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index 1531ff115..a4d1b4875 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -135,6 +135,20 @@ providers.filter(function (provider) { }); }); + it('the destroySubnet() method should take an id, delete a subnet', function (done) { + if (mock) { + setupDestroySubnetMock(client, provider, { + authServer: authServer, + server: server + }, context.currentSubnet); + } + + client.destroySubnet(context.currentSubnet.id, function (err) { + should.not.exist(err); + done(); + }); + }); + it('the updateSubnet() method should update a subnet', function (done) { var subnetToUpdate = context.currentSubnet; From 12c9046a162f567bba6219c6d4d955a2908f07af Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 13 May 2014 13:07:39 -0700 Subject: [PATCH 089/460] [provider] [docs] [test] Adding network service for HP provider along with tests & docs. --- README.md | 5 +- docs/README.md | 1 + docs/providers/hp/network.md | 173 ++++++++++++++++++++++++ lib/pkgcloud/hp/index.js | 1 + lib/pkgcloud/hp/network/client/index.js | 31 +++++ lib/pkgcloud/hp/network/index.js | 15 ++ test/common/network/network-test.js | 66 +++++++++ test/common/network/port-test.js | 69 ++++++++++ test/common/network/subnet-test.js | 71 ++++++++++ test/fixtures/hp/realToken.json | 12 ++ 10 files changed, 443 insertions(+), 1 deletion(-) create mode 100644 docs/providers/hp/network.md create mode 100644 lib/pkgcloud/hp/network/client/index.js create mode 100644 lib/pkgcloud/hp/network/index.js diff --git a/README.md b/README.md index adb9b1598..eeea0bdf4 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ If a service does not have at least two providers, it is considered a *beta* int * **[Load Balancers](#load-balancers----beta)** *(beta)* * [Rackspace](docs/providers/rackspace/loadbalancer.md) * **[Network](#network----beta)** *(beta)* + * [HP](docs/providers/hp/network.md) * [Openstack](docs/providers/openstack/network.md) ## Compute @@ -403,7 +404,7 @@ Each instance of `pkgcloud.loadbalancer.Client` returned from `pkgcloud.loadbala ## Network -- Beta -##### Note: Network is considered Beta until there are multiple providers; presently only Openstack providers are supported. +##### Note: Network is considered Beta until there are multiple providers; presently only HP & Openstack providers are supported. The `pkgcloud.network` service is designed to make it easy to create and manage networks. @@ -424,8 +425,10 @@ To get started with a `pkgcloud.network` client just create one: #### Providers +* [HP](docs/providers/hp/network.md) * [Openstack](docs/providers/openstack/network.md) + Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.createClient` has a set of uniform APIs: ### Networks diff --git a/docs/README.md b/docs/README.md index 1c5dcb544..38c3098d4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -42,3 +42,4 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](providers/rackspace/loadbalancer.md) * **Networking** *(beta)* * [Openstack](providers/openstack/network.md) + * [HP](providers/openstack/hp.md) diff --git a/docs/providers/hp/network.md b/docs/providers/hp/network.md new file mode 100644 index 000000000..e7d5659c7 --- /dev/null +++ b/docs/providers/hp/network.md @@ -0,0 +1,173 @@ +##Using the HP Cloud Network provider + +Creating a client is straight-forward: + +``` js + var hPNetwork = pkgcloud.network.createClient({ + provider: 'hp', + username: 'your-user-name', + password: 'your-password', + region: 'region of identity service', + authUrl: 'https://your-identity-service' + }); +``` +### API Methods + +**Networks** + +#### client.getNetworks(callback) +Lists all networks that are available to use on your HP Cloud account + +Callback returns `f(err, networks)` where `networks` is an `Array` + +#### client.getNetwork(network, callback) +Gets specified network + +Takes network or networkId as an argument and returns the network in the callback +`f(err, network)` + +#### client.createNetwork(options, callback) +Creates a network with the options specified + +Options are as follows: + +```js +{ + name: 'networkName', // optional + adminStateUp : true, // optional + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, Admin only +} +``` +Returns the network in the callback `f(err, network)` + +#### client.updateNetwork(options, callback) +Updates a network with the options specified + +Options are as follows: + +```js +{ + id : 'networkId', // required + name: 'networkName', // optional + adminStateUp : true, // optional + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, Admin only +} +``` +Returns the network in the callback `f(err, network)` + +#### client.destroyNetwork(network, callback) +Destroys the specified network + +Takes network or networkId as an argument and returns the id of the destroyed network in the callback `f(err, networkId)` + +**Subnets** + +#### client.getSubnets(callback) +Lists all subnets that are available to use on your HP Cloud account + +Callback returns `f(err, subnets)` where `subnets` is an `Array` + +#### client.getSubnet(subnet, callback) +Gets specified subnet + +Takes subnet or subnetId as an argument and returns the subnet in the callback +`f(err, subnet)` + +#### client.createSubnet(options, callback) +Creates a subnet with the options specified + +Options are as follows: + +```js +{ + name: 'subnetName', // optional + networkId : 'networkId', // required, The ID of the attached network. + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + gatewayIp : 'gateway ip address', // optional,The gateway IP address. + enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. +} +``` +Returns the subnet in the callback `f(err, subnet)` + +#### client.updateSubnet(options, callback) +Updates a subnet with the options specified + +Options are as follows: + +```js +{ + id : 'subnetId', // required + name: 'subnetName', // optional + networkId : 'networkId', // required, The ID of the attached network. + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + gatewayIp : 'gateway ip address', // optional,The gateway IP address. + enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. +} +``` +Returns the subnet in the callback `f(err, subnet)` + +#### client.destroySubnet(subnet, callback) +Destroys the specified subnet + +Takes subnet or subnetId as an argument and returns the id of the destroyed subnet in the callback `f(err, subnetId)` + +**Ports** + +#### client.getPorts(callback) +Lists all ports that are available to use on your HP Cloud account + +Callback returns `f(err, ports)` where `ports` is an `Array` + +#### client.getPort(port, callback) +Gets specified port + +Takes port or portId as an argument and returns the port in the callback +`f(err, port)` + +#### client.createPort(options, callback) +Creates a port with the options specified + +Options are as follows: + +```js +{ + name: 'portName', // optional + adminStateUp : true, // optional, The administrative status of the router. Admin-only + networkId : 'networkId', // required, The ID of the attached network. + status : 'text status', // optional, The status of the port. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + macAddress: 'mac address' // optional + fixedIps : ['ip address1', 'ip address 2'], // optional. + securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. +} +``` +Returns the port in the callback `f(err, port)` + +#### client.updatePort(options, callback) +Updates a port with the options specified + +Options are as follows: + +```js +{ + id : 'portId', // required + name: 'portName', // optional + adminStateUp : true, // optional, The administrative status of the router. Admin-only + networkId : 'networkId', // required, The ID of the attached network. + status : 'text status', // optional, The status of the port. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + macAddress: 'mac address' // optional + fixedIps : ['ip address1', 'ip address 2'], // optional. + securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. +} +``` +Returns the port in the callback `f(err, port)` + +#### client.destroyPort(port, callback) +Destroys the specified port + +Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)` diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js index 0c6379545..fd0c7677f 100644 --- a/lib/pkgcloud/hp/index.js +++ b/lib/pkgcloud/hp/index.js @@ -8,3 +8,4 @@ exports.storage = require('./storage'); exports.compute = require('./compute'); +exports.network = require('./network'); diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js new file mode 100644 index 000000000..79f7178ea --- /dev/null +++ b/lib/pkgcloud/hp/network/client/index.js @@ -0,0 +1,31 @@ +/* + * client.js: Client for HP networking + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +var utile = require('utile'), + urlJoin = require('url-join'), + hp = require('../../client'), + NetworkClient = require('../../../openstack/network/networkClient').NetworkClient, + _ = require('underscore'); + +var Client = exports.Client = function (options) { + hp.Client.call(this, options); + + this.models = { + Network: require('../../../openstack/network/network').Network, + Subnet: require('../../../openstack/network/subnet').Subnet, + Port: require('../../../openstack/network/port').Port + }; + + utile.mixin(this, require('../../../openstack/network/client/networks')); + utile.mixin(this, require('../../../openstack/network/client/subnets')); + utile.mixin(this, require('../../../openstack/network/client/ports')); + + this.serviceType = 'network'; +}; + +utile.inherits(Client, hp.Client); +_.extend(Client.prototype, NetworkClient.prototype); diff --git a/lib/pkgcloud/hp/network/index.js b/lib/pkgcloud/hp/network/index.js new file mode 100644 index 000000000..39de77514 --- /dev/null +++ b/lib/pkgcloud/hp/network/index.js @@ -0,0 +1,15 @@ +/* + * index.js: Top-level include for the HP networking client. + * + * (C) 2014 Hewlett-Packard Development Company, L.P. + * + */ + +exports.Client = require('./client').Client; +exports.Network = require('../../openstack/network/network').Network; +exports.Subnet = require('../../openstack/network/subnet').Subnet; +exports.Port = require('../../openstack/network/port').Port; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index c5a62621a..566372779 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -251,6 +251,11 @@ function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ @@ -260,6 +265,12 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'hp') { + servers.server + .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id), + {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwork){ @@ -268,6 +279,11 @@ function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwor .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupNetworksMock(client, provider, servers) { @@ -299,6 +315,34 @@ function setupNetworksMock(client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks') .replyWithFile(200, __dirname + '/../../fixtures/openstack/networks.json'); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/networks.json'); + } } function setupNetworkMock(client, provider, servers) { @@ -308,6 +352,12 @@ function setupNetworkMock(client, provider, servers) { {network: {name: 'create-test-ids2'}}) .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', + {network: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupRefreshNetworkMock(client, provider, servers, network) { @@ -316,6 +366,11 @@ function setupRefreshNetworkMock(client, provider, servers, network) { .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks',network.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks',network.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupNetworkModelCreateMock(client, provider, servers) { @@ -325,6 +380,12 @@ function setupNetworkModelCreateMock(client, provider, servers) { {network: {name: 'model created network'}}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', + {network: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupGetNetworkMock(client, provider, servers) { @@ -333,6 +394,11 @@ function setupGetNetworkMock(client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'hp') { + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } } var serverStatusReply = function (name, status) { diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index c4ab16a86..69b219e41 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -253,6 +253,11 @@ function setupDestroyPortMock(client, provider, servers, currentPort){ .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupUpdatePortMock(client, provider, servers, currentPort){ @@ -265,6 +270,15 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'hp') { + servers.server + .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id), + {"port":{"status":"ACTIVE","name":"my_port","admin_state_up":false,"mac_address":"fa:16:3e:58:42:ed", + "fixed_ips":[{"subnet_id":"008ba151-0b8c-4a67-98b5-0d2b87666062","ip_address":"172.24.4.2"}], + "security_groups":[],"network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3"} + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupModelDestroyedPortMock(client, provider, servers, currentPort){ @@ -273,6 +287,11 @@ function setupModelDestroyedPortMock(client, provider, servers, currentPort){ .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupPortsMock(client, provider, servers) { @@ -304,6 +323,34 @@ function setupPortsMock(client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports') .replyWithFile(200, __dirname + '/../../fixtures/openstack/ports.json'); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/ports.json'); + } } function setupCreatePortMock(client, provider, servers) { @@ -313,6 +360,12 @@ function setupCreatePortMock(client, provider, servers) { {port: {name: 'create-test-ids2'}}) .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', + {port: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupRefreshPortMock(client, provider, servers, port) { @@ -321,6 +374,11 @@ function setupRefreshPortMock(client, provider, servers, port) { .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', port.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', port.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupPortModelCreateMock(client, provider, servers) { @@ -330,6 +388,12 @@ function setupPortModelCreateMock(client, provider, servers) { {port: {name: 'model created network'}}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', + {port: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupGetPortMock(client, provider, servers, currentPort) { @@ -338,4 +402,9 @@ function setupGetPortMock(client, provider, servers, currentPort) { .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index a4d1b4875..414055444 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -253,6 +253,11 @@ function setupDestroySubnetMock(client, provider, servers, currentSubnet){ .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ @@ -267,6 +272,17 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ "enable_dhcp":false}}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'hp') { + servers.server + .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id), + {"subnet":{"name":"my_subnet", + "network_id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id":"4fd44f30292945e481c7b8a0c8908869", + "allocation_pools":[{"start":"192.0.0.2","end":"192.255.255.254"}], + "gateway_ip":"192.0.0.1","ip_version":4,"cidr":"192.0.0.0/8", + "enable_dhcp":false}}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet){ @@ -275,6 +291,11 @@ function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet) .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupSubnetsMock(client, provider, servers) { @@ -306,6 +327,34 @@ function setupSubnetsMock(client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets') .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnets.json'); } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnets.json'); + } } function setupCreateSubnetMock(client, provider, servers) { @@ -315,6 +364,12 @@ function setupCreateSubnetMock(client, provider, servers) { {subnet: {name: 'create-test-ids2'}}) .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', + {subnet: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupRefreshSubnetMock(client, provider, servers, subnet) { @@ -323,6 +378,11 @@ function setupRefreshSubnetMock(client, provider, servers, subnet) { .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', subnet.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', subnet.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupSubnetModelCreateMock(client, provider, servers) { @@ -332,6 +392,12 @@ function setupSubnetModelCreateMock(client, provider, servers) { {subnet: {name: 'model created network'}}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', + {subnet: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupGetSubnetMock(client, provider, servers, currentSubnet) { @@ -340,4 +406,9 @@ function setupGetSubnetMock(client, provider, servers, currentSubnet) { .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } } diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 736af37b5..3683ed292 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -47,6 +47,18 @@ "endpoints_links": [], "type": "compute", "name": "nova" + }, { + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "region": "region-a.geo-1", + "internalURL": "http://10.225.0.8:8774/v2/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v2/5ACED3DC3AA740ABAA41711243CC6949" + } + ], + "endpoints_links": [], + "type": "network", + "name": "neutron" }, { "endpoints": [ From c0e19a72964175d0249fc149db4c15ddbea632d9 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 14 May 2014 14:17:33 -0700 Subject: [PATCH 090/460] Added network authentication tests for HP provider. --- test/hp/network/authentication-test.js | 228 +++++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 test/hp/network/authentication-test.js diff --git a/test/hp/network/authentication-test.js b/test/hp/network/authentication-test.js new file mode 100644 index 000000000..2e4fc4dcd --- /dev/null +++ b/test/hp/network/authentication-test.js @@ -0,0 +1,228 @@ +/* +* authentication-test.js: Tests for pkgcloud hp network authentication +* +* (C) 2014 Hewlett-Packard Development Company, L.P. +* +*/ + +var should = require('should'), + async = require('async'), + hock = require('hock'), + macros = require('../macros'), + helpers = require('../../helpers'), + mock = !!process.env.MOCK; + +describe('pkgcloud/hp/network/authentication', function () { + var client, authServer, server; + + describe('The pkgcloud hp network client', function () { + + before(function (done) { + client = helpers.createClient('hp', 'network'); + + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + hock.createHock(12346, function (err, hockClient) { + should.not.exist(err); + should.exist(hockClient); + + authServer = hockClient; + next(); + }); + }, + function (next) { + hock.createHock(12345, function (err, hockClient) { + should.not.exist(err); + should.exist(hockClient); + + server = hockClient; + next(); + }); + } + ], done); + }); + + it('should have core methods defined', function() { + macros.shouldHaveCreds(client); + }); + + describe('the auth() method with a valid username and api key', function () { + var err, res; + + beforeEach(function (done) { + + client = helpers.createClient('hp', 'compute'); + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + + client.auth(function (e) { + should.not.exist(e); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function () { + client._identity.should.be.a('object'); + }); + }); + + describe('the auth() method with an invalid username and api key', function () { + + var badClient = helpers.createClient('hp', 'compute', { + username: 'fake', + apiKey: 'data', + authUrl: 'localhost:12346', + protocol: 'http://', + region: 'custom region' + }); + + var err, res; + + beforeEach(function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'fake', + secretKey: 'data' + } + } + }) + .reply(401, { + unauthorized: { + message: 'Username or api key is invalid', code: 401 + } + }); + } + + badClient.auth(function (e) { + err = e; + authServer && authServer.done(); + done(); + }); + + }); + + it('should respond with Error code 401', function () { + should.exist(err); + // TODO resolve identity responses + }); + }); + + describe('auth tokens should expire', function () { + var tokenExpiry; + + beforeEach(function (done) { + + client = helpers.createClient('hp', 'compute'); + + client.on('log::*', function(message, obj) { + if (this.event !== 'log::trace') { + console.log(message); + console.dir(obj); + } + }); + + if (mock) { + + var response = helpers.gethpAuthResponse(new Date(new Date().getTime() + 1)); + + tokenExpiry = response.access.token.expires; + + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, response); + } + + client.auth(function (e) { + should.not.exist(e); + authServer && authServer.done(); + done(); + }); + }); + + it('should update the config with appropriate urls', function () { + client._identity.should.be.a('object'); + client._identity.token.expires.toString().should.equal(tokenExpiry); + }); + + it('should expire the token and set authorized to false', function(done) { + setTimeout(function() { + client._isAuthorized().should.equal(false); + done(); + }, 5); + }); + + it('should expire the token and reauth on next call', function (done) { + + if (mock) { + authServer + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.gethpAuthResponse()); + + server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); + } + + setTimeout(function () { + client._isAuthorized().should.equal(false); + client.getImages(function(err, images) { + client._isAuthorized().should.equal(true); + should.not.exist(err); + should.exist(images); + server && server.done(); + authServer && authServer.done(); + done(); + }); + }, 5); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + }); +}); From db89f719cfd425a40355164da043ed4df06a4268 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 19 May 2014 12:54:01 -0700 Subject: [PATCH 091/460] Restricting import of extensions to only those supported by HP. Responding to code review comments. --- docs/providers/hp/README.md | 12 ++++++++---- docs/providers/hp/compute.md | 2 +- docs/providers/hp/getting-started-compute.md | 2 +- docs/providers/hp/network.md | 2 +- docs/providers/hp/storage.md | 2 +- lib/pkgcloud/hp/client.js | 5 +++-- lib/pkgcloud/hp/compute/client/index.js | 4 +++- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 4c79b455e..e14174dff 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -20,9 +20,13 @@ For all of the HP Cloud services, you create a client with the same options: var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password' + apiKey: 'your-api-key' }); ``` +### Getting your API key + +You can provision API keys in your cloud management console. +Please see [here](https://community.hpcloud.com/article/managing-your-access-keys) for more instructions. ### Authentication Endpoints and Regions @@ -40,7 +44,7 @@ If you're targeting an HP Private Cloud instance, please contact your administra var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password', + apiKey: 'your-api-key', region: 'region-a.geo-1', authUrl: 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/' }); @@ -52,7 +56,7 @@ var client = require('pkgcloud').compute.createClient({ var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password', + apiKey: 'your-api-key', region: 'region-b.geo-1', authUrl: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/' }); @@ -70,7 +74,7 @@ If you're targeting an HP Private Cloud instance, please contact your administra var client = require('pkgcloud').compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password', + apiKey: 'your-api-key', region: 'region-a.custom.corp' }); ``` diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md index 5568d6462..7efb3a183 100644 --- a/docs/providers/hp/compute.md +++ b/docs/providers/hp/compute.md @@ -6,7 +6,7 @@ Creating a client is straight-forward: var HPCompute = pkgcloud.compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password', + apiKey: 'your-api-key', region: 'region of identity service', authUrl: 'https://your-identity-service' }); diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md index 9e7e3b870..744a38359 100644 --- a/docs/providers/hp/getting-started-compute.md +++ b/docs/providers/hp/getting-started-compute.md @@ -26,7 +26,7 @@ var pkgcloud = require('pkgcloud'), var client = pkgcloud.compute.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password', + apiKey: 'your-api-key', region: 'region of identity service', authUrl: 'https://your-identity-service' }); diff --git a/docs/providers/hp/network.md b/docs/providers/hp/network.md index e7d5659c7..b8824ed0c 100644 --- a/docs/providers/hp/network.md +++ b/docs/providers/hp/network.md @@ -6,7 +6,7 @@ Creating a client is straight-forward: var hPNetwork = pkgcloud.network.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password', + apiKey: 'your-api-key', region: 'region of identity service', authUrl: 'https://your-identity-service' }); diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index f861d3502..265b77dd4 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -13,7 +13,7 @@ Creating a client is straight-forward: var hpStorage = pkgcloud.storage.createClient({ provider: 'hp', username: 'your-user-name', - password: 'your-password', + apiKey: 'your-api-key', region: 'region of identity service', authUrl: 'https://your-identity-service' }); diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index 8f2d9ee1f..978cb7e4a 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -13,11 +13,12 @@ var utile = require('utile'), var Client = exports.Client = function (options) { options = options || {}; - if(!options.authUrl){ + if (!options.authUrl){ throw new Error('authUrl is invalid'); } - options.identity = identity.Identity; + options.identity = identity.Identity; + if (typeof options.useServiceCatalog === 'undefined') { options.useServiceCatalog = true; } diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 345ededed..665914453 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -16,7 +16,9 @@ var Client = exports.Client = function (options) { utile.mixin(this, require('../../../openstack/compute/client/flavors')); utile.mixin(this, require('../../../openstack/compute/client/images')); utile.mixin(this, require('../../../openstack/compute/client/servers')); - utile.mixin(this, require('../../../openstack/compute/client/extensions')); + utile.mixin(this, require('../../../openstack/compute/client/extensions/floating-ips')); + utile.mixin(this, require('../../../openstack/compute/client/extensions/security-groups')); + utile.mixin(this, require('../../../openstack/compute/client/extensions/servers')); this.serviceType = 'compute'; }; From 762c7875c73f760ecc7f6ed58091a9df06bc0b85 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 19 May 2014 12:56:08 -0700 Subject: [PATCH 092/460] Removing whitespace. --- lib/pkgcloud/hp/client.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index 978cb7e4a..cc47bbb34 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -18,7 +18,7 @@ var Client = exports.Client = function (options) { } options.identity = identity.Identity; - + if (typeof options.useServiceCatalog === 'undefined') { options.useServiceCatalog = true; } @@ -31,7 +31,6 @@ var Client = exports.Client = function (options) { utile.inherits(Client, base.Client); Client.prototype._getIdentityOptions = function() { - return _.extend({ apiKey: this.config.apiKey }, Client.super_.prototype._getIdentityOptions.call(this)); From 886380848e33e8995af643ab2a96ebe839305fd9 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Tue, 20 May 2014 15:52:01 -0700 Subject: [PATCH 093/460] Added release notes and updated package version to 0.9.5 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 143370221..0062fca56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.9.5 +* Openstack Network service. +* Added support for HP Cloud provider. + ## v0.9.4 * Added support for os-security-groups compute extension @@ -91,4 +95,3 @@ ## v0.7.2 * Added a pkgcloud User-Agent for outbound HTTP requests #134 * Added tests for core compute method signatures - diff --git a/package.json b/package.json index 28c331d57..19b5bd0a0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "0.9.4", + "version": "0.9.5", "author": "Nodejitsu Inc ", "contributors": [ { "name": "Charlie Robbins", "email": "charlie@nodejitsu.com" }, From aa28ab5a416383a75e40173d4cdaeb83cc9c9ac3 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 21 May 2014 11:07:03 -0700 Subject: [PATCH 094/460] Updating changelog for 0.9.5 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0062fca56..9f2e9836d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v0.9.5 * Openstack Network service. * Added support for HP Cloud provider. +* Added support for Rackspace Storage Temporary URLs ## v0.9.4 * Added support for os-security-groups compute extension From a2a02698ffb31792396891822b94564ff96cb039 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 21 May 2014 14:01:11 -0700 Subject: [PATCH 095/460] Changed branding to use HP Helion branding for HP provider --- README.md | 2 +- docs/providers/hp/README.md | 11 +++++++---- docs/providers/hp/compute.md | 4 +++- docs/providers/hp/getting-started-compute.md | 8 ++++---- docs/providers/hp/network.md | 2 ++ docs/providers/hp/storage.md | 2 ++ 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index eeea0bdf4..b8d7a042a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Currently there are six service types which are handled by pkgcloud: * [DNS](#dns----beta) *(beta)* * [Block Storage](#block-storage----beta) *(beta)* * [Load Balancers](#load-balancers----beta) *(beta)* -* [Network](#dns----beta) *(beta)* +* [Network](#network----beta) *(beta)* In our [Roadmap](#roadmap), we plan to add support for more services, such as Queueing, Monitoring, and more. Additionally, we plan to implement more providers for the *beta* services, thus moving them out of *beta*. diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index e14174dff..e0eae595e 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -1,13 +1,16 @@ -## Using the HP Cloud provider in pkgcloud +![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) -The HP Cloud provider in pkgcloud supports the following services: +## Using the HP Helion Cloud provider in pkgcloud + +The HP Helion Cloud provider in pkgcloud supports the following services: * [**Compute**](compute.md) (cloud compute) +* [**Network**](network.md) (network) * [**Storage**](storage.md) (object storage) -### Activating your HP Cloud services +### Activating your HP Helion Cloud services -If this is your first time using HP Cloud Services, please follow [this](https://community.hpcloud.com/article/hp-public-cloud-quick-start-guide) guide to get started. +If this is your first time using HP Helion Cloud Services, please follow [this](https://community.hpcloud.com/article/hp-public-cloud-quick-start-guide) guide to get started. ### Getting Started with Compute We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md index 7efb3a183..8b4a32261 100644 --- a/docs/providers/hp/compute.md +++ b/docs/providers/hp/compute.md @@ -1,4 +1,6 @@ -##Using the HP Cloud Compute provider +![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) + +##Using the HP Helion Cloud Compute provider Creating a client is straight-forward: diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md index 744a38359..f42848c0e 100644 --- a/docs/providers/hp/getting-started-compute.md +++ b/docs/providers/hp/getting-started-compute.md @@ -1,8 +1,8 @@ -# Getting started with pkgcloud & HP - +![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) +# Getting started with pkgcloud & HP Helion Cloud The HP node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package -Pkgcloud currently supports HP Cloud Compute and HP Cloud Object Storage. +Pkgcloud currently supports HP Helion Cloud Compute and HP Helion Cloud Object Storage, and HP Helion Cloud Networking. To install `pkgcloud` from the command line: @@ -14,7 +14,7 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). ## Using pkgcloud -In this example, we're going to create a HP Cloud Compute client, create two servers, and then output their details to the command line. +In this example, we're going to create a HP Helion Cloud Compute client, create two servers, and then output their details to the command line. *Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* diff --git a/docs/providers/hp/network.md b/docs/providers/hp/network.md index b8824ed0c..fa68340c0 100644 --- a/docs/providers/hp/network.md +++ b/docs/providers/hp/network.md @@ -1,3 +1,5 @@ +![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) + ##Using the HP Cloud Network provider Creating a client is straight-forward: diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index 265b77dd4..c8ffe179c 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -1,3 +1,5 @@ +![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) + ## Using the HP Object Storage provider * Container From 7648371e17589fb554d366d518ea651466b5b6d1 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 30 May 2014 11:04:48 -0400 Subject: [PATCH 096/460] Fixing a copy/paste error from getFlavors in openstack.getFlavor - Fixes #292 --- lib/pkgcloud/openstack/compute/client/flavors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/compute/client/flavors.js b/lib/pkgcloud/openstack/compute/client/flavors.js index a876be1fc..a4f804fdb 100644 --- a/lib/pkgcloud/openstack/compute/client/flavors.js +++ b/lib/pkgcloud/openstack/compute/client/flavors.js @@ -58,7 +58,7 @@ exports.getFlavor = function getFlavor(flavor, callback) { if (err) { return callback(err); } - if (!body || !body.flavors) { + if (!body || !body.flavor) { return callback(new Error('Unexpected empty response')); } else { From bcb63d058b2f2cb7d418cec78aef42ae86129523 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 10 Jun 2014 10:56:13 -0700 Subject: [PATCH 097/460] v0.9.6 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f2e9836d..a384e189b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.9.6 +* Fixed a long-standing bug in openstack.compute.getFlavor #292 + ## v0.9.5 * Openstack Network service. * Added support for HP Cloud provider. diff --git a/package.json b/package.json index 19b5bd0a0..00d49fd51 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "0.9.5", + "version": "0.9.6", "author": "Nodejitsu Inc ", "contributors": [ { "name": "Charlie Robbins", "email": "charlie@nodejitsu.com" }, From cd2fb53f4c06802497ee339df84c9dae671f2b58 Mon Sep 17 00:00:00 2001 From: Joshua Holbrook Date: Sun, 29 Jun 2014 23:15:56 -0400 Subject: [PATCH 098/460] Fix call to undefined Flavor --- lib/pkgcloud/digitalocean/compute/client/flavors.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/digitalocean/compute/client/flavors.js b/lib/pkgcloud/digitalocean/compute/client/flavors.js index 015a67dde..8d203af0d 100644 --- a/lib/pkgcloud/digitalocean/compute/client/flavors.js +++ b/lib/pkgcloud/digitalocean/compute/client/flavors.js @@ -57,6 +57,7 @@ exports.getFlavor = function getFlavor(flavor, callback) { return !flavor ? callback(new Error('No flavor found with id: ' + flavorId)) - : callback(null, new Flavor(self, flavor)); + : callback(null, new compute.Flavor(self, flavor)); }); -}; \ No newline at end of file +}; + From d2220e52a41cdaa72795c581eb190666592a49ce Mon Sep 17 00:00:00 2001 From: Shannon Code Date: Thu, 3 Jul 2014 11:20:36 -0400 Subject: [PATCH 099/460] Updated config to include region --- examples/compute/rackspace.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/compute/rackspace.js b/examples/compute/rackspace.js index dd5e89cb5..f768bed58 100644 --- a/examples/compute/rackspace.js +++ b/examples/compute/rackspace.js @@ -4,7 +4,8 @@ var pkgcloud = require('pkgcloud'), // create our client with your rackspace credentials var client = pkgcloud.providers.rackspace.compute.createClient({ username: 'your-username', - apiKey: 'your-api-key' + apiKey: 'your-api-key', + region: 'DFW' }); // first we're going to get our flavors @@ -69,4 +70,4 @@ function handleServerResponse(err, server) { console.log('Make sure you DELETE server: ' + server.id + ' in order to not accrue billing charges'); }); -} \ No newline at end of file +} From a5b1d219051e638967d8f354bb7b361ab876d738 Mon Sep 17 00:00:00 2001 From: Ross Johnson Date: Fri, 18 Jul 2014 11:05:22 -0500 Subject: [PATCH 100/460] Rackspace: Allow 403 for cdn uri. Resolves #298. --- .../storage/client/cdn-containers.js | 2 +- test/rackspace/storage/container-test.js | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index c64c7d09a..f8b38ef73 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -287,7 +287,7 @@ exports._getCdnContainerDetails = function(container, callback) { container: containerName, serviceType: this.cdnServiceType }, function (err, body, res) { - if (err && !(err.statusCode === 404)) { + if (err && !(err.statusCode === 403 || err.statusCode === 404)) { return callback(err); } else if (err) { diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index 3f67a8087..8b064db92 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -292,6 +292,38 @@ describe('pkgcloud/rackspace/storage/containers', function () { }); + it('getContainer should allow 403 cdn response (for ACL)', function (done) { + + if (mock) { + server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') + .reply(200, '', { 'content-length': '0', + 'x-container-object-count': '144', + 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', + 'x-timestamp': '1368837729.84945', + 'x-container-meta-foo': 'baz', + 'x-container-bytes-used': '134015617', + 'content-type': 'application/json; charset=utf-8', + 'accept-ranges': 'bytes', + 'x-trans-id': 'txb0bcacabf853476e87f846ff0e85a22f', + date: 'Thu, 13 Jun 2013 15:18:17 GMT', + connection: 'keep-alive' } + ) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') + .reply(403); + } + + client.getContainer('0.1.3-85', function (err, container) { + should.not.exist(err); + should.exist(container); + + container.should.be.instanceof(Container); + + server && server.done(); + done(); + }); + }); + it('getContainer should include cdn metadata', function (done) { if (mock) { From 31c0a1c9a5090727a20d4942f9c1fb3189b190d1 Mon Sep 17 00:00:00 2001 From: "G. Hemingway" Date: Wed, 6 Aug 2014 09:26:29 -0500 Subject: [PATCH 101/460] Allow AWS client against non-https servers I want to test my application against a "fake" local S3. It is not running HTTPS. This change allows me to specify a non-HTTPS connection by passing { protocol: 'http://' } to the client creation as an option. --- lib/pkgcloud/amazon/storage/client/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index 5c47db546..f8ceb09ba 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -50,10 +50,10 @@ Client.prototype._getUrl = function (options) { options = options || {}; if (typeof options === 'string') { - return urlJoin('https://' + this.serversUrl, options); + return urlJoin(this.protocol + this.serversUrl, options); } - return urlJoin('https://' + + return urlJoin(this.protocol + (options.container ? options.container + '.' : '') + this.serversUrl, options.path); }; From ec4bbd86f17af209f7f69ae89a667df4b18f8024 Mon Sep 17 00:00:00 2001 From: Peter deHaan Date: Wed, 13 Aug 2014 21:17:42 -0700 Subject: [PATCH 102/460] Update qs dependency See https://nodesecurity.io/advisories/qs_dos_extended_event_loop_blocking --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 00d49fd51..5f02a70da 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "mime": "1.2.x", "through": "~2.3", "pkginfo": "0.2.x", - "qs": "0.6.x", + "qs": "1.2.1", "request": "2.22.x", "underscore": "1.4.x", "url-join": "0.0.x", From 937b4bc8b7ef30128d81cd163f32b43e4028ca53 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 07:58:14 -0700 Subject: [PATCH 103/460] Adding an etag property to amazon storage object --- lib/pkgcloud/amazon/storage/file.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index d7ae0ceae..fc8e06558 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -18,9 +18,12 @@ File.prototype._setProperties = function (details) { var self = this; this.name = details.name || details.Key; + this.etag = details.ETag || details.etag || null; this.size = +(details.Size || details['content-length']) || 0; this.container = details.container; + // amazon appears to send the etag double enquoted + this.etag = this.etag ? this.etag.replace(/"/g,'') : this.etag; // AWS Specific this.storageClass = this.StorageClass; }; From ca6a34b736aa1233504d5e8277dd3c13890cd224 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 08:47:02 -0700 Subject: [PATCH 104/460] Updating request to 2.40.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f02a70da..10b8d856a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "through": "~2.3", "pkginfo": "0.2.x", "qs": "1.2.1", - "request": "2.22.x", + "request": "2.40.x", "underscore": "1.4.x", "url-join": "0.0.x", "utile": "0.x.x" From 4e9aea1386d3e82421ef2b6b309718ad9ea17c06 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 08:51:27 -0700 Subject: [PATCH 105/460] Updating underscore to 1.6.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10b8d856a..03601071b 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "pkginfo": "0.2.x", "qs": "1.2.1", "request": "2.40.x", - "underscore": "1.4.x", + "underscore": "1.6.x", "url-join": "0.0.x", "utile": "0.x.x" }, From 9222d72a83717632858a9b36f945abc6e86c3a34 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 08:52:18 -0700 Subject: [PATCH 106/460] Updating async to 0.9.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 03601071b..3cd87b7ec 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "redistogo" ], "dependencies": { - "async": "0.1.x", + "async": "0.9.x", "errs": "0.2.x", "eventemitter2": "0.4.x", "filed": "0.0.7", From b7e9981dae9534e8735aa2f7ea1beeaa189e7cb4 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 08:54:32 -0700 Subject: [PATCH 107/460] Updating errs from 0.2.x to 0.3.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3cd87b7ec..213b2bdcd 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ ], "dependencies": { "async": "0.9.x", - "errs": "0.2.x", + "errs": "0.3.x", "eventemitter2": "0.4.x", "filed": "0.0.7", "ip": "0.0.x", From 4269818eca1ab22f470efc3f78ac795a4413640e Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 08:57:05 -0700 Subject: [PATCH 108/460] Updated filed from 0.0.7 to 0.1.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 213b2bdcd..79f418e22 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "async": "0.9.x", "errs": "0.3.x", "eventemitter2": "0.4.x", - "filed": "0.0.7", + "filed": "0.1.x", "ip": "0.0.x", "xml2js": "0.1.x", "mime": "1.2.x", From 65668bb19c7a48a0fc6f7110122f49f2d165d52e Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 09:00:04 -0700 Subject: [PATCH 109/460] updating ip from 0.0.x to 0.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79f418e22..ca79d2e52 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "errs": "0.3.x", "eventemitter2": "0.4.x", "filed": "0.1.x", - "ip": "0.0.x", + "ip": "0.3.1", "xml2js": "0.1.x", "mime": "1.2.x", "through": "~2.3", From c8b39bf1c075a3d76f6bf31fdd38122c5ab779fb Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 09:06:10 -0700 Subject: [PATCH 110/460] removing pkginfo from pkgcloud --- lib/pkgcloud.js | 2 +- package.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index fc284a891..dc5aa0656 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -9,7 +9,7 @@ var path = require('path'); var pkgcloud = exports; -require('pkginfo')(module, 'version'); +pkgcloud.version = require('../package.json').version; var components = [ './pkgcloud/core/base', diff --git a/package.json b/package.json index ca79d2e52..84d501905 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "xml2js": "0.1.x", "mime": "1.2.x", "through": "~2.3", - "pkginfo": "0.2.x", "qs": "1.2.1", "request": "2.40.x", "underscore": "1.6.x", From ed6644563354a67df02f60ac4ee195b9b01f1856 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 09:45:00 -0700 Subject: [PATCH 111/460] Removing unneeded utile package --- lib/pkgcloud/amazon/client.js | 4 +- lib/pkgcloud/amazon/compute/client/groups.js | 2 +- lib/pkgcloud/amazon/compute/client/index.js | 19 ++-- lib/pkgcloud/amazon/compute/client/keys.js | 4 +- lib/pkgcloud/amazon/compute/flavor.js | 4 +- lib/pkgcloud/amazon/compute/image.js | 4 +- lib/pkgcloud/amazon/compute/server.js | 4 +- lib/pkgcloud/amazon/storage/client/files.js | 15 +-- lib/pkgcloud/amazon/storage/client/index.js | 11 ++- lib/pkgcloud/amazon/storage/container.js | 4 +- lib/pkgcloud/amazon/storage/file.js | 4 +- lib/pkgcloud/azure/client.js | 4 +- lib/pkgcloud/azure/compute/client/index.js | 17 ++-- lib/pkgcloud/azure/compute/client/keys.js | 4 +- lib/pkgcloud/azure/compute/flavor.js | 4 +- lib/pkgcloud/azure/compute/image.js | 4 +- lib/pkgcloud/azure/compute/server.js | 4 +- lib/pkgcloud/azure/database/client/index.js | 10 +- lib/pkgcloud/azure/storage/client/files.js | 9 +- lib/pkgcloud/azure/storage/client/index.js | 11 ++- lib/pkgcloud/azure/storage/container.js | 4 +- lib/pkgcloud/azure/storage/file.js | 4 +- lib/pkgcloud/common/auth.js | 4 +- lib/pkgcloud/core/base/client.js | 6 +- lib/pkgcloud/core/base/model.js | 4 +- lib/pkgcloud/core/compute/flavor.js | 4 +- lib/pkgcloud/core/compute/image.js | 4 +- lib/pkgcloud/core/compute/server.js | 4 +- lib/pkgcloud/core/dns/record.js | 4 +- lib/pkgcloud/core/dns/zone.js | 4 +- .../core/loadbalancer/loadbalancer.js | 4 +- lib/pkgcloud/core/loadbalancer/node.js | 4 +- lib/pkgcloud/core/network/network.js | 4 +- lib/pkgcloud/core/network/port.js | 4 +- lib/pkgcloud/core/network/subnet.js | 4 +- lib/pkgcloud/core/storage/container.js | 4 +- lib/pkgcloud/core/storage/file.js | 4 +- lib/pkgcloud/digitalocean/client.js | 4 +- .../digitalocean/compute/client/index.js | 15 +-- .../digitalocean/compute/client/keys.js | 2 +- lib/pkgcloud/digitalocean/compute/flavor.js | 4 +- lib/pkgcloud/digitalocean/compute/image.js | 4 +- lib/pkgcloud/digitalocean/compute/server.js | 4 +- lib/pkgcloud/hp/client.js | 4 +- lib/pkgcloud/hp/compute/client/index.js | 16 +-- lib/pkgcloud/hp/network/client/index.js | 10 +- lib/pkgcloud/hp/storage/client/index.js | 8 +- .../iriscouch/database/client/index.js | 8 +- lib/pkgcloud/joyent/client.js | 4 +- lib/pkgcloud/joyent/compute/client/index.js | 15 +-- lib/pkgcloud/joyent/compute/client/keys.js | 2 +- lib/pkgcloud/joyent/compute/flavor.js | 4 +- lib/pkgcloud/joyent/compute/image.js | 4 +- lib/pkgcloud/joyent/compute/server.js | 4 +- lib/pkgcloud/mongohq/database/client/index.js | 9 +- .../mongolab/database/client/index.js | 11 ++- lib/pkgcloud/openstack/client.js | 4 +- .../compute/client/extensions/index.js | 17 ++-- .../openstack/compute/client/index.js | 12 +-- lib/pkgcloud/openstack/compute/flavor.js | 4 +- lib/pkgcloud/openstack/compute/image.js | 4 +- lib/pkgcloud/openstack/compute/server.js | 4 +- lib/pkgcloud/openstack/context/identity.js | 4 +- .../openstack/identity/client/index.js | 4 +- .../openstack/network/client/index.js | 10 +- lib/pkgcloud/openstack/network/network.js | 4 +- lib/pkgcloud/openstack/network/port.js | 4 +- lib/pkgcloud/openstack/network/subnet.js | 4 +- .../openstack/storage/client/files.js | 6 +- .../openstack/storage/client/index.js | 8 +- lib/pkgcloud/openstack/storage/container.js | 4 +- lib/pkgcloud/openstack/storage/file.js | 4 +- .../rackspace/blockstorage/client/index.js | 13 +-- .../rackspace/blockstorage/snapshot.js | 4 +- lib/pkgcloud/rackspace/blockstorage/volume.js | 4 +- .../rackspace/blockstorage/volumetype.js | 4 +- lib/pkgcloud/rackspace/client.js | 4 +- .../rackspace/compute/client/index.js | 16 +-- lib/pkgcloud/rackspace/compute/server.js | 4 +- .../rackspace/database/client/index.js | 12 +-- lib/pkgcloud/rackspace/database/database.js | 4 +- lib/pkgcloud/rackspace/database/flavor.js | 4 +- lib/pkgcloud/rackspace/database/instance.js | 4 +- lib/pkgcloud/rackspace/database/user.js | 4 +- lib/pkgcloud/rackspace/dns/client/index.js | 8 +- lib/pkgcloud/rackspace/dns/record.js | 4 +- lib/pkgcloud/rackspace/dns/status.js | 4 +- lib/pkgcloud/rackspace/dns/zone.js | 4 +- .../rackspace/loadbalancer/client/index.js | 8 +- .../rackspace/loadbalancer/loadbalancer.js | 4 +- lib/pkgcloud/rackspace/loadbalancer/node.js | 4 +- .../rackspace/storage/client/files.js | 2 +- .../rackspace/storage/client/index.js | 14 +-- lib/pkgcloud/rackspace/storage/container.js | 4 +- lib/pkgcloud/rackspace/storage/file.js | 4 +- .../redistogo/database/client/index.js | 10 +- lib/pkgcloud/telefonica/compute/client.js | 4 +- package.json | 3 +- test/common/compute/base-test.js | 98 +++++++++---------- test/common/compute/server-test.js | 7 +- test/common/network/base-test.js | 2 +- test/common/network/network-test.js | 5 +- test/common/network/port-test.js | 2 +- test/common/network/subnet-test.js | 2 +- test/common/storage/base-test.js | 14 +-- 105 files changed, 367 insertions(+), 358 deletions(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index e39fa754c..a7f7d1d3f 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), request = require('request'), base = require('../core/base'); @@ -33,7 +33,7 @@ var Client = exports.Client = function (options) { } }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype._toArray = function toArray(obj) { if (typeof obj === 'undefined') { diff --git a/lib/pkgcloud/amazon/compute/client/groups.js b/lib/pkgcloud/amazon/compute/client/groups.js index 6c44c04f7..849e157dc 100644 --- a/lib/pkgcloud/amazon/compute/client/groups.js +++ b/lib/pkgcloud/amazon/compute/client/groups.js @@ -4,7 +4,7 @@ */ var errs = require('errs'), - utile = require('utile'); + util = require('util'); // // ### function listGroups (options, callback) diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index 9063483dc..fdb9ecd6a 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -6,33 +6,34 @@ */ var qs = require('querystring'), - utile = require('utile'), + util = require('util'), urlJoin = require('url-join'), xml2js = require('xml2js'), auth = require('../../../common/auth'), - amazon = require('../../client'); + amazon = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { amazon.Client.call(this, options); this.securityGroup = options.securityGroup; - utile.mixin(this, require('./flavors')); - utile.mixin(this, require('./images')); - utile.mixin(this, require('./servers')); - utile.mixin(this, require('./keys')); - utile.mixin(this, require('./groups')); + _.extend(this, require('./flavors')); + _.extend(this, require('./images')); + _.extend(this, require('./servers')); + _.extend(this, require('./keys')); + _.extend(this, require('./groups')); this.before.push(auth.amazon.bodySignature); }; -utile.inherits(Client, amazon.Client); +util.inherits(Client, amazon.Client); Client.prototype._query = function query(action, query, callback) { return this._request({ method: 'POST', headers: { }, - body: utile.mixin({ Action: action }, query) + body: _.extend({ Action: action }, query) }, function (err, body, res) { if (err) { return callback(err); diff --git a/lib/pkgcloud/amazon/compute/client/keys.js b/lib/pkgcloud/amazon/compute/client/keys.js index a8e9b9936..d6588f2d3 100644 --- a/lib/pkgcloud/amazon/compute/client/keys.js +++ b/lib/pkgcloud/amazon/compute/client/keys.js @@ -6,7 +6,7 @@ */ var errs = require('errs'), - utile = require('utile'); + util = require('util'); // // ### function listKeys (options, callback) @@ -69,7 +69,7 @@ exports.addKey = function (options, callback) { 'ImportKeyPair', { KeyName: options.name, - PublicKeyMaterial: utile.base64.encode(options.key) + PublicKeyMaterial: new Buffer(options.key).toString('base64') }, function (err, body, res) { return err diff --git a/lib/pkgcloud/amazon/compute/flavor.js b/lib/pkgcloud/amazon/compute/flavor.js index 894477ca9..3c0ab2e1f 100644 --- a/lib/pkgcloud/amazon/compute/flavor.js +++ b/lib/pkgcloud/amazon/compute/flavor.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/flavor'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); }; -utile.inherits(Flavor, base.Flavor); +util.inherits(Flavor, base.Flavor); Flavor.options = { 'm1.small': { ram: 1.7 * 1024, disk: 160 }, diff --git a/lib/pkgcloud/amazon/compute/image.js b/lib/pkgcloud/amazon/compute/image.js index 5648bbafc..d21297aad 100644 --- a/lib/pkgcloud/amazon/compute/image.js +++ b/lib/pkgcloud/amazon/compute/image.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/image'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); }; -utile.inherits(Image, base.Image); +util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { this.id = details.imageId; diff --git a/lib/pkgcloud/amazon/compute/server.js b/lib/pkgcloud/amazon/compute/server.js index 818a6c608..484f51b2f 100644 --- a/lib/pkgcloud/amazon/compute/server.js +++ b/lib/pkgcloud/amazon/compute/server.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/server'); var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); }; -utile.inherits(Server, base.Server); +util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { this.id = details.instanceId; diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 04c5cbc4c..79059c1a3 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -9,11 +9,12 @@ var fs = require('fs'), filed = require('filed'), mime = require('mime'), request = require('request'), - utile = require('utile'), + util = require('util'), qs = require('querystring'), base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), - storage = pkgcloud.providers.amazon.storage; + storage = pkgcloud.providers.amazon.storage, + _ = require('underscore'); const MAX_UPLOAD = 5 * 1024 * 1024 * 1024; @@ -191,9 +192,9 @@ exports.multipartUpload = function (options, callback) { stream.on('end', function () { if (fastCase) { // Upload with default method once again - var rstream = self.upload(utile.mixin({}, options, { + var rstream = self.upload(_.extend({}, options, { stream: null, - headers: utile.mixin({}, options.headers, { + headers: _.extend({}, options.headers, { 'content-length': first.length }) }), handleResponse); @@ -225,7 +226,7 @@ exports.multipartUpload = function (options, callback) { partNumber: id, uploadId: uploadId }, - headers: utile.mixin({}, options.headers, { + headers: _.extend({}, options.headers, { 'content-length': data.length }) }, function (err, body, res) { @@ -298,7 +299,7 @@ exports.download = function (options, callback) { function onDownload(err, body, res) { return err ? callback(err) - : callback(null, new (storage.File)(self, utile.mixin(res.headers, { + : callback(null, new (storage.File)(self, _.extend(res.headers, { container: container, name: options.remote }))); @@ -341,7 +342,7 @@ exports.getFile = function (container, file, callback) { function (err, body, res) { return err ? callback(err) - : callback(null, new storage.File(self, utile.mixin(res.headers, { + : callback(null, new storage.File(self, _.extend(res.headers, { container: container, name: file }))); diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index f8ceb09ba..d10acbdb1 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -5,24 +5,25 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), xml2js = require('xml2js'), auth = require('../../../common/auth'), - amazon = require('../../client'); + amazon = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { this.serversUrl = 's3.amazonaws.com'; amazon.Client.call(this, options); - utile.mixin(this, require('./containers')); - utile.mixin(this, require('./files')); + _.extend(this, require('./containers')); + _.extend(this, require('./files')); this.before.push(auth.amazon.headersSignature); }; -utile.inherits(Client, amazon.Client); +util.inherits(Client, amazon.Client); Client.prototype._xmlRequest = function query(options, callback) { diff --git a/lib/pkgcloud/amazon/storage/container.js b/lib/pkgcloud/amazon/storage/container.js index ec01c99c3..d3e584437 100644 --- a/lib/pkgcloud/amazon/storage/container.js +++ b/lib/pkgcloud/amazon/storage/container.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), storage = require('../storage'), base = require('../../core/storage/container'); @@ -13,7 +13,7 @@ var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); }; -utile.inherits(Container, base.Container); +util.inherits(Container, base.Container); Container.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index fc8e06558..b36531694 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); }; -utile.inherits(File, base.File); +util.inherits(File, base.File); File.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/azure/client.js b/lib/pkgcloud/azure/client.js index 3ab008686..e915c2d23 100644 --- a/lib/pkgcloud/azure/client.js +++ b/lib/pkgcloud/azure/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), request = require('request'), base = require('../core/base'); @@ -23,7 +23,7 @@ var Client = exports.Client = function (options) { } }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype._toArray = function toArray(obj) { if (typeof obj === 'undefined') { diff --git a/lib/pkgcloud/azure/compute/client/index.js b/lib/pkgcloud/azure/compute/client/index.js index 6253ccffe..54883a7ee 100644 --- a/lib/pkgcloud/azure/compute/client/index.js +++ b/lib/pkgcloud/azure/compute/client/index.js @@ -6,21 +6,22 @@ */ var qs = require('querystring'), - utile = require('utile'), + util = require('util'), urlJoin = require('url-join'), https = require('https'), auth = require('../../../common/auth'), azureApi = require('../../utils/azureApi.js'), xml2JSON = require('../../utils/xml2json.js').xml2JSON, - azure = require('../../client'); + azure = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { azure.Client.call(this, options); - utile.mixin(this, require('./flavors')); - utile.mixin(this, require('./images')); - utile.mixin(this, require('./servers')); - utile.mixin(this, require('./keys')); + _.extend(this, require('./flavors')); + _.extend(this, require('./images')); + _.extend(this, require('./servers')); + _.extend(this, require('./keys')); this.serversUrl = options.serversUrl || azureApi.MANAGEMENT_ENDPOINT; this.version = azureApi.MANAGEMENT_API_VERSION; @@ -47,13 +48,13 @@ var Client = exports.Client = function (options) { } }; -utile.inherits(Client, azure.Client); +util.inherits(Client, azure.Client); Client.prototype._query = function query(action, query, callback) { return this._request({ method: 'POST', headers: { }, - body: utile.mixin({ Action: action }, query) + body: _.extend({ Action: action }, query) }, function (err, body, res) { if (err) { return callback(err); } xml2JSON(body, function (err, data) { diff --git a/lib/pkgcloud/azure/compute/client/keys.js b/lib/pkgcloud/azure/compute/client/keys.js index ef2597d84..1d61125a0 100644 --- a/lib/pkgcloud/azure/compute/client/keys.js +++ b/lib/pkgcloud/azure/compute/client/keys.js @@ -6,7 +6,7 @@ */ var errs = require('errs'), - utile = require('utile'); + util = require('util'); // // ### function listKeys (options, callback) @@ -69,7 +69,7 @@ exports.addKey = function (options, callback) { 'ImportKeyPair', { KeyName: options.name, - PublicKeyMaterial: utile.base64.encode(options.key) + PublicKeyMaterial: new Buffer(options.key).toString('base64') }, function (err, body, res) { return err diff --git a/lib/pkgcloud/azure/compute/flavor.js b/lib/pkgcloud/azure/compute/flavor.js index 1b17b8b60..d2b93b5a6 100644 --- a/lib/pkgcloud/azure/compute/flavor.js +++ b/lib/pkgcloud/azure/compute/flavor.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/flavor'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); }; -utile.inherits(Flavor, base.Flavor); +util.inherits(Flavor, base.Flavor); Flavor.options = { 'ExtraSmall': { ram: 0.768 * 1024, disk: 20 }, diff --git a/lib/pkgcloud/azure/compute/image.js b/lib/pkgcloud/azure/compute/image.js index 38bb6b1f4..06a1682d7 100644 --- a/lib/pkgcloud/azure/compute/image.js +++ b/lib/pkgcloud/azure/compute/image.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/image'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); }; -utile.inherits(Image, base.Image); +util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { this.id = details.Name; diff --git a/lib/pkgcloud/azure/compute/server.js b/lib/pkgcloud/azure/compute/server.js index 3118db6c5..398f47cea 100644 --- a/lib/pkgcloud/azure/compute/server.js +++ b/lib/pkgcloud/azure/compute/server.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/server'); var Server = exports.Server = function Server(client, details) { @@ -13,7 +13,7 @@ var Server = exports.Server = function Server(client, details) { this.requestPending = false; }; -utile.inherits(Server, base.Server); +util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { var roleInstance = null; diff --git a/lib/pkgcloud/azure/database/client/index.js b/lib/pkgcloud/azure/database/client/index.js index 7a6820c82..689c7e0fa 100644 --- a/lib/pkgcloud/azure/database/client/index.js +++ b/lib/pkgcloud/azure/database/client/index.js @@ -5,13 +5,13 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), auth = require('../../../common/auth'), azureApi = require('../../utils/azureApi.js'), xml2JSON = require('../../utils/xml2json.js').xml2JSON, - azure = require('../../client'); - + azure = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { azure.Client.call(this, options); @@ -24,10 +24,10 @@ var Client = exports.Client = function (options) { this.azureKeys.storageAccessKey = this.config.storageAccessKey; this.before.push(auth.azure.tablesSignature); - utile.mixin(this, require('./databases')); + _.extend(this, require('./databases')); }; -utile.inherits(Client, azure.Client); +util.inherits(Client, azure.Client); // // Gets the version of the Azure Tables API we are running against diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index a985218b9..7ac60aa30 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -9,13 +9,14 @@ var fs = require('fs'), filed = require('filed'), mime = require('mime'), request = require('request'), - utile = require('utile'), + util = require('util'), urlJoin = require('url-join'), qs = require('querystring'), base = require('../../../core/storage'), AzureConstants = require('../../utils/constants'), pkgcloud = require('../../../../../lib/pkgcloud'), - storage = pkgcloud.providers.azure.storage; + storage = pkgcloud.providers.azure.storage, + _ = require('underscore'); // // ### function removeFile (container, file, callback) @@ -221,7 +222,7 @@ exports.download = function (options, callback) { function onDownload(err, body, res) { return err ? callback(err) - : callback(null, new (storage.File)(self, utile.mixin(res.headers, { + : callback(null, new (storage.File)(self, _.extend(res.headers, { container: container, name: options.remote }))); @@ -260,7 +261,7 @@ exports.getFile = function (container, file, callback) { }, function (err, body, res) { return err ? callback(err) - : callback(null, new storage.File(self, utile.mixin(res.headers, { + : callback(null, new storage.File(self, _.extend(res.headers, { container: container, name: file }))); diff --git a/lib/pkgcloud/azure/storage/client/index.js b/lib/pkgcloud/azure/storage/client/index.js index 1f6eac737..a4b4eb37e 100644 --- a/lib/pkgcloud/azure/storage/client/index.js +++ b/lib/pkgcloud/azure/storage/client/index.js @@ -5,20 +5,21 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), auth = require('../../../common/auth'), azureApi = require('../../utils/azureApi.js'), xml2JSON = require('../../utils/xml2json.js').xml2JSON, - azure = require('../../client'); + azure = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { this.serversUrl = options.serversUrl || azureApi.STORAGE_ENDPOINT; azure.Client.call(this, options); - utile.mixin(this, require('./containers')); - utile.mixin(this, require('./files')); + _.extend(this, require('./containers')); + _.extend(this, require('./files')); // add the auth keys for request authorization this.azureKeys = {}; @@ -28,7 +29,7 @@ var Client = exports.Client = function (options) { this.before.push(auth.azure.storageSignature); }; -utile.inherits(Client, azure.Client); +util.inherits(Client, azure.Client); Client.prototype._xmlRequest = function query(options, callback) { return this._request(options, function (err, body, res) { diff --git a/lib/pkgcloud/azure/storage/container.js b/lib/pkgcloud/azure/storage/container.js index f3c2d90bb..44be0552f 100644 --- a/lib/pkgcloud/azure/storage/container.js +++ b/lib/pkgcloud/azure/storage/container.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), storage = require('../storage'), base = require('../../core/storage/container'); @@ -13,7 +13,7 @@ var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); }; -utile.inherits(Container, base.Container); +util.inherits(Container, base.Container); Container.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/azure/storage/file.js b/lib/pkgcloud/azure/storage/file.js index cbfb3de30..c06b979ce 100644 --- a/lib/pkgcloud/azure/storage/file.js +++ b/lib/pkgcloud/azure/storage/file.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); }; -utile.inherits(File, base.File); +util.inherits(File, base.File); File.prototype._setProperties = function (details) { this.container = details.container; diff --git a/lib/pkgcloud/common/auth.js b/lib/pkgcloud/common/auth.js index 3a0b10034..6161f5397 100644 --- a/lib/pkgcloud/common/auth.js +++ b/lib/pkgcloud/common/auth.js @@ -8,7 +8,7 @@ var httpSignature = require('./http-signature'), awsSignature = require('./aws-signature'), azureSignature = require('./azure-signature'), - utile = require('utile'); + util = require('util'); var auth = exports; @@ -19,7 +19,7 @@ auth.basic = function basicAuth(req) { req.headers = req.headers || {}; req.headers.authorization = [ 'Basic', - utile.base64.encode(credentials) + new Buffer(credentials).toString('base64') ].join(' '); }; diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index 489028069..aabedd861 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -8,7 +8,7 @@ var fs = require('fs'), events = require('eventemitter2'), request = require('request'), - utile = require('utile'), + util = require('util'), qs = require('qs'), common = require('../../common'), pkgcloud = require('../../../pkgcloud'), @@ -27,7 +27,7 @@ var Client = exports.Client = function (options) { this.config = options || {}; }; -utile.inherits(Client, events.EventEmitter2); +util.inherits(Client, events.EventEmitter2); /** * Client._request @@ -105,7 +105,7 @@ Client.prototype._request = function (options, callback) { delete opts.signingUrl; // Set our User Agent - opts.headers['User-Agent'] = utile.format('nodejs-pkgcloud/%s', pkgcloud.version); + opts.headers['User-Agent'] = util.format('nodejs-pkgcloud/%s', pkgcloud.version); // If we are missing callback if (!callback) { diff --git a/lib/pkgcloud/core/base/model.js b/lib/pkgcloud/core/base/model.js index 2b1f5eed1..c882d3087 100644 --- a/lib/pkgcloud/core/base/model.js +++ b/lib/pkgcloud/core/base/model.js @@ -6,7 +6,7 @@ */ var events = require('eventemitter2'), - utile = require('utile'); + util = require('util'); var Model = exports.Model = function (client, details) { events.EventEmitter2.call(this, { delimiter: '::', wildcard: true }); @@ -17,7 +17,7 @@ var Model = exports.Model = function (client, details) { } }; -utile.inherits(Model, events.EventEmitter2); +util.inherits(Model, events.EventEmitter2); // ### function setWait (attributes, interval, callback) // diff --git a/lib/pkgcloud/core/compute/flavor.js b/lib/pkgcloud/core/compute/flavor.js index 42b33d4cf..70ab650ba 100644 --- a/lib/pkgcloud/core/compute/flavor.js +++ b/lib/pkgcloud/core/compute/flavor.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Flavor = exports.Flavor = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Flavor, model.Model); +util.inherits(Flavor, model.Model); Flavor.prototype.refresh = function (callback) { return this.client.getFlavor(this, callback); diff --git a/lib/pkgcloud/core/compute/image.js b/lib/pkgcloud/core/compute/image.js index 7fff63adb..e1992d8cf 100644 --- a/lib/pkgcloud/core/compute/image.js +++ b/lib/pkgcloud/core/compute/image.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Image = exports.Image = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Image, model.Model); +util.inherits(Image, model.Model); Image.prototype.refresh = function (callback) { return this.client.getImage(this, callback); diff --git a/lib/pkgcloud/core/compute/server.js b/lib/pkgcloud/core/compute/server.js index 64d789bac..1eac79980 100644 --- a/lib/pkgcloud/core/compute/server.js +++ b/lib/pkgcloud/core/compute/server.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'), computeStatus = require('../../common/status').compute; @@ -13,7 +13,7 @@ var Server = exports.Server = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Server, model.Model); +util.inherits(Server, model.Model); Server.prototype.refresh = function (callback) { var self = this; diff --git a/lib/pkgcloud/core/dns/record.js b/lib/pkgcloud/core/dns/record.js index c7d760f4f..fec81e9cd 100644 --- a/lib/pkgcloud/core/dns/record.js +++ b/lib/pkgcloud/core/dns/record.js @@ -7,14 +7,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Record = exports.Record = function (zone, details) { model.Model.call(this, zone.client, details); }; -utile.inherits(Record, model.Model); +util.inherits(Record, model.Model); Record.prototype.create = function(callback) { return this.zone.createRecord(this, callback); diff --git a/lib/pkgcloud/core/dns/zone.js b/lib/pkgcloud/core/dns/zone.js index 6f1bbd252..a334cf899 100644 --- a/lib/pkgcloud/core/dns/zone.js +++ b/lib/pkgcloud/core/dns/zone.js @@ -7,14 +7,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Zone = exports.Zone = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Zone, model.Model); +util.inherits(Zone, model.Model); Zone.prototype.create = function (callback) { return this.client.createZone(this, callback); diff --git a/lib/pkgcloud/core/loadbalancer/loadbalancer.js b/lib/pkgcloud/core/loadbalancer/loadbalancer.js index f2fda0017..5e4ebf45e 100644 --- a/lib/pkgcloud/core/loadbalancer/loadbalancer.js +++ b/lib/pkgcloud/core/loadbalancer/loadbalancer.js @@ -7,14 +7,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var LoadBalancer = exports.LoadBalancer = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(LoadBalancer, model.Model); +util.inherits(LoadBalancer, model.Model); LoadBalancer.prototype.create = function (callback) { return this.client.createLoadBalancer(this, callback); diff --git a/lib/pkgcloud/core/loadbalancer/node.js b/lib/pkgcloud/core/loadbalancer/node.js index c9ce602ae..606ff409a 100644 --- a/lib/pkgcloud/core/loadbalancer/node.js +++ b/lib/pkgcloud/core/loadbalancer/node.js @@ -7,11 +7,11 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Node = exports.Node = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Node, model.Model); +util.inherits(Node, model.Model); diff --git a/lib/pkgcloud/core/network/network.js b/lib/pkgcloud/core/network/network.js index 621f3560e..d51abacc6 100644 --- a/lib/pkgcloud/core/network/network.js +++ b/lib/pkgcloud/core/network/network.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Network = exports.Network = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Network, model.Model); +util.inherits(Network, model.Model); Network.prototype.create = function (callback) { this.client.createNetwork(this.name, callback); diff --git a/lib/pkgcloud/core/network/port.js b/lib/pkgcloud/core/network/port.js index 8560098d0..d918a1020 100644 --- a/lib/pkgcloud/core/network/port.js +++ b/lib/pkgcloud/core/network/port.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Port = exports.Port = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Port, model.Model); +util.inherits(Port, model.Model); Port.prototype.create = function (callback) { this.client.createPort(this.name, callback); diff --git a/lib/pkgcloud/core/network/subnet.js b/lib/pkgcloud/core/network/subnet.js index ccee30a21..34c2568b7 100644 --- a/lib/pkgcloud/core/network/subnet.js +++ b/lib/pkgcloud/core/network/subnet.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Subnet = exports.Subnet = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Subnet, model.Model); +util.inherits(Subnet, model.Model); Subnet.prototype.create = function (callback) { this.client.createSubnet(this.name, callback); diff --git a/lib/pkgcloud/core/storage/container.js b/lib/pkgcloud/core/storage/container.js index a89df056c..70e67dc0d 100644 --- a/lib/pkgcloud/core/storage/container.js +++ b/lib/pkgcloud/core/storage/container.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../base/model'); var Container = exports.Container = function (client, details) { @@ -14,7 +14,7 @@ var Container = exports.Container = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(Container, model.Model); +util.inherits(Container, model.Model); Container.prototype.create = function (callback) { this.client.createContainer(this.name, callback); diff --git a/lib/pkgcloud/core/storage/file.js b/lib/pkgcloud/core/storage/file.js index e7981d892..d2f1a945e 100644 --- a/lib/pkgcloud/core/storage/file.js +++ b/lib/pkgcloud/core/storage/file.js @@ -6,7 +6,7 @@ */ var fs = require('fs'), - utile = require('utile'), + util = require('util'), model = require('../base/model'), storage = require('../storage'); @@ -14,7 +14,7 @@ var File = exports.File = function (client, details) { model.Model.call(this, client, details); }; -utile.inherits(File, model.Model); +util.inherits(File, model.Model); File.prototype.remove = function (callback) { this.client.removeFile(this.containerName, this.name, callback); diff --git a/lib/pkgcloud/digitalocean/client.js b/lib/pkgcloud/digitalocean/client.js index c261ff5cc..e04690f1a 100644 --- a/lib/pkgcloud/digitalocean/client.js +++ b/lib/pkgcloud/digitalocean/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), fs = require('fs'), auth = require('../common/auth'), base = require('../core/base'); @@ -48,7 +48,7 @@ var Client = exports.Client = function (opts) { }); }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype.failCodes = { 400: 'Bad Request', diff --git a/lib/pkgcloud/digitalocean/compute/client/index.js b/lib/pkgcloud/digitalocean/compute/client/index.js index 9fd493816..87dfae663 100644 --- a/lib/pkgcloud/digitalocean/compute/client/index.js +++ b/lib/pkgcloud/digitalocean/compute/client/index.js @@ -5,20 +5,21 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), - digitalocean = require('../../client'); + digitalocean = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { digitalocean.Client.call(this, options); - utile.mixin(this, require('./flavors')); - utile.mixin(this, require('./images')); - utile.mixin(this, require('./servers')); - utile.mixin(this, require('./keys')); + _.extend(this, require('./flavors')); + _.extend(this, require('./images')); + _.extend(this, require('./servers')); + _.extend(this, require('./keys')); }; -utile.inherits(Client, digitalocean.Client); +util.inherits(Client, digitalocean.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/digitalocean/compute/client/keys.js b/lib/pkgcloud/digitalocean/compute/client/keys.js index 4e5cc493c..f7aa21dc8 100644 --- a/lib/pkgcloud/digitalocean/compute/client/keys.js +++ b/lib/pkgcloud/digitalocean/compute/client/keys.js @@ -6,7 +6,7 @@ */ var errs = require('errs'), - utile = require('utile'); + util = require('util'); // // ### function listKeys (callback) diff --git a/lib/pkgcloud/digitalocean/compute/flavor.js b/lib/pkgcloud/digitalocean/compute/flavor.js index f585d3976..c48f90b96 100644 --- a/lib/pkgcloud/digitalocean/compute/flavor.js +++ b/lib/pkgcloud/digitalocean/compute/flavor.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/flavor'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); }; -utile.inherits(Flavor, base.Flavor); +util.inherits(Flavor, base.Flavor); Flavor.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/digitalocean/compute/image.js b/lib/pkgcloud/digitalocean/compute/image.js index 57c7429c7..1347d4569 100644 --- a/lib/pkgcloud/digitalocean/compute/image.js +++ b/lib/pkgcloud/digitalocean/compute/image.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/image'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); }; -utile.inherits(Image, base.Image); +util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/digitalocean/compute/server.js b/lib/pkgcloud/digitalocean/compute/server.js index c7fc2c9a3..49475e23b 100644 --- a/lib/pkgcloud/digitalocean/compute/server.js +++ b/lib/pkgcloud/digitalocean/compute/server.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), compute = require('../../core/compute'), base = require('../../core/compute/server'); @@ -13,7 +13,7 @@ var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); }; -utile.inherits(Server, base.Server); +util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index cc47bbb34..74dc00f8a 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), identity = require('./identity'), base = require('../openstack/client'), _ = require('underscore'); @@ -28,7 +28,7 @@ var Client = exports.Client = function (options) { this.provider = 'hp'; }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype._getIdentityOptions = function() { return _.extend({ diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 665914453..7d2fdfb34 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -6,22 +6,22 @@ * */ -var utile = require('utile'), +var util = require('util'), hp = require('../../client'), ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, _ = require('underscore'); var Client = exports.Client = function (options) { hp.Client.call(this, options); - utile.mixin(this, require('../../../openstack/compute/client/flavors')); - utile.mixin(this, require('../../../openstack/compute/client/images')); - utile.mixin(this, require('../../../openstack/compute/client/servers')); - utile.mixin(this, require('../../../openstack/compute/client/extensions/floating-ips')); - utile.mixin(this, require('../../../openstack/compute/client/extensions/security-groups')); - utile.mixin(this, require('../../../openstack/compute/client/extensions/servers')); + _.extend(this, require('../../../openstack/compute/client/flavors')); + _.extend(this, require('../../../openstack/compute/client/images')); + _.extend(this, require('../../../openstack/compute/client/servers')); + _.extend(this, require('../../../openstack/compute/client/extensions/floating-ips')); + _.extend(this, require('../../../openstack/compute/client/extensions/security-groups')); + _.extend(this, require('../../../openstack/compute/client/extensions/servers')); this.serviceType = 'compute'; }; -utile.inherits(Client, hp.Client); +util.inherits(Client, hp.Client); _.extend(Client.prototype, ComputeClient.prototype); diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js index 79f7178ea..ae03efe7b 100644 --- a/lib/pkgcloud/hp/network/client/index.js +++ b/lib/pkgcloud/hp/network/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), hp = require('../../client'), NetworkClient = require('../../../openstack/network/networkClient').NetworkClient, @@ -20,12 +20,12 @@ var Client = exports.Client = function (options) { Port: require('../../../openstack/network/port').Port }; - utile.mixin(this, require('../../../openstack/network/client/networks')); - utile.mixin(this, require('../../../openstack/network/client/subnets')); - utile.mixin(this, require('../../../openstack/network/client/ports')); + _.extend(this, require('../../../openstack/network/client/networks')); + _.extend(this, require('../../../openstack/network/client/subnets')); + _.extend(this, require('../../../openstack/network/client/ports')); this.serviceType = 'network'; }; -utile.inherits(Client, hp.Client); +util.inherits(Client, hp.Client); _.extend(Client.prototype, NetworkClient.prototype); diff --git a/lib/pkgcloud/hp/storage/client/index.js b/lib/pkgcloud/hp/storage/client/index.js index cc5d8aaed..ef4f69dbb 100644 --- a/lib/pkgcloud/hp/storage/client/index.js +++ b/lib/pkgcloud/hp/storage/client/index.js @@ -6,7 +6,7 @@ * */ -var utile = require('utile'), +var util = require('util'), hp = require('../../client'), StorageClient = require('../../../openstack/storage/storageClient').StorageClient, _ = require('underscore'); @@ -19,11 +19,11 @@ var Client = exports.Client = function (options) { File: require('../../../openstack/storage/file').File }; - utile.mixin(this, require('../../../openstack/storage/client/containers')); - utile.mixin(this, require('../../../openstack/storage/client/files')); + _.extend(this, require('../../../openstack/storage/client/containers')); + _.extend(this, require('../../../openstack/storage/client/files')); this.serviceType = 'object-store'; }; -utile.inherits(Client, hp.Client); +util.inherits(Client, hp.Client); _.extend(Client.prototype, StorageClient.prototype); diff --git a/lib/pkgcloud/iriscouch/database/client/index.js b/lib/pkgcloud/iriscouch/database/client/index.js index be65f4707..b0c0b2dc8 100644 --- a/lib/pkgcloud/iriscouch/database/client/index.js +++ b/lib/pkgcloud/iriscouch/database/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), request = require('request'), pkgcloud = require('../../../../pkgcloud'), errs = require('errs'); @@ -71,8 +71,8 @@ Client.prototype.create = function (attrs, callback) { followRedirect: false, headers: { 'Content-Type': 'application/json', - 'Authorization': "Basic " + utile.base64.encode(this.username + ':' + this.password), - 'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version) + 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64'), + 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) } }; @@ -159,7 +159,7 @@ Client.prototype._checkCouch = function (couchName, callback) { followRedirect: false, headers: { 'Content-Type': 'application/json', - 'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version) + 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) } }, diff --git a/lib/pkgcloud/joyent/client.js b/lib/pkgcloud/joyent/client.js index fd4eeeb91..c682fd07e 100644 --- a/lib/pkgcloud/joyent/client.js +++ b/lib/pkgcloud/joyent/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), fs = require('fs'), auth = require('../common/auth'), base = require('../core/base'); @@ -88,7 +88,7 @@ var Client = exports.Client = function (opts) { }); }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype.failCodes = { 400: 'Bad Request', diff --git a/lib/pkgcloud/joyent/compute/client/index.js b/lib/pkgcloud/joyent/compute/client/index.js index 33bf1b75e..4524cd411 100644 --- a/lib/pkgcloud/joyent/compute/client/index.js +++ b/lib/pkgcloud/joyent/compute/client/index.js @@ -5,20 +5,21 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), - joyent = require('../../client'); + joyent = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { joyent.Client.call(this, options); - utile.mixin(this, require('./flavors')); - utile.mixin(this, require('./images')); - utile.mixin(this, require('./servers')); - utile.mixin(this, require('./keys')); + _.extend(this, require('./flavors')); + _.extend(this, require('./images')); + _.extend(this, require('./servers')); + _.extend(this, require('./keys')); }; -utile.inherits(Client, joyent.Client); +util.inherits(Client, joyent.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/joyent/compute/client/keys.js b/lib/pkgcloud/joyent/compute/client/keys.js index 563f4a0f2..3dbfc2bef 100644 --- a/lib/pkgcloud/joyent/compute/client/keys.js +++ b/lib/pkgcloud/joyent/compute/client/keys.js @@ -6,7 +6,7 @@ */ var errs = require('errs'), - utile = require('utile'); + util = require('util'); // // ### function listKeys (callback) diff --git a/lib/pkgcloud/joyent/compute/flavor.js b/lib/pkgcloud/joyent/compute/flavor.js index 3b5167e3a..b11157b26 100644 --- a/lib/pkgcloud/joyent/compute/flavor.js +++ b/lib/pkgcloud/joyent/compute/flavor.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/flavor'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); }; -utile.inherits(Flavor, base.Flavor); +util.inherits(Flavor, base.Flavor); Flavor.prototype._setProperties = function (details) { this.id = details.name; diff --git a/lib/pkgcloud/joyent/compute/image.js b/lib/pkgcloud/joyent/compute/image.js index 47e68e3c2..e80a4ad06 100644 --- a/lib/pkgcloud/joyent/compute/image.js +++ b/lib/pkgcloud/joyent/compute/image.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/image'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); }; -utile.inherits(Image, base.Image); +util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { this.id = details.urn; diff --git a/lib/pkgcloud/joyent/compute/server.js b/lib/pkgcloud/joyent/compute/server.js index a45cb2283..05f71237e 100644 --- a/lib/pkgcloud/joyent/compute/server.js +++ b/lib/pkgcloud/joyent/compute/server.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), compute = require('../../core/compute'), base = require('../../core/compute/server'), computeStatus = require('../../common/status').compute; @@ -14,7 +14,7 @@ var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); }; -utile.inherits(Server, base.Server); +util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/mongohq/database/client/index.js b/lib/pkgcloud/mongohq/database/client/index.js index b70d44f3c..d23f9fd84 100644 --- a/lib/pkgcloud/mongohq/database/client/index.js +++ b/lib/pkgcloud/mongohq/database/client/index.js @@ -5,13 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), base = require('../../../core/base'), auth = require('../../../common/auth'), url = require('url'), request = require('request'), - errs = require('errs'); + errs = require('errs'), + _ = require('underscore'); var Client = exports.Client = function (options) { base.Client.call(this, options); @@ -25,10 +26,10 @@ var Client = exports.Client = function (options) { this.before.push(auth.basic); - utile.mixin(this, require('./databases')); + _.extend(this, require('./databases')); }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/mongolab/database/client/index.js b/lib/pkgcloud/mongolab/database/client/index.js index a00104e76..648c70ef6 100644 --- a/lib/pkgcloud/mongolab/database/client/index.js +++ b/lib/pkgcloud/mongolab/database/client/index.js @@ -5,10 +5,11 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), base = require('../../../core/base'), - auth = require('../../../common/auth'); + auth = require('../../../common/auth'), + _ = require('underscore'); var Client = exports.Client = function (options) { base.Client.call(this, options); @@ -30,11 +31,11 @@ var Client = exports.Client = function (options) { } }); - utile.mixin(this, require('./databases')); - utile.mixin(this, require('./accounts')); + _.extend(this, require('./databases')); + _.extend(this, require('./accounts')); }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 9f2c7b5b8..99c9f55a1 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), request = require('request'), through = require('through'), base = require('../core/base'), @@ -66,7 +66,7 @@ var Client = exports.Client = function (options) { this._serviceUrl = null; }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype._getIdentityOptions = function() { var options = { diff --git a/lib/pkgcloud/openstack/compute/client/extensions/index.js b/lib/pkgcloud/openstack/compute/client/extensions/index.js index 1fb53a6f6..2ed95e588 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/index.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/index.js @@ -8,7 +8,8 @@ * (updated by Alvaro M. Reol) */ -var utile = require('utile'); +var util = require('util'), + _ = require('underscore'); var extensions = { getExtensions: function(callback) { @@ -22,12 +23,12 @@ var extensions = { } }; -utile.mixin(extensions, require('./floating-ips')); -utile.mixin(extensions, require('./keys')); -utile.mixin(extensions, require('./networks')); -utile.mixin(extensions, require('./security-groups')); -utile.mixin(extensions, require('./security-group-rules')); -utile.mixin(extensions, require('./servers')); -utile.mixin(extensions, require('./volume-attachments')); +_.extend(extensions, require('./floating-ips')); +_.extend(extensions, require('./keys')); +_.extend(extensions, require('./networks')); +_.extend(extensions, require('./security-groups')); +_.extend(extensions, require('./security-group-rules')); +_.extend(extensions, require('./servers')); +_.extend(extensions, require('./volume-attachments')); module.exports = extensions; diff --git a/lib/pkgcloud/openstack/compute/client/index.js b/lib/pkgcloud/openstack/compute/client/index.js index a47eda70f..061a23097 100644 --- a/lib/pkgcloud/openstack/compute/client/index.js +++ b/lib/pkgcloud/openstack/compute/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), openstack = require('../../client'), ComputeClient = require('../computeClient').ComputeClient, _ = require('underscore'); @@ -13,13 +13,13 @@ var utile = require('utile'), var Client = exports.Client = function (options) { openstack.Client.call(this, options); - utile.mixin(this, require('./flavors')); - utile.mixin(this, require('./images')); - utile.mixin(this, require('./servers')); - utile.mixin(this, require('./extensions')); + _.extend(this, require('./flavors')); + _.extend(this, require('./images')); + _.extend(this, require('./servers')); + _.extend(this, require('./extensions')); this.serviceType = 'compute'; }; -utile.inherits(Client, openstack.Client); +util.inherits(Client, openstack.Client); _.extend(Client.prototype, ComputeClient.prototype); diff --git a/lib/pkgcloud/openstack/compute/flavor.js b/lib/pkgcloud/openstack/compute/flavor.js index d6679d0bc..0fb8f587e 100644 --- a/lib/pkgcloud/openstack/compute/flavor.js +++ b/lib/pkgcloud/openstack/compute/flavor.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/flavor'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); }; -utile.inherits(Flavor, base.Flavor); +util.inherits(Flavor, base.Flavor); Flavor.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/openstack/compute/image.js b/lib/pkgcloud/openstack/compute/image.js index fd093ffdc..89f7dfe97 100644 --- a/lib/pkgcloud/openstack/compute/image.js +++ b/lib/pkgcloud/openstack/compute/image.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/compute/image'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); }; -utile.inherits(Image, base.Image); +util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/openstack/compute/server.js b/lib/pkgcloud/openstack/compute/server.js index 79b22fe5d..67c04602f 100644 --- a/lib/pkgcloud/openstack/compute/server.js +++ b/lib/pkgcloud/openstack/compute/server.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), compute = require('../../core/compute'), base = require('../../core/compute/server'), _ = require('underscore'); @@ -14,7 +14,7 @@ var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); }; -utile.inherits(Server, base.Server); +util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index c30728da4..810e833f6 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -13,7 +13,7 @@ var _ = require('underscore'), ServiceCatalog = require('./serviceCatalog').ServiceCatalog, svcCat = require('./serviceCatalog'), url = require('url'), - utile = require('utile'), + util = require('util'), urlJoin = require('url-join'), util = require('util'), pkgcloud = require('../../../pkgcloud'), @@ -59,7 +59,7 @@ var Identity = exports.Identity = function (options) { }); }; -utile.inherits(Identity, events.EventEmitter2); +util.inherits(Identity, events.EventEmitter2); /** * Identity.authorize diff --git a/lib/pkgcloud/openstack/identity/client/index.js b/lib/pkgcloud/openstack/identity/client/index.js index c26bd21c1..3e532382f 100644 --- a/lib/pkgcloud/openstack/identity/client/index.js +++ b/lib/pkgcloud/openstack/identity/client/index.js @@ -6,7 +6,7 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), openstack = require('../../client'), _ = require('underscore'); @@ -17,7 +17,7 @@ var Client = exports.Client = function (options) { this.serviceType = null; }; -utile.inherits(Client, openstack.Client); +util.inherits(Client, openstack.Client); /** * Client._getUrl diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index 3966831ec..b096dc5e3 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), openstack = require('../../client'), NetworkClient = require('../networkClient').NetworkClient, @@ -20,12 +20,12 @@ var Client = exports.Client = function (options) { Port: require('../port').Port }; - utile.mixin(this, require('./networks')); - utile.mixin(this, require('./subnets')); - utile.mixin(this, require('./ports')); + _.extend(this, require('./networks')); + _.extend(this, require('./subnets')); + _.extend(this, require('./ports')); this.serviceType = 'network'; }; -utile.inherits(Client, openstack.Client); +util.inherits(Client, openstack.Client); _.extend(Client.prototype, NetworkClient.prototype); diff --git a/lib/pkgcloud/openstack/network/network.js b/lib/pkgcloud/openstack/network/network.js index c4a03ae44..80a3813d7 100644 --- a/lib/pkgcloud/openstack/network/network.js +++ b/lib/pkgcloud/openstack/network/network.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/network/network'), _ = require('underscore'); @@ -13,7 +13,7 @@ var Network = exports.Network = function Network(client, details) { base.Network.call(this, client, details); }; -utile.inherits(Network, base.Network); +util.inherits(Network, base.Network); Network.prototype._setProperties = function (details) { this.name = details.name || this.name; diff --git a/lib/pkgcloud/openstack/network/port.js b/lib/pkgcloud/openstack/network/port.js index f7f99f015..1b90c44a0 100644 --- a/lib/pkgcloud/openstack/network/port.js +++ b/lib/pkgcloud/openstack/network/port.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/network/port'), _ = require('underscore'); @@ -13,7 +13,7 @@ var Port = exports.Port = function Port(client, details) { base.Port.call(this, client, details); }; -utile.inherits(Port, base.Port); +util.inherits(Port, base.Port); Port.prototype._setProperties = function (details) { diff --git a/lib/pkgcloud/openstack/network/subnet.js b/lib/pkgcloud/openstack/network/subnet.js index 8feaf1f87..708301a2d 100644 --- a/lib/pkgcloud/openstack/network/subnet.js +++ b/lib/pkgcloud/openstack/network/subnet.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/network/subnet'), _ = require('underscore'); @@ -13,7 +13,7 @@ var Subnet = exports.Subnet = function Subnet(client, details) { base.Subnet.call(this, client, details); }; -utile.inherits(Subnet, base.Subnet); +util.inherits(Subnet, base.Subnet); Subnet.prototype._setProperties = function (details) { this.name = details.name || this.name; diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 397a73661..ad51f9ff0 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -10,7 +10,7 @@ var fs = require('fs'), filed = require('filed'), mime = require('mime'), request = require('request'), - utile = require('utile'), + util = require('util'), base = require('../../../core/storage'), pkgcloud = require('../../../../pkgcloud'), _ = require('underscore'), @@ -166,7 +166,7 @@ exports.download = function (options, callback) { function onDownload(err, body, res) { return err ? callback(err) - : callback(null, new self.models.File(self, utile.mixin(res.headers, { + : callback(null, new self.models.File(self, _.extend(res.headers, { container: container, name: options.remote }))); @@ -219,7 +219,7 @@ exports.getFile = function (container, file, callback) { }, function (err, body, res) { return err ? callback(err) - : callback(null, new self.models.File(self, utile.mixin(res.headers, { + : callback(null, new self.models.File(self, _.extend(res.headers, { container: container, name: file }))); diff --git a/lib/pkgcloud/openstack/storage/client/index.js b/lib/pkgcloud/openstack/storage/client/index.js index 216e78266..967c85d65 100644 --- a/lib/pkgcloud/openstack/storage/client/index.js +++ b/lib/pkgcloud/openstack/storage/client/index.js @@ -6,7 +6,7 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), openstack = require('../../client'), StorageClient = require('../storageClient').StorageClient, @@ -20,11 +20,11 @@ var Client = exports.Client = function (options) { File: require('../file').File }; - utile.mixin(this, require('./containers')); - utile.mixin(this, require('./files')); + _.extend(this, require('./containers')); + _.extend(this, require('./files')); this.serviceType = 'object-store'; }; -utile.inherits(Client, openstack.Client); +util.inherits(Client, openstack.Client); _.extend(Client.prototype, StorageClient.prototype); diff --git a/lib/pkgcloud/openstack/storage/container.js b/lib/pkgcloud/openstack/storage/container.js index f996a9cbc..f9d5e3a9f 100644 --- a/lib/pkgcloud/openstack/storage/container.js +++ b/lib/pkgcloud/openstack/storage/container.js @@ -6,7 +6,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/storage/container'), _ = require('underscore'); @@ -14,7 +14,7 @@ var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); }; -utile.inherits(Container, base.Container); +util.inherits(Container, base.Container); Container.prototype.updateMetadata = function (callback) { this.client.updateContainerMetadata(this.container, callback); diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index 5b164cd0b..d603b69fb 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -6,14 +6,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); }; -utile.inherits(File, base.File); +util.inherits(File, base.File); File.prototype.updateMetadata = function (callback) { this.client.updateFileMetadata(this.container, this, callback); diff --git a/lib/pkgcloud/rackspace/blockstorage/client/index.js b/lib/pkgcloud/rackspace/blockstorage/client/index.js index 25cd95d90..fa5c0f455 100644 --- a/lib/pkgcloud/rackspace/blockstorage/client/index.js +++ b/lib/pkgcloud/rackspace/blockstorage/client/index.js @@ -7,21 +7,22 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), - rackspace = require('../../client'); + rackspace = require('../../client'), + _ = require('underscore'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); - utile.mixin(this, require('./volumetypes')); - utile.mixin(this, require('./snapshots')); - utile.mixin(this, require('./volumes')); + _.extend(this, require('./volumetypes')); + _.extend(this, require('./snapshots')); + _.extend(this, require('./volumes')); this.serviceType = 'volume'; }; -utile.inherits(Client, rackspace.Client); +util.inherits(Client, rackspace.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/rackspace/blockstorage/snapshot.js b/lib/pkgcloud/rackspace/blockstorage/snapshot.js index db3181cb1..f6be4f6a0 100644 --- a/lib/pkgcloud/rackspace/blockstorage/snapshot.js +++ b/lib/pkgcloud/rackspace/blockstorage/snapshot.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/base'), _ = require('underscore'); @@ -15,7 +15,7 @@ var Snapshot = exports.Snapshot = function Snapshot(client, details) { base.Model.call(this, client, details); }; -utile.inherits(Snapshot, base.Model); +util.inherits(Snapshot, base.Model); Snapshot.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/rackspace/blockstorage/volume.js b/lib/pkgcloud/rackspace/blockstorage/volume.js index bf669299d..944876dbb 100644 --- a/lib/pkgcloud/rackspace/blockstorage/volume.js +++ b/lib/pkgcloud/rackspace/blockstorage/volume.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/base'), _ = require('underscore'); @@ -15,7 +15,7 @@ var Volume = exports.Volume = function Volume(client, details) { base.Model.call(this, client, details); }; -utile.inherits(Volume, base.Model); +util.inherits(Volume, base.Model); Volume.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/rackspace/blockstorage/volumetype.js b/lib/pkgcloud/rackspace/blockstorage/volumetype.js index 0a226c329..07e71b708 100644 --- a/lib/pkgcloud/rackspace/blockstorage/volumetype.js +++ b/lib/pkgcloud/rackspace/blockstorage/volumetype.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/base'), _ = require('underscore'); @@ -15,7 +15,7 @@ var VolumeType = exports.VolumeType = function VolumeType(client, details) { base.Model.call(this, client, details); }; -utile.inherits(VolumeType, base.Model); +util.inherits(VolumeType, base.Model); VolumeType.prototype._setProperties = function (details) { this.id = details.id; diff --git a/lib/pkgcloud/rackspace/client.js b/lib/pkgcloud/rackspace/client.js index d7a07067b..d5983e844 100644 --- a/lib/pkgcloud/rackspace/client.js +++ b/lib/pkgcloud/rackspace/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), identity = require('./identity'), base = require('../openstack/client'), _ = require('underscore'); @@ -25,7 +25,7 @@ var Client = exports.Client = function (options) { this.provider = 'rackspace'; }; -utile.inherits(Client, base.Client); +util.inherits(Client, base.Client); Client.prototype._getIdentityOptions = function() { return _.extend({ diff --git a/lib/pkgcloud/rackspace/compute/client/index.js b/lib/pkgcloud/rackspace/compute/client/index.js index 04ff529d5..352c7c4b9 100644 --- a/lib/pkgcloud/rackspace/compute/client/index.js +++ b/lib/pkgcloud/rackspace/compute/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), rackspace = require('../../client'), ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, _ = require('underscore'); @@ -13,17 +13,17 @@ var utile = require('utile'), var Client = exports.Client = function (options) { rackspace.Client.call(this, options); - utile.mixin(this, require('../../../openstack/compute/client/flavors')); - utile.mixin(this, require('../../../openstack/compute/client/images')); - utile.mixin(this, require('../../../openstack/compute/client/servers')); - utile.mixin(this, require('../../../openstack/compute/client/extensions')); + _.extend(this, require('../../../openstack/compute/client/flavors')); + _.extend(this, require('../../../openstack/compute/client/images')); + _.extend(this, require('../../../openstack/compute/client/servers')); + _.extend(this, require('../../../openstack/compute/client/extensions')); // rackspace specific extensions - utile.mixin(this, require('./extensions/networksv2')); - utile.mixin(this, require('./extensions/virtual-interfacesv2')); + _.extend(this, require('./extensions/networksv2')); + _.extend(this, require('./extensions/virtual-interfacesv2')); this.serviceType = 'compute'; }; -utile.inherits(Client, rackspace.Client); +util.inherits(Client, rackspace.Client); _.extend(Client.prototype, ComputeClient.prototype); diff --git a/lib/pkgcloud/rackspace/compute/server.js b/lib/pkgcloud/rackspace/compute/server.js index cd7125cc4..e3a95ce40 100644 --- a/lib/pkgcloud/rackspace/compute/server.js +++ b/lib/pkgcloud/rackspace/compute/server.js @@ -7,11 +7,11 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../openstack/compute/server'); var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); }; -utile.inherits(Server, base.Server); +util.inherits(Server, base.Server); diff --git a/lib/pkgcloud/rackspace/database/client/index.js b/lib/pkgcloud/rackspace/database/client/index.js index a19f535c8..70a7e88a0 100644 --- a/lib/pkgcloud/rackspace/database/client/index.js +++ b/lib/pkgcloud/rackspace/database/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), request = require('request'), rackspace = require('../../client'), @@ -17,15 +17,15 @@ var Client = exports.Client = function (options) { this.before.push(auth.accountId); - utile.mixin(this, require('./flavors')); - utile.mixin(this, require('./instances')); - utile.mixin(this, require('./databases')); - utile.mixin(this, require('./users')); + _.extend(this, require('./flavors')); + _.extend(this, require('./instances')); + _.extend(this, require('./databases')); + _.extend(this, require('./users')); this.serviceType = 'rax:database'; }; -utile.inherits(Client, rackspace.Client); +util.inherits(Client, rackspace.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/rackspace/database/database.js b/lib/pkgcloud/rackspace/database/database.js index 855b6da85..77d0c290d 100644 --- a/lib/pkgcloud/rackspace/database/database.js +++ b/lib/pkgcloud/rackspace/database/database.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../../core/base/model'); var Database = exports.Database = function Database(client, details) { model.Model.call(this, client, details); }; -utile.inherits(Database, model.Model); +util.inherits(Database, model.Model); Database.prototype.refresh = function (callback) { this.client.getDatabase(this, callback); diff --git a/lib/pkgcloud/rackspace/database/flavor.js b/lib/pkgcloud/rackspace/database/flavor.js index 981f3d1e2..8f0ed858a 100644 --- a/lib/pkgcloud/rackspace/database/flavor.js +++ b/lib/pkgcloud/rackspace/database/flavor.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../openstack/compute/flavor'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); }; -utile.inherits(Flavor, base.Flavor); +util.inherits(Flavor, base.Flavor); Flavor.prototype._setProperties = function (details) { var selfLink = details.links.filter(function (link) { diff --git a/lib/pkgcloud/rackspace/database/instance.js b/lib/pkgcloud/rackspace/database/instance.js index 1d4a039fc..ebd055369 100644 --- a/lib/pkgcloud/rackspace/database/instance.js +++ b/lib/pkgcloud/rackspace/database/instance.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../../core/base/model'), computeStatus = require('../../common/status').compute; @@ -13,7 +13,7 @@ var Instance = exports.Instance = function Instance(client, details) { model.Model.call(this, client, details); }; -utile.inherits(Instance, model.Model); +util.inherits(Instance, model.Model); Instance.prototype.refresh = function (callback) { this.client.getInstance(this, callback); diff --git a/lib/pkgcloud/rackspace/database/user.js b/lib/pkgcloud/rackspace/database/user.js index 677548640..0b9e9362c 100644 --- a/lib/pkgcloud/rackspace/database/user.js +++ b/lib/pkgcloud/rackspace/database/user.js @@ -5,14 +5,14 @@ * */ -var utile = require('utile'), +var util = require('util'), model = require('../../core/base/model'); var User = exports.User = function User(client, details) { model.Model.call(this, client, details); }; -utile.inherits(User, model.Model); +util.inherits(User, model.Model); User.prototype.refresh = function (callback) { this.client.getUser(this, callback); diff --git a/lib/pkgcloud/rackspace/dns/client/index.js b/lib/pkgcloud/rackspace/dns/client/index.js index 853912973..320096848 100644 --- a/lib/pkgcloud/rackspace/dns/client/index.js +++ b/lib/pkgcloud/rackspace/dns/client/index.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), rackspace = require('../../client'), urlJoin = require('url-join'), Status = require('../status').Status, @@ -16,13 +16,13 @@ var utile = require('utile'), var Client = exports.Client = function (options) { rackspace.Client.call(this, options); - utile.mixin(this, require('./records.js')); - utile.mixin(this, require('./zones.js')); + _.extend(this, require('./records.js')); + _.extend(this, require('./zones.js')); this.serviceType = 'rax:dns'; }; -utile.inherits(Client, rackspace.Client); +util.inherits(Client, rackspace.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/rackspace/dns/record.js b/lib/pkgcloud/rackspace/dns/record.js index 8e87943b7..01f9094ee 100644 --- a/lib/pkgcloud/rackspace/dns/record.js +++ b/lib/pkgcloud/rackspace/dns/record.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/dns/record'), _ = require('underscore'); @@ -15,7 +15,7 @@ var Record = exports.Record = function Record(zone, details) { base.Record.call(this, zone, details); }; -utile.inherits(Record, base.Record); +util.inherits(Record, base.Record); Record.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/rackspace/dns/status.js b/lib/pkgcloud/rackspace/dns/status.js index 6e734cdf3..36f4263e1 100644 --- a/lib/pkgcloud/rackspace/dns/status.js +++ b/lib/pkgcloud/rackspace/dns/status.js @@ -7,14 +7,14 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/base/model'); var Status = exports.Status = function Status(client, details) { base.Model.call(this, client, details); }; -utile.inherits(Status, base.Model); +util.inherits(Status, base.Model); /** * @name Status.getDetails diff --git a/lib/pkgcloud/rackspace/dns/zone.js b/lib/pkgcloud/rackspace/dns/zone.js index d39e58172..ba2cbb28e 100644 --- a/lib/pkgcloud/rackspace/dns/zone.js +++ b/lib/pkgcloud/rackspace/dns/zone.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/dns/zone'), _ = require('underscore'); @@ -15,7 +15,7 @@ var Zone = exports.Zone = function Zone(client, details) { base.Zone.call(this, client, details); }; -utile.inherits(Zone, base.Zone); +util.inherits(Zone, base.Zone); Zone.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/index.js b/lib/pkgcloud/rackspace/loadbalancer/client/index.js index 41e2caf41..e8d955378 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/index.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/index.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), rackspace = require('../../client'), urlJoin = require('url-join'), _ = require('underscore'); @@ -15,13 +15,13 @@ var utile = require('utile'), var Client = exports.Client = function (options) { rackspace.Client.call(this, options); - utile.mixin(this, require('./nodes.js')); - utile.mixin(this, require('./loadbalancers.js')); + _.extend(this, require('./nodes.js')); + _.extend(this, require('./loadbalancers.js')); this.serviceType = 'rax:load-balancer'; }; -utile.inherits(Client, rackspace.Client); +util.inherits(Client, rackspace.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js b/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js index 59e6d99c7..4b370d367 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js +++ b/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/loadbalancer/loadbalancer'), _ = require('underscore'); @@ -15,7 +15,7 @@ var LoadBalancer = exports.LoadBalancer = function LoadBalancer(client, details) base.LoadBalancer.call(this, client, details); }; -utile.inherits(LoadBalancer, base.LoadBalancer); +util.inherits(LoadBalancer, base.LoadBalancer); LoadBalancer.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/rackspace/loadbalancer/node.js b/lib/pkgcloud/rackspace/loadbalancer/node.js index 27e4976e7..3ee491906 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/node.js +++ b/lib/pkgcloud/rackspace/loadbalancer/node.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../core/loadbalancer/node'), _ = require('underscore'); @@ -15,7 +15,7 @@ var Node = exports.Node = function Node(client, details) { base.Node.call(this, client, details); }; -utile.inherits(Node, base.Node); +util.inherits(Node, base.Node); Node.prototype._setProperties = function (details) { var self = this; diff --git a/lib/pkgcloud/rackspace/storage/client/files.js b/lib/pkgcloud/rackspace/storage/client/files.js index 955ad0ff3..498b83dc9 100644 --- a/lib/pkgcloud/rackspace/storage/client/files.js +++ b/lib/pkgcloud/rackspace/storage/client/files.js @@ -8,7 +8,7 @@ var fs = require('fs'), request = require('request'), - utile = require('utile'), + util = require('util'), base = require('../../../core/storage'), pkgcloud = require('../../../../pkgcloud'), _ = require('underscore'); diff --git a/lib/pkgcloud/rackspace/storage/client/index.js b/lib/pkgcloud/rackspace/storage/client/index.js index 24ad889d7..8797a9818 100644 --- a/lib/pkgcloud/rackspace/storage/client/index.js +++ b/lib/pkgcloud/rackspace/storage/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), rackspace = require('../../client'), StorageClient = require('../../../openstack/storage/storageClient').StorageClient, _ = require('underscore'); @@ -18,16 +18,16 @@ var Client = exports.Client = function (options) { File: require('../file').File }; - utile.mixin(this, require('../../../openstack/storage/client/containers')); - utile.mixin(this, require('../../../openstack/storage/client/files')); - utile.mixin(this, require('./archive')); - utile.mixin(this, require('./cdn-containers')); - utile.mixin(this, require('./files')); + _.extend(this, require('../../../openstack/storage/client/containers')); + _.extend(this, require('../../../openstack/storage/client/files')); + _.extend(this, require('./archive')); + _.extend(this, require('./cdn-containers')); + _.extend(this, require('./files')); this.serviceType = 'object-store'; this.cdnServiceType = 'rax:object-cdn'; }; -utile.inherits(Client, rackspace.Client); +util.inherits(Client, rackspace.Client); _.extend(Client.prototype, StorageClient.prototype); diff --git a/lib/pkgcloud/rackspace/storage/container.js b/lib/pkgcloud/rackspace/storage/container.js index ef3986ad9..538906acd 100644 --- a/lib/pkgcloud/rackspace/storage/container.js +++ b/lib/pkgcloud/rackspace/storage/container.js @@ -6,7 +6,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../openstack/storage/container'), _ = require('underscore'); @@ -14,7 +14,7 @@ var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); }; -utile.inherits(Container, base.Container); +util.inherits(Container, base.Container); Container.prototype.refreshCdnDetails = function (callback) { var self = this; diff --git a/lib/pkgcloud/rackspace/storage/file.js b/lib/pkgcloud/rackspace/storage/file.js index 5e72adc97..ce74ef73a 100644 --- a/lib/pkgcloud/rackspace/storage/file.js +++ b/lib/pkgcloud/rackspace/storage/file.js @@ -7,7 +7,7 @@ * */ -var utile = require('utile'), +var util = require('util'), base = require('../../openstack/storage/file'), _ = require('underscore'); @@ -15,7 +15,7 @@ var File = exports.File = function File(client, details) { base.File.call(this, client, details); }; -utile.inherits(File, base.File); +util.inherits(File, base.File); File.prototype.purgeFromCdn = function (emails, callback) { this.client.purgeFileFromCdn(this.container, this, emails, callback); diff --git a/lib/pkgcloud/redistogo/database/client/index.js b/lib/pkgcloud/redistogo/database/client/index.js index 0fecca24d..5011f3f46 100644 --- a/lib/pkgcloud/redistogo/database/client/index.js +++ b/lib/pkgcloud/redistogo/database/client/index.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), request = require('request'), pkgcloud = require('../../../../pkgcloud'), errs = require('errs'); @@ -27,7 +27,7 @@ Client.prototype._getUrl = function () { Client.prototype._request = function (options, callback) { var self = this; - options.headers['User-Agent'] = utile.format('nodejs-pkgcloud/%s', pkgcloud.version); + options.headers['User-Agent'] = util.format('nodejs-pkgcloud/%s', pkgcloud.version); request(options, function (err, response, body) { if (err) { @@ -76,7 +76,7 @@ Client.prototype.create = function (attrs, callback) { method : 'POST', body : 'instance%5Bplan%5D=' + attrs.plan, headers: { - 'Authorization': "Basic " + utile.base64.encode(this.username + ':' + this.password) + 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64') } }; this._request(options, callback); @@ -102,7 +102,7 @@ Client.prototype.get = function (id, callback) { uri : this._getUrl() + path + '.json', method : 'GET', headers: { - 'Authorization': "Basic " + utile.base64.encode(this.username + ':' + this.password) + 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64') } }; this._request(options, callback); @@ -125,7 +125,7 @@ Client.prototype.remove = function (id, callback) { uri : this._getUrl() + path + '.json', method : 'DELETE', headers: { - 'Authorization': "Basic " + utile.base64.encode(this.username + ':' + this.password), + 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64'), 'Content-Length': 0 } }; diff --git a/lib/pkgcloud/telefonica/compute/client.js b/lib/pkgcloud/telefonica/compute/client.js index b157390f6..c7c84e969 100644 --- a/lib/pkgcloud/telefonica/compute/client.js +++ b/lib/pkgcloud/telefonica/compute/client.js @@ -5,7 +5,7 @@ * */ -var utile = require('utile'), +var util = require('util'), urlJoin = require('url-join'), joyent = require('../../joyent/compute'); @@ -17,7 +17,7 @@ var Client = exports.Client = function (options) { || 'api-eu-lon-1.instantservers.telefonica.com'; }; -utile.inherits(Client, joyent.Client); +util.inherits(Client, joyent.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/package.json b/package.json index 84d501905..b664b35b9 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,7 @@ "qs": "1.2.1", "request": "2.40.x", "underscore": "1.6.x", - "url-join": "0.0.x", - "utile": "0.x.x" + "url-join": "0.0.x" }, "devDependencies": { "hock" : "0.2.x", diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 4878b2077..7831fbf23 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -9,7 +9,7 @@ var fs = require('fs'), path = require('path'), should = require('should'), qs = require('qs'), - utile = require('utile'), + util = require('util'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), @@ -146,7 +146,7 @@ providers.forEach(function(provider) { }); } - client.createServer(utile.mixin({ + client.createServer(_.extend({ name: 'create-test-setWait', image: context.images[0].id, flavor: context.flavors[0].id @@ -229,7 +229,7 @@ function setupVersionMock(client, provider, servers) { .reply(200, helpers.getRackspaceAuthResponse()); servers.server - .get('/v2/', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/versions.json'); } else if (provider === 'openstack') { @@ -241,9 +241,9 @@ function setupVersionMock(client, provider, servers) { password: 'MOCK-PASSWORD' } } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') .post('/v2.0/tokens', { auth: { @@ -253,11 +253,11 @@ function setupVersionMock(client, provider, servers) { }, tenantId: '72e90ecb69c44d0296072ea39e537041' } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers.getOpenstackAuthResponse()); servers.server - .get('/v2/', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/versions.json'); } else if (provider === 'hp') { @@ -269,9 +269,9 @@ function setupVersionMock(client, provider, servers) { secretKey: 'MOCK-API-KEY' } } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { @@ -281,17 +281,17 @@ function setupVersionMock(client, provider, servers) { }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers.gethpAuthResponse()); servers.server - .get('/v2/', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/versions.json'); } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/datacenters', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, '', { 'x-api-version': '6.5.0' }); } } @@ -299,19 +299,19 @@ function setupVersionMock(client, provider, servers) { function setupFlavorMock(client, provider, servers) { if (provider === 'rackspace') { servers.server - .get('/v2/123456/flavors/detail', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/123456/flavors/detail', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/flavors.json'); } else if (provider === 'openstack') { servers.server .get('/v2/72e90ecb69c44d0296072ea39e537041/flavors/detail', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/packages', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/joyent/flavors.json'); } else if (provider === 'digitalocean') { @@ -326,7 +326,7 @@ function setupFlavorMock(client, provider, servers) { else if (provider === 'hp') { servers.server .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); } } @@ -335,32 +335,32 @@ function setupImagesMock(client, provider, servers) { if (provider === 'rackspace') { servers.server .get('/v2/123456/images/detail', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/images.json'); } else if (provider === 'openstack') { servers.server .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/datasets', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/joyent/images.json'); } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) .post('/?Action=DescribeImages', { 'Owner.0': 'self' }, - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/amazon/images.xml'); } else if (provider === 'azure') { servers.server .get('/azure-account-subscription-id/services/images', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/images.xml'); } else if (provider === 'digitalocean') { @@ -375,7 +375,7 @@ function setupImagesMock(client, provider, servers) { else if (provider === 'hp') { servers.server .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); } } @@ -414,10 +414,10 @@ function setupServerMock(client, provider, servers) { imageRef: '9922a7c7-5a42-4a56-bc6a-93f857ae2346' } }, - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(202, __dirname + '/../../fixtures/rackspace/setWaitResp1.json') .get('/v2/123456/servers/a0a5f183-b94e-4a41-a854-64cff53375bf', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/a0a5f183-b94e-4a41-a854-64cff53375bf.json'); } else if (provider === 'openstack') { @@ -429,10 +429,10 @@ function setupServerMock(client, provider, servers) { imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' } }, - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/creatingServer.json') .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated.json'); } else if (provider === 'joyent') { @@ -442,11 +442,11 @@ function setupServerMock(client, provider, servers) { 'package': 'Small 1GB', dataset: 'sdc:sdc:nodejitsu:1.0.0' }, - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/joyent/setWait.json') .get('/' + client.account + '/machines/534aa63a-104f-4d6d-a3b1-c0d341a20a53', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/joyent/setWaitResp1.json'); } else if (provider === 'amazon') { @@ -458,7 +458,7 @@ function setupServerMock(client, provider, servers) { 'MaxCount': '1', 'MinCount': '1', 'UserData': 'eyJuYW1lIjoiY3JlYXRlLXRlc3Qtc2V0V2FpdCJ9' - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/amazon/run-instances.xml') .post('/?Action=DescribeInstances', { 'Filter.1.Name': 'instance-state-code', @@ -468,12 +468,12 @@ function setupServerMock(client, provider, servers) { 'Filter.1.Value.4': '64', 'Filter.1.Value.5': '80', 'InstanceId.1': 'i-1d48637b' - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/amazon/pending-server.xml') .post('/?Action=DescribeInstanceAttribute', { 'Attribute': 'userData', 'InstanceId': 'i-1d48637b' - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server-attr.xml') .post('/?Action=DescribeInstances', { 'Filter.1.Name': 'instance-state-code', @@ -483,50 +483,50 @@ function setupServerMock(client, provider, servers) { 'Filter.1.Value.4': '64', 'Filter.1.Value.5': '80', 'InstanceId.1': 'i-1d48637b' - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml') .post('/?Action=DescribeInstanceAttribute', { 'Attribute': 'userData', 'InstanceId': 'i-1d48637b' - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server-attr.xml'); } else if (provider === 'azure') { servers.server .get('/azure-account-subscription-id/services/hostedservices/create-test-setWait?embed-detail=true', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(404, __dirname + '/../../fixtures/azure/hosted-service-404.xml') - .post('/azure-account-subscription-id/services/hostedservices', helpers.loadFixture('azure/create-hosted-service.xml'), {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .post('/azure-account-subscription-id/services/hostedservices', helpers.loadFixture('azure/create-hosted-service.xml'), {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(201, '', { location: 'https://management.core.windows.net/subscriptions/azure-account-subscription-id/compute/create-test-setWait', 'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5'}) .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml') - .get('/azure-account-subscription-id/services/images/CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/azure-account-subscription-id/services/images/CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/image-1.xml') - .post('/azure-account-subscription-id/services/hostedservices/create-test-setWait/deployments', helpers.loadFixture('azure/create-deployment.xml'), {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .post('/azure-account-subscription-id/services/hostedservices/create-test-setWait/deployments', helpers.loadFixture('azure/create-deployment.xml'), {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(202, '', {'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5'}) .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-inprogress.xml') .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml') // TODO: have to do this twice as setWait() does not check server status before calling server.refresh()? .get('/azure-account-subscription-id/services/hostedservices/create-test-setWait?embed-detail=true', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/running-server.xml') .get('/azure-account-subscription-id/services/hostedservices/create-test-setWait?embed-detail=true', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/running-server.xml') .filteringRequestBodyRegEx(/.*/, '*') .post('/azure-account-subscription-id/services/hostedservices/create-test-setWait/certificates', '*', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(202, '', {'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5'}) .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml'); } else if (provider === 'hp') { @@ -538,10 +538,10 @@ function setupServerMock(client, provider, servers) { imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' } }, - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(202, __dirname + '/../../fixtures/hp/creatingServer.json') .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/serverCreated.json'); } } @@ -550,17 +550,17 @@ function setupDestroyMock(client, provider, servers) { if (provider === 'rackspace') { servers.server .delete('/v2/123456/servers/a0a5f183-b94e-4a41-a854-64cff53375bf', - {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(204); } else if (provider === 'openstack') { servers.server - .delete('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .delete('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(204); } else if (provider === 'hp') { servers.server - .delete('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .delete('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(204); } else if (provider === 'digitalocean') { diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index acddd558f..5fe81bc17 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -9,11 +9,10 @@ var fs = require('fs'), path = require('path'), qs = require('qs'), should = require('should'), - utile = require('utile'), + util = require('util'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), - async = require('async'), _ = require('underscore'), providers = require('../../configs/providers.json'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, @@ -112,7 +111,7 @@ providers.forEach(function (provider) { }); } - client.createServer(utile.mixin({ + client.createServer(_.extend({ name: 'create-test-ids2', image: context.images[0].id, flavor: context.flavors[0].id @@ -619,7 +618,7 @@ function setupGetServerMock(client, provider, servers) { // "the rebootServer() method": { // topic: function () { // var self = this; -// client.createServer(utile.mixin({ +// client.createServer(_.extend({ // name : "test-reboot", // image : testContext.images[0].id, // flavor: testContext.flavors[0].id diff --git a/test/common/network/base-test.js b/test/common/network/base-test.js index 65cfecdb5..56ad8570d 100644 --- a/test/common/network/base-test.js +++ b/test/common/network/base-test.js @@ -9,7 +9,7 @@ var fs = require('fs'), path = require('path'), should = require('should'), qs = require('qs'), - utile = require('utile'), + util = require('util'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 566372779..1b345531d 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -9,11 +9,10 @@ var fs = require('fs'), path = require('path'), qs = require('qs'), should = require('should'), - utile = require('utile'), + util = require('util'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), - async = require('async'), _ = require('underscore'), providers = require('../../configs/providers.json'), Network = require('../../../lib/pkgcloud/core/network/network').Network, @@ -108,7 +107,7 @@ providers.filter(function (provider) { }); } - client.createNetwork(utile.mixin({ + client.createNetwork(_.extend({ name: 'create-test-ids2' }), function (err, network) { should.not.exist(err); diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 69b219e41..52942ae5d 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -9,7 +9,7 @@ var fs = require('fs'), path = require('path'), qs = require('qs'), should = require('should'), - utile = require('utile'), + util = require('util'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index 414055444..b89125828 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -9,7 +9,7 @@ var fs = require('fs'), path = require('path'), qs = require('qs'), should = require('should'), - utile = require('utile'), + util = require('util'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index b1ef2733c..10a204042 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -11,7 +11,7 @@ var fs = require('fs'), assert = require('../../helpers/assert'), helpers = require('../../helpers'), should = require('should'), - utile = require('utile'), + util = require('util'), async = require('async'), hock = require('hock'), urlJoin = require('url-join'), @@ -460,9 +460,9 @@ providers.filter(function (provider) { password: 'MOCK-PASSWORD' } } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') .post('/v2.0/tokens', { auth: { @@ -472,7 +472,7 @@ providers.filter(function (provider) { }, tenantId: '72e90ecb69c44d0296072ea39e537041' } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers.getOpenstackAuthResponse()); servers.server @@ -521,9 +521,9 @@ providers.filter(function (provider) { secretKey: 'MOCK-API-KEY' } } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { @@ -533,7 +533,7 @@ providers.filter(function (provider) { }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } - }, {'User-Agent': utile.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, helpers.gethpAuthResponse()); servers.server From 7a3a37241f0f9df867bd53b3bdd9b0ded2d5bec2 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 14 Aug 2014 11:43:13 -0700 Subject: [PATCH 112/460] Consistent version strings --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b664b35b9..35bd839c3 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,11 @@ "errs": "0.3.x", "eventemitter2": "0.4.x", "filed": "0.1.x", - "ip": "0.3.1", + "ip": "0.3.x", "xml2js": "0.1.x", "mime": "1.2.x", - "through": "~2.3", - "qs": "1.2.1", + "through": "2.3.x", + "qs": "1.2.x", "request": "2.40.x", "underscore": "1.6.x", "url-join": "0.0.x" From a7864da23bfdfd92c0b1e166bcbd70531953d466 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 15 Aug 2014 09:00:24 -0700 Subject: [PATCH 113/460] Updating mocha and should --- package.json | 4 ++-- test/amazon/compute/client/groups-test.js | 2 +- test/amazon/compute/client/keys-test.js | 2 +- test/azure/databases/databases-test.js | 2 +- test/common/compute/server-test.js | 2 +- test/common/compute/signature-test.js | 20 +++++++++---------- test/common/network/signature-test.js | 8 ++++---- test/common/storage/base-test.js | 4 ++-- test/hp/compute/authentication-test.js | 4 ++-- test/hp/network/authentication-test.js | 4 ++-- test/mongolab/databases/databases-test.js | 10 +++++----- test/rackspace/blockstorage/volumes-test.js | 4 ++-- test/rackspace/compute/authentication-test.js | 6 +++--- test/rackspace/compute/image-test.js | 2 +- .../databases/authentication-test.js | 2 +- test/rackspace/databases/databases-test.js | 4 ++-- test/rackspace/databases/flavor-test.js | 8 ++++---- test/rackspace/databases/instances-test.js | 18 ++++++++--------- test/rackspace/databases/users-test.js | 8 ++++---- 19 files changed, 57 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index 35bd839c3..611f6a613 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ }, "devDependencies": { "hock" : "0.2.x", - "mocha": "1.9.x", - "should": "1.2.x", + "mocha": "1.21.x", + "should": "4.0.x", "mocha-lcov-reporter": "0.0.1", "coveralls": "2.x.x" }, diff --git a/test/amazon/compute/client/groups-test.js b/test/amazon/compute/client/groups-test.js index dd51e2457..411748849 100644 --- a/test/amazon/compute/client/groups-test.js +++ b/test/amazon/compute/client/groups-test.js @@ -74,7 +74,7 @@ describe('pkgcloud/amazon/groups', function () { client.listGroups(function (err, data) { should.not.exist(err); - data.should.be.instanceOf(Array); + data.should.be.an.Array; server && server.done(); done(); }); diff --git a/test/amazon/compute/client/keys-test.js b/test/amazon/compute/client/keys-test.js index a22c5aff6..a0826294a 100644 --- a/test/amazon/compute/client/keys-test.js +++ b/test/amazon/compute/client/keys-test.js @@ -74,7 +74,7 @@ describe('pkgcloud/amazon/keys', function () { client.listKeys(function (err, data) { should.not.exist(err); - data.should.be.instanceOf(Array); + data.should.be.an.Array; server && server.done(); done(); }); diff --git a/test/azure/databases/databases-test.js b/test/azure/databases/databases-test.js index 2ceacea8f..9af9b8bc3 100644 --- a/test/azure/databases/databases-test.js +++ b/test/azure/databases/databases-test.js @@ -93,7 +93,7 @@ describe('pkgcloud/azure/databases', function () { client.list(function (err, databases) { should.not.exist(err); should.exist(databases); - databases.should.be.instanceOf(Array); + databases.should.be.an.Array; databases.should.have.length(1); server && server.done(); diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 5fe81bc17..f81177376 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -145,7 +145,7 @@ providers.forEach(function (provider) { should.not.exist(err); should.exist(servers); - servers.should.be.instanceOf(Array); + servers.should.be.an.Array; servers.forEach(function(srv) { srv.should.be.instanceOf(Server); diff --git a/test/common/compute/signature-test.js b/test/common/compute/signature-test.js index 17402c616..58570f1c9 100644 --- a/test/common/compute/signature-test.js +++ b/test/common/compute/signature-test.js @@ -17,52 +17,52 @@ providers.forEach(function (provider) { var client = helpers.createClient(provider, 'compute'); it('client.getVersion should have length 1', function () { - client.getVersion.should.be.a('function'); + client.getVersion.should.be.a.Function; client.getVersion.should.have.length(1); }); it('client.createServer should take 2 arguments', function () { - client.createServer.should.be.a('function'); + client.createServer.should.be.a.Function; client.createServer.should.have.length(2); }); it('client.getServers should take at least 1 argument', function () { - client.getServers.should.be.a('function'); + client.getServers.should.be.a.Function; should.ok(client.getServers.length >= 1); }); it('client.getServer should take 2 arguments', function () { - client.getServer.should.be.a('function'); + client.getServer.should.be.a.Function; client.getServer.should.have.length(2); }); it('client.rebootServer should have minimum 2 arguments', function () { - client.rebootServer.should.be.a('function'); + client.rebootServer.should.be.a.Function; should.ok(client.rebootServer.length >= 2); }); it('client.destroyServer should take at least 2 arguments', function () { - client.destroyServer.should.be.a('function'); + client.destroyServer.should.be.a.Function; should.ok(client.destroyServer.length >= 2); }); it('client.getFlavor should take 2 arguments', function () { - client.getFlavor.should.be.a('function'); + client.getFlavor.should.be.a.Function; client.getFlavor.should.have.length(2); }); it('client.getFlavors should take 1 argument', function () { - client.getFlavors.should.be.a('function'); + client.getFlavors.should.be.a.Function; client.getFlavors.should.have.length(1); }); it('client.getImage should take 2 arguments', function () { - client.getImage.should.be.a('function'); + client.getImage.should.be.a.Function; client.getImage.should.have.length(2); }); it('client.getImages should have minimum 1 argument', function () { - client.getImages.should.be.a('function'); + client.getImages.should.be.a.Function; should.ok(client.getImages.length >= 1); }); }); diff --git a/test/common/network/signature-test.js b/test/common/network/signature-test.js index e21aed166..546ee88f9 100644 --- a/test/common/network/signature-test.js +++ b/test/common/network/signature-test.js @@ -19,22 +19,22 @@ providers.filter(function (provider) { var client = helpers.createClient(provider, 'network'); it('client.getNetworks should take 2 arguments', function () { - client.getNetworks.should.be.a('function'); + client.getNetworks.should.be.a.Function; client.getNetworks.should.have.length(2); }); it('client.getNetwork should take 2 arguments', function () { - client.getNetwork.should.be.a('function'); + client.getNetwork.should.be.a.Function; client.getNetwork.should.have.length(2); }); it('client.getNetworks should take at least 1 argument', function () { - client.getNetworks.should.be.a('function'); + client.getNetworks.should.be.a.Function; should.ok(client.getNetworks.length >= 1); }); it('client.createNetwork should take 2 arguments', function () { - client.createNetwork.should.be.a('function'); + client.createNetwork.should.be.a.Function; client.createNetwork.should.have.length(2); }); diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 10a204042..c0260844e 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -100,7 +100,7 @@ providers.filter(function (provider) { client.getContainers(function (err, containers) { should.not.exist(err); should.exist(containers); - containers.should.be.instanceOf(Array); + containers.should.be.an.Array; containers.forEach(function(container) { container.should.be.instanceOf(Container); @@ -268,7 +268,7 @@ providers.filter(function (provider) { should.not.exist(err); should.exist(files); - files.should.be.instanceOf(Array); + files.should.be.an.Array; files.forEach(function(file) { file.should.be.instanceOf(File); diff --git a/test/hp/compute/authentication-test.js b/test/hp/compute/authentication-test.js index 6a789627c..b556eba01 100644 --- a/test/hp/compute/authentication-test.js +++ b/test/hp/compute/authentication-test.js @@ -77,7 +77,7 @@ describe('pkgcloud/hp/compute/authentication', function () { }); it('should update the config with appropriate urls', function () { - client._identity.should.be.a('object'); + client._identity.should.be.a.Object; }); }); @@ -166,7 +166,7 @@ describe('pkgcloud/hp/compute/authentication', function () { }); it('should update the config with appropriate urls', function () { - client._identity.should.be.a('object'); + client._identity.should.be.a.Object; client._identity.token.expires.toString().should.equal(tokenExpiry); }); diff --git a/test/hp/network/authentication-test.js b/test/hp/network/authentication-test.js index 2e4fc4dcd..c49fa21da 100644 --- a/test/hp/network/authentication-test.js +++ b/test/hp/network/authentication-test.js @@ -77,7 +77,7 @@ describe('pkgcloud/hp/network/authentication', function () { }); it('should update the config with appropriate urls', function () { - client._identity.should.be.a('object'); + client._identity.should.be.a.Object; }); }); @@ -166,7 +166,7 @@ describe('pkgcloud/hp/network/authentication', function () { }); it('should update the config with appropriate urls', function () { - client._identity.should.be.a('object'); + client._identity.should.be.a.Object; client._identity.token.expires.toString().should.equal(tokenExpiry); }); diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js index 21e62ad83..62ea19566 100644 --- a/test/mongolab/databases/databases-test.js +++ b/test/mongolab/databases/databases-test.js @@ -162,7 +162,7 @@ describe('pkgcloud/mongolab/databases', function () { client.getAccounts(function(err, accounts) { should.not.exist(err); should.exist(accounts); - accounts.should.be.instanceOf(Array); + accounts.should.be.an.Array; accounts.should.have.length(2); accounts.forEach(function(account) { should.exist(account.username); @@ -264,9 +264,9 @@ describe('pkgcloud/mongolab/databases', function () { client.getDatabases(context.account.username, function (err, databases) { should.not.exist(err); should.exist(databases); - databases.should.be.instanceOf(Array); + databases.should.be.an.Array; databases.should.have.length(1); - databases[0].should.be.a('object'); + databases[0].should.be.a.Object; databases[0].name.should.equal(context.account.username + '_testDatabase'); context.databaseName = databases[0].name; @@ -300,7 +300,7 @@ describe('pkgcloud/mongolab/databases', function () { function (err, database) { should.not.exist(err); should.exist(database); - database.should.be.a('object'); + database.should.be.a.Object; database.name.should.equal(context.account.username + '_testDatabase'); server && server.done(); @@ -367,7 +367,7 @@ describe('pkgcloud/mongolab/databases', function () { client.getDatabases(context.account.username, function (err, databases) { should.not.exist(err); should.exist(databases); - databases.should.be.instanceOf(Array); + databases.should.be.an.Array; databases.should.have.length(0); server && server.done(); diff --git a/test/rackspace/blockstorage/volumes-test.js b/test/rackspace/blockstorage/volumes-test.js index 5dba17ebf..6d2e6098d 100644 --- a/test/rackspace/blockstorage/volumes-test.js +++ b/test/rackspace/blockstorage/volumes-test.js @@ -71,7 +71,7 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { client.getVolumes(function (err, volumes) { should.not.exist(err); should.exist(volumes); - volumes.should.be.instanceOf(Array); + volumes.should.be.an.Array; volumes.length.should.equal(0); authServer && authServer.done(); server && server.done(); @@ -119,7 +119,7 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { client.getVolumes(function (err, volumes) { should.not.exist(err); should.exist(volumes); - volumes.should.be.instanceOf(Array); + volumes.should.be.an.Array; volumes.forEach(function(volume) { volume.should.be.instanceOf(Volume); }); diff --git a/test/rackspace/compute/authentication-test.js b/test/rackspace/compute/authentication-test.js index 4baf5bd0b..6fdda22ab 100644 --- a/test/rackspace/compute/authentication-test.js +++ b/test/rackspace/compute/authentication-test.js @@ -108,7 +108,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { }); it('should update the config with appropriate urls', function () { - client._identity.should.be.a('object'); + client._identity.should.be.a.Object; }); it('the getLimits() method should return the proper limits', function (done) { @@ -123,7 +123,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { should.exist(limits); should.exist(limits.absolute); should.exist(limits.rate); - limits.rate.should.be.instanceOf(Array); + limits.rate.should.be.an.Array; server && server.done(); done(); }); @@ -214,7 +214,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { }); it('should update the config with appropriate urls', function () { - client._identity.should.be.a('object'); + client._identity.should.be.a.Object; client._identity.token.expires.toString().should.equal(tokenExpiry); }); diff --git a/test/rackspace/compute/image-test.js b/test/rackspace/compute/image-test.js index 01278cd8f..a17dcf9f2 100644 --- a/test/rackspace/compute/image-test.js +++ b/test/rackspace/compute/image-test.js @@ -69,7 +69,7 @@ describe('pkgcloud/rackspace/compute/images', function () { client.getServers(function(err, servers) { should.not.exist(err); should.exist(servers); - servers.should.be.instanceOf(Array); + servers.should.be.an.Array; testContext.servers = servers; authServer && authServer.done(); server && server.done(); diff --git a/test/rackspace/databases/authentication-test.js b/test/rackspace/databases/authentication-test.js index 0809ba887..99d155083 100644 --- a/test/rackspace/databases/authentication-test.js +++ b/test/rackspace/databases/authentication-test.js @@ -86,7 +86,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { client.getVersion(function (err, versions) { should.not.exist(err); should.exist(versions); - versions.should.be.instanceOf(Array); + versions.should.be.an.Array; versions.should.have.length(1); server && server.done(); diff --git a/test/rackspace/databases/databases-test.js b/test/rackspace/databases/databases-test.js index 6583c238e..b4ae12793 100644 --- a/test/rackspace/databases/databases-test.js +++ b/test/rackspace/databases/databases-test.js @@ -195,7 +195,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.exist(list); should.exist(list[0]) list[0].name.should.equal('TestDatabase'); - list[0].name.should.be.a('string'); + list[0].name.should.be.a.String; server && server.done(); done(); }); @@ -288,7 +288,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { function (err, instances, offset) { should.not.exist(err); should.exist(instances); - instances.should.be.instanceOf(Array); + instances.should.be.an.Array; instances.should.have.length(1); should.not.exist(offset); server && server.done(); diff --git a/test/rackspace/databases/flavor-test.js b/test/rackspace/databases/flavor-test.js index 3e8df1e28..b6f72e781 100644 --- a/test/rackspace/databases/flavor-test.js +++ b/test/rackspace/databases/flavor-test.js @@ -74,7 +74,7 @@ describe('pkgcloud/rackspace/databases/errors', function () { getFlavors(true, function (err, flavors) { should.not.exist(err); should.exist(flavors); - flavors.should.be.instanceOf(Array); + flavors.should.be.an.Array; flavors.forEach(function (flavor) { flavor.should.be.instanceOf(Flavor); }); @@ -90,10 +90,10 @@ describe('pkgcloud/rackspace/databases/errors', function () { getFlavors(false, function (err, flavors) { should.not.exist(err); should.exist(flavors); - flavors.should.be.instanceOf(Array); + flavors.should.be.an.Array; flavors.forEach(function (flavor) { - flavor.ram.should.be.a('number'); - flavor.href.should.be.a('string'); + flavor.ram.should.be.a.Number; + flavor.href.should.be.a.String; }); server && server.done(); done(); diff --git a/test/rackspace/databases/instances-test.js b/test/rackspace/databases/instances-test.js index 456756768..60bb19b68 100644 --- a/test/rackspace/databases/instances-test.js +++ b/test/rackspace/databases/instances-test.js @@ -141,7 +141,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('should return the list of instances', function () { should.not.exist(err); should.exist(instances); - instances.should.be.instanceOf(Array); + instances.should.be.an.Array; instances.length.should.be.above(0); testContext.instancesQuantity = instances.length; @@ -157,10 +157,10 @@ describe('pkgcloud/rackspace/databases/instances', function () { instances.forEach(function (instance) { should.exist(instance.id); - instance.links.should.be.instanceOf(Array); - instance.flavor.should.be.a('object'); - instance.volume.should.be.a('object'); - instance.volume.size.should.be.a('number'); + instance.links.should.be.an.Array; + instance.flavor.should.be.a.Object; + instance.volume.should.be.a.Object; + instance.volume.size.should.be.a.Number; }); }); @@ -205,7 +205,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('should respond at least 2 elements', function() { should.not.exist(err); should.exist(instances); - instances.should.be.instanceOf(Array); + instances.should.be.an.Array; instances.should.have.length(2); }); @@ -272,7 +272,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { client.getInstances({ offset: testContext.marker }, function (err, instances, offset) { should.not.exist(err); should.exist(instances); - instances.should.be.instanceOf(Array); + instances.should.be.an.Array; should.ok(instances.length >= 2 && instances.length < testContext.instancesQuantity); server && server.done(); @@ -292,7 +292,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { client.getInstances({limit: 1, offset: testContext.marker }, function (err, instances, offset) { should.not.exist(err); should.exist(instances); - instances.should.be.instanceOf(Array); + instances.should.be.an.Array; should.exist(offset); instances.should.have.length(1); server && server.done(); @@ -528,7 +528,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { }); function assertLinks(links) { - links.should.be.instanceOf(Array); + links.should.be.an.Array; links.forEach(function (link) { should.exist(link.href); should.exist(link.rel); diff --git a/test/rackspace/databases/users-test.js b/test/rackspace/databases/users-test.js index 35defc579..ff06ea6aa 100644 --- a/test/rackspace/databases/users-test.js +++ b/test/rackspace/databases/users-test.js @@ -229,7 +229,7 @@ describe('pkgcloud/rackspace/databases/users', function () { client.getUsers({ instance: instance }, function (err, list) { should.not.exist(err); should.exist(list); - list.should.be.instanceOf(Array); + list.should.be.an.Array; list.forEach(function (user) { user.should.be.instanceOf(User); }); @@ -294,7 +294,7 @@ describe('pkgcloud/rackspace/databases/users', function () { client.getUsers({ instance: instance, offset: testContext.marker }, function (err, list, offset) { should.not.exist(err); should.exist(list); - list.should.be.instanceOf(Array); + list.should.be.an.Array; list.should.have.length(2); should.not.exist(offset); server && server.done(); @@ -320,7 +320,7 @@ describe('pkgcloud/rackspace/databases/users', function () { offset:testContext.marker }, function(err, list, offset) { should.not.exist(err); should.exist(list); - list.should.be.instanceOf(Array); + list.should.be.an.Array; list.should.have.length(1); should.exist(offset); server && server.done(); @@ -396,7 +396,7 @@ describe('pkgcloud/rackspace/databases/users', function () { should.exist(response); response.statusCode.should.equal(200); should.exist(response.body); - response.body.user.should.be.a('object'); + response.body.user.should.be.a.Object; should.exist(response.body.user.password); response.body.user.name.should.equal('root'); server && server.done(); From 3a7074cce1801d07dd560c590c7faba0396d830e Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 28 Aug 2014 09:12:34 -0700 Subject: [PATCH 114/460] Cleaning up artifacts from merging an old PR --- lib/pkgcloud/openstack/compute/client/images.js | 17 ++++++++--------- test/common/compute/meta-test.js | 2 -- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/pkgcloud/openstack/compute/client/images.js b/lib/pkgcloud/openstack/compute/client/images.js index 4d226495b..4492fd1fb 100644 --- a/lib/pkgcloud/openstack/compute/client/images.js +++ b/lib/pkgcloud/openstack/compute/client/images.js @@ -150,25 +150,24 @@ exports.destroyImage = function destroyImage(image, callback) { * @description updates image metadata * * @param {String|object} image the image or imageId to get - * @param meta {JSON object} + * @param {object} metadata the metadata object to store * @param callback * @returns {*} */ -exports.updateImageMeta = function updateImageMeta(image,meta, callback) { - var imageId = image instanceof compute.Image ? image.id : image; - - var specs= { - "metadata" : meta - }; +exports.updateImageMeta = function updateImageMeta(image, metadata, callback) { + var imageId = image instanceof compute.Image ? image.id : image, + specs = { + metadata : metadata + }; return this._request({ path: urlJoin(_urlPrefix, imageId, 'metadata' ), method: 'POST', body: specs }, - function (err, resp) { + function (err, body) { return err ? callback(err) - : callback(null, resp); + : callback(null, body); }); }; diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index 6f677a258..4cc009488 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -9,8 +9,6 @@ var fs = require('fs'), path = require('path'), qs = require('qs'), should = require('should'), - utile = require('utile'), - async = require('async'), helpers = require('../../helpers'), hock = require('hock'), async = require('async'), From bc2b08c4f54fc4e3034cbd1526e6be654b289439 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 28 Aug 2014 09:14:52 -0700 Subject: [PATCH 115/460] Cleaning up meta-test code after PR --- test/common/compute/meta-test.js | 63 +++++++------------------------- 1 file changed, 14 insertions(+), 49 deletions(-) diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index 4cc009488..486135aec 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -6,18 +6,17 @@ */ var fs = require('fs'), - path = require('path'), - qs = require('qs'), - should = require('should'), - helpers = require('../../helpers'), - hock = require('hock'), - async = require('async'), - _ = require('underscore'), - Image = require('../../../lib/pkgcloud/core/compute/image').Image, - mock = !!process.env.MOCK; - -providers=["openstack"]; - + path = require('path'), + qs = require('qs'), + should = require('should'), + helpers = require('../../helpers'), + hock = require('hock'), + async = require('async'), + _ = require('underscore'), + Image = require('../../../lib/pkgcloud/core/compute/image').Image, + mock = !!process.env.MOCK; + +var providers=["openstack"]; providers.forEach(function (provider) { describe('pkgcloud/common/compute/server [' + provider + ']', function () { @@ -66,7 +65,7 @@ providers.forEach(function (provider) { context.images = images - images.forEach(function(img) { + images.forEach(function(img) { img.should.be.instanceOf(Image); }); @@ -131,9 +130,8 @@ function setupMetaMock(client, provider, servers) { } } - function setupImagesMock(client, provider, servers) { - if (provider === 'openstack') { + if (provider === 'openstack') { servers.authServer .post('/v2.0/tokens', { auth: { @@ -160,38 +158,5 @@ function setupImagesMock(client, provider, servers) { servers.server .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json') - } - -} - - -/** - * serverStatusReply() - * fills in the nock xml reply from the server with server name and status - * @param name - name of the server - * @param status - status to be returned in reply - * status should be: - * ReadyRole - server is RUNNING - * VMStopped - server is still PROVISIONING - * Provisioning - server is still PROVISIONING - * see lib/pkgcloud/azure/compute/server.js for more status values - * - * @return {String} - the xml reply containing the server name and status - */ -var serverStatusReply = function (name, status) { - - var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; - - var result = _.template(template, params); - return result; -}; - -var filterPath = function (path) { - var name = PATH.basename(path); - if (path.search('embed-detail=true') !== -1) { - return '/getStatus?name=' + name; } - - return path; -}; +} From 4d319afa7c2560c81d9cff829ab6aa66cf391769 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Mon, 28 Jul 2014 16:12:14 -0500 Subject: [PATCH 116/460] added in {name: db} object model to RS db users.js. Added in separate functionality for database for backwards compatibility --- .../rackspace/database/client/users.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/rackspace/database/client/users.js b/lib/pkgcloud/rackspace/database/client/users.js index c292f58e8..21a7e8e53 100644 --- a/lib/pkgcloud/rackspace/database/client/users.js +++ b/lib/pkgcloud/rackspace/database/client/users.js @@ -51,7 +51,8 @@ exports.createUser = function createUser(options, callback) { // Check for required options. ['username', 'password', 'database', 'instance'].forEach(function (required) { - if (!opts[required]) { + // API allows for individual or multiple databases + if (!opts[required] && ( require == 'database' && !opt['databases'])) { if (calledBack) { return; } errs.handle(errs.create({ message: 'Options. ' + required + ' is a required argument' @@ -88,19 +89,27 @@ exports.createUser = function createUser(options, callback) { opts['databases'].length > 0) { opts['databases'].forEach(function (item, idx) { if (typeof item === 'string') { - databases.push(item); + databases.push({'name' : item}); } else if (item instanceof Database) { - databases.push(item.name); + databases.push({'name' : item.name}); } }); } + if (opts && opts['database'] && typeof opts['database'] === 'string') { + databases.push({ 'name' : opts['database']}); + } + + if (opts && opts['database'] && opts['database'] instanceof Database) { + databases.push({ 'name' : opts['database'].name}); + } + if (opts && opts['databases'] && typeof opts['databases'] === 'string') { - databases.push(opts['databases']); + databases.push({ 'name' : opts['databases']}); } if (opts && opts['databases'] && opts['databases'] instanceof Database) { - databases.push(opts['databases'].name); + databases.push({ 'name' : opts['databases'].name}); } // Check for invalid characters and permitted length of database databases.forEach(function (db) { From 810cebfdfa21e3c81326d17fc4d47c7c9a9cbb63 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 28 Aug 2014 12:26:18 -0700 Subject: [PATCH 117/460] Cleaning up tests for databases/createUser --- .../rackspace/database/client/users.js | 2 +- test/rackspace/databases/users-test.js | 55 +++++++++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/rackspace/database/client/users.js b/lib/pkgcloud/rackspace/database/client/users.js index 21a7e8e53..21c33d17f 100644 --- a/lib/pkgcloud/rackspace/database/client/users.js +++ b/lib/pkgcloud/rackspace/database/client/users.js @@ -52,7 +52,7 @@ exports.createUser = function createUser(options, callback) { // Check for required options. ['username', 'password', 'database', 'instance'].forEach(function (required) { // API allows for individual or multiple databases - if (!opts[required] && ( require == 'database' && !opt['databases'])) { + if (!opts[required] && ( required === 'database' && !opts['databases'])) { if (calledBack) { return; } errs.handle(errs.create({ message: 'Options. ' + required + ' is a required argument' diff --git a/test/rackspace/databases/users-test.js b/test/rackspace/databases/users-test.js index ff06ea6aa..9493655f2 100644 --- a/test/rackspace/databases/users-test.js +++ b/test/rackspace/databases/users-test.js @@ -69,7 +69,7 @@ describe('pkgcloud/rackspace/databases/users', function () { { name: 'joeTest', password: 'joepasswd', - databases: [] + databases: [ { name: 'TestDatabase' } ] } ] }) @@ -94,6 +94,43 @@ describe('pkgcloud/rackspace/databases/users', function () { }); + it('the createUser() method should work with databases argument', function (done) { + if (mock) { + server + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTest', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + + helpers.selectInstance(client, function (instance) { + client.createUser({ + username: 'joeTest', + password: 'joepasswd', + databases: ['TestDatabase'], + instance: instance + }, function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + authServer && authServer.done(); + server && server.done(); + done(); + }); + }); + + }); + it('create an other user for test pagination should response correctly', function (done) { if (mock) { @@ -105,7 +142,9 @@ describe('pkgcloud/rackspace/databases/users', function () { { name: 'joeTestTwo', password: 'joepasswd', - databases: [] + databases: [ + { name: 'TestDatabase' } + ] } ] }) @@ -115,7 +154,9 @@ describe('pkgcloud/rackspace/databases/users', function () { { name: 'joeTestThree', password: 'joepasswd', - databases: [] + databases: [ + { name: 'TestDatabase' } + ] } ] }) @@ -156,12 +197,16 @@ describe('pkgcloud/rackspace/databases/users', function () { { name: 'joeTestFour', password: 'joepasswd', - databases: [] + databases: [ + { name: 'TestDatabase' } + ] }, { name: 'joeTestFive', password: 'joepasswd', - databases: [] + databases: [ + { name: 'TestDatabase' } + ] } ] }) From 32b9552c8db929db5ad3c9c374ade4a10233b3b8 Mon Sep 17 00:00:00 2001 From: Manuel Mazzuola Date: Fri, 29 Aug 2014 16:28:13 +0200 Subject: [PATCH 118/460] [rackspace] first commit of adding static website' index page to storage provider' containers --- .../storage/client/cdn-containers.js | 44 +++++++++++++++++++ lib/pkgcloud/rackspace/storage/container.js | 7 ++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index f8b38ef73..2f9b85c31 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -149,6 +149,7 @@ exports.getCdnContainers = function (options, callback) { // when requesting single cdn containers // container.cdnEnabled = container.cdn_enabled == 'true'; + container.staticWebsiteIndexPage = container.static_website_index_page; container.logRetention = container.log_retention == 'true'; container.cdnUri = container.cdn_uri; container.cdnSslUri = container.cdn_ssl_uri; @@ -307,6 +308,7 @@ exports._getCdnContainerDetails = function(container, callback) { container.cdniOSUri = res.headers['x-cdn-ios-uri']; container.ttl = parseInt(res.headers['x-ttl'], 10); container.logRetention = res.headers['x-log-retention'] == 'True'; + container.staticWebsiteIndexPage = res.headers['x-container-meta-web-index']; container.metadata = self.deserializeMetadata(self.CONTAINER_META_PREFIX, res.headers); @@ -314,6 +316,48 @@ exports._getCdnContainerDetails = function(container, callback) { }); }; +/** + * client.setStaticWebsiteIndexPage + * + * @description set the stitc website index page on a storage container + * + * @param {String|object} container the container or containerName + * @param {object} options an object with options + * @param {String} options.indexFile configure the static website index file for this container + * @param callback + */ +exports.setStaticWebsiteIndexPage = function (container, options, callback) { + var self = this, + containerName = container instanceof self.models.Container ? container.name : container, + indexFile = options.indexFile; + + if (typeof options === 'function') { + callback = options; + indexFile = 'index.html'; + } + + var staticWebsiteOpts = { + method: 'POST', + container: containerName, + serviceType: this.cdnServiceType, + headers: { + 'x-container-meta-web-index': indexFile + } + }; + + self._request(staticWebsiteOpts, function(err) { + if (err) { + return callback(err); + } + + self.getContainer(containerName, function(err, container) { + return err + ? callback(err) + : callback(err, container); + }); + }); +}; + /** * client.setTemporaryUrlKey * diff --git a/lib/pkgcloud/rackspace/storage/container.js b/lib/pkgcloud/rackspace/storage/container.js index 538906acd..c4feb8108 100644 --- a/lib/pkgcloud/rackspace/storage/container.js +++ b/lib/pkgcloud/rackspace/storage/container.js @@ -42,18 +42,23 @@ Container.prototype.updateCdn = function (options, callback) { this.client.updateCdnContainer(this, options, callback); }; +Container.prototype.setStaticWebsiteIndexPage = function (options, callback) { + this.client.setStaticWebsiteIndexPage(this, options, callback); +}; + Container.prototype._setProperties = function (details) { this.cdnEnabled = details.cdnEnabled || this.cdnEnabled || false; this.cdnUri = details.cdnUri || this.cdnUri; this.cdnSslUri = details.cdnSslUri || this.cdnSslUri; this.cdnStreamingUri = details.cdnStreamingUri || this.cdnStreamingUri; this.cdniOSUri = details.cdniOSUri || this.cdniOSUri; + this.staticWebsiteIndexPage = details.staticWebsiteIndexPage || this.staticWebsiteIndexPage || ''; Container.super_.prototype._setProperties.call(this, details); }; Container.prototype.toJSON = function () { return _.pick(this, ['name', 'ttl', 'logRetention', 'count', 'bytes', 'cdnEnabled', 'cdnUri', 'cdnSslUri', 'cdnStreamingUri', - 'cdniOSUri', 'metadata']); + 'cdniOSUri', 'staticWebsiteIndexPage', 'metadata']); }; From 9cc2a5935fedd6bfad1d1787297f3824c8ab7994 Mon Sep 17 00:00:00 2001 From: Manuel Mazzuola Date: Fri, 29 Aug 2014 16:29:39 +0200 Subject: [PATCH 119/460] [rackspace] added a static website test --- test/rackspace/storage/container-test.js | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index 8b064db92..07144d875 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -442,6 +442,74 @@ describe('pkgcloud/rackspace/storage/containers', function () { }); }); + it('getContainer and set static website index page ', function (done) { + + if (mock) { + server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') + .reply(200, '', { 'content-length': '0', + 'x-container-object-count': '144', + 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', + 'x-timestamp': '1368837729.84945', + 'x-container-meta-foo': 'baz', + 'x-container-bytes-used': '134015617', + 'content-type': 'application/json; charset=utf-8', + 'accept-ranges': 'bytes', + 'x-trans-id': 'txb0bcacabf853476e87f846ff0e85a22f', + date: 'Thu, 13 Jun 2013 15:18:17 GMT', + connection: 'keep-alive' } + ) + .post('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85', null, null) + .reply(202) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') + .reply(404) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') + .reply(200, '', { 'content-length': '0', + 'x-container-object-count': '144', + 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', + 'x-timestamp': '1368837729.84945', + 'x-container-meta-foo': 'baz', + 'x-container-bytes-used': '134015617', + 'content-type': 'application/json; charset=utf-8', + 'accept-ranges': 'bytes', + 'x-trans-id': 'txb0bcacabf853476e87f846ff0e85a22f', + date: 'Thu, 13 Jun 2013 15:18:17 GMT', + connection: 'keep-alive' } + ) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') + .reply(200, '', { + 'x-cdn-ssl-uri': 'https://c98c1215ec09a78cd287-edfcb31ae70ea7c07367728d50539bc7.ssl.cf1.rackcdn.com', + 'x-ttl': '186400', + 'x-container-meta-web-index': 'index.htm', + 'x-log-retention': 'True', + 'content-type': 'text/html; charset=UTF-8', + 'x-cdn-streaming-uri': 'http://e5addf7be8783adf8c6d-edfcb31ae70ea7c07367728d50539bc7.r63.stream.cf1.rackcdn.com', + 'content-length': '0', + 'x-trans-id': 'tx8a8acb8f3f7142c8bd36f27a18415996', + date: 'Wed, 12 Jun 2013 19:04:25'}); + } + + client.getContainer('0.1.3-85', function (err, container) { + should.not.exist(err); + should.exist(container); + + container.should.be.instanceof(Container); + + container.staticWebsiteIndexPage.should.equal(''); + + container.setStaticWebsiteIndexPage('index.htm', function (err, container) { + should.not.exist(err); + should.exist(container); + container.should.be.instanceof(Container); + + container.staticWebsiteIndexPage.should.equal('index.htm'); + + server && server.done(); + done(); + }); + }); + }); + it('updateContainerMetadata should throw if passed non container', function() { (function() { client.updateContainerMetadata({ name: 'foo' }) From b84da8090a33e799f418823fed652d45372dd987 Mon Sep 17 00:00:00 2001 From: Manuel Mazzuola Date: Fri, 29 Aug 2014 16:31:44 +0200 Subject: [PATCH 120/460] Fixed misspelled word --- lib/pkgcloud/rackspace/storage/client/cdn-containers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 2f9b85c31..84b471111 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -319,7 +319,7 @@ exports._getCdnContainerDetails = function(container, callback) { /** * client.setStaticWebsiteIndexPage * - * @description set the stitc website index page on a storage container + * @description set the static website index page on a storage container * * @param {String|object} container the container or containerName * @param {object} options an object with options From 60a3577d854948332631b68ee2ad1b6192a349cc Mon Sep 17 00:00:00 2001 From: Manuel Mazzuola Date: Fri, 29 Aug 2014 21:25:43 +0200 Subject: [PATCH 121/460] Use updateContainerMetadata and removeContainerMetadata instead own request --- .../storage/client/cdn-containers.js | 39 ++++------ lib/pkgcloud/rackspace/storage/container.js | 7 +- test/rackspace/storage/container-test.js | 73 +++++++++++++++++-- 3 files changed, 88 insertions(+), 31 deletions(-) diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 84b471111..65949bddc 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -149,7 +149,6 @@ exports.getCdnContainers = function (options, callback) { // when requesting single cdn containers // container.cdnEnabled = container.cdn_enabled == 'true'; - container.staticWebsiteIndexPage = container.static_website_index_page; container.logRetention = container.log_retention == 'true'; container.cdnUri = container.cdn_uri; container.cdnSslUri = container.cdn_ssl_uri; @@ -308,7 +307,6 @@ exports._getCdnContainerDetails = function(container, callback) { container.cdniOSUri = res.headers['x-cdn-ios-uri']; container.ttl = parseInt(res.headers['x-ttl'], 10); container.logRetention = res.headers['x-log-retention'] == 'True'; - container.staticWebsiteIndexPage = res.headers['x-container-meta-web-index']; container.metadata = self.deserializeMetadata(self.CONTAINER_META_PREFIX, res.headers); @@ -327,35 +325,30 @@ exports._getCdnContainerDetails = function(container, callback) { * @param callback */ exports.setStaticWebsiteIndexPage = function (container, options, callback) { - var self = this, - containerName = container instanceof self.models.Container ? container.name : container, - indexFile = options.indexFile; + var indexFile = options.indexFile; if (typeof options === 'function') { callback = options; indexFile = 'index.html'; } - var staticWebsiteOpts = { - method: 'POST', - container: containerName, - serviceType: this.cdnServiceType, - headers: { - 'x-container-meta-web-index': indexFile - } - }; + container.metadata['web-index'] = indexFile; - self._request(staticWebsiteOpts, function(err) { - if (err) { - return callback(err); - } + this.updateContainerMetadata(container, callback); +}; - self.getContainer(containerName, function(err, container) { - return err - ? callback(err) - : callback(err, container); - }); - }); +/** + * client.removeStaticWebsite + * + * @description remove the static website index page on a storage container + * + * @param {String|object} container the container or containerName + * @param callback + */ +exports.removeStaticWebsite = function (container, callback) { + var indexFile = container.metadata['web-index']; + + this.removeContainerMetadata(container, {'web-index': indexFile}, callback); }; /** diff --git a/lib/pkgcloud/rackspace/storage/container.js b/lib/pkgcloud/rackspace/storage/container.js index c4feb8108..53aaecde8 100644 --- a/lib/pkgcloud/rackspace/storage/container.js +++ b/lib/pkgcloud/rackspace/storage/container.js @@ -46,19 +46,22 @@ Container.prototype.setStaticWebsiteIndexPage = function (options, callback) { this.client.setStaticWebsiteIndexPage(this, options, callback); }; +Container.prototype.removeStaticWebsite = function (callback) { + this.client.removeStaticWebsite(this, callback); +}; + Container.prototype._setProperties = function (details) { this.cdnEnabled = details.cdnEnabled || this.cdnEnabled || false; this.cdnUri = details.cdnUri || this.cdnUri; this.cdnSslUri = details.cdnSslUri || this.cdnSslUri; this.cdnStreamingUri = details.cdnStreamingUri || this.cdnStreamingUri; this.cdniOSUri = details.cdniOSUri || this.cdniOSUri; - this.staticWebsiteIndexPage = details.staticWebsiteIndexPage || this.staticWebsiteIndexPage || ''; Container.super_.prototype._setProperties.call(this, details); }; Container.prototype.toJSON = function () { return _.pick(this, ['name', 'ttl', 'logRetention', 'count', 'bytes', 'cdnEnabled', 'cdnUri', 'cdnSslUri', 'cdnStreamingUri', - 'cdniOSUri', 'staticWebsiteIndexPage', 'metadata']); + 'cdniOSUri', 'metadata']); }; diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index 07144d875..f9ba9f60b 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -460,10 +460,72 @@ describe('pkgcloud/rackspace/storage/containers', function () { connection: 'keep-alive' } ) .post('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85', null, null) - .reply(202) + .reply(200, '', { 'content-length': '0', + 'x-container-object-count': '144', + 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', + 'x-container-meta-web-index': 'index.htm', + 'x-timestamp': '1368837729.84945', + 'x-container-meta-foo': 'baz', + 'x-container-bytes-used': '134015617', + 'content-type': 'application/json; charset=utf-8', + 'accept-ranges': 'bytes', + 'x-trans-id': 'txb0bcacabf853476e87f846ff0e85a22f', + date: 'Thu, 13 Jun 2013 15:18:17 GMT', + connection: 'keep-alive' } + ) .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') - .reply(404) + .reply(200, '', { + 'x-cdn-ssl-uri': 'https://c98c1215ec09a78cd287-edfcb31ae70ea7c07367728d50539bc7.ssl.cf1.rackcdn.com', + 'x-ttl': '186400', + 'x-container-meta-web-index': 'index.htm', + 'x-log-retention': 'True', + 'content-type': 'text/html; charset=UTF-8', + 'x-cdn-streaming-uri': 'http://e5addf7be8783adf8c6d-edfcb31ae70ea7c07367728d50539bc7.r63.stream.cf1.rackcdn.com', + 'content-length': '0', + 'x-trans-id': 'tx8a8acb8f3f7142c8bd36f27a18415996', + date: 'Wed, 12 Jun 2013 19:04:25'}); + } + + client.getContainer('0.1.3-85', function (err, container) { + should.not.exist(err); + should.exist(container); + + container.should.be.instanceof(Container); + + (container.metadata['web-index'] == undefined).should.be.true; + + container.setStaticWebsiteIndexPage({indexFile: 'index.htm'}, function (err, container) { + should.not.exist(err); + should.exist(container); + container.should.be.instanceof(Container); + + container.metadata['web-index'].should.equal('index.htm'); + + server && server.done(); + done(); + }); + }); + }); + + it('getContainer and remove static website', function (done) { + + if (mock) { + server .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') + .reply(200, '', { 'content-length': '0', + 'x-container-object-count': '144', + 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', + 'x-container-meta-web-index': 'index.htm', + 'x-timestamp': '1368837729.84945', + 'x-container-meta-foo': 'baz', + 'x-container-bytes-used': '134015617', + 'content-type': 'application/json; charset=utf-8', + 'accept-ranges': 'bytes', + 'x-trans-id': 'txb0bcacabf853476e87f846ff0e85a22f', + date: 'Thu, 13 Jun 2013 15:18:17 GMT', + connection: 'keep-alive' } + ) + .post('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85', null, null) .reply(200, '', { 'content-length': '0', 'x-container-object-count': '144', 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', @@ -480,7 +542,6 @@ describe('pkgcloud/rackspace/storage/containers', function () { .reply(200, '', { 'x-cdn-ssl-uri': 'https://c98c1215ec09a78cd287-edfcb31ae70ea7c07367728d50539bc7.ssl.cf1.rackcdn.com', 'x-ttl': '186400', - 'x-container-meta-web-index': 'index.htm', 'x-log-retention': 'True', 'content-type': 'text/html; charset=UTF-8', 'x-cdn-streaming-uri': 'http://e5addf7be8783adf8c6d-edfcb31ae70ea7c07367728d50539bc7.r63.stream.cf1.rackcdn.com', @@ -495,14 +556,14 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); - container.staticWebsiteIndexPage.should.equal(''); + container.metadata['web-index'].should.equal('index.htm'); - container.setStaticWebsiteIndexPage('index.htm', function (err, container) { + container.removeStaticWebsite(function (err, container) { should.not.exist(err); should.exist(container); container.should.be.instanceof(Container); - container.staticWebsiteIndexPage.should.equal('index.htm'); + (container.metadata['web-index'] == undefined).should.be.true; server && server.done(); done(); From f71d0f071125f4797201bf602ead7ccb698570aa Mon Sep 17 00:00:00 2001 From: Manuel Mazzuola Date: Sun, 31 Aug 2014 19:53:37 +0200 Subject: [PATCH 122/460] Implemented error page definition --- .../storage/client/cdn-containers.js | 19 +++++++++++++------ lib/pkgcloud/rackspace/storage/container.js | 4 ++-- test/rackspace/storage/container-test.js | 11 +++++++++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 65949bddc..115474459 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -315,24 +315,27 @@ exports._getCdnContainerDetails = function(container, callback) { }; /** - * client.setStaticWebsiteIndexPage + * client.setStaticWebsite * * @description set the static website index page on a storage container * * @param {String|object} container the container or containerName * @param {object} options an object with options * @param {String} options.indexFile configure the static website index file for this container + * @param {String} options.errorFile configure the static website error file for this container * @param callback */ -exports.setStaticWebsiteIndexPage = function (container, options, callback) { - var indexFile = options.indexFile; +exports.setStaticWebsite = function (container, options, callback) { + var indexFile = options.indexFile, errorFile = options.errorFile; if (typeof options === 'function') { callback = options; indexFile = 'index.html'; + errorFile = 'error.html'; } container.metadata['web-index'] = indexFile; + container.metadata['web-error'] = errorFile; this.updateContainerMetadata(container, callback); }; @@ -340,15 +343,19 @@ exports.setStaticWebsiteIndexPage = function (container, options, callback) { /** * client.removeStaticWebsite * - * @description remove the static website index page on a storage container + * @description remove the static website index/error page on a storage container * * @param {String|object} container the container or containerName * @param callback */ exports.removeStaticWebsite = function (container, callback) { - var indexFile = container.metadata['web-index']; + var indexFile = container.metadata['web-index'], errorFile = container.metadata['web-error'], + metadata = { + 'web-index': indexFile, + 'web-error': errorFile + }; - this.removeContainerMetadata(container, {'web-index': indexFile}, callback); + this.removeContainerMetadata(container, metadata, callback); }; /** diff --git a/lib/pkgcloud/rackspace/storage/container.js b/lib/pkgcloud/rackspace/storage/container.js index 53aaecde8..81e3ac3e6 100644 --- a/lib/pkgcloud/rackspace/storage/container.js +++ b/lib/pkgcloud/rackspace/storage/container.js @@ -42,8 +42,8 @@ Container.prototype.updateCdn = function (options, callback) { this.client.updateCdnContainer(this, options, callback); }; -Container.prototype.setStaticWebsiteIndexPage = function (options, callback) { - this.client.setStaticWebsiteIndexPage(this, options, callback); +Container.prototype.setStaticWebsite = function (options, callback) { + this.client.setStaticWebsite(this, options, callback); }; Container.prototype.removeStaticWebsite = function (callback) { diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index f9ba9f60b..ece51e321 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -442,7 +442,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { }); }); - it('getContainer and set static website index page ', function (done) { + it('getContainer and set static website index page and error page ', function (done) { if (mock) { server @@ -464,6 +464,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { 'x-container-object-count': '144', 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', 'x-container-meta-web-index': 'index.htm', + 'x-container-meta-web-error': 'error.htm', 'x-timestamp': '1368837729.84945', 'x-container-meta-foo': 'baz', 'x-container-bytes-used': '134015617', @@ -478,6 +479,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { 'x-cdn-ssl-uri': 'https://c98c1215ec09a78cd287-edfcb31ae70ea7c07367728d50539bc7.ssl.cf1.rackcdn.com', 'x-ttl': '186400', 'x-container-meta-web-index': 'index.htm', + 'x-container-meta-web-error': 'error.htm', 'x-log-retention': 'True', 'content-type': 'text/html; charset=UTF-8', 'x-cdn-streaming-uri': 'http://e5addf7be8783adf8c6d-edfcb31ae70ea7c07367728d50539bc7.r63.stream.cf1.rackcdn.com', @@ -493,13 +495,15 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); (container.metadata['web-index'] == undefined).should.be.true; + (container.metadata['web-error'] == undefined).should.be.true; - container.setStaticWebsiteIndexPage({indexFile: 'index.htm'}, function (err, container) { + container.setStaticWebsite({indexFile: 'index.htm', errorFile: 'error.htm'}, function (err, container) { should.not.exist(err); should.exist(container); container.should.be.instanceof(Container); container.metadata['web-index'].should.equal('index.htm'); + container.metadata['web-error'].should.equal('error.htm'); server && server.done(); done(); @@ -516,6 +520,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { 'x-container-object-count': '144', 'x-container-meta-awesome': 'Tue Jun 04 2013 07:58:52 GMT-0700 (PDT)', 'x-container-meta-web-index': 'index.htm', + 'x-container-meta-web-error': 'error.htm', 'x-timestamp': '1368837729.84945', 'x-container-meta-foo': 'baz', 'x-container-bytes-used': '134015617', @@ -557,6 +562,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); container.metadata['web-index'].should.equal('index.htm'); + container.metadata['web-error'].should.equal('error.htm'); container.removeStaticWebsite(function (err, container) { should.not.exist(err); @@ -564,6 +570,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); (container.metadata['web-index'] == undefined).should.be.true; + (container.metadata['web-error'] == undefined).should.be.true; server && server.done(); done(); From a734ecb7753d623e726695c384863055ca8c69ec Mon Sep 17 00:00:00 2001 From: ghemingway Date: Mon, 1 Sep 2014 10:06:47 -0500 Subject: [PATCH 123/460] Add v1.0 support for openstack swift storage --- lib/pkgcloud/openstack/client.js | 4 +++- lib/pkgcloud/openstack/context/identity.js | 25 ++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 99c9f55a1..c4a65ce4b 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -35,7 +35,8 @@ var Client = exports.Client = function (options) { this.authUrl = options.authUrl || 'auth.api.trystack.org'; this.provider = 'openstack'; this.region = options.region; - this.tenantId = options.tenantId; + this.tenantId = options.tenantId; + this.version = options.version || 'v2.0'; if (!/^http[s]?\:\/\//.test(this.authUrl)) { this.authUrl = 'http://' + this.authUrl; @@ -71,6 +72,7 @@ util.inherits(Client, base.Client); Client.prototype._getIdentityOptions = function() { var options = { url: this.authUrl, + version: this.version, username: this.config.username, password: this.config.password }; diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index 810e833f6..22cd92006 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -13,7 +13,7 @@ var _ = require('underscore'), ServiceCatalog = require('./serviceCatalog').ServiceCatalog, svcCat = require('./serviceCatalog'), url = require('url'), - util = require('util'), + utile = require('utile'), urlJoin = require('url-join'), util = require('util'), pkgcloud = require('../../../pkgcloud'), @@ -59,7 +59,7 @@ var Identity = exports.Identity = function (options) { }); }; -util.inherits(Identity, events.EventEmitter2); +utile.inherits(Identity, events.EventEmitter2); /** * Identity.authorize @@ -76,7 +76,6 @@ Identity.prototype.authorize = function (options, callback) { callback = options; options = {}; } - var authenticationOptions = { uri: urlJoin(options.url || self.options.url, '/v2.0/tokens'), method: 'POST', @@ -87,6 +86,12 @@ Identity.prototype.authorize = function (options, callback) { } }; + if (self.options.version === 1 || self.options.version === '/v1.0') { + authenticationOptions.uri = urlJoin(options.url || self.options.url, '/auth/v1.0'); + authenticationOptions.method = 'GET'; + authenticationOptions.headers['X-Auth-User'] = self.options.username; + authenticationOptions.headers['X-Auth-Key'] = self.options.password; + } self._buildAuthenticationPayload(); // we can't be called without a payload @@ -126,9 +131,16 @@ Identity.prototype.authorize = function (options, callback) { statusCode: response.statusCode }); + if (self.options.version === 1 || self.options.version === '/v1.0') { + self._storageURL = response.headers['x-storage-url']; + self.token = { + id: response.headers['x-auth-token'] + }; + callback(); + } // If we don't have a tenantId in the response (meaning no service catalog) // go ahead and make a 1-off request to get a tenant and then reauthorize - if (!body.access.token.tenant) { + else if (!body.access.token.tenant) { getTenantId(urlJoin(options.url || self.options.url, '/v2.0/tenants'), body.access.token.id); } else { @@ -246,6 +258,9 @@ Identity.prototype.getServiceEndpointUrl = function (options) { if (this.useServiceCatalog) { return this.serviceCatalog.getServiceEndpointUrl(options); } + else if (this.options.version === 1 || this.options.version === '/v1.0') { + return this._storageURL; + } else { return this.options.url; } @@ -282,6 +297,4 @@ function getError(err, res, body) { return err2; } - - return; } From f644c3cff029366ea63fca1ea61dcb5fdc497d24 Mon Sep 17 00:00:00 2001 From: ghemingway Date: Tue, 2 Sep 2014 14:01:56 -0500 Subject: [PATCH 124/460] Remove utile requirement. --- lib/pkgcloud/openstack/context/identity.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index 22cd92006..bc3ba87fc 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -13,7 +13,6 @@ var _ = require('underscore'), ServiceCatalog = require('./serviceCatalog').ServiceCatalog, svcCat = require('./serviceCatalog'), url = require('url'), - utile = require('utile'), urlJoin = require('url-join'), util = require('util'), pkgcloud = require('../../../pkgcloud'), @@ -59,7 +58,7 @@ var Identity = exports.Identity = function (options) { }); }; -utile.inherits(Identity, events.EventEmitter2); +util.inherits(Identity, events.EventEmitter2); /** * Identity.authorize From 00d7ba69adc1bb6e491031d9687e7386a2bcf28b Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 12 Sep 2014 14:42:55 -0700 Subject: [PATCH 125/460] Updating hock to v1.0 --- package.json | 2 +- test/amazon/compute/client/groups-test.js | 38 ++++---- test/amazon/compute/client/keys-test.js | 30 +++--- test/azure/databases/databases-test.js | 26 +++--- test/common/compute/base-test.js | 66 ++++++------- test/common/compute/meta-test.js | 43 +++++---- test/common/compute/server-test.js | 78 ++++++++-------- test/common/network/network-test.js | 85 +++++++++-------- test/common/network/port-test.js | 86 +++++++++-------- test/common/network/subnet-test.js | 86 +++++++++-------- test/common/storage/base-test.js | 90 +++++++++--------- test/hp/compute/authentication-test.js | 58 ++++++------ test/hp/network/authentication-test.js | 57 ++++++------ test/hp/storage/authentication-test.js | 31 +++---- .../databases/databases-redis-test.js | 17 ++-- test/iriscouch/databases/databases-test.js | 17 ++-- test/mongohq/databases/databases-test.js | 21 ++--- test/mongolab/databases/databases-test.js | 57 ++++++------ .../compute/client/startServer-test.js | 36 ++++--- .../compute/client/stopServer-test.js | 36 ++++--- test/openstack/identity/identity-test.js | 52 +++++------ test/rackspace/blockstorage/volumes-test.js | 49 +++++----- test/rackspace/compute/authentication-test.js | 61 ++++++------ test/rackspace/compute/image-test.js | 45 ++++----- .../databases/authentication-test.js | 52 +++++------ test/rackspace/databases/databases-test.js | 77 +++++++-------- test/rackspace/databases/flavor-test.js | 45 ++++----- test/rackspace/databases/instances-test.js | 93 +++++++++---------- test/rackspace/databases/users-test.js | 87 ++++++++--------- test/rackspace/storage/authentication-test.js | 35 ++++--- test/rackspace/storage/container-test.js | 79 ++++++++-------- test/rackspace/storage/storage-object-test.js | 71 +++++++------- test/redistogo/databases/databases-test.js | 25 ++--- 33 files changed, 820 insertions(+), 911 deletions(-) diff --git a/package.json b/package.json index 611f6a613..5168237cd 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "url-join": "0.0.x" }, "devDependencies": { - "hock" : "0.2.x", + "hock" : "1.0.x", "mocha": "1.21.x", "should": "4.0.x", "mocha-lcov-reporter": "0.0.1", diff --git a/test/amazon/compute/client/groups-test.js b/test/amazon/compute/client/groups-test.js index 411748849..bb808fc72 100644 --- a/test/amazon/compute/client/groups-test.js +++ b/test/amazon/compute/client/groups-test.js @@ -1,11 +1,12 @@ var helpers = require('../../../helpers'), + http = require('http'), should = require('should'), hock = require('hock'), mock = !!process.env.MOCK; describe('pkgcloud/amazon/groups', function () { - var client, server; + var client, server, hockInstance; before(function (done) { client = helpers.createClient('amazon', 'compute'); @@ -14,20 +15,17 @@ describe('pkgcloud/amazon/groups', function () { return done(); } - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient.filteringRequestBody(helpers.authFilter); + hockInstance = hock.createHock(); + hockInstance.filteringRequestBody(helpers.authFilter); - done(); - }); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); it('add SecurityGroup should succeed', function(done) { if (mock) { - server + hockInstance .post('/?Action=CreateSecurityGroup', { GroupDescription: 'unit test', GroupName: 'unit test' @@ -41,7 +39,7 @@ describe('pkgcloud/amazon/groups', function () { }, function(err, data) { should.not.exist(err); data.should.equal(true); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -49,7 +47,7 @@ describe('pkgcloud/amazon/groups', function () { it('destroy SecurityGroup should succeed', function (done) { if (mock) { - server + hockInstance .post('/?Action=DeleteSecurityGroup', { GroupName: 'unit test' }) @@ -59,7 +57,7 @@ describe('pkgcloud/amazon/groups', function () { client.destroyGroup('unit test', function (err, data) { should.not.exist(err); data.should.equal(true); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -67,7 +65,7 @@ describe('pkgcloud/amazon/groups', function () { it('list SecurityGroups should succeed', function (done) { if (mock) { - server + hockInstance .post('/?Action=DescribeSecurityGroups', {}) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/list-groups.xml'); } @@ -75,7 +73,7 @@ describe('pkgcloud/amazon/groups', function () { client.listGroups(function (err, data) { should.not.exist(err); data.should.be.an.Array; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -83,7 +81,7 @@ describe('pkgcloud/amazon/groups', function () { it('get SecurityGroup should succeed', function (done) { if (mock) { - server + hockInstance .post('/?Action=DescribeSecurityGroups', { 'GroupName.1': 'unit test' }) @@ -93,7 +91,7 @@ describe('pkgcloud/amazon/groups', function () { client.getGroup('unit test', function (err, data) { should.not.exist(err); // TODO - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -101,7 +99,7 @@ describe('pkgcloud/amazon/groups', function () { it('add Rules should succeed', function(done) { if (mock) { - server + hockInstance .post('/?Action=AuthorizeSecurityGroupIngress', { GroupName: 'unit test', 'IpPermissions.1.FromPort': '0', @@ -123,7 +121,7 @@ describe('pkgcloud/amazon/groups', function () { }, function(err, data) { should.not.exist(err); data.should.equal(true); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -131,7 +129,7 @@ describe('pkgcloud/amazon/groups', function () { it('delete Rules should succeed', function (done) { if (mock) { - server + hockInstance .post('/?Action=RevokeSecurityGroupIngress', { GroupName: 'unit test', 'IpPermissions.1.FromPort': '0', @@ -153,7 +151,7 @@ describe('pkgcloud/amazon/groups', function () { }, function (err, data) { should.not.exist(err); data.should.equal(true); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/amazon/compute/client/keys-test.js b/test/amazon/compute/client/keys-test.js index a0826294a..4301ed911 100644 --- a/test/amazon/compute/client/keys-test.js +++ b/test/amazon/compute/client/keys-test.js @@ -1,11 +1,12 @@ var helpers = require('../../../helpers'), + http = require('http'), should = require('should'), hock = require('hock'), mock = !!process.env.MOCK; describe('pkgcloud/amazon/keys', function () { - var client, server; + var client, server, hockInstance; before(function (done) { client = helpers.createClient('amazon', 'compute'); @@ -14,20 +15,17 @@ describe('pkgcloud/amazon/keys', function () { return done(); } - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient.filteringRequestBody(helpers.authFilter); + hockInstance = hock.createHock(); + hockInstance.filteringRequestBody(helpers.authFilter); - done(); - }); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); it('add KeyPair should succeed', function(done) { if (mock) { - server + hockInstance .post('/?Action=ImportKeyPair', { KeyName: 'unittest', PublicKeyMaterial: 'c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFDblhidGZGTTNrNExFb3hMaENGQ3lucnBibmtPYWphQ2xFUVVzdWRaazBTVWxVenl0Y2laRjArN25VaDg1VDZjZWMyNjdnazZ4ZTBZWEJqalhWc2xqcGtBVnIyc21ycFRwc2FJWk1qdXdPNlZHNFdYMG54NFhJaG1lTy9WcmdvYzY5Q0liTFJqNnkySlI1UTlaaHVqZVZJK1FZVkg3RnZ0OTZMZjh5SkN6YzRQdDZIVCswU2pudnlqSVZRTkcrWFVuS21GMWNVTGZiWTZOK2JwbUhJQWpxNW1mLzR4T2lKeHFUa0N0NmhoNGk4aE4vOHJmMzUwL0dDUE1GYTA0Umh2Si9hQVRWMmhxLzR4UXZVUXhzdzVsWnUzM3dZMENiQXI1Z3Z2bHZQd1grV0pFQjQ3RU9adEwrdm1nZVdieGJETGNFNUVaSnIxejJIV2ZSQkIweC9uQng=' @@ -41,7 +39,7 @@ describe('pkgcloud/amazon/keys', function () { }, function(err, data) { should.not.exist(err); data.should.equal(true); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -49,7 +47,7 @@ describe('pkgcloud/amazon/keys', function () { it('destroy KeyPair should succeed', function (done) { if (mock) { - server + hockInstance .post('/?Action=DeleteKeyPair', { KeyName: 'unittest' }) @@ -59,7 +57,7 @@ describe('pkgcloud/amazon/keys', function () { client.destroyKey('unittest', function (err, data) { should.not.exist(err); data.should.equal(true); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -67,7 +65,7 @@ describe('pkgcloud/amazon/keys', function () { it('list KeyPairs should succeed', function (done) { if (mock) { - server + hockInstance .post('/?Action=DescribeKeyPairs', {}) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/list-keys.xml'); } @@ -75,7 +73,7 @@ describe('pkgcloud/amazon/keys', function () { client.listKeys(function (err, data) { should.not.exist(err); data.should.be.an.Array; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -83,7 +81,7 @@ describe('pkgcloud/amazon/keys', function () { it('get KeyPair should succeed', function (done) { if (mock) { - server + hockInstance .post('/?Action=DescribeKeyPairs', { 'KeyName.1': 'unittest' }) @@ -93,7 +91,7 @@ describe('pkgcloud/amazon/keys', function () { client.getKey('unittest', function (err, data) { should.not.exist(err); // TODO - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/azure/databases/databases-test.js b/test/azure/databases/databases-test.js index 9af9b8bc3..58b2e3b51 100644 --- a/test/azure/databases/databases-test.js +++ b/test/azure/databases/databases-test.js @@ -6,6 +6,7 @@ */ var helpers = require('../../helpers'), + http = require('http'), should = require('should'), urlJoin = require('url-join'), hock = require('hock'), @@ -13,7 +14,7 @@ var helpers = require('../../helpers'), describe('pkgcloud/azure/databases', function () { - var client, server, testContext = {}; + var client, server, testContext = {}, hockInstance; before(function (done) { client = helpers.createClient('azure', 'database'); @@ -31,21 +32,18 @@ describe('pkgcloud/azure/databases', function () { : options.path)); }; - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + hockInstance = hock.createHock(); + hockInstance.filteringRequestBodyRegEx(/.*/, '*'); - server = hockClient.filteringRequestBodyRegEx(/.*/, '*'); - - done(); - }); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); describe('the pkgcloud azure db client', function() { it('the create() method with correct options should respond correctly', function(done) { if (mock) { - server + hockInstance .post('/Tables', '*') .replyWithFile(201, __dirname + '/../../fixtures/azure/database/createTableResponse.xml'); } @@ -61,7 +59,7 @@ describe('pkgcloud/azure/databases', function () { database.password.should.equal(''); testContext.databaseId = database.id; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -85,7 +83,7 @@ describe('pkgcloud/azure/databases', function () { it('the list() method with correct options should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/Tables') .replyWithFile(201, __dirname + '/../../fixtures/azure/database/listTables.xml'); } @@ -96,7 +94,7 @@ describe('pkgcloud/azure/databases', function () { databases.should.be.an.Array; databases.should.have.length(1); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -104,7 +102,7 @@ describe('pkgcloud/azure/databases', function () { it('the remove() method with correct options should respond correctly', function (done) { if (mock) { - server + hockInstance .delete("/Tables%28%27testDatabase%27%29") .reply(204, '', {'content-length': '0'}); } @@ -112,7 +110,7 @@ describe('pkgcloud/azure/databases', function () { client.remove(testContext.databaseId, function (err, result) { should.not.exist(err); result.should.equal(true); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 7831fbf23..240dd7c28 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -11,6 +11,7 @@ var fs = require('fs'), qs = require('qs'), util = require('util'), async = require('async'), + http = require('http'), helpers = require('../../helpers'), hock = require('hock'), _ = require('underscore'), @@ -32,7 +33,9 @@ providers.forEach(function(provider) { var client = helpers.createClient(provider, 'compute'), context = {}, - authServer, server; + authServer, server, + authHockInstance, + hockInstance; before(function(done) { @@ -40,21 +43,18 @@ providers.forEach(function(provider) { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function(next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function(err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done) }); @@ -62,8 +62,8 @@ providers.forEach(function(provider) { it('the getVersion() method with no arguments should return the version', function (done) { if (mock) { var errors = setupVersionMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -79,8 +79,8 @@ providers.forEach(function(provider) { should.exist(version); version.should.equal(versions[provider]); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); } @@ -89,8 +89,8 @@ providers.forEach(function(provider) { it('the getFlavors() method should return a list of flavors', function(done) { if (mock) { setupFlavorMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -104,8 +104,8 @@ providers.forEach(function(provider) { context.flavors = flavors; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -114,8 +114,8 @@ providers.forEach(function(provider) { it('the getImages() method should return a list of images', function (done) { if (mock) { setupImagesMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -129,20 +129,20 @@ providers.forEach(function(provider) { context.images = images; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); - it('the setWait() method waiting for a server to be operational should return a running server', function (done) { + it('the setWait() method waiting for a hockInstance to be operational should return a running hockInstance', function (done) { var m = mock ? 0.1 : 100; if (mock) { setupServerMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -162,8 +162,8 @@ providers.forEach(function(provider) { srv2.status.should.equal(srv2.STATUS.running); context.server = srv2; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -179,8 +179,8 @@ providers.forEach(function(provider) { if (mock) { setupDestroyMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -188,8 +188,8 @@ providers.forEach(function(provider) { should.not.exist(err); should.exist(result); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index 486135aec..acda64a54 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -10,6 +10,7 @@ var fs = require('fs'), qs = require('qs'), should = require('should'), helpers = require('../../helpers'), + http = require('http'), hock = require('hock'), async = require('async'), _ = require('underscore'), @@ -23,7 +24,9 @@ providers.forEach(function (provider) { var client = helpers.createClient(provider, 'compute'), context = {}, - authServer, server; + authServer, server, + authHockInstance, + hockInstance; before(function (done) { @@ -31,21 +34,18 @@ providers.forEach(function (provider) { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done) }); @@ -54,8 +54,8 @@ providers.forEach(function (provider) { if (mock) { setupImagesMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -63,15 +63,14 @@ providers.forEach(function (provider) { should.not.exist(err); should.exist(images); - context.images = images + context.images = images; images.forEach(function(img) { img.should.be.instanceOf(Image); }); - - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -81,8 +80,8 @@ providers.forEach(function (provider) { it('the updateImageMeta() method should update the image metadata', function (done) { if (mock) { setupMetaMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -96,8 +95,8 @@ providers.forEach(function (provider) { context.currentServer = server; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index f81177376..d1a5829e9 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -12,6 +12,7 @@ var fs = require('fs'), util = require('util'), async = require('async'), helpers = require('../../helpers'), + http = require('http'), hock = require('hock'), _ = require('underscore'), providers = require('../../configs/providers.json'), @@ -30,7 +31,9 @@ providers.forEach(function (provider) { var client = helpers.createClient(provider, 'compute'), context = {}, - authServer, server; + authServer, server, + authHockInstance, + hockInstance; before(function (done) { @@ -38,21 +41,18 @@ providers.forEach(function (provider) { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done) }); @@ -61,8 +61,8 @@ providers.forEach(function (provider) { if (mock) { setupImagesMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -70,10 +70,10 @@ providers.forEach(function (provider) { should.not.exist(err); should.exist(images); - context.images = images + context.images = images; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -83,8 +83,8 @@ providers.forEach(function (provider) { if (mock) { setupFlavorMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -92,10 +92,10 @@ providers.forEach(function (provider) { should.not.exist(err); should.exist(flavors); - context.flavors = flavors + context.flavors = flavors; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -106,8 +106,8 @@ providers.forEach(function (provider) { if (mock) { setupServerMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -126,8 +126,8 @@ providers.forEach(function (provider) { srv2.name.should.equal('create-test-ids2'); srv2.imageId.should.equal(context.images[0].id); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -136,8 +136,8 @@ providers.forEach(function (provider) { it('the getServers() method should return a list of servers', function (done) { if (mock) { setupGetServersMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -151,8 +151,8 @@ providers.forEach(function (provider) { srv.should.be.instanceOf(Server); }); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -161,8 +161,8 @@ providers.forEach(function (provider) { it.skip('the getServer() method should get a server instance', function (done) { if (mock) { setupGetServerMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -172,10 +172,10 @@ providers.forEach(function (provider) { srv.should.be.instanceOf(Server); - context.currentServer = server; + context.currentServer = hockInstance; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -184,8 +184,8 @@ providers.forEach(function (provider) { it.skip('the server.rebootServer() method should restart a server instance', function (done) { if (mock) { setupRebootMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -197,8 +197,8 @@ providers.forEach(function (provider) { it.skip('the destroyServer() method should delete a server instance', function (done) { if (mock) { setupRebootMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 1b345531d..ccfe2cef7 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -12,6 +12,7 @@ var fs = require('fs'), util = require('util'), async = require('async'), helpers = require('../../helpers'), + http = require('http'), hock = require('hock'), _ = require('underscore'), providers = require('../../configs/providers.json'), @@ -26,7 +27,8 @@ providers.filter(function (provider) { var client = helpers.createClient(provider, 'network'), context = {}, - authServer, server; + authServer, server, + authHockInstance, hockInstance; before(function (done) { @@ -34,31 +36,28 @@ providers.filter(function (provider) { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } - ], done); + ], done) }); it('the getNetworks() function should return a list of networks', function(done) { if (mock) { setupNetworksMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -68,8 +67,8 @@ providers.filter(function (provider) { context.networks = networks; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -78,8 +77,8 @@ providers.filter(function (provider) { it('the getNetwork() method should get a network instance', function (done) { if (mock) { setupGetNetworkMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -90,8 +89,8 @@ providers.filter(function (provider) { network.should.have.property('id', context.networks[0].id); context.currentNetwork = network; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -102,8 +101,8 @@ providers.filter(function (provider) { if (mock) { setupNetworkMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -112,8 +111,8 @@ providers.filter(function (provider) { }), function (err, network) { should.not.exist(err); should.exist(network); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -121,8 +120,8 @@ providers.filter(function (provider) { it('the destroyNetwork() method should delete a network', function (done) { if (mock) { setupDestroyNetworkMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, context.currentNetwork); } @@ -135,8 +134,8 @@ providers.filter(function (provider) { it('the destroyNetwork() method should take an id, delete a network', function (done) { if (mock) { setupDestroyNetworkMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, context.currentNetwork); } @@ -153,8 +152,8 @@ providers.filter(function (provider) { if (mock) { setupUpdateNetworkMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, networkToUpdate); } @@ -169,8 +168,8 @@ providers.filter(function (provider) { if (mock) { setupNetworkModelCreateMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -179,8 +178,8 @@ providers.filter(function (provider) { network.create(function (err, createdNetwork) { should.not.exist(err); should.exist(createdNetwork); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -193,8 +192,8 @@ providers.filter(function (provider) { if (mock) { setupRefreshNetworkMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, network); } @@ -202,8 +201,8 @@ providers.filter(function (provider) { should.not.exist(err); should.exist(refreshedNetwork); refreshedNetwork.should.have.property('name', 'private-network'); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -215,8 +214,8 @@ providers.filter(function (provider) { if (mock) { setupModelDestroyedNetworkMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, network); } @@ -233,10 +232,10 @@ providers.filter(function (provider) { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done); }); diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 52942ae5d..e1c9f7593 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -13,7 +13,7 @@ var fs = require('fs'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), - async = require('async'), + http = require('http'), _ = require('underscore'), providers = require('../../configs/providers.json'), Port = require('../../../lib/pkgcloud/core/network/port').Port, @@ -27,7 +27,8 @@ providers.filter(function (provider) { var client = helpers.createClient(provider, 'network'), context = {}, - authServer, server; + authServer, server, + authHockInstance, hockInstance; before(function (done) { @@ -35,31 +36,28 @@ providers.filter(function (provider) { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } - ], done); + ], done) }); it('the getPorts() function should return a list of ports', function(done) { if (mock) { setupPortsMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -69,8 +67,8 @@ providers.filter(function (provider) { context.ports = ports; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -79,8 +77,8 @@ providers.filter(function (provider) { it('the getPort() method should get a port instance', function (done) { if (mock) { setupGetPortMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, context.ports[0]); } @@ -91,8 +89,8 @@ providers.filter(function (provider) { port.should.have.property('id', context.ports[0].id); context.currentPort = port; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -103,8 +101,8 @@ providers.filter(function (provider) { if (mock) { setupCreatePortMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -115,8 +113,8 @@ providers.filter(function (provider) { should.exist(port); port.should.be.an.instanceOf(Port); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -124,8 +122,8 @@ providers.filter(function (provider) { it('the destroyPort() method should delete a port', function (done) { if (mock) { setupDestroyPortMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, context.currentPort); } @@ -138,8 +136,8 @@ providers.filter(function (provider) { it('the destroyPort() method should take an id, delete a port', function (done) { if (mock) { setupDestroyPortMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, context.currentPort); } @@ -156,8 +154,8 @@ providers.filter(function (provider) { if (mock) { setupUpdatePortMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, portToUpdate); } @@ -172,8 +170,8 @@ providers.filter(function (provider) { if (mock) { setupPortModelCreateMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -182,8 +180,8 @@ providers.filter(function (provider) { port.create(function (err, createdPort) { should.not.exist(err); should.exist(createdPort); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -196,8 +194,8 @@ providers.filter(function (provider) { if (mock) { setupRefreshPortMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, port); } @@ -205,8 +203,8 @@ providers.filter(function (provider) { should.not.exist(err); should.exist(refreshedPort); refreshedPort.should.have.property('name', 'my_port'); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -218,8 +216,8 @@ providers.filter(function (provider) { if (mock) { setupModelDestroyedPortMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, port); } @@ -236,10 +234,10 @@ providers.filter(function (provider) { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done); }); diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index b89125828..70d525fb5 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -12,8 +12,8 @@ var fs = require('fs'), util = require('util'), async = require('async'), helpers = require('../../helpers'), + http = require('http'), hock = require('hock'), - async = require('async'), _ = require('underscore'), providers = require('../../configs/providers.json'), Subnet = require('../../../lib/pkgcloud/core/network/subnet').Subnet, @@ -27,7 +27,8 @@ providers.filter(function (provider) { var client = helpers.createClient(provider, 'network'), context = {}, - authServer, server; + authServer, server, + authHockInstance, hockInstance; before(function (done) { @@ -35,31 +36,28 @@ providers.filter(function (provider) { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } - ], done); + ], done) }); it('the getSubnets() function should return a list of subnets', function(done) { if (mock) { setupSubnetsMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -69,8 +67,8 @@ providers.filter(function (provider) { context.subnets = subnets; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -79,8 +77,8 @@ providers.filter(function (provider) { it('the getSubnet() method should get a subnet instance', function (done) { if (mock) { setupGetSubnetMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance },context.subnets[0]); } @@ -91,8 +89,8 @@ providers.filter(function (provider) { subnet.should.have.property('id', context.subnets[0].id); context.currentSubnet = subnet; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -103,8 +101,8 @@ providers.filter(function (provider) { if (mock) { setupCreateSubnetMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -115,8 +113,8 @@ providers.filter(function (provider) { should.exist(subnet); subnet.should.be.an.instanceOf(Subnet); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -124,8 +122,8 @@ providers.filter(function (provider) { it('the destroySubnet() method should delete a subnet', function (done) { if (mock) { setupDestroySubnetMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, context.currentSubnet); } @@ -138,8 +136,8 @@ providers.filter(function (provider) { it('the destroySubnet() method should take an id, delete a subnet', function (done) { if (mock) { setupDestroySubnetMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, context.currentSubnet); } @@ -156,8 +154,8 @@ providers.filter(function (provider) { if (mock) { setupUpdateSubnetMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, subnetToUpdate); } @@ -172,8 +170,8 @@ providers.filter(function (provider) { if (mock) { setupSubnetModelCreateMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }); } @@ -182,8 +180,8 @@ providers.filter(function (provider) { subnet.create(function (err, createdSubnet) { should.not.exist(err); should.exist(createdSubnet); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -196,8 +194,8 @@ providers.filter(function (provider) { if (mock) { setupRefreshSubnetMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, subnet); } @@ -205,8 +203,8 @@ providers.filter(function (provider) { should.not.exist(err); should.exist(refreshedSubnet); refreshedSubnet.should.have.property('name', 'my_subnet'); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -218,8 +216,8 @@ providers.filter(function (provider) { if (mock) { setupModelDestroyedSubnetMock(client, provider, { - authServer: authServer, - server: server + authServer: authHockInstance, + server: hockInstance }, subnet); } @@ -236,10 +234,10 @@ providers.filter(function (provider) { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done); }); diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index c0260844e..4dfde8341 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -14,6 +14,7 @@ var fs = require('fs'), util = require('util'), async = require('async'), hock = require('hock'), + http = require('http'), urlJoin = require('url-join'), _ = require('underscore'), providers = require('../../configs/providers.json'), @@ -30,8 +31,9 @@ providers.filter(function (provider) { describe('pkgcloud/common/storage/base [' + provider + ']', function () { var client = helpers.createClient(provider, 'storage'), - context = {}, - authServer, server; + context = {}, + authServer, server, + authHockInstance, hockInstance; before(function (done) { @@ -39,20 +41,20 @@ providers.filter(function (provider) { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12345, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } - ], done) + ], done); }); it('the createContainer() method should return newly created container', function(done) { @@ -64,8 +66,8 @@ providers.filter(function (provider) { } setupCreateContainerMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -76,8 +78,8 @@ providers.filter(function (provider) { context.container = container; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -92,8 +94,8 @@ providers.filter(function (provider) { } setupGetContainersMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -107,7 +109,7 @@ providers.filter(function (provider) { }); // TODO Name check - server && server.done(); + hockInstance && hockInstance.done(); done(); }); @@ -122,8 +124,8 @@ providers.filter(function (provider) { } setupUploadStreamMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -144,7 +146,7 @@ providers.filter(function (provider) { should.exist(response.statusCode); should.exist(response.headers); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); @@ -161,8 +163,8 @@ providers.filter(function (provider) { } setupDownloadStreamMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -177,7 +179,7 @@ providers.filter(function (provider) { context.fileContents.should.equal(fillerama); file.size.should.equal(Buffer.byteLength(context.fileContents)); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); @@ -197,8 +199,8 @@ providers.filter(function (provider) { } setupDownloadStreamMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -213,7 +215,7 @@ providers.filter(function (provider) { context.fileContents.should.equal(fillerama); file.size.should.equal(Buffer.byteLength(context.fileContents)); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); @@ -233,8 +235,8 @@ providers.filter(function (provider) { } setupGetFileMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -245,7 +247,7 @@ providers.filter(function (provider) { file.name.should.equal(context.file.name); file.size.should.equal(context.file.size); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -259,8 +261,8 @@ providers.filter(function (provider) { } setupGetFilesMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -276,7 +278,7 @@ providers.filter(function (provider) { // TODO look for context.file in array - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -290,8 +292,8 @@ providers.filter(function (provider) { } setupRemoveFileMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -299,7 +301,7 @@ providers.filter(function (provider) { should.not.exist(err); should.exist(ok); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -379,8 +381,8 @@ providers.filter(function (provider) { } setupDestroyContainerMock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -388,7 +390,7 @@ providers.filter(function (provider) { should.not.exist(err); should.exist(ok); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -402,8 +404,8 @@ providers.filter(function (provider) { } setupGetContainers2Mock(provider, client, { - server: server, - authServer: authServer + server: hockInstance, + authServer: authHockInstance }); } @@ -411,7 +413,7 @@ providers.filter(function (provider) { should.not.exist(err); should.exist(ok); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -423,10 +425,10 @@ providers.filter(function (provider) { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/hp/compute/authentication-test.js b/test/hp/compute/authentication-test.js index b556eba01..34a6e6efc 100644 --- a/test/hp/compute/authentication-test.js +++ b/test/hp/compute/authentication-test.js @@ -8,12 +8,13 @@ var should = require('should'), async = require('async'), hock = require('hock'), + http = require('http'), macros = require('../macros'), helpers = require('../../helpers'), mock = !!process.env.MOCK; describe('pkgcloud/hp/compute/authentication', function () { - var client, authServer, server; + var client, authHockInstance, hockInstance, authServer, server; describe('The pkgcloud hp Compute client', function () { @@ -24,26 +25,20 @@ describe('pkgcloud/hp/compute/authentication', function () { return done(); } - async.parallel([ - function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); - authServer = hockClient; - next(); - }); - }, - function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); - server = hockClient; - next(); - }); - } - ], done); + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); }); it('should have core methods defined', function() { @@ -57,7 +52,7 @@ describe('pkgcloud/hp/compute/authentication', function () { client = helpers.createClient('hp', 'compute'); if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -71,7 +66,7 @@ describe('pkgcloud/hp/compute/authentication', function () { client.auth(function (e) { should.not.exist(e); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -96,7 +91,7 @@ describe('pkgcloud/hp/compute/authentication', function () { beforeEach(function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -114,7 +109,7 @@ describe('pkgcloud/hp/compute/authentication', function () { badClient.auth(function (e) { err = e; - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); @@ -134,6 +129,7 @@ describe('pkgcloud/hp/compute/authentication', function () { client = helpers.createClient('hp', 'compute'); client.on('log::*', function(message, obj) { + // Ken: why is this console log present? if (this.event !== 'log::trace') { console.log(message); console.dir(obj); @@ -146,7 +142,7 @@ describe('pkgcloud/hp/compute/authentication', function () { tokenExpiry = response.access.token.expires; - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -160,7 +156,7 @@ describe('pkgcloud/hp/compute/authentication', function () { client.auth(function (e) { should.not.exist(e); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -180,7 +176,7 @@ describe('pkgcloud/hp/compute/authentication', function () { it('should expire the token and reauth on next call', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -191,7 +187,7 @@ describe('pkgcloud/hp/compute/authentication', function () { }) .reply(200, helpers.gethpAuthResponse()); - server + hockInstance .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); } @@ -202,8 +198,8 @@ describe('pkgcloud/hp/compute/authentication', function () { client._isAuthorized().should.equal(true); should.not.exist(err); should.exist(images); - server && server.done(); - authServer && authServer.done(); + hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); done(); }); }, 5); @@ -217,10 +213,10 @@ describe('pkgcloud/hp/compute/authentication', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done); }); diff --git a/test/hp/network/authentication-test.js b/test/hp/network/authentication-test.js index c49fa21da..a3e8875ce 100644 --- a/test/hp/network/authentication-test.js +++ b/test/hp/network/authentication-test.js @@ -8,12 +8,13 @@ var should = require('should'), async = require('async'), hock = require('hock'), + http = require('http'), macros = require('../macros'), helpers = require('../../helpers'), mock = !!process.env.MOCK; describe('pkgcloud/hp/network/authentication', function () { - var client, authServer, server; + var client, authHockInstance, hockInstance, authServer, server; describe('The pkgcloud hp network client', function () { @@ -24,26 +25,20 @@ describe('pkgcloud/hp/network/authentication', function () { return done(); } - async.parallel([ - function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); - authServer = hockClient; - next(); - }); - }, - function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); - server = hockClient; - next(); - }); - } - ], done); + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); }); it('should have core methods defined', function() { @@ -57,7 +52,7 @@ describe('pkgcloud/hp/network/authentication', function () { client = helpers.createClient('hp', 'compute'); if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -71,7 +66,7 @@ describe('pkgcloud/hp/network/authentication', function () { client.auth(function (e) { should.not.exist(e); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -96,7 +91,7 @@ describe('pkgcloud/hp/network/authentication', function () { beforeEach(function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -114,7 +109,7 @@ describe('pkgcloud/hp/network/authentication', function () { badClient.auth(function (e) { err = e; - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); @@ -146,7 +141,7 @@ describe('pkgcloud/hp/network/authentication', function () { tokenExpiry = response.access.token.expires; - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -160,7 +155,7 @@ describe('pkgcloud/hp/network/authentication', function () { client.auth(function (e) { should.not.exist(e); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -180,7 +175,7 @@ describe('pkgcloud/hp/network/authentication', function () { it('should expire the token and reauth on next call', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -191,7 +186,7 @@ describe('pkgcloud/hp/network/authentication', function () { }) .reply(200, helpers.gethpAuthResponse()); - server + hockInstance .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); } @@ -202,8 +197,8 @@ describe('pkgcloud/hp/network/authentication', function () { client._isAuthorized().should.equal(true); should.not.exist(err); should.exist(images); - server && server.done(); - authServer && authServer.done(); + hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); done(); }); }, 5); @@ -217,10 +212,10 @@ describe('pkgcloud/hp/network/authentication', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done); }); diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index fb82528cd..f6aac39a6 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -10,6 +10,7 @@ var should = require('should'), helpers = require('../../helpers'), async = require('async'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; describe('pkgcloud/hp/storage/authentication', function () { @@ -21,23 +22,22 @@ describe('pkgcloud/hp/storage/authentication', function () { describe('the auth() method', function() { describe('with a valid user name and api key', function() { - var authServer; + var authHockInstance, authServer before(function(done) { if (!mock) { return done(); } - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - done(); - }); + authHockInstance = hock.createHock(); + authServer = http.createServer(authHockInstance.handler); + authServer.listen(12346, done); }); it('should respond with 204 and appropriate info', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -53,14 +53,14 @@ describe('pkgcloud/hp/storage/authentication', function () { client.auth(function (err) { should.not.exist(err); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); it('should update the config with appropriate urls', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -76,7 +76,7 @@ describe('pkgcloud/hp/storage/authentication', function () { client.auth(function (err) { should.not.exist(err); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -94,23 +94,22 @@ describe('pkgcloud/hp/storage/authentication', function () { }); describe('with an invalid user name and api key shouldn\'t authenticate', function () { - var authServer; + var authHockInstance, authServer; before(function (done) { if (!mock) { return done(); } - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - done(); - }); + authHockInstance = hock.createHock(); + authServer = http.createServer(authHockInstance.handler); + authServer.listen(12346, done); }); it('should respond with 401 unauthorized', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'apiAccessKeyCredentials': { @@ -136,7 +135,7 @@ describe('pkgcloud/hp/storage/authentication', function () { badClient.auth(function (err, res) { should.exist(err); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js index 386606570..a6cb0ba2a 100644 --- a/test/iriscouch/databases/databases-redis-test.js +++ b/test/iriscouch/databases/databases-redis-test.js @@ -9,10 +9,11 @@ var helpers = require('../../helpers'), should = require('should'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; describe('pkgcloud/iriscouch/databases-redis', function () { - var context = {}, client, server; + var context = {}, client, hockInstance, server; before(function (done) { client = helpers.createClient('iriscouch', 'database'); @@ -21,13 +22,9 @@ describe('pkgcloud/iriscouch/databases-redis', function () { return done(); } - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - done(); - }); + hockInstance = hock.createHock(); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); it('the create() method with correct options should respond correctly', function(done) { @@ -35,7 +32,7 @@ describe('pkgcloud/iriscouch/databases-redis', function () { context.tempPassword = (mock ? 'sTTi:lh9vCF[' : randomPassword(12).replace("\\", "")); if (mock) { - server + hockInstance .post('/hosting_public', helpers.loadFixture('iriscouch/database-redis.json')) .reply(201, { ok: true, id: 'Redis/nodejitsudb43639', @@ -58,7 +55,7 @@ describe('pkgcloud/iriscouch/databases-redis', function () { context.databaseId = database.id; database.password.should.equal([database.host, context.tempPassword].join(':')); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/iriscouch/databases/databases-test.js b/test/iriscouch/databases/databases-test.js index 6de16f013..407221eba 100644 --- a/test/iriscouch/databases/databases-test.js +++ b/test/iriscouch/databases/databases-test.js @@ -9,10 +9,11 @@ var helpers = require('../../helpers'), should = require('should'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; describe('pkgcloud/iriscouch/databases', function () { - var context = {}, client, server; + var context = {}, client, hockInstance, server; before(function (done) { client = helpers.createClient('iriscouch', 'database'); @@ -21,13 +22,9 @@ describe('pkgcloud/iriscouch/databases', function () { return done(); } - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - done(); - }); + hockInstance = hock.createHock(); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); it('the create() method with correct options should respond correctly', function (done) { @@ -39,7 +36,7 @@ describe('pkgcloud/iriscouch/databases', function () { return 'http://localhost:12345'; }; - server + hockInstance .post('/hosting_public', helpers.loadFixture('iriscouch/database.json')) .reply(201, { ok: true, @@ -62,7 +59,7 @@ describe('pkgcloud/iriscouch/databases', function () { should.exist(database.uri); context.databaseId = database.id; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/mongohq/databases/databases-test.js b/test/mongohq/databases/databases-test.js index ccda3730d..40ab8b187 100644 --- a/test/mongohq/databases/databases-test.js +++ b/test/mongohq/databases/databases-test.js @@ -9,10 +9,11 @@ var helpers = require('../../helpers'), should = require('should'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; describe('pkgcloud/mongohq/databases', function () { - var context = {}, client, server; + var context = {}, client, hockInstance, server; before(function (done) { client = helpers.createClient('mongohq', 'database'); @@ -21,19 +22,15 @@ describe('pkgcloud/mongohq/databases', function () { return done(); } - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - done(); - }); + hockInstance = hock.createHock(); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); it('the create() method with correct options should respond correctly', function (done) { if (mock) { - server + hockInstance .post('/provider/resources', "app_id=testDatabase&plan=free") .reply(200, helpers.loadFixture('mongohq/database.json')); } @@ -50,7 +47,7 @@ describe('pkgcloud/mongohq/databases', function () { should.exist(database.password); context.databaseId = database.id; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -58,7 +55,7 @@ describe('pkgcloud/mongohq/databases', function () { it('the remove() method with correct options should respond correctly', function (done) { if (mock) { - server + hockInstance .delete('/provider/resources/63562') .reply(200, "OK"); } @@ -68,7 +65,7 @@ describe('pkgcloud/mongohq/databases', function () { should.exist(confirm); confirm.should.equal('deleted');; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js index 62ea19566..d6d08038e 100644 --- a/test/mongolab/databases/databases-test.js +++ b/test/mongolab/databases/databases-test.js @@ -9,10 +9,11 @@ var helpers = require('../../helpers'), should = require('should'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; describe('pkgcloud/mongolab/databases', function () { - var context = {}, client, server; + var context = {}, client, hockInstance, server; before(function (done) { client = helpers.createClient('mongolab', 'database'); @@ -21,19 +22,15 @@ describe('pkgcloud/mongolab/databases', function () { return done(); } - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - done(); - }); + hockInstance = hock.createHock(); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); it('the createAccount() method with correct options should respond correctly', function (done) { if (mock) { - server + hockInstance .post('/api/1/partners/nodejitsu/accounts', { name: 'nodejitsu_daniel', adminUser: { @@ -55,7 +52,7 @@ describe('pkgcloud/mongolab/databases', function () { should.exist(response.account.password); context.account = response.account; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -122,7 +119,7 @@ describe('pkgcloud/mongolab/databases', function () { it('with numbers should respond with success', function(done) { if (mock) { - server + hockInstance .post('/api/1/partners/nodejitsu/accounts', { name: 'nodejitsu_custompassword', adminUser: { @@ -145,7 +142,7 @@ describe('pkgcloud/mongolab/databases', function () { should.exist(response.account.email); context.custompw = response.account; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -154,7 +151,7 @@ describe('pkgcloud/mongolab/databases', function () { it('the getAccounts() method should respond with all accounts', function(done) { if (mock) { - server + hockInstance .get('/api/1/partners/nodejitsu/accounts') .reply(200, helpers.loadFixture('mongolab/userList.json')) } @@ -169,7 +166,7 @@ describe('pkgcloud/mongolab/databases', function () { should.exist(account.email); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -177,7 +174,7 @@ describe('pkgcloud/mongolab/databases', function () { it('the getAccount() method should return the matching account', function(done) { if (mock) { - server + hockInstance .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel') .reply(200, { name: 'nodejitsu_daniel', @@ -194,7 +191,7 @@ describe('pkgcloud/mongolab/databases', function () { account.username.should.equal(context.account.username); account.email.should.equal(context.account.email); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); @@ -203,7 +200,7 @@ describe('pkgcloud/mongolab/databases', function () { it('the create() method with correct options should respond correctly', function (done) { if (mock) { - server + hockInstance .post('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases', helpers.loadFixture('mongolab/reqDatabase.json')) .reply(200, helpers.loadFixture('mongolab/database.json')); } @@ -221,7 +218,7 @@ describe('pkgcloud/mongolab/databases', function () { should.exist(database.password); context.databaseId = database.id; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -256,7 +253,7 @@ describe('pkgcloud/mongolab/databases', function () { it('with valid options should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases') .reply(200, [ { name : 'nodejitsu_daniel_testDatabase' } ]); } @@ -270,7 +267,7 @@ describe('pkgcloud/mongolab/databases', function () { databases[0].name.should.equal(context.account.username + '_testDatabase'); context.databaseName = databases[0].name; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -289,7 +286,7 @@ describe('pkgcloud/mongolab/databases', function () { it('with valid options should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases/nodejitsu_daniel_testDatabase') .reply(200, { name : 'nodejitsu_daniel_testDatabase' }); } @@ -303,7 +300,7 @@ describe('pkgcloud/mongolab/databases', function () { database.should.be.a.Object; database.name.should.equal(context.account.username + '_testDatabase'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -340,7 +337,7 @@ describe('pkgcloud/mongolab/databases', function () { it('with valid options should respond correctly', function (done) { if (mock) { - server + hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases/nodejitsu_daniel_testDatabase') .reply(200, " null ") } @@ -351,7 +348,7 @@ describe('pkgcloud/mongolab/databases', function () { function (err) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -359,7 +356,7 @@ describe('pkgcloud/mongolab/databases', function () { it('and have no databases left after getDatabases()', function (done) { if (mock) { - server + hockInstance .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases') .reply(200, []); } @@ -370,7 +367,7 @@ describe('pkgcloud/mongolab/databases', function () { databases.should.be.an.Array; databases.should.have.length(0); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -407,7 +404,7 @@ describe('pkgcloud/mongolab/databases', function () { it('with valid options should respond correctly', function (done) { if (mock) { - server + hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel') .reply(200, " null ") } @@ -416,7 +413,7 @@ describe('pkgcloud/mongolab/databases', function () { function (err) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -424,7 +421,7 @@ describe('pkgcloud/mongolab/databases', function () { it('and delete the other account', function (done) { if (mock) { - server + hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_custompassword') .reply(200, " null "); } @@ -432,7 +429,7 @@ describe('pkgcloud/mongolab/databases', function () { client.deleteAccount(context.custompw.username, function (err, databases) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/openstack/compute/client/startServer-test.js b/test/openstack/compute/client/startServer-test.js index 03cf56c22..4f534c0b9 100644 --- a/test/openstack/compute/client/startServer-test.js +++ b/test/openstack/compute/client/startServer-test.js @@ -11,6 +11,7 @@ var helpers = require('../../../helpers'); var should = require('should'), async = require('async'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; @@ -20,7 +21,7 @@ var options = {}; describe('pkgcloud/common/compute/server[openstack]', function () { - var authServer, server; + var authHockInstance, hockInstance, authServer, server; before(function (done) { @@ -28,28 +29,25 @@ var options = {}; return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } - ], done) + ], done); }); it('the server.startServer() method should start a server instance', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -72,7 +70,7 @@ var options = {}; }) .reply(200, helpers.getOpenstackAuthResponse()); - server + hockInstance .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', {"os-start":null}) .reply(202, ''); } @@ -80,8 +78,8 @@ var options = {}; client.startServer('a2e90ecb69c44d0296072ea39e53704a', function (err) { should.not.exist(err); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -96,10 +94,10 @@ var options = {}; async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/openstack/compute/client/stopServer-test.js b/test/openstack/compute/client/stopServer-test.js index 5bd203f30..c818f15ac 100644 --- a/test/openstack/compute/client/stopServer-test.js +++ b/test/openstack/compute/client/stopServer-test.js @@ -11,6 +11,7 @@ var helpers = require('../../../helpers'); var should = require('should'), async = require('async'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; @@ -20,7 +21,7 @@ var options = {}; describe('pkgcloud/common/compute/server[openstack]', function () { - var authServer, server; + var authHockInstance, hockInstance, authServer, server; before(function (done) { @@ -28,28 +29,25 @@ var options = {}; return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock({ - port: 12345, - throwOnUnmatched: false - }, function (err, hockClient) { - server = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - next(); - }); + authServer.listen(12346, next); } - ], done) + ], done); }); it('the server.stopServer() method should stop a server instance', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -72,7 +70,7 @@ var options = {}; }) .reply(200, helpers.getOpenstackAuthResponse()); - server + hockInstance .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', {"os-stop":null}) .reply(202, ''); } @@ -80,8 +78,8 @@ var options = {}; client.stopServer('a2e90ecb69c44d0296072ea39e53704a', function (err) { should.not.exist(err); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -96,10 +94,10 @@ var options = {}; async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/openstack/identity/identity-test.js b/test/openstack/identity/identity-test.js index 1e24becf7..984bd476d 100644 --- a/test/openstack/identity/identity-test.js +++ b/test/openstack/identity/identity-test.js @@ -3,10 +3,11 @@ var identity = require('../../../lib/pkgcloud/openstack/identity'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; describe('pkgcloud/openstack/identity', function () { - var server, adminServer; + var hockInstance, adminHockInstance, server, adminServer; before(function (done) { @@ -14,32 +15,27 @@ describe('pkgcloud/openstack/identity', function () { return done(); } - async.parallel([ - function(next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + hockInstance = hock.createHock({ throwOnUnmatched: false }); + adminHockInstance = hock.createHock(); - server = hockClient; - next(); - }); - }, - function(next) { - hock.createHock(12347, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + server = http.createServer(hockInstance.handler); + adminServer = http.createServer(adminHockInstance.handler); - adminServer = hockClient; - next(); - }); - }], done); + async.parallel([ + function (next) { + server.listen(12346, next); + }, + function (next) { + adminServer.listen(12347, next); + } + ], done); }); describe('the pkgcloud openstack identity.createIdentity() function', function() { it('with valid inputs should return an identity', function(done) { if (mock) { - server + hockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -72,7 +68,7 @@ describe('pkgcloud/openstack/identity', function () { client.auth(function(err) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -80,7 +76,7 @@ describe('pkgcloud/openstack/identity', function () { it('with no tenants listed from /v2.0/tenants should return an error', function (done) { if (mock) { - server + hockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -104,14 +100,14 @@ describe('pkgcloud/openstack/identity', function () { should.exist(err); err.message.should.equal('Unable to find tenants'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); it('user token should validate with admin token', function(done) { if (mock) { - server + hockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -135,7 +131,7 @@ describe('pkgcloud/openstack/identity', function () { .reply(200, helpers.getOpenstackAuthResponse()); - adminServer + adminHockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -191,7 +187,7 @@ describe('pkgcloud/openstack/identity', function () { it('get the tenant info with admin token', function(done) { if (mock) { - server + hockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -215,7 +211,7 @@ describe('pkgcloud/openstack/identity', function () { .reply(200, helpers.getOpenstackAuthResponse()) - adminServer + adminHockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -288,7 +284,7 @@ describe('pkgcloud/openstack/identity', function () { it('with no active tenants listed from /v2.0/tenants should return an error', function (done) { if (mock) { - server + hockInstance .post('/v2.0/tokens', { auth: { passwordCredentials: { @@ -313,7 +309,7 @@ describe('pkgcloud/openstack/identity', function () { should.exist(err); err.message.should.equal('Unable to find an active tenant'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/rackspace/blockstorage/volumes-test.js b/test/rackspace/blockstorage/volumes-test.js index 6d2e6098d..1487133dc 100644 --- a/test/rackspace/blockstorage/volumes-test.js +++ b/test/rackspace/blockstorage/volumes-test.js @@ -11,13 +11,14 @@ var fs = require('fs'), should = require('should'), async = require('async'), hock = require('hock'), + http = require('http'), helpers = require('../../helpers'), Volume = require('../../../lib/pkgcloud/rackspace/blockstorage/volume').Volume, mock = !!process.env.MOCK; describe('pkgcloud/rackspace/blockstorage/volumes', function () { var client, - testContext = {}, authServer, server; + testContext = {}, authHockInstance, hockInstance, server, authServer; before(function (done) { client = helpers.createClient('rackspace', 'blockstorage'); @@ -26,24 +27,18 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); @@ -52,7 +47,7 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { it('should get an empty list of volumes', function(done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -63,7 +58,7 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v1/123456/volumes') .reply(200, { volumes: [] }); } @@ -73,8 +68,8 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { should.exist(volumes); volumes.should.be.an.Array; volumes.length.should.equal(0); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -82,7 +77,7 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { it('should create a new volume', function (done) { if (mock) { - server + hockInstance .post('/v1/123456/volumes', { volume: { display_name: 'foo3', @@ -102,8 +97,8 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { should.exist(volume); volume.should.be.instanceOf(Volume); volume.name.should.equal('foo3'); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); @@ -111,7 +106,7 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { it('should get a list of volumes', function (done) { if (mock) { - server + hockInstance .get('/v1/123456/volumes') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/volumes.json'); } @@ -123,8 +118,8 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { volumes.forEach(function(volume) { volume.should.be.instanceOf(Volume); }); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -177,10 +172,10 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/compute/authentication-test.js b/test/rackspace/compute/authentication-test.js index 6fdda22ab..1b3ac93d9 100644 --- a/test/rackspace/compute/authentication-test.js +++ b/test/rackspace/compute/authentication-test.js @@ -7,13 +7,14 @@ var should = require('should'), async = require('async'), + http = require('http'), hock = require('hock'), macros = require('../macros'), helpers = require('../../helpers'), mock = !!process.env.MOCK; describe('pkgcloud/rackspace/compute/authentication', function () { - var client, authServer, server; + var client, authHockInstance, hockInstance, authServer, server; describe('The pkgcloud Rackspace Compute client', function () { @@ -24,24 +25,18 @@ describe('pkgcloud/rackspace/compute/authentication', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); @@ -52,7 +47,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { it('the getVersion() method should return the proper version', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -63,7 +58,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v2/') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/versions.json'); } @@ -72,8 +67,8 @@ describe('pkgcloud/rackspace/compute/authentication', function () { should.not.exist(err); should.exist(version); version.should.equal('v2'); - server && server.done(); - authServer && authServer.done(); + hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -88,7 +83,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { client = helpers.createClient('rackspace', 'compute'); if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -102,7 +97,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { client.auth(function (e) { should.not.exist(e); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -113,7 +108,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { it('the getLimits() method should return the proper limits', function (done) { if (mock) { - server + hockInstance .get('/v2/123456/limits') .reply(200, { limits: { absolute: { maxPrivateIPs: 0 }, rate: [] } }, {}); } @@ -124,7 +119,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { should.exist(limits.absolute); should.exist(limits.rate); limits.rate.should.be.an.Array; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -144,7 +139,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { beforeEach(function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -162,7 +157,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { badClient.auth(function (e) { err = e; - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); @@ -194,7 +189,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { tokenExpiry = response.access.token.expires; - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -208,7 +203,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { client.auth(function (e) { should.not.exist(e); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -228,7 +223,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { it('should expire the token and reauth on next call', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -239,7 +234,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v2/123456/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/images.json'); } @@ -250,8 +245,8 @@ describe('pkgcloud/rackspace/compute/authentication', function () { client._isAuthorized().should.equal(true); should.not.exist(err); should.exist(images); - server && server.done(); - authServer && authServer.done(); + hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); done(); }); }, 5); @@ -265,10 +260,10 @@ describe('pkgcloud/rackspace/compute/authentication', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/compute/image-test.js b/test/rackspace/compute/image-test.js index a17dcf9f2..0ee3538c2 100644 --- a/test/rackspace/compute/image-test.js +++ b/test/rackspace/compute/image-test.js @@ -11,12 +11,13 @@ var fs = require('fs'), should = require('should'), async = require('async'), hock = require('hock'), + http = require('http'), helpers = require('../../helpers'), mock = !!process.env.MOCK; describe('pkgcloud/rackspace/compute/images', function () { var client, - testContext = {}, authServer, server; + testContext = {}, authHockInstance, hockInstance, authServer, server; before(function (done) { client = helpers.createClient('rackspace', 'compute'); @@ -25,24 +26,18 @@ describe('pkgcloud/rackspace/compute/images', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); @@ -50,7 +45,7 @@ describe('pkgcloud/rackspace/compute/images', function () { describe('The pkgcloud Rackspace Compute client', function () { before(function(done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -61,7 +56,7 @@ describe('pkgcloud/rackspace/compute/images', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v2/123456/servers/detail') .reply(200, helpers.loadFixture('rackspace/servers.json')); } @@ -71,15 +66,15 @@ describe('pkgcloud/rackspace/compute/images', function () { should.exist(servers); servers.should.be.an.Array; testContext.servers = servers; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); it('the createImage() method with a serverId should create a new image', function(done) { if (mock) { - server + hockInstance .post('/v2/123456/servers/a0a5f183-b94e-4a41-a854-00aa00aa00aa/action', { createImage: { name: 'test-img-id' } }) @@ -97,7 +92,7 @@ describe('pkgcloud/rackspace/compute/images', function () { should.not.exist(err); should.exist(image); testContext.image = image; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -105,14 +100,14 @@ describe('pkgcloud/rackspace/compute/images', function () { after(function(done) { if (mock) { - server + hockInstance .delete('/v2/123456/images/a52cce1f-73fa-49ed-8382-0ab1c9caa322') .reply(204, '', {}); } client.destroyImage(testContext.image, function(err) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -125,10 +120,10 @@ describe('pkgcloud/rackspace/compute/images', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/databases/authentication-test.js b/test/rackspace/databases/authentication-test.js index 99d155083..d42527149 100644 --- a/test/rackspace/databases/authentication-test.js +++ b/test/rackspace/databases/authentication-test.js @@ -10,11 +10,12 @@ var should = require('should'), macros = require('../macros'), async = require('async'), hock = require('hock'), + http = require('http'), helpers = require('../../helpers'), mock = process.env.MOCK; describe('pkgcloud/rackspace/database/authentication', function() { - var client, testContext = {}, authServer, server; + var client, testContext = {}, authHockInstance, hockInstance, authServer, server; before(function(done) { client = helpers.createClient('rackspace', 'database'); @@ -23,27 +24,20 @@ describe('pkgcloud/rackspace/database/authentication', function() { return done(); } - async.parallel([ - function(next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); - authServer = hockClient; - next(); - }); - }, - function(next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); - server = hockClient; - next(); - }); + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); } - ], done) - + ], done); }); describe('The pkgcloud Rackspace Database client', function() { @@ -53,7 +47,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { it('the getVersion() method should return the proper version', function(done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -64,7 +58,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/') .reply(200, { versions: [ @@ -89,8 +83,8 @@ describe('pkgcloud/rackspace/database/authentication', function() { versions.should.be.an.Array; versions.should.have.length(1); - server && server.done(); - authServer && authServer.done(); + hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -103,7 +97,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { beforeEach(function(done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -117,7 +111,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { client.auth(function (e) { err = e; - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); @@ -154,7 +148,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { beforeEach(function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -172,7 +166,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { badClient.auth(function (e) { err = e; - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); @@ -191,10 +185,10 @@ describe('pkgcloud/rackspace/database/authentication', function() { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/databases/databases-test.js b/test/rackspace/databases/databases-test.js index b4ae12793..c79e87c28 100644 --- a/test/rackspace/databases/databases-test.js +++ b/test/rackspace/databases/databases-test.js @@ -8,13 +8,14 @@ var should = require('should'), hock = require('hock'), + http = require('http'), async = require('async'), helpers = require('../../helpers'), mock = !!process.env.MOCK; describe('pkgcloud/rackspace/databases/databases', function() { - var client, testContext = {}, server, authServer; + var client, testContext = {}, hockInstance, authHockInstance, server, authServer; describe('The pkgcloud Rackspace Database client', function() { @@ -25,31 +26,25 @@ describe('pkgcloud/rackspace/databases/databases', function() { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); it('the createDatabases() method should respond correctly', function(done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -60,7 +55,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', @@ -77,8 +72,8 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -87,7 +82,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('create another database for pagination test should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', @@ -104,7 +99,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -113,7 +108,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the create() method should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', @@ -130,7 +125,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -157,7 +152,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the getDatabases() method should return a list of databases', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') @@ -170,7 +165,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.exist(list); list.should.be.an.instanceOf(Array); list.should.have.length(2); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -179,7 +174,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the getDatabases() method should return a list of databases with names', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') @@ -196,7 +191,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.exist(list[0]) list[0].name.should.equal('TestDatabase'); list[0].name.should.be.a.String; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -205,7 +200,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the getDatabases() method with limit should respond one element', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1') @@ -220,7 +215,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.exist(instances); instances.should.be.an.instanceOf(Array); instances.should.have.length(1); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -229,7 +224,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the getDatabases() method with limit should pass as third argument the offset mark', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1') @@ -243,7 +238,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.exist(offset); offset.should.equal('TestDatabase'); testContext.marker = offset; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -252,7 +247,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the getDatabases() method with offset should respond less quantity', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?marker=TestDatabase') @@ -266,7 +261,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.exist(instances); instances.should.have.length(1); should.not.exist(offset); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -276,7 +271,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { 'should respond just one result with no more next points', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1&marker=TestDatabase') @@ -291,7 +286,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { instances.should.be.an.Array; instances.should.have.length(1); should.not.exist(offset); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -300,7 +295,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the destroyDatabase() method with first db should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') @@ -312,7 +307,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -321,7 +316,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { it('the destroyDatabase() method with last db should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') @@ -333,7 +328,7 @@ describe('pkgcloud/rackspace/databases/databases', function() { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -346,10 +341,10 @@ describe('pkgcloud/rackspace/databases/databases', function() { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/databases/flavor-test.js b/test/rackspace/databases/flavor-test.js index b6f72e781..50c0a1880 100644 --- a/test/rackspace/databases/flavor-test.js +++ b/test/rackspace/databases/flavor-test.js @@ -7,14 +7,15 @@ var should = require('should'), hock = require('hock'), + http = require('http'), async = require('async'), helpers = require('../../helpers'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, mock = !!process.env.MOCK; -describe('pkgcloud/rackspace/databases/errors', function () { +describe('pkgcloud/rackspace/databases/flavors', function () { var testContext = {}, - client, authServer, server; + client, authHockInstance, hockInstance, server, authServer; describe('The pkgcloud Rackspace Database client', function () { @@ -25,24 +26,18 @@ describe('pkgcloud/rackspace/databases/errors', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); @@ -50,7 +45,7 @@ describe('pkgcloud/rackspace/databases/errors', function () { function getFlavors(auth, callback) { if (mock) { if (auth) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -62,7 +57,7 @@ describe('pkgcloud/rackspace/databases/errors', function () { .reply(200, helpers.getRackspaceAuthResponse()); } - server + hockInstance .get('/v1.0/123456/flavors') .reply(200, helpers.loadFixture('rackspace/databaseFlavors.json')) } @@ -79,8 +74,8 @@ describe('pkgcloud/rackspace/databases/errors', function () { flavor.should.be.instanceOf(Flavor); }); - server && server.done(); - authServer && authServer.done(); + hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); testContext.flavors = flavors; done(); }); @@ -95,14 +90,14 @@ describe('pkgcloud/rackspace/databases/errors', function () { flavor.ram.should.be.a.Number; flavor.href.should.be.a.String; }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); it('the getFlavor() method should return a valid flavor', function(done) { if (mock) { - server + hockInstance .get('/v1.0/123456/flavors/3') .reply(200, helpers.loadFixture('rackspace/databaseFlavor3.json')); } @@ -112,7 +107,7 @@ describe('pkgcloud/rackspace/databases/errors', function () { should.exist(flavor); flavor.should.be.instanceOf(Flavor); flavor.id.should.equal(testContext.flavors[2].id); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -124,10 +119,10 @@ describe('pkgcloud/rackspace/databases/errors', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/databases/instances-test.js b/test/rackspace/databases/instances-test.js index 60bb19b68..37ad717ce 100644 --- a/test/rackspace/databases/instances-test.js +++ b/test/rackspace/databases/instances-test.js @@ -8,6 +8,7 @@ var should = require('should'), hock = require('hock'), + http = require('http'), async = require('async'), helpers = require('../../helpers'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, @@ -16,7 +17,7 @@ var should = require('should'), describe('pkgcloud/rackspace/databases/instances', function () { var testContext = {}, - client, authServer, server; + client, authHockInstance, hockInstance, authServer, server; describe('The pkgcloud Rackspace Database client', function () { @@ -27,24 +28,18 @@ describe('pkgcloud/rackspace/databases/instances', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); @@ -56,7 +51,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { before(function(done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -67,7 +62,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v1.0/123456/flavors/1') .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) @@ -95,8 +90,8 @@ describe('pkgcloud/rackspace/databases/instances', function () { }, function(e, i) { err = e; instance = i; - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -124,7 +119,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { before(function(done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) } @@ -133,7 +128,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { err = e; instances = i; offset = o; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -188,7 +183,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { before(function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances?limit=2') .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')) } @@ -197,7 +192,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { err = e; instances = i; offset = o; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -220,7 +215,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('should respond correctly', function(done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') @@ -233,7 +228,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { should.not.exist(err); should.exist(result); result.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -244,7 +239,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('should response with details', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') .reply(200, helpers.loadFixture('rackspace/databaseInstance.json')) } @@ -254,7 +249,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { should.exist(instance); instance.should.be.instanceOf(Instance); instance.id.should.equal(testContext.Instance.id); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -264,7 +259,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('with offset should respond less quantity', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262') .reply(200, helpers.loadFixture('rackspace/databaseInstanceOffset.json')) } @@ -275,7 +270,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { instances.should.be.an.Array; should.ok(instances.length >= 2 && instances.length < testContext.instancesQuantity); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); @@ -284,7 +279,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('with limit and offset should respond just one result with more next points', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances?limit=1&marker=55041e91-98ab-4cd5-8148-f3b3978b3262') .reply(200, helpers.loadFixture('rackspace/databaseInstanceLimitOffset.json')) } @@ -295,7 +290,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { instances.should.be.an.Array; should.exist(offset); instances.should.have.length(1); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -312,7 +307,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('without flavor parameter should get errors', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) } @@ -320,7 +315,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { helpers.selectInstance(client, function (instance) { client.setFlavor(instance, function (err) { should.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -329,7 +324,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('without instance parameter should get errors', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/flavors/2') .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) } @@ -340,7 +335,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { client.setFlavor(flavor, function(err) { should.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -349,7 +344,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('with correct inputs should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/flavors/2') @@ -369,7 +364,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { should.exist(flavor); client.setFlavor(instance, flavor, function (err) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -388,7 +383,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('without size parameter should get errors', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) } @@ -396,7 +391,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { helpers.selectInstance(client, function (instance) { client.setVolumeSize(instance, function (err) { should.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -405,7 +400,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('without invalid size parameter should get errors', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) } @@ -413,7 +408,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { helpers.selectInstance(client, function (instance) { client.setVolumeSize(instance, 12, function (err) { should.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -422,7 +417,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('with correct inputs should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { @@ -440,7 +435,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { client.setVolumeSize(instance, newSize, function (err) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -464,7 +459,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('with invalid size should respond with errors', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/flavors/1') .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) } @@ -476,7 +471,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { size: '1' }, function(err) { should.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -493,7 +488,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { it('with valid instance should restart', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) @@ -503,7 +498,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { helpers.selectInstance(client, function (instance) { client.restartInstance(instance, function (err) { should.not.exist(err); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -517,10 +512,10 @@ describe('pkgcloud/rackspace/databases/instances', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/databases/users-test.js b/test/rackspace/databases/users-test.js index 9493655f2..a56abf5f3 100644 --- a/test/rackspace/databases/users-test.js +++ b/test/rackspace/databases/users-test.js @@ -9,13 +9,14 @@ var should = require('should'), async = require('async'), hock = require('hock'), + http = require('http'), helpers = require('../../helpers'), User = require('../../../lib/pkgcloud/rackspace/database/user').User, mock = !!process.env.MOCK; describe('pkgcloud/rackspace/databases/users', function () { var testContext = {}, - client, authServer, server; + client, authHockInstance, hockInstance, authServer, server; describe('The pkgcloud Rackspace Database client', function () { @@ -26,31 +27,25 @@ describe('pkgcloud/rackspace/databases/users', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); it('the createUser() method should respond correctly', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -61,7 +56,7 @@ describe('pkgcloud/rackspace/databases/users', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { @@ -86,8 +81,8 @@ describe('pkgcloud/rackspace/databases/users', function () { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -96,7 +91,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('the createUser() method should work with databases argument', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { @@ -123,8 +118,8 @@ describe('pkgcloud/rackspace/databases/users', function () { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -134,7 +129,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('create an other user for test pagination should response correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { @@ -179,7 +174,7 @@ describe('pkgcloud/rackspace/databases/users', function () { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -189,7 +184,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('create multiple users in one request should response correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { @@ -231,7 +226,7 @@ describe('pkgcloud/rackspace/databases/users', function () { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -240,7 +235,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('create users with questionable characters should respond with error', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); } @@ -254,7 +249,7 @@ describe('pkgcloud/rackspace/databases/users', function () { }, function (err, response) { should.exist(err); should.not.exist(response); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -263,7 +258,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('the getUsers() method should get the list of users', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') @@ -278,7 +273,7 @@ describe('pkgcloud/rackspace/databases/users', function () { list.forEach(function (user) { user.should.be.instanceOf(User); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -291,7 +286,7 @@ describe('pkgcloud/rackspace/databases/users', function () { before(function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') @@ -303,7 +298,7 @@ describe('pkgcloud/rackspace/databases/users', function () { err = e; list = l; offset = o; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -323,7 +318,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('with offset should respond less quantity', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?marker=joeTest') @@ -342,7 +337,7 @@ describe('pkgcloud/rackspace/databases/users', function () { list.should.be.an.Array; list.should.have.length(2); should.not.exist(offset); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -351,7 +346,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('with limit and offset should responsd with just result with more next points', function(done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1&marker=joeTest') @@ -368,7 +363,7 @@ describe('pkgcloud/rackspace/databases/users', function () { list.should.be.an.Array; list.should.have.length(1); should.exist(offset); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -379,7 +374,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('should respond correctly', function(done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') @@ -391,7 +386,7 @@ describe('pkgcloud/rackspace/databases/users', function () { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -400,7 +395,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('should destroy the user used for pagination', function(done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') @@ -412,7 +407,7 @@ describe('pkgcloud/rackspace/databases/users', function () { should.not.exist(err); should.exist(response); response.statusCode.should.equal(202); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -422,7 +417,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('the enableRoot() method should respond correctly', function(done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') @@ -444,7 +439,7 @@ describe('pkgcloud/rackspace/databases/users', function () { response.body.user.should.be.a.Object; should.exist(response.body.user.password); response.body.user.name.should.equal('root'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -453,7 +448,7 @@ describe('pkgcloud/rackspace/databases/users', function () { it('the enableRoot() method should respond correctly', function (done) { if (mock) { - server + hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') @@ -466,7 +461,7 @@ describe('pkgcloud/rackspace/databases/users', function () { should.exist(root); should.exist(response); response.statusCode.should.equal(200); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -479,10 +474,10 @@ describe('pkgcloud/rackspace/databases/users', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/rackspace/storage/authentication-test.js b/test/rackspace/storage/authentication-test.js index d63e28ac0..0146d1078 100644 --- a/test/rackspace/storage/authentication-test.js +++ b/test/rackspace/storage/authentication-test.js @@ -9,6 +9,7 @@ var should = require('should'), macros = require('../macros'), helpers = require('../../helpers'), async = require('async'), + http = require('http'), hock = require('hock'), mock = !!process.env.MOCK; @@ -21,23 +22,22 @@ describe('pkgcloud/rackspace/storage/authentication', function () { describe('the auth() method', function() { describe('with a valid user name and api key', function() { - var authServer; + var authHockInstance, authServer; before(function(done) { if (!mock) { return done(); } - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - done(); - }); + authHockInstance = hock.createHock(); + authServer = http.createServer(authHockInstance.handler); + authServer.listen(12346, done); }); it('should respond with 204 and appropriate info', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -53,14 +53,14 @@ describe('pkgcloud/rackspace/storage/authentication', function () { client.auth(function (err) { should.not.exist(err); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); it('should update the config with appropriate urls', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -76,13 +76,13 @@ describe('pkgcloud/rackspace/storage/authentication', function () { client.auth(function (err) { should.not.exist(err); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); after(function(done) { - if (authServer) { + if (authHockInstance) { authServer.close(function () { done(); }); @@ -94,23 +94,22 @@ describe('pkgcloud/rackspace/storage/authentication', function () { }); describe('with an invalid user name and api key shouldn\'t authenticate', function () { - var authServer; + var authHockInstance, authServer; before(function (done) { if (!mock) { return done(); } - hock.createHock(12346, function (err, hockClient) { - authServer = hockClient; - done(); - }); + authHockInstance = hock.createHock(); + authServer = http.createServer(authHockInstance.handler); + authServer.listen(12346, done); }); it('should respond with 401 unauthorized', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -135,13 +134,13 @@ describe('pkgcloud/rackspace/storage/authentication', function () { badClient.auth(function (err, res) { should.exist(err); - authServer && authServer.done(); + authHockInstance && authHockInstance.done(); done(); }); }); after(function (done) { - if (authServer) { + if (authHockInstance) { authServer.close(function () { done(); }); diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index ece51e321..79475ee0f 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -13,6 +13,7 @@ var path = require('path'), helpers = require('../../helpers'), async = require('async'), hock = require('hock'), + http = require('http'), Container = require('../../../lib/pkgcloud/core/storage/container').Container, mock = !!process.env.MOCK; @@ -23,7 +24,7 @@ if (!mock) { describe('pkgcloud/rackspace/storage/containers', function () { describe('The pkgcloud Rackspace Storage client', function () { - var client, server, authServer; + var client, hockInstance, authHockInstance, authServer, server; before(function (done) { client = helpers.createClient('rackspace', 'storage'); @@ -32,24 +33,18 @@ describe('pkgcloud/rackspace/storage/containers', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); @@ -57,7 +52,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainers should return a list of containers', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -68,7 +63,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getContainers.json'); } @@ -80,8 +75,8 @@ describe('pkgcloud/rackspace/storage/containers', function () { containers.forEach(function(c) { c.should.be.instanceof(Container); }); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -89,7 +84,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainers with options should get CDN attributes and return a list of containers', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getContainers.json') .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') @@ -174,8 +169,8 @@ describe('pkgcloud/rackspace/storage/containers', function () { containers.forEach(function (c) { c.should.be.instanceof(Container); }); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -183,7 +178,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainers with limit should return reduced set', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json&limit=3') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getContainersLimit.json'); } @@ -195,7 +190,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { containers.forEach(function (c) { c.should.be.instanceof(Container); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -203,7 +198,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainers with limit should return reduced set', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json&limit=3') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getContainersLimit.json'); } @@ -215,7 +210,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { containers.forEach(function (c) { c.should.be.instanceof(Container); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -223,7 +218,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainers with marker should start offset appropriately', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json&marker=0.1.3-90') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getContainersMarker.json'); } @@ -235,7 +230,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { containers.forEach(function (c) { c.should.be.instanceof(Container); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -243,7 +238,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainers with marker and limit should start offset appropriatley', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json&limit=4&marker=0.1.3-85') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getContainersLimitMarker.json'); } @@ -255,14 +250,14 @@ describe('pkgcloud/rackspace/storage/containers', function () { containers.forEach(function (c) { c.should.be.instanceof(Container); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); it('getContainer should URL encode container names', function (done) { if (mock) { - server + hockInstance .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/~!%40%23%24%25%5E%26*()_%2B') .reply(200, '', { 'content-length': '0', 'x-container-object-count': '144', @@ -286,7 +281,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); @@ -295,7 +290,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainer should allow 403 cdn response (for ACL)', function (done) { if (mock) { - server + hockInstance .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') .reply(200, '', { 'content-length': '0', 'x-container-object-count': '144', @@ -319,7 +314,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -327,7 +322,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainer should include cdn metadata', function (done) { if (mock) { - server + hockInstance .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') .reply(200, '', { 'content-length': '0', 'x-container-object-count': '144', @@ -365,7 +360,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.cdnEnabled.should.equal(true); container.cdnUri.should.equal('http://cbebcab2b59eae3d0c71-edfcb31ae70ea7c07367728d50539bc7.r63.cf1.rackcdn.com'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -373,7 +368,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainer and enable CDN ', function (done) { if (mock) { - server + hockInstance .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') .reply(200, '', { 'content-length': '0', 'x-container-object-count': '144', @@ -436,7 +431,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.cdnEnabled.should.equal(true); container.cdnUri.should.equal('http://cbebcab2b59eae3d0c71-edfcb31ae70ea7c07367728d50539bc7.r63.cf1.rackcdn.com'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -445,7 +440,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainer and set static website index page and error page ', function (done) { if (mock) { - server + hockInstance .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') .reply(200, '', { 'content-length': '0', 'x-container-object-count': '144', @@ -505,7 +500,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.metadata['web-index'].should.equal('index.htm'); container.metadata['web-error'].should.equal('error.htm'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -514,7 +509,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('getContainer and remove static website', function (done) { if (mock) { - server + hockInstance .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.3-85') .reply(200, '', { 'content-length': '0', 'x-container-object-count': '144', @@ -572,7 +567,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { (container.metadata['web-index'] == undefined).should.be.true; (container.metadata['web-error'] == undefined).should.be.true; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); diff --git a/test/rackspace/storage/storage-object-test.js b/test/rackspace/storage/storage-object-test.js index baf544645..96e8f9988 100755 --- a/test/rackspace/storage/storage-object-test.js +++ b/test/rackspace/storage/storage-object-test.js @@ -12,6 +12,7 @@ var path = require('path'), pkgcloud = require('../../../lib/pkgcloud'), helpers = require('../../helpers'), async = require('async'), + http = require('http'), hock = require('hock'), File = require('../../../lib/pkgcloud/core/storage/file').File, mock = !!process.env.MOCK, @@ -24,7 +25,7 @@ if (!mock) { describe('pkgcloud/rackspace/storage/storage-object', function () { describe('The pkgcloud Rackspace Storage client', function () { - var client, server, authServer; + var client, hockInstance, authHockInstance, server, authServer; /** * Generates a container file list response of specified size for large container tests. @@ -60,24 +61,18 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { return done(); } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ function (next) { - hock.createHock(12346, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - authServer = hockClient; - next(); - }); + server.listen(12345, next); }, function (next) { - hock.createHock(12345, function (err, hockClient) { - should.not.exist(err); - should.exist(hockClient); - - server = hockClient; - next(); - }); + authServer.listen(12346, next); } ], done); }); @@ -85,7 +80,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { it('getFiles should return a list of files', function (done) { if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -96,7 +91,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getFiles.json'); } @@ -108,8 +103,8 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { files.forEach(function (f) { f.should.be.instanceof(File); }); - authServer && authServer.done(); - server && server.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -120,7 +115,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { return done(); } - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json') .reply(200, generateFilesResponse(0, 10000)); @@ -128,7 +123,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { should.not.exist(err); should.exist(files); files.length.should.equal(10000); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -136,7 +131,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { it('getFiles with limit should return reduced set', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json&limit=3') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getContainersLimit.json'); } @@ -148,7 +143,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { files.forEach(function (f) { f.should.be.instanceof(File); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -159,7 +154,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { return done(); } - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json') .reply(200, generateFilesResponse(0, 10000)) .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json&marker=FILE09999') @@ -171,7 +166,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { should.not.exist(err); should.exist(files); files.should.have.length(23400); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -182,7 +177,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { return done(); } - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json') .reply(200, generateFilesResponse(0, 10000)) .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json&marker=FILE09999') @@ -194,7 +189,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { should.not.exist(err); should.exist(files); files.should.have.length(20000); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -202,7 +197,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { it('getFiles with marker should start offset appropriately', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json&marker=ubuntu-10.04-x86_64%2Fconf%2Fdistributions') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getFilesMarker.json'); } @@ -214,7 +209,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { files.forEach(function (f) { f.should.be.instanceof(File); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -222,7 +217,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { it('getFiles with marker and limit should start offset appropriately', function (done) { if (mock) { - server + hockInstance .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215?format=json&limit=4&marker=CHANGELOG') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/getFilesLimitMarker.json'); } @@ -234,14 +229,14 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { files.forEach(function (f) { f.should.be.instanceof(File); }); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); it('getFile should URL encode the file name', function (done) { if (mock) { - server + hockInstance .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/0.1.7-215/~!%40%23%24%25%5E%26*()_%2B/~!%40%23%24%25%5E%26*()_%2B?format=json') .reply(200); } @@ -250,7 +245,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { should.not.exist(err); should.exist(file); file.should.be.instanceof(File); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -262,7 +257,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { fs.writeFileSync(tmp, new Buffer(data, "base64")); if (mock) { - authServer + authHockInstance .post('/v2.0/tokens', { auth: { 'RAX-KSKEY:apiKeyCredentials': { @@ -273,7 +268,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { }) .reply(200, helpers.getRackspaceAuthResponse()); - server + hockInstance .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?extract-archive=tar.gz', new Buffer(data, "base64").toString()) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/extract.json'); } @@ -285,7 +280,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { }, function(e, ok, resp) { should.not.exist(e); should.exist(resp); - server && server.done(); + hockInstance && hockInstance.done(); fs.unlinkSync(tmp); done(); @@ -301,10 +296,10 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { async.parallel([ function (next) { - authServer.close(next); + server.close(next); }, function (next) { - server.close(next); + authServer.close(next); } ], done) }); diff --git a/test/redistogo/databases/databases-test.js b/test/redistogo/databases/databases-test.js index fec3a795b..06c09be6d 100644 --- a/test/redistogo/databases/databases-test.js +++ b/test/redistogo/databases/databases-test.js @@ -9,22 +9,23 @@ var should = require('should'), helpers = require('../../helpers'), hock = require('hock'), + http = require('http'), mock = !!process.env.MOCK; describe('pkgcloud/redistogo/databases', function () { var testContext = {}, client = helpers.createClient('redistogo', 'database'), - server = null; + hockInstance = null, + server; before(function(done) { if (!mock) { return done(); } - hock.createHock(12345, function(err, hockClient) { - server = hockClient; - done(); - }); + hockInstance = hock.createHock(); + server = http.createServer(hockInstance.handler); + server.listen(12345, done); }); @@ -33,7 +34,7 @@ describe('pkgcloud/redistogo/databases', function () { it('with correct options should respond correctly', function(done) { if (mock) { - server + hockInstance .post('/instances.json', "instance%5Bplan%5D=nano") .replyWithFile(201, __dirname + '/../../fixtures/redistogo/database.json'); } @@ -46,7 +47,7 @@ describe('pkgcloud/redistogo/databases', function () { should.exist(database.username); should.exist(database.password); testContext.databaseId = database.id; - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -63,7 +64,7 @@ describe('pkgcloud/redistogo/databases', function () { describe('the get() method', function() { it('with correct options should respond correctly', function(done) { if (mock) { - server + hockInstance .get('/instances/253739.json') .replyWithFile(200, __dirname + '/../../fixtures/redistogo/database.json'); } @@ -75,7 +76,7 @@ describe('pkgcloud/redistogo/databases', function () { should.exist(database.uri); should.exist(database.username); should.exist(database.password); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -92,7 +93,7 @@ describe('pkgcloud/redistogo/databases', function () { describe('the remove() method', function () { it('with correct options should respond correctly', function (done) { if (mock) { - server + hockInstance .delete('/instances/253739.json') .reply(200); } @@ -101,7 +102,7 @@ describe('pkgcloud/redistogo/databases', function () { should.not.exist(err); should.exist(confirm); confirm.should.equal('deleted'); - server && server.done(); + hockInstance && hockInstance.done(); done(); }); }); @@ -117,7 +118,7 @@ describe('pkgcloud/redistogo/databases', function () { }); after(function(done) { - if (server) { + if (hockInstance) { server.close(function() { done(); }); From ccb911d6d361e5cf30450a95cbcaa0728d3d02ba Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 15 Sep 2014 09:06:17 -0700 Subject: [PATCH 126/460] First commit using aws-sdk in lieu of home-grown aws impl --- .../amazon/storage/client/containers.js | 28 +- lib/pkgcloud/amazon/storage/client/files.js | 23 +- lib/pkgcloud/amazon/storage/client/index.js | 18 +- lib/pkgcloud/amazon/storage/container.js | 10 +- lib/pkgcloud/amazon/storage/file.js | 10 +- lib/pkgcloud/openstack/storage/container.js | 2 +- package.json | 86 ++- test/common/storage/base-test.js | 559 +++++++++--------- 8 files changed, 389 insertions(+), 347 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index 0bac80377..8d6f2d873 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -19,20 +19,19 @@ var async = require('async'), exports.getContainers = function (callback) { var self = this; - this._xmlRequest({ - path: '/' - }, function (err, body) { + self.s3.listBuckets(function(err, data) { if (err) { - return callback(err); + callback(err); + return; } - var containers = self._toArray(body.Buckets.Bucket); + var containers = data.Buckets; - containers = containers.map(function (container) { + containers = containers.map(function(container) { return new (storage.Container)(self, container); }); - callback(null, containers); + callback(err, containers); }); }; @@ -47,12 +46,12 @@ exports.getContainer = function (container, callback) { var containerName = container instanceof storage.Container ? container.name : container, self = this; - this._xmlRequest({ - container: containerName - }, function (err, body) { + self.s3.listObjects({ + Bucket: containerName + }, function(err, data) { return err ? callback(err) - : callback(null, new (storage.Container)(self, body)); + : callback(null, new (storage.Container)(self, data)); }); }; @@ -67,10 +66,9 @@ exports.createContainer = function (options, callback) { var containerName = options instanceof base.Container ? options.name : options, self = this; - this._xmlRequest({ - method: 'PUT', - container: containerName - }, function (err) { + self.s3.createBucket({ + Bucket: containerName + }, function(err) { return err ? callback(err) : callback(null, new (storage.Container)(self, options)); diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 79059c1a3..9087668cf 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -333,19 +333,16 @@ exports.getFile = function (container, file, callback) { var containerName = container instanceof base.Container ? container.name : container, self = this; - this._request( - { - method: 'HEAD', - container: containerName, - path: file - }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, new storage.File(self, _.extend(res.headers, { - container: container, - name: file - }))); + self.s3.headObject({ + Bucket: containerName, + Key: file + }, function(err, data) { + return err + ? callback(err) + : callback(null, new storage.File(self, _.extend(data, { + container: container, + name: file + }))); }); }; diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index d10acbdb1..9dfa6dcf4 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -8,19 +8,27 @@ var util = require('util'), urlJoin = require('url-join'), xml2js = require('xml2js'), + AWS = require('aws-sdk'), auth = require('../../../common/auth'), amazon = require('../../client'), _ = require('underscore'); var Client = exports.Client = function (options) { - this.serversUrl = 's3.amazonaws.com'; - - amazon.Client.call(this, options); - _.extend(this, require('./containers')); _.extend(this, require('./files')); - this.before.push(auth.amazon.headersSignature); + AWS.config.update({ accessKeyId: options.keyId, secretAccessKey: options.key }); + AWS.config.update({ region: options.region }); + + if (options.serversUrl) { + AWS.config.update({ + httpOptions: { + proxy: options.protocol ? options.protocol + options.serversUrl : 'https://' + options.serversUrl + } + }); + } + + this.s3 = new AWS.S3(); }; util.inherits(Client, amazon.Client); diff --git a/lib/pkgcloud/amazon/storage/container.js b/lib/pkgcloud/amazon/storage/container.js index d3e584437..8942469a6 100644 --- a/lib/pkgcloud/amazon/storage/container.js +++ b/lib/pkgcloud/amazon/storage/container.js @@ -7,7 +7,8 @@ var util = require('util'), storage = require('../storage'), - base = require('../../core/storage/container'); + base = require('../../core/storage/container'), + _ = require('underscore'); var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); @@ -33,9 +34,14 @@ Container.prototype._setProperties = function (details) { this.isTruncated = details.IsTruncated === 'true'; if (details.Contents) { - this.client._toArray(details.Contents).forEach(function (file) { + details.Contents.forEach(function (file) { file.container = self; self.files.push(new storage.File(self.client, file)); }); } }; + +Container.prototype.toJSON = function () { + return _.pick(this, ['name', 'maxKeys', 'isTruncated' ]); +}; + diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index b36531694..cfcdaec14 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -6,7 +6,8 @@ */ var util = require('util'), - base = require('../../core/storage/file'); + base = require('../../core/storage/file'), + _ = require('underscore'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); @@ -19,11 +20,16 @@ File.prototype._setProperties = function (details) { this.name = details.name || details.Key; this.etag = details.ETag || details.etag || null; + this.lastModified = details.LastModified || details.lastModified || null; this.size = +(details.Size || details['content-length']) || 0; this.container = details.container; // amazon appears to send the etag double enquoted this.etag = this.etag ? this.etag.replace(/"/g,'') : this.etag; // AWS Specific - this.storageClass = this.StorageClass; + this.storageClass = details.StorageClass || this.StorageClass; }; + +File.prototype.toJSON = function () { + return _.pick(this, ['name', 'etag', 'size', 'storageClass', 'lastModified' ]); +}; \ No newline at end of file diff --git a/lib/pkgcloud/openstack/storage/container.js b/lib/pkgcloud/openstack/storage/container.js index f9d5e3a9f..4808eae6a 100644 --- a/lib/pkgcloud/openstack/storage/container.js +++ b/lib/pkgcloud/openstack/storage/container.js @@ -28,7 +28,7 @@ Container.prototype._setProperties = function (details) { this.name = details.name || this.name; this.ttl = details.ttl || this.ttl; this.logRetention = details.logRetention || this.logRetention; - this.count = details.count || this.count || 0 + this.count = details.count || this.count || 0; this.bytes = details.bytes || this.bytes || 0; this.metadata = details.metadata || this.metadata || {}; }; diff --git a/package.json b/package.json index 5168237cd..c56c5dfdb 100644 --- a/package.json +++ b/package.json @@ -1,56 +1,80 @@ { - "name": "pkgcloud", + "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "0.9.6", - "author": "Nodejitsu Inc ", + "version": "0.9.6", + "author": "Nodejitsu Inc ", "contributors": [ - { "name": "Charlie Robbins", "email": "charlie@nodejitsu.com" }, - { "name": "Nuno Job", "email": "nuno@nodejitsu.com" }, - { "name": "Daniel Aristizabal", "email": "daniel@nodejitsu.com" }, - { "name": "Ken Perkins", "email": "ken.perkins@rackspace.com" } + { + "name": "Charlie Robbins", + "email": "charlie@nodejitsu.com" + }, + { + "name": "Nuno Job", + "email": "nuno@nodejitsu.com" + }, + { + "name": "Daniel Aristizabal", + "email": "daniel@nodejitsu.com" + }, + { + "name": "Ken Perkins", + "email": "ken.perkins@rackspace.com" + } ], "repository": { "type": "git", - "url" : "http://github.com/pkgcloud/pkgcloud.git" + "url": "http://github.com/pkgcloud/pkgcloud.git" }, "keywords": [ - "cloud", "cloud computing", - "api", "rackspace", - "joyent", "aws", - "amazon", "azure", - "iaas", "servers", - "compute", "storage", - "databases", "client", - "mongolab", "iriscouch", - "mongohq", "openstack", + "cloud", + "cloud computing", + "api", + "rackspace", + "joyent", + "aws", + "amazon", + "azure", + "iaas", + "servers", + "compute", + "storage", + "databases", + "client", + "mongolab", + "iriscouch", + "mongohq", + "openstack", "redistogo" ], "dependencies": { - "async": "0.9.x", - "errs": "0.3.x", + "async": "0.9.x", + "errs": "0.3.x", "eventemitter2": "0.4.x", - "filed": "0.1.x", - "ip": "0.3.x", - "xml2js": "0.1.x", - "mime": "1.2.x", - "through": "2.3.x", - "qs": "1.2.x", - "request": "2.40.x", - "underscore": "1.6.x", - "url-join": "0.0.x" + "filed": "0.1.x", + "ip": "0.3.x", + "xml2js": "0.1.x", + "mime": "1.2.x", + "through": "2.3.x", + "qs": "1.2.x", + "request": "2.40.x", + "underscore": "1.6.x", + "url-join": "0.0.x", + "aws-sdk": "~2.0.17" }, "devDependencies": { - "hock" : "1.0.x", + "hock": "1.0.x", "mocha": "1.21.x", "should": "4.0.x", "mocha-lcov-reporter": "0.0.1", "coveralls": "2.x.x" }, - "main": "./lib/pkgcloud", + "main": "./lib/pkgcloud", "scripts": { "test": "make test", "test-cov": "make test-cov", "test-coveralls": "make test-coveralls" }, - "engines": { "node": "0.8.x || 0.10.x" } + "engines": { + "node": "0.8.x || 0.10.x" + } } diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 4dfde8341..4c8570ac1 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -47,6 +47,9 @@ providers.filter(function (provider) { server = http.createServer(hockInstance.handler); authServer = http.createServer(authHockInstance.handler); + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); + async.parallel([ function (next) { server.listen(12345, next); @@ -114,118 +117,118 @@ providers.filter(function (provider) { }); }); - - it('the upload() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupUploadStreamMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - var stream = client.upload({ - container: context.container, - remote: 'test-file.txt', - headers: {'x-amz-acl': 'public-read'} - }, function(err, ok, response) { - should.not.exist(err); - should.exist(ok); - - context.file = { - name: 'test-file.txt', - size: Buffer.byteLength(fillerama) - }; - - should.exist(response); - should.exist(response.statusCode); - should.exist(response.headers); - - hockInstance && hockInstance.done(); - done(); - }); - - var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); - file.pipe(stream); - }); - - it('the download() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupDownloadStreamMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - var stream = client.download({ - container: context.container, - remote: context.file.name - }, function (err, file) { - should.not.exist(err); - should.exist(file); - - file.name.should.equal(context.file.name); - context.fileContents.should.equal(fillerama); - file.size.should.equal(Buffer.byteLength(context.fileContents)); - - hockInstance && hockInstance.done(); - done(); - }); - - context.fileContents = ''; - stream.on('data', function (data) { - context.fileContents += data; - }); - stream.end(); - }); - - it('the download() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupDownloadStreamMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - var stream = client.download({ - container: context.container, - remote: context.file.name - }, function (err, file) { - should.not.exist(err); - should.exist(file); - - file.name.should.equal(context.file.name); - context.fileContents.should.equal(fillerama); - file.size.should.equal(Buffer.byteLength(context.fileContents)); - - hockInstance && hockInstance.done(); - done(); - }); - - context.fileContents = ''; - stream.on('data', function (data) { - context.fileContents += data; - }); - stream.end(); - }); - +// +// it('the upload() method with container and filename should succeed', function (done) { +// +// if (mock) { +// if (provider === 'joyent') { +// // TODO figure out why joyent was disabled in vows based tests +// return done(); +// } +// +// setupUploadStreamMock(provider, client, { +// server: hockInstance, +// authServer: authHockInstance +// }); +// } +// +// var stream = client.upload({ +// container: context.container, +// remote: 'test-file.txt', +// headers: {'x-amz-acl': 'public-read'} +// }, function(err, ok, response) { +// should.not.exist(err); +// should.exist(ok); +// +// context.file = { +// name: 'test-file.txt', +// size: Buffer.byteLength(fillerama) +// }; +// +// should.exist(response); +// should.exist(response.statusCode); +// should.exist(response.headers); +// +// hockInstance && hockInstance.done(); +// done(); +// }); +// +// var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); +// file.pipe(stream); +// }); +// +// it('the download() method with container and filename should succeed', function (done) { +// +// if (mock) { +// if (provider === 'joyent') { +// // TODO figure out why joyent was disabled in vows based tests +// return done(); +// } +// +// setupDownloadStreamMock(provider, client, { +// server: hockInstance, +// authServer: authHockInstance +// }); +// } +// +// var stream = client.download({ +// container: context.container, +// remote: context.file.name +// }, function (err, file) { +// should.not.exist(err); +// should.exist(file); +// +// file.name.should.equal(context.file.name); +// context.fileContents.should.equal(fillerama); +// file.size.should.equal(Buffer.byteLength(context.fileContents)); +// +// hockInstance && hockInstance.done(); +// done(); +// }); +// +// context.fileContents = ''; +// stream.on('data', function (data) { +// context.fileContents += data; +// }); +// stream.end(); +// }); +// +// it('the download() method with container and filename should succeed', function (done) { +// +// if (mock) { +// if (provider === 'joyent') { +// // TODO figure out why joyent was disabled in vows based tests +// return done(); +// } +// +// setupDownloadStreamMock(provider, client, { +// server: hockInstance, +// authServer: authHockInstance +// }); +// } +// +// var stream = client.download({ +// container: context.container, +// remote: context.file.name +// }, function (err, file) { +// should.not.exist(err); +// should.exist(file); +// +// file.name.should.equal(context.file.name); +// context.fileContents.should.equal(fillerama); +// file.size.should.equal(Buffer.byteLength(context.fileContents)); +// +// hockInstance && hockInstance.done(); +// done(); +// }); +// +// context.fileContents = ''; +// stream.on('data', function (data) { +// context.fileContents += data; +// }); +// stream.end(); +// }); +// it('the getFile() method with container and filename should succeed', function (done) { if (mock) { @@ -251,172 +254,172 @@ providers.filter(function (provider) { done(); }); }); - - it('the getFiles() method with container should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupGetFilesMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.getFiles(context.container, false, function (err, files) { - should.not.exist(err); - should.exist(files); - - files.should.be.an.Array; - - files.forEach(function(file) { - file.should.be.instanceOf(File); - }) - - // TODO look for context.file in array - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the removeFile() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupRemoveFileMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.removeFile(context.container, context.file.name, function (err, ok) { - should.not.exist(err); - should.exist(ok); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the upload() method with large file should succeed', function (done) { - - if (mock) { - return done(); - // TODO mock these out - } - - var stream = client.upload({ - container: context.container, - remote: 'bigfile.raw' - }, function (err, ok) { - should.not.exist(err); - should.exist(ok); - - context.file = { - name: 'bigfile.raw', - size: fs.readFileSync(helpers.fixturePath('bigfile.raw')).length - }; - - done(); - }); - - var file = fs.createReadStream(helpers.fixturePath('bigfile.raw')); - file.pipe(stream); - }); - - it('the download() method with large file should succeed', function (done) { - - if (mock) { - return done(); - // TODO mock these out - } - - var stream = client.download({ - container: context.container, - remote: context.file.name - }, function (err, file) { - - should.not.exist(err); - should.exist(file); - file.should.be.instanceOf(File); - - file.name.should.equal(context.file.name); - file.size.should.equal(context.fileContentsSize); - - context.fileContents = Buffer.concat(context.fileContents, - file.size); - - // Compare byte by byte - var original = fs.readFileSync(helpers.fixturePath('bigfile.raw')); - for (var i = 0; i < file.size; i++) { - assert.equal(context.fileContents[i], original[i]); - } - - done(); - }); - - context.fileContents = []; - context.fileContentsSize = 0; - stream.on('data', function (data) { - context.fileContents.push(data); - context.fileContentsSize += data.length; - }); - stream.end(); - }); - - it('the destroyContainer() method with container should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupDestroyContainerMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.destroyContainer(context.container, function (err, ok) { - should.not.exist(err); - should.exist(ok); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the getContainers() method should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupGetContainers2Mock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.getContainers(function (err, ok) { - should.not.exist(err); - should.exist(ok); - - hockInstance && hockInstance.done(); - done(); - }); - }); +// +// it('the getFiles() method with container should succeed', function (done) { +// +// if (mock) { +// if (provider === 'joyent') { +// // TODO figure out why joyent was disabled in vows based tests +// return done(); +// } +// +// setupGetFilesMock(provider, client, { +// server: hockInstance, +// authServer: authHockInstance +// }); +// } +// +// client.getFiles(context.container, false, function (err, files) { +// should.not.exist(err); +// should.exist(files); +// +// files.should.be.an.Array; +// +// files.forEach(function(file) { +// file.should.be.instanceOf(File); +// }) +// +// // TODO look for context.file in array +// +// hockInstance && hockInstance.done(); +// done(); +// }); +// }); +// +// it('the removeFile() method with container and filename should succeed', function (done) { +// +// if (mock) { +// if (provider === 'joyent') { +// // TODO figure out why joyent was disabled in vows based tests +// return done(); +// } +// +// setupRemoveFileMock(provider, client, { +// server: hockInstance, +// authServer: authHockInstance +// }); +// } +// +// client.removeFile(context.container, context.file.name, function (err, ok) { +// should.not.exist(err); +// should.exist(ok); +// +// hockInstance && hockInstance.done(); +// done(); +// }); +// }); +// +// it('the upload() method with large file should succeed', function (done) { +// +// if (mock) { +// return done(); +// // TODO mock these out +// } +// +// var stream = client.upload({ +// container: context.container, +// remote: 'bigfile.raw' +// }, function (err, ok) { +// should.not.exist(err); +// should.exist(ok); +// +// context.file = { +// name: 'bigfile.raw', +// size: fs.readFileSync(helpers.fixturePath('bigfile.raw')).length +// }; +// +// done(); +// }); +// +// var file = fs.createReadStream(helpers.fixturePath('bigfile.raw')); +// file.pipe(stream); +// }); +// +// it('the download() method with large file should succeed', function (done) { +// +// if (mock) { +// return done(); +// // TODO mock these out +// } +// +// var stream = client.download({ +// container: context.container, +// remote: context.file.name +// }, function (err, file) { +// +// should.not.exist(err); +// should.exist(file); +// file.should.be.instanceOf(File); +// +// file.name.should.equal(context.file.name); +// file.size.should.equal(context.fileContentsSize); +// +// context.fileContents = Buffer.concat(context.fileContents, +// file.size); +// +// // Compare byte by byte +// var original = fs.readFileSync(helpers.fixturePath('bigfile.raw')); +// for (var i = 0; i < file.size; i++) { +// assert.equal(context.fileContents[i], original[i]); +// } +// +// done(); +// }); +// +// context.fileContents = []; +// context.fileContentsSize = 0; +// stream.on('data', function (data) { +// context.fileContents.push(data); +// context.fileContentsSize += data.length; +// }); +// stream.end(); +// }); +// +// it('the destroyContainer() method with container should succeed', function (done) { +// +// if (mock) { +// if (provider === 'joyent') { +// // TODO figure out why joyent was disabled in vows based tests +// return done(); +// } +// +// setupDestroyContainerMock(provider, client, { +// server: hockInstance, +// authServer: authHockInstance +// }); +// } +// +// client.destroyContainer(context.container, function (err, ok) { +// should.not.exist(err); +// should.exist(ok); +// +// hockInstance && hockInstance.done(); +// done(); +// }); +// }); +// +// it('the getContainers() method should succeed', function (done) { +// +// if (mock) { +// if (provider === 'joyent') { +// // TODO figure out why joyent was disabled in vows based tests +// return done(); +// } +// +// setupGetContainers2Mock(provider, client, { +// server: hockInstance, +// authServer: authHockInstance +// }); +// } +// +// client.getContainers(function (err, ok) { +// should.not.exist(err); +// should.exist(ok); +// +// hockInstance && hockInstance.done(); +// done(); +// }); +// }); after(function (done) { if (!mock) { From e8eba23f6d639e2c607a4b5968aba39afa1808a0 Mon Sep 17 00:00:00 2001 From: Deniz Ozger Date: Mon, 15 Sep 2014 17:39:53 +0100 Subject: [PATCH 127/460] Options parameter in files.getFiles() is now optional In spec, options parameter appears to be optional (https://github.com/pkgcloud/pkgcloud/blob/master/docs/providers/rackspace/storage.md#clientgetfilescontainer-options-functionerr-files--), however if null is passed, the method generates "TypeError: Cannot read property 'limit' of null". --- lib/pkgcloud/openstack/storage/client/files.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index ad51f9ff0..e3e9ba43a 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -244,6 +244,8 @@ exports.getFiles = function (container, options, callback) { if (typeof options === 'function') { callback = options; options = {}; + } else if (!options) { + options = {}; } // If limit is not specified, or it is <=10k, just make a single request From ad37634e2056f8d8beef57de7d74837e7049519b Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 15 Sep 2014 10:24:45 -0700 Subject: [PATCH 128/460] Ensuring backwards compat for non-ported aws methods --- lib/pkgcloud/amazon/storage/client/index.js | 5 + lib/pkgcloud/amazon/storage/file.js | 2 +- test/common/storage/base-test.js | 556 ++++++++++---------- 3 files changed, 284 insertions(+), 279 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index 9dfa6dcf4..ad7123e69 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -14,6 +14,10 @@ var util = require('util'), _ = require('underscore'); var Client = exports.Client = function (options) { + this.serversUrl = 's3.amazonaws.com'; + + amazon.Client.call(this, options); + _.extend(this, require('./containers')); _.extend(this, require('./files')); @@ -28,6 +32,7 @@ var Client = exports.Client = function (options) { }); } + this.before.push(auth.amazon.headersSignature); this.s3 = new AWS.S3(); }; diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index cfcdaec14..c0f94d389 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -21,7 +21,7 @@ File.prototype._setProperties = function (details) { this.name = details.name || details.Key; this.etag = details.ETag || details.etag || null; this.lastModified = details.LastModified || details.lastModified || null; - this.size = +(details.Size || details['content-length']) || 0; + this.size = +(details.Size || details['content-length'] || details.ContentLength) || 0; this.container = details.container; // amazon appears to send the etag double enquoted diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 4c8570ac1..190de092d 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -117,118 +117,118 @@ providers.filter(function (provider) { }); }); -// -// it('the upload() method with container and filename should succeed', function (done) { -// -// if (mock) { -// if (provider === 'joyent') { -// // TODO figure out why joyent was disabled in vows based tests -// return done(); -// } -// -// setupUploadStreamMock(provider, client, { -// server: hockInstance, -// authServer: authHockInstance -// }); -// } -// -// var stream = client.upload({ -// container: context.container, -// remote: 'test-file.txt', -// headers: {'x-amz-acl': 'public-read'} -// }, function(err, ok, response) { -// should.not.exist(err); -// should.exist(ok); -// -// context.file = { -// name: 'test-file.txt', -// size: Buffer.byteLength(fillerama) -// }; -// -// should.exist(response); -// should.exist(response.statusCode); -// should.exist(response.headers); -// -// hockInstance && hockInstance.done(); -// done(); -// }); -// -// var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); -// file.pipe(stream); -// }); -// -// it('the download() method with container and filename should succeed', function (done) { -// -// if (mock) { -// if (provider === 'joyent') { -// // TODO figure out why joyent was disabled in vows based tests -// return done(); -// } -// -// setupDownloadStreamMock(provider, client, { -// server: hockInstance, -// authServer: authHockInstance -// }); -// } -// -// var stream = client.download({ -// container: context.container, -// remote: context.file.name -// }, function (err, file) { -// should.not.exist(err); -// should.exist(file); -// -// file.name.should.equal(context.file.name); -// context.fileContents.should.equal(fillerama); -// file.size.should.equal(Buffer.byteLength(context.fileContents)); -// -// hockInstance && hockInstance.done(); -// done(); -// }); -// -// context.fileContents = ''; -// stream.on('data', function (data) { -// context.fileContents += data; -// }); -// stream.end(); -// }); -// -// it('the download() method with container and filename should succeed', function (done) { -// -// if (mock) { -// if (provider === 'joyent') { -// // TODO figure out why joyent was disabled in vows based tests -// return done(); -// } -// -// setupDownloadStreamMock(provider, client, { -// server: hockInstance, -// authServer: authHockInstance -// }); -// } -// -// var stream = client.download({ -// container: context.container, -// remote: context.file.name -// }, function (err, file) { -// should.not.exist(err); -// should.exist(file); -// -// file.name.should.equal(context.file.name); -// context.fileContents.should.equal(fillerama); -// file.size.should.equal(Buffer.byteLength(context.fileContents)); -// -// hockInstance && hockInstance.done(); -// done(); -// }); -// -// context.fileContents = ''; -// stream.on('data', function (data) { -// context.fileContents += data; -// }); -// stream.end(); -// }); -// + + it('the upload() method with container and filename should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupUploadStreamMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + var stream = client.upload({ + container: context.container, + remote: 'test-file.txt', + headers: {'x-amz-acl': 'public-read'} + }, function(err, ok, response) { + should.not.exist(err); + should.exist(ok); + + context.file = { + name: 'test-file.txt', + size: Buffer.byteLength(fillerama) + }; + + should.exist(response); + should.exist(response.statusCode); + should.exist(response.headers); + + hockInstance && hockInstance.done(); + done(); + }); + + var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); + file.pipe(stream); + }); + + it('the download() method with container and filename should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupDownloadStreamMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + var stream = client.download({ + container: context.container, + remote: context.file.name + }, function (err, file) { + should.not.exist(err); + should.exist(file); + + file.name.should.equal(context.file.name); + context.fileContents.should.equal(fillerama); + file.size.should.equal(Buffer.byteLength(context.fileContents)); + + hockInstance && hockInstance.done(); + done(); + }); + + context.fileContents = ''; + stream.on('data', function (data) { + context.fileContents += data; + }); + stream.end(); + }); + + it('the download() method with container and filename should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupDownloadStreamMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + var stream = client.download({ + container: context.container, + remote: context.file.name + }, function (err, file) { + should.not.exist(err); + should.exist(file); + + file.name.should.equal(context.file.name); + context.fileContents.should.equal(fillerama); + file.size.should.equal(Buffer.byteLength(context.fileContents)); + + hockInstance && hockInstance.done(); + done(); + }); + + context.fileContents = ''; + stream.on('data', function (data) { + context.fileContents += data; + }); + stream.end(); + }); + it('the getFile() method with container and filename should succeed', function (done) { if (mock) { @@ -254,172 +254,172 @@ providers.filter(function (provider) { done(); }); }); -// -// it('the getFiles() method with container should succeed', function (done) { -// -// if (mock) { -// if (provider === 'joyent') { -// // TODO figure out why joyent was disabled in vows based tests -// return done(); -// } -// -// setupGetFilesMock(provider, client, { -// server: hockInstance, -// authServer: authHockInstance -// }); -// } -// -// client.getFiles(context.container, false, function (err, files) { -// should.not.exist(err); -// should.exist(files); -// -// files.should.be.an.Array; -// -// files.forEach(function(file) { -// file.should.be.instanceOf(File); -// }) -// -// // TODO look for context.file in array -// -// hockInstance && hockInstance.done(); -// done(); -// }); -// }); -// -// it('the removeFile() method with container and filename should succeed', function (done) { -// -// if (mock) { -// if (provider === 'joyent') { -// // TODO figure out why joyent was disabled in vows based tests -// return done(); -// } -// -// setupRemoveFileMock(provider, client, { -// server: hockInstance, -// authServer: authHockInstance -// }); -// } -// -// client.removeFile(context.container, context.file.name, function (err, ok) { -// should.not.exist(err); -// should.exist(ok); -// -// hockInstance && hockInstance.done(); -// done(); -// }); -// }); -// -// it('the upload() method with large file should succeed', function (done) { -// -// if (mock) { -// return done(); -// // TODO mock these out -// } -// -// var stream = client.upload({ -// container: context.container, -// remote: 'bigfile.raw' -// }, function (err, ok) { -// should.not.exist(err); -// should.exist(ok); -// -// context.file = { -// name: 'bigfile.raw', -// size: fs.readFileSync(helpers.fixturePath('bigfile.raw')).length -// }; -// -// done(); -// }); -// -// var file = fs.createReadStream(helpers.fixturePath('bigfile.raw')); -// file.pipe(stream); -// }); -// -// it('the download() method with large file should succeed', function (done) { -// -// if (mock) { -// return done(); -// // TODO mock these out -// } -// -// var stream = client.download({ -// container: context.container, -// remote: context.file.name -// }, function (err, file) { -// -// should.not.exist(err); -// should.exist(file); -// file.should.be.instanceOf(File); -// -// file.name.should.equal(context.file.name); -// file.size.should.equal(context.fileContentsSize); -// -// context.fileContents = Buffer.concat(context.fileContents, -// file.size); -// -// // Compare byte by byte -// var original = fs.readFileSync(helpers.fixturePath('bigfile.raw')); -// for (var i = 0; i < file.size; i++) { -// assert.equal(context.fileContents[i], original[i]); -// } -// -// done(); -// }); -// -// context.fileContents = []; -// context.fileContentsSize = 0; -// stream.on('data', function (data) { -// context.fileContents.push(data); -// context.fileContentsSize += data.length; -// }); -// stream.end(); -// }); -// -// it('the destroyContainer() method with container should succeed', function (done) { -// -// if (mock) { -// if (provider === 'joyent') { -// // TODO figure out why joyent was disabled in vows based tests -// return done(); -// } -// -// setupDestroyContainerMock(provider, client, { -// server: hockInstance, -// authServer: authHockInstance -// }); -// } -// -// client.destroyContainer(context.container, function (err, ok) { -// should.not.exist(err); -// should.exist(ok); -// -// hockInstance && hockInstance.done(); -// done(); -// }); -// }); -// -// it('the getContainers() method should succeed', function (done) { -// -// if (mock) { -// if (provider === 'joyent') { -// // TODO figure out why joyent was disabled in vows based tests -// return done(); -// } -// -// setupGetContainers2Mock(provider, client, { -// server: hockInstance, -// authServer: authHockInstance -// }); -// } -// -// client.getContainers(function (err, ok) { -// should.not.exist(err); -// should.exist(ok); -// -// hockInstance && hockInstance.done(); -// done(); -// }); -// }); + + it('the getFiles() method with container should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupGetFilesMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + client.getFiles(context.container, false, function (err, files) { + should.not.exist(err); + should.exist(files); + + files.should.be.an.Array; + + files.forEach(function(file) { + file.should.be.instanceOf(File); + }); + + // TODO look for context.file in array + + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the removeFile() method with container and filename should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupRemoveFileMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + client.removeFile(context.container, context.file.name, function (err, ok) { + should.not.exist(err); + should.exist(ok); + + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the upload() method with large file should succeed', function (done) { + + if (mock) { + return done(); + // TODO mock these out + } + + var stream = client.upload({ + container: context.container, + remote: 'bigfile.raw' + }, function (err, ok) { + should.not.exist(err); + should.exist(ok); + + context.file = { + name: 'bigfile.raw', + size: fs.readFileSync(helpers.fixturePath('bigfile.raw')).length + }; + + done(); + }); + + var file = fs.createReadStream(helpers.fixturePath('bigfile.raw')); + file.pipe(stream); + }); + + it('the download() method with large file should succeed', function (done) { + + if (mock) { + return done(); + // TODO mock these out + } + + var stream = client.download({ + container: context.container, + remote: context.file.name + }, function (err, file) { + + should.not.exist(err); + should.exist(file); + file.should.be.instanceOf(File); + + file.name.should.equal(context.file.name); + file.size.should.equal(context.fileContentsSize); + + context.fileContents = Buffer.concat(context.fileContents, + file.size); + + // Compare byte by byte + var original = fs.readFileSync(helpers.fixturePath('bigfile.raw')); + for (var i = 0; i < file.size; i++) { + assert.equal(context.fileContents[i], original[i]); + } + + done(); + }); + + context.fileContents = []; + context.fileContentsSize = 0; + stream.on('data', function (data) { + context.fileContents.push(data); + context.fileContentsSize += data.length; + }); + stream.end(); + }); + + it('the destroyContainer() method with container should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupDestroyContainerMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + client.destroyContainer(context.container, function (err, ok) { + should.not.exist(err); + should.exist(ok); + + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the getContainers() method should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupGetContainers2Mock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + client.getContainers(function (err, ok) { + should.not.exist(err); + should.exist(ok); + + hockInstance && hockInstance.done(); + done(); + }); + }); after(function (done) { if (!mock) { From 9b9ad01565dbb6ac254461b970237a755ba83712 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 15 Sep 2014 12:43:56 -0700 Subject: [PATCH 129/460] Updating getFiles and removeFile to use aws-sdk --- lib/pkgcloud/amazon/storage/client/files.js | 59 +++++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 9087668cf..71dc36e33 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -26,6 +26,8 @@ const MAX_UPLOAD = 5 * 1024 * 1024 * 1024; // Destroys the `file` in the specified `container`. // exports.removeFile = function (container, file, callback) { + var self = this; + if (container instanceof storage.Container) { container = container.name; } @@ -34,15 +36,13 @@ exports.removeFile = function (container, file, callback) { file = file.name; } - this._request({ - method: 'DELETE', - container: container, - path: file - }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, res.statusCode == 204); + self.s3.deleteObject({ + Bucket: container, + Key: file + }, function(err, data) { + return err + ? callback(err) + : callback(null, !!data.DeleteMarker); }); }; @@ -354,20 +354,33 @@ exports.getFiles = function (container, options, callback) { callback = options; options = null; } + else if (!options) { + options = {}; + } - this._xmlRequest( - { - container: containerName, - qs: options - }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, self._toArray(body.Contents).map(function (file) { - file.container = container; - return new storage.File(self, file); - })); - } - ); + var s3Options = { + Bucket: containerName + }; + + if (options.marker) { + s3Options.Marker = options.marker; + } + + if (options.prefix) { + s3Options.Prefix = options.prefix; + } + + if (options.maxKeys) { + s3Options.MaxKeys = options.maxKeys + } + + self.s3.listObjects(s3Options, function(err, data) { + return err + ? callback(err) + : callback(null, self._toArray(data.Contents).map(function (file) { + file.container = container; + return new storage.File(self, file); + })); + }); }; From 47cc1f516fe18d8705853e820fc0ebaf3717c4f3 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 15 Sep 2014 13:12:24 -0700 Subject: [PATCH 130/460] Updating getFiles, destroyContainer to use aws-sdk --- .../amazon/storage/client/containers.js | 64 +++++++++++++------ lib/pkgcloud/amazon/storage/client/files.js | 6 +- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index 8d6f2d873..44526ee3d 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -85,35 +85,59 @@ exports.destroyContainer = function (container, callback) { var containerName = container instanceof base.Container ? container.name : container, self = this; - this.getFiles(containerName, false, function (err, files) { + function getPagedFiles(containerName, marker, callback) { + var options = {}; + + if (marker) { + options.marker = marker; + } + + self.getFiles(containerName, marker, callback); + } + + function deleteContainer(err) { if (err) { return callback(err); } - function deleteContainer(err) { - if (err) { - return callback(err); + self._xmlRequest({ + method: 'DELETE', + container: containerName + }, function (err, body, res) { + return err + ? callback(err) + : callback(null, res.statusCode == 204); } + ); + } - self._xmlRequest({ - method: 'DELETE', - container: containerName - }, function (err, body, res) { - return err - ? callback(err) - : callback(null, res.statusCode == 204); - } - ); + function handleResponse(err, files, meta) { + if (err) { + return callback(err); } - function destroyFile(file, next) { - file.remove(next); - } + if (meta.isTruncated) { + deleteFiles(files, function (err) { + if (err) { + callback(err); + return; + } - if (files.length === 0) { - return deleteContainer(); + getPagedFiles(containerName, files[files.length - 1].name, handleResponse); + }); + return; } - async.forEach(files, destroyFile, deleteContainer); - }); + deleteFiles(files, deleteContainer); + } + + function deleteFiles(files, next) { + async.forEachLimit(files, 10, destroyFile, next) + } + + function destroyFile(file, next) { + file.remove(next); + } + + getPagedFiles(containerName, null, handleResponse); }; diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 71dc36e33..d87369498 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -380,7 +380,11 @@ exports.getFiles = function (container, options, callback) { : callback(null, self._toArray(data.Contents).map(function (file) { file.container = container; return new storage.File(self, file); - })); + }), { + isTruncated: data.IsTruncated, + marker: data.Marker, + nextMarker: data.NextMarker + }); }); }; From 3800c08ba1cc79194c9e5872bd0398f8b2da62a8 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 15 Sep 2014 13:48:02 -0700 Subject: [PATCH 131/460] Reimplmeneting client.download for amazon streaming storage --- lib/pkgcloud/amazon/storage/client/files.js | 47 +++------------------ 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index d87369498..487f8be9b 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -11,6 +11,7 @@ var fs = require('fs'), request = require('request'), util = require('util'), qs = require('querystring'), + through = require('through'), base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), storage = pkgcloud.providers.amazon.storage, @@ -285,48 +286,14 @@ exports.multipartUpload = function (options, callback) { return stream; }; -exports.download = function (options, callback) { - var self = this, - success = callback ? onDownload : null, - container = options.container, - inputStream, - apiStream; - - // - // Optional helper function passed to `this._request` - // in the case when no callback is passed to `.download(options)`. - // - function onDownload(err, body, res) { - return err - ? callback(err) - : callback(null, new (storage.File)(self, _.extend(res.headers, { - container: container, - name: options.remote - }))); - } - - if (container instanceof storage.Container) { - container = container.name; - } - - if (options.local) { - inputStream = filed(options.local); - } - else if (options.stream) { - inputStream = options.stream; - } - - apiStream = this._request({ - path: options.remote, - container: container, - download: true - }, success); +exports.download = function (options) { + var self = this; - if (inputStream) { - apiStream.pipe(inputStream); - } + return self.s3.getObject({ + Bucket: options.container instanceof base.Container ? options.container.name : options.container, + Key: options.remote instanceof base.File ? options.remote.name : options.remote + }).createReadStream(); - return apiStream; }; exports.getFile = function (container, file, callback) { From 9f8a8c7ffede199c14061737f7d1421554d8b20c Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 16 Sep 2014 11:50:21 -0700 Subject: [PATCH 132/460] Adding streaming upload/download to amazon provider --- lib/pkgcloud/amazon/storage/client/files.js | 248 +------------------- lib/pkgcloud/amazon/storage/client/index.js | 8 +- lib/pkgcloud/azure/storage/client/files.js | 39 +-- lib/pkgcloud/azure/storage/utils.js | 7 + package.json | 3 +- test/common/storage/base-test.js | 76 ++---- 6 files changed, 69 insertions(+), 312 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 487f8be9b..45a7e1c01 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -6,19 +6,13 @@ */ var fs = require('fs'), - filed = require('filed'), - mime = require('mime'), request = require('request'), util = require('util'), - qs = require('querystring'), - through = require('through'), base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), storage = pkgcloud.providers.amazon.storage, _ = require('underscore'); -const MAX_UPLOAD = 5 * 1024 * 1024 * 1024; - // // ### function removeFile (container, file, callback) // #### @container {string} Name of the container to destroy the file in @@ -47,243 +41,19 @@ exports.removeFile = function (container, file, callback) { }); }; -exports.upload = function (options, callback) { - if (typeof options === 'function' && !callback) { - callback = options; - options = {}; - } - - // - // Optional helper function passed to `this._request` - // in the case when no callback is passed to `.upload(options)`. - // - function onUpload(err, body, res) { - return err - ? callback(err) - : callback(null, res.statusCode == 200, res); - } - - var container = options.container, - success = callback ? onUpload : null, - apiStream, - inputStream; - - if (container instanceof storage.Container) { - container = container.name; - } - - options.headers = options.headers || {}; - - if (options.local) { - inputStream = filed(options.local); - options.headers['content-length'] = fs.statSync(options.local).size; - } - else if (options.stream) { - inputStream = options.stream; - } - - if (options.headers && !options.headers['content-type'] && options.remote) { - options.headers['content-type'] = mime.lookup(options.remote); - } - - // If the content-length is greater than 5gb, we need to force the - // multi-part path by nuking the content-length header - if (options.headers['content-length'] !== undefined && - parseInt(options.headers['content-length'], 10) > MAX_UPLOAD) { - delete options.headers['content-length']; - } - - if (options.headers['content-length'] !== undefined) { - // Regular upload - apiStream = this._request({ - method: 'PUT', - upload: true, - container: container, - path: options.remote, - headers: options.headers || {} - }, success); - } else { - // Multi-part, 5mb chunk upload - apiStream = this.multipartUpload(options, success); - } - - if (inputStream) { - inputStream.pipe(apiStream); - } - - return apiStream; -}; - -exports.multipartUpload = function (options, callback) { - var self = this, - container = options.container, - chunk = 5 * 1024 * 1024, - chunksStarted = 0, - chunksFinished = [], - stream = new storage.ChunkedStream(chunk), - ended = false; - - if (container instanceof storage.Container) { - container = container.name; - } - - // We're doing a lot of parallel stuff there, - // but callback should be called only once - function handleResponse(err, body, res) { - if (handleResponse.called) return; - handleResponse.called = true; - callback && callback(err, body, res); - } - - handleResponse.called = false; - - // Wait for first data event, probably file is less than 5 mbs and - // we don't need that multipart thing at all - var first = null, - fastCase = true; - - stream.once('data', function (data) { - // Good case - all data fits in one chunk - if (fastCase) { - if (data.length < chunk && !first) { - first = data; - return; - } else { - fastCase = false; - - // Emit accumulated chunk - self.emit('data', first); - first = null; - } - } - - stream.pause(); - self._xmlRequest({ - method: 'POST', - container: container, - // Don't use the qs option here because there's no way to turn an object - // parsed with qs into just ?uploads. i.e. { uploads: null } turns into - // '?uploads=' which breaks signing - path: options.remote + '?uploads' - }, function (err, body, res) { - if (err) { - return handleResponse(err); - } - - if (res.statusCode !== 200) return handleResponse(res.statusCode, res); - - // Upload rest - function onChunk(chunk) { - stream.pause(); - uploadChunk(body.UploadId, chunk, function (err, chunk) { - if (err) return handleResponse(err); - - finish(chunk); - stream.resume(); - }); - } - stream.on('data', onChunk); - - // Upload existing chunk - onChunk(data); - } - ); - }); - - stream.on('end', function () { - if (fastCase) { - // Upload with default method once again - var rstream = self.upload(_.extend({}, options, { - stream: null, - headers: _.extend({}, options.headers, { - 'content-length': first.length - }) - }), handleResponse); - rstream.end(first); - return; - } - - ended = true; - finish(); - }); - - function uploadChunk(uploadId, data, uploadCallback) { - // Ignore empty chunks - if (data.length === 0) return; - - var id = ++chunksStarted, - chunk = { - uploadId: uploadId, - id: id, - etag: null - }; - - var stream = self._request({ - method: 'PUT', - upload: true, - path: options.remote, - container: container, - qs: { - partNumber: id, - uploadId: uploadId - }, - headers: _.extend({}, options.headers, { - 'content-length': data.length - }) - }, function (err, body, res) { - if (err) { return uploadCallback(err); } - if (res.statusCode != 200) return uploadCallback(res.statusCode); - - chunk.etag = res.headers.etag; - uploadCallback(null, chunk); - }); - stream.write(data); - stream.end(); - } - - function finish(chunk) { - if (chunk) chunksFinished.push(chunk); - - // We must send request only if: - // - stream was ended - // - we was doing multipart request - // - all chunks were uploaded - if (!ended || - chunksFinished.length === 0 || - chunksFinished.length !== chunksStarted) { - return; - } - - // Sort chunks in ascending order - chunksFinished.sort(function (a, b) { - return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; - }); +exports.upload = function (options) { + var self = this; - var body = '' + - chunksFinished.map(function (chunk) { - return '' + - '' + chunk.id + '' + - '' + chunk.etag + '' + - ''; - }).join('') + - ''; + var s3Options = { + Bucket: options.container instanceof base.Container ? options.container.name : options.container, + Key: options.remote instanceof base.File ? options.remote.name : options.remote + }; - // Send "Complete Multipart Upload" request - self._request({ - method: 'POST', - container: container, - path: options.remote, - qs: { - uploadId: chunksFinished[0].uploadId - }, - headers: { - 'Content-Length': Buffer.byteLength(body) - }, - body: body - }, handleResponse); + if (options.contentType) { + s3Options.ContentType = options.contentType; } - return stream; + return self.s3Stream.upload(s3Options); }; exports.download = function (options) { diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index ad7123e69..acdd3ba31 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -9,6 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), xml2js = require('xml2js'), AWS = require('aws-sdk'), + s3Stream = require('s3-upload-stream'), auth = require('../../../common/auth'), amazon = require('../../client'), _ = require('underscore'); @@ -32,8 +33,13 @@ var Client = exports.Client = function (options) { }); } - this.before.push(auth.amazon.headersSignature); this.s3 = new AWS.S3(); + + // configure the s3Stream + s3Stream.client(this.s3); + this.s3Stream = s3Stream; + + this.before.push(auth.amazon.headersSignature); }; util.inherits(Client, amazon.Client); diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 7ac60aa30..8368c34a0 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -63,8 +63,8 @@ exports.upload = function (options, callback) { var container = options.container, success = callback ? onUpload : null, path, - rstream, - lstream; + writeableStream, + readableStream; if (container instanceof storage.Container) { container = container.name; @@ -73,11 +73,11 @@ exports.upload = function (options, callback) { options.headers = options.headers || {}; if (options.local) { - lstream = filed(options.local); + readableStream = filed(options.local); options.headers['content-length'] = fs.statSync(options.local).size; } else if (options.stream) { - lstream = options.stream; + readableStream = options.stream; } if (options.headers && !options.headers['content-type'] && options.remote) { @@ -97,7 +97,7 @@ exports.upload = function (options, callback) { if (options.headers['content-length'] !== undefined) { // Regular upload - rstream = this._request({ + writeableStream = this._request({ method: 'PUT', upload: true, path: path, @@ -106,12 +106,12 @@ exports.upload = function (options, callback) { }, success); } else { // Multi-part, 5mb chunk upload - rstream = this.multipartUpload(options, success); + writeableStream = this.multipartUpload(options, success); } - if (lstream) lstream.pipe(rstream); + if (readableStream) readableStream.pipe(writeableStream); - return rstream; + return writeableStream; }; var getBlockId = function (a, b) { @@ -124,15 +124,15 @@ exports.multipartUpload = function (options, callback) { chunk = AzureConstants.BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES, numBlocks = 0, chunksFinished = [], - stream = new storage.ChunkedStream(chunk), + chunkedStream = new storage.ChunkedStream(chunk), ended = false; if (container instanceof storage.Container) { container = container.name; } - stream.on('data', function (data) { - stream.pause(); + chunkedStream.on('data', function (data) { + chunkedStream.pause(); options.azureBlockId = getBlockId(numBlocks++, 15); options.headers['content-length'] = data.length; @@ -140,22 +140,25 @@ exports.multipartUpload = function (options, callback) { // TODO What to do if err here? // TODO MUST FIX if (!ended) { - stream.resume(); + chunkedStream.resume(); } else { - self.sendBlockList(options, numBlocks, callback); + self.sendBlockList(options, numBlocks, function(err, body, res) { + chunkedStream.complete(); + callback && callback(err, body, res); + }); } }; - var rstream = self.upload(options, next); - rstream.write(data); - rstream.end(); + var writeableStream = self.upload(options, next); + writeableStream.write(data); + writeableStream.end(); }); - stream.on('end', function (data) { + chunkedStream.on('end', function (data) { ended = true; }); - return stream; + return chunkedStream; }; exports.sendBlockList = function (options, numBlocks, callback) { diff --git a/lib/pkgcloud/azure/storage/utils.js b/lib/pkgcloud/azure/storage/utils.js index c10963d33..6485a3972 100644 --- a/lib/pkgcloud/azure/storage/utils.js +++ b/lib/pkgcloud/azure/storage/utils.js @@ -70,6 +70,13 @@ ChunkedStream.prototype.end = function end() { this.emit('end'); }; ChunkedStream.prototype.close = ChunkedStream.prototype.end; +ChunkedStream.prototype.complete = function() { + if (!this.ended) { + this.end(); + } + + this.emit('complete'); +}; ChunkedStream.prototype.emitChunk = function emitChunk(chunk) { if (this.paused) { diff --git a/package.json b/package.json index c56c5dfdb..a255fc20b 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "request": "2.40.x", "underscore": "1.6.x", "url-join": "0.0.x", - "aws-sdk": "~2.0.17" + "aws-sdk": "~2.0.17", + "s3-upload-stream": "~1.0.0" }, "devDependencies": { "hock": "1.0.x", diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 190de092d..0746cd5cc 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -136,22 +136,27 @@ providers.filter(function (provider) { container: context.container, remote: 'test-file.txt', headers: {'x-amz-acl': 'public-read'} - }, function(err, ok, response) { + }); + + stream.on('error', function(err, response) { should.not.exist(err); - should.exist(ok); + should.not.exist(response); + }); + + stream.on('uploaded', complete); + stream.on('complete', complete); + + function complete() { + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); context.file = { name: 'test-file.txt', size: Buffer.byteLength(fillerama) }; - should.exist(response); - should.exist(response.statusCode); - should.exist(response.headers); - - hockInstance && hockInstance.done(); done(); - }); + } var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); file.pipe(stream); @@ -174,59 +179,19 @@ providers.filter(function (provider) { var stream = client.download({ container: context.container, remote: context.file.name - }, function (err, file) { - should.not.exist(err); - should.exist(file); - - file.name.should.equal(context.file.name); - context.fileContents.should.equal(fillerama); - file.size.should.equal(Buffer.byteLength(context.fileContents)); - - hockInstance && hockInstance.done(); - done(); }); context.fileContents = ''; + stream.on('data', function (data) { context.fileContents += data; }); - stream.end(); - }); - it('the download() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupDownloadStreamMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - var stream = client.download({ - container: context.container, - remote: context.file.name - }, function (err, file) { - should.not.exist(err); - should.exist(file); - - file.name.should.equal(context.file.name); + stream.on('end', function() { context.fileContents.should.equal(fillerama); - file.size.should.equal(Buffer.byteLength(context.fileContents)); - hockInstance && hockInstance.done(); done(); }); - - context.fileContents = ''; - stream.on('data', function (data) { - context.fileContents += data; - }); - stream.end(); }); it('the getFile() method with container and filename should succeed', function (done) { @@ -578,8 +543,13 @@ function setupUploadStreamMock(provider, client, servers) { } else if (provider === 'amazon') { servers.server - .put('/test-file.txt', fillerama) - .reply(200, '', {}) + .post('/test-file.txt?uploads') + .reply(200, '\npkgcloud-test-containertest-file.txtU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) + .put('/test-file.txt?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', fillerama) + .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/test-file.txtpkgcloud-test-containertest-file.txt"b2286fe4aac65809a1b7a053d07fc99f-1"') + .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') + .reply(200); + } else if (provider === 'azure') { servers.server @@ -604,7 +574,7 @@ function setupDownloadStreamMock(provider, client, servers) { else if (provider === 'amazon') { servers.server .get('/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2 }) + .reply(200, fillerama, { 'content-length': fillerama.length + 2 }); } else if (provider === 'azure') { servers.server From e87a075f255391a9fc32cb3bf1bff2c46eabb747 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 16 Sep 2014 14:21:05 -0700 Subject: [PATCH 133/460] requiring node >=0.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a255fc20b..a61596e27 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,6 @@ "test-coveralls": "make test-coveralls" }, "engines": { - "node": "0.8.x || 0.10.x" + "node": ">=0.10.x" } } From caf2fdd817eeca13e62e9ce19ea1e1f29b5fe425 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 16 Sep 2014 14:33:39 -0700 Subject: [PATCH 134/460] Adding user agent for aws calls --- lib/pkgcloud/amazon/storage/client/containers.js | 6 ++---- lib/pkgcloud/amazon/storage/client/index.js | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index 44526ee3d..8f5b319ce 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -6,8 +6,6 @@ */ var async = require('async'), - request = require('request'), - base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), storage = pkgcloud.providers.amazon.storage; @@ -63,7 +61,7 @@ exports.getContainer = function (container, callback) { // with this instance. // exports.createContainer = function (options, callback) { - var containerName = options instanceof base.Container ? options.name : options, + var containerName = options instanceof storage.Container ? options.name : options, self = this; self.s3.createBucket({ @@ -82,7 +80,7 @@ exports.createContainer = function (options, callback) { // Destroys the specified `container` and all files in it. // exports.destroyContainer = function (container, callback) { - var containerName = container instanceof base.Container ? container.name : container, + var containerName = container instanceof storage.Container ? container.name : container, self = this; function getPagedFiles(containerName, marker, callback) { diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index acdd3ba31..baaf7b9ab 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -11,6 +11,7 @@ var util = require('util'), AWS = require('aws-sdk'), s3Stream = require('s3-upload-stream'), auth = require('../../../common/auth'), + pkgcloud = require('../../../../pkgcloud'), amazon = require('../../client'), _ = require('underscore'); @@ -33,6 +34,12 @@ var Client = exports.Client = function (options) { }); } + var userAgent = AWS.util.userAgent(); + + AWS.util.userAgent = function() { + return util.format('nodejs-pkgcloud/%s %s', pkgcloud.version, userAgent); + }; + this.s3 = new AWS.S3(); // configure the s3Stream From 47976b1b4c5c1b807eccb2d0be5bc528f84f3f08 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 16 Sep 2014 14:36:49 -0700 Subject: [PATCH 135/460] Removing all traces of home-grown aws storage service --- .../amazon/storage/client/containers.js | 9 ++--- lib/pkgcloud/amazon/storage/client/index.js | 39 ------------------- 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index 8f5b319ce..9ae51ff39 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -98,13 +98,12 @@ exports.destroyContainer = function (container, callback) { return callback(err); } - self._xmlRequest({ - method: 'DELETE', - container: containerName - }, function (err, body, res) { + self.s3.deleteBucket({ + Bucket: containerName + }, function (err) { return err ? callback(err) - : callback(null, res.statusCode == 204); + : callback(null, true); } ); } diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index baaf7b9ab..0e6b88944 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -6,11 +6,8 @@ */ var util = require('util'), - urlJoin = require('url-join'), - xml2js = require('xml2js'), AWS = require('aws-sdk'), s3Stream = require('s3-upload-stream'), - auth = require('../../../common/auth'), pkgcloud = require('../../../../pkgcloud'), amazon = require('../../client'), _ = require('underscore'); @@ -45,42 +42,6 @@ var Client = exports.Client = function (options) { // configure the s3Stream s3Stream.client(this.s3); this.s3Stream = s3Stream; - - this.before.push(auth.amazon.headersSignature); }; util.inherits(Client, amazon.Client); - -Client.prototype._xmlRequest = function query(options, callback) { - - if (typeof options === 'function') { - callback = options; - options = {}; - } - - return this._request(options, function (err, body, res) { - - if (err) { - return callback(err); - } - var parser = new xml2js.Parser(); - - parser.parseString(body || '', function (err, data) { - return err - ? callback(err) - : callback(null, data, res); - }); - }); -}; - -Client.prototype._getUrl = function (options) { - options = options || {}; - - if (typeof options === 'string') { - return urlJoin(this.protocol + this.serversUrl, options); - } - - return urlJoin(this.protocol + - (options.container ? options.container + '.' : '') + - this.serversUrl, options.path); -}; From 877a755c41d530c9f49525cfd20abc78fb22e9ef Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 16 Sep 2014 14:50:07 -0700 Subject: [PATCH 136/460] removing chunkedstream from aws provider --- lib/pkgcloud/amazon/storage/index.js | 1 - lib/pkgcloud/amazon/storage/utils.js | 99 ---------------------------- 2 files changed, 100 deletions(-) delete mode 100644 lib/pkgcloud/amazon/storage/utils.js diff --git a/lib/pkgcloud/amazon/storage/index.js b/lib/pkgcloud/amazon/storage/index.js index 7d0432889..82ac8dfcd 100644 --- a/lib/pkgcloud/amazon/storage/index.js +++ b/lib/pkgcloud/amazon/storage/index.js @@ -8,7 +8,6 @@ exports.Client = require('./client').Client; exports.Container = require('./container').Container; exports.File = require('./file').File; -exports.ChunkedStream = require('./utils').ChunkedStream; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/amazon/storage/utils.js b/lib/pkgcloud/amazon/storage/utils.js deleted file mode 100644 index 5418ab998..000000000 --- a/lib/pkgcloud/amazon/storage/utils.js +++ /dev/null @@ -1,99 +0,0 @@ -var util = require('util'), - Stream = require('stream').Stream; - -var ChunkedStream = exports.ChunkedStream = function ChunkedStream(chunk) { - Stream.call(this); - - this.writable = true; - this.readable = true; - - this.ended = false; - this.paused = false; - this.size = 0; - this.chunk = chunk; - this.buffer = []; - this.chunkBuffer = []; -}; - -util.inherits(ChunkedStream, Stream); - -ChunkedStream.prototype.write = function write(data, encoding) { - if (!Buffer.isBuffer(data)) { - data = new Buffer(data, encoding); - } - - this.buffer.push(data); - this.size += data.length; - - // Split data in chunks - while (this.size >= this.chunk) { - var total = 0, - parts = []; - - this.buffer = this.buffer.filter(function (part) { - if (total >= this.chunk) return true; - - parts.push(part); - total += part.length; - return false; - }, this); - - // Last chunk is bigger than we need - if (total > this.chunk) { - var last = parts[parts.length - 1], - splitPos = last.length - total + this.chunk, - head = last.slice(0, splitPos), - tail = last.slice(splitPos); - - parts[parts.length - 1] = head; - - // Return tail back to main buffer - this.buffer.unshift(tail); - } - - this.emitChunk(Buffer.concat(parts, this.chunk)); - this.size -= this.chunk; - } - - if (this.paused) return false; -}; - -ChunkedStream.prototype.end = function end() { - if (this.ended) return; - - // Emit all left data - var self = this; - this.ended = true; - this.emitChunk(Buffer.concat(this.buffer, this.size)); - this.buffer = []; - this.size = 0; - - this.emit('end'); -}; -ChunkedStream.prototype.close = ChunkedStream.prototype.end; - -ChunkedStream.prototype.emitChunk = function emitChunk(chunk) { - if (this.paused) { - this.chunkBuffer.push(chunk); - return; - } - this.emit('data', chunk); -}; - -ChunkedStream.prototype.pause = function pause() { - if (this.paused) return; - this.paused = true; -}; - -ChunkedStream.prototype.resume = function resume() { - if (!this.paused) return; - this.paused = false; - - // Emit all accumulated data - this.chunkBuffer.forEach(function (chunk) { - this.emit('data', chunk); - }, this); - this.chunkBuffer = []; - - this.emit('drain'); -}; From cd80f126e6b4473a2439d0e0379ee0295a8566f4 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 17 Sep 2014 06:32:22 -0700 Subject: [PATCH 137/460] Configuring travis only for 0.10 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 340271c98..55979cfb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: node_js node_js: - - "0.8" - "0.10" notifications: From 1971ac788a60020921c4860fc5e14bdbea8fe8bc Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 17 Sep 2014 09:30:40 -0700 Subject: [PATCH 138/460] First pass at using aws-sdk for amazon compute provider --- lib/pkgcloud/amazon/client.js | 28 ++++- lib/pkgcloud/amazon/compute/client/images.js | 27 ++--- lib/pkgcloud/amazon/compute/client/index.js | 5 +- lib/pkgcloud/amazon/compute/client/servers.js | 103 ++++++++---------- lib/pkgcloud/amazon/compute/image.js | 4 +- lib/pkgcloud/amazon/compute/server.js | 14 +-- lib/pkgcloud/amazon/storage/client/index.js | 19 ---- test/common/compute/base-test.js | 36 +++--- test/common/compute/server-test.js | 27 +++-- test/common/storage/base-test.js | 18 +-- test/configs/mock/amazon.json | 3 +- test/fixtures/versions.json | 2 +- 12 files changed, 146 insertions(+), 140 deletions(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index a7f7d1d3f..0f4791fb6 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -6,10 +6,15 @@ */ var util = require('util'), + AWS = require('aws-sdk'), request = require('request'), + pkgcloud = require('../../../../pkgcloud'), base = require('../core/base'); +var userAgent = AWS.util.userAgent(); var Client = exports.Client = function (options) { + var self = this; + base.Client.call(this, options); options = options || {}; @@ -18,12 +23,33 @@ var Client = exports.Client = function (options) { this.provider = 'amazon'; this.securityGroup = options.securityGroup; this.securityGroupId = options.securityGroupId; - this.version = options.version || '2012-04-01'; + this.version = options.version || '2014-06-15'; this.protocol = options.protocol || 'https://'; this.serversUrl = options.serversUrl || this.serversUrl || 'ec2.amazonaws.com'; + // Configure amazon client + AWS.config.update({ accessKeyId: options.keyId, secretAccessKey: options.key }); + AWS.config.update({ region: options.region }); + + // TODO think about a proxy option for pkgcloud + // enable forwarding to mock test server + if (options.serversUrl) { + AWS.config.update({ + httpOptions: { + proxy: options.protocol ? options.protocol + options.serversUrl : 'https://' + options.serversUrl + } + }); + } + + this.userAgent = util.format('nodejs-pkgcloud/%s %s', pkgcloud.version, userAgent); + + // Setup a custom user agent for pkgcloud + AWS.util.userAgent = function () { + return self.userAgent; + }; + // support either key/accessKey syntax this.config.key = this.config.key || options.accessKey; this.config.keyId = this.config.keyId || options.accessKeyId; diff --git a/lib/pkgcloud/amazon/compute/client/images.js b/lib/pkgcloud/amazon/compute/client/images.js index 2f4f2415f..b8ba37305 100644 --- a/lib/pkgcloud/amazon/compute/client/images.js +++ b/lib/pkgcloud/amazon/compute/client/images.js @@ -22,24 +22,25 @@ exports.getImages = function getImages(options, callback) { options = null; } - var query = { 'Owner.0': 'self' }, + var query = { Owners: [ 'self' ] }, self = this; if (options && options.owners) { - // - // TODO: Support more than just owners - // - for (var i = 0; i < options.owners.length; i++) { - query['Owner.' + (i + 1)] = options.owners[i]; - } + options.owners.forEach(function(owner) { + query.Owners.push(owner); + }); } - return this._query('DescribeImages', query, function (err, body, res) { - return err - ? callback(err) - : callback(null, self._toArray(body.imagesSet.item).map(function (image) { - return new compute.Image(self, image); - }), res); + self.ec2.describeImages(query, function(err, data) { + console.dir(err); + if (err) { + callback(err); + return; + } + + callback(err, data.Images.map(function(image) { + return new compute.Image(self, image); + })); }); }; diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index fdb9ecd6a..66e14f5f1 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -5,7 +5,8 @@ * */ -var qs = require('querystring'), +var AWS = require('aws-sdk'), + qs = require('querystring'), util = require('util'), urlJoin = require('url-join'), xml2js = require('xml2js'), @@ -24,6 +25,8 @@ var Client = exports.Client = function (options) { _.extend(this, require('./keys')); _.extend(this, require('./groups')); + this.ec2 = new AWS.EC2(); + this.before.push(auth.amazon.bodySignature); }; diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index 66da39eb2..93ca5309b 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -47,31 +47,29 @@ exports.getLimits = function getLimits(callback) { exports._getDetails = function getDetails(details, callback) { var self = this; - self._query( - 'DescribeInstanceAttribute', { - InstanceId: details.instanceId, - Attribute: 'userData' - }, - function (err, body, res) { - if (err) { - // disregard the errors, if any - return callback(null, details); - } + self.ec2.describeInstanceAttribute({ + InstanceId: details.instanceId || details.InstanceId, + Attribute: 'userData' + }, function(err, data) { + if (err) { + // disregard the errors, if any + return callback(null, details); + } - var meta = new Buffer( - body.userData.value || '', - 'base64' - ).toString(); + var meta = new Buffer( + data.UserData.Value || '', + 'base64' + ).toString(); - try { - meta = JSON.parse(meta); - } catch (e) { - meta = {}; - } + try { + meta = JSON.parse(meta); + } catch (e) { + meta = {}; + } - details.name = meta.name; - callback(null, details); - }); + details.name = meta.name; + callback(null, details); + }); }; // @@ -81,24 +79,21 @@ exports._getDetails = function getDetails(details, callback) { // // Lists all servers available to your account. // -exports.getServers = function getServers(callback) { - var self = this; - return self._query('DescribeInstances', {}, function (err, body, res) { - if (err) { - return callback(err); - } +exports.getServers = function getServers(options, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } - var servers = []; + var self = this; - if (!body || !body.reservationSet || !body.reservationSet.item) { - return callback(null, []); + self.ec2.describeInstances(options, function(err, data) { + if (err) { + callback(err); + return; } - self._toArray(body.reservationSet.item).forEach(function (reservation) { - self._toArray(reservation.instancesSet.item).forEach(function (instance) { - servers.push(instance); - }); - }); + var servers = data.Reservations; async.map( servers, @@ -107,8 +102,8 @@ exports.getServers = function getServers(callback) { return err ? callback(err) : callback(null, servers.map(function (server) { - return new compute.Server(self, server); - }), res); + return new compute.Server(self, server); + })); } ); }); @@ -181,21 +176,18 @@ exports.createServer = function createServer(options, callback) { || options['Placement.AvailabilityZone']; } - return this._query( - 'RunInstances', - createOptions, - function (err, body, res) { + self.ec2.runInstances(createOptions, function(err, data) { var server; if (err) { return callback(err); } - self._toArray(body.instancesSet.item).forEach(function (instance) { + data.Instances.forEach(function (instance) { instance.meta = meta; server = new compute.Server(self, instance); }); - callback(null, server, res); + callback(null, server); } ); }; @@ -232,26 +224,21 @@ exports.getServer = function getServer(server, callback) { var self = this, serverId = server instanceof base.Server ? server.id : server; - return this._query( - 'DescribeInstances', - { - 'InstanceId.1' : serverId, - 'Filter.1.Name': 'instance-state-code', - 'Filter.1.Value.1': 0, // pending - 'Filter.1.Value.2': 16, // running - 'Filter.1.Value.3': 32, // shutting down - 'Filter.1.Value.4': 64, // stopping - 'Filter.1.Value.5': 80 // stopped - }, - function (err, body, res) { + self.ec2.describeInstances({ + InstanceIds: [ serverId ], + Filters: [ + { Name: 'instance-state-code', + Values : [ '0', '16', '32', '64', '80' ] } + ] + }, function (err, data) { var server; if (err) { return callback(err); } - self._toArray(body.reservationSet.item).forEach(function (reservation) { - self._toArray(reservation.instancesSet.item).forEach(function (instance) { + data.Reservations.forEach(function(reservation) { + reservation.Instances.forEach(function (instance) { server = instance; }); }); diff --git a/lib/pkgcloud/amazon/compute/image.js b/lib/pkgcloud/amazon/compute/image.js index d21297aad..7dfc17cde 100644 --- a/lib/pkgcloud/amazon/compute/image.js +++ b/lib/pkgcloud/amazon/compute/image.js @@ -15,8 +15,8 @@ var Image = exports.Image = function Image(client, details) { util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { - this.id = details.imageId; - this.name = details.name || details.imageLocation.split('/')[1]; + this.id = details.imageId || details.ImageId; + this.name = details.Name || details.ImageLocation.split('/')[1]; this.created = new Date(0); this.details = this.amazon = details; }; diff --git a/lib/pkgcloud/amazon/compute/server.js b/lib/pkgcloud/amazon/compute/server.js index 484f51b2f..472e42baa 100644 --- a/lib/pkgcloud/amazon/compute/server.js +++ b/lib/pkgcloud/amazon/compute/server.js @@ -15,11 +15,11 @@ var Server = exports.Server = function Server(client, details) { util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { - this.id = details.instanceId; + this.id = details.InstanceId || details.instanceId; this.name = details.name || (details.meta || {}).name; - if (details.instanceState) { - switch (details.instanceState.name.toUpperCase()) { + if (details.State) { + switch (details.State.Name.toUpperCase()) { case 'PENDING': this.status = this.STATUS.provisioning; break; @@ -56,9 +56,9 @@ Server.prototype._setProperties = function (details) { // // AWS specific // - this.imageId = details.imageId; - this.addresses = details.addresses = addresses; - this.launchTime = details.launchTime; - this.type = details.instanceType; + this.imageId = details.ImageId; + this.addresses = details.Addresses = addresses; + this.launchTime = details.LaunchTime; + this.type = details.InstanceType; this.original = this.amazon = details; }; diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index 0e6b88944..a9dcbbf9e 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -13,30 +13,11 @@ var util = require('util'), _ = require('underscore'); var Client = exports.Client = function (options) { - this.serversUrl = 's3.amazonaws.com'; - amazon.Client.call(this, options); _.extend(this, require('./containers')); _.extend(this, require('./files')); - AWS.config.update({ accessKeyId: options.keyId, secretAccessKey: options.key }); - AWS.config.update({ region: options.region }); - - if (options.serversUrl) { - AWS.config.update({ - httpOptions: { - proxy: options.protocol ? options.protocol + options.serversUrl : 'https://' + options.serversUrl - } - }); - } - - var userAgent = AWS.util.userAgent(); - - AWS.util.userAgent = function() { - return util.format('nodejs-pkgcloud/%s %s', pkgcloud.version, userAgent); - }; - this.s3 = new AWS.S3(); // configure the s3Stream diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 240dd7c28..813ce3a75 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -46,6 +46,9 @@ providers.forEach(function(provider) { hockInstance = hock.createHock({ throwOnUnmatched: false }); authHockInstance = hock.createHock(); + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + server = http.createServer(hockInstance.handler); authServer = http.createServer(authHockInstance.handler); @@ -136,7 +139,7 @@ providers.forEach(function(provider) { }); }); - it('the setWait() method waiting for a hockInstance to be operational should return a running hockInstance', function (done) { + it('the setWait() method waiting for a server to be operational should return a running server', function (done) { var m = mock ? 0.1 : 100; if (mock) { @@ -154,7 +157,7 @@ providers.forEach(function(provider) { should.not.exist(err); should.exist(srv1); - srv1.setWait({ status: srv1.STATUS.running }, 100 * m, function (err, srv2) { + srv1.setWait({ status: srv1.STATUS.running }, 100 * m, 1000, function (err, srv2) { should.not.exist(err); should.exist(srv2); srv2.should.be.instanceOf(Server); @@ -353,8 +356,8 @@ function setupImagesMock(client, provider, servers) { else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) - .post('/?Action=DescribeImages', { 'Owner.0': 'self' }, - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .post('/', { Action: 'DescribeImages', 'Owner.1': 'self' }, + {'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/images.xml'); } else if (provider === 'azure') { @@ -452,15 +455,17 @@ function setupServerMock(client, provider, servers) { else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) - .post('/?Action=RunInstances', { + .post('/', { + 'Action':'RunInstances', 'ImageId': 'ami-85db1cec', 'InstanceType': 'm1.small', 'MaxCount': '1', 'MinCount': '1', 'UserData': 'eyJuYW1lIjoiY3JlYXRlLXRlc3Qtc2V0V2FpdCJ9' - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/run-instances.xml') - .post('/?Action=DescribeInstances', { + .post('/', { + 'Action': 'DescribeInstances', 'Filter.1.Name': 'instance-state-code', 'Filter.1.Value.1': '0', 'Filter.1.Value.2': '16', @@ -468,14 +473,16 @@ function setupServerMock(client, provider, servers) { 'Filter.1.Value.4': '64', 'Filter.1.Value.5': '80', 'InstanceId.1': 'i-1d48637b' - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/pending-server.xml') - .post('/?Action=DescribeInstanceAttribute', { + .post('/', { + 'Action': 'DescribeInstanceAttribute', 'Attribute': 'userData', 'InstanceId': 'i-1d48637b' - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server-attr.xml') - .post('/?Action=DescribeInstances', { + .post('/', { + 'Action': 'DescribeInstances', 'Filter.1.Name': 'instance-state-code', 'Filter.1.Value.1': '0', 'Filter.1.Value.2': '16', @@ -483,12 +490,13 @@ function setupServerMock(client, provider, servers) { 'Filter.1.Value.4': '64', 'Filter.1.Value.5': '80', 'InstanceId.1': 'i-1d48637b' - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml') - .post('/?Action=DescribeInstanceAttribute', { + .post('/', { + 'Action': 'DescribeInstanceAttribute', 'Attribute': 'userData', 'InstanceId': 'i-1d48637b' - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server-attr.xml'); } diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index d1a5829e9..ca3880f41 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -44,6 +44,9 @@ providers.forEach(function (provider) { hockInstance = hock.createHock({ throwOnUnmatched: false }); authHockInstance = hock.createHock(); + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + server = http.createServer(hockInstance.handler); authServer = http.createServer(authHockInstance.handler); @@ -278,7 +281,10 @@ function setupImagesMock(client, provider, servers) { else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) - .post('/?Action=DescribeImages', { 'Owner.0': 'self' }) + .post('/', + { Action: 'DescribeImages', + 'Owner.1': 'self' }, + { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/images.xml'); } else if (provider === 'azure') { @@ -411,22 +417,25 @@ function setupServerMock(client, provider, servers) { else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) - .post('/?Action=RunInstances', { + .post('/', { + 'Action': 'RunInstances', 'ImageId': 'ami-85db1cec', 'InstanceType': 'm1.small', 'MaxCount': '1', 'MinCount': '1', 'UserData': 'eyJuYW1lIjoiY3JlYXRlLXRlc3QtaWRzMiJ9' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/run-instances.xml') // .post('/?Action=DescribeInstances') // .replyWithFile(200, __dirname + '/../../fixtures/amazon/pending-server.xml') - .post('/?Action=DescribeInstanceAttribute', { + .post('/', { + 'Action':'DescribeInstanceAttribute', 'Attribute': 'userData', 'InstanceId': 'i-1d48637b' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server-attr2.xml') - .post('/?Action=DescribeInstances', { + .post('/', { + 'Action': 'DescribeInstances', 'Filter.1.Name': 'instance-state-code', 'Filter.1.Value.1': '0', 'Filter.1.Value.2': '16', @@ -434,7 +443,7 @@ function setupServerMock(client, provider, servers) { 'Filter.1.Value.4': '64', 'Filter.1.Value.5': '80', 'InstanceId.1': 'i-1d48637b' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml'); } else if (provider === 'azure') { @@ -495,7 +504,9 @@ function setupGetServersMock(client, provider, servers) { else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) - .post('/?Action=DescribeInstances', {}) + .post('/', { + Action: 'DescribeInstances' + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml') } else if (provider === 'azure') { diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 0746cd5cc..149810280 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -48,7 +48,7 @@ providers.filter(function (provider) { authServer = http.createServer(authHockInstance.handler); // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); + hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); async.parallel([ function (next) { @@ -403,7 +403,7 @@ providers.filter(function (provider) { }); }); - function setupCreateContainerMock(provider, client, servers) { +function setupCreateContainerMock(provider, client, servers) { if (provider === 'rackspace') { servers.authServer .post('/v2.0/tokens', { @@ -450,20 +450,8 @@ providers.filter(function (provider) { .reply(201); } else if (provider === 'amazon') { - - // Override the clients getUrl method as it tries to prefix the container name onto the request - client._getUrl = function (options) { - options = options || {}; - - if (typeof options === 'string') { - return urlJoin(this.protocol + this.serversUrl, options); - } - - return urlJoin(this.protocol + this.serversUrl, options.path); - }; - servers.server - .put('/') + .put('/', 'us-west-2') .reply(200); } else if (provider === 'azure') { diff --git a/test/configs/mock/amazon.json b/test/configs/mock/amazon.json index a353271bc..5c3a4b0fe 100644 --- a/test/configs/mock/amazon.json +++ b/test/configs/mock/amazon.json @@ -2,5 +2,6 @@ "keyId": "MOCK-KEYID", "key": "MOCK-KEY", "serversUrl": "localhost:12345", - "protocol": "http://" + "protocol": "http://", + "region": "us-west-2" } diff --git a/test/fixtures/versions.json b/test/fixtures/versions.json index e23d699e0..639772075 100644 --- a/test/fixtures/versions.json +++ b/test/fixtures/versions.json @@ -1 +1 @@ -{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2012-04-01", "azure": "2012-03-01", "openstack": "v2", "hp": "v1"} \ No newline at end of file +{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2014-06-15", "azure": "2012-03-01", "openstack": "v2", "hp": "v1"} \ No newline at end of file From 4c71540d04f9029e6ba727d7731658db78d46d44 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 17 Sep 2014 14:20:48 -0700 Subject: [PATCH 139/460] Adding aws-sdk for amazon compute provider --- lib/pkgcloud/amazon/compute/client/groups.js | 115 +++++++++--------- lib/pkgcloud/amazon/compute/client/images.js | 84 ++++++++----- lib/pkgcloud/amazon/compute/client/servers.js | 90 +++++++------- lib/pkgcloud/amazon/compute/flavor.js | 64 +++++++--- lib/pkgcloud/amazon/compute/image.js | 8 +- lib/pkgcloud/amazon/compute/server.js | 13 +- lib/pkgcloud/openstack/compute/flavor.js | 9 +- lib/pkgcloud/openstack/compute/image.js | 9 +- .../blockstorage/client/snapshots.js | 1 - test/amazon/compute/client/groups-test.js | 65 ++++++---- 10 files changed, 276 insertions(+), 182 deletions(-) diff --git a/lib/pkgcloud/amazon/compute/client/groups.js b/lib/pkgcloud/amazon/compute/client/groups.js index 849e157dc..e0f23bd2c 100644 --- a/lib/pkgcloud/amazon/compute/client/groups.js +++ b/lib/pkgcloud/amazon/compute/client/groups.js @@ -4,7 +4,8 @@ */ var errs = require('errs'), - util = require('util'); + util = require('util'), + _ = require('underscore'); // // ### function listGroups (options, callback) @@ -22,10 +23,23 @@ exports.listGroups = function (options, callback) { var self = this; options = options || {}; - return this._query('DescribeSecurityGroups', options, function (err, body, res) { - return err - ? callback(err) - : callback(err, self._toArray(body.securityGroupInfo.item)); + var requestOpts = {}; + + if (options.groupNames) { + requestOpts.GroupNames = options.groupNames; + } + + if (options.groupIds) { + requestOpts.GroupIds = options.groupIds; + } + + self.ec2.describeSecurityGroups(requestOpts, function(err, data) { + if (err) { + callback(err); + return; + } + + callback(err, data.SecurityGroups); }); }; @@ -37,12 +51,15 @@ exports.listGroups = function (options, callback) { // Gets the details of the EC2 SecurityGroup with the specified `name`. // exports.getGroup = function (name, callback) { - return this.listGroups({ - 'GroupName.1': name - }, function (err, body) { - return err - ? callback(err) - : callback(null, body[0]); + this.listGroups({ groupNames: [ name ] }, function(err, groups) { + if (err) { + callback(err); + } else if (groups && groups[0]) { + callback(err, groups[0]); + } + else { + callback(new Error('Group not found')); + } }); }; @@ -63,18 +80,16 @@ exports.addGroup = function (options, callback) { ); } - return this._query( - 'CreateSecurityGroup', - { - GroupName: options.name, - GroupDescription: options.description - }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, true); - } - ); + var requestOpts = { + GroupName: options.name, + Description: options.description + }; + + this.ec2.createSecurityGroup(requestOpts, function(err, data) { + return err + ? callback(err) + : callback(null, _.extend(requestOpts, { GroupId: data.GroupId })); + }); }; // @@ -85,15 +100,11 @@ exports.addGroup = function (options, callback) { // Destroys EC2 SecurityGroup with the specified `name`. // exports.destroyGroup = function (name, callback) { - return this._query( - 'DeleteSecurityGroup', - { GroupName: name }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, true); - } - ); + this.ec2.deleteSecurityGroup({ GroupName: name }, function(err) { + return err + ? callback(err) + : callback(null, true); + }); }; // @@ -117,18 +128,14 @@ exports.addRules = function (options, callback) { } // Simply append the group name to the rules - override if existing - var rules = options.rules; - rules.GroupName = options.name; - - return this._query( - 'AuthorizeSecurityGroupIngress', - rules , - function (err, body, res) { - return err - ? callback(err) - : callback(null, true); - } - ); + this.ec2.authorizeSecurityGroupIngress({ + GroupName: options.name, + IpPermissions: options.rules + }, function(err) { + return err + ? callback(err) + : callback(null, true); + }); }; // @@ -152,16 +159,12 @@ exports.delRules = function (options, callback) { } // Simply append the group name to the rules - override if existing - var rules = options.rules; - rules.GroupName = options.name; - - return this._query( - 'RevokeSecurityGroupIngress', - rules , - function (err, body, res) { - return err - ? callback(err) - : callback(null, true); - } - ); + this.ec2.revokeSecurityGroupIngress({ + GroupName: options.name, + IpPermissions: options.rules + }, function (err) { + return err + ? callback(err) + : callback(null, true); + }); }; diff --git a/lib/pkgcloud/amazon/compute/client/images.js b/lib/pkgcloud/amazon/compute/client/images.js index b8ba37305..1fc2563ff 100644 --- a/lib/pkgcloud/amazon/compute/client/images.js +++ b/lib/pkgcloud/amazon/compute/client/images.js @@ -19,20 +19,29 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), exports.getImages = function getImages(options, callback) { if (!callback && typeof options === 'function') { callback = options; - options = null; + options = {}; } - var query = { Owners: [ 'self' ] }, + var requestOpts = { }, self = this; - if (options && options.owners) { - options.owners.forEach(function(owner) { - query.Owners.push(owner); + if (options.owners) { + requestOpts.Owners = options.owners.map(function(owner) { + return owner; }); } - self.ec2.describeImages(query, function(err, data) { - console.dir(err); + if (options.images) { + requestOpts.ImageIds = options.images.map(function(image) { + return image instanceof base.Image ? image.id : image; + }); + } + + if (!requestOpts.ImageIds && !requestOpts.Owners) { + requestOpts.Owners = [ 'self' ]; + } + + self.ec2.describeImages(requestOpts, function(err, data) { if (err) { callback(err); return; @@ -53,21 +62,22 @@ exports.getImages = function getImages(options, callback) { // object. // exports.getImage = function getImage(image, callback) { - var self = this, - imageId = image instanceof base.Image ? image.id : image, - query = { 'ImageId.1': imageId }; + var self = this; - return this._query('DescribeImages', query, function (err, body, res) { + self.getImages({ + images: [ image ] + }, function(err, images) { if (err) { - return callback(err); + callback(err); + return; } - var image = self._toArray(body.imagesSet.item).map(function (image) { - return image ? new compute.Image(self, image) : null; - })[0]; - return !image - ? callback(new Error('Image not found')) - : callback(null, image, res); + if (images && images[0]) { + callback(err, images[0]); + return; + } + + callback(new Error('Image not found')) }); }; @@ -89,13 +99,15 @@ exports.createImage = function createImage(options, callback) { var self = this, serverId = options.server instanceof base.Server - ? options.server.id : options.server, - query = { InstanceId: serverId, Name: options.name }; + ? options.server.id : options.server; - return this._query('CreateImage', query, function (err, body, res) { + this.ec2.createImage({ + InstanceId: serverId, + Name: options.name + }, function(err, data) { return err ? callback(err) - : self.getImage(res.imageId, callback); + : self.getImage(data.ImageId, callback); }); }; @@ -115,19 +127,25 @@ exports.destroyImage = function destroyImage(image, callback) { return callback(err); } - if (!image.blockDeviceMapping.item || - !image.blockDeviceMapping.item.ebs.snapshotId) { + if (!image.blockDeviceMappings || !image.blockDeviceMappings[0] || + !image.blockDeviceMappings[0].Ebs || !image.blockDeviceMappings[0].Ebs.SnapshotId) { return callback(new TypeError('Image is not EBS backed')); } - var query = { - snapshotId: image.blockDeviceMapping.item.ebs.snapshotId - }; - - self._query('DeleteSnapshot', query, function (err, body, res) { - return err - ? callback(err) - : callback(null, { ok: query.snapshotId }, res); - }); + self.ec2.deregisterImage({ ImageId: image instanceof base.Image ? image.id : image }, + function(err) { + if (err) { + callback(err); + return; + } + + self.ec2.deleteSnapshot({ + SnapshotId: image.blockDeviceMappings[0].Ebs.SnapshotId + }, function(err) { + return err + ? callback(err) + : callback(null, { ok: image.blockDeviceMappings[0].Ebs.SnapshotId }); + }); + }); }); }; diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index 93ca5309b..69c2a6b4a 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -93,10 +93,15 @@ exports.getServers = function getServers(options, callback) { return; } - var servers = data.Reservations; + var servers = []; - async.map( - servers, + data.Reservations.forEach(function(reservation) { + reservation.Instances.forEach(function(instance) { + servers.push(instance); + }); + }); + + async.map(servers, self._getDetails.bind(self), function finish(err, servers) { return err @@ -129,14 +134,14 @@ exports.createServer = function createServer(options, callback) { options = options || {}; // no args var self = this, - meta = { name: options.name || '' }, - createOptions = { - UserData: new Buffer(JSON.stringify(meta)).toString('base64'), - MinCount: 1, - MaxCount: 1 - }, - securityGroup, - securityGroupId; + meta = { name: options.name || '' }, + createOptions = { + UserData: new Buffer(JSON.stringify(meta)).toString('base64'), + MinCount: 1, + MaxCount: 1 + }, + securityGroup, + securityGroupId; if (!options.image) { return errs.handle( @@ -177,19 +182,18 @@ exports.createServer = function createServer(options, callback) { } self.ec2.runInstances(createOptions, function(err, data) { - var server; - if (err) { - return callback(err); - } + var server; + if (err) { + return callback(err); + } - data.Instances.forEach(function (instance) { - instance.meta = meta; - server = new compute.Server(self, instance); - }); + data.Instances.forEach(function (instance) { + instance.meta = meta; + server = new compute.Server(self, instance); + }); - callback(null, server); - } - ); + callback(null, server); + }); }; // @@ -200,17 +204,16 @@ exports.createServer = function createServer(options, callback) { // Destroy a server in AWS. // exports.destroyServer = function destroyServer(server, callback) { - var serverId = server instanceof base.Server ? server.id : server; - - return this._query( - 'TerminateInstances', - { InstanceId: serverId }, - function (err, body, res) { - return err - ? callback && callback(err) - : callback && callback(null, { ok: serverId }, res); - } - ); + var self = this, + serverId = server instanceof base.Server ? server.id : server; + + self.ec2.terminateInstances({ + InstanceIds: [ serverId ] + }, function(err) { + return err + ? callback && callback(err) + : callback && callback(null, { ok: serverId }); + }); }; // @@ -264,17 +267,16 @@ exports.getServer = function getServer(server, callback) { // Reboots a server // exports.rebootServer = function rebootServer(server, callback) { - var serverId = server instanceof base.Server ? server.id : server; - - return this._query( - 'RebootInstances', - { InstanceId: serverId }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, { ok: serverId }, res); - } - ); + var self = this, + serverId = server instanceof base.Server ? server.id : server; + + self.ec2.rebootInstances({ + InstanceIds: [ serverId ] + }, function (err) { + return err + ? callback && callback(err) + : callback && callback(null, { ok: serverId }); + }); }; // diff --git a/lib/pkgcloud/amazon/compute/flavor.js b/lib/pkgcloud/amazon/compute/flavor.js index 3c0ab2e1f..036ae2f22 100644 --- a/lib/pkgcloud/amazon/compute/flavor.js +++ b/lib/pkgcloud/amazon/compute/flavor.js @@ -5,8 +5,9 @@ * */ -var util = require('util'), - base = require('../../core/compute/flavor'); +var util = require('util'), + base = require('../../core/compute/flavor'), + _ = require('underscore'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); @@ -15,19 +16,48 @@ var Flavor = exports.Flavor = function Flavor(client, details) { util.inherits(Flavor, base.Flavor); Flavor.options = { - 'm1.small': { ram: 1.7 * 1024, disk: 160 }, - 'm1.medium': { ram: 3.75 * 1024, disk: 410 }, - 'm1.large': { ram: 7.5 * 1024, disk: 850 }, - 'm1.xlarge': { ram: 15 * 1024, disk: 1690 }, - 'c1.medium': { ram: 1.7 * 1024, disk: 350 }, - 'c1.xlarge': { ram: 7 * 1024, disk: 1690 }, - 'm2.xlarge': { ram: 17.1 * 1024, disk: 420 }, - 'm2.2xlarge': { ram: 34.2 * 1024, disk: 850 }, - 'm2.4xlarge': { ram: 68.4 * 1024, disk: 1690 }, - 'cc1.4xlarge': { ram: 23 * 1024, disk: 1690 }, - 'cg1.4xlarge': { ram: 22 * 1024, disk: 1690 }, - 'cc2.8xlarge': { ram: 60.5 * 1024, disk: 3370 }, - 't1.micro': { ram: 613, disk: 0 } + + // Previous Generation Instance Types + 'm1.small': { id: 'm1.small', ram: 1.7 * 1024, disk: 160 }, + 'm1.medium': { id: 'm1.medium', ram: 3.75 * 1024, disk: 410 }, + 'm1.large': { id: 'm1.large', ram: 7.5 * 1024, disk: 2 * 420 }, + 'm1.xlarge': { id: 'm1.xlarge', ram: 15 * 1024, disk: 4 * 420 }, + 'c1.medium': { id: 'c1.medium', ram: 1.7 * 1024, disk: 350 }, + 'c1.xlarge': { id: 'c1.xlarge', ram: 7 * 1024, disk: 4 * 420 }, + 'cc2.8xlarge': { id: 'cc2.8xlarge', ram: 60.5 * 1024, disk: 4 * 840 }, + 'm2.xlarge': { id: 'm2.xlarge', ram: 17.1 * 1024, disk: 420 }, + 'm2.2xlarge': { id: 'm2.2xlarge', ram: 34.2 * 1024, disk: 850 }, + 'm2.4xlarge': { id: 'm2.4xlarge', ram: 68.4 * 1024, disk: 2 * 840 }, + 'cr1.8xlarge': { id: 'cr1.8xlarge', ram: 244 * 1024, disk: 2 * 120 }, + 'hi1.4xlarge': { id: 'hi1.4xlarge', ram: 60.5 * 1024, disk: 2 * 1024 }, + 'cg1.4xlarge': { id: 'cg1.4xlarge', ram: 22.5 * 1024, disk: 2 * 840 }, + 't1.micro': { id: 't1.micro', ram: 613, disk: 0}, + + // Current Generation Instance Types + 't2.micro': { id: 't2.micro', ram: 1024, disk: 0 }, + 't2.small': { id: 't2.small', ram: 2 * 1024, disk: 0 }, + 't2.medium': { id: 't2.medium', ram: 4 * 1024, disk: 0 }, + 'm3.medium': { id: 'm3.medium', ram: 3.75 * 1024, disk: 4 }, + 'm3.large': { id: 'm3.large', ram: 7.5 * 1024, disk: 32 }, + 'm3.xlarge': { id: 'm3.xlarge', ram: 15 * 1024, disk: 2 * 40 }, + 'm3.2xlarge': { id: 'm3.2xlarge', ram: 30 * 1024, disk: 2 * 80 }, + 'c3.large': { id: 'c3.large', ram: 3.75 * 1024, disk: 2 * 16 }, + 'c3.xlarge': { id: 'c3.xlarge', ram: 7.5 * 1024, disk: 2 * 40 }, + 'c3.2xlarge': { id: 'c3.2xlarge', ram: 15 * 1024, disk: 2 * 80 }, + 'c3.4xlarge': { id: 'c3.4xlarge', ram: 30 * 1024, disk: 2 * 160 }, + 'c3.8xlarge': { id: 'c3.8xlarge', ram: 60 * 1024, disk: 2 * 320 }, + 'g2.2xlarge': { id: 'g2.2xlarge', ram: 15 * 1024, disk: 60 }, + 'r3.large': { id: 'r3.large', ram: 15.25 * 1024, disk: 32 }, + 'r3.xlarge': { id: 'r3.xlarge', ram: 30.5 * 1024, disk: 80 }, + 'r3.2xlarge': { id: 'r3.2xlarge', ram: 61 * 1024, disk: 160 }, + 'r3.4xlarge': { id: 'r3.4xlarge', ram: 122 * 1024, disk: 320 }, + 'r3.8xlarge': { id: 'r3.8xlarge', ram: 244 * 1024, disk: 2 * 320 }, + 'i2.xlarge': { id: 'i2.xlarge', ram: 30.5 * 1024, disk: 800 }, + 'i2.2xlarge': { id: 'i2.2xlarge', ram: 61 * 1024, disk: 2 * 800 }, + 'i2.4xlarge': { id: 'i2.4xlarge', ram: 122 * 1024, disk: 4 * 800 }, + 'i2.8xlarge': { id: 'i2.8xlarge', ram: 244 * 1024, disk: 8 * 800 }, + 'hs1.8xlarge': { id: 'hs1.8xlarge', ram: 117 * 1024, disk: 24 * 2000 } + }; Flavor.prototype._setProperties = function (details) { @@ -40,3 +70,7 @@ Flavor.prototype._setProperties = function (details) { this.ram = Flavor.options[id].ram; this.disk = Flavor.options[id].disk; }; + +Flavor.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'ram', 'disk' ]); +}; \ No newline at end of file diff --git a/lib/pkgcloud/amazon/compute/image.js b/lib/pkgcloud/amazon/compute/image.js index 7dfc17cde..5edd28e83 100644 --- a/lib/pkgcloud/amazon/compute/image.js +++ b/lib/pkgcloud/amazon/compute/image.js @@ -6,7 +6,8 @@ */ var util = require('util'), - base = require('../../core/compute/image'); + base = require('../../core/compute/image') + _ = require('underscore'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); @@ -18,5 +19,10 @@ Image.prototype._setProperties = function (details) { this.id = details.imageId || details.ImageId; this.name = details.Name || details.ImageLocation.split('/')[1]; this.created = new Date(0); + this.blockDeviceMappings = details.BlockDeviceMappings; this.details = this.amazon = details; }; + +Image.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'created', 'blockDeviceMappings']); +}; \ No newline at end of file diff --git a/lib/pkgcloud/amazon/compute/server.js b/lib/pkgcloud/amazon/compute/server.js index 472e42baa..99c3d3932 100644 --- a/lib/pkgcloud/amazon/compute/server.js +++ b/lib/pkgcloud/amazon/compute/server.js @@ -6,7 +6,8 @@ */ var util = require('util'), - base = require('../../core/compute/server'); + base = require('../../core/compute/server'), + _ = require('underscore'); var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); @@ -41,13 +42,13 @@ Server.prototype._setProperties = function (details) { var addresses = { private: [], public: [] }; - ['ipAddress', 'dnsName'].forEach(function (prop) { + ['PublicIpAddress', 'PublicDnsName'].forEach(function (prop) { if (typeof details[prop] === 'string') { addresses.public.push(details[prop]); } }); - ['privateIpAddress', 'privateDnsName'].forEach(function (prop) { + ['PrivateIpAddress', 'PrivateDnsName'].forEach(function (prop) { if (typeof details[prop] === 'string') { addresses.private.push(details[prop]); } @@ -59,6 +60,10 @@ Server.prototype._setProperties = function (details) { this.imageId = details.ImageId; this.addresses = details.Addresses = addresses; this.launchTime = details.LaunchTime; - this.type = details.InstanceType; + this.flavorId = details.InstanceType; this.original = this.amazon = details; }; + +Server.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'status', 'image', 'addresses', 'launchTime', 'flavor' ]); +}; diff --git a/lib/pkgcloud/openstack/compute/flavor.js b/lib/pkgcloud/openstack/compute/flavor.js index 0fb8f587e..956cb86a7 100644 --- a/lib/pkgcloud/openstack/compute/flavor.js +++ b/lib/pkgcloud/openstack/compute/flavor.js @@ -5,8 +5,9 @@ * */ -var util = require('util'), - base = require('../../core/compute/flavor'); +var util = require('util'), + base = require('../../core/compute/flavor'), + _ = require('underscore'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); @@ -22,3 +23,7 @@ Flavor.prototype._setProperties = function (details) { this.vcpus = details.vcpus; this.swap = details.swap; }; + +Flavor.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'ram', 'disk', 'vcpus', 'swap' ]); +}; \ No newline at end of file diff --git a/lib/pkgcloud/openstack/compute/image.js b/lib/pkgcloud/openstack/compute/image.js index 89f7dfe97..257cf484d 100644 --- a/lib/pkgcloud/openstack/compute/image.js +++ b/lib/pkgcloud/openstack/compute/image.js @@ -5,8 +5,9 @@ * */ -var util = require('util'), - base = require('../../core/compute/image'); +var util = require('util'), + base = require('../../core/compute/image'), + _ = require('underscore'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); @@ -25,4 +26,8 @@ Image.prototype._setProperties = function (details) { this.updated = details.updated; this.status = details.status; this.progress = details.progress; +}; + +Image.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'status', 'progress', 'created', 'updated']); }; \ No newline at end of file diff --git a/lib/pkgcloud/rackspace/blockstorage/client/snapshots.js b/lib/pkgcloud/rackspace/blockstorage/client/snapshots.js index 57751e3dd..37dd51a0d 100644 --- a/lib/pkgcloud/rackspace/blockstorage/client/snapshots.js +++ b/lib/pkgcloud/rackspace/blockstorage/client/snapshots.js @@ -97,7 +97,6 @@ exports.createSnapshot = function(details, callback) { }; self._request(createOptions, function(err, body, res) { - console.dir(body); return err ? callback(err) : callback(null, new Snapshot(self, body.snapshot)); diff --git a/test/amazon/compute/client/groups-test.js b/test/amazon/compute/client/groups-test.js index bb808fc72..13fc49e69 100644 --- a/test/amazon/compute/client/groups-test.js +++ b/test/amazon/compute/client/groups-test.js @@ -18,6 +18,9 @@ describe('pkgcloud/amazon/groups', function () { hockInstance = hock.createHock(); hockInstance.filteringRequestBody(helpers.authFilter); + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + server = http.createServer(hockInstance.handler); server.listen(12345, done); }); @@ -26,10 +29,11 @@ describe('pkgcloud/amazon/groups', function () { if (mock) { hockInstance - .post('/?Action=CreateSecurityGroup', { + .post('/', { + Action: 'CreateSecurityGroup', GroupDescription: 'unit test', GroupName: 'unit test' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/add-group.xml'); } @@ -38,7 +42,8 @@ describe('pkgcloud/amazon/groups', function () { description: 'unit test' }, function(err, data) { should.not.exist(err); - data.should.equal(true); + data.GroupId.should.equal('sg-a6e01ccd'); + hockInstance && hockInstance.done(); done(); }); @@ -48,9 +53,10 @@ describe('pkgcloud/amazon/groups', function () { if (mock) { hockInstance - .post('/?Action=DeleteSecurityGroup', { + .post('/', { + Action: 'DeleteSecurityGroup', GroupName: 'unit test' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/destroy-group.xml'); } @@ -66,7 +72,7 @@ describe('pkgcloud/amazon/groups', function () { if (mock) { hockInstance - .post('/?Action=DescribeSecurityGroups', {}) + .post('/', { Action: 'DescribeSecurityGroups'}, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/list-groups.xml'); } @@ -82,9 +88,10 @@ describe('pkgcloud/amazon/groups', function () { if (mock) { hockInstance - .post('/?Action=DescribeSecurityGroups', { + .post('/', { + Action: 'DescribeSecurityGroups', 'GroupName.1': 'unit test' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/list-group.xml'); } @@ -100,24 +107,28 @@ describe('pkgcloud/amazon/groups', function () { if (mock) { hockInstance - .post('/?Action=AuthorizeSecurityGroupIngress', { + .post('/', { + Action: 'AuthorizeSecurityGroupIngress', GroupName: 'unit test', 'IpPermissions.1.FromPort': '0', 'IpPermissions.1.Groups.1.GroupName': 'unit test', 'IpPermissions.1.IpProtocol': 'tcp', 'IpPermissions.1.ToPort': '65535' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/add-rules.xml'); } client.addRules({ name: 'unit test', - rules: { - 'IpPermissions.1.IpProtocol': 'tcp', - 'IpPermissions.1.Groups.1.GroupName': 'unit test', - 'IpPermissions.1.FromPort': 0, - 'IpPermissions.1.ToPort': 65535 - } + rules: [ + { IpProtocol: 'tcp', + FromPort: 0, + UserIdGroupPairs: [ { + GroupName: 'unit test' + } ], + ToPort: 65535 + } + ] }, function(err, data) { should.not.exist(err); data.should.equal(true); @@ -130,24 +141,30 @@ describe('pkgcloud/amazon/groups', function () { if (mock) { hockInstance - .post('/?Action=RevokeSecurityGroupIngress', { + .post('/', { + Action: 'RevokeSecurityGroupIngress', GroupName: 'unit test', 'IpPermissions.1.FromPort': '0', 'IpPermissions.1.Groups.1.GroupName': 'unit test', 'IpPermissions.1.IpProtocol': 'tcp', 'IpPermissions.1.ToPort': '65535' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/destroy-rules.xml'); } client.delRules({ name: 'unit test', - rules: { - 'IpPermissions.1.IpProtocol': 'tcp', - 'IpPermissions.1.Groups.1.GroupName': 'unit test', - 'IpPermissions.1.FromPort': 0, - 'IpPermissions.1.ToPort': 65535 - } + rules: + [ + { IpProtocol: 'tcp', + FromPort: 0, + UserIdGroupPairs: [ + { + GroupName: 'unit test' + } + ], + ToPort: 65535 + } ] }, function (err, data) { should.not.exist(err); data.should.equal(true); From 81f14eea4597500c215fc1165a76ee4979615747 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 17 Sep 2014 15:51:05 -0700 Subject: [PATCH 140/460] Removing all traces of original aws provider --- lib/pkgcloud/amazon/compute/client/index.js | 31 ------------- lib/pkgcloud/amazon/compute/client/keys.js | 50 ++++++++++----------- test/amazon/compute/client/keys-test.js | 22 +++++---- 3 files changed, 39 insertions(+), 64 deletions(-) diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index 66e14f5f1..f9cdd7d61 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -9,7 +9,6 @@ var AWS = require('aws-sdk'), qs = require('querystring'), util = require('util'), urlJoin = require('url-join'), - xml2js = require('xml2js'), auth = require('../../../common/auth'), amazon = require('../../client'), _ = require('underscore'); @@ -26,36 +25,6 @@ var Client = exports.Client = function (options) { _.extend(this, require('./groups')); this.ec2 = new AWS.EC2(); - - this.before.push(auth.amazon.bodySignature); }; util.inherits(Client, amazon.Client); - -Client.prototype._query = function query(action, query, callback) { - return this._request({ - method: 'POST', - headers: { }, - body: _.extend({ Action: action }, query) - }, function (err, body, res) { - if (err) { - return callback(err); - } - var parser = new xml2js.Parser(); - - parser.parseString(body, function (err, data) { - return err - ? callback(err) - : callback(err, data, res); - }); - }); -}; - -Client.prototype._getUrl = function (options) { - options = options || {}; - - return urlJoin(this.protocol + this.serversUrl, - (typeof options === 'string' - ? options - : options.path)); -}; diff --git a/lib/pkgcloud/amazon/compute/client/keys.js b/lib/pkgcloud/amazon/compute/client/keys.js index d6588f2d3..a506e26e7 100644 --- a/lib/pkgcloud/amazon/compute/client/keys.js +++ b/lib/pkgcloud/amazon/compute/client/keys.js @@ -21,13 +21,19 @@ exports.listKeys = function (options, callback) { options = {}; } - var self = this; + var self = this, + requestOpts = {}; + options = options || {}; - return this._query('DescribeKeyPairs', options, function (err, body, res) { + if (options.keyNames) { + requestOpts.KeyNames = options.keyNames; + } + + self.ec2.describeKeyPairs(requestOpts, function(err, data) { return err ? callback(err) - : callback(null, self._toArray(body.keySet.item)); + : callback(err, data.KeyPairs); }); }; @@ -40,7 +46,7 @@ exports.listKeys = function (options, callback) { // exports.getKey = function (name, callback) { return this.listKeys({ - 'KeyName.1': name + keyNames: [ name ] }, function (err, body) { return err ? callback(err) @@ -65,18 +71,14 @@ exports.addKey = function (options, callback) { ); } - return this._query( - 'ImportKeyPair', - { - KeyName: options.name, - PublicKeyMaterial: new Buffer(options.key).toString('base64') - }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, true); - } - ); + this.ec2.importKeyPair({ + KeyName: options.name, + PublicKeyMaterial: new Buffer(options.key).toString('base64') + }, function (err) { + return err + ? callback(err) + : callback(null, true); + }); }; // @@ -87,13 +89,11 @@ exports.addKey = function (options, callback) { // Destroys EC2 Key Pair with the specified `name`. // exports.destroyKey = function (name, callback) { - return this._query( - 'DeleteKeyPair', - { KeyName: name }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, true); - } - ); + this.ec2.deleteKeyPair({ + KeyName: name + }, function (err) { + return err + ? callback(err) + : callback(null, true); + }); }; \ No newline at end of file diff --git a/test/amazon/compute/client/keys-test.js b/test/amazon/compute/client/keys-test.js index 4301ed911..2f5eea3c7 100644 --- a/test/amazon/compute/client/keys-test.js +++ b/test/amazon/compute/client/keys-test.js @@ -18,6 +18,9 @@ describe('pkgcloud/amazon/keys', function () { hockInstance = hock.createHock(); hockInstance.filteringRequestBody(helpers.authFilter); + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + server = http.createServer(hockInstance.handler); server.listen(12345, done); }); @@ -26,10 +29,11 @@ describe('pkgcloud/amazon/keys', function () { if (mock) { hockInstance - .post('/?Action=ImportKeyPair', { + .post('/', { + Action: 'ImportKeyPair', KeyName: 'unittest', - PublicKeyMaterial: 'c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFDblhidGZGTTNrNExFb3hMaENGQ3lucnBibmtPYWphQ2xFUVVzdWRaazBTVWxVenl0Y2laRjArN25VaDg1VDZjZWMyNjdnazZ4ZTBZWEJqalhWc2xqcGtBVnIyc21ycFRwc2FJWk1qdXdPNlZHNFdYMG54NFhJaG1lTy9WcmdvYzY5Q0liTFJqNnkySlI1UTlaaHVqZVZJK1FZVkg3RnZ0OTZMZjh5SkN6YzRQdDZIVCswU2pudnlqSVZRTkcrWFVuS21GMWNVTGZiWTZOK2JwbUhJQWpxNW1mLzR4T2lKeHFUa0N0NmhoNGk4aE4vOHJmMzUwL0dDUE1GYTA0Umh2Si9hQVRWMmhxLzR4UXZVUXhzdzVsWnUzM3dZMENiQXI1Z3Z2bHZQd1grV0pFQjQ3RU9adEwrdm1nZVdieGJETGNFNUVaSnIxejJIV2ZSQkIweC9uQng=' - }) + PublicKeyMaterial: 'YzNOb0xYSnpZU0JCUVVGQlFqTk9lbUZETVhsak1rVkJRVUZCUkVGUlFVSkJRVUZDUVZGRGJsaGlkR1pHVFROck5FeEZiM2hNYUVOR1EzbHVjbkJpYm10UFlXcGhRMnhGVVZWemRXUmFhekJUVld4VmVubDBZMmxhUmpBck4yNVZhRGcxVkRaalpXTXlOamRuYXpaNFpUQlpXRUpxYWxoV2MyeHFjR3RCVm5JeWMyMXljRlJ3YzJGSldrMXFkWGRQTmxaSE5GZFlNRzU0TkZoSmFHMWxUeTlXY21kdll6WTVRMGxpVEZKcU5ua3lTbEkxVVRsYWFIVnFaVlpKSzFGWlZrZzNSblowT1RaTVpqaDVTa042WXpSUWREWklWQ3N3VTJwdWRubHFTVlpSVGtjcldGVnVTMjFHTVdOVlRHWmlXVFpPSzJKd2JVaEpRV3B4TlcxbUx6UjRUMmxLZUhGVWEwTjBObWhvTkdrNGFFNHZPSEptTXpVd0wwZERVRTFHWVRBMFVtaDJTaTloUVZSV01taHhMelI0VVhaVlVYaHpkelZzV25Vek0zZFpNRU5pUVhJMVozWjJiSFpRZDFnclYwcEZRalEzUlU5YWRFd3JkbTFuWlZkaWVHSkVUR05GTlVWYVNuSXhlakpJVjJaU1FrSXdlQzl1UW5nPQ==' + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/add-key.xml'); } @@ -48,9 +52,10 @@ describe('pkgcloud/amazon/keys', function () { if (mock) { hockInstance - .post('/?Action=DeleteKeyPair', { + .post('/', { + Action: 'DeleteKeyPair', KeyName: 'unittest' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/destroy-key.xml'); } @@ -66,7 +71,7 @@ describe('pkgcloud/amazon/keys', function () { if (mock) { hockInstance - .post('/?Action=DescribeKeyPairs', {}) + .post('/', { Action: 'DescribeKeyPairs' }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/list-keys.xml'); } @@ -82,9 +87,10 @@ describe('pkgcloud/amazon/keys', function () { if (mock) { hockInstance - .post('/?Action=DescribeKeyPairs', { + .post('/', { + Action: 'DescribeKeyPairs', 'KeyName.1': 'unittest' - }) + }, { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../../fixtures/amazon/list-keys.xml'); } From 17542fe0674e7bf72626da288efb9a3677a645bd Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 18 Sep 2014 08:48:23 -0700 Subject: [PATCH 141/460] Removing more aws specific code --- lib/pkgcloud/amazon/compute/client/index.js | 1 - lib/pkgcloud/common/auth.js | 5 - lib/pkgcloud/common/aws-signature.js | 122 -------------------- 3 files changed, 128 deletions(-) delete mode 100644 lib/pkgcloud/common/aws-signature.js diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index f9cdd7d61..5476e1d4a 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -9,7 +9,6 @@ var AWS = require('aws-sdk'), qs = require('querystring'), util = require('util'), urlJoin = require('url-join'), - auth = require('../../../common/auth'), amazon = require('../../client'), _ = require('underscore'); diff --git a/lib/pkgcloud/common/auth.js b/lib/pkgcloud/common/auth.js index 6161f5397..961920aca 100644 --- a/lib/pkgcloud/common/auth.js +++ b/lib/pkgcloud/common/auth.js @@ -6,7 +6,6 @@ */ var httpSignature = require('./http-signature'), - awsSignature = require('./aws-signature'), azureSignature = require('./azure-signature'), util = require('util'); @@ -47,10 +46,6 @@ function azureSignatureGenerator(sign) { } auth.httpSignature = signatureGenerator(httpSignature.sign); -auth.amazon = { - bodySignature: signatureGenerator(awsSignature.signBody), - headersSignature: signatureGenerator(awsSignature.signHeaders) -}; auth.azure = { managementSignature: azureSignatureGenerator(azureSignature.managementSignature), diff --git a/lib/pkgcloud/common/aws-signature.js b/lib/pkgcloud/common/aws-signature.js deleted file mode 100644 index 3b01faca3..000000000 --- a/lib/pkgcloud/common/aws-signature.js +++ /dev/null @@ -1,122 +0,0 @@ -/* - * aws-signature.js: Implmentation of authentication for Amazon AWS APIs. - * - * (C) 2012 Nodejitsu Inc. - * - */ - -var url = require('url'), - qs = require('querystring'), - crypto = require('crypto'); - -exports.signBody = function signBody(req, options) { - if (!options) options = {}; - - if (typeof options.key !== 'string') { - throw new TypeError('`key` is a required argument for aws-signature'); - } - - if (typeof options.keyId !== 'string') { - throw new TypeError('`keyId` is a required argument for aws-signature'); - } - - var signatureString = [ - req.method, '\n', - this.serversUrl, '\n', - '/', '\n' - ], - query = req.body; - - query.AWSAccessKeyId = options.keyId; - query.SignatureMethod = 'HmacSHA256'; - query.SignatureVersion = 2; - query.Version = this.version; - query.Timestamp = new Date(+new Date + 36e5 * 30).toISOString(); - - Object.keys(query).sort().forEach(function (key, i) { - if (i !== 0) signatureString.push('&'); - signatureString.push(encodeURIComponent(key), '=', encodeURIComponent(query[key])); - }); - - var toSign = signatureString.join(''); - - // Crappy code, but AWS seems to need it - toSign = toSign.replace(/!/g, '%21'); - toSign = toSign.replace(/'/g, '%27'); - toSign = toSign.replace(/\*/g, '%2A'); - toSign = toSign.replace(/\(/g, '%28'); - toSign = toSign.replace(/\)/g, '%29'); - - query.Signature = crypto.createHmac( - 'sha256', - options.key - ).update(toSign).digest('base64'); - - if (req.qs) { - req.qs.Action = query.Action; - } - else { - req.qs = { - Action: query.Action - }; - } - - delete query.Action; - - req.body = Object.keys(query).sort().map(function (key) { - return encodeURIComponent(key) + '=' + encodeURIComponent(query[key]); - }).join('&'); - - req.headers['Content-Type'] = 'application/x-www-form-urlencoded'; - req.headers['Content-Length'] = Buffer.byteLength(req.body); -}; - -exports.signHeaders = function signHeaders(req, options) { - if (!options) options = {}; - - if (typeof options.key !== 'string') { - throw new TypeError('`key` is a required argument for aws-signature'); - } - - if (typeof options.keyId !== 'string') { - throw new TypeError('`keyId` is a required argument for aws-signature'); - } - - req.headers = req.headers || {}; - - // Lower-case keys in headers hashmap - var headers = {}; - Object.keys(req.headers).forEach(function (key) { - headers[key.toLowerCase()] = req.headers[key]; - }); - - var now = new Date(), - signatureString = [ - req.method || 'GET', '\n', - headers['content-md5'] || '', '\n', - headers['content-type'] || '', '\n', - now.toUTCString(), '\n' - ]; - - // Push amz headers to signature string - Object.keys(headers).forEach(function (key) { - if (/^x-amz/.test(key)) { - signatureString.push(key, ':', headers[key], '\n'); - } - }); - - if (req.signingUrl) { - signatureString.push(req.signingUrl); - } - else { - signatureString.push(req.path); - } - - var signature = crypto.createHmac( - 'sha1', - options.key - ).update(signatureString.join('')).digest('base64'); - - req.headers.Date = now.toUTCString(); - req.headers.Authorization = 'AWS ' + options.keyId + ':' + signature; -}; From c15e310f4f7ce36646fac2a28aaa87508113e6f6 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 18 Sep 2014 09:50:06 -0700 Subject: [PATCH 142/460] More robust input handling for client.getImages in aws --- lib/pkgcloud/amazon/compute/client/images.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/pkgcloud/amazon/compute/client/images.js b/lib/pkgcloud/amazon/compute/client/images.js index 1fc2563ff..a32798062 100644 --- a/lib/pkgcloud/amazon/compute/client/images.js +++ b/lib/pkgcloud/amazon/compute/client/images.js @@ -25,16 +25,18 @@ exports.getImages = function getImages(options, callback) { var requestOpts = { }, self = this; - if (options.owners) { - requestOpts.Owners = options.owners.map(function(owner) { - return owner; - }); + if (options.owners && options.owners instanceof Array) { + requestOpts.Owners = options.owners; + } + else if (options.owners && typeof options.owners === 'string') { + requestOpts.Owners = [ options.owners ]; } - if (options.images) { - requestOpts.ImageIds = options.images.map(function(image) { - return image instanceof base.Image ? image.id : image; - }); + if (options.images && options.images instanceof Array) { + requestOpts.ImageIds = options.images; + } + else if (options.images && typeof options.images === 'string') { + requestOpts.ImagesIds = [ options.images ]; } if (!requestOpts.ImageIds && !requestOpts.Owners) { From 6fddb99b2940eee999efce0ee8912ebacf4ce8b9 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 18 Sep 2014 10:07:40 -0700 Subject: [PATCH 143/460] Comment re: perf of getServers on aws provider --- lib/pkgcloud/amazon/compute/client/servers.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index 69c2a6b4a..24beaf1c2 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -101,6 +101,7 @@ exports.getServers = function getServers(options, callback) { }); }); + // TODO investigate performance when getServers returns 100s of servers async.map(servers, self._getDetails.bind(self), function finish(err, servers) { From e7b18c0b68fa0bddcb83bb6f4cf62711e3d9848d Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 19 Sep 2014 16:54:56 -0700 Subject: [PATCH 144/460] First commit of orchestration stack model --- lib/pkgcloud.js | 1 + lib/pkgcloud/openstack/index.js | 3 +- .../openstack/orchestration/client/index.js | 50 +++ .../openstack/orchestration/client/stacks.js | 317 ++++++++++++++++++ lib/pkgcloud/openstack/orchestration/index.js | 16 + lib/pkgcloud/openstack/orchestration/stack.js | 46 +++ 6 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 lib/pkgcloud/openstack/orchestration/client/index.js create mode 100644 lib/pkgcloud/openstack/orchestration/client/stacks.js create mode 100644 lib/pkgcloud/openstack/orchestration/index.js create mode 100644 lib/pkgcloud/openstack/orchestration/stack.js diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index dc5aa0656..5d5776c26 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -40,6 +40,7 @@ var services = [ 'database', 'dns', 'loadbalancer', + 'orchestration', 'network', 'storage' ]; diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index 03a07b0f9..fdfc6bb27 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -6,6 +6,7 @@ */ exports.compute = require('./compute'); -exports.storage = require('./storage'); exports.identity = require('./identity'); +exports.orchestration = require('./orchestration'); exports.network = require('./network'); +exports.storage = require('./storage'); diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js new file mode 100644 index 000000000..c43c7cc6f --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -0,0 +1,50 @@ +/* + * index.js: Compute client for OpenStack + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ + +var util = require('util'), + openstack = require('../../client'), + urlJoin = require('url-join'), +// ComputeClient = require('../computeClient').ComputeClient, + _ = require('underscore'); + +var Client = exports.Client = function (options) { + openstack.Client.call(this, options); + + _.extend(this, require('./stacks')); +// _.extend(this, require('./images')); +// _.extend(this, require('./servers')); +// _.extend(this, require('./extensions')); + + this.serviceType = 'orchestration'; + +}; + +util.inherits(Client, openstack.Client); +//_.extend(Client.prototype, ComputeClient.prototype); + +/** + * client._getUrl + * + * @description get the url for the current compute service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function (options) { + options = options || {}; + + if (!this._serviceUrl) { + throw new Error('Service url not found'); + } + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); +}; diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js new file mode 100644 index 000000000..47e9accc4 --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -0,0 +1,317 @@ +/* + * stacks.js: Instance methods for working with stacks from OpenStack Orchestration + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ +var request = require('request'), + pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + urlJoin = require('url-join'), + util = require('util'), + _ = require('underscore'), + orchestration = pkgcloud.providers.openstack.orchestration; + +var _urlPrefix = '/stacks'; + +/** + * client.getStacks + * + * @description get the list of stacks for the current account + * + * @param {object|Function} [options] A set of options for the getStacks call + * @param {function} callback f(err, stacks) where stacks is an array of Stack + * @returns {*} + */ +exports.getStacks = function getStacks(options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var requestOptions = { + path: _urlPrefix + }; + + requestOptions.qs = _.pick(options, + 'status', + 'name', + 'limit', + 'marker', + 'sort'); + + if (options.sortDir) { + requestOptions['sort_dir'] = options.sortDir; + } + + if (options.sortKeys) { + requestOptions['sort_keys'] = options.sortKeys; + } + + return this._request(requestOptions, function (err, body) { + if (err) { + callback(err); + return; + } + + callback(err, body.stacks.map(function(stack) { + return new orchestration.Stack(self, stack); + })); + }); +}; + +/** + * client.createStack + * + * @description Creates a stack with the specified options. + + * @param {object} details the details to create this stack + * @param {String} details.name the name of the new stack + * @param {String} details.environment the environment for the stack + * @param {Number} details.timeout timeout in minutes for stack creation + * @param {Object} [details.template] template for the stack, required unless templateUrl is provided + * @param {String} [details.templateUrl] url for the template, required if no template + * @param {Object} [details.parameters] optional parameters configuration + * @param {Object} [details.files] optional files configuration + * @param callback + * @returns {request|null} + */ +exports.createStack = function (details, callback) { + if (typeof details === 'function') { + callback = details; + details = {}; + } + + details = details || {}; + + if (!validateProperties(['name', 'timeout'], details, + 'options.%s is a required argument.', callback)) { + return; + } + + if (!details.templateUrl && !details.template) { + callback(new Error('one of template or templateUrl are required')); + return; + } + + var self = this, + createOptions = { + method: 'POST', + path: details.preview ? urlJoin(_urlPrefix, 'preview'): _urlPrefix, + body: { + stack_name: details.name, + environment: details.environment, + timeout_mins: typeof details.timeout === 'number' ? details.timeout : parseInt(details.timeout) + } + }; + + if (details.template) { + createOptions.body.template = details.template; + } + else if (details.templateUrl) { + createOptions.body['template_url'] = details.templateUrl; + } + + if (details.parameters) { + createOptions.body.parameters = details.parameters; + } + + if (details.files) { + createOptions.body.files = details.files; + } + + return self._request(createOptions, function (err, body) { + if (err) { + return callback(err); + } + + if (!body || !body.stack) { + return new Error('Stack not passed back from OpenStack.'); + } + + callback(err, new orchestration.Stack(self, body.stack)); + }); +}; + +/** + * client.previewStack + * + * @description Preview a stack creation with the specified options. + + * @param {object} details the details to create this stack + * @param {String} details.name the name of the new stack + * @param {String} details.environment the environment for the stack + * @param {Number} details.timeout timeout in minutes for stack creation + * @param {Object} [details.template] template for the stack, required unless templateUrl is provided + * @param {String} [details.templateUrl] url for the template, required if no template + * @param {Object} [details.parameters] optional parameters configuration + * @param {Object} [details.files] optional files configuration + * @param callback + * @returns {request|*} + */ +exports.previewStack = function(details, callback) { + return this.createStack(_.extend(details, { preview: true }), callback); +}; + +/** + * client.getStack + * + * @description Gets a stack from the account + * + * @param {String|object} stack The stack or stackName to fetch + * @param {Function} callback + * @returns {request|*} + */ +exports.getStack = function (stack, callback) { + var self = this, + path = stack instanceof orchestration.Stack + ? urlJoin(_urlPrefix, stack.name, stack.id) + : urlJoin(_urlPrefix, stack); + + return this._request({ + path: path + }, function (err, body) { + if (err) { + return callback(err); + } + if (!body.stack) { + return new Error('Unexpected empty response'); + } + else { + callback(null, new orchestration.Stack(self, body.stack)); + } + }); +}; + +/** + * client.updateStack + * + * @description Update a stack + * + * @param {String|object} stack The stack or stackName to update + * @param {Function} callback + * @returns {request|*} + */ +exports.updateStack = function (stack, callback) { + if (!stack instanceof orchestration.Stack) { + callback(new Error('you must provide a stack to update')); + return; + } + + return this._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id), + body: { + template_url: stack.templateUrl, + template: stack.template, + files: stack.files, + environment: stack.environment, + parameters: stack.parameters, + timeout_mins: stack.timeout + }, + method: 'PUT' + }, function (err) { + if (err) { + return callback(err); + } + + callback(err, stack); + }); +}; + +/** + * client.deleteStack + * + * @description Delete a stack from the account + * + * @param {String|object} stack The stack or stackName to delete + * @param {Function} callback + * @returns {request|*} + */ +exports.deleteStack = function (stack, callback) { + var path = stack instanceof orchestration.Stack + ? urlJoin(_urlPrefix, stack.name, stack.id) + : urlJoin(_urlPrefix, stack); + + return this._request({ + path: path, + method: 'DELETE' + }, function (err) { + if (err) { + return callback(err); + } + + callback(err, true); + }); +}; + +/** + * client.abandonStack + * + * @description Delete a stack, but preserve the created resources + * + * @param {String|object} stack The stack or stackName to abandon + * @param {Function} callback + * @returns {request|*} + */ +exports.abandonStack = function (stack, callback) { + var self = this; + + if (typeof stack === 'string') { + self.getStack(stack, function(err, stack) { + if (err) { + callback(err); + return; + } + + abandon(stack); + }); + + return; + } + else if (!stack instanceof orchestration.stack) { + callback(new Error('stack must be a string or stack instance')); + return; + } + + abandon(stack); + + function abandon(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'abandon'), + method: 'DELETE' + }, function (err) { + if (err) { + return callback(err); + } + + callback(err, true); + }); + } +}; + +/** + * validateProperties + * + * @description local helper function for validating arguments + * + * @param {Array} required The list of required properties + * @param {object} options The options object to validate + * @param {String} formatString String formatter for the error message + * @param {Function} callback + * @returns {boolean} + */ +function validateProperties(required, options, formatString, callback) { + return !required.some(function (item) { + if (typeof(options[item]) === 'undefined') { + errs.handle( + errs.create({ message: util.format(formatString, item) }), + callback + ); + return true; + } + return false; + }); +} diff --git a/lib/pkgcloud/openstack/orchestration/index.js b/lib/pkgcloud/openstack/orchestration/index.js new file mode 100644 index 000000000..211721d01 --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/index.js @@ -0,0 +1,16 @@ +/* + * index.js: Top-level include for the OpenStack orchestration module + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ + +exports.Client = require('./client').Client; +exports.Stack = require('./stack').Stack; +//exports.Image = require('./image').Image; +//exports.Server = require('./server').Server; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/openstack/orchestration/stack.js b/lib/pkgcloud/openstack/orchestration/stack.js new file mode 100644 index 000000000..3d00cb0c1 --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/stack.js @@ -0,0 +1,46 @@ +/* + * volume.js: OpenStack Orchestration Stack + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + * + */ + +var util = require('util'), + base = require('../../core/base'), + _ = require('underscore'); + +var Stack = exports.Stack = function Stack(client, details) { + base.Model.call(this, client, details); +}; + +util.inherits(Stack, base.Model); + +Stack.prototype._setProperties = function (details) { + this.id = details.id; + this.name = details.name || details['stack_name']; + this.status = details.status || details['stack_status']; + this.description = details.description; + this.templateDescription = details.templateDescription || details['template_description']; + this.statusReason = details.statusReason || details['stack_status_reason']; + this.owner = details.owner || details['stack_owner']; + this.disableRollback = details.disableRollback || details['disable_rollback']; + this.parameters = details.parameters; + this.capabilities = details.capabilities; + this.notificationTopics = details.notificationTopics || details['notification_topics']; + this.timeout = details.timeout || details['timeout_mins']; + + this.createdAt = details['creation_time']; + this.updatedAt = details['updated_time']; +}; + +Stack.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'status', 'description', 'templateDescription', 'statusReason', 'owner', + 'disableRollback', 'parameters', 'capabilities', 'notificationTopics', 'timeout', 'updatedAt', 'createdAt' ]); +}; + + + + + From 4d4fa216ef23a02777c253566c8275001e80d0d9 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 19 Sep 2014 17:01:39 -0700 Subject: [PATCH 145/460] Abandon stack callback data should be passed --- lib/pkgcloud/openstack/orchestration/client/stacks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 47e9accc4..faf780268 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -282,12 +282,12 @@ exports.abandonStack = function (stack, callback) { return self._request({ path: urlJoin(_urlPrefix, stack.name, stack.id, 'abandon'), method: 'DELETE' - }, function (err) { + }, function (err, abandonStackData) { if (err) { return callback(err); } - callback(err, true); + callback(err, abandonStackData); }); } }; From 87eab341be7fb0b560ed8cd5ac484208d269c204 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 20 Sep 2014 09:12:44 -0700 Subject: [PATCH 146/460] Adding adopt stack support --- .../openstack/orchestration/client/stacks.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index faf780268..7aff769db 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -123,6 +123,15 @@ exports.createStack = function (details, callback) { createOptions.body.files = details.files; } + // Adopt Stack options + if (details.stackData) { + createOptions.body['adopt_stack_data'] = JSON.stringify(details.stackData); + + if (typeof details.disableRollback === 'boolean') { + createOptions.body['disable_rollback'] = details.disableRollback; + } + } + return self._request(createOptions, function (err, body) { if (err) { return callback(err); @@ -156,6 +165,28 @@ exports.previewStack = function(details, callback) { return this.createStack(_.extend(details, { preview: true }), callback); }; +/** + * client.adoptStack + * + * @description adopt a stack from previously abandoned resources + + * @param {object} details the details to create this stack + * @param {String} details.name the name of the new stack + * @param {String} details.environment the environment for the stack + * @param {Number} details.timeout timeout in minutes for stack creation + * @param {Object} details.stackData Object with stack data to adopt + * @param {Boolean} details.disableRollback Controls whetehr a failure during stack creation causes deletion + * @param {Object} [details.template] template for the stack, required unless templateUrl is provided + * @param {String} [details.templateUrl] url for the template, required if no template + * @param {Object} [details.parameters] optional parameters configuration + * @param {Object} [details.files] optional files configuration + * @param callback + * @returns {request|*} + */ +exports.adoptStack = function (details, callback) { + return this.createStack(details, callback); +}; + /** * client.getStack * From 5886dbaa1d301450e857c40dcf3393cd19c930fa Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 20 Sep 2014 13:29:06 -0700 Subject: [PATCH 147/460] Adding events, resources, and template apis --- .../openstack/orchestration/client/events.js | 141 +++++++++++++++ .../openstack/orchestration/client/index.js | 6 +- .../orchestration/client/resources.js | 166 ++++++++++++++++++ .../orchestration/client/templates.js | 99 +++++++++++ lib/pkgcloud/openstack/orchestration/index.js | 2 +- .../openstack/orchestration/resource.js | 48 +++++ 6 files changed, 458 insertions(+), 4 deletions(-) create mode 100644 lib/pkgcloud/openstack/orchestration/client/events.js create mode 100644 lib/pkgcloud/openstack/orchestration/client/resources.js create mode 100644 lib/pkgcloud/openstack/orchestration/client/templates.js create mode 100644 lib/pkgcloud/openstack/orchestration/resource.js diff --git a/lib/pkgcloud/openstack/orchestration/client/events.js b/lib/pkgcloud/openstack/orchestration/client/events.js new file mode 100644 index 000000000..c22f843d8 --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/client/events.js @@ -0,0 +1,141 @@ +/* + * events.js: Instance methods for working with stack events from OpenStack Orchestration + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ +var request = require('request'), + pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + urlJoin = require('url-join'), + util = require('util'), + _ = require('underscore'), + orchestration = pkgcloud.providers.openstack.orchestration; + +var _urlPrefix = '/stacks'; + +/** + * client.getEvents + * + * @description get the list of stack events for a provided stack + * + * @param {object|string} stack stack or stackName to find events for + * @param {function} callback f(err, events) where stacks is an array of Event + * @returns {*} + */ +exports.getEvents = function(stack, callback) { + var self = this; + + if (stack instanceof orchestration.Stack) { + getEvents(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function (err, stack) { + if (err) { + callback(err); + return; + } + + getEvents(stack); + }); + } + + function getEvents(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'events') + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.events); + + }); + } +}; + +/** + * client.getResourceEvents + * + * @description get the list of stack events for a provided stack and resource + * + * @param {object|string} stack stack or stackName to find events for + * @param {object|string} resource resource or resourceName to find events for + * @param {function} callback f(err, events) where stacks is an array of Event + * @returns {*} + */ +exports.getResourceEvents = function (stack, resource, callback) { + var self = this; + + if (stack instanceof orchestration.Stack) { + getEvents(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function (err, stack) { + if (err) { + callback(err); + return; + } + + getEvents(stack); + }); + } + + function getEvents(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', + resource instanceof orchestration.Resource ? resource.name : resource, 'events') + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.events); + + }); + } +}; + +/** + * client.getEvent + * + * @description get the event for a provided stack, resource, and eventName + * + * @param {object|string} stack stack or stackName + * @param {object|string} resource resource or resourceName + * @param {string} eventId eventId to query for + * @param {function} callback f(err, event) + * @returns {*} + */ +exports.getEvent = function (stack, resource, eventId, callback) { + var self = this; + + if (stack instanceof orchestration.Stack) { + getEvent(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function (err, stack) { + if (err) { + callback(err); + return; + } + + getEvent(stack); + }); + } + + function getEvent(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', + resource instanceof orchestration.Resource ? resource.name : resource, 'events', eventId) + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.event); + + }); + } +}; \ No newline at end of file diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js index c43c7cc6f..d18982f18 100644 --- a/lib/pkgcloud/openstack/orchestration/client/index.js +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -16,9 +16,9 @@ var Client = exports.Client = function (options) { openstack.Client.call(this, options); _.extend(this, require('./stacks')); -// _.extend(this, require('./images')); -// _.extend(this, require('./servers')); -// _.extend(this, require('./extensions')); + _.extend(this, require('./templates')); + _.extend(this, require('./events')); + _.extend(this, require('./resources')); this.serviceType = 'orchestration'; diff --git a/lib/pkgcloud/openstack/orchestration/client/resources.js b/lib/pkgcloud/openstack/orchestration/client/resources.js new file mode 100644 index 000000000..823a50ced --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/client/resources.js @@ -0,0 +1,166 @@ +/* + * resources.js: Instance methods for working with stack resources from OpenStack Orchestration + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ +var request = require('request'), + pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + urlJoin = require('url-join'), + util = require('util'), + _ = require('underscore'), + orchestration = pkgcloud.providers.openstack.orchestration; + +var _urlPrefix = '/resource_types'; + +/** + * client.getResources + * + * @description get the list of stack resources for a provided stack + * + * @param {object|string} stack stack or stackName to find resources for + * @param {function} callback f(err, resources) where stacks is an array of Resource + * @returns {*} + */ +exports.getResources = function (stack, callback) { + var self = this; + + if (stack instanceof orchestration.Stack) { + getResources(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function (err, stack) { + if (err) { + callback(err); + return; + } + + getResources(stack); + }); + } + + function getResources(stack) { + return self._request({ + path: urlJoin('/stacks', stack.name, stack.id, 'resources') + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.resources.map(function(resource) { + return new orchestration.Resource(self, _.extend({ stack: stack }, resource)); + })); + }); + } +}; + +/** + * client.getResource + * + * @description get the resource data for a provided resource and stack + * + * @param {object|string} stack stack or stackName to find resources for + * @param {object|string} resource resource or resourceName to get + * @param {function} callback f(err, resource) + * @returns {*} + */ +exports.getResource = function (stack, resource, callback) { + var self = this; + + if (stack instanceof orchestration.Stack) { + getResource(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function (err, stack) { + if (err) { + callback(err); + return; + } + + getResource(stack); + }); + } + + function getResource(stack) { + return self._request({ + path: urlJoin('/stacks', stack.name, stack.id, 'resources', + resource instanceof orchestration.Resource ? resource.name : resource) + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, new orchestration.Resource(self, _.extend({ stack: stack }, body.resource))); + }); + } +}; + +/** + * client.getResourceTypes + * + * @description get the list of resource types for the account + * + * @param {function} callback f(err, resourceTypes) where resourceTypes is an array of types + * @returns {*} + */ +exports.getResourceTypes = function (callback) { + var self = this; + + return self._request({ + path: _urlPrefix + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.resource_types); + }); +}; + +/** + * client.getResourceSchema + * + * @description get the schema for a provided resource type + * + * @param {string} resourceType the resourceType to get the schema for + * @param {function} callback f(err, schema) + * @returns {*} + */ +exports.getResourceSchema = function (resourceType, callback) { + var self = this; + + return self._request({ + path: urlJoin(_urlPrefix, resourceType) + }, function (err, schema) { + if (err) { + return callback(err); + } + + callback(null, schema); + }); +}; + +/** + * client.getResourceTemplate + * + * @description get the template for a provided resource type + * + * @param {string} resourceType the resourceType to get the template for + * @param {function} callback f(err, template) + * @returns {*} + */ +exports.getResourceTemplate = function (resourceType, callback) { + var self = this; + + return self._request({ + path: urlJoin(_urlPrefix, resourceType, 'template') + }, function (err, template) { + if (err) { + return callback(err); + } + + callback(null, template); + }); +}; \ No newline at end of file diff --git a/lib/pkgcloud/openstack/orchestration/client/templates.js b/lib/pkgcloud/openstack/orchestration/client/templates.js new file mode 100644 index 000000000..9937c1fbd --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/client/templates.js @@ -0,0 +1,99 @@ +/* + * templates.js: Instance methods for working with templates from OpenStack Orchestration + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ +var request = require('request'), + pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + urlJoin = require('url-join'), + util = require('util'), + _ = require('underscore'), + orchestration = pkgcloud.providers.openstack.orchestration; + +var _urlPrefix = '/stacks'; + +/** + * client.getTemplate + * + * @description get the template for a provided stack + * + * @param {object|string} stack the stackName or stack for the template query + * @param {function} callback f(err, template) + * @returns {*} + */ +exports.getTemplate = function (stack, callback) { + var self = this; + + if (stack instanceof orchestration.Stack) { + getTemplate(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function(err, stack) { + if (err) { + callback(err); + return; + } + + getTemplate(stack); + }); + } + + function getTemplate(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'template') + }, function (err, body) { + if (err) { + return callback(err); + } + if (!body) { + return new Error('Unexpected empty response'); + } + else { + callback(null, body); + } + }); + } +}; + +/** + * client.validateTemplate + * + * @description validate a provided template + * + * @param {object|string} template the template or templateUrl to validate + * @param {function} callback f(err, template) + * @returns {*} + */ +exports.validateTemplate = function (template, callback) { + var self = this, + requestOpts = { + path: urlJoin('/validate'), + method: 'POST', + body: {} + }; + + if (typeof template === 'string') { + requestOpts.body.template_url = template; + } + else if (typeof template === 'object') { + requestOpts.body.template = template; + } + else { + callback(new Error('please provide either a template object, or a templateUrl')) + } + + return self._request(requestOpts, function (err, body) { + if (err) { + return callback(err); + } + if (!body) { + return new Error('Unexpected empty response'); + } + else { + callback(null, body); + } + }); +}; diff --git a/lib/pkgcloud/openstack/orchestration/index.js b/lib/pkgcloud/openstack/orchestration/index.js index 211721d01..61f6569bd 100644 --- a/lib/pkgcloud/openstack/orchestration/index.js +++ b/lib/pkgcloud/openstack/orchestration/index.js @@ -8,7 +8,7 @@ exports.Client = require('./client').Client; exports.Stack = require('./stack').Stack; -//exports.Image = require('./image').Image; +exports.Resource = require('./resource').Resource; //exports.Server = require('./server').Server; exports.createClient = function (options) { diff --git a/lib/pkgcloud/openstack/orchestration/resource.js b/lib/pkgcloud/openstack/orchestration/resource.js new file mode 100644 index 000000000..55dd0fa1a --- /dev/null +++ b/lib/pkgcloud/openstack/orchestration/resource.js @@ -0,0 +1,48 @@ +/* + * volume.js: OpenStack Orchestration Stack + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + * + */ + +var util = require('util'), + base = require('../../core/base'), + Stack = require('./stack').Stack, + _ = require('underscore'); + +var Resource = exports.Resource = function Stack(client, details) { + base.Model.call(this, client, details); +}; + +util.inherits(Resource, base.Model); + +Resource.prototype._setProperties = function (details) { + this.name = details.name || details['resource_name']; + this.status = details.status || details['resource_status']; + this.stack = details.stack; + this.statusReason = details.statusReason || details['resource_status_reason']; + this.type = details.type || details['resource_type']; + this.logicalResourceId = details.logicalResourceId || details['logical_resource_id']; + this.physicalResourceId = details.physicalResourceId || details['physical_resource_id']; + this.requiredBy = details.requiredBy || details['required_by']; + this.updatedAt = details.updatedAt || details['updated_time']; + this.links = details.links; +}; + +Resource.prototype.toJSON = function () { + + var data = _.pick(this, ['name', 'status', 'statusReason', 'type', 'logicalResourceId', 'physicalResourceId', + 'requiredBy', 'updatedAt', 'links']); + + this.stack instanceof Stack ? data.stack = this.stack.toJSON() : {}; + + return data; + +}; + + + + + From 72df3b401c85d6ffaaf1036f4852e40dc849e71f Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 20 Sep 2014 14:21:12 -0700 Subject: [PATCH 148/460] Adding build_info query --- lib/pkgcloud/openstack/orchestration/client/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js index d18982f18..7145079cc 100644 --- a/lib/pkgcloud/openstack/orchestration/client/index.js +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -48,3 +48,15 @@ Client.prototype._getUrl = function (options) { ? options : options.path); }; + +Client.prototype.buildInfo = function(callback) { + return this._request({ + path: '/build_info' + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body); + }); +}; From ca42e0604bda660b43f8d1041aee1942ab2841e3 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 20 Sep 2014 14:22:28 -0700 Subject: [PATCH 149/460] Adding comment for buildInfo --- lib/pkgcloud/openstack/orchestration/client/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js index 7145079cc..55074c664 100644 --- a/lib/pkgcloud/openstack/orchestration/client/index.js +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -9,7 +9,6 @@ var util = require('util'), openstack = require('../../client'), urlJoin = require('url-join'), -// ComputeClient = require('../computeClient').ComputeClient, _ = require('underscore'); var Client = exports.Client = function (options) { @@ -25,7 +24,6 @@ var Client = exports.Client = function (options) { }; util.inherits(Client, openstack.Client); -//_.extend(Client.prototype, ComputeClient.prototype); /** * client._getUrl @@ -49,6 +47,14 @@ Client.prototype._getUrl = function (options) { : options.path); }; +/** + * client.buildInfo + * + * @description gets the build information for the orchestration service + * + * @param callback + * @returns {*} + */ Client.prototype.buildInfo = function(callback) { return this._request({ path: '/build_info' From 1f966a106ce1224611283efa395a82b116cf48d1 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 20 Sep 2014 14:23:18 -0700 Subject: [PATCH 150/460] Minor typo in orchestration client --- lib/pkgcloud/openstack/orchestration/client/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js index 55074c664..770ba32e5 100644 --- a/lib/pkgcloud/openstack/orchestration/client/index.js +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -1,5 +1,5 @@ /* - * index.js: Compute client for OpenStack + * index.js: Orchestration client for OpenStack * * (C) 2014 Rackspace * Ken Perkins From 8cd0240f95ef6fd58324e76491bf93a307927211 Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Mon, 22 Sep 2014 11:53:38 -0700 Subject: [PATCH 151/460] Fix upload/download markdown links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b8d7a042a..fcf2c91ef 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ pkgcloud is a standard library for node.js that abstracts away differences among * [Supported APIs](#supported-apis) * [Compute](#compute) * [Storage](#storage) - * [Uploading Files](#uploading) - * [Downloading Files](#downloading) + * [Uploading Files](#upload-a-file) + * [Downloading Files](#download-a-file) * [Database](#databases) * [DNS](#dns----beta) *(beta)* * [Block Storage](#block-storage----beta) *(beta)* From 09cec18f26b169c606f06d995e0a8fc9416731ff Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 30 Sep 2014 16:53:18 -0700 Subject: [PATCH 152/460] Adding some clarifications for createStack --- lib/pkgcloud/openstack/orchestration/client/stacks.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 7aff769db..77973a32f 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -103,7 +103,8 @@ exports.createStack = function (details, callback) { path: details.preview ? urlJoin(_urlPrefix, 'preview'): _urlPrefix, body: { stack_name: details.name, - environment: details.environment, + // environment is required from the API, but may be empty + environment: details.environment ? JSON.stringify(details.environment) : JSON.stringify({}), timeout_mins: typeof details.timeout === 'number' ? details.timeout : parseInt(details.timeout) } }; @@ -130,6 +131,12 @@ exports.createStack = function (details, callback) { if (typeof details.disableRollback === 'boolean') { createOptions.body['disable_rollback'] = details.disableRollback; } + + // if we're adopting a stack, copy the parameters (if any) from the stackData to + // the request payload + if (details.stackData.parameters) { + createOptions.body.parameters = details.stackData.parameters; + } } return self._request(createOptions, function (err, body) { From 3d5a0b7ce4ae64813065fe4afa92fd148afc1a02 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 1 Oct 2014 10:20:17 -0700 Subject: [PATCH 153/460] First pass of orchestration docs --- README.md | 61 ++++++++- docs/providers/openstack/README.md | 2 + docs/providers/openstack/orchestration.md | 128 ++++++++++++++++++ .../openstack/orchestration/client/events.js | 58 ++++---- .../orchestration/client/resources.js | 44 +++--- .../openstack/orchestration/client/stacks.js | 62 ++++----- 6 files changed, 270 insertions(+), 85 deletions(-) create mode 100644 docs/providers/openstack/orchestration.md diff --git a/README.md b/README.md index b8d7a042a..e851ea36e 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Currently there are six service types which are handled by pkgcloud: * [Block Storage](#block-storage----beta) *(beta)* * [Load Balancers](#load-balancers----beta) *(beta)* * [Network](#network----beta) *(beta)* +* [Orchestration](#orchestration----beta) *(beta)* In our [Roadmap](#roadmap), we plan to add support for more services, such as Queueing, Monitoring, and more. Additionally, we plan to implement more providers for the *beta* services, thus moving them out of *beta*. @@ -120,9 +121,11 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](docs/providers/rackspace/blockstorage.md) * **[Load Balancers](#load-balancers----beta)** *(beta)* * [Rackspace](docs/providers/rackspace/loadbalancer.md) +* **[Orchestration](#orchestration----beta)** *(beta)* + * [Openstack](docs/providers/openstack/orchestration.md) * **[Network](#network----beta)** *(beta)* - * [HP](docs/providers/hp/network.md) - * [Openstack](docs/providers/openstack/network.md) + * [HP](docs/providers/hp/network.md) + * [Openstack](docs/providers/openstack/network.md) ## Compute @@ -438,7 +441,6 @@ Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.creat * `client.updateNetwork(network, function (err, network) { })` * `client.deleteNetwork(network, function (err, networkId) { })` - ### Subnets * `client.getSubnets(options, function (err, subnets) { })` * `client.getSubnet(subnet, function (err, subnet) { })` @@ -453,6 +455,59 @@ Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.creat * `client.updatePort(port, function (err, port) { })` * `client.deletePort(port, function (err, portId) { })` +## Orchestration -- Beta + +##### Note: Orchestration is considered Beta until there are multiple providers; presently only Openstack are supported. + +The `pkgcloud.orchestration` service is designed to allow you to access Openstack Heat via node.js. You can manage stacks and resources from within any node.js application. + +To get started with a `pkgcloud.orchestration` client just create one: + +``` js + var client = require('pkgcloud').orchestration.createClient({ + // + // The name of the provider (e.g. "openstack") + // + provider: 'provider-name', + + // + // ... Provider specific credentials + // + }); +``` + +#### Providers + +* [Openstack](docs/providers/openstack/orchestration.md) + +Each instance of `pkgcloud.orchestration.Client` returned from `pkgcloud.orchestration.createClient` has a set of uniform APIs: + +### Stack +* `client.getStack(stack, function (err, stack) { })` +* `client.getStacks(options, function (err, stacks) { })` +* `client.createStack(details, function (err, stack) { })` +* `client.previewStack(details, function (err, stack) { })` +* `client.adoptStack(details, function (err, stack) { })` +* `client.updateStack(stack, function (err, stack) { })` +* `client.deleteStack(stack, function (err) { })` +* `client.abandonStack(stack, function (err, abandonedStack) { })` +* `client.getTemplate(stack, function (err, template) { })` + +### Resources +* `client.getResource(stack, resource, function (err, resource) { })` +* `client.getResources(stack, function (err, resources) { })` +* `client.getResourceTypes(function (err, resourceTypes) { })` +* `client.getResourceSchema(resourceType, function (err, resourceSchema) { })` +* `client.getResourceTemplate(resourceType, function (err, resourceTemplate) { })` + +### Events +* `client.getEvent(stack, resource, eventId, function (err, event) { })` +* `client.getEvents(stack, function (err, events) { })` +* `client.getResourceEvents(stack, resource, function (err, events) { })` + +### Templates +* `client.validateTemplate(template, function (err, template) { })` + ## Installation ``` bash diff --git a/docs/providers/openstack/README.md b/docs/providers/openstack/README.md index f525d7627..d372f0f68 100644 --- a/docs/providers/openstack/README.md +++ b/docs/providers/openstack/README.md @@ -4,6 +4,8 @@ The OpenStack provider in pkgcloud supports the following services: * [**Compute**](compute.md) (Nova) * [**Storage**](storage.md) (Swift) +* [**Network**](network.md) (Neutron) +* [**Orchestration**](orchestration.md) (Heat) ### Getting Started with Compute diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md new file mode 100644 index 000000000..f36024917 --- /dev/null +++ b/docs/providers/openstack/orchestration.md @@ -0,0 +1,128 @@ +##Using the Openstack Orchestration provider + +Creating a client is straight-forward: + +``` js + var openstack = pkgcloud.orchestration.createClient({ + provider: 'openstack', + username: 'your-user-name', + password: 'your-password', + authUrl: 'https://your-identity-service' + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +## Stacks + +#### client.getStacks([options], callback) +Lists all stacks that are available to use on your Openstack account + +Callback returns `f(err, stacks)` where `stacks` is an `Array` + +#### client.createStack(options, callback) +Creates a stack with the options specified. + +Options are as follows: + +```js +{ + name: 'my-stack-name', // required + timeout: 30, // timeout, in minutes, required + templateUrl: 'http://path.to.some.openstack.heat.template', // required, unless you pass template directly + template: { ... }, // optional, unless you don't provide templateUrl + parameters: { ... }, // optional parameters for the stack + environment: { ... }, // optional environment values for the stack + files: { ... }, // optional files for the stack +} +``` +Returns the stack in the callback `f(err, stack)` + +#### client.getStack(stack, callback) +Retrieves the provided stack or stackId from the service. Callback has the signature `f(err, stack)`. + +#### client.previewStack(details, callback) +Identical to the `client.createStack()` call, except it only previews the creation, instead of actually provisioning +the stack. + +Returns the previewed stack in the callback `f(err, stack)` + +#### client.adoptStack(details, callback) +Identical to the `client.createStack()` call, except it requires passing `details.stackData` which is the `abandonedStack` +value returned from `client.abandonStack()`. + +Returns the created stack in the callback `f(err, stack)` + +#### client.updateStack(stack, callback) + +Update the provided stack. + +The following values from the provided stack are updatable. + +```js +{ + name: 'my-stack-name', // required + timeout: 30, // timeout, in minutes, required + templateUrl: 'http://path.to.some.openstack.heat.template', // required, unless you pass template directly + template: { ... }, // optional, unless you don't provide templateUrl + parameters: { ... }, // optional parameters for the stack + environment: { ... }, // optional environment values for the stack + files: { ... }, // optional files for the stack +} +``` + +#### client.deleteStack(stack, callback) + +Delete the created stack, and delete the resources. Callback is `f(err)`. + +#### client.abandonStack(stack, callback) + +Delete the created stack, but leave the resources running. Will callback with `f(err, abandonedStack)` where the +`abandonedStack` would be passed in as an option to `client.createStack()`. + +#### client.getTemplate(stack, callback) + +Get the template for a provided stack. Will callback with `f(err, template)`. + +## Resources + +#### client.getResource(stack, resource, callback) + +Get the resource for a provided stack and resource or resourceName in the callback `f(err, +resource)` + +#### client.getResources(stack, callback) +Get the resources for a provided stack. Callback is `f(err, resources)`. + +#### client.getResourceTypes(callback) +Get a list of valid resource types. Callback is `f(err, resourceTypes)`. + +#### client.getResourceSchema(resourceType, callback) +Get the schema for a provided resourceType. Callback is `f(err, resourceSchema)`. + +#### client.getResourceTemplate(resourceType, callback) +Get the template for a provided resourceType. Callback is `f(err, resourceTemplate)`. + +## Events + +#### client.getEvent(stack, resource, eventId, callback) +Get the event for a provided stack, resource and eventId. + +`f(err, event)` + +#### client.getEvents(stack, callback) +Get all of the events for a provided stack + +`f(err, events)` + +#### client.getResourceEvents(stack, resource, callback) +Get all of the events for a stack and resource. + +`f(err, events)` + +## Templates + +#### client.validateTemplate(template, callback) +Validates a provided template, with a callback of `f(err, template)`. \ No newline at end of file diff --git a/lib/pkgcloud/openstack/orchestration/client/events.js b/lib/pkgcloud/openstack/orchestration/client/events.js index c22f843d8..191c7b521 100644 --- a/lib/pkgcloud/openstack/orchestration/client/events.js +++ b/lib/pkgcloud/openstack/orchestration/client/events.js @@ -16,19 +16,21 @@ var request = require('request'), var _urlPrefix = '/stacks'; /** - * client.getEvents + * client.getEvent * - * @description get the list of stack events for a provided stack + * @description get the event for a provided stack, resource, and eventName * - * @param {object|string} stack stack or stackName to find events for - * @param {function} callback f(err, events) where stacks is an array of Event + * @param {object|string} stack stack or stackName + * @param {object|string} resource resource or resourceName + * @param {string} eventId eventId to query for + * @param {function} callback f(err, event) * @returns {*} */ -exports.getEvents = function(stack, callback) { +exports.getEvent = function (stack, resource, eventId, callback) { var self = this; if (stack instanceof orchestration.Stack) { - getEvents(stack); + getEvent(stack); } else if (typeof stack === 'string') { self.getStack(stack, function (err, stack) { @@ -37,35 +39,35 @@ exports.getEvents = function(stack, callback) { return; } - getEvents(stack); + getEvent(stack); }); } - function getEvents(stack) { + function getEvent(stack) { return self._request({ - path: urlJoin(_urlPrefix, stack.name, stack.id, 'events') + path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', + resource instanceof orchestration.Resource ? resource.name : resource, 'events', eventId) }, function (err, body) { if (err) { return callback(err); } - callback(null, body.events); + callback(null, body.event); }); } }; /** - * client.getResourceEvents + * client.getEvents * - * @description get the list of stack events for a provided stack and resource + * @description get the list of stack events for a provided stack * * @param {object|string} stack stack or stackName to find events for - * @param {object|string} resource resource or resourceName to find events for * @param {function} callback f(err, events) where stacks is an array of Event * @returns {*} */ -exports.getResourceEvents = function (stack, resource, callback) { +exports.getEvents = function(stack, callback) { var self = this; if (stack instanceof orchestration.Stack) { @@ -84,8 +86,7 @@ exports.getResourceEvents = function (stack, resource, callback) { function getEvents(stack) { return self._request({ - path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', - resource instanceof orchestration.Resource ? resource.name : resource, 'events') + path: urlJoin(_urlPrefix, stack.name, stack.id, 'events') }, function (err, body) { if (err) { return callback(err); @@ -98,21 +99,20 @@ exports.getResourceEvents = function (stack, resource, callback) { }; /** - * client.getEvent + * client.getResourceEvents * - * @description get the event for a provided stack, resource, and eventName + * @description get the list of stack events for a provided stack and resource * - * @param {object|string} stack stack or stackName - * @param {object|string} resource resource or resourceName - * @param {string} eventId eventId to query for - * @param {function} callback f(err, event) + * @param {object|string} stack stack or stackName to find events for + * @param {object|string} resource resource or resourceName to find events for + * @param {function} callback f(err, events) where stacks is an array of Event * @returns {*} */ -exports.getEvent = function (stack, resource, eventId, callback) { +exports.getResourceEvents = function (stack, resource, callback) { var self = this; if (stack instanceof orchestration.Stack) { - getEvent(stack); + getEvents(stack); } else if (typeof stack === 'string') { self.getStack(stack, function (err, stack) { @@ -121,21 +121,21 @@ exports.getEvent = function (stack, resource, eventId, callback) { return; } - getEvent(stack); + getEvents(stack); }); } - function getEvent(stack) { + function getEvents(stack) { return self._request({ path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', - resource instanceof orchestration.Resource ? resource.name : resource, 'events', eventId) + resource instanceof orchestration.Resource ? resource.name : resource, 'events') }, function (err, body) { if (err) { return callback(err); } - callback(null, body.event); + callback(null, body.events); }); } -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/orchestration/client/resources.js b/lib/pkgcloud/openstack/orchestration/client/resources.js index 823a50ced..bb1b158cb 100644 --- a/lib/pkgcloud/openstack/orchestration/client/resources.js +++ b/lib/pkgcloud/openstack/orchestration/client/resources.js @@ -16,19 +16,20 @@ var request = require('request'), var _urlPrefix = '/resource_types'; /** - * client.getResources + * client.getResource * - * @description get the list of stack resources for a provided stack + * @description get the resource data for a provided resource and stack * * @param {object|string} stack stack or stackName to find resources for - * @param {function} callback f(err, resources) where stacks is an array of Resource + * @param {object|string} resource resource or resourceName to get + * @param {function} callback f(err, resource) * @returns {*} */ -exports.getResources = function (stack, callback) { +exports.getResource = function (stack, resource, callback) { var self = this; if (stack instanceof orchestration.Stack) { - getResources(stack); + getResource(stack); } else if (typeof stack === 'string') { self.getStack(stack, function (err, stack) { @@ -37,40 +38,38 @@ exports.getResources = function (stack, callback) { return; } - getResources(stack); + getResource(stack); }); } - function getResources(stack) { + function getResource(stack) { return self._request({ - path: urlJoin('/stacks', stack.name, stack.id, 'resources') + path: urlJoin('/stacks', stack.name, stack.id, 'resources', + resource instanceof orchestration.Resource ? resource.name : resource) }, function (err, body) { if (err) { return callback(err); } - callback(null, body.resources.map(function(resource) { - return new orchestration.Resource(self, _.extend({ stack: stack }, resource)); - })); + callback(null, new orchestration.Resource(self, _.extend({ stack: stack }, body.resource))); }); } }; /** - * client.getResource + * client.getResources * - * @description get the resource data for a provided resource and stack + * @description get the list of stack resources for a provided stack * * @param {object|string} stack stack or stackName to find resources for - * @param {object|string} resource resource or resourceName to get - * @param {function} callback f(err, resource) + * @param {function} callback f(err, resources) where stacks is an array of Resource * @returns {*} */ -exports.getResource = function (stack, resource, callback) { +exports.getResources = function (stack, callback) { var self = this; if (stack instanceof orchestration.Stack) { - getResource(stack); + getResources(stack); } else if (typeof stack === 'string') { self.getStack(stack, function (err, stack) { @@ -79,20 +78,21 @@ exports.getResource = function (stack, resource, callback) { return; } - getResource(stack); + getResources(stack); }); } - function getResource(stack) { + function getResources(stack) { return self._request({ - path: urlJoin('/stacks', stack.name, stack.id, 'resources', - resource instanceof orchestration.Resource ? resource.name : resource) + path: urlJoin('/stacks', stack.name, stack.id, 'resources') }, function (err, body) { if (err) { return callback(err); } - callback(null, new orchestration.Resource(self, _.extend({ stack: stack }, body.resource))); + callback(null, body.resources.map(function(resource) { + return new orchestration.Resource(self, _.extend({ stack: stack }, resource)); + })); }); } }; diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 77973a32f..0a3c840c8 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -15,6 +15,36 @@ var request = require('request'), var _urlPrefix = '/stacks'; +/** + * client.getStack + * + * @description Gets a stack from the account + * + * @param {String|object} stack The stack or stackName to fetch + * @param {Function} callback + * @returns {request|*} + */ +exports.getStack = function (stack, callback) { + var self = this, + path = stack instanceof orchestration.Stack + ? urlJoin(_urlPrefix, stack.name, stack.id) + : urlJoin(_urlPrefix, stack); + + return this._request({ + path: path + }, function (err, body) { + if (err) { + return callback(err); + } + if (!body.stack) { + return new Error('Unexpected empty response'); + } + else { + callback(null, new orchestration.Stack(self, body.stack)); + } + }); +}; + /** * client.getStacks * @@ -70,8 +100,8 @@ exports.getStacks = function getStacks(options, callback) { * @param {object} details the details to create this stack * @param {String} details.name the name of the new stack - * @param {String} details.environment the environment for the stack * @param {Number} details.timeout timeout in minutes for stack creation + * @param {String} [details.environment] the environment for the stack * @param {Object} [details.template] template for the stack, required unless templateUrl is provided * @param {String} [details.templateUrl] url for the template, required if no template * @param {Object} [details.parameters] optional parameters configuration @@ -194,36 +224,6 @@ exports.adoptStack = function (details, callback) { return this.createStack(details, callback); }; -/** - * client.getStack - * - * @description Gets a stack from the account - * - * @param {String|object} stack The stack or stackName to fetch - * @param {Function} callback - * @returns {request|*} - */ -exports.getStack = function (stack, callback) { - var self = this, - path = stack instanceof orchestration.Stack - ? urlJoin(_urlPrefix, stack.name, stack.id) - : urlJoin(_urlPrefix, stack); - - return this._request({ - path: path - }, function (err, body) { - if (err) { - return callback(err); - } - if (!body.stack) { - return new Error('Unexpected empty response'); - } - else { - callback(null, new orchestration.Stack(self, body.stack)); - } - }); -}; - /** * client.updateStack * From fb91ace8404d768cd739f87d6e3b6b129b0f1fd6 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 1 Oct 2014 10:20:59 -0700 Subject: [PATCH 154/460] Adding a link to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e851ea36e..ff988424b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ pkgcloud is a standard library for node.js that abstracts away differences among * [DNS](#dns----beta) *(beta)* * [Block Storage](#block-storage----beta) *(beta)* * [Load Balancers](#load-balancers----beta) *(beta)* +* [Orchestration](#orchestration----beta) *(beta)* * [Network](#network----beta) *(beta)* * _Fine Print_ * [Installation](#installation) From 2641a0d7230f6e84125e48126bbc25d03e9b7cb3 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 3 Oct 2014 10:05:24 -0700 Subject: [PATCH 155/460] First pass of orchestration tests --- .../openstack/orchestration/client/stacks.js | 8 +- .../getStack-create-in-progress.json | 39 ++++ test/fixtures/openstack/realToken.json | 10 + .../orchestration/create-stacks-test.js | 132 +++++++++++ .../orchestration/get-stacks-test.js | 205 ++++++++++++++++++ 5 files changed, 391 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/openstack/getStack-create-in-progress.json create mode 100644 test/openstack/orchestration/create-stacks-test.js create mode 100644 test/openstack/orchestration/get-stacks-test.js diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 0a3c840c8..485866ce9 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -5,6 +5,7 @@ * Ken Perkins * MIT LICENSE */ + var request = require('request'), pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), @@ -74,11 +75,11 @@ exports.getStacks = function getStacks(options, callback) { 'sort'); if (options.sortDir) { - requestOptions['sort_dir'] = options.sortDir; + requestOptions.qs['sort_dir'] = options.sortDir; } if (options.sortKeys) { - requestOptions['sort_keys'] = options.sortKeys; + requestOptions.qs['sort_keys'] = options.sortKeys; } return this._request(requestOptions, function (err, body) { @@ -178,7 +179,8 @@ exports.createStack = function (details, callback) { return new Error('Stack not passed back from OpenStack.'); } - callback(err, new orchestration.Stack(self, body.stack)); + // since createStack returns an href to the stack, lets go fetch it + self.getStack(body.stack.id, callback); }); }; diff --git a/test/fixtures/openstack/getStack-create-in-progress.json b/test/fixtures/openstack/getStack-create-in-progress.json new file mode 100644 index 000000000..5b7c45647 --- /dev/null +++ b/test/fixtures/openstack/getStack-create-in-progress.json @@ -0,0 +1,39 @@ +{ + "stack": { + "disable_rollback": true, + "description": "This is a Heat template to deploy a single Linux server running a Minecraft\nserver. The Minecraft server will be setup leveraging Chef solo.\n", + "parameters": { + "server_hostname": "minecraft", + "terms": "True", + "OS::stack_id": "e20b614b-c3ee-4b8b-bf4f-c05aaca947a2", + "OS::stack_name": "stack-test", + "minecraft_server_port": "25565", + "image": "Ubuntu 14.04 LTS (Trusty Tahr)", + "minecraft_spawn_monsters": "true", + "minecraft_spawn_npcs": "true", + "minecraft_gamemode": "0", + "minecraft_version": "1.8", + "minecraft_spawn_animals": "true", + "flavor": "4 GB Performance", + "chef_version": "11.16.0", + "kitchen": "https://github.com/rackspace-orchestration-templates/minecraft" + }, + "stack_status_reason": "Stack CREATE started", + "stack_name": "stack-test", + "stack_owner": null, + "creation_time": "2014-10-03T16:49:10Z", + "links": [ + { + "href": "http://localhost:12345/v1/72e90ecb69c44d0296072ea39e537041/stacks/stack-test/e20b614b-c3ee-4b8b-bf4f-c05aaca947a2", + "rel": "self" + } + ], + "capabilities": [], + "notification_topics": [], + "timeout_mins": 30, + "stack_status": "CREATE_IN_PROGRESS", + "updated_time": null, + "id": "e20b614b-c3ee-4b8b-bf4f-c05aaca947a2", + "template_description": "This is a Heat template to deploy a single Linux server running a Minecraft\nserver. The Minecraft server will be setup leveraging Chef solo.\n" + } +} \ No newline at end of file diff --git a/test/fixtures/openstack/realToken.json b/test/fixtures/openstack/realToken.json index 89d1d2ec8..ecbeaa49f 100644 --- a/test/fixtures/openstack/realToken.json +++ b/test/fixtures/openstack/realToken.json @@ -84,6 +84,16 @@ "endpoints_links": [], "type": "identity", "name": "keystone" + }, + { + "name": "heat", + "endpoints": [ + { + "region": "Calxeda-AUS1", + "publicURL": "http://localhost:12345/v1/72e90ecb69c44d0296072ea39e537041" + } + ], + "type": "orchestration" } ], "user": { diff --git a/test/openstack/orchestration/create-stacks-test.js b/test/openstack/orchestration/create-stacks-test.js new file mode 100644 index 000000000..a525770d0 --- /dev/null +++ b/test/openstack/orchestration/create-stacks-test.js @@ -0,0 +1,132 @@ +/* + * create-stacks-test.js: Test Methods for openstack heat stacks + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ + +var Client = new require('../../../lib/pkgcloud/core/base/client').Client; +var helpers = require('../../helpers'); + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + Stack = require('../../../lib/pkgcloud/openstack/orchestration/stack').Stack, + mock = !!process.env.MOCK; + +var client = helpers.createClient('openstack', 'orchestration'); + +var options = {}; + +describe('pkgcloud/openstack/orchestration/stacks[createStacks]', function () { + + var authHockInstance, hockInstance, authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the createStacks method should return a stack', function (done) { + if (mock) { + authHockInstance + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + hockInstance + .post('/v1/72e90ecb69c44d0296072ea39e537041/stacks', { + 'stack_name': 'stack-test', + environment: '{}', + 'timeout_mins': 30, + template_url: 'https://raw.githubusercontent.com/rackspace-orchestration-templates/minecraft/master/minecraft-server.yaml', + parameters: { terms: true } + }) + .reply(201, { stack: + { id: 'b39ecc51-8ac0-4396-a178-17fdc63f5d40', + links: [ + { href: 'http://localhost:12345//v1/72e90ecb69c44d0296072ea39e537041/stacks/stack-test/b39ecc51-8ac0-4396-a178-17fdc63f5d40', + rel: 'self' } + ] } }) + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/b39ecc51-8ac0-4396-a178-17fdc63f5d40') + .reply(301, {}, { Location: 'http://localhost:12345/v1/72e90ecb69c44d0296072ea39e537041/stacks/stack-test/b39ecc51-8ac0-4396-a178-17fdc63f5d40' }) + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/stack-test/b39ecc51-8ac0-4396-a178-17fdc63f5d40') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/getStack-create-in-progress.json'); + } + + client.createStack({ + name: 'stack-test', + timeout: 30, + templateUrl: 'https://raw.githubusercontent.com/rackspace-orchestration-templates/minecraft/master/minecraft-server.yaml', + parameters: { terms: true } + },function (err, stack) { + should.not.exist(err); + stack.should.be.instanceof(Stack); + stack.name.should.equal('stack-test'); + stack.status.should.equal('CREATE_IN_PROGRESS'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done) + }); + +}); + + + + + diff --git a/test/openstack/orchestration/get-stacks-test.js b/test/openstack/orchestration/get-stacks-test.js new file mode 100644 index 000000000..749009b30 --- /dev/null +++ b/test/openstack/orchestration/get-stacks-test.js @@ -0,0 +1,205 @@ +/* + * get-stacks-test.js: Test Methods for openstack heat stacks + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ + +var Client = new require('../../../lib/pkgcloud/core/base/client').Client; +var helpers = require('../../helpers'); + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK; + +var client = helpers.createClient('openstack', 'orchestration'); + +var options = {}; + +describe('pkgcloud/openstack/orchestration/stacks[getStacks]', function () { + + var authHockInstance, hockInstance, authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getStacks method should return an empty array', function (done) { + if (mock) { + authHockInstance + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks') + .reply(200, { stacks: [] }); + } + + client.getStacks(function (err, stacks) { + should.not.exist(err); + stacks.should.be.an.Array; + stacks.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + it('the getStacks method with name should pass option correctly', function (done) { + if (mock) { + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks?name=foo') + .reply(200, { stacks: [] }); + } + + client.getStacks({ name: 'foo' }, function (err, stacks) { + should.not.exist(err); + stacks.should.be.an.Array; + stacks.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + it('the getStacks method with sortDir should pass option correctly', function (done) { + if (mock) { + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks?sort_dir=foo') + .reply(200, { stacks: [] }); + } + + client.getStacks({ sortDir: 'foo' }, function (err, stacks) { + should.not.exist(err); + stacks.should.be.an.Array; + stacks.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + it('the getStacks method with sortKeys should pass option correctly', function (done) { + if (mock) { + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks?sort_keys=foo') + .reply(200, { stacks: [] }); + } + + client.getStacks({ sortKeys: 'foo' }, function (err, stacks) { + should.not.exist(err); + stacks.should.be.an.Array; + stacks.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + it('the getStacks method with status should pass option correctly', function (done) { + if (mock) { + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks?status=foo') + .reply(200, { stacks: [] }); + } + + client.getStacks({ status: 'foo' }, function (err, stacks) { + should.not.exist(err); + stacks.should.be.an.Array; + stacks.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + it('the getStacks method with limit & marker should pass option correctly', function (done) { + if (mock) { + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks?limit=10&marker=foo') + .reply(200, { stacks: [] }); + } + + client.getStacks({ limit: 10, marker: 'foo' }, function (err, stacks) { + should.not.exist(err); + stacks.should.be.an.Array; + stacks.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done) + }); + +}); + + + + + From 839d588674967ccdbaf91542157f8d8f4fe51453 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 3 Oct 2014 10:43:31 -0700 Subject: [PATCH 156/460] Cleaning up createStack options --- docs/providers/openstack/orchestration.md | 1 - .../openstack/orchestration/client/stacks.js | 12 +++++------- test/openstack/orchestration/create-stacks-test.js | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index f36024917..f82a05590 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -67,7 +67,6 @@ The following values from the provided stack are updatable. timeout: 30, // timeout, in minutes, required templateUrl: 'http://path.to.some.openstack.heat.template', // required, unless you pass template directly template: { ... }, // optional, unless you don't provide templateUrl - parameters: { ... }, // optional parameters for the stack environment: { ... }, // optional environment values for the stack files: { ... }, // optional files for the stack } diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 485866ce9..77f317f06 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -105,7 +105,6 @@ exports.getStacks = function getStacks(options, callback) { * @param {String} [details.environment] the environment for the stack * @param {Object} [details.template] template for the stack, required unless templateUrl is provided * @param {String} [details.templateUrl] url for the template, required if no template - * @param {Object} [details.parameters] optional parameters configuration * @param {Object} [details.files] optional files configuration * @param callback * @returns {request|null} @@ -135,7 +134,7 @@ exports.createStack = function (details, callback) { body: { stack_name: details.name, // environment is required from the API, but may be empty - environment: details.environment ? JSON.stringify(details.environment) : JSON.stringify({}), + environment: details.environment ? details.environment : {}, timeout_mins: typeof details.timeout === 'number' ? details.timeout : parseInt(details.timeout) } }; @@ -147,10 +146,6 @@ exports.createStack = function (details, callback) { createOptions.body['template_url'] = details.templateUrl; } - if (details.parameters) { - createOptions.body.parameters = details.parameters; - } - if (details.files) { createOptions.body.files = details.files; } @@ -166,10 +161,13 @@ exports.createStack = function (details, callback) { // if we're adopting a stack, copy the parameters (if any) from the stackData to // the request payload if (details.stackData.parameters) { - createOptions.body.parameters = details.stackData.parameters; + createOptions.body.environment.parameters = details.stackData.parameters; } } + // stringify this as the API for openstack requires a string for environment, not an object + createOptions.body.environment = JSON.stringify(createOptions.body.environment); + return self._request(createOptions, function (err, body) { if (err) { return callback(err); diff --git a/test/openstack/orchestration/create-stacks-test.js b/test/openstack/orchestration/create-stacks-test.js index a525770d0..ec9e53d0b 100644 --- a/test/openstack/orchestration/create-stacks-test.js +++ b/test/openstack/orchestration/create-stacks-test.js @@ -77,7 +77,7 @@ describe('pkgcloud/openstack/orchestration/stacks[createStacks]', function () { environment: '{}', 'timeout_mins': 30, template_url: 'https://raw.githubusercontent.com/rackspace-orchestration-templates/minecraft/master/minecraft-server.yaml', - parameters: { terms: true } + environment: JSON.stringify({ parameters: { terms: true } }) }) .reply(201, { stack: { id: 'b39ecc51-8ac0-4396-a178-17fdc63f5d40', @@ -95,7 +95,7 @@ describe('pkgcloud/openstack/orchestration/stacks[createStacks]', function () { name: 'stack-test', timeout: 30, templateUrl: 'https://raw.githubusercontent.com/rackspace-orchestration-templates/minecraft/master/minecraft-server.yaml', - parameters: { terms: true } + environment: { parameters: { terms: true } } },function (err, stack) { should.not.exist(err); stack.should.be.instanceof(Stack); From de09b9b94881ab924a0645c287bc67a84babaf1f Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 3 Oct 2014 11:18:57 -0700 Subject: [PATCH 157/460] Keeping parameters --- docs/providers/openstack/orchestration.md | 1 + .../openstack/orchestration/client/stacks.js | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index f82a05590..f36024917 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -67,6 +67,7 @@ The following values from the provided stack are updatable. timeout: 30, // timeout, in minutes, required templateUrl: 'http://path.to.some.openstack.heat.template', // required, unless you pass template directly template: { ... }, // optional, unless you don't provide templateUrl + parameters: { ... }, // optional parameters for the stack environment: { ... }, // optional environment values for the stack files: { ... }, // optional files for the stack } diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 77f317f06..485866ce9 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -105,6 +105,7 @@ exports.getStacks = function getStacks(options, callback) { * @param {String} [details.environment] the environment for the stack * @param {Object} [details.template] template for the stack, required unless templateUrl is provided * @param {String} [details.templateUrl] url for the template, required if no template + * @param {Object} [details.parameters] optional parameters configuration * @param {Object} [details.files] optional files configuration * @param callback * @returns {request|null} @@ -134,7 +135,7 @@ exports.createStack = function (details, callback) { body: { stack_name: details.name, // environment is required from the API, but may be empty - environment: details.environment ? details.environment : {}, + environment: details.environment ? JSON.stringify(details.environment) : JSON.stringify({}), timeout_mins: typeof details.timeout === 'number' ? details.timeout : parseInt(details.timeout) } }; @@ -146,6 +147,10 @@ exports.createStack = function (details, callback) { createOptions.body['template_url'] = details.templateUrl; } + if (details.parameters) { + createOptions.body.parameters = details.parameters; + } + if (details.files) { createOptions.body.files = details.files; } @@ -161,13 +166,10 @@ exports.createStack = function (details, callback) { // if we're adopting a stack, copy the parameters (if any) from the stackData to // the request payload if (details.stackData.parameters) { - createOptions.body.environment.parameters = details.stackData.parameters; + createOptions.body.parameters = details.stackData.parameters; } } - // stringify this as the API for openstack requires a string for environment, not an object - createOptions.body.environment = JSON.stringify(createOptions.body.environment); - return self._request(createOptions, function (err, body) { if (err) { return callback(err); From c78cd5023d2f1e6d390c04589c005c864a713c3b Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 3 Oct 2014 14:23:02 -0700 Subject: [PATCH 158/460] Adding explicit check for version in storage client --- lib/pkgcloud/openstack/storage/client/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pkgcloud/openstack/storage/client/index.js b/lib/pkgcloud/openstack/storage/client/index.js index 967c85d65..8fa11ef4c 100644 --- a/lib/pkgcloud/openstack/storage/client/index.js +++ b/lib/pkgcloud/openstack/storage/client/index.js @@ -13,6 +13,12 @@ var util = require('util'), _ = require('underscore'); var Client = exports.Client = function (options) { + // explicitly prevent service catalog usage if using version 1.0 for swift + // this must happen before we call into the base openstack client. + if (options.version === 1 || options.version === '/v1.0') { + options.useServiceCatalog = false; + } + openstack.Client.call(this, options); this.models = { From b46115408930c8990110fc5e455b13daf70537d9 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 3 Oct 2014 14:28:21 -0700 Subject: [PATCH 159/460] Adding some comments to clarify swift v1 auth --- lib/pkgcloud/openstack/context/identity.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index bc3ba87fc..c4af3c336 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -130,8 +130,10 @@ Identity.prototype.authorize = function (options, callback) { statusCode: response.statusCode }); + // If we've been asked to do v1 auth, check the response headers + // otherwise, check the body if (self.options.version === 1 || self.options.version === '/v1.0') { - self._storageURL = response.headers['x-storage-url']; + self._storageUrl = response.headers['x-storage-url']; self.token = { id: response.headers['x-auth-token'] }; @@ -257,8 +259,10 @@ Identity.prototype.getServiceEndpointUrl = function (options) { if (this.useServiceCatalog) { return this.serviceCatalog.getServiceEndpointUrl(options); } + // This is a hack to enable support for v1 swift clients + // TODO move all auth for v1 swift out of identity, as it's not related to identity at all else if (this.options.version === 1 || this.options.version === '/v1.0') { - return this._storageURL; + return this._storageUrl; } else { return this.options.url; From 61381494d1b7dac7919aabb85fd3ecb18056d3fb Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 6 Oct 2014 11:45:13 -0700 Subject: [PATCH 160/460] First commit of new storage api for amazon --- lib/pkgcloud/amazon/storage/client/files.js | 22 ++++++++++++++++++++- lib/pkgcloud/amazon/storage/file.js | 5 +++-- lib/pkgcloud/openstack/client.js | 2 +- package.json | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 45a7e1c01..eef051db8 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -10,6 +10,7 @@ var fs = require('fs'), util = require('util'), base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), + through = require('through2'), storage = pkgcloud.providers.amazon.storage, _ = require('underscore'); @@ -53,7 +54,26 @@ exports.upload = function (options) { s3Options.ContentType = options.contentType; } - return self.s3Stream.upload(s3Options); + var proxyStream = through(), + writableStream = self.s3Stream.upload(s3Options); + + // we need a proxy stream so we can always return a file model + // via the 'success' event + writableStream.on('uploaded', function(details) { + proxyStream.emit('success', new storage.File(self, details)); + }); + + writableStream.on('error', function(err) { + proxyStream.emit('error', err); + }); + + writableStream.on('data', function (chunk) { + proxyStream.emit('data', chunk); + }); + + proxyStream.pipe(writableStream); + + return proxyStream; }; exports.download = function (options) { diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index c0f94d389..d1ea8623f 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -22,7 +22,8 @@ File.prototype._setProperties = function (details) { this.etag = details.ETag || details.etag || null; this.lastModified = details.LastModified || details.lastModified || null; this.size = +(details.Size || details['content-length'] || details.ContentLength) || 0; - this.container = details.container; + this.container = details.container || details.Bucket; + this.location = details.location || details.Location; // amazon appears to send the etag double enquoted this.etag = this.etag ? this.etag.replace(/"/g,'') : this.etag; @@ -31,5 +32,5 @@ File.prototype._setProperties = function (details) { }; File.prototype.toJSON = function () { - return _.pick(this, ['name', 'etag', 'size', 'storageClass', 'lastModified' ]); + return _.pick(this, ['name', 'etag', 'size', 'storageClass', 'lastModified', 'container', 'location' ]); }; \ No newline at end of file diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 99c9f55a1..97955737a 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -7,7 +7,7 @@ var util = require('util'), request = require('request'), - through = require('through'), + through = require('through2'), base = require('../core/base'), errs = require('errs'), context = require('./context'); diff --git a/package.json b/package.json index a61596e27..9c3d1522e 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "ip": "0.3.x", "xml2js": "0.1.x", "mime": "1.2.x", - "through": "2.3.x", + "through2": "0.6.x", "qs": "1.2.x", "request": "2.40.x", "underscore": "1.6.x", From 0d55e7c6f507be06cfe06c5144d852e2d2687588 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 7 Oct 2014 13:25:48 -0400 Subject: [PATCH 161/460] Since HP is supported in pkgcloud, adding to the keywords in package.json. --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a61596e27..a60c6bdf6 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,10 @@ "iriscouch", "mongohq", "openstack", - "redistogo" + "redistogo", + "hpcloud", + "hp", + "helion" ], "dependencies": { "async": "0.9.x", From 926b4348811ef243ec2e5905fe34a63d72925269 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 7 Oct 2014 10:51:53 -0700 Subject: [PATCH 162/460] Working v1 streaming api --- lib/pkgcloud/amazon/storage/client/files.js | 5 + lib/pkgcloud/azure/storage/client/files.js | 260 ++++++++++-------- lib/pkgcloud/azure/storage/container.js | 5 + lib/pkgcloud/azure/storage/file.js | 5 + lib/pkgcloud/azure/storage/utils.js | 7 - lib/pkgcloud/openstack/client.js | 3 +- lib/pkgcloud/openstack/context/identity.js | 1 - .../openstack/storage/client/files.js | 106 ++++--- lib/pkgcloud/openstack/storage/file.js | 5 + test/common/storage/base-test.js | 15 +- 10 files changed, 230 insertions(+), 182 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index eef051db8..6d19d98dc 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -45,6 +45,11 @@ exports.removeFile = function (container, file, callback) { exports.upload = function (options) { var self = this; + // check for deprecated calling with a callback + if (typeof arguments[arguments.length - 1] === 'function') { + self.emit('log::warn', 'storage.upload no longer supports calling with a callback'); + } + var s3Options = { Bucket: options.container instanceof base.Container ? options.container.name : options.container, Key: options.remote instanceof base.File ? options.remote.name : options.remote diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 8368c34a0..26c40123b 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -7,6 +7,7 @@ var fs = require('fs'), filed = require('filed'), + through = require('through2'), mime = require('mime'), request = require('request'), util = require('util'), @@ -44,173 +45,214 @@ exports.removeFile = function (container, file, callback) { }); }; -exports.upload = function (options, callback) { - if (typeof options === 'function' && !callback) { - callback = options; - options = {}; - } +exports.upload = function (options) { + var self = this; - // - // Optional helper function passed to `this._request` - // in the case when no callback is passed to `.upload(options)`. - // - function onUpload(err, body, res) { - return err - ? callback(err) - : callback(null, res.statusCode === 200 || res.statusCode === 201, res); + // check for deprecated calling with a callback + if (typeof arguments[arguments.length - 1] === 'function') { + self.emit('log::warn', 'storage.upload no longer supports calling with a callback'); } - var container = options.container, - success = callback ? onUpload : null, - path, - writeableStream, - readableStream; - - if (container instanceof storage.Container) { - container = container.name; + // if we don't have a size, we need to immediately jump into multipart upload + if (!options.size) { + return self.multipartUpload(options); } - options.headers = options.headers || {}; + var writableStream, + proxyStream = through(), + uploadOptions = { + method: 'PUT', + upload: true, + headers: options.headers || {} + }; - if (options.local) { - readableStream = filed(options.local); - options.headers['content-length'] = fs.statSync(options.local).size; + if (options.container instanceof storage.Container) { + uploadOptions.path = urlJoin(options.container.name, options.remote); } - else if (options.stream) { - readableStream = options.stream; + else { + uploadOptions.path = urlJoin(options.container, options.remote); } - if (options.headers && !options.headers['content-type'] && options.remote) { - options.headers['content-type'] = mime.lookup(options.remote); + if (options.contentType) { + uploadOptions.headers['content-type'] = options.contentType; + } + else { + uploadOptions.headers['content-type'] = options.remote ? mime.lookup(options.remote) : mime.lookup(options.path); } - options.headers['x-ms-blob-type'] = AzureConstants.BlobConstants.BlobTypes.BLOCK; + uploadOptions.headers['content-length'] = options.size; + uploadOptions.headers['x-ms-blob-type'] = AzureConstants.BlobConstants.BlobTypes.BLOCK; - path = urlJoin(container, options.remote); + writableStream = self._request(uploadOptions); - if (options.azureBlockId) { - options.qs = { - comp: 'block', - blockid: options.azureBlockId - } - } + writableStream.on('complete', function() { + // load the file metadata from the cloud, so we can return a proper model + self.getFile(options.container, options.remote, function (err, file) { + if (err) { + proxyStream.emit('error', err); + return; + } - if (options.headers['content-length'] !== undefined) { - // Regular upload - writeableStream = this._request({ - method: 'PUT', - upload: true, - path: path, - headers: options.headers || {}, - qs: options.qs - }, success); - } else { - // Multi-part, 5mb chunk upload - writeableStream = this.multipartUpload(options, success); - } + proxyStream.emit('success', file); + }); + }); + + writableStream.on('error', function(err) { + proxyStream.emit('err', err); + }); - if (readableStream) readableStream.pipe(writeableStream); + writableStream.on('data', function (chunk) { + proxyStream.emit('data', chunk); + }); - return writeableStream; + // we need a proxy stream so we can always return a file model + // via the 'success' event + proxyStream.pipe(writableStream); + + return proxyStream; }; var getBlockId = function (a, b) { return "block" + ((1e15 + a + "").slice(-b)); }; -exports.multipartUpload = function (options, callback) { +exports.multipartUpload = function (options) { var self = this, - container = options.container, - chunk = AzureConstants.BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES, - numBlocks = 0, - chunksFinished = [], - chunkedStream = new storage.ChunkedStream(chunk), + numberOfBlocks = 0, + chunkedStream = new storage.ChunkedStream(AzureConstants.BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES), + proxyStream = through(), ended = false; - if (container instanceof storage.Container) { - container = container.name; - } - + // for each chunk of data, we need to upload a block chunkedStream.on('data', function (data) { chunkedStream.pause(); - options.azureBlockId = getBlockId(numBlocks++, 15); - options.headers['content-length'] = data.length; - var next = function (err, body, res) { - // TODO What to do if err here? - // TODO MUST FIX + var blockOptions = { + container: options.container, + remote: options.remote, + headers: options.headers || {}, + size: data.length, + blockId: getBlockId(numberOfBlocks++, 15) + }; + + var writableStream = self.uploadBlock(blockOptions); + + writableStream.on('error', function(err) { + chunkedStream.emit('error', err); + }); + + // when the block has been uploaded, resume if more data + writableStream.on('complete', function() { if (!ended) { chunkedStream.resume(); - } else { - self.sendBlockList(options, numBlocks, function(err, body, res) { - chunkedStream.complete(); - callback && callback(err, body, res); + } + else { + // when we're done with data, we need to upload the block list + self.sendBlockList(_.extend({ + numberOfBlocks: numberOfBlocks + } ,_.pick(options, ['remote', 'container', 'headers', 'contentType'])), function(err) { + if (err) { + proxyStream.emit('error', err); + return; + } + + // finally, fetch the file, and emit success on the original stream + self.getFile(options.container, options.remote, function(err, file) { + if (err) { + proxyStream.emit('error', err); + return; + } + + proxyStream.emit('success', file); + }); }); } - }; + }); - var writeableStream = self.upload(options, next); - writeableStream.write(data); - writeableStream.end(); + // write the chunk to the block stream, and end it. + writableStream.write(data); + writableStream.end(); }); - chunkedStream.on('end', function (data) { + chunkedStream.on('end', function () { ended = true; }); - return chunkedStream; + chunkedStream.on('error', function(err) { + proxyStream.emit('error', err); + }); + + proxyStream.pipe(chunkedStream); + + return proxyStream; }; -exports.sendBlockList = function (options, numBlocks, callback) { - var container = options.container, - body, - path, - qs; +exports.sendBlockList = function (options, callback) { + var putOptions = { + method: 'PUT', + headers: options.headers || {}, + qs: { + comp: 'blocklist' + } + }; - if (container instanceof storage.Container) { - container = container.name; + if (options.container instanceof storage.Container) { + putOptions.path = urlJoin(options.container.name, options.remote); + } + else { + putOptions.path = urlJoin(options.container, options.remote); } - - options.headers = options.headers || {}; // remove x-ms-blob-type header or request will fail - if (options.headers['x-ms-blob-type']) { - delete options.headers['x-ms-blob-type']; + if (putOptions.headers['x-ms-blob-type']) { + delete putOptions.headers['x-ms-blob-type']; } - if (options.headers['content-type']) { - options.headers['x-ms-blob-content-type'] = options.headers['content-type']; + if (options.contentType) { + putOptions.headers['x-ms-blob-content-type'] = options.contentType; } else if (options.remote) { - options.headers['x-ms-blob-content-type'] = mime.lookup(options.remote); + putOptions.headers['x-ms-blob-content-type'] = mime.lookup(options.remote); } - path = urlJoin(container, options.remote); - qs = { - comp: 'blocklist' - }; - - body = ''; - body += ''; - for (var i = 0; i < numBlocks; i++) { - body += '' + encodeURIComponent(getBlockId(i, 15)) + ''; + putOptions.body = ''; + putOptions.body += ''; + for (var i = 0; i < options.numberOfBlocks; i++) { + putOptions.body += '' + encodeURIComponent(getBlockId(i, 15)) + ''; } - body += ''; + putOptions.body += ''; - options.headers['content-length'] = body.length; + putOptions.headers['content-length'] = putOptions.body.length; - this._request({ - method: 'PUT', - path: path, - body: body, - headers: options.headers, - qs: qs - }, function (err, body, res) { + this._request(putOptions, function (err, body, res) { return err ? callback && callback(err) : callback && callback(null, res.statusCode === 201, res); }); }; +exports.uploadBlock = function(options) { + var uploadOptions = { + method: 'PUT', + upload: true, + headers: { + 'content-length': options.size + }, + qs: { + comp: 'block', + blockid: options.blockId + } + }; + + if (options.container instanceof storage.Container) { + uploadOptions.path = urlJoin(options.container.name, options.remote); + } + else { + uploadOptions.path = urlJoin(options.container, options.remote); + } + + return this._request(uploadOptions); +}; + exports.download = function (options, callback) { var self = this, success = callback ? onDownload : null, diff --git a/lib/pkgcloud/azure/storage/container.js b/lib/pkgcloud/azure/storage/container.js index 44be0552f..0e800b0fc 100644 --- a/lib/pkgcloud/azure/storage/container.js +++ b/lib/pkgcloud/azure/storage/container.js @@ -7,6 +7,7 @@ var util = require('util'), storage = require('../storage'), + _ = require('underscore'), base = require('../../core/storage/container'); var Container = exports.Container = function Container(client, details) { @@ -31,3 +32,7 @@ Container.prototype._setProperties = function (details) { this.original = this.azure = details; }; + +Container.prototype.toJSON = function () { + return _.pick(this, ['name']); +}; diff --git a/lib/pkgcloud/azure/storage/file.js b/lib/pkgcloud/azure/storage/file.js index c06b979ce..ce2a70e5b 100644 --- a/lib/pkgcloud/azure/storage/file.js +++ b/lib/pkgcloud/azure/storage/file.js @@ -6,6 +6,7 @@ */ var util = require('util'), + _ = require('underscore'), base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { @@ -26,3 +27,7 @@ File.prototype._setProperties = function (details) { this.size = (details['content-length']) ? parseInt(details['content-length'], 10) : 0; } }; + +File.prototype.toJSON = function () { + return _.pick(this, ['name', 'size', 'container' ]); +}; \ No newline at end of file diff --git a/lib/pkgcloud/azure/storage/utils.js b/lib/pkgcloud/azure/storage/utils.js index 6485a3972..c10963d33 100644 --- a/lib/pkgcloud/azure/storage/utils.js +++ b/lib/pkgcloud/azure/storage/utils.js @@ -70,13 +70,6 @@ ChunkedStream.prototype.end = function end() { this.emit('end'); }; ChunkedStream.prototype.close = ChunkedStream.prototype.end; -ChunkedStream.prototype.complete = function() { - if (!this.ended) { - this.end(); - } - - this.emit('complete'); -}; ChunkedStream.prototype.emitChunk = function emitChunk(chunk) { if (this.paused) { diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 97955737a..9c50b0ead 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -172,7 +172,8 @@ Client.prototype._request = function (options, callback) { var self = this; if (!self._isAuthorized()) { self.emit('log::trace', 'Not-Authenticated, inlining Auth...'); - var buf = through().pause(); + var buf = through(); + buf.pause(); self.auth(function (err) { if (err) { self.emit('log::error', 'Error with inline authentication', err); diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index 810e833f6..4857fbd4e 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -15,7 +15,6 @@ var _ = require('underscore'), url = require('url'), util = require('util'), urlJoin = require('url-join'), - util = require('util'), pkgcloud = require('../../../pkgcloud'), errs = require('errs'); diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index ad51f9ff0..bf94cbd73 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -13,6 +13,7 @@ var fs = require('fs'), util = require('util'), base = require('../../../core/storage'), pkgcloud = require('../../../../pkgcloud'), + through = require('through2'), _ = require('underscore'), storage = pkgcloud.providers.openstack.storage; @@ -59,81 +60,68 @@ exports.removeFile = function (container, file, callback) { * @param callback * @returns {request|*} */ -exports.upload = function (options, callback) { - if (typeof options === 'function' && !callback) { - callback = options; - options = {}; - } +exports.upload = function (options) { + var self = this; - // - // Optional helper function passed to `this._request` - // in the case when no callback is passed to `.upload(options)`. - // - function onUpload(err, body, res) { - return err - ? callback(err) - : callback(null, true, res); + // check for deprecated calling with a callback + if (typeof arguments[arguments.length - 1] === 'function') { + self.emit('log::warn', 'storage.upload no longer supports calling with a callback'); } var container = options.container, - success = callback ? onUpload : null, - self = this, - apiStream, - inputStream, - uploadOptions; - - if (container instanceof this.models.Container) { - container = container.name; + writableStream, + proxyStream = through(), + uploadOptions = { + method: 'PUT', + upload: true, + container: container, + path: options.remote, + headers: options.headers || {} + }; + + if (options.container instanceof this.models.Container) { + uploadOptions.container = options.container.name; } - uploadOptions = { - method: 'PUT', - upload: true, - container: container, - path: options.remote, - headers: options.headers || {} - }; - - if (options.local) { - inputStream = filed(options.local); - uploadOptions.headers['content-length'] = fs.statSync(options.local).size; - } - else if (options.stream) { - inputStream = options.stream; + if (options.contentType) { + uploadOptions.headers['content-type'] = options.contentType; } - - if (!uploadOptions.headers['content-type']) { + else { uploadOptions.headers['content-type'] = mime.lookup(options.remote); } - // If the inputStream is a request stream, headers are automatically - // copied from the source stream to the destination stream. - // As CloudFiles uses ETag to compute an md5 hash, this leads to a case - // where a remote resource with an ETag, piped via request to CloudFiles with - // pkgcloud, would result in a 422 "Unable to Process" error. - // - // As a result, we explicitly only opt in 'Content-Type' and 'Content-Length' - // if there is a response handler on the inputStream - if (inputStream) { - inputStream.on('response', function(response) { - response.headers = { - 'content-type': response.headers['content-type'], - 'content-length': response.headers['content-length'] - } - }); - } - if (options.metadata) { uploadOptions.headers = _.extend(uploadOptions.headers, self.serializeMetadata(self.OBJECT_META_PREFIX, options.metadata)); } - apiStream = this._request(uploadOptions, success); - if (inputStream) { - inputStream.pipe(apiStream); - } + writableStream = this._request(uploadOptions); - return apiStream; + writableStream.on('complete', function() { + // load the file metadata from the cloud, so we can return a proper model + self.getFile(uploadOptions.container, options.remote, function (err, file) { + if (err) { + proxyStream.emit('error', err); + return; + } + + proxyStream.emit('success', file); + }); + }); + + writableStream.on('error', function (err) { + proxyStream.emit('error', err); + }); + + writableStream.on('data', function (chunk) { + proxyStream.emit('data', chunk); + }); + + // we need a proxy stream so we can always return a file model + // via the 'success' event + proxyStream.pipe(writableStream); + + return proxyStream; }; /** diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index d603b69fb..32ba5e485 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -7,6 +7,7 @@ */ var util = require('util'), + _ = require('underscore'), base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { @@ -66,3 +67,7 @@ File.prototype._setProperties = function (details) { }); }; +File.prototype.toJSON = function () { + return _.pick(this, ['name', 'etag', 'size', 'storageClass', 'lastModified', 'container', 'location' ]); +}; + diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 149810280..15568066f 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -141,14 +141,13 @@ providers.filter(function (provider) { stream.on('error', function(err, response) { should.not.exist(err); should.not.exist(response); + done(); }); - stream.on('uploaded', complete); - stream.on('complete', complete); - - function complete() { + stream.on('success', function(file) { authHockInstance && authHockInstance.done(); hockInstance && hockInstance.done(); + file.should.be.an.instanceof(File); context.file = { name: 'test-file.txt', @@ -156,7 +155,7 @@ providers.filter(function (provider) { }; done(); - } + }); var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); file.pipe(stream); @@ -528,6 +527,8 @@ function setupUploadStreamMock(provider, client, servers) { servers.server .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) .reply(200) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); } else if (provider === 'amazon') { servers.server @@ -545,11 +546,15 @@ function setupUploadStreamMock(provider, client, servers) { .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', "block000000000000000") .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) + .get('/pkgcloud-test-container/test-file.txt') + .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})) } else if (provider === 'hp') { servers.server .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) .reply(200) + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); } } From 8e74df8a1e93a34eb807343ab7db6d1572f6ae5c Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 7 Oct 2014 10:56:19 -0700 Subject: [PATCH 163/460] fixing up options for uploaded files --- lib/pkgcloud/azure/storage/client/files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 26c40123b..3e71227eb 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -77,7 +77,7 @@ exports.upload = function (options) { uploadOptions.headers['content-type'] = options.contentType; } else { - uploadOptions.headers['content-type'] = options.remote ? mime.lookup(options.remote) : mime.lookup(options.path); + uploadOptions.headers['content-type'] = mime.lookup(options.remote); } uploadOptions.headers['content-length'] = options.size; From 75d6509fb121e7f426216a4c7be827f1979989fe Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 7 Oct 2014 13:10:14 -0700 Subject: [PATCH 164/460] moving util around --- lib/pkgcloud/openstack/context/identity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index 4857fbd4e..77995ff45 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -13,8 +13,8 @@ var _ = require('underscore'), ServiceCatalog = require('./serviceCatalog').ServiceCatalog, svcCat = require('./serviceCatalog'), url = require('url'), - util = require('util'), urlJoin = require('url-join'), + util = require('util'), pkgcloud = require('../../../pkgcloud'), errs = require('errs'); From e5346bf26a3c91754c7a51a3dfb44d6448ea5b79 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 7 Oct 2014 14:46:29 -0700 Subject: [PATCH 165/460] First pass of new error handling for streams --- lib/pkgcloud/azure/storage/client/files.js | 9 ++- lib/pkgcloud/core/base/client.js | 57 +++++++++++-------- lib/pkgcloud/openstack/client.js | 23 ++++++-- .../openstack/storage/client/files.js | 10 +++- 4 files changed, 68 insertions(+), 31 deletions(-) diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 3e71227eb..39d2378b8 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -85,7 +85,14 @@ exports.upload = function (options) { writableStream = self._request(uploadOptions); - writableStream.on('complete', function() { + writableStream.on('complete', function(response) { + var err = self._parseError(response); + + if (err) { + proxyStream.emit('error', err); + return; + } + // load the file metadata from the cloud, so we can return a proper model self.getFile(options.container, options.remote, function (err, file) { if (err) { diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index aabedd861..ccc81ca27 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -150,30 +150,9 @@ Client.prototype._defaultRequestHandler = function (callback) { return callback(err); } - var statusCode = res.statusCode.toString(), - err2; - - if (Object.keys(self.failCodes).indexOf(statusCode) !== -1) { - // - // TODO: Support more than JSON errors here - // - err2 = { - provider: self.provider, - failCode: self.failCodes[statusCode], - statusCode: res.statusCode, - message: self.provider + ' Error (' + - statusCode + '): ' + self.failCodes[statusCode], - href: res.request.uri.href, - method: res.request.method, - headers: res.headers - }; - - try { - err2.result = typeof body === 'string' ? JSON.parse(body) : body; - } catch (e) { - err2.result = { err: body }; - } + var err2 = self._parseError(res, body); + if (err2) { self.emit('log::error', 'Error during provider response', err2); return callback(errs.create(err2)); } @@ -188,3 +167,35 @@ Client.prototype._defaultRequestHandler = function (callback) { callback(err, body, res); } }; + +Client.prototype._parseError = function(response, body) { + var self = this, + statusCode = response.statusCode.toString(), + err; + + if (Object.keys(self.failCodes).indexOf(statusCode) !== -1) { + // + // TODO: Support more than JSON errors here + // + err = { + provider: self.provider, + failCode: self.failCodes[statusCode], + statusCode: response.statusCode, + message: self.provider + ' Error (' + + statusCode + '): ' + self.failCodes[statusCode], + href: response.request.uri.href, + method: response.request.method, + headers: response.headers + }; + + if (body) { + try { + err.result = typeof body === 'string' ? JSON.parse(body) : body; + } catch (e) { + err.result = { err: body }; + } + } + } + + return err; +}; diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 9c50b0ead..f26248e0c 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -172,8 +172,9 @@ Client.prototype._request = function (options, callback) { var self = this; if (!self._isAuthorized()) { self.emit('log::trace', 'Not-Authenticated, inlining Auth...'); - var buf = through(); - buf.pause(); + var proxyStream = through(); + proxyStream.pause(); + self.auth(function (err) { if (err) { self.emit('log::error', 'Error with inline authentication', err); @@ -184,16 +185,26 @@ Client.prototype._request = function (options, callback) { var apiStream = Client.super_.prototype._request.call(self, options, callback); if (options.upload) { - buf.pipe(apiStream); + + // needed for event propagation during proxied auth for streams + apiStream.on('error', function (err) { + proxyStream.emit('error', err); + }); + + apiStream.on('complete', function (response) { + proxyStream.emit('complete', response); + }); + + proxyStream.pipe(apiStream); } else if (options.download) { - apiStream.pipe(buf); + apiStream.pipe(proxyStream); } - buf.resume(); + proxyStream.resume(); }); - return buf; + return proxyStream; } else { self.emit('log::trace', 'Creating Authenticated Request'); diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index bf94cbd73..f471d5a0f 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -13,6 +13,7 @@ var fs = require('fs'), util = require('util'), base = require('../../../core/storage'), pkgcloud = require('../../../../pkgcloud'), + errs = require('errs'), through = require('through2'), _ = require('underscore'), storage = pkgcloud.providers.openstack.storage; @@ -97,7 +98,14 @@ exports.upload = function (options) { writableStream = this._request(uploadOptions); - writableStream.on('complete', function() { + writableStream.on('complete', function(response) { + var err = self._parseError(response); + + if (err) { + proxyStream.emit('error', err); + return; + } + // load the file metadata from the cloud, so we can return a proper model self.getFile(uploadOptions.container, options.remote, function (err, file) { if (err) { From 4601d74b6426c94b16bf74c34699d69d3c719b64 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 7 Oct 2014 15:29:02 -0700 Subject: [PATCH 166/460] Error tests for streaming upload --- lib/pkgcloud/azure/storage/client/files.js | 10 +- test/common/storage/upload-test.js | 209 +++++++++++++++++++++ 2 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 test/common/storage/upload-test.js diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 39d2378b8..b263c2cfd 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -149,8 +149,14 @@ exports.multipartUpload = function (options) { }); // when the block has been uploaded, resume if more data - writableStream.on('complete', function() { - if (!ended) { + writableStream.on('complete', function(response) { + var err = self._parseError(response); + + if (err) { + chunkedStream.emit('error', err); + ended = true; + } + else if (!ended) { chunkedStream.resume(); } else { diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js new file mode 100644 index 000000000..6865da9f9 --- /dev/null +++ b/test/common/storage/upload-test.js @@ -0,0 +1,209 @@ +/* + * base-test.js: Test that should be common to all providers. + * + * (C) 2012 Nodejitsu Inc. + * + */ + +var fs = require('fs'), + path = require('path'), + Buffer = require('buffer').Buffer, + assert = require('../../helpers/assert'), + helpers = require('../../helpers'), + should = require('should'), + util = require('util'), + async = require('async'), + hock = require('hock'), + http = require('http'), + urlJoin = require('url-join'), + _ = require('underscore'), + providers = require('../../configs/providers.json'), + versions = require('../../fixtures/versions.json'), + Container = require('../../../lib/pkgcloud/core/storage/container').Container, + File = require('../../../lib/pkgcloud/core/storage/file').File, + mock = !!process.env.MOCK, + pkgcloud = require('../../../lib/pkgcloud'), + fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].storage; +}).forEach(function (provider) { + describe('pkgcloud/common/storage/base [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'storage'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the client.upload stream should emit error', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupUploadStreamError(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + var stream = client.upload({ + container: 'pkgcloud-test-container', + remote: 'test-file.txt' + }); + + stream.on('error', function (err) { + should.exist(err); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + + stream.on('success', function (file) { + should.not.exist(file); + done(); + }); + + stream.end('foo'); + }); + + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done) + }); + }); +}); + +function setupUploadStreamError(provider, client, servers) { + if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', 'foo') + .reply(400) + } + else if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', 'foo') + .reply(400) + } + else if (provider === 'amazon') { + servers.server + .post('/test-file.txt?uploads') + .reply(400) + } + else if (provider === 'azure') { + + // Override the clients getUrl method as it tries to prefix the container name onto the request + client._getUrl = function (options) { + options = options || {}; + + return urlJoin('http://localhost:12345/', + (typeof options === 'string' + ? options + : options.path)); + }; + + servers.server + .put('/pkgcloud-test-container/test-file.txt?comp=block&blockid=block000000000000000', 'foo') + .reply(400); + } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', 'foo') + .reply(400); + } +} From 11e338cafda87dd41ae77abe8cbd5c1fcd1a4ffc Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Fri, 10 Oct 2014 17:45:26 +0100 Subject: [PATCH 167/460] Added more options to getFiles so that you can set end_marker, prefix, path and delimiter in the openstack storage client. --- lib/pkgcloud/openstack/storage/client/files.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index ad51f9ff0..ffcd932fa 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -303,6 +303,22 @@ exports._getFiles = function (container, options, callback) { getFilesOpts.qs.marker = options.marker; } + if (options.end_marker) { + getFilesOpts.qs.end_marker = options.end_marker; + } + + if (options.prefix) { + getFilesOpts.qs.prefix = options.prefix; + } + + if (options.path) { + getFilesOpts.qs.path = options.path; + } + + if (options.delimiter) { + getFilesOpts.qs.delimiter = options.delimiter; + } + this._request(getFilesOpts, function (err, body) { if (err) { From 718627452809d003702fa2b783cb9acbabdb3a58 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Mon, 13 Oct 2014 17:10:35 +0100 Subject: [PATCH 168/460] Refactored the additional options using _.pick to reduce repetition. end_marker has been renamed to endMarker to conform with the option casing for pkgcloud. --- .../openstack/storage/client/files.js | 36 +++++-------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index ffcd932fa..58d7ca1a3 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -289,35 +289,15 @@ exports._getFiles = function (container, options, callback) { self = this; var getFilesOpts = { - path: containerName, - qs: { - format: 'json' + path: containerName, + qs: _.extend({ + format: 'json' + }, _.pick(options, ['limit', 'marker', 'prefix', 'path', 'delimiter'])) + }; + + if (options.endMarker) { + getFilesOpts.qs.end_marker = options.endMarker; } - }; - - if (options.limit) { - getFilesOpts.qs.limit = options.limit; - } - - if (options.marker) { - getFilesOpts.qs.marker = options.marker; - } - - if (options.end_marker) { - getFilesOpts.qs.end_marker = options.end_marker; - } - - if (options.prefix) { - getFilesOpts.qs.prefix = options.prefix; - } - - if (options.path) { - getFilesOpts.qs.path = options.path; - } - - if (options.delimiter) { - getFilesOpts.qs.delimiter = options.delimiter; - } this._request(getFilesOpts, function (err, body) { From 93265a652a07e2b7f886464598c1e72c82f4aadc Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 13 Oct 2014 09:11:58 -0700 Subject: [PATCH 169/460] Fixing delete container for openstack to be robust --- .../openstack/compute/client/servers.js | 5 ++ .../openstack/storage/client/containers.js | 57 ++++++++++++------- test/common/storage/base-test.js | 41 ++++++++++++- 3 files changed, 81 insertions(+), 22 deletions(-) diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index 3c839d26f..36fc5753d 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -150,6 +150,11 @@ exports.createServer = function createServer(details, callback) { createOptions.body.server.security_groups = details.securityGroups; } + if (details.cloudConfig) { + createOptions.body.server.user_data = details.cloudConfig; + createOptions.body.server.config_drive = true; + } + return this._request(createOptions, function (err, body) { if (err) { return callback(err); diff --git a/lib/pkgcloud/openstack/storage/client/containers.js b/lib/pkgcloud/openstack/storage/client/containers.js index d37b99dfa..be9374243 100644 --- a/lib/pkgcloud/openstack/storage/client/containers.js +++ b/lib/pkgcloud/openstack/storage/client/containers.js @@ -190,34 +190,53 @@ exports.destroyContainer = function (container, callback) { var containerName = container instanceof this.models.Container ? container.name : container, self = this; - this.getFiles(container, function (err, files) { + // first fetch the container, to get the count of objects + this.getContainer(container, function(err, container) { if (err) { - return callback(err); + callback(err); + return; } - function deleteContainer(err) { + // we need to call get files, but with a limit of the current count of the container + // with a modest offset incase of any cache staleness + self.getFiles(container, { limit: container.count + 1000 }, function (err, files) { if (err) { return callback(err); } - self._request({ - method: 'DELETE', - container: containerName - }, function(err) { - return err - ? callback(err) - : callback(null, true); - }); - } + function deleteContainer(err) { + if (err) { + return callback(err); + } + + self._request({ + method: 'DELETE', + container: containerName + }, function (err) { + // if the file we're deleting returns a 404 error, ignore it + if (err && err.statusCode === 404) { + callback(null, false); + return; + } + // non-404 case, propagate it + else if (err) { + callback(err); + return; + } + + callback(null, true); + }); + } - function destroyFile(file, next) { - file.remove(next); - } + function destroyFile(file, next) { + file.remove(next); + } - if (files.length === 0) { - return deleteContainer(); - } + if (files.length === 0) { + return deleteContainer(); + } - async.forEach(files, destroyFile, deleteContainer); + async.forEachLimit(files, 15, destroyFile, deleteContainer); + }); }); }; diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 15568066f..88e13ba6a 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -659,9 +659,39 @@ function setupRemoveFileMock(provider, client, servers) { } function setupDestroyContainerMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { + if (provider === 'openstack') { servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } + else if (provider === 'rackspace') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') .reply(200, [ { bytes: fillerama.length, @@ -690,7 +720,12 @@ function setupDestroyContainerMock(provider, client, servers) { } else if (provider === 'hp') { servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') .reply(200, [ { bytes: fillerama.length, From a2942304407e6d74e55a41007c54ba7d74b6827a Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Fri, 10 Oct 2014 17:45:26 +0100 Subject: [PATCH 170/460] Added more options to getFiles so that you can set end_marker, prefix, path and delimiter in the openstack storage client. --- lib/pkgcloud/openstack/storage/client/files.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index f471d5a0f..4b5eab7c7 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -299,6 +299,22 @@ exports._getFiles = function (container, options, callback) { getFilesOpts.qs.marker = options.marker; } + if (options.end_marker) { + getFilesOpts.qs.end_marker = options.end_marker; + } + + if (options.prefix) { + getFilesOpts.qs.prefix = options.prefix; + } + + if (options.path) { + getFilesOpts.qs.path = options.path; + } + + if (options.delimiter) { + getFilesOpts.qs.delimiter = options.delimiter; + } + this._request(getFilesOpts, function (err, body) { if (err) { From de22199131ba4a0c446580849ba9348e70cdd648 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 13 Oct 2014 09:28:33 -0700 Subject: [PATCH 171/460] Cleaning up inconsistent options handling for storage.getFiles - Fixes a broken test as part of #334 --- lib/pkgcloud/amazon/storage/client/containers.js | 2 +- lib/pkgcloud/amazon/storage/client/files.js | 3 --- lib/pkgcloud/azure/storage/client/files.js | 7 ++++++- test/common/storage/base-test.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index 9ae51ff39..aff429cb0 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -136,5 +136,5 @@ exports.destroyContainer = function (container, callback) { file.remove(next); } - getPagedFiles(containerName, null, handleResponse); + getPagedFiles(containerName, handleResponse); }; diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 45a7e1c01..e4d51896d 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -89,9 +89,6 @@ exports.getFiles = function (container, options, callback) { if (typeof options === 'function') { callback = options; - options = null; - } - else if (!options) { options = {}; } diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 8368c34a0..be290bf7b 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -271,10 +271,15 @@ exports.getFile = function (container, file, callback) { }); }; -exports.getFiles = function (container, download, callback) { +exports.getFiles = function (container, options, callback) { var containerName = container instanceof base.Container ? container.name : container, self = this; + if (typeof options === 'function') { + callback = options; + options = {}; + } + this._xmlRequest({ method: 'GET', path: containerName, diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 149810280..35b8da7cc 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -234,7 +234,7 @@ providers.filter(function (provider) { }); } - client.getFiles(context.container, false, function (err, files) { + client.getFiles(context.container, function (err, files) { should.not.exist(err); should.exist(files); From 1cad369e8bfb190fc3794b91b70fa4d2fc7f2ca8 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 13 Oct 2014 23:23:37 -0700 Subject: [PATCH 172/460] Fixing a missing adminPass response from createServer --- lib/pkgcloud/openstack/compute/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/compute/server.js b/lib/pkgcloud/openstack/compute/server.js index 67c04602f..1c78ec513 100644 --- a/lib/pkgcloud/openstack/compute/server.js +++ b/lib/pkgcloud/openstack/compute/server.js @@ -135,7 +135,7 @@ Server.prototype.getAddresses = function (type, callback) { }; Server.prototype.toJSON = function() { - return _.pick(this, ['id', 'name', 'status', 'hostId', 'addresses', + return _.pick(this, ['id', 'name', 'status', 'hostId', 'adminPass', 'addresses', 'links', 'key_name', 'image', 'flavor', 'user_id', 'tenant_id', 'progress', 'OS-EXT-STS:task_state', 'OS-EXT-STS:vm_state', 'OS-EXT-STS:power_state', 'OS-DCF:diskConfig', 'accessIPv4', 'accessIPv6', 'config_drive', 'metadata', From beac5e3375259497840d757d7edf2405c8ed079c Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 10:05:40 -0700 Subject: [PATCH 173/460] Updating documentation for pkgcloud 1.0 --- README.md | 17 +++++-- docs/providers/hp/storage.md | 62 +++++++------------------ docs/providers/openstack/storage.md | 61 +++++++----------------- docs/providers/rackspace/storage.md | 61 +++++++----------------- examples/storage/rackspace.js | 26 ++++++----- lib/pkgcloud/hp/compute/client/index.js | 1 + 6 files changed, 78 insertions(+), 150 deletions(-) diff --git a/README.md b/README.md index d149b26df..a2278a278 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ Each instance of `pkgcloud.storage.Client` returned from `pkgcloud.storage.creat * `client.getContainer(containerName, function (err, container) { })` ### File -* `client.upload(options, function (err) { })` +* `client.upload(options)` * `client.download(options, function (err) { })` * `client.getFiles(container, function (err, files) { })` * `client.getFile(container, file, function (err, server) { })` @@ -225,10 +225,21 @@ Both the `.upload(options)` and `.download(options)` have had **careful attentio var client = pkgcloud.storage.createClient({ /* ... */ }); - fs.createReadStream('a-file.txt').pipe(client.upload({ + var readStream = fs.createReadStream('a-file.txt'); + var writeStream = client.upload({ container: 'a-container', remote: 'remote-file-name.txt' - })); + }); + + writeStream.on('error', function(err) { + // handle your error case + }); + + writeStream.on('success', function(file) { + // success, file will be a File model + }); + + readStream.pipe(writeStream); ``` ### Download a File diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index c8ffe179c..7d7a9b2fd 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -130,7 +130,7 @@ client.removeContainerMetadata(container, { year: false }, function(err, c) { ### File APIs -* [`client.upload(options, function(err, result) { })`](#clientuploadoptions-functionerr-result--) +* [`client.upload(options)`](#clientuploadoptions--) * [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) * [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) * [`client.getFiles(container, function(err, file) { })`](#clientgetfilescontainer-functionerr-file--) @@ -153,9 +153,9 @@ var myContainer = new Container({ name: 'my-container' }); client.getFile(myContainer, 'my-file', function(err, file) { ... }); ``` -#### client.upload(options, function(err, result) { }) +#### client.upload(options) { }) -Returns a writeable stream. Upload a new file to a [`container`](#container-model). `result` will be `true` on success. +Returns a `writableStream`. Upload a new file to a [`container`](#container-model). `writableStream` will emit `success` on completion of the upload, and will emit `error` on any failure. Function for `success` is `function(file) { ... }` where `file` is a [`file`](#file-model) model To upload a file, you need to provide an `options` argument: @@ -164,57 +164,29 @@ var options = { // required options container: 'my-container', // this can be either the name or an instance of container remote: 'my-file', // name of the new file - - // optional, either stream or local - stream: myStream, // any instance of a readable stream - local: '/path/to/local/file' // a path to any local file - - // Other optional values - metadata: { // provide any number of property/values for metadata - campaign: '2012 magazine' - }, - headers: { // optionally provide raw headers to send to cloud files - 'content-type': 'application/json' - } + contentType: 'application/json', // optional mime type for the file, will attempt to auto-detect based on remote name + size: 1234 // size of the file }; ``` -You need not provide either `stream` or `local`. `client.upload` returns a writeable stream, so you can simply pipe directly into it from your stream. For example: - ```Javascript -var fs = require('fs'), - pkgcloud = require('pkgcloud'); - -var client = pkgcloud.providers.hp.storage.createClient({ ... }); - -var myFile = fs.createReadStream('/my/local/file'); - -myFile.pipe(client.upload({ - container: 'my-container', - remote: 'my-file' -}, function(err, result) { - // handle the upload result -})); -``` - -You could also upload a local file via the `local` property on `options`: + var readStream = fs.createReadStream('a-file.txt'); + var writeStream = client.upload({ + container: 'a-container', + remote: 'remote-file-name.txt' + }); -```Javascript -var pkgcloud = require('pkgcloud'); + writeStream.on('error', function(err) { + // handle your error case + }); -var client = pkgcloud.providers.hp.storage.createClient({ ... }); + writeStream.on('success', function(file) { + // success, file will be a File model + }); -client.upload({ - container: 'my-container', - remote: 'my-file', - local: '/path/to/my/file' -}, function(err, result) { - // handle the upload result -}); + readStream.pipe(writeStream); ``` -This is functionally equivalent to piping from an `fs.createReadStream`, but has a simplified calling convention. - #### client.download(options, function(err, file) { }) Returns a readable stream. Download a [`file`](#file-model) from a [`container`](#container-model). diff --git a/docs/providers/openstack/storage.md b/docs/providers/openstack/storage.md index 0d07c9b49..b3b3e5aab 100644 --- a/docs/providers/openstack/storage.md +++ b/docs/providers/openstack/storage.md @@ -127,7 +127,7 @@ client.removeContainerMetadata(container, { year: false }, function(err, c) { ### File APIs -* [`client.upload(options, function(err, result) { })`](#clientuploadoptions-functionerr-result--) +* [`client.upload(options)`](#clientuploadoptions--) * [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) * [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) * [`client.getFiles(container, function(err, file) { })`](#clientgetfilescontainer-functionerr-file--) @@ -151,8 +151,7 @@ client.getFile(myContainer, 'my-file', function(err, file) { ... }); ``` #### client.upload(options, function(err, result) { }) - -Returns a writeable stream. Upload a new file to a [`container`](#container-model). `result` will be `true` on success. +Returns a `writableStream`. Upload a new file to a [`container`](#container-model). `writableStream` will emit `success` on completion of the upload, and will emit `error` on any failure. Function for `success` is `function(file) { ... }` where `file` is a [`file`](#file-model) model To upload a file, you need to provide an `options` argument: @@ -161,57 +160,29 @@ var options = { // required options container: 'my-container', // this can be either the name or an instance of container remote: 'my-file', // name of the new file - - // optional, either stream or local - stream: myStream, // any instance of a readable stream - local: '/path/to/local/file' // a path to any local file - - // Other optional values - metadata: { // provide any number of property/values for metadata - campaign: '2012 magazine' - }, - headers: { // optionally provide raw headers to send to cloud files - 'content-type': 'application/json' - } + contentType: 'application/json', // optional mime type for the file, will attempt to auto-detect based on remote name + size: 1234 // size of the file }; ``` -You need not provide either `stream` or `local`. `client.upload` returns a writeable stream, so you can simply pipe directly into it from your stream. For example: - ```Javascript -var fs = require('fs'), - pkgcloud = require('pkgcloud'); - -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); - -var myFile = fs.createReadStream('/my/local/file'); - -myFile.pipe(client.upload({ - container: 'my-container', - remote: 'my-file' -}, function(err, result) { - // handle the upload result -})); -``` - -You could also upload a local file via the `local` property on `options`: + var readStream = fs.createReadStream('a-file.txt'); + var writeStream = client.upload({ + container: 'a-container', + remote: 'remote-file-name.txt' + }); -```Javascript -var pkgcloud = require('pkgcloud'); + writeStream.on('error', function(err) { + // handle your error case + }); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + writeStream.on('success', function(file) { + // success, file will be a File model + }); -client.upload({ - container: 'my-container', - remote: 'my-file', - local: '/path/to/my/file' -}, function(err, result) { - // handle the upload result -}); + readStream.pipe(writeStream); ``` -This is functionally equivalent to piping from an `fs.createReadStream`, but has a simplified calling convention. - #### client.download(options, function(err, file) { }) Returns a readable stream. Download a [`file`](#file-model) from a [`container`](#container-model). diff --git a/docs/providers/rackspace/storage.md b/docs/providers/rackspace/storage.md index 00c076454..98753baed 100644 --- a/docs/providers/rackspace/storage.md +++ b/docs/providers/rackspace/storage.md @@ -127,7 +127,7 @@ client.removeContainerMetadata(container, { year: false }, function(err, c) { ### File APIs -* [`client.upload(options, function(err, result) { })`](#clientuploadoptions-functionerr-result--) +* [`client.upload(options)`](#clientuploadoptions--) * [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) * [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) * [`client.getFiles(container, [options], function(err, file) { })`](#clientgetfilescontainer-options-functionerr-files--) @@ -151,8 +151,7 @@ client.getFile(myContainer, 'my-file', function(err, file) { ... }); ``` #### client.upload(options, function(err, result) { }) - -Returns a writeable stream. Upload a new file to a [`container`](#container-model). `result` will be `true` on success. +Returns a `writableStream`. Upload a new file to a [`container`](#container-model). `writableStream` will emit `success` on completion of the upload, and will emit `error` on any failure. Function for `success` is `function(file) { ... }` where `file` is a [`file`](#file-model) model To upload a file, you need to provide an `options` argument: @@ -161,57 +160,29 @@ var options = { // required options container: 'my-container', // this can be either the name or an instance of container remote: 'my-file', // name of the new file - - // optional, either stream or local - stream: myStream, // any instance of a readable stream - local: '/path/to/local/file' // a path to any local file - - // Other optional values - metadata: { // provide any number of property/values for metadata - campaign: '2012 magazine' - }, - headers: { // optionally provide raw headers to send to cloud files - 'content-type': 'application/json' - } + contentType: 'application/json', // optional mime type for the file, will attempt to auto-detect based on remote name + size: 1234 // size of the file }; ``` -You need not provide either `stream` or `local`. `client.upload` returns a writeable stream, so you can simply pipe directly into it from your stream. For example: - ```Javascript -var fs = require('fs'), - pkgcloud = require('pkgcloud'); - -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); - -var myFile = fs.createReadStream('/my/local/file'); - -myFile.pipe(client.upload({ - container: 'my-container', - remote: 'my-file' -}, function(err, result) { - // handle the upload result -})); -``` - -You could also upload a local file via the `local` property on `options`: + var readStream = fs.createReadStream('a-file.txt'); + var writeStream = client.upload({ + container: 'a-container', + remote: 'remote-file-name.txt' + }); -```Javascript -var pkgcloud = require('pkgcloud'); + writeStream.on('error', function(err) { + // handle your error case + }); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); + writeStream.on('success', function(file) { + // success, file will be a File model + }); -client.upload({ - container: 'my-container', - remote: 'my-file', - local: '/path/to/my/file' -}, function(err, result) { - // handle the upload result -}); + readStream.pipe(writeStream); ``` -This is functionally equivalent to piping from an `fs.createReadStream`, but has a simplified calling convention. - #### client.download(options, function(err, file) { }) Returns a readable stream. Download a [`file`](#file-model) from a [`container`](#container-model). diff --git a/examples/storage/rackspace.js b/examples/storage/rackspace.js index 1b26a2ea3..3333613fc 100644 --- a/examples/storage/rackspace.js +++ b/examples/storage/rackspace.js @@ -57,18 +57,20 @@ rackspace.createContainer({ var myPicture = fs.createReadStream('/path/to/some/file/picture.jpg'); - myPicture.pipe(rackspace.upload({ - container: container.name, - remote: 'profile-picture.jpg' - }, - function (err, result) { - if (err) { - console.dir(err); - return; - } - - console.log(result); - })); + var upload = rackspace.upload({ + container: container.name, + remote: 'profile-picture.jpg' + }); + + upload.on('error', function(err) { + console.error(err); + }); + + upload.on('success', function(file) { + console.log(file.toJSON()); + }); + + myPicture.pipe(upload); }); // 4 -- setup container as CDN diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 7d2fdfb34..2d86740c9 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -16,6 +16,7 @@ var Client = exports.Client = function (options) { _.extend(this, require('../../../openstack/compute/client/flavors')); _.extend(this, require('../../../openstack/compute/client/images')); _.extend(this, require('../../../openstack/compute/client/servers')); + _.extend(this, require('../../../openstack/compute/client/extensions/keys')); _.extend(this, require('../../../openstack/compute/client/extensions/floating-ips')); _.extend(this, require('../../../openstack/compute/client/extensions/security-groups')); _.extend(this, require('../../../openstack/compute/client/extensions/servers')); From cf5bba9575a448349240abf917d137b29c078fdf Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 10:08:51 -0700 Subject: [PATCH 174/460] Cleaning up some broken markdown --- docs/providers/hp/storage.md | 4 ++-- docs/providers/openstack/storage.md | 4 ++-- docs/providers/rackspace/storage.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/providers/hp/storage.md b/docs/providers/hp/storage.md index 7d7a9b2fd..be9208993 100644 --- a/docs/providers/hp/storage.md +++ b/docs/providers/hp/storage.md @@ -130,7 +130,7 @@ client.removeContainerMetadata(container, { year: false }, function(err, c) { ### File APIs -* [`client.upload(options)`](#clientuploadoptions--) +* [`client.upload(options)`](#clientuploadoptions) * [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) * [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) * [`client.getFiles(container, function(err, file) { })`](#clientgetfilescontainer-functionerr-file--) @@ -153,7 +153,7 @@ var myContainer = new Container({ name: 'my-container' }); client.getFile(myContainer, 'my-file', function(err, file) { ... }); ``` -#### client.upload(options) { }) +#### client.upload(options) Returns a `writableStream`. Upload a new file to a [`container`](#container-model). `writableStream` will emit `success` on completion of the upload, and will emit `error` on any failure. Function for `success` is `function(file) { ... }` where `file` is a [`file`](#file-model) model diff --git a/docs/providers/openstack/storage.md b/docs/providers/openstack/storage.md index b3b3e5aab..825421d6b 100644 --- a/docs/providers/openstack/storage.md +++ b/docs/providers/openstack/storage.md @@ -127,7 +127,7 @@ client.removeContainerMetadata(container, { year: false }, function(err, c) { ### File APIs -* [`client.upload(options)`](#clientuploadoptions--) +* [`client.upload(options)`](#clientuploadoptions) * [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) * [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) * [`client.getFiles(container, function(err, file) { })`](#clientgetfilescontainer-functionerr-file--) @@ -150,7 +150,7 @@ var myContainer = new Container({ name: 'my-container' }); client.getFile(myContainer, 'my-file', function(err, file) { ... }); ``` -#### client.upload(options, function(err, result) { }) +#### client.upload(options) Returns a `writableStream`. Upload a new file to a [`container`](#container-model). `writableStream` will emit `success` on completion of the upload, and will emit `error` on any failure. Function for `success` is `function(file) { ... }` where `file` is a [`file`](#file-model) model To upload a file, you need to provide an `options` argument: diff --git a/docs/providers/rackspace/storage.md b/docs/providers/rackspace/storage.md index 98753baed..dce2bf2b6 100644 --- a/docs/providers/rackspace/storage.md +++ b/docs/providers/rackspace/storage.md @@ -127,7 +127,7 @@ client.removeContainerMetadata(container, { year: false }, function(err, c) { ### File APIs -* [`client.upload(options)`](#clientuploadoptions--) +* [`client.upload(options)`](#clientuploadoptions) * [`client.download(options, function(err, file) { })`](#clientdownloadoptions-functionerr-file--) * [`client.getFile(container, file, function(err, file) { })`](#clientgetfilecontainer-file-functionerr-file--) * [`client.getFiles(container, [options], function(err, file) { })`](#clientgetfilescontainer-options-functionerr-files--) @@ -150,7 +150,7 @@ var myContainer = new Container({ name: 'my-container' }); client.getFile(myContainer, 'my-file', function(err, file) { ... }); ``` -#### client.upload(options, function(err, result) { }) +#### client.upload(options) Returns a `writableStream`. Upload a new file to a [`container`](#container-model). `writableStream` will emit `success` on completion of the upload, and will emit `error` on any failure. Function for `success` is `function(file) { ... }` where `file` is a [`file`](#file-model) model To upload a file, you need to provide an `options` argument: From 20b485a5f18dfd2f98dfb5b99c9b6be24720c227 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 10:09:34 -0700 Subject: [PATCH 175/460] 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 59aecf6bc..96711c10b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "0.9.6", + "version": "1.0.0", "author": "Nodejitsu Inc ", "contributors": [ { From 00561ea9d393a6b777edecbd0eaff770260f7fb0 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 10:25:12 -0700 Subject: [PATCH 176/460] Changelog updates for 1.0 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a384e189b..3250176b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## v1.0.0 +* Requires node 0.10, dropping support for node v0.8 +* Fundamentally changed the streaming file api for upload. No longer takes a callback. See #332 +* Significant cleanup across storage apis across providers +* Added `toJSON` on all models +* Changed underlying Amazon provider to use aws-sdk +* Added Openstack Heat provider +* updated all package dependencies, including removing `utile` +* static website support for Rackspace Cloud Files +* Added compute.keys support for HP Compute provider + ## v0.9.6 * Fixed a long-standing bug in openstack.compute.getFlavor #292 From 1b392e7f7f4642e0ed40d1f326cfe8b08943b7cb Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 11:42:01 -0700 Subject: [PATCH 177/460] Adding a thin wrapper for rackspace orchestration --- README.md | 2 + docs/providers/rackspace/README.md | 1 + docs/providers/rackspace/orchestration.md | 128 ++++++++++++++++++ lib/pkgcloud/openstack/orchestration/index.js | 1 - lib/pkgcloud/rackspace/index.js | 1 + .../rackspace/orchestration/client/index.js | 67 +++++++++ lib/pkgcloud/rackspace/orchestration/index.js | 16 +++ 7 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 docs/providers/rackspace/orchestration.md create mode 100644 lib/pkgcloud/rackspace/orchestration/client/index.js create mode 100644 lib/pkgcloud/rackspace/orchestration/index.js diff --git a/README.md b/README.md index a2278a278..8a88dfbb4 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](docs/providers/rackspace/loadbalancer.md) * **[Orchestration](#orchestration----beta)** *(beta)* * [Openstack](docs/providers/openstack/orchestration.md) + * [Rackspace](docs/providers/rackspace/orchestration.md) * **[Network](#network----beta)** *(beta)* * [HP](docs/providers/hp/network.md) * [Openstack](docs/providers/openstack/network.md) @@ -491,6 +492,7 @@ To get started with a `pkgcloud.orchestration` client just create one: #### Providers * [Openstack](docs/providers/openstack/orchestration.md) +* [Rackspace](docs/providers/rackspace/orchestration.md) Each instance of `pkgcloud.orchestration.Client` returned from `pkgcloud.orchestration.createClient` has a set of uniform APIs: diff --git a/docs/providers/rackspace/README.md b/docs/providers/rackspace/README.md index f47d8adf4..e8ea55e53 100644 --- a/docs/providers/rackspace/README.md +++ b/docs/providers/rackspace/README.md @@ -7,6 +7,7 @@ The Rackspace provider in pkgcloud supports the following services: * [**Databases**](databases.md) (Cloud Databases) * [**DNS**](dns.md) (Cloud DNS) *(beta)* * [**Block Storage**](blockstorage.md) (Cloud Block Storage) *(beta)* +* [**Orchestration**](orchestration.md) (Cloud Orchestration) *(beta)* * [**Load Balancers**](loadbalancer.md) (Cloud Load Balancers) *(beta)* ### Getting Started with Compute diff --git a/docs/providers/rackspace/orchestration.md b/docs/providers/rackspace/orchestration.md new file mode 100644 index 000000000..3cd5a622a --- /dev/null +++ b/docs/providers/rackspace/orchestration.md @@ -0,0 +1,128 @@ +##Using the Rackspace Orchestration provider + +Creating a client is straight-forward: + +``` js + var rackspace = pkgcloud.orchestration.createClient({ + provider: 'rackspace', + username: 'your-user-name', + password: 'your-password', + authUrl: 'https://your-identity-service' + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +## Stacks + +#### client.getStacks([options], callback) +Lists all stacks that are available to use on your Rackspace account + +Callback returns `f(err, stacks)` where `stacks` is an `Array` + +#### client.createStack(options, callback) +Creates a stack with the options specified. + +Options are as follows: + +```js +{ + name: 'my-stack-name', // required + timeout: 30, // timeout, in minutes, required + templateUrl: 'http://path.to.some.openstack.heat.template', // required, unless you pass template directly + template: { ... }, // optional, unless you don't provide templateUrl + parameters: { ... }, // optional parameters for the stack + environment: { ... }, // optional environment values for the stack + files: { ... }, // optional files for the stack +} +``` +Returns the stack in the callback `f(err, stack)` + +#### client.getStack(stack, callback) +Retrieves the provided stack or stackId from the service. Callback has the signature `f(err, stack)`. + +#### client.previewStack(details, callback) +Identical to the `client.createStack()` call, except it only previews the creation, instead of actually provisioning +the stack. + +Returns the previewed stack in the callback `f(err, stack)` + +#### client.adoptStack(details, callback) +Identical to the `client.createStack()` call, except it requires passing `details.stackData` which is the `abandonedStack` +value returned from `client.abandonStack()`. + +Returns the created stack in the callback `f(err, stack)` + +#### client.updateStack(stack, callback) + +Update the provided stack. + +The following values from the provided stack are updatable. + +```js +{ + name: 'my-stack-name', // required + timeout: 30, // timeout, in minutes, required + templateUrl: 'http://path.to.some.openstack.heat.template', // required, unless you pass template directly + template: { ... }, // optional, unless you don't provide templateUrl + parameters: { ... }, // optional parameters for the stack + environment: { ... }, // optional environment values for the stack + files: { ... }, // optional files for the stack +} +``` + +#### client.deleteStack(stack, callback) + +Delete the created stack, and delete the resources. Callback is `f(err)`. + +#### client.abandonStack(stack, callback) + +Delete the created stack, but leave the resources running. Will callback with `f(err, abandonedStack)` where the +`abandonedStack` would be passed in as an option to `client.createStack()`. + +#### client.getTemplate(stack, callback) + +Get the template for a provided stack. Will callback with `f(err, template)`. + +## Resources + +#### client.getResource(stack, resource, callback) + +Get the resource for a provided stack and resource or resourceName in the callback `f(err, +resource)` + +#### client.getResources(stack, callback) +Get the resources for a provided stack. Callback is `f(err, resources)`. + +#### client.getResourceTypes(callback) +Get a list of valid resource types. Callback is `f(err, resourceTypes)`. + +#### client.getResourceSchema(resourceType, callback) +Get the schema for a provided resourceType. Callback is `f(err, resourceSchema)`. + +#### client.getResourceTemplate(resourceType, callback) +Get the template for a provided resourceType. Callback is `f(err, resourceTemplate)`. + +## Events + +#### client.getEvent(stack, resource, eventId, callback) +Get the event for a provided stack, resource and eventId. + +`f(err, event)` + +#### client.getEvents(stack, callback) +Get all of the events for a provided stack + +`f(err, events)` + +#### client.getResourceEvents(stack, resource, callback) +Get all of the events for a stack and resource. + +`f(err, events)` + +## Templates + +#### client.validateTemplate(template, callback) +Validates a provided template, with a callback of `f(err, template)`. \ No newline at end of file diff --git a/lib/pkgcloud/openstack/orchestration/index.js b/lib/pkgcloud/openstack/orchestration/index.js index 61f6569bd..56642940b 100644 --- a/lib/pkgcloud/openstack/orchestration/index.js +++ b/lib/pkgcloud/openstack/orchestration/index.js @@ -9,7 +9,6 @@ exports.Client = require('./client').Client; exports.Stack = require('./stack').Stack; exports.Resource = require('./resource').Resource; -//exports.Server = require('./server').Server; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/rackspace/index.js b/lib/pkgcloud/rackspace/index.js index 370ba7065..c4692676a 100644 --- a/lib/pkgcloud/rackspace/index.js +++ b/lib/pkgcloud/rackspace/index.js @@ -10,4 +10,5 @@ exports.compute = require('./compute'); exports.database = require('./database'); exports.dns = require('./dns'); exports.loadbalancer = require('./loadbalancer'); +exports.orchestration = require('./orchestration'); exports.storage = require('./storage'); diff --git a/lib/pkgcloud/rackspace/orchestration/client/index.js b/lib/pkgcloud/rackspace/orchestration/client/index.js new file mode 100644 index 000000000..cdd6b92bb --- /dev/null +++ b/lib/pkgcloud/rackspace/orchestration/client/index.js @@ -0,0 +1,67 @@ +/* + * client.js: client for Rackspace Orchestration + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + */ + +var util = require('util'), + rackspace = require('../../client'), + urlJoin = require('url-join'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + rackspace.Client.call(this, options); + + _.extend(this, require('../../../openstack/orchestration/client/events')); + _.extend(this, require('../../../openstack/orchestration/client/resources')); + _.extend(this, require('../../../openstack/orchestration/client/stacks')); + _.extend(this, require('../../../openstack/orchestration/client/templates')); + + this.serviceType = 'orchestration'; +}; + +util.inherits(Client, rackspace.Client); + +/** + * client._getUrl + * + * @description get the url for the current compute service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function (options) { + options = options || {}; + + if (!this._serviceUrl) { + throw new Error('Service url not found'); + } + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); +}; + +/** + * client.buildInfo + * + * @description gets the build information for the orchestration service + * + * @param callback + * @returns {*} + */ +Client.prototype.buildInfo = function (callback) { + return this._request({ + path: '/build_info' + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body); + }); +}; diff --git a/lib/pkgcloud/rackspace/orchestration/index.js b/lib/pkgcloud/rackspace/orchestration/index.js new file mode 100644 index 000000000..79ecf358b --- /dev/null +++ b/lib/pkgcloud/rackspace/orchestration/index.js @@ -0,0 +1,16 @@ + /* + * index.js: Top-level include for the Rackspace orchestration module + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + * + */ + +exports.Client = require('./client').Client; +exports.Stack = require('../../openstack/orchestration/stack').Stack; +exports.Resource = require('../../openstack/orchestration/resource').Resource; + +exports.createClient = function (options) { + return new exports.Client(options); +}; \ No newline at end of file From cbfb449aa14da6ce2fecc851962d9ba1f6d995dd Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 11:42:46 -0700 Subject: [PATCH 178/460] 1.0.1 changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3250176b7..c267df293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.0.1 +* Adding a rackspace orchestration provider + ## v1.0.0 * Requires node 0.10, dropping support for node v0.8 * Fundamentally changed the streaming file api for upload. No longer takes a callback. See #332 From c3e367c4ee8430f1efaf153be0db6b228496781d Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 11:42:50 -0700 Subject: [PATCH 179/460] 1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96711c10b..05a8873ca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.0.0", + "version": "1.0.1", "author": "Nodejitsu Inc ", "contributors": [ { From 72e2ebd2a5e52a9b5a7f147d086722f740981ce9 Mon Sep 17 00:00:00 2001 From: JC Ivancevich Date: Fri, 17 Oct 2014 15:58:34 -0300 Subject: [PATCH 180/460] default header check --- lib/pkgcloud/openstack/client.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 393d6a840..85a5b66c7 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -52,6 +52,10 @@ var Client = exports.Client = function (options) { }); this.before.push(function (req) { + if (req.headers['Content-Type'] && req.headers['Content-Type'] !== 'application/json') { + req.json = false; + return; + } req.json = true; if (typeof req.body !== 'undefined') { req.headers['Content-Type'] = 'application/json'; From b615ee68c88ad3a9eb95b42d020ee86cb05d5f72 Mon Sep 17 00:00:00 2001 From: JC Ivancevich Date: Fri, 17 Oct 2014 16:13:26 -0300 Subject: [PATCH 181/460] bulk delete --- .../openstack/storage/client/files.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 82dd4a3e1..a1ea1fab7 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -43,6 +43,31 @@ exports.removeFile = function (container, file, callback) { ); }; +/** + * client.bulkDelete + * + * @description remove a list of files from a container + * + * @param {String|object} container the container or containerName + * @param {array} files the files or fileNames to delete + * @param callback + */ +exports.bulkDelete = function(container, files, callback) { + var containerName = container instanceof this.models.Container ? container.name : container; + this._request({ + method: 'DELETE', + body: files.map(function(f) { + return containerName + '/' + f; + }).join('\r\n'), + headers: { + 'Content-Type': 'text/plain' + }, + qs: { + 'bulk-delete': true + } + }, callback); +}; + /** * client.upload * From 45d479cfe0c698303ef987989136b13c42436eee Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 17:18:21 -0700 Subject: [PATCH 182/460] Adding Openstack Cinder Support --- CHANGELOG.md | 3 + README.md | 4 +- docs/README.md | 8 +- docs/providers/openstack/README.md | 1 + docs/providers/openstack/blockstorage.md | 165 ++++++++++++++++++ .../openstack/blockstorage/client/index.js | 35 ++++ .../blockstorage/client/snapshots.js | 4 +- .../blockstorage/client/volumes.js | 4 +- .../blockstorage/client/volumetypes.js | 4 +- lib/pkgcloud/openstack/blockstorage/index.js | 17 ++ .../blockstorage/snapshot.js | 4 +- .../blockstorage/volume.js | 4 +- .../blockstorage/volumetype.js | 2 +- lib/pkgcloud/openstack/index.js | 1 + .../rackspace/blockstorage/client/index.js | 6 +- lib/pkgcloud/rackspace/blockstorage/index.js | 6 +- test/rackspace/blockstorage/volumes-test.js | 2 +- 17 files changed, 249 insertions(+), 21 deletions(-) create mode 100644 docs/providers/openstack/blockstorage.md create mode 100644 lib/pkgcloud/openstack/blockstorage/client/index.js rename lib/pkgcloud/{rackspace => openstack}/blockstorage/client/snapshots.js (98%) rename lib/pkgcloud/{rackspace => openstack}/blockstorage/client/volumes.js (97%) rename lib/pkgcloud/{rackspace => openstack}/blockstorage/client/volumetypes.js (95%) create mode 100644 lib/pkgcloud/openstack/blockstorage/index.js rename lib/pkgcloud/{rackspace => openstack}/blockstorage/snapshot.js (92%) rename lib/pkgcloud/{rackspace => openstack}/blockstorage/volume.js (93%) rename lib/pkgcloud/{rackspace => openstack}/blockstorage/volumetype.js (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c267df293..971cfb456 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.0.2 +* Adding support for OpenStack Cinder + ## v1.0.1 * Adding a rackspace orchestration provider diff --git a/README.md b/README.md index 8a88dfbb4..ba48116db 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](docs/providers/rackspace/dns.md) * **[Block Storage](#block-storage----beta)** *(beta)* * [Rackspace](docs/providers/rackspace/blockstorage.md) + * [Openstack](docs/providers/openstack/blockstorage.md) * **[Load Balancers](#load-balancers----beta)** *(beta)* * [Rackspace](docs/providers/rackspace/loadbalancer.md) * **[Orchestration](#orchestration----beta)** *(beta)* @@ -339,7 +340,7 @@ Each instance of `pkgcloud.dns.Client` returned from `pkgcloud.dns.createClient` ## Block Storage -- Beta -##### Note: Block Storage is considered Beta until there are multiple providers; presently only Rackspace are supported. +##### Note: Block Storage is considered Beta until there are multiple providers; presently only Openstack and Rackspace are supported. The `pkgcloud.blockstorage` service is designed to make it easy to create and manage block storage volumes and snapshots. @@ -361,6 +362,7 @@ To get started with a `pkgcloud.blockstorage` client just create one: #### Providers * [Rackspace](docs/providers/rackspace/blockstorage.md) +* [Rackspace](docs/providers/openstack/blockstorage.md) Each instance of `pkgcloud.blockstorage.Client` returned from `pkgcloud.blockstorage.createClient` has a set of uniform APIs: diff --git a/docs/README.md b/docs/README.md index 38c3098d4..38dd9fde5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -38,8 +38,12 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](providers/rackspace/dns.md) * **Block Storage** *(beta)* * [Rackspace](providers/rackspace/blockstorage.md) + * [Openstack](providers/openstack/blockstorage.md) +* **Orchestration** *(beta)* + * [Rackspace](providers/rackspace/orchestration.md) + * [Openstack](providers/openstack/orchestration.md) * **Load Balancers** *(beta)* * [Rackspace](providers/rackspace/loadbalancer.md) * **Networking** *(beta)* - * [Openstack](providers/openstack/network.md) - * [HP](providers/openstack/hp.md) + * [Openstack](providers/openstack/network.md) + * [HP](providers/openstack/hp.md) diff --git a/docs/providers/openstack/README.md b/docs/providers/openstack/README.md index d372f0f68..74abecd32 100644 --- a/docs/providers/openstack/README.md +++ b/docs/providers/openstack/README.md @@ -2,6 +2,7 @@ The OpenStack provider in pkgcloud supports the following services: +* [**BlockStorage**](blockstorage.md) (Cinder) * [**Compute**](compute.md) (Nova) * [**Storage**](storage.md) (Swift) * [**Network**](network.md) (Neutron) diff --git a/docs/providers/openstack/blockstorage.md b/docs/providers/openstack/blockstorage.md new file mode 100644 index 000000000..6a115f3b2 --- /dev/null +++ b/docs/providers/openstack/blockstorage.md @@ -0,0 +1,165 @@ +##Using the Openstack Block Storage provider + +#### BETA - This API may change as additional providers for block storage are added to pkgcloud + +Creating a block-storage client is straight-forward: + +``` js + var openstack = pkgcloud.blockstorage.createClient({ + provider: 'openstack', + username: 'your-user-name', + apiKey: 'your-api-key' + }); +``` + +[More options for creating clients](README.md) + +Note: For **attaching volumes to compute instances**, please see the [compute volume attachments](compute.md#volume-attachments) documentation. + +* Volume + * [Model](#volume-model) + * [APIs](#volume-apis) +* Snapshot + * [Model](#snapshot-model) + * [APIs](#snapshot-apis) +* VolumeType + * [Model](#volumetype-model) + * [APIs](#volumetype-apis) + +### Volume Model + +A Volume for BlockStorage has following properties: + +```Javascript +{ + id: '12345678-1111-2222-3333-123456789012', // id of the volume + name: 'foo3', + description: 'my volume', + status: 'available', // status of the volume + size: 100, // in GB + volumeType: 'SATA', + attachments: [], // array of the attachments for this volume + snapshotId: null, // snapshotId, if any, for this volume + createdAt: '2013-07-26T15:54:04.000000' +} +``` + +### Snapshot Model + +A Snapshot for BlockStorage has the following properties: + +```Javascript +{ + id: '12345678-1111-2222-3333-123456789012', // id of the snapshot + name: 'foo3', + description: 'my snapshot', + status: 'available', // status of the snapshot + size: 100, // in GB + volumeId: '12345678-1111-2222-3333-123456789012', + createdAt: '2013-07-26T15:54:04.000000' +} +``` + +### VolumeType Model + +A VolumeType for BlockStorage has the following properties: + +```Javascript +{ + id: '12345678-1111-2222-3333-123456789012', // id of the snapshot + name: 'SSD', + extra_specs: {} // not used presently +} +``` + +### Volume APIs + +#### client.getVolumes(options, callback) +Lists all volumes that are available to use on your Openstack account + +Callback returns `f(err, volumes)` where `volumes` is an `Array`. `options` is an optional `boolean` which will return the full volume details if true. + +#### client.getVolume(volume, callback) +Gets specified volume. + +Takes volume or volumeId as an argument and returns the volume in the callback +`f(err, volume)` + +#### client.createVolume(details, callback) +Creates a volume with the details specified + +Options are as follows: + +```js +{ + name: 'volumeName', // required + description: 'my volume', // required + size: 100, // 100-1000 gb + volumeType: 'SSD' // optional, defaults to spindles + snapshotId: '1234567890' // optional, the snapshotId to use when creating the volume +} +``` +Returns the new volume in the callback `f(err, volume)` + +#### client.deleteVolume(volume, callback) +Deletes the specified volume + +Takes volume or volumeId as an argument and returns an error if unsuccessful `f(err)` + +#### client.updateVolume(volume, callback) +Updates the name & description on the provided volume. Does not support resize. + +Returns callback with a confirmation + +### Snapshot APIs + +#### client.getSnapshots(options, callback) +Lists all snapshots that are available to use on your Openstack account + +Callback returns `f(err, snapshots)` where `snapshots` is an `Array`. `options` is an optional `boolean` which will return the full snapshot details if true. + +#### client.getSnapshot(snapshot, callback) +Gets specified snapshot. + +Takes snapshot or snapshotId as an argument and returns the snapshot in the callback +`f(err, snapshot)` + +#### client.createSnapshot(details, callback) +Creates a snapshot with the details specified + +Options are as follows: + +```js +{ + name: 'volumeName', // required + description: 'my volume', // required + volumeId: 'asdf1234', // required, volume id of the new snapshot + force: true // optional, defaults to false. force creation of the snapshot +} +``` +Returns the new snapshot in the callback `f(err, snapshot)` + +#### client.deleteSnapshot(snapshot, callback) +Deletes the specified snapshot + +Takes snapshot or snapshotId as an argument and returns an error if unsuccessful `f(err)` + +#### client.updateSnapshot(snapshot, callback) +Updates the name & description on the provided snapshot. + +Returns callback with a confirmation + +### VolumeType APIs + +Volume types are used to define which kind of new volume to create. + +#### client.getVolumeTypes(callback) +Lists all volumeTypes that are available to use on your Openstack account + +Callback returns `f(err, volumeTypes)` where `volumeTypes` is an `Array`. + +#### client.getVolumeType(volumeType, callback) +Gets specified volumeType. + +Takes volumeType or volumeTypeId as an argument and returns the volumeType in the callback +`f(err, volumeType)` diff --git a/lib/pkgcloud/openstack/blockstorage/client/index.js b/lib/pkgcloud/openstack/blockstorage/client/index.js new file mode 100644 index 000000000..514cfba96 --- /dev/null +++ b/lib/pkgcloud/openstack/blockstorage/client/index.js @@ -0,0 +1,35 @@ +/* + * index.js: Openstack cinder (blockstorage) client + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + * + */ + +var util = require('util'), + urlJoin = require('url-join'), + openstack = require('../../client'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + openstack.Client.call(this, options); + + _.extend(this, require('./volumetypes')); + _.extend(this, require('./snapshots')); + _.extend(this, require('./volumes')); + + this.serviceType = 'volume'; +}; + +util.inherits(Client, openstack.Client); + +Client.prototype._getUrl = function (options) { + options = options || {}; + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); + +}; diff --git a/lib/pkgcloud/rackspace/blockstorage/client/snapshots.js b/lib/pkgcloud/openstack/blockstorage/client/snapshots.js similarity index 98% rename from lib/pkgcloud/rackspace/blockstorage/client/snapshots.js rename to lib/pkgcloud/openstack/blockstorage/client/snapshots.js index 37dd51a0d..a0fddec4d 100644 --- a/lib/pkgcloud/rackspace/blockstorage/client/snapshots.js +++ b/lib/pkgcloud/openstack/blockstorage/client/snapshots.js @@ -1,7 +1,7 @@ /* - * snapshots.js: Instance methods for working with SnapShots from OpenStack Block Storage + * snapshots.js: Instance methods for working with SnapShots from Openstack Cinder (Block Storage) * - * (C) 2013 Rackspace + * (C) 2014 Rackspace * Ken Perkins * MIT LICENSE * diff --git a/lib/pkgcloud/rackspace/blockstorage/client/volumes.js b/lib/pkgcloud/openstack/blockstorage/client/volumes.js similarity index 97% rename from lib/pkgcloud/rackspace/blockstorage/client/volumes.js rename to lib/pkgcloud/openstack/blockstorage/client/volumes.js index 41ff07390..106151af3 100644 --- a/lib/pkgcloud/rackspace/blockstorage/client/volumes.js +++ b/lib/pkgcloud/openstack/blockstorage/client/volumes.js @@ -1,7 +1,7 @@ /* - * volumes.js: Instance methods for working with Volumes from CloudBlockStorage + * volumes.js: Instance methods for working with Volumes from Openstack Cinder (Block Storage) * - * (C) 2013 Rackspace + * (C) 2014 Rackspace * Ken Perkins * MIT LICENSE * diff --git a/lib/pkgcloud/rackspace/blockstorage/client/volumetypes.js b/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js similarity index 95% rename from lib/pkgcloud/rackspace/blockstorage/client/volumetypes.js rename to lib/pkgcloud/openstack/blockstorage/client/volumetypes.js index bf64aa9d9..438b668ed 100644 --- a/lib/pkgcloud/rackspace/blockstorage/client/volumetypes.js +++ b/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js @@ -1,7 +1,7 @@ /* - * volumetypes.js: Instance methods for working with VolumeTypes from CloudBlockStorage + * volumetypes.js: Instance methods for working with VolumeTypes from Openstack Cinder (Block Storage) * - * (C) 2013 Rackspace + * (C) 2014 Rackspace * Ken Perkins * MIT LICENSE * diff --git a/lib/pkgcloud/openstack/blockstorage/index.js b/lib/pkgcloud/openstack/blockstorage/index.js new file mode 100644 index 000000000..e80ae01ff --- /dev/null +++ b/lib/pkgcloud/openstack/blockstorage/index.js @@ -0,0 +1,17 @@ +/* + * index.js: Top-level include for the Openstack Block Storage module + * + * (C) 2014 Rackspace + * Ken Perkins + * MIT LICENSE + * + */ + +exports.Client = require('./client').Client; +exports.Volume = require('./volume').Volume; +exports.VolumeType = require('./volumetype').VolumeType; +exports.Snapshot = require('./snapshot').Snapshot; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/rackspace/blockstorage/snapshot.js b/lib/pkgcloud/openstack/blockstorage/snapshot.js similarity index 92% rename from lib/pkgcloud/rackspace/blockstorage/snapshot.js rename to lib/pkgcloud/openstack/blockstorage/snapshot.js index f6be4f6a0..75b054784 100644 --- a/lib/pkgcloud/rackspace/blockstorage/snapshot.js +++ b/lib/pkgcloud/openstack/blockstorage/snapshot.js @@ -1,7 +1,7 @@ /* - * volume.js: OpenStack BlockStorage snapshot + * volume.js: OpenStack Block Storage snapshot * - * (C) 2013 Rackspace + * (C) 2014 Rackspace * Ken Perkins * MIT LICENSE * diff --git a/lib/pkgcloud/rackspace/blockstorage/volume.js b/lib/pkgcloud/openstack/blockstorage/volume.js similarity index 93% rename from lib/pkgcloud/rackspace/blockstorage/volume.js rename to lib/pkgcloud/openstack/blockstorage/volume.js index 944876dbb..2ccf74d5b 100644 --- a/lib/pkgcloud/rackspace/blockstorage/volume.js +++ b/lib/pkgcloud/openstack/blockstorage/volume.js @@ -1,7 +1,7 @@ /* - * volume.js: OpenStack BlockStorage volume + * volume.js: OpenStack Block Storage volume * - * (C) 2013 Rackspace + * (C) 2014 Rackspace * Ken Perkins * MIT LICENSE * diff --git a/lib/pkgcloud/rackspace/blockstorage/volumetype.js b/lib/pkgcloud/openstack/blockstorage/volumetype.js similarity index 96% rename from lib/pkgcloud/rackspace/blockstorage/volumetype.js rename to lib/pkgcloud/openstack/blockstorage/volumetype.js index 07e71b708..c4b79a243 100644 --- a/lib/pkgcloud/rackspace/blockstorage/volumetype.js +++ b/lib/pkgcloud/openstack/blockstorage/volumetype.js @@ -1,7 +1,7 @@ /* * volumetype.js: OpenStack Block Storage volume type * - * (C) 2013 Rackspace + * (C) 2014 Rackspace * Ken Perkins * MIT LICENSE * diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index fdfc6bb27..59d3c730d 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -5,6 +5,7 @@ * */ +exports.blockstorage = require('./blockstorage'); exports.compute = require('./compute'); exports.identity = require('./identity'); exports.orchestration = require('./orchestration'); diff --git a/lib/pkgcloud/rackspace/blockstorage/client/index.js b/lib/pkgcloud/rackspace/blockstorage/client/index.js index fa5c0f455..3d8e95848 100644 --- a/lib/pkgcloud/rackspace/blockstorage/client/index.js +++ b/lib/pkgcloud/rackspace/blockstorage/client/index.js @@ -15,9 +15,9 @@ var util = require('util'), var Client = exports.Client = function (options) { rackspace.Client.call(this, options); - _.extend(this, require('./volumetypes')); - _.extend(this, require('./snapshots')); - _.extend(this, require('./volumes')); + _.extend(this, require('../../../openstack/blockstorage/client/volumetypes')); + _.extend(this, require('../../../openstack/blockstorage/client/snapshots')); + _.extend(this, require('../../../openstack/blockstorage/client/volumes')); this.serviceType = 'volume'; }; diff --git a/lib/pkgcloud/rackspace/blockstorage/index.js b/lib/pkgcloud/rackspace/blockstorage/index.js index c48916fee..9c8abcd17 100644 --- a/lib/pkgcloud/rackspace/blockstorage/index.js +++ b/lib/pkgcloud/rackspace/blockstorage/index.js @@ -8,9 +8,9 @@ */ exports.Client = require('./client').Client; -exports.Volume = require('./volume').Volume; -exports.VolumeType = require('./volumetype').VolumeType; -exports.Snapshot = require('./snapshot').Snapshot; +exports.Volume = require('../../openstack/blockstorage/volume').Volume; +exports.VolumeType = require('../../openstack/blockstorage/volumetype').VolumeType; +exports.Snapshot = require('../../openstack/blockstorage/snapshot').Snapshot; exports.createClient = function (options) { return new exports.Client(options); diff --git a/test/rackspace/blockstorage/volumes-test.js b/test/rackspace/blockstorage/volumes-test.js index 1487133dc..5a467933b 100644 --- a/test/rackspace/blockstorage/volumes-test.js +++ b/test/rackspace/blockstorage/volumes-test.js @@ -13,7 +13,7 @@ var fs = require('fs'), hock = require('hock'), http = require('http'), helpers = require('../../helpers'), - Volume = require('../../../lib/pkgcloud/rackspace/blockstorage/volume').Volume, + Volume = require('../../../lib/pkgcloud/openstack/blockstorage/volume').Volume, mock = !!process.env.MOCK; describe('pkgcloud/rackspace/blockstorage/volumes', function () { From 622a37066ceaac2b7a99f63372b4774559bf61d3 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 17:22:27 -0700 Subject: [PATCH 183/460] 1.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05a8873ca..93c78c7d0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.0.1", + "version": "1.0.2", "author": "Nodejitsu Inc ", "contributors": [ { From d1af8dbdff37d6c8163a43a24816e01e9f3d3ac4 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 17 Oct 2014 20:10:49 -0700 Subject: [PATCH 184/460] Adding null option handles for amazon, azure --- lib/pkgcloud/amazon/storage/client/files.js | 3 +++ lib/pkgcloud/azure/storage/client/files.js | 3 +++ lib/pkgcloud/openstack/storage/client/files.js | 3 ++- test/common/storage/base-test.js | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 6a3369f05..ae1431337 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -116,6 +116,9 @@ exports.getFiles = function (container, options, callback) { callback = options; options = {}; } + else if (!options) { + options = {}; + } var s3Options = { Bucket: containerName diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 18612de04..a3862578e 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -334,6 +334,9 @@ exports.getFiles = function (container, options, callback) { callback = options; options = {}; } + else if (!options) { + options = {}; + } this._xmlRequest({ method: 'GET', diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index db097282a..81336456c 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -240,7 +240,8 @@ exports.getFiles = function (container, options, callback) { if (typeof options === 'function') { callback = options; options = {}; - } else if (!options) { + } + else if (!options) { options = {}; } diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index a923f82df..71165844b 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -233,7 +233,7 @@ providers.filter(function (provider) { }); } - client.getFiles(context.container, function (err, files) { + client.getFiles(context.container, null, function (err, files) { should.not.exist(err); should.exist(files); From 445aeaa377641f0572568832fe5fb16dc912c566 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 18 Oct 2014 11:27:42 -0700 Subject: [PATCH 185/460] Cleaning up Rackspace references in openstack providers - Fixes #338 --- docs/providers/openstack/compute.md | 4 ++-- docs/providers/openstack/storage.md | 6 +++--- lib/pkgcloud/openstack/storage/client/files.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/providers/openstack/compute.md b/docs/providers/openstack/compute.md index 3b107dafd..8c4ee84f1 100644 --- a/docs/providers/openstack/compute.md +++ b/docs/providers/openstack/compute.md @@ -76,7 +76,7 @@ Returns a list of all possible server flavors available in the callback `f(err, flavors)` #### client.getFlavor(flavor, callback) -Returns the specified rackspace flavor of Openstack Images by ID or flavor +Returns the specified flavor of Openstack Images by ID or flavor object in the callback `f(err, flavor)` **images** @@ -114,7 +114,7 @@ Destroys the specified image and returns a confirmation ## Volume Attachments -Attaching a volume to a compute instance requires using a rackspace compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. +Attaching a volume to a compute instance requires using an openstack compute client, as well as possessing a `volume` or `volumeId`. Detaching volumes behaves the same way. #### client.getVolumeAttachments(server, callback) diff --git a/docs/providers/openstack/storage.md b/docs/providers/openstack/storage.md index 825421d6b..c85470bb7 100644 --- a/docs/providers/openstack/storage.md +++ b/docs/providers/openstack/storage.md @@ -10,7 +10,7 @@ Creating a client is straight-forward: ``` js - var rackspace = pkgcloud.storage.createClient({ + var openstack = pkgcloud.storage.createClient({ provider: 'openstack', username: 'your-user-name', password: 'your-password', @@ -207,7 +207,7 @@ You need not provide either `stream` or `local`. `client.download` returns a rea var fs = require('fs'), pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.openstack.storage.createClient({ ... }); var myFile = fs.createWriteStream('/my/local/file'); @@ -224,7 +224,7 @@ You could also download to a local file via the `local` property on `options`: ```Javascript var pkgcloud = require('pkgcloud'); -var client = pkgcloud.providers.rackspace.storage.createClient({ ... }); +var client = pkgcloud.providers.openstack.storage.createClient({ ... }); client.download({ container: 'my-container', diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 81336456c..ef2b62bc2 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -334,7 +334,7 @@ exports._getFiles = function (container, options, callback) { * client.updateFileMetadata * * @description Updates the specified `file` with the provided metadata `headers` - * in the Rackspace Cloud Files account associated with this instance. + * in the Openstack account associated with this instance. * * @param {String|object} container the container or containerName * @param {String|object} file the file or fileName to update From a2c4295ebabe9abaa8b7fe89f81d6f0a06745635 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 18 Oct 2014 11:41:03 -0700 Subject: [PATCH 186/460] Adding more details to options required for creating a client to rackspace - Part of #337 --- docs/providers/rackspace/blockstorage.md | 9 ++++++--- docs/providers/rackspace/compute.md | 9 ++++++--- docs/providers/rackspace/databases.md | 9 ++++++--- docs/providers/rackspace/dns.md | 9 ++++++--- docs/providers/rackspace/loadbalancer.md | 9 ++++++--- docs/providers/rackspace/orchestration.md | 10 ++++++---- docs/providers/rackspace/storage.md | 10 ++++++---- 7 files changed, 42 insertions(+), 23 deletions(-) diff --git a/docs/providers/rackspace/blockstorage.md b/docs/providers/rackspace/blockstorage.md index cb59ef682..f1dc0b70c 100644 --- a/docs/providers/rackspace/blockstorage.md +++ b/docs/providers/rackspace/blockstorage.md @@ -6,9 +6,12 @@ Creating a block-storage client is straight-forward: ``` js var rackspace = pkgcloud.blockstorage.createClient({ - provider: 'rackspace', - username: 'your-user-name', - apiKey: 'your-api-key' + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + region: 'IAD', // required, regions can be found at + // http://www.rackspace.com/knowledge_center/article/about-regions + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine }); ``` diff --git a/docs/providers/rackspace/compute.md b/docs/providers/rackspace/compute.md index 25bedbe4c..8637ed016 100644 --- a/docs/providers/rackspace/compute.md +++ b/docs/providers/rackspace/compute.md @@ -6,9 +6,12 @@ Creating a client is straight-forward: ``` js var rackspace = pkgcloud.compute.createClient({ - provider: 'rackspace', - username: 'your-user-name', - apiKey: 'your-api-key' + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + region: 'IAD', // required, regions can be found at + // http://www.rackspace.com/knowledge_center/article/about-regions + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine }); ``` diff --git a/docs/providers/rackspace/databases.md b/docs/providers/rackspace/databases.md index 6ad70fff9..8ccf0a475 100644 --- a/docs/providers/rackspace/databases.md +++ b/docs/providers/rackspace/databases.md @@ -4,9 +4,12 @@ Creating a client is straight-forward: ``` js var rackspace = pkgcloud.database.createClient({ - provider: 'rackspace', - username: 'your-user-name', - apiKey: 'your-api-key' + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + region: 'IAD', // required, regions can be found at + // http://www.rackspace.com/knowledge_center/article/about-regions + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine }); ``` diff --git a/docs/providers/rackspace/dns.md b/docs/providers/rackspace/dns.md index 58d6349cc..255be6f2b 100644 --- a/docs/providers/rackspace/dns.md +++ b/docs/providers/rackspace/dns.md @@ -10,10 +10,13 @@ Creating a client is straight-forward: ``` js + // Rackspace Cloud DNS is a global service, so no region is required + var rackspace = pkgcloud.dns.createClient({ - provider: 'rackspace', - username: 'your-user-name', - apiKey: 'your-api-key' + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine }); ``` diff --git a/docs/providers/rackspace/loadbalancer.md b/docs/providers/rackspace/loadbalancer.md index 20ccf5cc0..1c045062f 100644 --- a/docs/providers/rackspace/loadbalancer.md +++ b/docs/providers/rackspace/loadbalancer.md @@ -28,9 +28,12 @@ Creating a loadbalancer client is straight-forward: ``` js var rackspace = pkgcloud.loadbalancer.createClient({ - provider: 'rackspace', - username: 'your-user-name', - apiKey: 'your-api-key' + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + region: 'IAD', // required, regions can be found at + // http://www.rackspace.com/knowledge_center/article/about-regions + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine }); ``` diff --git a/docs/providers/rackspace/orchestration.md b/docs/providers/rackspace/orchestration.md index 3cd5a622a..7f53282d2 100644 --- a/docs/providers/rackspace/orchestration.md +++ b/docs/providers/rackspace/orchestration.md @@ -4,10 +4,12 @@ Creating a client is straight-forward: ``` js var rackspace = pkgcloud.orchestration.createClient({ - provider: 'rackspace', - username: 'your-user-name', - password: 'your-password', - authUrl: 'https://your-identity-service' + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + region: 'IAD', // required, regions can be found at + // http://www.rackspace.com/knowledge_center/article/about-regions + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine }); ``` diff --git a/docs/providers/rackspace/storage.md b/docs/providers/rackspace/storage.md index dce2bf2b6..645a948d9 100644 --- a/docs/providers/rackspace/storage.md +++ b/docs/providers/rackspace/storage.md @@ -11,10 +11,12 @@ Creating a client is straight-forward: ``` js var rackspace = pkgcloud.storage.createClient({ - provider: 'rackspace', - username: 'your-rax-user-name', - apiKey: 'your-rax-api-key', - region: 'IAD' + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + region: 'IAD', // required, regions can be found at + // http://www.rackspace.com/knowledge_center/article/about-regions + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine }); ``` From dcc5820ee516371ba511f417a49a5c002caba56d Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 18 Oct 2014 11:47:00 -0700 Subject: [PATCH 187/460] Cleaning up the options for the openstack createClient docs - Part of #337 --- docs/providers/openstack/blockstorage.md | 8 +++++--- docs/providers/openstack/compute.md | 10 ++++++---- docs/providers/openstack/network.md | 11 +++++++---- docs/providers/openstack/orchestration.md | 10 ++++++---- docs/providers/openstack/storage.md | 10 ++++++---- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/docs/providers/openstack/blockstorage.md b/docs/providers/openstack/blockstorage.md index 6a115f3b2..60073e582 100644 --- a/docs/providers/openstack/blockstorage.md +++ b/docs/providers/openstack/blockstorage.md @@ -6,11 +6,13 @@ Creating a block-storage client is straight-forward: ``` js var openstack = pkgcloud.blockstorage.createClient({ - provider: 'openstack', - username: 'your-user-name', - apiKey: 'your-api-key' + provider: 'openstack', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required }); ``` +**Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.* [More options for creating clients](README.md) diff --git a/docs/providers/openstack/compute.md b/docs/providers/openstack/compute.md index 8c4ee84f1..614246ee6 100644 --- a/docs/providers/openstack/compute.md +++ b/docs/providers/openstack/compute.md @@ -4,13 +4,15 @@ Creating a client is straight-forward: ``` js var openstack = pkgcloud.compute.createClient({ - provider: 'openstack', - username: 'your-user-name', - password: 'your-password', - authUrl: 'https://your-identity-service' + provider: 'openstack', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required }); ``` +**Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.* + [More options for creating clients](README.md) ### API Methods diff --git a/docs/providers/openstack/network.md b/docs/providers/openstack/network.md index a778fdc7f..7c1fca117 100644 --- a/docs/providers/openstack/network.md +++ b/docs/providers/openstack/network.md @@ -4,12 +4,15 @@ Creating a client is straight-forward: ``` js var openstack = pkgcloud.network.createClient({ - provider: 'openstack', - username: 'your-user-name', - password: 'your-password', - authUrl: 'https://yourIdentity-service' + provider: 'openstack', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required }); ``` + +**Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.* + ### API Methods **Networks** diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index f36024917..fc2a099d0 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -4,13 +4,15 @@ Creating a client is straight-forward: ``` js var openstack = pkgcloud.orchestration.createClient({ - provider: 'openstack', - username: 'your-user-name', - password: 'your-password', - authUrl: 'https://your-identity-service' + provider: 'openstack', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required }); ``` +**Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.* + [More options for creating clients](README.md) ### API Methods diff --git a/docs/providers/openstack/storage.md b/docs/providers/openstack/storage.md index c85470bb7..6ff53d136 100644 --- a/docs/providers/openstack/storage.md +++ b/docs/providers/openstack/storage.md @@ -11,13 +11,15 @@ Creating a client is straight-forward: ``` js var openstack = pkgcloud.storage.createClient({ - provider: 'openstack', - username: 'your-user-name', - password: 'your-password', - authUrl: 'https://your-identity-service' + provider: 'openstack', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required }); ``` +**Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.* + Learn about [more options for creating clients](README.md) in the Openstack `storage` provider. ### Container Model From 611430c664d7967c159d2487bd854cbb6eadbe00 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 18 Oct 2014 11:48:37 -0700 Subject: [PATCH 188/460] Adding a note on the openstack README - Part of #337 --- docs/providers/openstack/README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/providers/openstack/README.md b/docs/providers/openstack/README.md index 74abecd32..d323023ca 100644 --- a/docs/providers/openstack/README.md +++ b/docs/providers/openstack/README.md @@ -16,15 +16,18 @@ We've provided a [simple compute example](getting-started-compute.md) where it c For all of the Openstack services, you create a client with the same options: -```Javascript -var client = require('pkgcloud').compute.createClient({ - provider: 'openstack', - username: 'your-user-name', - password: 'your-password', - authUrl: 'https://your-identity-service' -}); +```javascript + var openstack = pkgcloud.storage.createClient({ + provider: 'openstack', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required + }); ``` +**Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.* + + ### Authentication Endpoints and Regions All of the Openstack `createClient` calls have a few options that can be provided: From 4d3ffdd72f353d7b51f5090c173e06e82780d320 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 18 Oct 2014 11:49:29 -0700 Subject: [PATCH 189/460] Adding a missing region to rackspace compute-getting-started - Part of #337 --- docs/providers/rackspace/getting-started-compute.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/providers/rackspace/getting-started-compute.md b/docs/providers/rackspace/getting-started-compute.md index 9ec9832a7..7ed6d007e 100644 --- a/docs/providers/rackspace/getting-started-compute.md +++ b/docs/providers/rackspace/getting-started-compute.md @@ -25,7 +25,8 @@ var pkgcloud = require('pkgcloud'), // create our client with your rackspace credentials var client = pkgcloud.providers.rackspace.compute.createClient({ username: 'your-username', - apiKey: 'your-api-key' + apiKey: 'your-api-key', + region: 'your-region' // see http://www.rackspace.com/knowledge_center/article/about-regions }); // first we're going to get our flavors From 129f5a2dc419f946a7c139c7ccd7e52dab559e09 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 18 Oct 2014 12:00:32 -0700 Subject: [PATCH 190/460] Adding regions list to rackspace docs --- docs/providers/rackspace/README.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/providers/rackspace/README.md b/docs/providers/rackspace/README.md index e8ea55e53..1a5a9208c 100644 --- a/docs/providers/rackspace/README.md +++ b/docs/providers/rackspace/README.md @@ -32,33 +32,40 @@ In addition to your `apiKey`, you could alternately provide your `password` as a All of the Rackspace `createClient` calls have a few options that can be provided: -#### authUrl +#### region -`authUrl` specifies the authentication endpoint used to create a token for your Rackspace client. By default, this is set to the Global endpoint: https://identity.api.rackspacecloud.com. +`region` specifies which region of a service to use. Different services have different regions enabled, and DNS doesn't require a region at all. The current list of regions is: -##### Authenticating against the London endpoint +- `DFW` (Dallas, Texas) +- `ORD` (Chicago, Illinois) +- `IAD` (Washington, DC) +- `LON` (London, UK) +- `SYD` (Sydney, Austrailia) +- `HKG` (Hong Kong, China) + +##### Specifying a custom region ```Javascript var client = require('pkgcloud').compute.createClient({ provider: 'rackspace', username: 'your-user-name', apiKey: 'your-api-key', - authUrl: 'https://lon.identity.api.rackspacecloud.com' + region: 'ORD' }); ``` -#### region +#### authUrl -`region` specifies which region of a service to use. For example, when you authenticate with the global endpoint for compute, you have the option of either `DFW`, `ORD`, or `SYD`. The default region is `DFW`. Previous pkgcloud versions did not let you specify which region you used, so all calls were against `DFW`. +`authUrl` specifies the authentication endpoint used to create a token for your Rackspace client. By default, this is set to the Global endpoint: https://identity.api.rackspacecloud.com. -##### Specifying a custom region +##### Authenticating against the London endpoint ```Javascript var client = require('pkgcloud').compute.createClient({ provider: 'rackspace', username: 'your-user-name', apiKey: 'your-api-key', - region: 'ORD' + authUrl: 'https://lon.identity.api.rackspacecloud.com' }); ``` From 3b2179d273e11999fb099706cd88396adf072e75 Mon Sep 17 00:00:00 2001 From: JC Ivancevich Date: Sat, 18 Oct 2014 18:33:02 -0300 Subject: [PATCH 191/460] accept both string and File values and explicit callback for bulk delete --- lib/pkgcloud/openstack/storage/client/files.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index a1ea1fab7..6b384e9d3 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -53,11 +53,12 @@ exports.removeFile = function (container, file, callback) { * @param callback */ exports.bulkDelete = function(container, files, callback) { - var containerName = container instanceof this.models.Container ? container.name : container; + var self = this, + containerName = container instanceof this.models.Container ? container.name : container; this._request({ method: 'DELETE', body: files.map(function(f) { - return containerName + '/' + f; + return containerName + '/' + (f instanceof self.models.File ? f.name : f); }).join('\r\n'), headers: { 'Content-Type': 'text/plain' @@ -65,7 +66,11 @@ exports.bulkDelete = function(container, files, callback) { qs: { 'bulk-delete': true } - }, callback); + }, function(err, results) { + return err + ? callback(err) + : callback(null, results); + }); }; /** From 2ce7d3027592d73c69407fc1ad03cffd1c80c299 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sat, 18 Oct 2014 14:51:44 -0700 Subject: [PATCH 192/460] Minor style cleanup --- lib/pkgcloud/openstack/storage/client/files.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 6b384e9d3..9847b132d 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -16,6 +16,7 @@ var fs = require('fs'), errs = require('errs'), through = require('through2'), _ = require('underscore'), + urlJoin = require('url-join'), storage = pkgcloud.providers.openstack.storage; /** @@ -57,8 +58,8 @@ exports.bulkDelete = function(container, files, callback) { containerName = container instanceof this.models.Container ? container.name : container; this._request({ method: 'DELETE', - body: files.map(function(f) { - return containerName + '/' + (f instanceof self.models.File ? f.name : f); + body: files.map(function(file) { + return urlJoin(containerName, (file instanceof self.models.File ? file.name : file)); }).join('\r\n'), headers: { 'Content-Type': 'text/plain' From 62597f171ddd984071157c575e6b95f9a9f94940 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Sun, 19 Oct 2014 08:21:16 -0700 Subject: [PATCH 193/460] Cleaning up Amazon docs --- docs/providers/amazon.md | 42 ++++++++++++++++++----------------- lib/pkgcloud/amazon/client.js | 10 ++++----- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/providers/amazon.md b/docs/providers/amazon.md index 7f5273352..c19aed2ad 100644 --- a/docs/providers/amazon.md +++ b/docs/providers/amazon.md @@ -1,26 +1,28 @@ -# Using Amazon Web Services (aws) with `pkgcloud` +## Using the Amazon (AWS) provider in pkgcloud -* [Using Compute](#using-compute) -* [Using Storage](#using-storage) +The Amazon provider in pkgcloud supports the following services: - -## Using Compute +* **Compute** (EC2) +* **Storage** S3 (Simple Storage Service) -``` js - var amazon = pkgcloud.compute.createClient({ - provider: 'amazon', - key: 'asdfkjas;dkj43498aj3n', - keyId: '98kja34lkj' - }); -``` +### Client Creation - -## Using Storage +For all of the Amazon services, you create a client with the same options: -``` js - var amazon = pkgcloud.storage.createClient({ - provider: 'amazon', // 'aws', 's3' - key: 'asdfkjas;dkj43498aj3n', - keyId: '98kja34lkj' - }); +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'amazon', + key: 'your-secret-key-id', // secret key + keyId: 'your-access-key-id' // access key id + region: 'us-west-2' // region +}); ``` + +```Javascript +var client = require('pkgcloud').storage.createClient({ + provider: 'amazon', + key: 'your-secret-key-id', // secret key + keyId: 'your-access-key-id' // access key id + region: 'us-west-2' // region +}); +``` \ No newline at end of file diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index 0f4791fb6..602908d3c 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -29,8 +29,12 @@ var Client = exports.Client = function (options) { || this.serversUrl || 'ec2.amazonaws.com'; + // support either key/accessKey syntax + this.config.key = this.config.key || options.accessKey; + this.config.keyId = this.config.keyId || options.accessKeyId; + // Configure amazon client - AWS.config.update({ accessKeyId: options.keyId, secretAccessKey: options.key }); + AWS.config.update({ accessKeyId: this.config.keyId, secretAccessKey: this.config.key }); AWS.config.update({ region: options.region }); // TODO think about a proxy option for pkgcloud @@ -50,10 +54,6 @@ var Client = exports.Client = function (options) { return self.userAgent; }; - // support either key/accessKey syntax - this.config.key = this.config.key || options.accessKey; - this.config.keyId = this.config.keyId || options.accessKeyId; - if (!this.before) { this.before = []; } From c271029ec813d1072080c2aa99fb4d3aeb7bfd3a Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 20 Oct 2014 21:38:12 -0700 Subject: [PATCH 194/460] Adding the ability to override the default identity path for openstack - Fixes #336 --- lib/pkgcloud/hp/identity/hpIdentity.js | 1 + lib/pkgcloud/openstack/client.js | 3 +++ lib/pkgcloud/openstack/context/identity.js | 3 ++- lib/pkgcloud/rackspace/identity/rackspaceIdentity.js | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/hp/identity/hpIdentity.js b/lib/pkgcloud/hp/identity/hpIdentity.js index 7070665b6..e57630507 100644 --- a/lib/pkgcloud/hp/identity/hpIdentity.js +++ b/lib/pkgcloud/hp/identity/hpIdentity.js @@ -16,6 +16,7 @@ exports.Identity = HPIdentity = function (options) { this.options = options; this.name = 'HPIdentity'; + this.basePath = options.basePath || '/v2.0/tokens'; this.useServiceCatalog = (typeof options.useServiceCatalog === 'boolean') ? options.useServiceCatalog : true; diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 85a5b66c7..8c10cb3d5 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -90,6 +90,9 @@ Client.prototype._getIdentityOptions = function() { if (typeof this.config.useServiceCatalog === 'boolean') { options.useServiceCatalog = this.config.useServiceCatalog; } + if (this.config.basePath) { + options.basePath = this.config.basePath; + } return options; }; diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index c4af3c336..fb1c65c49 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -47,6 +47,7 @@ var Identity = exports.Identity = function (options) { self.options = options || {}; self.name = 'OpenstackIdentity'; + self.basePath = options.basePath || '/v2.0/tokens'; self.useServiceCatalog = (typeof options.useServiceCatalog === 'boolean') ? options.useServiceCatalog : true; @@ -76,7 +77,7 @@ Identity.prototype.authorize = function (options, callback) { options = {}; } var authenticationOptions = { - uri: urlJoin(options.url || self.options.url, '/v2.0/tokens'), + uri: urlJoin(options.url || self.options.url, self.basePath), method: 'POST', headers: { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version), diff --git a/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js b/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js index eae184477..b518016ff 100644 --- a/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js +++ b/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js @@ -17,6 +17,7 @@ exports.Identity = RackspaceIdentity = function (options) { this.options = options; this.name = 'RackspaceIdentity'; + this.basePath = options.basePath || '/v2.0/tokens'; this.useServiceCatalog = (typeof options.useServiceCatalog === 'boolean') ? options.useServiceCatalog : true; From 04007466d6893388c0ea6fff12c19c930b1cbb7a Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 22 Oct 2014 14:34:48 -0700 Subject: [PATCH 195/460] Moving rackspace database client to openstack --- .../{rackspace => openstack}/database/client/databases.js | 0 .../{rackspace => openstack}/database/client/flavors.js | 0 .../{rackspace => openstack}/database/client/instances.js | 0 .../{rackspace => openstack}/database/client/users.js | 0 .../{rackspace => openstack}/database/database.js | 0 lib/pkgcloud/{rackspace => openstack}/database/flavor.js | 0 .../{rackspace => openstack}/database/instance.js | 0 lib/pkgcloud/{rackspace => openstack}/database/user.js | 0 lib/pkgcloud/rackspace/database/client/index.js | 8 ++++---- lib/pkgcloud/rackspace/database/index.js | 8 ++++---- test/rackspace/databases/instances-test.js | 7 +++---- test/rackspace/databases/users-test.js | 4 ++-- 12 files changed, 13 insertions(+), 14 deletions(-) rename lib/pkgcloud/{rackspace => openstack}/database/client/databases.js (100%) rename lib/pkgcloud/{rackspace => openstack}/database/client/flavors.js (100%) rename lib/pkgcloud/{rackspace => openstack}/database/client/instances.js (100%) rename lib/pkgcloud/{rackspace => openstack}/database/client/users.js (100%) rename lib/pkgcloud/{rackspace => openstack}/database/database.js (100%) rename lib/pkgcloud/{rackspace => openstack}/database/flavor.js (100%) rename lib/pkgcloud/{rackspace => openstack}/database/instance.js (100%) rename lib/pkgcloud/{rackspace => openstack}/database/user.js (100%) diff --git a/lib/pkgcloud/rackspace/database/client/databases.js b/lib/pkgcloud/openstack/database/client/databases.js similarity index 100% rename from lib/pkgcloud/rackspace/database/client/databases.js rename to lib/pkgcloud/openstack/database/client/databases.js diff --git a/lib/pkgcloud/rackspace/database/client/flavors.js b/lib/pkgcloud/openstack/database/client/flavors.js similarity index 100% rename from lib/pkgcloud/rackspace/database/client/flavors.js rename to lib/pkgcloud/openstack/database/client/flavors.js diff --git a/lib/pkgcloud/rackspace/database/client/instances.js b/lib/pkgcloud/openstack/database/client/instances.js similarity index 100% rename from lib/pkgcloud/rackspace/database/client/instances.js rename to lib/pkgcloud/openstack/database/client/instances.js diff --git a/lib/pkgcloud/rackspace/database/client/users.js b/lib/pkgcloud/openstack/database/client/users.js similarity index 100% rename from lib/pkgcloud/rackspace/database/client/users.js rename to lib/pkgcloud/openstack/database/client/users.js diff --git a/lib/pkgcloud/rackspace/database/database.js b/lib/pkgcloud/openstack/database/database.js similarity index 100% rename from lib/pkgcloud/rackspace/database/database.js rename to lib/pkgcloud/openstack/database/database.js diff --git a/lib/pkgcloud/rackspace/database/flavor.js b/lib/pkgcloud/openstack/database/flavor.js similarity index 100% rename from lib/pkgcloud/rackspace/database/flavor.js rename to lib/pkgcloud/openstack/database/flavor.js diff --git a/lib/pkgcloud/rackspace/database/instance.js b/lib/pkgcloud/openstack/database/instance.js similarity index 100% rename from lib/pkgcloud/rackspace/database/instance.js rename to lib/pkgcloud/openstack/database/instance.js diff --git a/lib/pkgcloud/rackspace/database/user.js b/lib/pkgcloud/openstack/database/user.js similarity index 100% rename from lib/pkgcloud/rackspace/database/user.js rename to lib/pkgcloud/openstack/database/user.js diff --git a/lib/pkgcloud/rackspace/database/client/index.js b/lib/pkgcloud/rackspace/database/client/index.js index 70a7e88a0..617476f78 100644 --- a/lib/pkgcloud/rackspace/database/client/index.js +++ b/lib/pkgcloud/rackspace/database/client/index.js @@ -17,10 +17,10 @@ var Client = exports.Client = function (options) { this.before.push(auth.accountId); - _.extend(this, require('./flavors')); - _.extend(this, require('./instances')); - _.extend(this, require('./databases')); - _.extend(this, require('./users')); + _.extend(this, require('../../../openstack/database/client/flavors')); + _.extend(this, require('../../../openstack/database/client/instances')); + _.extend(this, require('../../../openstack/database/client/databases')); + _.extend(this, require('../../../openstack/database/client/users')); this.serviceType = 'rax:database'; }; diff --git a/lib/pkgcloud/rackspace/database/index.js b/lib/pkgcloud/rackspace/database/index.js index 995030f48..f09c0df3f 100644 --- a/lib/pkgcloud/rackspace/database/index.js +++ b/lib/pkgcloud/rackspace/database/index.js @@ -6,10 +6,10 @@ */ exports.Client = require('./client').Client; -exports.Flavor = require('./flavor').Flavor; -exports.Instance = require('./instance').Instance; -exports.Database = require('./database').Database; -exports.User = require('./user').User; +exports.Flavor = require('../../openstack/database/flavor').Flavor; +exports.Instance = require('../../openstack/database/instance').Instance; +exports.Database = require('../../openstack/database/database').Database; +exports.User = require('../../openstack/database/user').User; exports.createClient = function createClient(options) { return new exports.Client(options); diff --git a/test/rackspace/databases/instances-test.js b/test/rackspace/databases/instances-test.js index 37ad717ce..5e7daf051 100644 --- a/test/rackspace/databases/instances-test.js +++ b/test/rackspace/databases/instances-test.js @@ -12,7 +12,7 @@ var should = require('should'), async = require('async'), helpers = require('../../helpers'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, - Instance = require('../../../lib/pkgcloud/rackspace/database/instance').Instance, + Instance = require('../../../lib/pkgcloud/openstack/database/instance').Instance, mock = !!process.env.MOCK; describe('pkgcloud/rackspace/databases/instances', function () { @@ -49,7 +49,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { var err, instance; before(function(done) { - + if (mock) { authHockInstance .post('/v2.0/tokens', { @@ -77,7 +77,7 @@ describe('pkgcloud/rackspace/databases/instances', function () { } }) .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); - + } client.getFlavor(1, function (err, flavor) { should.not.exist(err); @@ -529,4 +529,3 @@ function assertLinks(links) { should.exist(link.rel); }); } - diff --git a/test/rackspace/databases/users-test.js b/test/rackspace/databases/users-test.js index a56abf5f3..4c3f8d57b 100644 --- a/test/rackspace/databases/users-test.js +++ b/test/rackspace/databases/users-test.js @@ -11,7 +11,7 @@ var should = require('should'), hock = require('hock'), http = require('http'), helpers = require('../../helpers'), - User = require('../../../lib/pkgcloud/rackspace/database/user').User, + User = require('../../../lib/pkgcloud/openstack/database/user').User, mock = !!process.env.MOCK; describe('pkgcloud/rackspace/databases/users', function () { @@ -42,7 +42,7 @@ describe('pkgcloud/rackspace/databases/users', function () { } ], done); }); - + it('the createUser() method should respond correctly', function (done) { if (mock) { authHockInstance From ee563df0141783cb149601dd7b9964a11cbba659 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 22 Oct 2014 14:35:58 -0700 Subject: [PATCH 196/460] Added support for HP provider --- lib/pkgcloud/hp/database/client/index.js | 62 ++++++++++++++++++++++++ lib/pkgcloud/hp/database/index.js | 16 ++++++ 2 files changed, 78 insertions(+) create mode 100644 lib/pkgcloud/hp/database/client/index.js create mode 100644 lib/pkgcloud/hp/database/index.js diff --git a/lib/pkgcloud/hp/database/client/index.js b/lib/pkgcloud/hp/database/client/index.js new file mode 100644 index 000000000..617476f78 --- /dev/null +++ b/lib/pkgcloud/hp/database/client/index.js @@ -0,0 +1,62 @@ +/* + * client.js: Database client for Rackspace Cloud Databases + * + * (C) 2011 Nodejitsu Inc. + * + */ + +var util = require('util'), + urlJoin = require('url-join'), + request = require('request'), + rackspace = require('../../client'), + auth = require('../../../common/auth.js'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + rackspace.Client.call(this, options); + + this.before.push(auth.accountId); + + _.extend(this, require('../../../openstack/database/client/flavors')); + _.extend(this, require('../../../openstack/database/client/instances')); + _.extend(this, require('../../../openstack/database/client/databases')); + _.extend(this, require('../../../openstack/database/client/users')); + + this.serviceType = 'rax:database'; +}; + +util.inherits(Client, rackspace.Client); + +Client.prototype._getUrl = function (options) { + options = options || {}; + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); + +}; + +// +// Gets the version of the OpenStack Compute API we are running against +// Parameters: callback +// +Client.prototype.getVersion = function getVersion(callback) { + var self = this; + + this.auth(function (err) { + if (err) { + return callback(err); + } + + self._request({ + uri: self._getUrl('/').replace('/v1.0/' + self._identity.token.tenant.id + '/', '') + }, function (err, body) { + if (err) { + return callback(err); + } + return callback(null, + ((typeof body === 'object') ? body.versions : JSON.parse(body).versions)); + }); + }); +}; diff --git a/lib/pkgcloud/hp/database/index.js b/lib/pkgcloud/hp/database/index.js new file mode 100644 index 000000000..f09c0df3f --- /dev/null +++ b/lib/pkgcloud/hp/database/index.js @@ -0,0 +1,16 @@ +/* + * index.js: Top-level include for the Rackspace database module + * + * (C) 2011 Nodejitsu Inc. + * + */ + +exports.Client = require('./client').Client; +exports.Flavor = require('../../openstack/database/flavor').Flavor; +exports.Instance = require('../../openstack/database/instance').Instance; +exports.Database = require('../../openstack/database/database').Database; +exports.User = require('../../openstack/database/user').User; + +exports.createClient = function createClient(options) { + return new exports.Client(options); +}; From 3e9cb8c6af1dbdb0b8772d5d5b1ab900e89f4e3c Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 22 Oct 2014 14:39:19 -0700 Subject: [PATCH 197/460] Moving rackspace db tests to common --- test/{rackspace => common}/databases/databases-test.js | 0 test/{rackspace => common}/databases/errors-test.js | 0 test/{rackspace => common}/databases/flavor-test.js | 0 test/{rackspace => common}/databases/instances-test.js | 0 test/{rackspace => common}/databases/users-test.js | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename test/{rackspace => common}/databases/databases-test.js (100%) rename test/{rackspace => common}/databases/errors-test.js (100%) rename test/{rackspace => common}/databases/flavor-test.js (100%) rename test/{rackspace => common}/databases/instances-test.js (100%) rename test/{rackspace => common}/databases/users-test.js (100%) diff --git a/test/rackspace/databases/databases-test.js b/test/common/databases/databases-test.js similarity index 100% rename from test/rackspace/databases/databases-test.js rename to test/common/databases/databases-test.js diff --git a/test/rackspace/databases/errors-test.js b/test/common/databases/errors-test.js similarity index 100% rename from test/rackspace/databases/errors-test.js rename to test/common/databases/errors-test.js diff --git a/test/rackspace/databases/flavor-test.js b/test/common/databases/flavor-test.js similarity index 100% rename from test/rackspace/databases/flavor-test.js rename to test/common/databases/flavor-test.js diff --git a/test/rackspace/databases/instances-test.js b/test/common/databases/instances-test.js similarity index 100% rename from test/rackspace/databases/instances-test.js rename to test/common/databases/instances-test.js diff --git a/test/rackspace/databases/users-test.js b/test/common/databases/users-test.js similarity index 100% rename from test/rackspace/databases/users-test.js rename to test/common/databases/users-test.js From 427e2caff738c8cb76b2417e909ed7b5d5114410 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 22 Oct 2014 14:52:01 -0700 Subject: [PATCH 198/460] Fixed HP & Openstack db providers, added tests --- lib/pkgcloud/hp/database/client/index.js | 8 +-- lib/pkgcloud/hp/index.js | 1 + .../openstack/database/client/index.js | 62 +++++++++++++++++++ lib/pkgcloud/openstack/database/index.js | 16 +++++ lib/pkgcloud/openstack/index.js | 1 + test/common/databases/users-test.js | 12 ++-- 6 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 lib/pkgcloud/openstack/database/client/index.js create mode 100644 lib/pkgcloud/openstack/database/index.js diff --git a/lib/pkgcloud/hp/database/client/index.js b/lib/pkgcloud/hp/database/client/index.js index 617476f78..29fb8b621 100644 --- a/lib/pkgcloud/hp/database/client/index.js +++ b/lib/pkgcloud/hp/database/client/index.js @@ -8,12 +8,12 @@ var util = require('util'), urlJoin = require('url-join'), request = require('request'), - rackspace = require('../../client'), + hp = require('../../client'), auth = require('../../../common/auth.js'), _ = require('underscore'); var Client = exports.Client = function (options) { - rackspace.Client.call(this, options); + hp.Client.call(this, options); this.before.push(auth.accountId); @@ -22,10 +22,10 @@ var Client = exports.Client = function (options) { _.extend(this, require('../../../openstack/database/client/databases')); _.extend(this, require('../../../openstack/database/client/users')); - this.serviceType = 'rax:database'; + this.serviceType = 'database'; }; -util.inherits(Client, rackspace.Client); +util.inherits(Client, hp.Client); Client.prototype._getUrl = function (options) { options = options || {}; diff --git a/lib/pkgcloud/hp/index.js b/lib/pkgcloud/hp/index.js index fd0c7677f..f725ea2df 100644 --- a/lib/pkgcloud/hp/index.js +++ b/lib/pkgcloud/hp/index.js @@ -9,3 +9,4 @@ exports.storage = require('./storage'); exports.compute = require('./compute'); exports.network = require('./network'); +exports.database = require('./database'); diff --git a/lib/pkgcloud/openstack/database/client/index.js b/lib/pkgcloud/openstack/database/client/index.js new file mode 100644 index 000000000..6194c8d88 --- /dev/null +++ b/lib/pkgcloud/openstack/database/client/index.js @@ -0,0 +1,62 @@ +/* + * client.js: Database client for Rackspace Cloud Databases + * + * (C) 2011 Nodejitsu Inc. + * + */ + +var util = require('util'), + urlJoin = require('url-join'), + request = require('request'), + rackspace = require('../../client'), + auth = require('../../../common/auth.js'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + rackspace.Client.call(this, options); + + this.before.push(auth.accountId); + + _.extend(this, require('../flavors')); + _.extend(this, require('../instances')); + _.extend(this, require('../databases')); + _.extend(this, require('../users')); + + this.serviceType = 'database'; +}; + +util.inherits(Client, rackspace.Client); + +Client.prototype._getUrl = function (options) { + options = options || {}; + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); + +}; + +// +// Gets the version of the OpenStack Compute API we are running against +// Parameters: callback +// +Client.prototype.getVersion = function getVersion(callback) { + var self = this; + + this.auth(function (err) { + if (err) { + return callback(err); + } + + self._request({ + uri: self._getUrl('/').replace('/v1.0/' + self._identity.token.tenant.id + '/', '') + }, function (err, body) { + if (err) { + return callback(err); + } + return callback(null, + ((typeof body === 'object') ? body.versions : JSON.parse(body).versions)); + }); + }); +}; diff --git a/lib/pkgcloud/openstack/database/index.js b/lib/pkgcloud/openstack/database/index.js new file mode 100644 index 000000000..995030f48 --- /dev/null +++ b/lib/pkgcloud/openstack/database/index.js @@ -0,0 +1,16 @@ +/* + * index.js: Top-level include for the Rackspace database module + * + * (C) 2011 Nodejitsu Inc. + * + */ + +exports.Client = require('./client').Client; +exports.Flavor = require('./flavor').Flavor; +exports.Instance = require('./instance').Instance; +exports.Database = require('./database').Database; +exports.User = require('./user').User; + +exports.createClient = function createClient(options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index fdfc6bb27..5dae155ca 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -10,3 +10,4 @@ exports.identity = require('./identity'); exports.orchestration = require('./orchestration'); exports.network = require('./network'); exports.storage = require('./storage'); +exports.database = require('./database'); diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index 4c3f8d57b..ee6043f37 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -12,16 +12,19 @@ var should = require('should'), http = require('http'), helpers = require('../../helpers'), User = require('../../../lib/pkgcloud/openstack/database/user').User, + providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; - -describe('pkgcloud/rackspace/databases/users', function () { +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].database; +}).forEach(function (provider) { +describe('pkgcloud/['+provider+']/databases/users', function () { var testContext = {}, client, authHockInstance, hockInstance, authServer, server; - describe('The pkgcloud Rackspace Database client', function () { + describe('The pkgcloud '+provider+' Database client', function () { before(function (done) { - client = helpers.createClient('rackspace', 'database'); + client = helpers.createClient(provider, 'database'); if (!mock) { return done(); @@ -483,3 +486,4 @@ describe('pkgcloud/rackspace/databases/users', function () { }); }); }); +}); From a62acd068e6a9fee9287ceb8554afaeb05649d92 Mon Sep 17 00:00:00 2001 From: jholthusen Date: Thu, 23 Oct 2014 14:22:20 +0200 Subject: [PATCH 199/460] Update getting-started-compute.md Stumbled across this while trying to get DevStack working with pkgcloud .... maybe it helps... people seldom complain about slight issues in the document... Made the few amendments (missing region argument, changed flavor and image name) I needed to do to get DevStack to run... not entirely sure if it also applies to full OpenStack (lack of iron on my part ;-) ) --- docs/providers/openstack/getting-started-compute.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/providers/openstack/getting-started-compute.md b/docs/providers/openstack/getting-started-compute.md index d947ee178..31815afe1 100644 --- a/docs/providers/openstack/getting-started-compute.md +++ b/docs/providers/openstack/getting-started-compute.md @@ -17,6 +17,7 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). In this example, we're going to create a Openstack compute client, create two servers, and then output their details to the command line. *Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* +*Note: For DevStack, change AuthUrl to http://* ```Javascript var pkgcloud = require('pkgcloud'), @@ -27,6 +28,7 @@ var client = pkgcloud.compute.createClient({ provider: 'openstack', username: 'your-user-name', password: 'your-password', + region: 'RegionOne' authUrl: 'https://your-identity-service' }); @@ -45,10 +47,10 @@ client.getFlavors(function (err, flavors) { } // Pick a 512MB instance flavor - var flavor = _.findWhere(flavors, { name: '512MB Standard Instance' }); + var flavor = _.findWhere(flavors, { name: 'm1.tiny' }); // Pick an image based on Ubuntu 12.04 - var image = _.findWhere(images, { name: 'Ubuntu 12.04 LTS (Precise Pangolin)' }); + var image = _.findWhere(images, { name: 'cirros-0.3.2-x86_64-uec' }); // Create our first server client.createServer({ @@ -93,4 +95,4 @@ function handleServerResponse(err, server) { ' in order to not accrue billing charges'); }); } -``` \ No newline at end of file +``` From d08d548fe8f54687273938304c1e5cc5d01930fe Mon Sep 17 00:00:00 2001 From: jholthusen Date: Thu, 23 Oct 2014 15:39:45 +0200 Subject: [PATCH 200/460] Update getting-started-compute.md Also updated the status that is being checked.... --- docs/providers/openstack/getting-started-compute.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/providers/openstack/getting-started-compute.md b/docs/providers/openstack/getting-started-compute.md index 31815afe1..a2be6d71e 100644 --- a/docs/providers/openstack/getting-started-compute.md +++ b/docs/providers/openstack/getting-started-compute.md @@ -79,8 +79,8 @@ function handleServerResponse(err, server) { console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); - // Wait for status: ACTIVE on our server, and then callback - server.setWait({ status: 'ACTIVE' }, 5000, function (err) { + // Wait for status: RUNNING on our server, and then callback + server.setWait({ status: 'RUNNING' }, 5000, function (err) { if (err) { console.dir(err); return; From 2ca69d4b421534a30f71df39f6bef0d5dc7f4da6 Mon Sep 17 00:00:00 2001 From: jholthusen Date: Fri, 24 Oct 2014 11:08:08 +0200 Subject: [PATCH 201/460] Update getting-started-compute.md Extended my comments and the normalised server status. On Openstack, server.STATUS.active is not available... In Horizon, this is the Instance Power State, as opposed to the instance status, which is stored in server.openstack.OS-EXT-STS:vm_state , as far as I can figure it out... I have to admit, I am just starting to look into this (both OpenStack and pkgcloud), so if there are any obvious 'DOH's in what I am writing, be patient ;-) One of my ideas at at the moment is to write a "set up your DevStack base config automatically" set of scripts, will share if I manage to create anything useful there... --- docs/providers/openstack/getting-started-compute.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/providers/openstack/getting-started-compute.md b/docs/providers/openstack/getting-started-compute.md index a2be6d71e..5aeacc4a7 100644 --- a/docs/providers/openstack/getting-started-compute.md +++ b/docs/providers/openstack/getting-started-compute.md @@ -17,7 +17,7 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). In this example, we're going to create a Openstack compute client, create two servers, and then output their details to the command line. *Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* -*Note: For DevStack, change AuthUrl to http://* +*Note: For DevStack, change AuthUrl to http://:5000* ```Javascript var pkgcloud = require('pkgcloud'), @@ -28,7 +28,7 @@ var client = pkgcloud.compute.createClient({ provider: 'openstack', username: 'your-user-name', password: 'your-password', - region: 'RegionOne' + region: 'RegionOne' //default for DevStack, might be different on other OpenStack distributions authUrl: 'https://your-identity-service' }); @@ -50,7 +50,7 @@ client.getFlavors(function (err, flavors) { var flavor = _.findWhere(flavors, { name: 'm1.tiny' }); // Pick an image based on Ubuntu 12.04 - var image = _.findWhere(images, { name: 'cirros-0.3.2-x86_64-uec' }); + var image = _.findWhere(images, { name: 'cirros-0.3.2-x86_64-uec' }); // Check if this version is correct // Create our first server client.createServer({ @@ -80,7 +80,7 @@ function handleServerResponse(err, server) { console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); // Wait for status: RUNNING on our server, and then callback - server.setWait({ status: 'RUNNING' }, 5000, function (err) { + server.setWait({ status: server.STATUS.running }, 5000, function (err) { if (err) { console.dir(err); return; From 64baa1f6768445baf3a8973dad7e176d79b2b2a2 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 09:35:40 -0700 Subject: [PATCH 202/460] Added tests for OpenStack and HP database providers --- .../openstack/database/client/index.js | 8 +- test/common/databases/users-test.js | 698 ++++++++++++------ test/fixtures/hp/databaseInstances.json | 145 ++++ test/fixtures/hp/databaseUsers.json | 12 + test/fixtures/hp/realToken.json | 12 + .../fixtures/openstack/databaseInstances.json | 145 ++++ test/fixtures/openstack/databaseUsers.json | 12 + test/fixtures/openstack/realToken.json | 24 +- test/rackspace/databases/user-limit-test.js | 149 ++++ 9 files changed, 981 insertions(+), 224 deletions(-) create mode 100644 test/fixtures/hp/databaseInstances.json create mode 100644 test/fixtures/hp/databaseUsers.json create mode 100644 test/fixtures/openstack/databaseInstances.json create mode 100644 test/fixtures/openstack/databaseUsers.json create mode 100644 test/rackspace/databases/user-limit-test.js diff --git a/lib/pkgcloud/openstack/database/client/index.js b/lib/pkgcloud/openstack/database/client/index.js index 6194c8d88..0fed0ba4f 100644 --- a/lib/pkgcloud/openstack/database/client/index.js +++ b/lib/pkgcloud/openstack/database/client/index.js @@ -17,10 +17,10 @@ var Client = exports.Client = function (options) { this.before.push(auth.accountId); - _.extend(this, require('../flavors')); - _.extend(this, require('../instances')); - _.extend(this, require('../databases')); - _.extend(this, require('../users')); + _.extend(this, require('./flavors')); + _.extend(this, require('./instances')); + _.extend(this, require('./databases')); + _.extend(this, require('./users')); this.serviceType = 'database'; }; diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index ee6043f37..9a36028b6 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -1,5 +1,5 @@ /* - * users-test.js: Tests for Rackspace Cloud Database users within an instace + * users-test.js: Tests for Cloud Database users within an instace * * (C) 2010 Nodejitsu Inc. * MIT LICENSE @@ -15,7 +15,8 @@ var should = require('should'), providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].database; + return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; + // return provider === 'openstack'; }).forEach(function (provider) { describe('pkgcloud/['+provider+']/databases/users', function () { var testContext = {}, @@ -48,30 +49,8 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('the createUser() method should respond correctly', function (done) { if (mock) { - authHockInstance - .post('/v2.0/tokens', { - auth: { - 'RAX-KSKEY:apiKeyCredentials': { - username: 'MOCK-USERNAME', - apiKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, helpers.getRackspaceAuthResponse()); - - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTest', - password: 'joepasswd', - databases: [ { name: 'TestDatabase' } ] - } - ] - }) - .reply(202); + setupAuthenticationMock(authHockInstance, hockInstance, provider); + setupCreateUserMock(authHockInstance, hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -94,21 +73,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('the createUser() method should work with databases argument', function (done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTest', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); + setupCreateUserMock(authHockInstance, hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -132,33 +97,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('create an other user for test pagination should response correctly', function (done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestTwo', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestThree', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); + setupCreateAnotherUserMock(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -187,28 +126,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('create multiple users in one request should response correctly', function (done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestFour', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - }, - { - name: 'joeTestFive', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); + setupCreateMultiplsUsersMock(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -238,9 +156,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('create users with questionable characters should respond with error', function (done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); + setupCreateUsersWithRestrictedCharacters(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -261,11 +177,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('the getUsers() method should get the list of users', function (done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); + setupGetUsersMock(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -282,106 +194,11 @@ describe('pkgcloud/['+provider+']/databases/users', function () { }); }); - describe('the getUsers() method', function () { - - var err, list, offset; - - before(function (done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') - .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance, limit: 1 }, function (e, l, o) { - err = e; - list = l; - offset = o; - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with limit should respond with one element', function () { - should.not.exist(err); - should.exist(list); - list.should.have.length(1); - }); - - it('with limitshould pass as third argument the offset mark', function () { - should.exist(offset); - testContext.marker = offset; - }); - - it('with offset should respond less quantity', function (done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?marker=joeTest') - .reply(200, { - users: [ - { name: 'joeTestTwo', databases: []}, - { name: 'joeTestThree', databases: []} - ] - }); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance, offset: testContext.marker }, function (err, list, offset) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.should.have.length(2); - should.not.exist(offset); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with limit and offset should responsd with just result with more next points', function(done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1&marker=joeTest') - .reply(200, helpers.loadFixture('rackspace/databaseUsersLimitOffset.json')); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ - instance: instance, - limit: 1, - offset:testContext.marker }, function(err, list, offset) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.should.have.length(1); - should.exist(offset); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - describe('the destroyUsers() method', function() { it('should respond correctly', function(done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') - .reply(202); + setupDestroyUsersMock(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -398,11 +215,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('should destroy the user used for pagination', function(done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') - .reply(202); + setupDestroyUsersMockWithPagination(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -420,16 +233,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('the enableRoot() method should respond correctly', function(done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { - user: { - password: 'dbba235b-d078-42ec-b992-dec1464c49cc', - name: 'root' - } - }); + setupEnableRootMock(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -451,11 +255,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { it('the enableRoot() method should respond correctly', function (done) { if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { rootEnabled: true }); + setupEnableRootMockWithStatus(hockInstance, provider); } helpers.selectInstance(client, function (instance) { @@ -487,3 +287,473 @@ describe('pkgcloud/['+provider+']/databases/users', function () { }); }); }); + +function setupAuthenticationMock (authHockInstance, hockInstance, provider) { + if (provider === 'rackspace') { + authHockInstance + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + } + else if (provider === 'openstack') { + authHockInstance + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + } + else if (provider === 'hp') { + authHockInstance.post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + else if (provider === 'openstack') { + authHockInstance.post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + } + else { + throw new Error('not supported'); + } +} + +function setupCreateUserMock(authHockInstance, hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTest', + password: 'joepasswd', + databases: [ { name: 'TestDatabase' } ] + } + ] + }) + .reply(202); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTest', + password: 'joepasswd', + databases: [ { name: 'TestDatabase' } ] + } + ] + }) + .reply(202); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTest', + password: 'joepasswd', + databases: [ { name: 'TestDatabase' } ] + } + ] + }) + .reply(202); + } + else { + throw new Error('not supported'); + } +} + +function setupCreateAnotherUserMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestTwo', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestThree', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestTwo', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestThree', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestTwo', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestThree', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else { + throw new Error('not supported'); + } +} + +function setupCreateMultiplsUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else { + throw new Error('not supported'); + } +} + +function setupCreateUsersWithRestrictedCharacters(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')); + } + else { + throw new Error('not supported'); + } +} + +function setupGetUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('openstack/databaseUsers.json')); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('hp/databaseUsers.json')); + } + else { + throw new Error('not supported'); + } + +} + +function setupEnableRootMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' + } + }); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' + } + }); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' + } + }); + } +} + +function setupEnableRootMockWithStatus(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } +} + +function setupDestroyUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } +} + +function setupDestroyUsersMockWithPagination(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); + } +} diff --git a/test/fixtures/hp/databaseInstances.json b/test/fixtures/hp/databaseInstances.json new file mode 100644 index 000000000..b37d94731 --- /dev/null +++ b/test/fixtures/hp/databaseInstances.json @@ -0,0 +1,145 @@ +{ + "instances": [ + { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "55041e91-98ab-4cd5-8148-f3b3978b3262" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904" + }, { + "status": "BUILD", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/91c21563-74d2-4b8a-9f8f-871e61714446", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/91c21563-74d2-4b8a-9f8f-871e61714446", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "91c21563-74d2-4b8a-9f8f-871e61714446" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/c98bf7db-bfa2-4d88-9469-c0a458a99e86", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/c98bf7db-bfa2-4d88-9469-c0a458a99e86", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "2", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/2", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ] + }, + "id": "c98bf7db-bfa2-4d88-9469-c0a458a99e86" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/databaseUsers.json b/test/fixtures/hp/databaseUsers.json new file mode 100644 index 000000000..5620bcf4e --- /dev/null +++ b/test/fixtures/hp/databaseUsers.json @@ -0,0 +1,12 @@ +{ + "users": [{ + "name": "joeTest", + "databases": [] + }, { + "name": "joeTestTwo", + "databases": [] + }, { + "name": "jowTestThree", + "databases": [] + }] +} \ No newline at end of file diff --git a/test/fixtures/hp/realToken.json b/test/fixtures/hp/realToken.json index 3683ed292..5e12a6dba 100644 --- a/test/fixtures/hp/realToken.json +++ b/test/fixtures/hp/realToken.json @@ -59,6 +59,18 @@ "endpoints_links": [], "type": "network", "name": "neutron" + },{ + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v1.0/5ACED3DC3AA740ABAA41711243CC6949", + "region": "region-a.geo-1", + "internalURL": "http://10.225.0.8:8774/v1.0/5ACED3DC3AA740ABAA41711243CC6949", + "publicURL": "http://localhost:12345/v1.0/5ACED3DC3AA740ABAA41711243CC6949" + } + ], + "endpoints_links": [], + "type": "database", + "name": "database" }, { "endpoints": [ diff --git a/test/fixtures/openstack/databaseInstances.json b/test/fixtures/openstack/databaseInstances.json new file mode 100644 index 000000000..b37d94731 --- /dev/null +++ b/test/fixtures/openstack/databaseInstances.json @@ -0,0 +1,145 @@ +{ + "instances": [ + { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "55041e91-98ab-4cd5-8148-f3b3978b3262" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904" + }, { + "status": "BUILD", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/91c21563-74d2-4b8a-9f8f-871e61714446", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/91c21563-74d2-4b8a-9f8f-871e61714446", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "91c21563-74d2-4b8a-9f8f-871e61714446" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/c98bf7db-bfa2-4d88-9469-c0a458a99e86", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/c98bf7db-bfa2-4d88-9469-c0a458a99e86", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "2", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/2", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ] + }, + "id": "c98bf7db-bfa2-4d88-9469-c0a458a99e86" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/openstack/databaseUsers.json b/test/fixtures/openstack/databaseUsers.json new file mode 100644 index 000000000..5620bcf4e --- /dev/null +++ b/test/fixtures/openstack/databaseUsers.json @@ -0,0 +1,12 @@ +{ + "users": [{ + "name": "joeTest", + "databases": [] + }, { + "name": "joeTestTwo", + "databases": [] + }, { + "name": "jowTestThree", + "databases": [] + }] +} \ No newline at end of file diff --git a/test/fixtures/openstack/realToken.json b/test/fixtures/openstack/realToken.json index ecbeaa49f..e494bfeb7 100644 --- a/test/fixtures/openstack/realToken.json +++ b/test/fixtures/openstack/realToken.json @@ -31,7 +31,7 @@ "internalURL": "http://10.225.0.8:9292/v1", "publicURL": "http://image.myownendpoint.org:9292/v1" } - ], + ], "endpoints_links": [], "type": "image", "name": "glance" @@ -43,8 +43,8 @@ "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "compute", "name": "nova" }, { @@ -55,10 +55,22 @@ "internalURL": "http://10.225.0.8:8774/v2/72e90ecb69c44d0296072ea39e537041", "publicURL": "http://localhost:12345/v2/72e90ecb69c44d0296072ea39e537041" } - ], - "endpoints_links": [], + ], + "endpoints_links": [], "type": "network", "name": "neutron" + },{ + "endpoints": [ + { + "adminURL": "http://10.225.0.8:8774/v1.0/72e90ecb69c44d0296072ea39e537041", + "region": "Calxeda-AUS1", + "internalURL": "http://10.225.0.8:8774/v1.0/72e90ecb69c44d0296072ea39e537041", + "publicURL": "http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041" + } + ], + "endpoints_links": [], + "type": "database", + "name": "database" }, { "endpoints": [ @@ -104,4 +116,4 @@ "name": "MOCK-USERNAME" } } -} \ No newline at end of file +} diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js new file mode 100644 index 000000000..ec6d5f52c --- /dev/null +++ b/test/rackspace/databases/user-limit-test.js @@ -0,0 +1,149 @@ +/* + * users-limit-test.js: Tests for Cloud Database users within an instace + * + * (C) 2010 Nodejitsu Inc. + * MIT LICENSE + * + */ + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + helpers = require('../../helpers'), + User = require('../../../lib/pkgcloud/openstack/database/user').User, + mock = !!process.env.MOCK; + + describe.skip('pkgcloud/[rackspace]/databases/users/limits', function () { + var testContext = {}, + client, authHockInstance, hockInstance, authServer, + server, err, list, offset; + + before(function (done) { + client = helpers.createClient('rackspace', 'database'); + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + + if (mock) { + setupAuthenticationMock(authHockInstance); + setupGetUsersMock(hockInstance); + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') + .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance, limit: 1 }, function (e, l, o) { + err = e; + list = l; + offset = o; + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with limit should respond with one element', function () { + should.not.exist(err); + should.exist(list); + list.should.have.length(1); + }); + + it('with limitshould pass as third argument the offset mark', function () { + should.exist(offset); + testContext.marker = offset; + }); + + it('with offset should respond less quantity', function (done) { + + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?marker=joeTest') + .reply(200, { + users: [ + { name: 'joeTestTwo', databases: []}, + { name: 'joeTestThree', databases: []} + ] + }); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance, offset: testContext.marker }, function (err, list, offset) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.should.have.length(2); + should.not.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with limit and offset should responsd with just result with more next points', function(done) { + + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1&marker=joeTest') + .reply(200, helpers.loadFixture('rackspace/databaseUsersLimitOffset.json')); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ + instance: instance, + limit: 1, + offset:testContext.marker }, function(err, list, offset) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.should.have.length(1); + should.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + +function setupGetUsersMock(hockInstance) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); +} + +function setupAuthenticationMock (authHockInstance) { + authHockInstance + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); +} From f889c6430faa1dc736418a5cd3af90bbac1ae1e4 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 10:02:15 -0700 Subject: [PATCH 203/460] Added test for database flavors for HP & Openstack providers --- test/common/databases/flavor-test.js | 211 ++++++++++-------- test/fixtures/hp/databaseFlavor1.json | 16 ++ test/fixtures/hp/databaseFlavor2.json | 16 ++ test/fixtures/hp/databaseFlavor3.json | 18 ++ test/fixtures/hp/databaseFlavors.json | 64 ++++++ test/fixtures/hp/databaseFlavorsDetail.json | 68 ++++++ test/fixtures/openstack/databaseFlavor1.json | 16 ++ test/fixtures/openstack/databaseFlavor2.json | 16 ++ test/fixtures/openstack/databaseFlavor3.json | 18 ++ test/fixtures/openstack/databaseFlavors.json | 64 ++++++ .../openstack/databaseFlavorsDetail.json | 68 ++++++ test/helpers/index.js | 65 ++++++ 12 files changed, 549 insertions(+), 91 deletions(-) create mode 100644 test/fixtures/hp/databaseFlavor1.json create mode 100644 test/fixtures/hp/databaseFlavor2.json create mode 100644 test/fixtures/hp/databaseFlavor3.json create mode 100644 test/fixtures/hp/databaseFlavors.json create mode 100644 test/fixtures/hp/databaseFlavorsDetail.json create mode 100644 test/fixtures/openstack/databaseFlavor1.json create mode 100644 test/fixtures/openstack/databaseFlavor2.json create mode 100644 test/fixtures/openstack/databaseFlavor3.json create mode 100644 test/fixtures/openstack/databaseFlavors.json create mode 100644 test/fixtures/openstack/databaseFlavorsDetail.json diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index 50c0a1880..c46e63377 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -11,121 +11,150 @@ var should = require('should'), async = require('async'), helpers = require('../../helpers'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, + providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; -describe('pkgcloud/rackspace/databases/flavors', function () { - var testContext = {}, - client, authHockInstance, hockInstance, server, authServer; +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; +}).forEach(function (provider) { + describe('pkgcloud/rackspace/['+provider+']/flavors', function () { + var testContext = {}, + client, authHockInstance, hockInstance, server, authServer; - describe('The pkgcloud Rackspace Database client', function () { + describe('The pkgcloud '+provider+' Database client', function () { - before(function (done) { - client = helpers.createClient('rackspace', 'database'); + before(function (done) { + client = helpers.createClient(provider, 'database'); - if (!mock) { - return done(); - } + if (!mock) { + return done(); + } - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + function getFlavors(auth, callback) { + if (mock) { + if (auth) { + helpers.setupAuthenticationMock(authHockInstance, provider); + } - function getFlavors(auth, callback) { - if (mock) { - if (auth) { - authHockInstance - .post('/v2.0/tokens', { - auth: { - 'RAX-KSKEY:apiKeyCredentials': { - username: 'MOCK-USERNAME', - apiKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, helpers.getRackspaceAuthResponse()); + setupGetFlavorsMock(hockInstance, provider); } - hockInstance - .get('/v1.0/123456/flavors') - .reply(200, helpers.loadFixture('rackspace/databaseFlavors.json')) + client.getFlavors(callback); } - client.getFlavors(callback); - } - - it('the getFlavors() method should return the list of flavors', function(done) { - getFlavors(true, function (err, flavors) { - should.not.exist(err); - should.exist(flavors); - flavors.should.be.an.Array; - flavors.forEach(function (flavor) { - flavor.should.be.instanceOf(Flavor); + it('the getFlavors() method should return the list of flavors', function(done) { + getFlavors(true, function (err, flavors) { + should.not.exist(err); + should.exist(flavors); + flavors.should.be.an.Array; + flavors.forEach(function (flavor) { + flavor.should.be.instanceOf(Flavor); + }); + + hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); + testContext.flavors = flavors; + done(); }); - - hockInstance && hockInstance.done(); - authHockInstance && authHockInstance.done(); - testContext.flavors = flavors; - done(); }); - }); - it('the getFlavors() method should return the list of flavor with rackspace specific information', function (done) { - getFlavors(false, function (err, flavors) { - should.not.exist(err); - should.exist(flavors); - flavors.should.be.an.Array; - flavors.forEach(function (flavor) { - flavor.ram.should.be.a.Number; - flavor.href.should.be.a.String; + it('the getFlavors() method should return the list of flavor with rackspace specific information', function (done) { + getFlavors(false, function (err, flavors) { + should.not.exist(err); + should.exist(flavors); + flavors.should.be.an.Array; + flavors.forEach(function (flavor) { + flavor.ram.should.be.a.Number; + flavor.href.should.be.a.String; + }); + hockInstance && hockInstance.done(); + done(); }); - hockInstance && hockInstance.done(); - done(); }); - }); - it('the getFlavor() method should return a valid flavor', function(done) { - if (mock) { - hockInstance - .get('/v1.0/123456/flavors/3') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor3.json')); - } + it('the getFlavor() method should return a valid flavor', function(done) { + if (mock) { + setupGetFlavorMock(hockInstance, provider); + } - client.getFlavor(testContext.flavors[2].id, function(err, flavor) { - should.not.exist(err); - should.exist(flavor); - flavor.should.be.instanceOf(Flavor); - flavor.id.should.equal(testContext.flavors[2].id); - hockInstance && hockInstance.done(); - done(); + client.getFlavor(testContext.flavors[2].id, function(err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.instanceOf(Flavor); + flavor.id.should.equal(testContext.flavors[2].id); + hockInstance && hockInstance.done(); + done(); + }); }); - }); - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); + after(function (done) { + if (!mock) { + return done(); } - ], done) + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done) + }); }); }); + + function setupGetFlavorsMock(hockInstance, provider ){ + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors') + .reply(200, helpers.loadFixture('rackspace/databaseFlavors.json')) + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') + .reply(200, helpers.loadFixture('openstack/databaseFlavors.json')) + + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors') + .reply(200, helpers.loadFixture('hp/databaseFlavors.json')) + } + } }); + +function setupGetFlavorMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/3') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor3.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/3') + .reply(200, helpers.loadFixture('openstack/databaseFlavor3.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/3') + .reply(200, helpers.loadFixture('hp/databaseFlavor3.json')); + } +} diff --git a/test/fixtures/hp/databaseFlavor1.json b/test/fixtures/hp/databaseFlavor1.json new file mode 100644 index 000000000..5df3dc30d --- /dev/null +++ b/test/fixtures/hp/databaseFlavor1.json @@ -0,0 +1,16 @@ + { + "flavor": { + "ram": 512, + "id": 1, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/databaseFlavor2.json b/test/fixtures/hp/databaseFlavor2.json new file mode 100644 index 000000000..f44c45b08 --- /dev/null +++ b/test/fixtures/hp/databaseFlavor2.json @@ -0,0 +1,16 @@ +{ + "flavor": { + "ram": 1024, + "id": 2, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/databaseFlavor3.json b/test/fixtures/hp/databaseFlavor3.json new file mode 100644 index 000000000..99eb47471 --- /dev/null +++ b/test/fixtures/hp/databaseFlavor3.json @@ -0,0 +1,18 @@ +{ + "flavor": { + "vcpus": 1, + "ram": 2048, + "id": 3, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/3", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/databaseFlavors.json b/test/fixtures/hp/databaseFlavors.json new file mode 100644 index 000000000..9a4ff3485 --- /dev/null +++ b/test/fixtures/hp/databaseFlavors.json @@ -0,0 +1,64 @@ +{ + "flavors": [ + { + "id": 1, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "ram": 512 + }, + { + "id": 2, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/2", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small", + "ram": 1024 + }, + { + "id": 3, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/3", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium", + "ram": 2048 + }, + { + "id": 4, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/4", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/4", + "rel": "bookmark" + } + ], + "name": "m1.large", + "ram": 4096 + } + ] +} \ No newline at end of file diff --git a/test/fixtures/hp/databaseFlavorsDetail.json b/test/fixtures/hp/databaseFlavorsDetail.json new file mode 100644 index 000000000..6e30a06b7 --- /dev/null +++ b/test/fixtures/hp/databaseFlavorsDetail.json @@ -0,0 +1,68 @@ +{ + "flavors": [ + { + "vcpus": 1, + "ram": 2048, + "id": 3, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/3", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium" + }, + { + "vcpus": 1, + "ram": 4096, + "id": 4, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/4", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/4", + "rel": "bookmark" + } + ], + "name": "m1.large" + }, + { + "vcpus": 1, + "ram": 512, + "id": 1, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny" + }, + { + "vcpus": 1, + "ram": 1024, + "id": 2, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/2", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/openstack/databaseFlavor1.json b/test/fixtures/openstack/databaseFlavor1.json new file mode 100644 index 000000000..5df3dc30d --- /dev/null +++ b/test/fixtures/openstack/databaseFlavor1.json @@ -0,0 +1,16 @@ + { + "flavor": { + "ram": 512, + "id": 1, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny" + } +} \ No newline at end of file diff --git a/test/fixtures/openstack/databaseFlavor2.json b/test/fixtures/openstack/databaseFlavor2.json new file mode 100644 index 000000000..f44c45b08 --- /dev/null +++ b/test/fixtures/openstack/databaseFlavor2.json @@ -0,0 +1,16 @@ +{ + "flavor": { + "ram": 1024, + "id": 2, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small" + } +} \ No newline at end of file diff --git a/test/fixtures/openstack/databaseFlavor3.json b/test/fixtures/openstack/databaseFlavor3.json new file mode 100644 index 000000000..99eb47471 --- /dev/null +++ b/test/fixtures/openstack/databaseFlavor3.json @@ -0,0 +1,18 @@ +{ + "flavor": { + "vcpus": 1, + "ram": 2048, + "id": 3, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/3", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium" + } +} \ No newline at end of file diff --git a/test/fixtures/openstack/databaseFlavors.json b/test/fixtures/openstack/databaseFlavors.json new file mode 100644 index 000000000..9a4ff3485 --- /dev/null +++ b/test/fixtures/openstack/databaseFlavors.json @@ -0,0 +1,64 @@ +{ + "flavors": [ + { + "id": 1, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "ram": 512 + }, + { + "id": 2, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/2", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small", + "ram": 1024 + }, + { + "id": 3, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/3", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium", + "ram": 2048 + }, + { + "id": 4, + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/4", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/4", + "rel": "bookmark" + } + ], + "name": "m1.large", + "ram": 4096 + } + ] +} \ No newline at end of file diff --git a/test/fixtures/openstack/databaseFlavorsDetail.json b/test/fixtures/openstack/databaseFlavorsDetail.json new file mode 100644 index 000000000..6e30a06b7 --- /dev/null +++ b/test/fixtures/openstack/databaseFlavorsDetail.json @@ -0,0 +1,68 @@ +{ + "flavors": [ + { + "vcpus": 1, + "ram": 2048, + "id": 3, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/3", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium" + }, + { + "vcpus": 1, + "ram": 4096, + "id": 4, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/4", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/4", + "rel": "bookmark" + } + ], + "name": "m1.large" + }, + { + "vcpus": 1, + "ram": 512, + "id": 1, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny" + }, + { + "vcpus": 1, + "ram": 1024, + "id": 2, + "links": [ + { + "href": "http://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/2", + "rel": "self" + }, + { + "href": "http://ord.databases.api.rackspacecloud.com/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small" + } + ] +} \ No newline at end of file diff --git a/test/helpers/index.js b/test/helpers/index.js index 7bd33d415..f54a6e1dd 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -196,4 +196,69 @@ helpers._getOpenstackStandardResponse = function(file, time) { return response; } +helpers.setupAuthenticationMock = function (authHockInstance, provider) { + if (provider === 'rackspace') { + authHockInstance + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + } + else if (provider === 'openstack') { + authHockInstance + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + } + else if (provider === 'hp') { + authHockInstance.post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + else { + throw new Error('provider ['+provider+'] not supported'); + } +} + helpers.pkgcloud = pkgcloud; From 85aeeeb161fd9b8e44e88862626fc03108efe309 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 10:19:23 -0700 Subject: [PATCH 204/460] Adding Database client tests for HP & OpenStack --- test/common/databases/databases-test.js | 693 +++++++++++++++--------- 1 file changed, 422 insertions(+), 271 deletions(-) diff --git a/test/common/databases/databases-test.js b/test/common/databases/databases-test.js index c79e87c28..a5e53c93b 100644 --- a/test/common/databases/databases-test.js +++ b/test/common/databases/databases-test.js @@ -11,344 +11,495 @@ var should = require('should'), http = require('http'), async = require('async'), helpers = require('../../helpers'), + providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; -describe('pkgcloud/rackspace/databases/databases', function() { +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; +}).forEach(function (provider) { + describe('pkgcloud/['+provider+']/databases/databases', function() { - var client, testContext = {}, hockInstance, authHockInstance, server, authServer; + var client, testContext = {}, hockInstance, authHockInstance, server, authServer; - describe('The pkgcloud Rackspace Database client', function() { + describe('The pkgcloud '+provider+' Database client', function() { - before(function (done) { - client = helpers.createClient('rackspace', 'database'); + before(function (done) { + client = helpers.createClient(provider, 'database'); - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); + if (!mock) { + return done(); } - ], done); - }); - it('the createDatabases() method should respond correctly', function(done) { - if (mock) { - authHockInstance - .post('/v2.0/tokens', { - auth: { - 'RAX-KSKEY:apiKeyCredentials': { - username: 'MOCK-USERNAME', - apiKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, helpers.getRackspaceAuthResponse()); + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabase' } - ] - }) - .reply(202); - } - - helpers.selectInstance(client, function (instance) { - client.createDatabase({name: 'TestDatabase', instance: instance}, function(err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); }); - }); - it('create another database for pagination test should respond correctly', function (done) { + it('the createDatabases() method should respond correctly', function(done) { + if (mock) { + helpers.setupAuthenticationMock(authHockInstance, provider); + setupCreateDatabasesMock(hockInstance, provider); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseTwo' } - ] - }) - .reply(202); - } - - helpers.selectInstance(client, function (instance) { - client.createDatabase({name: 'TestDatabaseTwo', instance: instance}, function(err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); + helpers.selectInstance(client, function (instance) { + client.createDatabase({name: 'TestDatabase', instance: instance}, function(err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('the create() method should respond correctly', function (done) { + it('create another database for pagination test should respond correctly', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseThree' } - ] - }) - .reply(202); - } - - helpers.selectInstance(client, function (instance) { - client.create({name: 'TestDatabaseThree', instance: instance}, function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); + if (mock) { + setupCreateDatabasesForPaginationMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.createDatabase({name: 'TestDatabaseTwo', instance: instance}, function(err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('the createDatabase() method with no name should get an error for name', function(done) { - client.createDatabase({}, function(err, response) { - should.exist(err); - should.not.exist(response); - err.message.should.equal('options. Name is a required argument'); - done(); - }); - }); + it('the create() method should respond correctly', function (done) { - it('the createDatabase() method with no instance should get an error for instance', function (done) { - client.createDatabase({ name: 'NotCreated' }, function (err, response) { - should.exist(err); - should.not.exist(response); - err.message.should.equal('options. Instance is a required argument'); - done(); - }); - }); + if (mock) { + setupModelCreateDatabasesMock(hockInstance, provider); + } - it('the getDatabases() method should return a list of databases', function (done) { + helpers.selectInstance(client, function (instance) { + client.create({name: 'TestDatabaseThree', instance: instance}, function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); - } - - helpers.selectInstance(client, function (instance) { - client.getDatabases({ instance: instance }, function(err, list) { - should.not.exist(err); - should.exist(list); - list.should.be.an.instanceOf(Array); - list.should.have.length(2); - hockInstance && hockInstance.done(); + it('the createDatabase() method with no name should get an error for name', function(done) { + client.createDatabase({}, function(err, response) { + should.exist(err); + should.not.exist(response); + err.message.should.equal('options. Name is a required argument'); done(); }); }); - }); - - it('the getDatabases() method should return a list of databases with names', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [ - {name: 'TestDatabase'}, - {name: 'TestDatabaseTwo'} - ]}); - } - - helpers.selectInstance(client, function (instance) { - client.getDatabases({ instance: instance }, function (err, list) { - should.not.exist(err); - should.exist(list); - should.exist(list[0]) - list[0].name.should.equal('TestDatabase'); - list[0].name.should.be.a.String; - hockInstance && hockInstance.done(); + it('the createDatabase() method with no instance should get an error for instance', function (done) { + client.createDatabase({ name: 'NotCreated' }, function (err, response) { + should.exist(err); + should.not.exist(response); + err.message.should.equal('options. Instance is a required argument'); done(); }); }); - }); - it('the getDatabases() method with limit should respond one element', function (done) { + it('the getDatabases() method should return a list of databases', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1') - .reply(200, {databases: [ - {name: 'TestDatabase'} - ]}); - } - - helpers.selectInstance(client, function (instance) { - client.getDatabases({ instance: instance, limit: 1 }, function (err, instances) { - should.not.exist(err); - should.exist(instances); - instances.should.be.an.instanceOf(Array); - instances.should.have.length(1); - hockInstance && hockInstance.done(); - done(); + if (mock) { + setupGetDatabasesMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.getDatabases({ instance: instance }, function(err, list) { + should.not.exist(err); + should.exist(list); + list.should.be.an.instanceOf(Array); + list.should.have.length(2); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('the getDatabases() method with limit should pass as third argument the offset mark', function (done) { + it('the getDatabases() method should return a list of databases with names', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1') - .reply(200, helpers.loadFixture('rackspace/databasesLimit.json')); - } - - helpers.selectInstance(client, function (instance) { - client.getDatabases({ instance: instance, limit: 1 }, function (err, instances, offset) { - should.not.exist(err); - should.exist(instances); - should.exist(offset); - offset.should.equal('TestDatabase'); - testContext.marker = offset; - hockInstance && hockInstance.done(); - done(); + if (mock) { + setupGetDatabasesMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.getDatabases({ instance: instance }, function (err, list) { + should.not.exist(err); + should.exist(list); + should.exist(list[0]) + list[0].name.should.equal('TestDatabase'); + list[0].name.should.be.a.String; + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('the getDatabases() method with offset should respond less quantity', function (done) { + it('the getDatabases() method with limit should respond one element', function (done) { + if (provider !== 'rackspace') { + return done(); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?marker=TestDatabase') - .reply(200, { databases: [{ name: 'TestDatabaseTwo '}] }); - } + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1') + .reply(200, {databases: [ + {name: 'TestDatabase'} + ]}); + } - helpers.selectInstance(client, function (instance) { - client.getDatabases({ instance: instance, offset: testContext.marker }, - function(err, instances, offset) { + helpers.selectInstance(client, function (instance) { + client.getDatabases({ instance: instance, limit: 1 }, function (err, instances) { should.not.exist(err); should.exist(instances); + instances.should.be.an.instanceOf(Array); instances.should.have.length(1); - should.not.exist(offset); hockInstance && hockInstance.done(); done(); + }); }); }); - }); - it('the getDatabases() method with limit and offset ' + - 'should respond just one result with no more next points', function (done) { + it('the getDatabases() method with limit should pass as third argument the offset mark', function (done) { + if (provider !== 'rackspace') { + return done(); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1&marker=TestDatabase') - .reply(200, { databases: [{ name: 'TestDatabaseTwo' }] }); - } + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1') + .reply(200, helpers.loadFixture('rackspace/databasesLimit.json')); + } - helpers.selectInstance(client, function (instance) { - client.getDatabases({ instance: instance, limit: 1, offset: testContext.marker }, - function (err, instances, offset) { + helpers.selectInstance(client, function (instance) { + client.getDatabases({ instance: instance, limit: 1 }, function (err, instances, offset) { should.not.exist(err); should.exist(instances); - instances.should.be.an.Array; - instances.should.have.length(1); - should.not.exist(offset); + should.exist(offset); + offset.should.equal('TestDatabase'); + testContext.marker = offset; hockInstance && hockInstance.done(); done(); }); + }); }); - }); - it('the destroyDatabase() method with first db should respond correctly', function (done) { + it('the getDatabases() method with offset should respond less quantity', function (done) { + if (provider !== 'rackspace') { + return done(); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') - .reply(202); - } - - helpers.selectInstance(client, function (instance) { - client.destroyDatabase('TestDatabase', instance, function(err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?marker=TestDatabase') + .reply(200, { databases: [{ name: 'TestDatabaseTwo '}] }); + } + + helpers.selectInstance(client, function (instance) { + client.getDatabases({ instance: instance, offset: testContext.marker }, + function(err, instances, offset) { + should.not.exist(err); + should.exist(instances); + instances.should.have.length(1); + should.not.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('the destroyDatabase() method with last db should respond correctly', function (done) { + it('the getDatabases() method with limit and offset ' + + 'should respond just one result with no more next points', function (done) { + if (provider !== 'rackspace') { + return done(); + } + + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases?limit=1&marker=TestDatabase') + .reply(200, { databases: [{ name: 'TestDatabaseTwo' }] }); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') - .reply(202); - } - - helpers.selectInstance(client, function (instance) { - client.destroyDatabase('TestDatabaseTwo', instance, function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); + helpers.selectInstance(client, function (instance) { + client.getDatabases({ instance: instance, limit: 1, offset: testContext.marker }, + function (err, instances, offset) { + should.not.exist(err); + should.exist(instances); + instances.should.be.an.Array; + instances.should.have.length(1); + should.not.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); + it('the destroyDatabase() method with first db should respond correctly', function (done) { + + if (mock) { + setupDestroyDatabasesMock(hockInstance, provider); } - ], done) - }); + helpers.selectInstance(client, function (instance) { + client.destroyDatabase('TestDatabase', instance, function(err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the destroyDatabase() method with last db should respond correctly', function (done) { + + if (mock) { + setupDestroyLastDatabasesMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.destroyDatabase('TestDatabaseTwo', instance, function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done) + }); + + }); }); }); +function setupCreateDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } +} + +function setupCreateDatabasesForPaginationMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } +} + +function setupModelCreateDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } +} + + + +function setupGetDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } +} + +function setupDestroyDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } +} + +function setupDestroyLastDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } +} From c64645cb87c3c09528dac8c87b5303cbb1fa88d0 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 12:24:48 -0700 Subject: [PATCH 205/460] Adding DBAAS service instance tests for HP & OpenStack provider --- test/common/databases/instances-test.js | 987 +++++++++++------- test/fixtures/hp/databaseInstance.json | 33 + .../hp/databaseInstanceLimitOffset.json | 39 + test/fixtures/hp/databaseInstancesLimit2.json | 67 ++ test/fixtures/openstack/databaseInstance.json | 33 + .../openstack/databaseInstancesLimit2.json | 67 ++ 6 files changed, 839 insertions(+), 387 deletions(-) create mode 100644 test/fixtures/hp/databaseInstance.json create mode 100644 test/fixtures/hp/databaseInstanceLimitOffset.json create mode 100644 test/fixtures/hp/databaseInstancesLimit2.json create mode 100644 test/fixtures/openstack/databaseInstance.json create mode 100644 test/fixtures/openstack/databaseInstancesLimit2.json diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index 5e7daf051..2661dc266 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -11,517 +11,457 @@ var should = require('should'), http = require('http'), async = require('async'), helpers = require('../../helpers'), + providers = require('../../configs/providers.json'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, Instance = require('../../../lib/pkgcloud/openstack/database/instance').Instance, mock = !!process.env.MOCK; +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; +}).forEach(function (provider) { + describe('pkgcloud/['+provider+']/databases/instances', function () { + var testContext = {}, + client, authHockInstance, hockInstance, authServer, server; -describe('pkgcloud/rackspace/databases/instances', function () { - var testContext = {}, - client, authHockInstance, hockInstance, authServer, server; + describe('The pkgcloud '+provider+' Database client', function () { - describe('The pkgcloud Rackspace Database client', function () { + before(function (done) { + client = helpers.createClient(provider, 'database'); - before(function (done) { - client = helpers.createClient('rackspace', 'database'); + if (!mock) { + return done(); + } - if (!mock) { - return done(); - } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); + describe('the create() method', function() { - describe('the create() method', function() { - - var err, instance; - - before(function(done) { - - if (mock) { - authHockInstance - .post('/v2.0/tokens', { - auth: { - 'RAX-KSKEY:apiKeyCredentials': { - username: 'MOCK-USERNAME', - apiKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, helpers.getRackspaceAuthResponse()); - - hockInstance - .get('/v1.0/123456/flavors/1') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) - - .post('/v1.0/123456/instances', { - instance: { - name: 'test-instance', - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], - volume: { - size:1 - } - } - }) - .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + var err, instance; - } - client.getFlavor(1, function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - flavor.should.be.instanceOf(Flavor); + before(function(done) { + helpers.setupAuthenticationMock(authHockInstance, provider); + setupCreateInstanceMock(hockInstance, provider); - client.createInstance({ - name: 'test-instance', - flavor: flavor - }, function(e, i) { - err = e; - instance = i; - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); + client.getFlavor(1, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.instanceOf(Flavor); + + client.createInstance({ + name: 'test-instance', + flavor: flavor + }, function(e, i) { + err = e; + instance = i; + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('should return a valid instance', function() { - should.not.exist(err); - should.exist(instance); - instance.should.be.instanceOf(Instance); - }); + it('should return a valid instance', function() { + should.not.exist(err); + should.exist(instance); + instance.should.be.instanceOf(Instance); + }); - it('should return the same name and flavor used', function() { - should.not.exist(err); - should.exist(instance); - instance.name.should.equal('test-instance'); - should.equal(1, instance.flavor.id); + it('should return the same name and flavor used', function() { + should.not.exist(err); + should.exist(instance); + instance.name.should.equal('test-instance'); + should.equal(1, instance.flavor.id); + }); }); - }); - describe('the getInstances() method', function() { - describe('without options', function() { + describe('the getInstances() method', function() { + describe('without options', function() { - var err, instances, offset + var err, instances, offset - before(function(done) { + before(function(done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - } + if (mock) { + setupGetInstancesMock(hockInstance, provider); + } - client.getInstances(function(e, i, o) { - err = e; - instances = i; - offset = o; - hockInstance && hockInstance.done(); - done(); + client.getInstances(function(e, i, o) { + err = e; + instances = i; + offset = o; + hockInstance && hockInstance.done(); + done(); + }); }); - }); - it('should return the list of instances', function () { - should.not.exist(err); - should.exist(instances); - instances.should.be.an.Array; - instances.length.should.be.above(0); + it('should return the list of instances', function () { + should.not.exist(err); + should.exist(instances); + instances.should.be.an.Array; + instances.length.should.be.above(0); - testContext.instancesQuantity = instances.length; - }); + testContext.instancesQuantity = instances.length; + }); - it('should valid instance each item in the list', function () { - instances.forEach(function (instance) { - instance.should.be.instanceOf(Instance); + it('should valid instance each item in the list', function () { + instances.forEach(function (instance) { + instance.should.be.instanceOf(Instance); + }); }); - }); - it('should response with extra info', function () { + it('should response with extra info', function () { - instances.forEach(function (instance) { - should.exist(instance.id); - instance.links.should.be.an.Array; - instance.flavor.should.be.a.Object; - instance.volume.should.be.a.Object; - instance.volume.size.should.be.a.Number; + instances.forEach(function (instance) { + should.exist(instance.id); + instance.links.should.be.an.Array; + instance.flavor.should.be.a.Object; + instance.volume.should.be.a.Object; + instance.volume.size.should.be.a.Number; + }); }); - }); - it('should have correct flavor', function () { - instances.forEach(function (instance) { - should.exist(instance.flavor.id); - assertLinks(instance.flavor.links); + it('should have correct flavor', function () { + instances.forEach(function (instance) { + should.exist(instance.flavor.id); + assertLinks(instance.flavor.links); + }); }); - }); - it('should have correct links', function () { - instances.forEach(function (instance) { - assertLinks(instance.links); + it('should have correct links', function () { + instances.forEach(function (instance) { + assertLinks(instance.links); + }); }); - }); - it('should have a null offset', function () { - should.not.exist(offset); - }); - }); - - describe('with limit', function () { - var err, instances, offset - - before(function (done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances?limit=2') - .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')) - } - - client.getInstances({ limit: 2 }, function (e, i, o) { - err = e; - instances = i; - offset = o; - hockInstance && hockInstance.done(); - done(); + it('should have a null offset', function () { + should.not.exist(offset); }); }); - it('should respond at least 2 elements', function() { - should.not.exist(err); - should.exist(instances); - instances.should.be.an.Array; - instances.should.have.length(2); - }); + describe('with limit', function () { - it('should pass as third argument the offset mark', function() { - should.exist(offset); - testContext.marker = offset; - }); - }); - }); + var err, instances, offset - describe('the destroyInstance() method', function() { - it('should respond correctly', function(done) { + before(function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202) - } + if (mock) { + setupGetDatabaseInstancesWithLimitMock(hockInstance, provider); + } - helpers.selectInstance(client, function (instance) { - testContext.Instance = instance; - client.destroyInstance(testContext.Instance, function(err, result) { + client.getInstances({ limit: 2 }, function (e, i, o) { + err = e; + instances = i; + offset = o; + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('should respond at least 2 elements', function() { should.not.exist(err); - should.exist(result); - result.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); + should.exist(instances); + instances.should.be.an.Array; + instances.should.have.length(2); + }); + + it('should pass as third argument the offset mark', function() { + should.exist(offset); + testContext.marker = offset; }); }); }); - }); - describe('the getInstance() method', function () { - it('should response with details', function (done) { + describe('the destroyInstance() method', function() { + it('should respond correctly', function(done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(200, helpers.loadFixture('rackspace/databaseInstance.json')) - } + if (mock) { + setupDestroyInstanceMock(hockInstance, provider); + } - client.getInstance(testContext.Instance.id, function (err, instance) { - should.not.exist(err); - should.exist(instance); - instance.should.be.instanceOf(Instance); - instance.id.should.equal(testContext.Instance.id); - hockInstance && hockInstance.done(); - done(); + helpers.selectInstance(client, function (instance) { + testContext.Instance = instance; + client.destroyInstance(testContext.Instance, function(err, result) { + should.not.exist(err); + should.exist(result); + result.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); }); }); - }); - describe('the getInstances() method', function () { - it('with offset should respond less quantity', function (done) { + describe.only('the getInstance() method', function () { + it('should response with details', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262') - .reply(200, helpers.loadFixture('rackspace/databaseInstanceOffset.json')) - } + if (mock) { + setGetInstanceMock(hockInstance, provider); + } - client.getInstances({ offset: testContext.marker }, function (err, instances, offset) { - should.not.exist(err); - should.exist(instances); - instances.should.be.an.Array; - should.ok(instances.length >= 2 - && instances.length < testContext.instancesQuantity); - hockInstance && hockInstance.done(); - done(); + client.getInstance(testContext.Instance.id, function (err, instance) { + should.not.exist(err); + should.exist(instance); + instance.should.be.instanceOf(Instance); + instance.id.should.equal(testContext.Instance.id); + hockInstance && hockInstance.done(); + done(); + }); }); - }); - it('with limit and offset should respond just one result with more next points', function (done) { + describe('the getInstances() method', function () { + it('with offset should respond less quantity', function (done) { + if(provider !== 'rackspace') { + return done(); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances?limit=1&marker=55041e91-98ab-4cd5-8148-f3b3978b3262') - .reply(200, helpers.loadFixture('rackspace/databaseInstanceLimitOffset.json')) - } + if (mock) { + hockInstance + .get('/v1.0/123456/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262') + .reply(200, helpers.loadFixture('rackspace/databaseInstanceOffset.json')) + } - client.getInstances({limit: 1, offset: testContext.marker }, function (err, instances, offset) { - should.not.exist(err); - should.exist(instances); - instances.should.be.an.Array; - should.exist(offset); - instances.should.have.length(1); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); + client.getInstances({ offset: testContext.marker }, function (err, instances, offset) { + should.not.exist(err); + should.exist(instances); + instances.should.be.an.Array; + should.ok(instances.length >= 2 + && instances.length < testContext.instancesQuantity); + hockInstance && hockInstance.done(); + done(); + }); - describe('the setFlavor() method', function () { - it('without instance and flavor parameters should get errors', function (done) { - client.setFlavor(function (err) { - should.exist(err); - done(); }); - }); - it('without flavor parameter should get errors', function (done) { + it('with limit and offset should respond just one result with more next points', function (done) { + if(provider !== 'rackspace') { + return done(); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - } + if (mock) { + hockInstance + .get('/v1.0/123456/instances?limit=1&marker=55041e91-98ab-4cd5-8148-f3b3978b3262') + .reply(200, helpers.loadFixture('rackspace/databaseInstanceLimitOffset.json')) + } - helpers.selectInstance(client, function (instance) { - client.setFlavor(instance, function (err) { - should.exist(err); + client.getInstances({limit: 1, offset: testContext.marker }, function (err, instances, offset) { + should.not.exist(err); + should.exist(instances); + instances.should.be.an.Array; + should.exist(offset); + instances.should.have.length(1); hockInstance && hockInstance.done(); done(); }); }); }); - it('without instance parameter should get errors', function (done) { + describe('the setFlavor() method', function () { + it('without instance and flavor parameters should get errors', function (done) { + client.setFlavor(function (err) { + should.exist(err); + done(); + }); + }); - if (mock) { - hockInstance - .get('/v1.0/123456/flavors/2') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) - } + it('without flavor parameter should get errors', function (done) { - client.getFlavor(2, function (err, flavor) { - should.not.exist(err); - should.exist(flavor); + if (mock) { + setupGetInstancesMock(hockInstance, provider); + } - client.setFlavor(flavor, function(err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); + helpers.selectInstance(client, function (instance) { + client.setFlavor(instance, function (err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('with correct inputs should respond correctly', function (done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/flavors/2') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' - } - }) - .reply(202) - } + it('without instance parameter should get errors', function (done) { - helpers.selectInstance(client, function (instance) { - var newFlavor = (Number(instance.flavor.id) === 4) ? 1 : Number(instance.flavor.id) + 1; - client.getFlavor(newFlavor, function (err, flavor) { + if (mock) { + setGetFlavorsMock(hockInstance, provider); + } + + client.getFlavor(2, function (err, flavor) { should.not.exist(err); should.exist(flavor); - client.setFlavor(instance, flavor, function (err) { - should.not.exist(err); + + client.setFlavor(flavor, function(err) { + should.exist(err); hockInstance && hockInstance.done(); done(); }); }); }); - }); - }); - describe('the setVolumeSize() method', function() { - it('without instance and size parameters should get errors', function(done) { - client.setVolumeSize(function(err) { - should.exist(err); - done(); - }); - }); + it('with correct inputs should respond correctly', function (done) { - it('without size parameter should get errors', function (done) { + if (mock) { + setupSetFlavorMock(hockInstance, provider); + } - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - } + helpers.selectInstance(client, function (instance) { + var newFlavor = (Number(instance.flavor.id) === 4) ? 1 : Number(instance.flavor.id) + 1; + client.getFlavor(newFlavor, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + client.setFlavor(instance, flavor, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + }); - helpers.selectInstance(client, function (instance) { - client.setVolumeSize(instance, function (err) { + describe('the setVolumeSize() method', function() { + it('without instance and size parameters should get errors', function(done) { + client.setVolumeSize(function(err) { should.exist(err); - hockInstance && hockInstance.done(); done(); }); }); - }); - it('without invalid size parameter should get errors', function (done) { + it('without size parameter should get errors', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - } + if (mock) { + setupGetInstancesMock(hockInstance, provider); + } - helpers.selectInstance(client, function (instance) { - client.setVolumeSize(instance, 12, function (err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); + helpers.selectInstance(client, function (instance) { + client.setVolumeSize(instance, function (err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - it('with correct inputs should respond correctly', function (done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - volume :{ - size :2 - } - } - }) - .reply(202) - } + it('without invalid size parameter should get errors', function (done) { - helpers.selectInstance(client, function (instance) { - var newSize = (Number(instance.volume.size) === 8) ? 1 : Number(instance.volume.size) + 1; + if (mock) { + setupGetInstancesMock(hockInstance, provider); + } - client.setVolumeSize(instance, newSize, function (err) { - should.not.exist(err); - hockInstance && hockInstance.done(); - done(); + helpers.selectInstance(client, function (instance) { + client.setVolumeSize(instance, 12, function (err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); }); }); - }); - }); - describe('the create() method with errors', function () { - it('should respond with errors', function (done) { - client.createInstance(function(err) { - should.exist(err); - done(); - }) - }); + it('with correct inputs should respond correctly', function (done) { - it('without flavor should respond with errors', function (done) { - client.createInstance({ name: 'test-without-flavor' }, function (err) { - should.exist(err); - done(); - }) + if (mock) { + setupResizeMock (hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + var newSize = (Number(instance.volume.size) === 8) ? 1 : Number(instance.volume.size) + 1; + + client.setVolumeSize(instance, newSize, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); }); - it('with invalid size should respond with errors', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/flavors/1') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) - } + describe('the create() method with errors', function () { + it('should respond with errors', function (done) { + client.createInstance(function(err) { + should.exist(err); + done(); + }) + }); - client.getFlavor(1, function (err, flavor) { - client.createInstance({ - name: 'test-instance', - flavor: flavor, - size: '1' - }, function(err) { + it('without flavor should respond with errors', function (done) { + client.createInstance({ name: 'test-without-flavor' }, function (err) { should.exist(err); - hockInstance && hockInstance.done(); done(); + }) + }); + + it('with invalid size should respond with errors', function (done) { + if (mock) { + setupGetOneFlavorMock(hockInstance, provider); + } + + client.getFlavor(1, function (err, flavor) { + client.createInstance({ + name: 'test-instance', + flavor: flavor, + size: '1' + }, function(err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); }); }); }); - }); - describe('the restartInstance() method', function () { - it('with no instance should return error', function (done) { - client.restartInstance(function (err) { - should.exist(err); - done(); - }) - }); + describe('the restartInstance() method', function () { + it('with no instance should return error', function (done) { + client.restartInstance(function (err) { + should.exist(err); + done(); + }) + }); - it('with valid instance should restart', function (done) { - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202) - } + it('with valid instance should restart', function (done) { + if (mock) { + setupRestartInstanceMock (hockInstance, provider); + } - helpers.selectInstance(client, function (instance) { - client.restartInstance(instance, function (err) { - should.not.exist(err); - hockInstance && hockInstance.done(); - done(); + helpers.selectInstance(client, function (instance) { + client.restartInstance(instance, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); }); }); }); - }); - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); + after(function (done) { + if (!mock) { + return done(); } - ], done) + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done) + }); }); }); -}); +}); function assertLinks(links) { links.should.be.an.Array; links.forEach(function (link) { @@ -529,3 +469,276 @@ function assertLinks(links) { should.exist(link.rel); }); } + +function setupCreateInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/1') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) + .post('/v1.0/123456/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') + .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') + .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } +} + +function setupGetInstancesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + } +} + +function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances?limit=2') + .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')) + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances?limit=2') + .reply(200, helpers.loadFixture('openstack/databaseInstancesLimit2.json')) + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances?limit=2') + .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')) + } +} + +function setupDestroyInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202) + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202) + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202) + } +} + +function setGetInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('rackspace/databaseInstance.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('openstack/databaseInstance.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('hp/databaseInstance.json')); + } +} + +function setGetFlavorsMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/2') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') + .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')) + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') + .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')) + } +} + +function setupSetFlavorMock(hockInstance, provider) { + if (provider ==='rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/flavors/2') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + } + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') + .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + } + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') + .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + } + }) + .reply(202); + } +} + +function setupResizeMock (hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 + } + } + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 + } + } + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 + } + } + }) + .reply(202); + } +} + +function setupGetOneFlavorMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/1') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') + .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') + .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')); + } +} + +function setupRestartInstanceMock (hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202) + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202) + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202) + } +} diff --git a/test/fixtures/hp/databaseInstance.json b/test/fixtures/hp/databaseInstance.json new file mode 100644 index 000000000..8d8b77bdb --- /dev/null +++ b/test/fixtures/hp/databaseInstance.json @@ -0,0 +1,33 @@ +{ + "instance": { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f" + } +} \ No newline at end of file diff --git a/test/fixtures/hp/databaseInstanceLimitOffset.json b/test/fixtures/hp/databaseInstanceLimitOffset.json new file mode 100644 index 000000000..58c549b4d --- /dev/null +++ b/test/fixtures/hp/databaseInstanceLimitOffset.json @@ -0,0 +1,39 @@ +{ + "instances": [ + { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904" + } + ], + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances?marker=8e31b45f-7bc7-4f3c-ad2d-3ae86e51a904&limit=1", + "rel": "next" + } + ] +} diff --git a/test/fixtures/hp/databaseInstancesLimit2.json b/test/fixtures/hp/databaseInstancesLimit2.json new file mode 100644 index 000000000..ca539781e --- /dev/null +++ b/test/fixtures/hp/databaseInstancesLimit2.json @@ -0,0 +1,67 @@ +{ + "instances": [ + { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "55041e91-98ab-4cd5-8148-f3b3978b3262" + } + ], + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262&limit=2", + "rel": "next" + } + ] +} diff --git a/test/fixtures/openstack/databaseInstance.json b/test/fixtures/openstack/databaseInstance.json new file mode 100644 index 000000000..8d8b77bdb --- /dev/null +++ b/test/fixtures/openstack/databaseInstance.json @@ -0,0 +1,33 @@ +{ + "instance": { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, + { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f" + } +} \ No newline at end of file diff --git a/test/fixtures/openstack/databaseInstancesLimit2.json b/test/fixtures/openstack/databaseInstancesLimit2.json new file mode 100644 index 000000000..c22fca1c9 --- /dev/null +++ b/test/fixtures/openstack/databaseInstancesLimit2.json @@ -0,0 +1,67 @@ +{ + "instances": [ + { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f" + }, { + "status": "ACTIVE", + "name": "test-instance", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/instances/55041e91-98ab-4cd5-8148-f3b3978b3262", + "rel": "bookmark" + } + ], + "volume": { + "size": 1 + }, + "flavor": { + "id": "1", + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/flavors/1", + "rel": "self" + }, { + "href": "https://ord.databases.api.rackspacecloud.com/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "55041e91-98ab-4cd5-8148-f3b3978b3262" + } + ], + "links": [ + { + "href": "https://ord.databases.api.rackspacecloud.com/v1.0/537645/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262&limit=2", + "rel": "next" + } + ] +} \ No newline at end of file From da6b6285925eb6f4ecdd6a87db93b4f665f8feeb Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 12:25:24 -0700 Subject: [PATCH 206/460] All tests passing --- test/common/databases/instances-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index 2661dc266..44daeca26 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -204,7 +204,7 @@ providers.filter(function (provider) { }); }); - describe.only('the getInstance() method', function () { + describe('the getInstance() method', function () { it('should response with details', function (done) { if (mock) { From 7fecb12f9f0bdbd9809db21127473987050fc613 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 12:27:22 -0700 Subject: [PATCH 207/460] Adding client error tests for database --- test/common/databases/errors-test.js | 324 ++++++++++++++------------- test/common/databases/users-test.js | 1 - 2 files changed, 164 insertions(+), 161 deletions(-) diff --git a/test/common/databases/errors-test.js b/test/common/databases/errors-test.js index ea621f56e..786d12456 100644 --- a/test/common/databases/errors-test.js +++ b/test/common/databases/errors-test.js @@ -7,173 +7,177 @@ */ var should = require('should'), - helpers = require('../../helpers'); + helpers = require('../../helpers') + providers = require('../../configs/providers.json'); -describe('pkgcloud/rackspace/databases/errors', function() { - var client = helpers.createClient('rackspace', 'database'); +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; +}).forEach(function (provider) { + describe('pkgcloud/['+provider+']/databases/errors', function() { + var client = helpers.createClient(provider, 'database'); - describe('The pkgcloud Rackspace Database client', function() { - describe('breaking the function', function() { - - it('createInstance() when no options should return an error', function(done) { - client.createInstance(function(err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createInstance() with bad options should return an error', function (done) { - client.createInstance({}, function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createInstance() with no instance options should return an error', function (done) { - client.createInstance({ name: 'shouldGetError' }, function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); + describe('The pkgcloud '+provider+' Database client', function() { + describe('breaking the function', function() { + + it('createInstance() when no options should return an error', function(done) { + client.createInstance(function(err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); }); - }); - - it('destroyInstance() with no instance should return an error', function (done) { - client.destroyInstance(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); + + it('createInstance() with bad options should return an error', function (done) { + client.createInstance({}, function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('createInstance() with no instance options should return an error', function (done) { + client.createInstance({ name: 'shouldGetError' }, function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('destroyInstance() with no instance should return an error', function (done) { + client.destroyInstance(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('getInstance() with no instance should return an error', function (done) { + client.getInstance(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('createDatabase() with no options should return an error', function (done) { + client.createDatabase(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('createDatabase() with no instance should return an error', function (done) { + client.createDatabase({ name: 'shouldGetError' }, function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('getDatabases() with no instance should return an error', function (done) { + client.getDatabases(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('destroyDatabase() with no options should return an error', function (done) { + client.destroyDatabase(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('destroyDatabase() with no instance should return an error', function (done) { + client.destroyDatabase('shouldGetError', function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('createUser() with no options should return an error', function (done) { + client.createUser(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('createUser() with empty objects should return an error', function (done) { + client.createUser({}, function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('createUser() with no db or instance should return an error', function (done) { + client.createUser({ + username: 'testing', + password: 'shouldFail' + }, function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); }); - }); - it('getInstance() with no instance should return an error', function (done) { - client.getInstance(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createDatabase() with no options should return an error', function (done) { - client.createDatabase(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createDatabase() with no instance should return an error', function (done) { - client.createDatabase({ name: 'shouldGetError' }, function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('getDatabases() with no instance should return an error', function (done) { - client.getDatabases(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('destroyDatabase() with no options should return an error', function (done) { - client.destroyDatabase(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('destroyDatabase() with no instance should return an error', function (done) { - client.destroyDatabase('shouldGetError', function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createUser() with no options should return an error', function (done) { - client.createUser(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createUser() with empty objects should return an error', function (done) { - client.createUser({}, function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createUser() with no db or instance should return an error', function (done) { - client.createUser({ - username: 'testing', - password: 'shouldFail' - }, function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('createUser() with no instance should return an error', function (done) { - client.createUser({ - username: 'testing', - password: 'shouldFail', - database: 'none' - }, function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('getUsers() with no instance should return an error', function (done) { - client.getUsers(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('destroyUser() with no instance should return an error', function (done) { - client.destroyUser(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('destroyUser() with no user should return an error', function (done) { - client.destroyUser('shouldGetError', function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('enableRoot() with no instance should return an error', function (done) { - client.enableRoot(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); - }); - }); - - it('rootEnabled() with no instance should return an error', function (done) { - client.rootEnabled(function (err, instance) { - should.exist(err); - should.not.exist(instance); - done(); + it('createUser() with no instance should return an error', function (done) { + client.createUser({ + username: 'testing', + password: 'shouldFail', + database: 'none' + }, function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('getUsers() with no instance should return an error', function (done) { + client.getUsers(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('destroyUser() with no instance should return an error', function (done) { + client.destroyUser(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('destroyUser() with no user should return an error', function (done) { + client.destroyUser('shouldGetError', function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('enableRoot() with no instance should return an error', function (done) { + client.enableRoot(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); + }); + + it('rootEnabled() with no instance should return an error', function (done) { + client.rootEnabled(function (err, instance) { + should.exist(err); + should.not.exist(instance); + done(); + }); }); }); }); }); }); - diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index 9a36028b6..e71a9aabb 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -16,7 +16,6 @@ var should = require('should'), mock = !!process.env.MOCK; providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; - // return provider === 'openstack'; }).forEach(function (provider) { describe('pkgcloud/['+provider+']/databases/users', function () { var testContext = {}, From 5940eb183bd03bb86a6130c1e31ccb2ac6f47d69 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 12:32:56 -0700 Subject: [PATCH 208/460] Documentation for DBAAS Services --- docs/README.md | 2 + docs/providers/hp/README.md | 1 + docs/providers/hp/databases.md | 92 +++++++++++++++++++++++++++ docs/providers/openstack/README.md | 1 + docs/providers/openstack/databases.md | 91 ++++++++++++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100644 docs/providers/hp/databases.md create mode 100644 docs/providers/openstack/databases.md diff --git a/docs/README.md b/docs/README.md index 38c3098d4..31a731233 100644 --- a/docs/README.md +++ b/docs/README.md @@ -29,8 +29,10 @@ If a service does not have at least two providers, it is considered a *beta* int * [Openstack](providers/openstack/storage.md) * [Rackspace](providers/rackspace/storage.md) * **Databases** + * [HP](providers/hp/database.md) * [IrisCouch](providers/iriscouch.md) * [MongoLab](providers/mongolab.md) + * [Openstack](providers/openstack/database.md) * [Rackspace](providers/rackspace/database.md) * [MongoHQ](providers/mongohq.md) * [RedisToGo](providers/redistogo.md) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index e0eae595e..42cb2c04c 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -5,6 +5,7 @@ The HP Helion Cloud provider in pkgcloud supports the following services: * [**Compute**](compute.md) (cloud compute) +* [**Databases**](databases.md) (databases) * [**Network**](network.md) (network) * [**Storage**](storage.md) (object storage) diff --git a/docs/providers/hp/databases.md b/docs/providers/hp/databases.md new file mode 100644 index 000000000..5f3b91353 --- /dev/null +++ b/docs/providers/hp/databases.md @@ -0,0 +1,92 @@ +##Using the HP Helion Database provider + +Creating a client is straight-forward: + +``` js + var rackspace = pkgcloud.database.createClient({ + provider: 'hp', + username: 'your-user-name', + apiKey: 'your-api-key', + region: 'region of identity service', + authUrl: 'https://your-identity-service' + }); +``` + +[More options for creating clients](README.md) + +### Creating a MySQL Database + +The steps for provision a MySQL database from HP Helion cloud databases are: + +1. Choose a flavor (memory RAM size) +2. Create an instance of a database server. +3. When the instance is provisioned, create your database. + +Also you can manage users across your instances and each instance can handle several databases. + +``` js + client.getFlavors(function (err, flavors) { + // + // Look at the availables flavors for your instance + // + console.log(flavors); + + // + // Lets choose the ID 1 for 512MB flavor + // + client.getFlavor(1, function (err, flavor) { + // + // Create the instance for host the databases. + // + client.createInstance({ + name: 'test-instance', + flavor: flavor, + // + // Optional, you can choose the disk size for the instance + // (1 - 8) in GB. Default to 1 + // + size: 3 + // + // Optional, you can give an array of database names for initialize + // when the instace is ready + // + databases: ['first-database', 'second-database'] + }, function (err, instance) { + // + // At this point when the instance is ready we can manage the databases + // + client.createDatabase({ + name: 'test-database', + instance: instance + }, function (err, database) { + // + // Log the result + // + console.log(database); + }); + }); + }) + }); +``` + +### API Methods ### + +#### client.createUser(options, callback) + +Allows the creation of specific users to have access to any database you create. + +Accepts one user object as the `options` argument or an array of user objects. + +A user object is defined as follows: + +```js +{ + username: 'nodejitsu', // required + password: 'foobar', // required + databases: ['first-db, second-db'], // required (Can be either string or array) + instance: instance // required (instance or instanceId) +} +``` + +**note**: If creating multiple users, the instance provided must be the same for +both. diff --git a/docs/providers/openstack/README.md b/docs/providers/openstack/README.md index d372f0f68..4350c9044 100644 --- a/docs/providers/openstack/README.md +++ b/docs/providers/openstack/README.md @@ -3,6 +3,7 @@ The OpenStack provider in pkgcloud supports the following services: * [**Compute**](compute.md) (Nova) +* [**Databases**](databases.md) (databases) * [**Storage**](storage.md) (Swift) * [**Network**](network.md) (Neutron) * [**Orchestration**](orchestration.md) (Heat) diff --git a/docs/providers/openstack/databases.md b/docs/providers/openstack/databases.md new file mode 100644 index 000000000..3669ea150 --- /dev/null +++ b/docs/providers/openstack/databases.md @@ -0,0 +1,91 @@ +##Using the Openstack Database provider + +Creating a client is straight-forward: + +``` js + var rackspace = pkgcloud.database.createClient({ + provider: 'openstack', + username: 'your-user-name', + password: 'your-password', + authUrl: 'https://your-identity-service' + }); +``` + +[More options for creating clients](README.md) + +### Creating a MySQL Database + +The steps for provision a MySQL database from Openstack cloud databases are: + +1. Choose a flavor (memory RAM size) +2. Create an instance of a database server. +3. When the instance is provisioned, create your database. + +Also you can manage users across your instances and each instance can handle several databases. + +``` js + client.getFlavors(function (err, flavors) { + // + // Look at the availables flavors for your instance + // + console.log(flavors); + + // + // Lets choose the ID 1 for 512MB flavor + // + client.getFlavor(1, function (err, flavor) { + // + // Create the instance for host the databases. + // + client.createInstance({ + name: 'test-instance', + flavor: flavor, + // + // Optional, you can choose the disk size for the instance + // (1 - 8) in GB. Default to 1 + // + size: 3 + // + // Optional, you can give an array of database names for initialize + // when the instace is ready + // + databases: ['first-database', 'second-database'] + }, function (err, instance) { + // + // At this point when the instance is ready we can manage the databases + // + client.createDatabase({ + name: 'test-database', + instance: instance + }, function (err, database) { + // + // Log the result + // + console.log(database); + }); + }); + }) + }); +``` + +### API Methods ### + +#### client.createUser(options, callback) + +Allows the creation of specific users to have access to any database you create. + +Accepts one user object as the `options` argument or an array of user objects. + +A user object is defined as follows: + +```js +{ + username: 'nodejitsu', // required + password: 'foobar', // required + databases: ['first-db, second-db'], // required (Can be either string or array) + instance: instance // required (instance or instanceId) +} +``` + +**note**: If creating multiple users, the instance provided must be the same for +both. From c24a50d5089457ac7bf4f34ca0441b0b4c4d0734 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Mon, 27 Oct 2014 13:01:03 -0700 Subject: [PATCH 209/460] Adding key-pairs extension to HP provider --- lib/pkgcloud/hp/compute/client/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 7d2fdfb34..15864e576 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -17,6 +17,7 @@ var Client = exports.Client = function (options) { _.extend(this, require('../../../openstack/compute/client/images')); _.extend(this, require('../../../openstack/compute/client/servers')); _.extend(this, require('../../../openstack/compute/client/extensions/floating-ips')); + _.extend(this, require('../../../openstack/compute/client/extensions/keys')); _.extend(this, require('../../../openstack/compute/client/extensions/security-groups')); _.extend(this, require('../../../openstack/compute/client/extensions/servers')); From 67f67ddd60299257e7fd6826f2ca545e839f0fff Mon Sep 17 00:00:00 2001 From: Song An BUI Date: Wed, 29 Oct 2014 12:05:29 +0100 Subject: [PATCH 210/460] [openstack] [compute] Server toJSON fix [openstack] [compute] fixes Server toJSON mistakenly returning 'flavor' and 'image' instead of 'flavorId' and 'imageId' --- lib/pkgcloud/openstack/compute/server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/compute/server.js b/lib/pkgcloud/openstack/compute/server.js index 1c78ec513..f593310ac 100644 --- a/lib/pkgcloud/openstack/compute/server.js +++ b/lib/pkgcloud/openstack/compute/server.js @@ -136,8 +136,8 @@ Server.prototype.getAddresses = function (type, callback) { Server.prototype.toJSON = function() { return _.pick(this, ['id', 'name', 'status', 'hostId', 'adminPass', 'addresses', - 'links', 'key_name', 'image', 'flavor', 'user_id', 'tenant_id', 'progress', + 'links', 'key_name', 'imageId', 'flavorId', 'user_id', 'tenant_id', 'progress', 'OS-EXT-STS:task_state', 'OS-EXT-STS:vm_state', 'OS-EXT-STS:power_state', 'OS-DCF:diskConfig', 'accessIPv4', 'accessIPv6', 'config_drive', 'metadata', 'created', 'updated']); -}; \ No newline at end of file +}; From d3875a0b7733ff26bda68a08f0b366172a0eb7f2 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 29 Oct 2014 12:29:22 +0000 Subject: [PATCH 211/460] Fixed the openstack storage copy function. --- lib/pkgcloud/openstack/storage/file.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index 32ba5e485..ca9ba5a8a 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -20,14 +20,12 @@ File.prototype.updateMetadata = function (callback) { this.client.updateFileMetadata(this.container, this, callback); }; -// Remark: This method is untested File.prototype.copy = function (container, destination, callback) { var copyOptions = { - method: 'PUT', + method: 'COPY', uri: this.fullPath, headers: { - 'X-COPY-DESTINATION': [container, destination].join('/'), - 'CONTENT-LENGTH': this.bytes + 'DESTINATION': '/' + [container, destination].join('/') } }; From d5e09f70f8dfb375a1e53230a627d7566fab49e1 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 29 Oct 2014 14:33:55 +0000 Subject: [PATCH 212/460] Moved the copy function intoopenstack/storage/client/files.js and proxied it in the file model. --- .../openstack/storage/client/files.js | 32 +++++++++++++++++++ lib/pkgcloud/openstack/storage/file.js | 14 +------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index c52f8c4bb..ac0439557 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -393,4 +393,36 @@ exports.updateFileMetadata = function (container, file, callback) { }); }; +/** + * client.copy + * + * @description copies a file to another location in the container. + * + * @param {String|object} container the container or containerName + * @param object file the file to copy + * @param String destination the destination to copy to + * @param callback + */ +exports.copy = function (container, file, destination, callback) { + var self = this, + containerName = container instanceof self.models.Container ? container.name : container; + + if (!file instanceof base.File) { + throw new Error('Must update an existing file instance'); + } + + var copyOptions = { + method: 'COPY', + uri: file.fullPath, + headers: { + 'DESTINATION': '/' + [containerName, destination].join('/') + } + }; + + this._request(copyOptions, function (err) { + return err + ? callback(err) + : callback(null, true); + }); +} diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index ca9ba5a8a..ce489964b 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -21,19 +21,7 @@ File.prototype.updateMetadata = function (callback) { }; File.prototype.copy = function (container, destination, callback) { - var copyOptions = { - method: 'COPY', - uri: this.fullPath, - headers: { - 'DESTINATION': '/' + [container, destination].join('/') - } - }; - - this.client._request(copyOptions, function (err, body, res) { - return err - ? callback(err) - : callback(null, true); - }); + this.client.copy(container, this, destination, callback) }; File.prototype._setProperties = function (details) { From 109b02d0212655bcba808466352454b4ee6f5b1b Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 29 Oct 2014 17:08:02 +0000 Subject: [PATCH 213/460] copy can now take a string or File for the file and destination parameters. --- lib/pkgcloud/openstack/storage/client/files.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index ac0439557..ee3e1841f 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -399,23 +399,24 @@ exports.updateFileMetadata = function (container, file, callback) { * @description copies a file to another location in the container. * * @param {String|object} container the container or containerName - * @param object file the file to copy - * @param String destination the destination to copy to + * @param {String|object} file the file or fileName to copy + * @param {String|object} destination the destination or destinationName to copy to * @param callback */ exports.copy = function (container, file, destination, callback) { var self = this, containerName = container instanceof self.models.Container ? container.name : container; - if (!file instanceof base.File) { - throw new Error('Must update an existing file instance'); - } - var copyOptions = { method: 'COPY', - uri: file.fullPath, + uri: file instanceof self.models.File ? file.fullPath : this._getUrl({ + container: containerName, + path: file + }), headers: { - 'DESTINATION': '/' + [containerName, destination].join('/') + 'DESTINATION': destination instanceof self.models.File ? + urlJoin('/', destination.container, destination.name) : + urlJoin('/', containerName, destination) } }; From 910fbc9fb352406cb04b7bd4d0c8f3e085b03019 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 29 Oct 2014 19:34:58 -0700 Subject: [PATCH 214/460] Responding to Code Review comments --- lib/pkgcloud/hp/database/index.js | 2 +- lib/pkgcloud/openstack/database/client/index.js | 2 +- lib/pkgcloud/openstack/database/database.js | 2 +- lib/pkgcloud/openstack/database/flavor.js | 2 +- lib/pkgcloud/openstack/database/index.js | 2 +- lib/pkgcloud/openstack/database/instance.js | 4 ++-- lib/pkgcloud/openstack/database/user.js | 2 +- test/common/databases/databases-test.js | 5 ++--- test/common/databases/errors-test.js | 5 ++--- test/common/databases/flavor-test.js | 4 ++-- test/common/databases/instances-test.js | 5 ++--- test/common/databases/users-test.js | 5 ++--- 12 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/pkgcloud/hp/database/index.js b/lib/pkgcloud/hp/database/index.js index f09c0df3f..76233a441 100644 --- a/lib/pkgcloud/hp/database/index.js +++ b/lib/pkgcloud/hp/database/index.js @@ -1,5 +1,5 @@ /* - * index.js: Top-level include for the Rackspace database module + * index.js: Top-level include for the HP database module * * (C) 2011 Nodejitsu Inc. * diff --git a/lib/pkgcloud/openstack/database/client/index.js b/lib/pkgcloud/openstack/database/client/index.js index 0fed0ba4f..75e3ca2af 100644 --- a/lib/pkgcloud/openstack/database/client/index.js +++ b/lib/pkgcloud/openstack/database/client/index.js @@ -1,5 +1,5 @@ /* - * client.js: Database client for Rackspace Cloud Databases + * client.js: Database client for Openstack Trove Databases * * (C) 2011 Nodejitsu Inc. * diff --git a/lib/pkgcloud/openstack/database/database.js b/lib/pkgcloud/openstack/database/database.js index 77d0c290d..c9ccb3e7d 100644 --- a/lib/pkgcloud/openstack/database/database.js +++ b/lib/pkgcloud/openstack/database/database.js @@ -1,5 +1,5 @@ /* - * databases.js: Rackspace Cloud Database within a Instance + * databases.js: Openstack Trove Database within a Instance * * (C) 2011 Nodejitsu Inc. * diff --git a/lib/pkgcloud/openstack/database/flavor.js b/lib/pkgcloud/openstack/database/flavor.js index 8f0ed858a..6f7d46a4d 100644 --- a/lib/pkgcloud/openstack/database/flavor.js +++ b/lib/pkgcloud/openstack/database/flavor.js @@ -1,5 +1,5 @@ /* - * flavor.js: Rackspace Cloud Databases flavor + * flavor.js: Openstack Trove Databases flavor * * (C) 2011 Nodejitsu Inc. * diff --git a/lib/pkgcloud/openstack/database/index.js b/lib/pkgcloud/openstack/database/index.js index 995030f48..8058bbdf3 100644 --- a/lib/pkgcloud/openstack/database/index.js +++ b/lib/pkgcloud/openstack/database/index.js @@ -1,5 +1,5 @@ /* - * index.js: Top-level include for the Rackspace database module + * index.js: Top-level include for the Openstack Trove module * * (C) 2011 Nodejitsu Inc. * diff --git a/lib/pkgcloud/openstack/database/instance.js b/lib/pkgcloud/openstack/database/instance.js index ebd055369..874fa4ba8 100644 --- a/lib/pkgcloud/openstack/database/instance.js +++ b/lib/pkgcloud/openstack/database/instance.js @@ -1,5 +1,5 @@ /* - * instances.js: Rackspace Cloud Database Instance + * instances.js: Openstack Trove Database Instance * * (C) 2011 Nodejitsu Inc. * @@ -62,4 +62,4 @@ Instance.prototype._setProperties = function (details) { this.hostname = details.hostname || this.hostname; this.volume = details.volume || this.volume; this.original = this.rackspace = details; -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/database/user.js b/lib/pkgcloud/openstack/database/user.js index 0b9e9362c..90c769cd5 100644 --- a/lib/pkgcloud/openstack/database/user.js +++ b/lib/pkgcloud/openstack/database/user.js @@ -1,5 +1,5 @@ /* - * user.js: Rackspace Cloud Database User + * user.js: Openstack Trove Database User * * (C) 2011 Nodejitsu Inc. * diff --git a/test/common/databases/databases-test.js b/test/common/databases/databases-test.js index a5e53c93b..eea62c614 100644 --- a/test/common/databases/databases-test.js +++ b/test/common/databases/databases-test.js @@ -1,8 +1,7 @@ /* - * databases-test.js: Tests for Rackspace Cloud Database instances + * databases-test.js: Tests for Openstack Trove Databases within an instances * - * (C) 2010 Nodejitsu Inc. - * MIT LICENSE + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/test/common/databases/errors-test.js b/test/common/databases/errors-test.js index 786d12456..0edffee97 100644 --- a/test/common/databases/errors-test.js +++ b/test/common/databases/errors-test.js @@ -1,8 +1,7 @@ /* -* errors-test.js: Tests for Rackspace Cloud Database instances +* errors-test.js: Tests for Openstack Trove client errors * -* (C) 2010 Nodejitsu Inc. -* MIT LICENSE +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index c46e63377..51bd96836 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -1,7 +1,7 @@ /* -* flavor-test.js: Test for pkgcloud Rackspace database flavor requests +* flavor-test.js: Test for pkgcloud Openstack Trove database flavors. * -* (C) 2010 Nodejitsu Inc. +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index 44daeca26..0187a4bc6 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -1,8 +1,7 @@ /* -* instances-test.js: Tests for Rackspace Cloud Database instances +* instances-test.js: Tests for Openstack Trove instances * -* (C) 2010 Nodejitsu Inc. -* MIT LICENSE +* (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index e71a9aabb..3aa95ab18 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -1,8 +1,7 @@ /* - * users-test.js: Tests for Cloud Database users within an instace + * users-test.js: Tests for Openstack Trove users within an instace * - * (C) 2010 Nodejitsu Inc. - * MIT LICENSE + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ From d14fbd43f6b771bf846fe4b7ceac11dd976955a8 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Wed, 29 Oct 2014 22:09:53 -0700 Subject: [PATCH 215/460] Updating copyright headers --- lib/pkgcloud/hp/database/client/index.js | 4 ++-- lib/pkgcloud/hp/database/index.js | 2 +- lib/pkgcloud/openstack/database/client/databases.js | 2 +- lib/pkgcloud/openstack/database/client/flavors.js | 4 ++-- lib/pkgcloud/openstack/database/client/index.js | 2 +- lib/pkgcloud/openstack/database/client/instances.js | 6 +++--- lib/pkgcloud/openstack/database/client/users.js | 4 ++-- lib/pkgcloud/openstack/database/database.js | 4 ++-- lib/pkgcloud/openstack/database/flavor.js | 2 +- lib/pkgcloud/openstack/database/index.js | 2 +- lib/pkgcloud/openstack/database/instance.js | 2 +- lib/pkgcloud/openstack/database/user.js | 4 ++-- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/pkgcloud/hp/database/client/index.js b/lib/pkgcloud/hp/database/client/index.js index 29fb8b621..1b4fbcf89 100644 --- a/lib/pkgcloud/hp/database/client/index.js +++ b/lib/pkgcloud/hp/database/client/index.js @@ -1,7 +1,7 @@ /* - * client.js: Database client for Rackspace Cloud Databases + * client.js: Database client for HP Trove Databases * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/hp/database/index.js b/lib/pkgcloud/hp/database/index.js index 76233a441..36f968345 100644 --- a/lib/pkgcloud/hp/database/index.js +++ b/lib/pkgcloud/hp/database/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the HP database module * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/client/databases.js b/lib/pkgcloud/openstack/database/client/databases.js index 0fd0027a0..0447a9b2b 100644 --- a/lib/pkgcloud/openstack/database/client/databases.js +++ b/lib/pkgcloud/openstack/database/client/databases.js @@ -1,7 +1,7 @@ /* * database.js: Database methods for working with database within instances from Rackspace Cloud * - * (C) 2012 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/client/flavors.js b/lib/pkgcloud/openstack/database/client/flavors.js index 0e03f91a0..45c4164e7 100644 --- a/lib/pkgcloud/openstack/database/client/flavors.js +++ b/lib/pkgcloud/openstack/database/client/flavors.js @@ -1,7 +1,7 @@ /* - * flavors.js: Implementation of Rackspace Flavors Client. + * flavors.js: Implementation of Openstack Trove Flavors Client. * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/client/index.js b/lib/pkgcloud/openstack/database/client/index.js index 75e3ca2af..bfb54fd7c 100644 --- a/lib/pkgcloud/openstack/database/client/index.js +++ b/lib/pkgcloud/openstack/database/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Database client for Openstack Trove Databases * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/client/instances.js b/lib/pkgcloud/openstack/database/client/instances.js index d132118d5..1ee7d8a59 100644 --- a/lib/pkgcloud/openstack/database/client/instances.js +++ b/lib/pkgcloud/openstack/database/client/instances.js @@ -1,7 +1,7 @@ /* - * instances.js: Instance methods for working with database instances from Rackspace Cloud + * instances.js: Instance methods for working with database instances from Openstack Trove * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ @@ -319,4 +319,4 @@ exports.setVolumeSize = function setVolumeSize(instance, newSize, callback) { message: 'Bad response from resize action.' }), callback); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/database/client/users.js b/lib/pkgcloud/openstack/database/client/users.js index 21c33d17f..7199e0316 100644 --- a/lib/pkgcloud/openstack/database/client/users.js +++ b/lib/pkgcloud/openstack/database/client/users.js @@ -1,7 +1,7 @@ /* - * users.js: Client methods for working with users on database within instances from Rackspace Cloud + * users.js: Client methods for working with users on database within instances from Openstack Trove. * - * (C) 2012 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/database.js b/lib/pkgcloud/openstack/database/database.js index c9ccb3e7d..0de734182 100644 --- a/lib/pkgcloud/openstack/database/database.js +++ b/lib/pkgcloud/openstack/database/database.js @@ -1,7 +1,7 @@ /* * databases.js: Openstack Trove Database within a Instance * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ @@ -24,4 +24,4 @@ Database.prototype._setProperties = function (details) { this.name = details.name; if (details.characterSet) this.characterSet = details.characterSet; if (details.collation) this.collation = details.collation; -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/database/flavor.js b/lib/pkgcloud/openstack/database/flavor.js index 6f7d46a4d..cdfa41e0a 100644 --- a/lib/pkgcloud/openstack/database/flavor.js +++ b/lib/pkgcloud/openstack/database/flavor.js @@ -1,7 +1,7 @@ /* * flavor.js: Openstack Trove Databases flavor * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/index.js b/lib/pkgcloud/openstack/database/index.js index 8058bbdf3..a46b22c79 100644 --- a/lib/pkgcloud/openstack/database/index.js +++ b/lib/pkgcloud/openstack/database/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Openstack Trove module * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/instance.js b/lib/pkgcloud/openstack/database/instance.js index 874fa4ba8..ac09d8397 100644 --- a/lib/pkgcloud/openstack/database/instance.js +++ b/lib/pkgcloud/openstack/database/instance.js @@ -1,7 +1,7 @@ /* * instances.js: Openstack Trove Database Instance * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ diff --git a/lib/pkgcloud/openstack/database/user.js b/lib/pkgcloud/openstack/database/user.js index 90c769cd5..ed35ef82b 100644 --- a/lib/pkgcloud/openstack/database/user.js +++ b/lib/pkgcloud/openstack/database/user.js @@ -1,7 +1,7 @@ /* * user.js: Openstack Trove Database User * - * (C) 2011 Nodejitsu Inc. + * (C) 2014 Hewlett-Packard Development Company, L.P. * */ @@ -21,4 +21,4 @@ User.prototype.refresh = function (callback) { User.prototype._setProperties = function (details) { this.name = details.name; this.password = details.password; -}; \ No newline at end of file +}; From 9100fb01fcc5413f41033500ed5fd6cc5e92a845 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 4 Nov 2014 10:41:45 +0100 Subject: [PATCH 216/460] Updating changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 971cfb456..589225017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.0.3 +* Adding support for Openstack Trove, and adding HP, rackspace providers + ## v1.0.2 * Adding support for OpenStack Cinder From 8ac6e303a9cfd12eb52a4688ac890154f77dddbc Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 4 Nov 2014 10:42:27 +0100 Subject: [PATCH 217/460] 1.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93c78c7d0..50cf1dbb9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.0.2", + "version": "1.0.3", "author": "Nodejitsu Inc ", "contributors": [ { From 859fd2c69d2cb207bf303738ad1a0c3e9c306048 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 13 Nov 2014 06:00:16 -0800 Subject: [PATCH 218/460] Cleaning up compute tests to filter out non-compute clients - Fixes #354 --- test/common/compute/base-test.js | 4 +++- test/common/compute/meta-test.js | 5 ++++- test/common/compute/server-test.js | 5 ++++- test/common/compute/signature-test.js | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 813ce3a75..0d2f117d3 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -28,7 +28,9 @@ var azureOptions = require('../../fixtures/azure/azure-options.json'); azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); -providers.forEach(function(provider) { +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function(provider) { describe('pkgcloud/common/compute/base [' + provider + ']', function () { var client = helpers.createClient(provider, 'compute'), diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index acda64a54..557600146 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -15,11 +15,14 @@ var fs = require('fs'), async = require('async'), _ = require('underscore'), Image = require('../../../lib/pkgcloud/core/compute/image').Image, + pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; var providers=["openstack"]; -providers.forEach(function (provider) { +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function (provider) { describe('pkgcloud/common/compute/server [' + provider + ']', function () { var client = helpers.createClient(provider, 'compute'), diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index ca3880f41..eea9f4054 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -20,13 +20,16 @@ var fs = require('fs'), Image = require('../../../lib/pkgcloud/core/compute/image').Image, Server = require('../../../lib/pkgcloud/core/compute/server').Server, azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'), + pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; var azureOptions = require('../../fixtures/azure/azure-options.json'); azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); -providers.forEach(function (provider) { +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function (provider) { describe('pkgcloud/common/compute/server [' + provider + ']', function () { var client = helpers.createClient(provider, 'compute'), diff --git a/test/common/compute/signature-test.js b/test/common/compute/signature-test.js index 58570f1c9..3b53323f9 100644 --- a/test/common/compute/signature-test.js +++ b/test/common/compute/signature-test.js @@ -7,10 +7,13 @@ var should = require('should'), providers = require('../../configs/providers.json'), + pkgcloud = require('../../../lib/pkgcloud'), helpers = require('../../helpers'), _ = require('underscore'); -providers.forEach(function (provider) { +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function (provider) { describe('pkgcloud/common/compute/signatures [' + provider + ']', function () { From 1c8f108f234ab8ecd334813aefc31bf6cf56dd2a Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Thu, 13 Nov 2014 06:12:47 -0800 Subject: [PATCH 219/460] Adding support to pass ACL through to aws s3 api - Fixes #353 --- lib/pkgcloud/amazon/storage/client/files.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index ae1431337..b94548a33 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -59,6 +59,11 @@ exports.upload = function (options) { s3Options.ContentType = options.contentType; } + // use ACL until a more obvious permission generalization is available + if (options.acl) { + s3Options.ACL = options.acl; + } + var proxyStream = through(), writableStream = self.s3Stream.upload(s3Options); From d7113ffaeb4b9d5a47bd37e62794f262c261adc9 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Mon, 3 Nov 2014 19:56:42 -0500 Subject: [PATCH 220/460] Integrate Google Cloud Storage --- docs/providers/google.md | 17 +++ lib/pkgcloud.js | 1 + lib/pkgcloud/google/client.js | 26 ++++ lib/pkgcloud/google/index.js | 8 ++ .../google/storage/client/containers.js | 123 ++++++++++++++++++ lib/pkgcloud/google/storage/client/files.js | 106 +++++++++++++++ lib/pkgcloud/google/storage/client/index.js | 64 +++++++++ lib/pkgcloud/google/storage/container.js | 26 ++++ lib/pkgcloud/google/storage/file.js | 26 ++++ lib/pkgcloud/google/storage/index.js | 14 ++ package.json | 9 +- test/configs/mock/google.json | 4 + test/google/storage/index.js | 116 +++++++++++++++++ 13 files changed, 536 insertions(+), 4 deletions(-) create mode 100644 docs/providers/google.md create mode 100644 lib/pkgcloud/google/client.js create mode 100644 lib/pkgcloud/google/index.js create mode 100644 lib/pkgcloud/google/storage/client/containers.js create mode 100644 lib/pkgcloud/google/storage/client/files.js create mode 100644 lib/pkgcloud/google/storage/client/index.js create mode 100644 lib/pkgcloud/google/storage/container.js create mode 100644 lib/pkgcloud/google/storage/file.js create mode 100644 lib/pkgcloud/google/storage/index.js create mode 100644 test/configs/mock/google.json create mode 100644 test/google/storage/index.js diff --git a/docs/providers/google.md b/docs/providers/google.md new file mode 100644 index 000000000..1ca01f12f --- /dev/null +++ b/docs/providers/google.md @@ -0,0 +1,17 @@ +## Using the Google Cloud provider in pkgcloud + +The Google Cloud provider in pkgcloud supports the following services: + +* **Storage** Google Cloud Storage (Simple Storage Service) + +### Client Creation + +For all of the Google services, you create a client with the same options: + +```Javascript +var client = require('pkgcloud').storage.createClient({ + provider: 'google', + keyFilename: '/path/to/a/keyfile.json', // path to a JSON key file + projectId: 'eco-channel-658' // project id +}); +``` \ No newline at end of file diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index 5d5776c26..2c34ef4c7 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -22,6 +22,7 @@ var providers = [ 'amazon', 'azure', 'digitalocean', + 'google', 'iriscouch', 'joyent', 'mongohq', diff --git a/lib/pkgcloud/google/client.js b/lib/pkgcloud/google/client.js new file mode 100644 index 000000000..e073406cb --- /dev/null +++ b/lib/pkgcloud/google/client.js @@ -0,0 +1,26 @@ +/* + * client.js: Base client from which all Google Cloud Storage clients inherit from + * + * (C) 2012 Nodejitsu Inc. + * + */ + +var util = require('util'), + gcloud = require('gcloud'), + base = require('../core/base'); + +var Client = exports.Client = function (options) { + var self = this; + + base.Client.call(this, options); + + options = options || {}; + + this.provider = 'google'; + this.config.keyFilename = this.config.keyFilename || options.keyFilename; + this.config.projectId = this.config.projectId || options.projectId; + + this.gcloud = gcloud(this.config); +}; + +util.inherits(Client, base.Client); diff --git a/lib/pkgcloud/google/index.js b/lib/pkgcloud/google/index.js new file mode 100644 index 000000000..81bc6dca1 --- /dev/null +++ b/lib/pkgcloud/google/index.js @@ -0,0 +1,8 @@ +/* + * index.js: Top-level include for the Google Cloud Storage module. + * + * (C) 2012 Nodejitsu Inc. + * + */ + +exports.storage = require('./storage'); diff --git a/lib/pkgcloud/google/storage/client/containers.js b/lib/pkgcloud/google/storage/client/containers.js new file mode 100644 index 000000000..82b9b087a --- /dev/null +++ b/lib/pkgcloud/google/storage/client/containers.js @@ -0,0 +1,123 @@ +/* + * containers.js: Instance methods for working with containers from Google Cloud Storage + * + * (C) 2012 Nodejitsu Inc. + * + */ + +var async = require('async'), + pkgcloud = require('../../../../../lib/pkgcloud'), + storage = pkgcloud.providers.google.storage; + +// +// ### function getContainers (callback) +// #### @callback {function} Continuation to respond to when complete. +// Gets all Google Cloud Storage containers for this instance. +// +exports.getContainers = function (callback) { + var self = this, + containers = []; + + function handleResponse(err, buckets, nextQuery) { + if (err) { + callback(err); + return; + } + + buckets.forEach(function(container) { + containers.push(new (storage.Container)(self, container)); + }); + + if (nextQuery) { + self.storage.getBuckets(nextQuery, handleResponse); + return; + } + + callback(err, containers); + } + + self.storage.getBuckets(handleResponse); +}; + +// +// ### function getContainer (container, callback) +// #### @container {string|storage.Container} Name of the container to return +// #### @callback {function} Continuation to respond to when complete. +// Responds with the Google Cloud Storage bucket for the specified +// `container`. +// +exports.getContainer = function (container, callback) { + var self = this, + bucket = this._getBucket(container); + + bucket.getMetadata(function(err) { + return err + ? callback(err) + : callback(null, new (storage.Container)(self, bucket)); + }); +}; + +// +// ### function createContainer (options, callback) +// #### @options {string|Container} Container to create in Google Cloud Storage +// #### @callback {function} Continuation to respond to when complete. +// Creates the specified `container` in Google Cloud Storage account associated +// with this instance. +// +exports.createContainer = function (options, callback) { + var self = this, + bucketName = this._getBucket(options).name; + + self.storage.createBucket(bucketName, function(err, bucket) { + return err + ? callback(err) + : callback(null, new (storage.Container)(self, bucket)); + }); +}; + +// +// ### function destroyContainer (container, callback) +// #### @container {string} Name of the container to destroy +// #### @callback {function} Continuation to respond to when complete. +// Destroys the specified `container` and all files in it. +// +exports.destroyContainer = function (container, callback) { + var self = this, + bucket = this._getBucket(container); + + function deleteContainer() { + bucket.delete(function(err) { + return err + ? callback(err) + : callback(null, true); + }); + } + + function handleResponse(err, files, nextQuery) { + if (err) { + return callback(err); + } + + if (files.length > 0) { + deleteFiles(files, function() { + if (nextQuery) { + bucket.getFiles(nextQuery, handleResponse); + } else { + deleteContainer(); + } + }); + } else { + deleteContainer(); + } + } + + function deleteFiles(files, next) { + async.forEachLimit(files, 10, destroyFile, next); + } + + function destroyFile(file, next) { + file.delete(next); + } + + bucket.getFiles(handleResponse); +}; diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js new file mode 100644 index 000000000..b2ba76a27 --- /dev/null +++ b/lib/pkgcloud/google/storage/client/files.js @@ -0,0 +1,106 @@ +/* + * files.js: Instance methods for working with files from Google Cloud Storage + * + * (C) 2012 Nodejitsu Inc. + * + */ + +var fs = require('fs'), + util = require('util'), + pkgcloud = require('../../../../../lib/pkgcloud'), + through = require('through2'), + storage = pkgcloud.providers.google.storage, + _ = require('underscore'); + +// +// ### function removeFile (container, file, callback) +// #### @container {string} Name of the container to destroy the file in +// #### @file {string} Name of the file to destroy. +// #### @callback {function} Continuation to respond to when complete. +// Destroys the `file` in the specified `container`. +// +exports.removeFile = function (container, file, callback) { + var bucket = this._getBucket(container), + file = this._getFile(bucket, file); + + file.delete(function(err) { + return err + ? callback(err) + : callback(null, true); + }); +}; + +exports.upload = function (options) { + var self = this, + bucket = this._getBucket(options), + file = this._getFile(bucket, options); + + // check for deprecated calling with a callback + if (typeof arguments[arguments.length - 1] === 'function') { + self.emit('log::warn', 'storage.upload no longer supports calling with a callback'); + } + + var proxyStream = through(), + writableStream = file.createWriteStream(); + + // we need a proxy stream so we can always return a file model + // via the 'success' event + writableStream.on('complete', function(file) { + proxyStream.emit('success', new storage.File(self, file)); + }); + + writableStream.on('error', function(err) { + proxyStream.emit('error', err); + }); + + writableStream.on('data', function(chunk) { + proxyStream.emit('data', chunk); + }); + + proxyStream.pipe(writableStream); + + return proxyStream; +}; + +exports.download = function (options) { + var bucket = this._getBucket(options), + file = this._getFile(bucket, options); + + return file.createReadStream(options); +}; + +exports.getFile = function (container, file, callback) { + var self = this, + bucket = this._getBucket(container), + file = this._getFile(bucket, file); + + file.getMetadata(function(err, data) { + return err + ? callback(err) + : callback(null, new storage.File(self, _.extend({ metadata: data }, { + container: container + }))); + }); +}; + +exports.getFiles = function (container, options, callback) { + var self = this, + bucket = this._getBucket(container); + + if (typeof options === 'function') { + callback = options; + options = {}; + } + else if (!options) { + options = {}; + } + + bucket.getFiles(options, function(err, files, nextQuery) { + return err + ? callback(err) + : callback(null, files.map(function (file) { + file.container = container; + return new storage.File(self, file); + }), nextQuery); + }); +}; diff --git a/lib/pkgcloud/google/storage/client/index.js b/lib/pkgcloud/google/storage/client/index.js new file mode 100644 index 000000000..ce5e66995 --- /dev/null +++ b/lib/pkgcloud/google/storage/client/index.js @@ -0,0 +1,64 @@ +/* + * client.js: Storage client for Google Cloud Storage + * + * (C) 2011 Nodejitsu Inc. + * + */ + +var util = require('util'), + google = require('../../client'), + _ = require('underscore'), + pkgcloud = require('../../../../../lib/pkgcloud'); + +var Client = exports.Client = function (options) { + google.Client.call(this, options); + + _.extend(this, require('./containers')); + _.extend(this, require('./files')); + + this.storage = this.gcloud.storage(options); +}; + +util.inherits(Client, google.Client); + +// +// Return a gcloud Bucket instance, after detecting its name from a variety of +// parameter types. +// +Client.prototype._getBucket = function (container) { + container = container.container || container; + + var containerName, + storage = pkgcloud.providers.google.storage; + + if (typeof container === 'string') { + containerName = container; + } + + if (container instanceof storage.Container) { + containerName = container.name; + } + + return this.storage.bucket(containerName || container); +}; + +// +// Return a gcloud File instance, after detecting its name from a variety of +// parameter types. +// +Client.prototype._getFile = function (bucket, file) { + file = file.file || file; + + var fileName, + storage = pkgcloud.providers.google.storage; + + if (typeof file === 'string') { + fileName = file; + } + + if (file instanceof storage.File) { + fileName = file.name; + } + + return bucket.file(fileName || file); +}; diff --git a/lib/pkgcloud/google/storage/container.js b/lib/pkgcloud/google/storage/container.js new file mode 100644 index 000000000..749be4ef9 --- /dev/null +++ b/lib/pkgcloud/google/storage/container.js @@ -0,0 +1,26 @@ +/* + * container.js: Google Cloud Storage Bucket + * + * (C) 2012 Nodejitsu Inc. + * + */ + +var util = require('util'), + base = require('../../core/storage/container'), + _ = require('underscore'); + +var Container = exports.Container = function Container(client, details) { + base.Container.call(this, client, details); +}; + +util.inherits(Container, base.Container); + +Container.prototype._setProperties = function (bucket) { + this.name = bucket.name; + this.metadata = bucket.metadata; + _.extend(this, bucket.metadata); +}; + +Container.prototype.toJSON = function () { + return this.metadata; +}; diff --git a/lib/pkgcloud/google/storage/file.js b/lib/pkgcloud/google/storage/file.js new file mode 100644 index 000000000..73653a39e --- /dev/null +++ b/lib/pkgcloud/google/storage/file.js @@ -0,0 +1,26 @@ +/* + * container.js: Google Cloud Storage File + * + * (C) 2012 Nodejitsu Inc. + * + */ + +var util = require('util'), + base = require('../../core/storage/file'), + _ = require('underscore'); + +var File = exports.File = function File(client, details) { + base.File.call(this, client, details); +}; + +util.inherits(File, base.File); + +File.prototype._setProperties = function (file) { + this.name = file.name; + this.metadata = file.metadata; + _.extend(this, file.metadata); +}; + +File.prototype.toJSON = function () { + return this.metadata; +}; \ No newline at end of file diff --git a/lib/pkgcloud/google/storage/index.js b/lib/pkgcloud/google/storage/index.js new file mode 100644 index 000000000..56fe6741d --- /dev/null +++ b/lib/pkgcloud/google/storage/index.js @@ -0,0 +1,14 @@ +/* + * index.js: Top-level include for the Google Cloud Storage module + * + * (C) 2012 Nodejitsu Inc. + * + */ + +exports.Client = require('./client').Client; +exports.Container = require('./container').Container; +exports.File = require('./file').File; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/package.json b/package.json index 50cf1dbb9..5f6aa0a27 100644 --- a/package.json +++ b/package.json @@ -51,19 +51,20 @@ ], "dependencies": { "async": "0.9.x", + "aws-sdk": "~2.0.17", "errs": "0.3.x", "eventemitter2": "0.4.x", "filed": "0.1.x", + "gcloud": "^0.10.0", "ip": "0.3.x", - "xml2js": "0.1.x", "mime": "1.2.x", - "through2": "0.6.x", "qs": "1.2.x", "request": "2.40.x", + "s3-upload-stream": "~1.0.0", + "through2": "0.6.x", "underscore": "1.6.x", "url-join": "0.0.x", - "aws-sdk": "~2.0.17", - "s3-upload-stream": "~1.0.0" + "xml2js": "0.1.x" }, "devDependencies": { "hock": "1.0.x", diff --git a/test/configs/mock/google.json b/test/configs/mock/google.json new file mode 100644 index 000000000..e3a6e708c --- /dev/null +++ b/test/configs/mock/google.json @@ -0,0 +1,4 @@ +{ + "keyFilename": "/Users/stephen/dev/keyfile.json", + "projectId": "nth-circlet-705" +} diff --git a/test/google/storage/index.js b/test/google/storage/index.js new file mode 100644 index 000000000..b51329022 --- /dev/null +++ b/test/google/storage/index.js @@ -0,0 +1,116 @@ +var helpers = require('../../helpers'), + fs = require('fs'), + assert = require('../../helpers/assert'), + mock = !!process.env.MOCK; + +describe('pkgcloud/google/storage', function () { + var CONTAINER_NAME = 'pkgcloud-temp-container-' + Date.now(), + container, + client; + + before(function (done) { + client = helpers.createClient('google', 'storage'); + + client.createContainer(CONTAINER_NAME, function(err, c) { + assert.ifError(err); + container = c; + done(); + }); + }); + + after(function (done) { + client.destroyContainer(container, done); + }); + + describe('containers', function () { + it('creates a container', function () { + assert.assertContainer(container); + }); + + it('gets all containers', function(done) { + client.getContainers(function(err, containers) { + assert.ifError(err); + + containers.forEach(assert.assertContainer); + + done(); + }); + }); + + it('gets a container', function (done) { + client.getContainer(CONTAINER_NAME, function(err, container) { + assert.ifError(err); + + assert.assertContainer(container); + assert.equal(container.name, CONTAINER_NAME); + + done(); + }); + }); + }); + + describe('files', function () { + var FILE_NAME = 'package.json', + file, + packageJson = JSON.parse(fs.readFileSync('./package.json')); + + before(function (done) { + fs.createReadStream('./package.json') + .pipe(client.upload({ + container: container, + file: 'package.json' + })) + .on('error', done) + .on('success', function(f) { + file = f; + done(); + }); + }); + + after(function (done) { + client.removeFile(container, file, done); + }); + + it('creates a file', function() { + assert.assertFile(file); + }); + + it('downloads a file', function(done) { + var buffer = new Buffer(''); + + client.download({ + container: container, + file: file + }) + .on('error', done) + .on('data', function(chunk) { + buffer = Buffer.concat([buffer, chunk]); + }) + .on('end', function() { + assert.deepEqual(JSON.parse(buffer), packageJson); + done(); + }); + }); + + it('gets all files', function(done) { + client.getFiles(container, function(err, files) { + assert.ifError(err); + + files.forEach(assert.assertFile); + + done(); + }); + }); + + it('gets a file', function(done) { + client.getFile(container, FILE_NAME, function(err, file) { + assert.ifError(err); + + assert.assertFile(file); + assert.equal(file.name, FILE_NAME); + + done(); + }); + }); + }); +}); \ No newline at end of file From 0d20e3d6afb2a86e9e1d326ba546d43a30a40f6a Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Fri, 14 Nov 2014 09:55:12 -0500 Subject: [PATCH 221/460] test with mocks --- package.json | 1 + test/configs/mock/google.json | 10 +- test/fixtures/google/create-bucket.json | 9 + test/fixtures/google/create-file.json | 16 ++ test/fixtures/google/get-bucket.json | 9 + test/fixtures/google/get-buckets.json | 23 +++ test/fixtures/google/get-file.json | 16 ++ test/fixtures/google/get-files.json | 21 ++ test/google/storage/all-test.js | 252 ++++++++++++++++++++++++ test/google/storage/index.js | 116 ----------- 10 files changed, 355 insertions(+), 118 deletions(-) create mode 100644 test/fixtures/google/create-bucket.json create mode 100644 test/fixtures/google/create-file.json create mode 100644 test/fixtures/google/get-bucket.json create mode 100644 test/fixtures/google/get-buckets.json create mode 100644 test/fixtures/google/get-file.json create mode 100644 test/fixtures/google/get-files.json create mode 100644 test/google/storage/all-test.js delete mode 100644 test/google/storage/index.js diff --git a/package.json b/package.json index 5f6aa0a27..810ab1544 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "aws", "amazon", "azure", + "google", "iaas", "servers", "compute", diff --git a/test/configs/mock/google.json b/test/configs/mock/google.json index e3a6e708c..2453eae8b 100644 --- a/test/configs/mock/google.json +++ b/test/configs/mock/google.json @@ -1,4 +1,10 @@ { - "keyFilename": "/Users/stephen/dev/keyfile.json", - "projectId": "nth-circlet-705" + "credentials": { + "private_key_id": "7", + "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIBOgIBAAJBAK8Q+ToR4tWGshaKYRHKJ3ZmMUF6jjwCS/u1A8v1tFbQiVpBlxYB\npaNcT2ENEXBGdmWqr8VwSl0NBIKyq4p0rhsCAQMCQHS1+3wL7I5ZzA8G62Exb6RE\nINZRtCgBh/0jV91OeDnfQUc07SE6vs31J8m7qw/rxeB3E9h6oGi9IVRebVO+9zsC\nIQDWb//KAzrSOo0P0yktnY57UF9Q3Y26rulWI6LqpsxZDwIhAND/cmlg7rUz34Pf\nSmM61lJEmMEjKp8RB/xgghzmCeI1AiEAjvVVMVd8jCcItTdwyRO0UjWU4JOz0cnw\n5BfB8cSIO18CIQCLVPbw60nOIpUClNxCJzmMLbsrbMcUtgVS6wFomVvsIwIhAK+A\nYqT6WwsMW2On5l9di+RPzhDT1QdGyTI5eFNS+GxY\n-----END RSA PRIVATE KEY-----", + "client_email": "firstpart@secondpart.com", + "client_id": "8", + "type": "service_account" + }, + "projectId": "test-project" } diff --git a/test/fixtures/google/create-bucket.json b/test/fixtures/google/create-bucket.json new file mode 100644 index 000000000..2b609ebe9 --- /dev/null +++ b/test/fixtures/google/create-bucket.json @@ -0,0 +1,9 @@ +{ + "kind": "storage#bucket", + "id": "test-bucket", + "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket", + "name": "test-bucket", + "location": "US", + "storageClass": "STANDARD", + "etag": "CAE=" +} \ No newline at end of file diff --git a/test/fixtures/google/create-file.json b/test/fixtures/google/create-file.json new file mode 100644 index 000000000..6f620a3f0 --- /dev/null +++ b/test/fixtures/google/create-file.json @@ -0,0 +1,16 @@ +{ + "kind": "storage#object", + "id": "test-bucket/package.json/1415899273437000", + "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket/o/package.json", + "name": "package.json", + "bucket": "test-bucket", + "generation": "1415899273437000", + "contentType": "image/png", + "updated": "2014-11-13T17:21:13.436Z", + "storageClass": "STANDARD", + "size": "49111", + "md5Hash": "CatH1NCRnQx11HYkd8d4WA==", + "mediaLink": "https://www.googleapis.com/download/storage/v1/b/test-bucket/o/package.json?generation=1415899273437000&alt=media", + "crc32c": "xvcxag==", + "etag": "CMi+7OmL+MECEAE=" +} \ No newline at end of file diff --git a/test/fixtures/google/get-bucket.json b/test/fixtures/google/get-bucket.json new file mode 100644 index 000000000..2b609ebe9 --- /dev/null +++ b/test/fixtures/google/get-bucket.json @@ -0,0 +1,9 @@ +{ + "kind": "storage#bucket", + "id": "test-bucket", + "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket", + "name": "test-bucket", + "location": "US", + "storageClass": "STANDARD", + "etag": "CAE=" +} \ No newline at end of file diff --git a/test/fixtures/google/get-buckets.json b/test/fixtures/google/get-buckets.json new file mode 100644 index 000000000..577098909 --- /dev/null +++ b/test/fixtures/google/get-buckets.json @@ -0,0 +1,23 @@ +{ + "kind": "storage#buckets", + "items": [ + { + "kind": "storage#bucket", + "id": "gcloud-test-bucket-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", + "selfLink": "https://www.googleapis.com/storage/v1/b/gcloud-test-bucket-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", + "name": "gcloud-test-bucket-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", + "location": "US", + "storageClass": "STANDARD", + "etag": "CAE=" + }, + { + "kind": "storage#bucket", + "id": "gcloud-test-bucket-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", + "selfLink": "https://www.googleapis.com/storage/v1/b/gcloud-test-bucket-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", + "name": "gcloud-test-bucket-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", + "location": "US", + "storageClass": "STANDARD", + "etag": "CAE=" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/google/get-file.json b/test/fixtures/google/get-file.json new file mode 100644 index 000000000..6f620a3f0 --- /dev/null +++ b/test/fixtures/google/get-file.json @@ -0,0 +1,16 @@ +{ + "kind": "storage#object", + "id": "test-bucket/package.json/1415899273437000", + "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket/o/package.json", + "name": "package.json", + "bucket": "test-bucket", + "generation": "1415899273437000", + "contentType": "image/png", + "updated": "2014-11-13T17:21:13.436Z", + "storageClass": "STANDARD", + "size": "49111", + "md5Hash": "CatH1NCRnQx11HYkd8d4WA==", + "mediaLink": "https://www.googleapis.com/download/storage/v1/b/test-bucket/o/package.json?generation=1415899273437000&alt=media", + "crc32c": "xvcxag==", + "etag": "CMi+7OmL+MECEAE=" +} \ No newline at end of file diff --git a/test/fixtures/google/get-files.json b/test/fixtures/google/get-files.json new file mode 100644 index 000000000..2ce4838a1 --- /dev/null +++ b/test/fixtures/google/get-files.json @@ -0,0 +1,21 @@ +{ + "kind": "storage#objects", + "items": [ + { + "kind": "storage#object", + "id": "test-bucket/package.json/1415899273437000", + "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket/o/package.json", + "name": "package.json", + "bucket": "test-bucket", + "generation": "1415899273437000", + "contentType": "image/png", + "updated": "2014-11-13T17:21:13.436Z", + "storageClass": "STANDARD", + "size": "49111", + "md5Hash": "CatH1NCRnQx11HYkd8d4WA==", + "mediaLink": "https://www.googleapis.com/download/storage/v1/b/test-bucket/o/package.json?generation=1415899273437000&alt=media", + "crc32c": "xvcxag==", + "etag": "CMi+7OmL+MECEAE=" + } + ] +} \ No newline at end of file diff --git a/test/google/storage/all-test.js b/test/google/storage/all-test.js new file mode 100644 index 000000000..9b37b2325 --- /dev/null +++ b/test/google/storage/all-test.js @@ -0,0 +1,252 @@ +var helpers = require('../../helpers'), + fs = require('fs'), + assert = require('../../helpers/assert'), + http = require('http'), + hock = require('hock'), + mock = !!process.env.MOCK, + request = require('request'), + through = require('through2'); + +describe('pkgcloud/google/storage', function () { + var FILE_NAME = 'package.json', + CONTAINER_NAME = mock ? 'test-bucket' : 'pkgcloud-temp-container-' + Date.now(), + container, + client, + hockInstance; + + before(function (done) { + var config = null; + + if (!mock) { + config = { + keyFilename: process.env.GCLOUD_KEYFILE, + projectId: process.env.GCLOUD_PROJECT_ID + }; + } + + client = helpers.createClient('google', 'storage', config); + + if (!mock) { + return createContainer(); + } + + hockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + server.listen(12345, createContainer); + + overrideGcloudRequester(); + + function createContainer() { + if (mock) { + hockInstance + .post('/storage/v1/b?project=test-project', { + name: CONTAINER_NAME + }) + .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); + } + + client.createContainer(CONTAINER_NAME, function(err, c) { + assert.ifError(err); + container = c; + + hockInstance && hockInstance.done(); + done(); + }); + } + + function overrideGcloudRequester() { + client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + callback(null, reqOpts); + }; + + client.storage.connection_.req = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + client.storage.connection_.requester(reqOpts, callback); + }; + + client.storage.connection_.requester = function (reqOpts, callback) { + if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { + var stream = through(); + stream.on('finish', function () { + fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { + if (err) { + return stream.emit('error', err); + } + stream.emit('complete', { body: JSON.parse(file) }); + }); + }); + return stream; + } + + if (reqOpts.uri === 'http://localhost:12345/mediaLink') { + return fs.createReadStream('./package.json'); + } + + return request(reqOpts, callback); + }; + } + }); + + after(function (done) { + if (mock) { + hockInstance + .get('/storage/v1/b/test-bucket/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); + + hockInstance + .delete('/storage/v1/b/test-bucket/o/package.json') + .reply(204, {}); + + hockInstance + .delete('/storage/v1/b/test-bucket') + .reply(204, {}); + } + + client.destroyContainer(container, function(err) { + if (!mock) { + return done(err); + } + + hockInstance && hockInstance.done(); + server.close(done); + }); + }); + + describe('containers', function () { + it('creates a container', function () { + assert.assertContainer(container); + }); + + it('gets all containers', function(done) { + if (mock) { + hockInstance + .get('/storage/v1/b?project=test-project') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); + } + + client.getContainers(function(err, containers) { + assert.ifError(err); + + containers.forEach(assert.assertContainer); + + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('gets a container', function (done) { + if (mock) { + hockInstance + .get('/storage/v1/b/' + CONTAINER_NAME) + .replyWithFile(200, __dirname + '/../../fixtures/google/get-bucket.json'); + } + + client.getContainer(CONTAINER_NAME, function(err, container) { + assert.ifError(err); + + assert.assertContainer(container); + assert.equal(container.name, CONTAINER_NAME); + + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + describe('files', function () { + var file, + packageJson = JSON.parse(fs.readFileSync('./package.json')); + + before(function (done) { + fs.createReadStream('./package.json') + .pipe(client.upload({ + container: container, + file: 'package.json' + })) + .on('error', done) + .on('success', function(f) { + file = f; + done(); + }); + }); + + after(function (done) { + if (mock) { + hockInstance + .delete('/storage/v1/b/test-bucket/o/package.json') + .reply(204, {}); + } + + client.removeFile(container, file, function(err) { + hockInstance && hockInstance.done(); + done(err || null); + }); + }); + + it('creates a file', function() { + assert.assertFile(file); + }); + + it('downloads a file', function(done) { + var buffer = new Buffer(''); + + if (mock) { + hockInstance + .get('/storage/v1/b/test-bucket/o/package.json') + .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }); + } + + client.download({ + container: container, + file: file + }) + .on('error', done) + .on('data', function(chunk) { + buffer = Buffer.concat([buffer, chunk]); + }) + .on('end', function() { + assert.deepEqual(JSON.parse(buffer), packageJson); + + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('gets all files', function(done) { + if (mock) { + hockInstance + .get('/storage/v1/b/test-bucket/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); + } + + client.getFiles(container, function(err, files) { + assert.ifError(err); + + files.forEach(assert.assertFile); + + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('gets a file', function(done) { + if (mock) { + hockInstance + .get('/storage/v1/b/test-bucket/o/package.json') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); + } + + client.getFile(container, FILE_NAME, function(err, file) { + assert.ifError(err); + + assert.assertFile(file); + assert.equal(file.name, FILE_NAME); + + hockInstance && hockInstance.done(); + done(); + }); + }); + }); +}); \ No newline at end of file diff --git a/test/google/storage/index.js b/test/google/storage/index.js deleted file mode 100644 index b51329022..000000000 --- a/test/google/storage/index.js +++ /dev/null @@ -1,116 +0,0 @@ -var helpers = require('../../helpers'), - fs = require('fs'), - assert = require('../../helpers/assert'), - mock = !!process.env.MOCK; - -describe('pkgcloud/google/storage', function () { - var CONTAINER_NAME = 'pkgcloud-temp-container-' + Date.now(), - container, - client; - - before(function (done) { - client = helpers.createClient('google', 'storage'); - - client.createContainer(CONTAINER_NAME, function(err, c) { - assert.ifError(err); - container = c; - done(); - }); - }); - - after(function (done) { - client.destroyContainer(container, done); - }); - - describe('containers', function () { - it('creates a container', function () { - assert.assertContainer(container); - }); - - it('gets all containers', function(done) { - client.getContainers(function(err, containers) { - assert.ifError(err); - - containers.forEach(assert.assertContainer); - - done(); - }); - }); - - it('gets a container', function (done) { - client.getContainer(CONTAINER_NAME, function(err, container) { - assert.ifError(err); - - assert.assertContainer(container); - assert.equal(container.name, CONTAINER_NAME); - - done(); - }); - }); - }); - - describe('files', function () { - var FILE_NAME = 'package.json', - file, - packageJson = JSON.parse(fs.readFileSync('./package.json')); - - before(function (done) { - fs.createReadStream('./package.json') - .pipe(client.upload({ - container: container, - file: 'package.json' - })) - .on('error', done) - .on('success', function(f) { - file = f; - done(); - }); - }); - - after(function (done) { - client.removeFile(container, file, done); - }); - - it('creates a file', function() { - assert.assertFile(file); - }); - - it('downloads a file', function(done) { - var buffer = new Buffer(''); - - client.download({ - container: container, - file: file - }) - .on('error', done) - .on('data', function(chunk) { - buffer = Buffer.concat([buffer, chunk]); - }) - .on('end', function() { - assert.deepEqual(JSON.parse(buffer), packageJson); - done(); - }); - }); - - it('gets all files', function(done) { - client.getFiles(container, function(err, files) { - assert.ifError(err); - - files.forEach(assert.assertFile); - - done(); - }); - }); - - it('gets a file', function(done) { - client.getFile(container, FILE_NAME, function(err, file) { - assert.ifError(err); - - assert.assertFile(file); - assert.equal(file.name, FILE_NAME); - - done(); - }); - }); - }); -}); \ No newline at end of file From f10c2610f349bfbbe8f79f0de0bb87f7e0fdf2c7 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Fri, 14 Nov 2014 10:17:15 -0500 Subject: [PATCH 222/460] style conventions --- .../google/storage/client/containers.js | 49 +++++++++---------- lib/pkgcloud/google/storage/client/files.js | 38 +++++++++++--- lib/pkgcloud/google/storage/client/index.js | 47 +++++++----------- 3 files changed, 74 insertions(+), 60 deletions(-) diff --git a/lib/pkgcloud/google/storage/client/containers.js b/lib/pkgcloud/google/storage/client/containers.js index 82b9b087a..2d4183fdb 100644 --- a/lib/pkgcloud/google/storage/client/containers.js +++ b/lib/pkgcloud/google/storage/client/containers.js @@ -9,11 +9,11 @@ var async = require('async'), pkgcloud = require('../../../../../lib/pkgcloud'), storage = pkgcloud.providers.google.storage; -// -// ### function getContainers (callback) -// #### @callback {function} Continuation to respond to when complete. -// Gets all Google Cloud Storage containers for this instance. -// +/** + * Get all Google Cloud Storage containers for this instance. + * + * @param {function} callback - Continuation to respond to when complete. + */ exports.getContainers = function (callback) { var self = this, containers = []; @@ -39,13 +39,12 @@ exports.getContainers = function (callback) { self.storage.getBuckets(handleResponse); }; -// -// ### function getContainer (container, callback) -// #### @container {string|storage.Container} Name of the container to return -// #### @callback {function} Continuation to respond to when complete. -// Responds with the Google Cloud Storage bucket for the specified -// `container`. -// +/** + * Responds with the Google Cloud Storage bucket for the specified container. + * + * @param {string|storage.Container} container - The container to return. + * @param {function} callback - Continuation to respond to when complete. + */ exports.getContainer = function (container, callback) { var self = this, bucket = this._getBucket(container); @@ -57,13 +56,13 @@ exports.getContainer = function (container, callback) { }); }; -// -// ### function createContainer (options, callback) -// #### @options {string|Container} Container to create in Google Cloud Storage -// #### @callback {function} Continuation to respond to when complete. -// Creates the specified `container` in Google Cloud Storage account associated -// with this instance. -// +/** + * Creates the specified `container` in the Google Cloud Storage account + * associated with this instance. + * + * @param {string|storage.Container} container - The container to create. + * @param {function} callback - Continuation to respond to when complete. + */ exports.createContainer = function (options, callback) { var self = this, bucketName = this._getBucket(options).name; @@ -75,12 +74,12 @@ exports.createContainer = function (options, callback) { }); }; -// -// ### function destroyContainer (container, callback) -// #### @container {string} Name of the container to destroy -// #### @callback {function} Continuation to respond to when complete. -// Destroys the specified `container` and all files in it. -// +/** + * Destroys the specified container and all files in it. + * + * @param {string|storage.Container} container - The container to destroy. + * @param {function} callback - Continuation to respond to when complete. + */ exports.destroyContainer = function (container, callback) { var self = this, bucket = this._getBucket(container); diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index b2ba76a27..69920e88f 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -12,13 +12,13 @@ var fs = require('fs'), storage = pkgcloud.providers.google.storage, _ = require('underscore'); -// -// ### function removeFile (container, file, callback) -// #### @container {string} Name of the container to destroy the file in -// #### @file {string} Name of the file to destroy. -// #### @callback {function} Continuation to respond to when complete. -// Destroys the `file` in the specified `container`. -// +/** + * Destroy a file in the specified container. + * + * @param {string} container - Name of the container to destroy the file in. + * @param {string} file - Name of the file to destroy. + * @param {function} callback - Continuation to respond to when complete. + */ exports.removeFile = function (container, file, callback) { var bucket = this._getBucket(container), file = this._getFile(bucket, file); @@ -30,6 +30,14 @@ exports.removeFile = function (container, file, callback) { }); }; +/** + * Upload a file to the specified bucket. + * + * @param {object} options - Configuration object. + * @param {object} options.container - Container object for the file. + * @param {object|string} options.file - The file to upload content to. + * @return {stream} + */ exports.upload = function (options) { var self = this, bucket = this._getBucket(options), @@ -62,6 +70,14 @@ exports.upload = function (options) { return proxyStream; }; +/** + * Download a file from the specified bucket. + * + * @param {object} options - Configuration object. + * @param {object} options.container - Container object for the file. + * @param {object|string} options.file - The file to upload content to. + * @return {stream} + */ exports.download = function (options) { var bucket = this._getBucket(options), file = this._getFile(bucket, options); @@ -83,6 +99,14 @@ exports.getFile = function (container, file, callback) { }); }; +/** + * Get all of the files from a gcloud bucket. + * + * @param {object} container - Container object for the file. + * @param {object=|function} options - Options or callback. + * @param {string} options.maxResults - Maximum amount of results to fetch. + * @param {function} callback - Continuation to respond to when complete. + */ exports.getFiles = function (container, options, callback) { var self = this, bucket = this._getBucket(container); diff --git a/lib/pkgcloud/google/storage/client/index.js b/lib/pkgcloud/google/storage/client/index.js index ce5e66995..fb96c09ce 100644 --- a/lib/pkgcloud/google/storage/client/index.js +++ b/lib/pkgcloud/google/storage/client/index.js @@ -21,44 +21,35 @@ var Client = exports.Client = function (options) { util.inherits(Client, google.Client); -// -// Return a gcloud Bucket instance, after detecting its name from a variety of -// parameter types. -// +/** + * Return a gcloud Bucket instance after detecting its name from a variety of + * parameter types. + * + * @param {object|string} container - A descriptor for a gcloud Bucket. + * @return {gcloud:bucket} + */ Client.prototype._getBucket = function (container) { container = container.container || container; - var containerName, - storage = pkgcloud.providers.google.storage; - - if (typeof container === 'string') { - containerName = container; - } - - if (container instanceof storage.Container) { - containerName = container.name; - } + var storage = pkgcloud.providers.google.storage, + containerName = container instanceof storage.Container ? container.name : container; return this.storage.bucket(containerName || container); }; -// -// Return a gcloud File instance, after detecting its name from a variety of -// parameter types. -// +/** + * Return a gcloud File instance after detecting its name from a variety of + * parameter types. + * + * @param {gcloud:bucket} bucket - A gcloud Bucket instance, which contains the file. + * @param {object|string} file - A descriptor for a gcloud File. + * @return {gcloud:file} + */ Client.prototype._getFile = function (bucket, file) { file = file.file || file; - var fileName, - storage = pkgcloud.providers.google.storage; - - if (typeof file === 'string') { - fileName = file; - } - - if (file instanceof storage.File) { - fileName = file.name; - } + var storage = pkgcloud.providers.google.storage, + fileName = file instanceof storage.File ? file.name : file; return bucket.file(fileName || file); }; From 77b2836e0e5cef8ca602d7418a8c52295377d8a2 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Fri, 14 Nov 2014 12:27:38 -0500 Subject: [PATCH 223/460] use common tests --- lib/pkgcloud/google/storage/client/index.js | 2 +- lib/pkgcloud/google/storage/file.js | 4 + test/common/storage/base-test.js | 92 ++++++- test/configs/providers.json | 2 +- test/fixtures/google/create-bucket.json | 2 +- test/fixtures/google/create-file.json | 14 +- test/fixtures/google/get-bucket.json | 9 - test/fixtures/google/get-buckets.json | 12 +- test/fixtures/google/get-file.json | 14 +- test/fixtures/google/get-files.json | 14 +- test/google/storage/all-test.js | 252 -------------------- 11 files changed, 123 insertions(+), 294 deletions(-) delete mode 100644 test/fixtures/google/get-bucket.json delete mode 100644 test/google/storage/all-test.js diff --git a/lib/pkgcloud/google/storage/client/index.js b/lib/pkgcloud/google/storage/client/index.js index fb96c09ce..1e33438d3 100644 --- a/lib/pkgcloud/google/storage/client/index.js +++ b/lib/pkgcloud/google/storage/client/index.js @@ -46,7 +46,7 @@ Client.prototype._getBucket = function (container) { * @return {gcloud:file} */ Client.prototype._getFile = function (bucket, file) { - file = file.file || file; + file = file.file || file.remote || file; var storage = pkgcloud.providers.google.storage, fileName = file instanceof storage.File ? file.name : file; diff --git a/lib/pkgcloud/google/storage/file.js b/lib/pkgcloud/google/storage/file.js index 73653a39e..fd02419ef 100644 --- a/lib/pkgcloud/google/storage/file.js +++ b/lib/pkgcloud/google/storage/file.js @@ -19,6 +19,10 @@ File.prototype._setProperties = function (file) { this.name = file.name; this.metadata = file.metadata; _.extend(this, file.metadata); + + if (this.size) { + this.size = parseInt(this.size, 10); + } }; File.prototype.toJSON = function () { diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 71165844b..f554730ff 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -17,6 +17,8 @@ var fs = require('fs'), http = require('http'), urlJoin = require('url-join'), _ = require('underscore'), + request = require('request'), + through = require('through2'), providers = require('../../configs/providers.json'), versions = require('../../fixtures/versions.json'), Container = require('../../../lib/pkgcloud/core/storage/container').Container, @@ -30,7 +32,16 @@ providers.filter(function (provider) { }).forEach(function (provider) { describe('pkgcloud/common/storage/base [' + provider + ']', function () { - var client = helpers.createClient(provider, 'storage'), + var config = null; + + if (!mock && provider === 'google') { + config = { + keyFilename: process.env.GCLOUD_KEYFILE, + projectId: process.env.GCLOUD_PROJECT_ID + }; + } + + var client = helpers.createClient(provider, 'storage', config), context = {}, authServer, server, authHockInstance, hockInstance; @@ -469,6 +480,40 @@ function setupCreateContainerMock(provider, client, servers) { .put('/pkgcloud-test-container?restype=container') .reply(201, '', helpers.azureResponseHeaders()); } + else if (provider === 'google') { + servers.server + .post('/storage/v1/b?project=test-project', { + name: 'pkgcloud-test-container' + }) + .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); + + client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + callback(null, reqOpts); + }; + + client.storage.connection_.req = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + client.storage.connection_.requester(reqOpts, callback); + }; + + client.storage.connection_.requester = function (reqOpts, callback) { + if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { + var stream = through(); + stream.on('finish', function () { + fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { + if (err) { + return stream.emit('error', err); + } + stream.emit('complete', { body: JSON.parse(file) }); + }); + }); + return stream; + } + + return request(reqOpts, callback); + }; + } else if (provider === 'hp') { servers.authServer .post('/v2.0/tokens', { @@ -515,6 +560,11 @@ function setupGetContainersMock(provider, client, servers) { .get('/?comp=list') .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()) } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b?project=test-project') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); + } else if (provider === 'hp') { servers.server .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') @@ -574,6 +624,13 @@ function setupDownloadStreamMock(provider, client, servers) { .get('/pkgcloud-test-container/test-file.txt') .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})) } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) + .get('/mediaLink') + .reply(200, fillerama); + } else if (provider === 'hp') { servers.server .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') @@ -597,7 +654,12 @@ function setupGetFileMock(provider, client, servers) { .get('/pkgcloud-test-container/test-file.txt') .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})) } - if (provider === 'hp') { + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); + } + else if (provider === 'hp') { servers.server .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') .reply(200, '', { 'content-length': fillerama.length + 2 }) @@ -624,6 +686,11 @@ function setupGetFilesMock(provider, client, servers) { .get('/pkgcloud-test-container?restype=container&comp=list') .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})) } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); + } else if (provider === 'hp') { servers.server .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') @@ -651,7 +718,12 @@ function setupRemoveFileMock(provider, client, servers) { .delete('/pkgcloud-test-container/test-file.txt') .reply(202, '', helpers.azureDeleteResponseHeaders()) } - if (provider === 'hp') { + else if (provider === 'google') { + servers.server + .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(204, {}); + } + else if (provider === 'hp') { servers.server .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(204, ''); @@ -718,6 +790,15 @@ function setupDestroyContainerMock(provider, client, servers) { .delete('/pkgcloud-test-container?restype=container') .reply(202, '', helpers.azureDeleteResponseHeaders()); } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json') + .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(204, {}) + .delete('/storage/v1/b/pkgcloud-test-container') + .reply(204, {}); + } else if (provider === 'hp') { servers.server .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') @@ -756,6 +837,11 @@ function setupGetContainers2Mock(provider, client, servers) { .get('/?comp=list') .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()) } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b?project=test-project') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); + } else if (provider === 'hp') { servers.server .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') diff --git a/test/configs/providers.json b/test/configs/providers.json index e643abe2d..96c4a7971 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1 +1 @@ -["rackspace", "openstack", "joyent", "amazon", "azure", "digitalocean", "hp"] \ No newline at end of file +["rackspace", "openstack", "joyent", "amazon", "azure", "digitalocean", "hp", "google"] \ No newline at end of file diff --git a/test/fixtures/google/create-bucket.json b/test/fixtures/google/create-bucket.json index 2b609ebe9..a17cbaa85 100644 --- a/test/fixtures/google/create-bucket.json +++ b/test/fixtures/google/create-bucket.json @@ -1,7 +1,7 @@ { "kind": "storage#bucket", "id": "test-bucket", - "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket", + "selfLink": "https://www.googleapis.com/storage/v1/b/pkgcloud-test-container", "name": "test-bucket", "location": "US", "storageClass": "STANDARD", diff --git a/test/fixtures/google/create-file.json b/test/fixtures/google/create-file.json index 6f620a3f0..b82cfa49b 100644 --- a/test/fixtures/google/create-file.json +++ b/test/fixtures/google/create-file.json @@ -1,16 +1,16 @@ { "kind": "storage#object", - "id": "test-bucket/package.json/1415899273437000", - "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket/o/package.json", - "name": "package.json", - "bucket": "test-bucket", + "id": "pkgcloud-test-container/test-file.txt/1415899273437000", + "selfLink": "https://www.googleapis.com/storage/v1/b/pkgcloud-test-container/o/test-file.txt", + "name": "test-file.txt", + "bucket": "pkgcloud-test-container", "generation": "1415899273437000", - "contentType": "image/png", + "contentType": "application/txt", "updated": "2014-11-13T17:21:13.436Z", "storageClass": "STANDARD", - "size": "49111", + "size": "1102", "md5Hash": "CatH1NCRnQx11HYkd8d4WA==", - "mediaLink": "https://www.googleapis.com/download/storage/v1/b/test-bucket/o/package.json?generation=1415899273437000&alt=media", + "mediaLink": "https://www.googleapis.com/download/storage/v1/b/pkgcloud-test-container/o/test-file.txt?generation=1415899273437000&alt=media", "crc32c": "xvcxag==", "etag": "CMi+7OmL+MECEAE=" } \ No newline at end of file diff --git a/test/fixtures/google/get-bucket.json b/test/fixtures/google/get-bucket.json deleted file mode 100644 index 2b609ebe9..000000000 --- a/test/fixtures/google/get-bucket.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "kind": "storage#bucket", - "id": "test-bucket", - "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket", - "name": "test-bucket", - "location": "US", - "storageClass": "STANDARD", - "etag": "CAE=" -} \ No newline at end of file diff --git a/test/fixtures/google/get-buckets.json b/test/fixtures/google/get-buckets.json index 577098909..541ee2c5f 100644 --- a/test/fixtures/google/get-buckets.json +++ b/test/fixtures/google/get-buckets.json @@ -3,18 +3,18 @@ "items": [ { "kind": "storage#bucket", - "id": "gcloud-test-bucket-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", - "selfLink": "https://www.googleapis.com/storage/v1/b/gcloud-test-bucket-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", - "name": "gcloud-test-bucket-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", + "id": "gcloud-pkgcloud-test-container-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", + "selfLink": "https://www.googleapis.com/storage/v1/b/gcloud-pkgcloud-test-container-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", + "name": "gcloud-pkgcloud-test-container-temp-d6daf200-6a92-11e4-81bd-493abfe0afb5", "location": "US", "storageClass": "STANDARD", "etag": "CAE=" }, { "kind": "storage#bucket", - "id": "gcloud-test-bucket-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", - "selfLink": "https://www.googleapis.com/storage/v1/b/gcloud-test-bucket-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", - "name": "gcloud-test-bucket-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", + "id": "gcloud-pkgcloud-test-container-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", + "selfLink": "https://www.googleapis.com/storage/v1/b/gcloud-pkgcloud-test-container-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", + "name": "gcloud-pkgcloud-test-container-temp-e992db50-6a93-11e4-b0ae-0f9ab23bdc30", "location": "US", "storageClass": "STANDARD", "etag": "CAE=" diff --git a/test/fixtures/google/get-file.json b/test/fixtures/google/get-file.json index 6f620a3f0..b82cfa49b 100644 --- a/test/fixtures/google/get-file.json +++ b/test/fixtures/google/get-file.json @@ -1,16 +1,16 @@ { "kind": "storage#object", - "id": "test-bucket/package.json/1415899273437000", - "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket/o/package.json", - "name": "package.json", - "bucket": "test-bucket", + "id": "pkgcloud-test-container/test-file.txt/1415899273437000", + "selfLink": "https://www.googleapis.com/storage/v1/b/pkgcloud-test-container/o/test-file.txt", + "name": "test-file.txt", + "bucket": "pkgcloud-test-container", "generation": "1415899273437000", - "contentType": "image/png", + "contentType": "application/txt", "updated": "2014-11-13T17:21:13.436Z", "storageClass": "STANDARD", - "size": "49111", + "size": "1102", "md5Hash": "CatH1NCRnQx11HYkd8d4WA==", - "mediaLink": "https://www.googleapis.com/download/storage/v1/b/test-bucket/o/package.json?generation=1415899273437000&alt=media", + "mediaLink": "https://www.googleapis.com/download/storage/v1/b/pkgcloud-test-container/o/test-file.txt?generation=1415899273437000&alt=media", "crc32c": "xvcxag==", "etag": "CMi+7OmL+MECEAE=" } \ No newline at end of file diff --git a/test/fixtures/google/get-files.json b/test/fixtures/google/get-files.json index 2ce4838a1..1c2675c57 100644 --- a/test/fixtures/google/get-files.json +++ b/test/fixtures/google/get-files.json @@ -3,17 +3,17 @@ "items": [ { "kind": "storage#object", - "id": "test-bucket/package.json/1415899273437000", - "selfLink": "https://www.googleapis.com/storage/v1/b/test-bucket/o/package.json", - "name": "package.json", - "bucket": "test-bucket", + "id": "pkgcloud-test-container/test-file.txt/1415899273437000", + "selfLink": "https://www.googleapis.com/storage/v1/b/pkgcloud-test-container/o/test-file.txt", + "name": "test-file.txt", + "bucket": "pkgcloud-test-container", "generation": "1415899273437000", - "contentType": "image/png", + "contentType": "application/txt", "updated": "2014-11-13T17:21:13.436Z", "storageClass": "STANDARD", - "size": "49111", + "size": "1102", "md5Hash": "CatH1NCRnQx11HYkd8d4WA==", - "mediaLink": "https://www.googleapis.com/download/storage/v1/b/test-bucket/o/package.json?generation=1415899273437000&alt=media", + "mediaLink": "https://www.googleapis.com/download/storage/v1/b/pkgcloud-test-container/o/test-file.txt?generation=1415899273437000&alt=media", "crc32c": "xvcxag==", "etag": "CMi+7OmL+MECEAE=" } diff --git a/test/google/storage/all-test.js b/test/google/storage/all-test.js deleted file mode 100644 index 9b37b2325..000000000 --- a/test/google/storage/all-test.js +++ /dev/null @@ -1,252 +0,0 @@ -var helpers = require('../../helpers'), - fs = require('fs'), - assert = require('../../helpers/assert'), - http = require('http'), - hock = require('hock'), - mock = !!process.env.MOCK, - request = require('request'), - through = require('through2'); - -describe('pkgcloud/google/storage', function () { - var FILE_NAME = 'package.json', - CONTAINER_NAME = mock ? 'test-bucket' : 'pkgcloud-temp-container-' + Date.now(), - container, - client, - hockInstance; - - before(function (done) { - var config = null; - - if (!mock) { - config = { - keyFilename: process.env.GCLOUD_KEYFILE, - projectId: process.env.GCLOUD_PROJECT_ID - }; - } - - client = helpers.createClient('google', 'storage', config); - - if (!mock) { - return createContainer(); - } - - hockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - server.listen(12345, createContainer); - - overrideGcloudRequester(); - - function createContainer() { - if (mock) { - hockInstance - .post('/storage/v1/b?project=test-project', { - name: CONTAINER_NAME - }) - .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); - } - - client.createContainer(CONTAINER_NAME, function(err, c) { - assert.ifError(err); - container = c; - - hockInstance && hockInstance.done(); - done(); - }); - } - - function overrideGcloudRequester() { - client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { - reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - callback(null, reqOpts); - }; - - client.storage.connection_.req = function (reqOpts, callback) { - reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - client.storage.connection_.requester(reqOpts, callback); - }; - - client.storage.connection_.requester = function (reqOpts, callback) { - if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { - var stream = through(); - stream.on('finish', function () { - fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { - if (err) { - return stream.emit('error', err); - } - stream.emit('complete', { body: JSON.parse(file) }); - }); - }); - return stream; - } - - if (reqOpts.uri === 'http://localhost:12345/mediaLink') { - return fs.createReadStream('./package.json'); - } - - return request(reqOpts, callback); - }; - } - }); - - after(function (done) { - if (mock) { - hockInstance - .get('/storage/v1/b/test-bucket/o') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); - - hockInstance - .delete('/storage/v1/b/test-bucket/o/package.json') - .reply(204, {}); - - hockInstance - .delete('/storage/v1/b/test-bucket') - .reply(204, {}); - } - - client.destroyContainer(container, function(err) { - if (!mock) { - return done(err); - } - - hockInstance && hockInstance.done(); - server.close(done); - }); - }); - - describe('containers', function () { - it('creates a container', function () { - assert.assertContainer(container); - }); - - it('gets all containers', function(done) { - if (mock) { - hockInstance - .get('/storage/v1/b?project=test-project') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); - } - - client.getContainers(function(err, containers) { - assert.ifError(err); - - containers.forEach(assert.assertContainer); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('gets a container', function (done) { - if (mock) { - hockInstance - .get('/storage/v1/b/' + CONTAINER_NAME) - .replyWithFile(200, __dirname + '/../../fixtures/google/get-bucket.json'); - } - - client.getContainer(CONTAINER_NAME, function(err, container) { - assert.ifError(err); - - assert.assertContainer(container); - assert.equal(container.name, CONTAINER_NAME); - - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - describe('files', function () { - var file, - packageJson = JSON.parse(fs.readFileSync('./package.json')); - - before(function (done) { - fs.createReadStream('./package.json') - .pipe(client.upload({ - container: container, - file: 'package.json' - })) - .on('error', done) - .on('success', function(f) { - file = f; - done(); - }); - }); - - after(function (done) { - if (mock) { - hockInstance - .delete('/storage/v1/b/test-bucket/o/package.json') - .reply(204, {}); - } - - client.removeFile(container, file, function(err) { - hockInstance && hockInstance.done(); - done(err || null); - }); - }); - - it('creates a file', function() { - assert.assertFile(file); - }); - - it('downloads a file', function(done) { - var buffer = new Buffer(''); - - if (mock) { - hockInstance - .get('/storage/v1/b/test-bucket/o/package.json') - .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }); - } - - client.download({ - container: container, - file: file - }) - .on('error', done) - .on('data', function(chunk) { - buffer = Buffer.concat([buffer, chunk]); - }) - .on('end', function() { - assert.deepEqual(JSON.parse(buffer), packageJson); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('gets all files', function(done) { - if (mock) { - hockInstance - .get('/storage/v1/b/test-bucket/o') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); - } - - client.getFiles(container, function(err, files) { - assert.ifError(err); - - files.forEach(assert.assertFile); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('gets a file', function(done) { - if (mock) { - hockInstance - .get('/storage/v1/b/test-bucket/o/package.json') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); - } - - client.getFile(container, FILE_NAME, function(err, file) { - assert.ifError(err); - - assert.assertFile(file); - assert.equal(file.name, FILE_NAME); - - hockInstance && hockInstance.done(); - done(); - }); - }); - }); -}); \ No newline at end of file From aa93c47a4565d280b5431f647f971108f2f23e3f Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Mon, 17 Nov 2014 17:50:12 -0500 Subject: [PATCH 224/460] elaborate on the docs --- README.md | 2 ++ docs/providers/google.md | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ba48116db..de3141fdf 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ If a service does not have at least two providers, it is considered a *beta* int * **[Storage](#storage)** * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) + * [Google](docs/providers/google.md) * [HP](docs/providers/hp/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) @@ -199,6 +200,7 @@ Each storage provider takes different credentials to authenticate; these details * [Amazon](docs/providers/amazon.md#using-storage) * [Azure](docs/providers/azure.md#using-storage) +* [Google](docs/providers/google.md#using-storage) * [HP](docs/providers/hp/storage.md) * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) diff --git a/docs/providers/google.md b/docs/providers/google.md index 1ca01f12f..0da860884 100644 --- a/docs/providers/google.md +++ b/docs/providers/google.md @@ -1,12 +1,19 @@ -## Using the Google Cloud provider in pkgcloud +# Using Google Cloud with `pkgcloud` The Google Cloud provider in pkgcloud supports the following services: -* **Storage** Google Cloud Storage (Simple Storage Service) +* **Storage** Google Cloud Storage -### Client Creation +Using the Google Cloud provider requires: -For all of the Google services, you create a client with the same options: +1. A project id +2. A JSON key file + +Both are provided from the [Google Developers Console](https://console.developers.google.com/project). For detailed instructions, see this [Getting Started guide](https://github.com/GoogleCloudPlatform/gcloud-node/blob/v0.10.0/README.md#authorization). + +
+ +## Using Storage ```Javascript var client = require('pkgcloud').storage.createClient({ From 3b555ff73c3813408a50c3e1316b04058dc185fb Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Tue, 18 Nov 2014 10:54:24 +0000 Subject: [PATCH 225/460] copy has been refactored to take an options parameter instead of multiple arguments. --- .../openstack/storage/client/files.js | 30 +++++++++++-------- lib/pkgcloud/openstack/storage/file.js | 4 +-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index ee3e1841f..774cea9e2 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -396,28 +396,32 @@ exports.updateFileMetadata = function (container, file, callback) { /** * client.copy * - * @description copies a file to another location in the container. + * @description copies a file to another location in the same or different container. * - * @param {String|object} container the container or containerName - * @param {String|object} file the file or fileName to copy - * @param {String|object} destination the destination or destinationName to copy to + * @param {object} options + * @param {String|object} options.sourceContainer the source container + * @param {String|object} options.destinationContainer the destination container + * @param {String|object} options.sourceFile the file to copy + * @param {String|object} [options.destinationFile] the destination to copy to + * @param {String|object} [options.headers] headers to send with the request * @param callback */ -exports.copy = function (container, file, destination, callback) { +exports.copy = function (options, callback) { var self = this, - containerName = container instanceof self.models.Container ? container.name : container; + containerName = options.sourceContainer instanceof self.models.Container ? options.sourceContainer.name : options.sourceContainer, + destContainerName = options.destinationContainer instanceof self.models.Container ? options.destinationContainer.name : options.destinationContainer, + destinationFile = options.destinationFile || options.sourceFile; var copyOptions = { method: 'COPY', - uri: file instanceof self.models.File ? file.fullPath : this._getUrl({ + uri: options.sourceFile instanceof self.models.File ? options.sourceFile.fullPath : this._getUrl({ container: containerName, - path: file + path: options.sourceFile }), - headers: { - 'DESTINATION': destination instanceof self.models.File ? - urlJoin('/', destination.container, destination.name) : - urlJoin('/', containerName, destination) - } + headers: _.extend(options.headers || {}, { + destination: urlJoin('/', destContainerName, + destinationFile instanceof self.models.File ? destinationFile.name : destinationFile) + }) }; this._request(copyOptions, function (err) { diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index ce489964b..ca0e41bb0 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -20,8 +20,8 @@ File.prototype.updateMetadata = function (callback) { this.client.updateFileMetadata(this.container, this, callback); }; -File.prototype.copy = function (container, destination, callback) { - this.client.copy(container, this, destination, callback) +File.prototype.copy = function (options, callback) { + this.client.copy(options, callback) }; File.prototype._setProperties = function (details) { From f6f2b6d3fdc9fbe6facf6da44852d6741bbcf2a2 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 18 Nov 2014 18:00:27 -0800 Subject: [PATCH 226/460] Updating broken or outdated links --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7c1b09bf..efe0ab59f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ The only issues we accept are bug reports or feature requests. Bugs must be isol ## Adding tests to my pull requests -The tests are written using [mocha](http://visionmedia.github.io/mocha/) and given the nature of `pkgcloud` test against third-party APIs are very slow specially in case of IaaS providers, so, we encourage the use of [`hock`](https://github.com/mmalecki) for mocking the responses. +The tests are written using [mocha](http://mochajs.org/) and given the nature of `pkgcloud` test against third-party APIs are very slow specially in case of IaaS providers, so, we encourage the use of [`hock`](https://github.com/mmalecki/hock) for mocking the responses. Be familiar with the whole test suite and its helpers and other utilities on `test/` directory, read it to see examples of tests. @@ -57,7 +57,7 @@ var hock = require('hock'); // ... ``` -As `hock` has a similar API to [nock](https://github.com/flatiron/nock), you can easily record the API calls using `nock`. do this using the `recorder.rec()` method offer by `nock` just add this before the test declaration: +As `hock` has a similar API to [nock](https://github.com/pgte/nock), you can easily record the API calls using `nock`. do this using the `recorder.rec()` method offer by `nock` just add this before the test declaration: ``` js nock.recorder.rec(); From 5105eca0c72f9b4606422a7f6e8a55fb4349b2cd Mon Sep 17 00:00:00 2001 From: mmdonohue Date: Fri, 21 Nov 2014 18:15:15 -0600 Subject: [PATCH 227/460] Update service.js This looks like a dup. 'options' is already declared on line 54. --- lib/pkgcloud/openstack/context/service.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/pkgcloud/openstack/context/service.js b/lib/pkgcloud/openstack/context/service.js index 6cf6e1b3d..b0b1cb749 100644 --- a/lib/pkgcloud/openstack/context/service.js +++ b/lib/pkgcloud/openstack/context/service.js @@ -57,8 +57,6 @@ Service.prototype.getEndpointUrl = function (options) { return ''; } - options = options || {}; - if (options.region) { _.each(self.endpoints, function (endpoint) { if (!endpoint.region || !matchRegion(endpoint.region, options.region)) { From 8f88da222b568df227383caa839034f324ab3976 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 21 Nov 2014 16:21:59 -0800 Subject: [PATCH 228/460] Refactoring version into client's _getUrl method --- lib/pkgcloud/hp/network/client/index.js | 14 ++++++++++++++ lib/pkgcloud/openstack/network/client/index.js | 14 ++++++++++++++ lib/pkgcloud/openstack/network/client/networks.js | 10 +++++----- lib/pkgcloud/openstack/network/client/ports.js | 10 +++++----- lib/pkgcloud/openstack/network/client/subnets.js | 10 +++++----- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js index ae03efe7b..abe9e5001 100644 --- a/lib/pkgcloud/hp/network/client/index.js +++ b/lib/pkgcloud/hp/network/client/index.js @@ -29,3 +29,17 @@ var Client = exports.Client = function (options) { util.inherits(Client, hp.Client); _.extend(Client.prototype, NetworkClient.prototype); + +/** + * client._getUrl + * + * @description get the url for the current networking service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function(options) { + this._serviceUrl = urlJoin(this._serviceUrl, 'v2.0') + return NetworkClient.prototype._getUrl.call(this, options); +}; diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index b096dc5e3..2af150bc6 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -29,3 +29,17 @@ var Client = exports.Client = function (options) { util.inherits(Client, openstack.Client); _.extend(Client.prototype, NetworkClient.prototype); + +/** + * client._getUrl + * + * @description get the url for the current networking service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function(options) { + this._serviceUrl = urlJoin(this._serviceUrl, 'v2.0') + return NetworkClient.prototype._getUrl.call(this, options); +}; diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 81615ef2e..5217896b5 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -29,7 +29,7 @@ exports.getNetworks = function (options, callback) { } var getNetworkOpts = { - path: '/v2.0/networks' + path: '/networks' }; this._request(getNetworkOpts, function (err, body) { @@ -59,7 +59,7 @@ exports.getNetwork = function (network, callback) { self = this; self.emit('log::trace', 'Getting details for network', networkId); this._request({ - path: urlJoin('/v2.0/networks', networkId), + path: urlJoin('/networks', networkId), method: 'GET' }, function (err, body, res) { if (err) { @@ -91,7 +91,7 @@ exports.createNetwork = function (options, callback) { var createNetworkOpts = { method: 'POST', - path: '/v2.0/networks', + path: '/networks', body: { 'network' : network} }; @@ -118,7 +118,7 @@ exports.updateNetwork = function (network, callback) { var updateNetworkOpts = { method: 'PUT', - path: urlJoin('/v2.0/networks', networkId), + path: urlJoin('/networks', networkId), contentType: 'application/json', body: { 'network' : networkToUpdate} }; @@ -144,7 +144,7 @@ exports.destroyNetwork = function (network, callback) { self = this; self.emit('log::trace', 'Deleting network', networkId); this._request({ - path: urlJoin('/v2.0/networks',networkId), + path: urlJoin('/networks',networkId), method: 'DELETE' }, function (err, body, res) { if (err) { diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index 44b2295de..32e2e916e 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -29,7 +29,7 @@ exports.getPorts = function (options, callback) { } var getPortOpts = { - path: '/v2.0/ports' + path: '/ports' }; this._request(getPortOpts, function (err, body) { @@ -59,7 +59,7 @@ exports.getPort = function (port, callback) { self = this; self.emit('log::trace', 'Getting details for port', portId); this._request({ - path: urlJoin('/v2.0/ports', portId), + path: urlJoin('/ports', portId), method: 'GET' }, function (err, body, res) { if (err) { @@ -91,7 +91,7 @@ exports.createPort = function (options, callback) { var createPortOpts = { method: 'POST', - path: '/v2.0/ports', + path: '/ports', body: { 'port' : port} }; @@ -118,7 +118,7 @@ exports.updatePort = function (port, callback) { port = _convertPortToWireFormat(port); var updatePortOpts = { method: 'PUT', - path: urlJoin('/v2.0/ports', portId), + path: urlJoin('/ports', portId), contentType: 'application/json', body: { 'port' : port} }; @@ -144,7 +144,7 @@ exports.destroyPort = function (port, callback) { self = this; self.emit('log::trace', 'Deleting port', portId); this._request({ - path: urlJoin('/v2.0/ports',portId), + path: urlJoin('/ports',portId), method: 'DELETE' }, function (err, body, res) { if (err) { diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index 3b31d9317..a305173f0 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -32,7 +32,7 @@ exports.getSubnets = function (options, callback) { } var getSubnetOpts = { - path: '/v2.0/subnets', + path: '/subnets', }; this._request(getSubnetOpts, function (err, body) { @@ -62,7 +62,7 @@ exports.getSubnet = function (subnet, callback) { self = this; self.emit('log::trace', 'Getting details for subnet', subnetId); this._request({ - path: urlJoin('/v2.0/subnets', subnetId), + path: urlJoin('/subnets', subnetId), method: 'GET' }, function (err, body, res) { if (err) { @@ -94,7 +94,7 @@ exports.createSubnet = function (options, callback) { var createSubnetOpts = { method: 'POST', - path: '/v2.0/subnets', + path: '/subnets', body: { 'subnet' : subnet} }; @@ -121,7 +121,7 @@ exports.updateSubnet = function (subnet, callback) { var updateSubnetOpts = { method: 'PUT', - path: urlJoin('/v2.0/subnets', subnetId), + path: urlJoin('/subnets', subnetId), contentType: 'application/json', body: { 'subnet' : subnetToUpdate} }; @@ -147,7 +147,7 @@ exports.destroySubnet = function (subnet, callback) { self = this; self.emit('log::trace', 'Deleting subnet', subnetId); this._request({ - path: urlJoin('/v2.0/subnets',subnetId), + path: urlJoin('/subnets',subnetId), method: 'DELETE' }, function (err, body, res) { if (err) { From 58e515d44c8983b9f07180926f4e91b19c4ffc5e Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 21 Nov 2014 16:24:13 -0800 Subject: [PATCH 229/460] Implementing Networking (Neutron) for Rackspace --- lib/pkgcloud/rackspace/index.js | 1 + .../rackspace/network/client/index.js | 32 +++++++++++++++++++ lib/pkgcloud/rackspace/network/index.js | 16 ++++++++++ 3 files changed, 49 insertions(+) create mode 100644 lib/pkgcloud/rackspace/network/client/index.js create mode 100644 lib/pkgcloud/rackspace/network/index.js diff --git a/lib/pkgcloud/rackspace/index.js b/lib/pkgcloud/rackspace/index.js index c4692676a..050f14f40 100644 --- a/lib/pkgcloud/rackspace/index.js +++ b/lib/pkgcloud/rackspace/index.js @@ -12,3 +12,4 @@ exports.dns = require('./dns'); exports.loadbalancer = require('./loadbalancer'); exports.orchestration = require('./orchestration'); exports.storage = require('./storage'); +exports.network = require('./network'); diff --git a/lib/pkgcloud/rackspace/network/client/index.js b/lib/pkgcloud/rackspace/network/client/index.js new file mode 100644 index 000000000..f18a70f43 --- /dev/null +++ b/lib/pkgcloud/rackspace/network/client/index.js @@ -0,0 +1,32 @@ +/* + * client.js: client for Rackspace Networking + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT License + */ + +var util = require('util'), + rackspace = require('../../client'), + NetworkClient = require('../../../openstack/network/networkClient').NetworkClient, + urlJoin = require('url-join'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + rackspace.Client.call(this, options); + + this.models = { + Network: require('../../../openstack/network/network').Network, + Subnet: require('../../../openstack/network/subnet').Subnet, + Port: require('../../../openstack/network/port').Port + }; + + _.extend(this, require('../../../openstack/network/client/networks')); + _.extend(this, require('../../../openstack/network/client/subnets')); + _.extend(this, require('../../../openstack/network/client/ports')); + + this.serviceType = 'network'; +}; + +util.inherits(Client, rackspace.Client); +_.extend(Client.prototype, NetworkClient.prototype); diff --git a/lib/pkgcloud/rackspace/network/index.js b/lib/pkgcloud/rackspace/network/index.js new file mode 100644 index 000000000..2a51364be --- /dev/null +++ b/lib/pkgcloud/rackspace/network/index.js @@ -0,0 +1,16 @@ +/* + * index.js: Top-level include for the Rackspace Networking module. + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +exports.Client = require('./client').Client; +exports.Network = require('../../openstack/network/network').Network; +exports.Subnet = require('../../openstack/network/subnet').Subnet; +exports.Port = require('../../openstack/network/port').Port; + +exports.createClient = function(options) { + return new exports.Client(options); +}; From b49546c26836d4d9adccf9dc448cc68475edb037 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 21 Nov 2014 16:31:32 -0800 Subject: [PATCH 230/460] Adding documentation for Rackspace Network implementation --- README.md | 2 + docs/providers/rackspace/README.md | 1 + docs/providers/rackspace/network.md | 177 ++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 docs/providers/rackspace/network.md diff --git a/README.md b/README.md index ba48116db..ce18a00dd 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ If a service does not have at least two providers, it is considered a *beta* int * **[Network](#network----beta)** *(beta)* * [HP](docs/providers/hp/network.md) * [Openstack](docs/providers/openstack/network.md) + * [Rackspace](docs/providers/rackspace/network.md) ## Compute @@ -445,6 +446,7 @@ To get started with a `pkgcloud.network` client just create one: * [HP](docs/providers/hp/network.md) * [Openstack](docs/providers/openstack/network.md) +* [Rackspace](docs/providers/rackspace/network.md) Each instance of `pkgcloud.network.Client` returned from `pkgcloud.network.createClient` has a set of uniform APIs: diff --git a/docs/providers/rackspace/README.md b/docs/providers/rackspace/README.md index 1a5a9208c..82b0e44fd 100644 --- a/docs/providers/rackspace/README.md +++ b/docs/providers/rackspace/README.md @@ -9,6 +9,7 @@ The Rackspace provider in pkgcloud supports the following services: * [**Block Storage**](blockstorage.md) (Cloud Block Storage) *(beta)* * [**Orchestration**](orchestration.md) (Cloud Orchestration) *(beta)* * [**Load Balancers**](loadbalancer.md) (Cloud Load Balancers) *(beta)* +* [**Network**](network.md) (Cloud Networks) *(beta)* ### Getting Started with Compute diff --git a/docs/providers/rackspace/network.md b/docs/providers/rackspace/network.md new file mode 100644 index 000000000..7c5e64978 --- /dev/null +++ b/docs/providers/rackspace/network.md @@ -0,0 +1,177 @@ +## Using the Rackspace Network provider + +Creating a client is straight-forward: + +``` js + var rackspace = pkgcloud.compute.createClient({ + provider: 'rackspace', // required + username: 'your-user-name', // required + apiKey: 'your-api-key', // required + region: 'IAD', // required, regions can be found at + // http://www.rackspace.com/knowledge_center/article/about-regions + useInternal: false // optional, use to talk to serviceNet from a Rackspace machine + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +## Networks + +#### client.getNetworks(callback) +Lists all networks that are available to use on your HP Cloud account + +Callback returns `f(err, networks)` where `networks` is an `Array` + +#### client.getNetwork(network, callback) +Gets specified network + +Takes network or networkId as an argument and returns the network in the callback +`f(err, network)` + +#### client.createNetwork(options, callback) +Creates a network with the options specified + +Options are as follows: + +```js +{ + name: 'networkName', // optional + adminStateUp : true, // optional + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, Admin only +} +``` +Returns the network in the callback `f(err, network)` + +#### client.updateNetwork(options, callback) +Updates a network with the options specified + +Options are as follows: + +```js +{ + id : 'networkId', // required + name: 'networkName', // optional + adminStateUp : true, // optional + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, Admin only +} +``` +Returns the network in the callback `f(err, network)` + +#### client.destroyNetwork(network, callback) +Destroys the specified network + +Takes network or networkId as an argument and returns the id of the destroyed network in the callback `f(err, networkId)` + +## Subnets + +#### client.getSubnets(callback) +Lists all subnets that are available to use on your HP Cloud account + +Callback returns `f(err, subnets)` where `subnets` is an `Array` + +#### client.getSubnet(subnet, callback) +Gets specified subnet + +Takes subnet or subnetId as an argument and returns the subnet in the callback +`f(err, subnet)` + +#### client.createSubnet(options, callback) +Creates a subnet with the options specified + +Options are as follows: + +```js +{ + name: 'subnetName', // optional + networkId : 'networkId', // required, The ID of the attached network. + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + gatewayIp : 'gateway ip address', // optional,The gateway IP address. + enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. +} +``` +Returns the subnet in the callback `f(err, subnet)` + +#### client.updateSubnet(options, callback) +Updates a subnet with the options specified + +Options are as follows: + +```js +{ + id : 'subnetId', // required + name: 'subnetName', // optional + networkId : 'networkId', // required, The ID of the attached network. + shared : true, // optional, Admin only + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + gatewayIp : 'gateway ip address', // optional,The gateway IP address. + enableDhcp : true // Set to true if DHCP is enabled and false if DHCP is disabled. +} +``` +Returns the subnet in the callback `f(err, subnet)` + +#### client.destroySubnet(subnet, callback) +Destroys the specified subnet + +Takes subnet or subnetId as an argument and returns the id of the destroyed subnet in the callback `f(err, subnetId)` + +## Ports + +#### client.getPorts(callback) +Lists all ports that are available to use on your HP Cloud account + +Callback returns `f(err, ports)` where `ports` is an `Array` + +#### client.getPort(port, callback) +Gets specified port + +Takes port or portId as an argument and returns the port in the callback +`f(err, port)` + +#### client.createPort(options, callback) +Creates a port with the options specified + +Options are as follows: + +```js +{ + name: 'portName', // optional + adminStateUp : true, // optional, The administrative status of the router. Admin-only + networkId : 'networkId', // required, The ID of the attached network. + status : 'text status', // optional, The status of the port. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + macAddress: 'mac address' // optional + fixedIps : ['ip address1', 'ip address 2'], // optional. + securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. +} +``` +Returns the port in the callback `f(err, port)` + +#### client.updatePort(options, callback) +Updates a port with the options specified + +Options are as follows: + +```js +{ + id : 'portId', // required + name: 'portName', // optional + adminStateUp : true, // optional, The administrative status of the router. Admin-only + networkId : 'networkId', // required, The ID of the attached network. + status : 'text status', // optional, The status of the port. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the network. Admin-only + macAddress: 'mac address' // optional + fixedIps : ['ip address1', 'ip address 2'], // optional. + securityGroups : ['security group1', 'security group2'] // optional, Specify one or more security group IDs. +} +``` +Returns the port in the callback `f(err, port)` + +#### client.destroyPort(port, callback) +Destroys the specified port + +Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)` From d82fa05f0d0a72f9ef2e8ce6742a1ab610ac0713 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 21 Nov 2014 17:54:17 -0800 Subject: [PATCH 231/460] Fixing bug with repeated concatenation of version string --- lib/pkgcloud/hp/network/client/index.js | 4 +++- lib/pkgcloud/openstack/network/client/index.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js index abe9e5001..8eb979b37 100644 --- a/lib/pkgcloud/hp/network/client/index.js +++ b/lib/pkgcloud/hp/network/client/index.js @@ -40,6 +40,8 @@ _.extend(Client.prototype, NetworkClient.prototype); * @private */ Client.prototype._getUrl = function(options) { - this._serviceUrl = urlJoin(this._serviceUrl, 'v2.0') + if (options.path) { + options.path = urlJoin('v2.0', options.path) + } return NetworkClient.prototype._getUrl.call(this, options); }; diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index 2af150bc6..074ebd987 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -40,6 +40,8 @@ _.extend(Client.prototype, NetworkClient.prototype); * @private */ Client.prototype._getUrl = function(options) { - this._serviceUrl = urlJoin(this._serviceUrl, 'v2.0') + if (options.path) { + options.path = urlJoin('v2.0', options.path) + } return NetworkClient.prototype._getUrl.call(this, options); }; From 1bf41fd70a41f998aff4581c1a572849bd64f5a8 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 21 Nov 2014 17:55:25 -0800 Subject: [PATCH 232/460] Adding Network service endpoints to Rackspace service catalog fixture --- test/fixtures/rackspace/auth.json | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/fixtures/rackspace/auth.json b/test/fixtures/rackspace/auth.json index 8af3cf8eb..62870e7ff 100644 --- a/test/fixtures/rackspace/auth.json +++ b/test/fixtures/rackspace/auth.json @@ -155,6 +155,42 @@ ], "name": "cloudServersOpenStack", "type": "compute" + }, + { + "name": "cloudNetworks", + "endpoints": [ + { + "region": "IAD", + "tenantId": "12345", + "publicURL": "http://localhost:12345/v2.0" + }, + { + "region": "LON", + "tenantId": "12345", + "publicURL": "http://localhost:12345/v2.0" + }, + { + "region": "ORD", + "tenantId": "12345", + "publicURL": "http://localhost:12345/v2.0" + }, + { + "region": "SYD", + "tenantId": "12345", + "publicURL": "http://localhost:12345/v2.0" + }, + { + "region": "DFW", + "tenantId": "12345", + "publicURL": "http://localhost:12345/v2.0" + }, + { + "region": "HKG", + "tenantId": "12345", + "publicURL": "http://localhost:12345/v2.0" + } + ], + "type": "network" } ], "user": { @@ -170,4 +206,4 @@ "RAX-AUTH:defaultRegion": "" } } -} \ No newline at end of file +} From a11b3f27a7135b12ebd39b262f83778e724e8f51 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 21 Nov 2014 17:55:47 -0800 Subject: [PATCH 233/460] Adding Network service unit tests for Rackspace provider --- test/common/network/network-test.js | 54 ++++++++++++++++++++++++++ test/common/network/port-test.js | 57 ++++++++++++++++++++++++++++ test/common/network/subnet-test.js | 59 +++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index ccfe2cef7..9cea26035 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -254,6 +254,11 @@ function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/networks', currentNetwork.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ @@ -269,6 +274,12 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'rackspace') { + servers.server + .put(urlJoin('/v2.0/networks', currentNetwork.id), + {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwork){ @@ -282,6 +293,11 @@ function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwor .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/networks', currentNetwork.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupNetworksMock(client, provider, servers) { @@ -341,6 +357,22 @@ function setupNetworksMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks') .replyWithFile(200, __dirname + '/../../fixtures/openstack/networks.json'); } + else if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + + servers.server + .get('/v2.0/networks') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/networks.json'); + } } function setupNetworkMock(client, provider, servers) { @@ -356,6 +388,12 @@ function setupNetworkMock(client, provider, servers) { {network: {name: 'create-test-ids2'}}) .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/networks', + {network: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupRefreshNetworkMock(client, provider, servers, network) { @@ -369,6 +407,11 @@ function setupRefreshNetworkMock(client, provider, servers, network) { .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks',network.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/networks',network.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupNetworkModelCreateMock(client, provider, servers) { @@ -384,6 +427,12 @@ function setupNetworkModelCreateMock(client, provider, servers) { {network: {name: 'model created network'}}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/networks', + {network: {name: 'model created network'}}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } } function setupGetNetworkMock(client, provider, servers) { @@ -397,6 +446,11 @@ function setupGetNetworkMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } + else if (provider === 'rackspace') { + servers.server + .get('/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + } } var serverStatusReply = function (name, status) { diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index e1c9f7593..f995ad525 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -256,6 +256,11 @@ function setupDestroyPortMock(client, provider, servers, currentPort){ .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/ports', currentPort.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupUpdatePortMock(client, provider, servers, currentPort){ @@ -277,6 +282,15 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'rackspace') { + servers.server + .put(urlJoin('/v2.0/ports', currentPort.id), + {"port":{"status":"ACTIVE","name":"my_port","admin_state_up":false,"mac_address":"fa:16:3e:58:42:ed", + "fixed_ips":[{"subnet_id":"008ba151-0b8c-4a67-98b5-0d2b87666062","ip_address":"172.24.4.2"}], + "security_groups":[],"network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3"} + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupModelDestroyedPortMock(client, provider, servers, currentPort){ @@ -290,6 +304,11 @@ function setupModelDestroyedPortMock(client, provider, servers, currentPort){ .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/ports', currentPort.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupPortsMock(client, provider, servers) { @@ -349,6 +368,22 @@ function setupPortsMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports') .replyWithFile(200, __dirname + '/../../fixtures/openstack/ports.json'); } + else if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + + servers.server + .get('/v2.0/ports') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/ports.json'); + } } function setupCreatePortMock(client, provider, servers) { @@ -364,6 +399,12 @@ function setupCreatePortMock(client, provider, servers) { {port: {name: 'create-test-ids2'}}) .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/ports', + {port: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupRefreshPortMock(client, provider, servers, port) { @@ -377,6 +418,11 @@ function setupRefreshPortMock(client, provider, servers, port) { .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', port.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/ports', port.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupPortModelCreateMock(client, provider, servers) { @@ -392,6 +438,12 @@ function setupPortModelCreateMock(client, provider, servers) { {port: {name: 'model created network'}}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/ports', + {port: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); + } } function setupGetPortMock(client, provider, servers, currentPort) { @@ -405,4 +457,9 @@ function setupGetPortMock(client, provider, servers, currentPort) { .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/ports', currentPort.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index 70d525fb5..acf2052f5 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -256,6 +256,11 @@ function setupDestroySubnetMock(client, provider, servers, currentSubnet){ .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ @@ -281,6 +286,17 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ "enable_dhcp":false}}) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'rackspace') { + servers.server + .put(urlJoin('/v2.0/subnets', currentSubnet.id), + {"subnet":{"name":"my_subnet", + "network_id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id":"4fd44f30292945e481c7b8a0c8908869", + "allocation_pools":[{"start":"192.0.0.2","end":"192.255.255.254"}], + "gateway_ip":"192.0.0.1","ip_version":4,"cidr":"192.0.0.0/8", + "enable_dhcp":false}}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet){ @@ -294,6 +310,11 @@ function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet) .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) .reply(204, helpers.getOpenstackAuthResponse()); } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) + .reply(204, helpers.getOpenstackAuthResponse()); + } } function setupSubnetsMock(client, provider, servers) { @@ -353,6 +374,22 @@ function setupSubnetsMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets') .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnets.json'); } + else if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + + servers.server + .get('/v2.0/subnets') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnets.json'); + } } function setupCreateSubnetMock(client, provider, servers) { @@ -368,6 +405,12 @@ function setupCreateSubnetMock(client, provider, servers) { {subnet: {name: 'create-test-ids2'}}) .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/subnets', + {subnet: {name: 'create-test-ids2'}}) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupRefreshSubnetMock(client, provider, servers, subnet) { @@ -381,6 +424,11 @@ function setupRefreshSubnetMock(client, provider, servers, subnet) { .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', subnet.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/subnets', subnet.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupSubnetModelCreateMock(client, provider, servers) { @@ -396,6 +444,12 @@ function setupSubnetModelCreateMock(client, provider, servers) { {subnet: {name: 'model created network'}}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/subnets', + {subnet: {name: 'model created network'}}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); + } } function setupGetSubnetMock(client, provider, servers, currentSubnet) { @@ -409,4 +463,9 @@ function setupGetSubnetMock(client, provider, servers, currentSubnet) { .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/subnets', currentSubnet.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + } } From 1be40205f59d41002dbf488d0679ec8db3bbe6c5 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 11:50:58 -0800 Subject: [PATCH 234/460] Testing formatting prettiness. --- test/common/network/network-test.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 9cea26035..b7f9efd5c 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -1,4 +1,4 @@ -/* +\/* * network-test.js: Test that should be common to all providers. * * (C) 2014 Hewlett-Packard Development Company, L.P. @@ -277,7 +277,14 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ else if (provider === 'rackspace') { servers.server .put(urlJoin('/v2.0/networks', currentNetwork.id), - {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) + { + "network": { + "admin_state_up": false, + "name": "private-network", + "shared": true, + "tenant_id": "4fd44f30292945e481c7b8a0c8908869" + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } } From bafca0ddd8f00121cebd2c107969750cf235bb6b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 11:53:14 -0800 Subject: [PATCH 235/460] Fixing typo. --- test/common/network/network-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index b7f9efd5c..ceee33dea 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -1,4 +1,4 @@ -\/* +/* * network-test.js: Test that should be common to all providers. * * (C) 2014 Hewlett-Packard Development Company, L.P. From 8e515bc8531f3039cfc83d2b4cd5fcbabfc22e8b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 11:55:05 -0800 Subject: [PATCH 236/460] Slight difference in pretty formatting. --- test/common/network/network-test.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index ceee33dea..a2c3d526a 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -276,15 +276,14 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ } else if (provider === 'rackspace') { servers.server - .put(urlJoin('/v2.0/networks', currentNetwork.id), - { - "network": { - "admin_state_up": false, - "name": "private-network", - "shared": true, - "tenant_id": "4fd44f30292945e481c7b8a0c8908869" - } - }) + .put(urlJoin('/v2.0/networks', currentNetwork.id), { + "network": { + "admin_state_up": false, + "name": "private-network", + "shared": true, + "tenant_id": "4fd44f30292945e481c7b8a0c8908869" + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } } From b883b3fa27b0d745cd2fae25044d49bad30a95fd Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 12:07:59 -0800 Subject: [PATCH 237/460] Prettifying JSON representations so they are more readable --- test/common/network/network-test.js | 62 +++++++++++---- test/common/network/port-test.js | 99 ++++++++++++++++++------ test/common/network/subnet-test.js | 114 ++++++++++++++++++++-------- 3 files changed, 202 insertions(+), 73 deletions(-) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index a2c3d526a..634c89b49 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -264,14 +264,26 @@ function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server - .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id), - {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) + .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id), { + "network": { + "admin_state_up": false, + "name": "private-network", + "shared": true, + "tenant_id": "4fd44f30292945e481c7b8a0c8908869" + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } else if (provider === 'hp') { servers.server - .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id), - {"network":{"admin_state_up":false,"name":"private-network","shared":true,"tenant_id":"4fd44f30292945e481c7b8a0c8908869"}}) + .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id), { + "network": { + "admin_state_up": false, + "name": "private-network", + "shared": true, + "tenant_id": "4fd44f30292945e481c7b8a0c8908869" + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } else if (provider === 'rackspace') { @@ -384,20 +396,29 @@ function setupNetworksMock(client, provider, servers) { function setupNetworkMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', - {network: {name: 'create-test-ids2'}}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', { + network: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); } else if (provider === 'hp') { servers.server - .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', - {network: {name: 'create-test-ids2'}}) + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', { + network: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); } else if (provider === 'rackspace') { servers.server - .post('/v2.0/networks', - {network: {name: 'create-test-ids2'}}) + .post('/v2.0/networks', { + network: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); } } @@ -423,20 +444,29 @@ function setupRefreshNetworkMock(client, provider, servers, network) { function setupNetworkModelCreateMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', - {network: {name: 'model created network'}}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', { + network: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); } else if (provider === 'hp') { servers.server - .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', - {network: {name: 'model created network'}}) + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', { + network: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/network.json'); } else if (provider === 'rackspace') { servers.server - .post('/v2.0/networks', - {network: {name: 'model created network'}}) + .post('/v2.0/networks', { + network: { + name: 'model created network' + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); } } diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index f995ad525..dc728f297 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -266,28 +266,61 @@ function setupDestroyPortMock(client, provider, servers, currentPort){ function setupUpdatePortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server - .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id), - {"port":{"status":"ACTIVE","name":"my_port","admin_state_up":false,"mac_address":"fa:16:3e:58:42:ed", - "fixed_ips":[{"subnet_id":"008ba151-0b8c-4a67-98b5-0d2b87666062","ip_address":"172.24.4.2"}], - "security_groups":[],"network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3"} + .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id), { + "port": { + "status": "ACTIVE", + "name": "my_port", + "admin_state_up": false, + "mac_address": "fa:16:3e:58:42:ed", + "fixed_ips": [ + { + "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", + "ip_address":"172.24.4.2" + } + ], + "security_groups":[], + "network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3" + } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } else if (provider === 'hp') { servers.server - .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id), - {"port":{"status":"ACTIVE","name":"my_port","admin_state_up":false,"mac_address":"fa:16:3e:58:42:ed", - "fixed_ips":[{"subnet_id":"008ba151-0b8c-4a67-98b5-0d2b87666062","ip_address":"172.24.4.2"}], - "security_groups":[],"network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3"} + .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id), { + "port": { + "status": "ACTIVE", + "name": "my_port", + "admin_state_up": false, + "mac_address": "fa:16:3e:58:42:ed", + "fixed_ips": [ + { + "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", + "ip_address":"172.24.4.2" + } + ], + "security_groups":[], + "network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3" + } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } else if (provider === 'rackspace') { servers.server - .put(urlJoin('/v2.0/ports', currentPort.id), - {"port":{"status":"ACTIVE","name":"my_port","admin_state_up":false,"mac_address":"fa:16:3e:58:42:ed", - "fixed_ips":[{"subnet_id":"008ba151-0b8c-4a67-98b5-0d2b87666062","ip_address":"172.24.4.2"}], - "security_groups":[],"network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3"} + .put(urlJoin('/v2.0/ports', currentPort.id), { + "port": { + "status": "ACTIVE", + "name": "my_port", + "admin_state_up": false, + "mac_address": "fa:16:3e:58:42:ed", + "fixed_ips": [ + { + "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", + "ip_address":"172.24.4.2" + } + ], + "security_groups":[], + "network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3" + } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); } @@ -389,20 +422,29 @@ function setupPortsMock(client, provider, servers) { function setupCreatePortMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', - {port: {name: 'create-test-ids2'}}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', { + port: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); } else if (provider === 'hp') { servers.server - .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', - {port: {name: 'create-test-ids2'}}) + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', { + port: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); } else if (provider === 'rackspace') { servers.server - .post('/v2.0/ports', - {port: {name: 'create-test-ids2'}}) + .post('/v2.0/ports', { + port: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); } } @@ -428,20 +470,29 @@ function setupRefreshPortMock(client, provider, servers, port) { function setupPortModelCreateMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', - {port: {name: 'model created network'}}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', { + port: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); } else if (provider === 'hp') { servers.server - .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', - {port: {name: 'model created network'}}) + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', { + port: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); } else if (provider === 'rackspace') { servers.server - .post('/v2.0/ports', - {port: {name: 'model created network'}}) + .post('/v2.0/ports', { + port: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index acf2052f5..c74dffbba 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -266,35 +266,65 @@ function setupDestroySubnetMock(client, provider, servers, currentSubnet){ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server - .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id), - {"subnet":{"name":"my_subnet", - "network_id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id":"4fd44f30292945e481c7b8a0c8908869", - "allocation_pools":[{"start":"192.0.0.2","end":"192.255.255.254"}], - "gateway_ip":"192.0.0.1","ip_version":4,"cidr":"192.0.0.0/8", - "enable_dhcp":false}}) + .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id), { + "subnet": { + "name": "my_subnet", + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "gateway_ip": "192.0.0.1", + "ip_version": 4, + "cidr": "192.0.0.0/8", + "enable_dhcp": false + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } else if (provider === 'hp') { servers.server - .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id), - {"subnet":{"name":"my_subnet", - "network_id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id":"4fd44f30292945e481c7b8a0c8908869", - "allocation_pools":[{"start":"192.0.0.2","end":"192.255.255.254"}], - "gateway_ip":"192.0.0.1","ip_version":4,"cidr":"192.0.0.0/8", - "enable_dhcp":false}}) + .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id), { + "subnet": { + "name": "my_subnet", + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "gateway_ip": "192.0.0.1", + "ip_version": 4, + "cidr": "192.0.0.0/8", + "enable_dhcp": false + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } else if (provider === 'rackspace') { servers.server - .put(urlJoin('/v2.0/subnets', currentSubnet.id), - {"subnet":{"name":"my_subnet", - "network_id":"d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id":"4fd44f30292945e481c7b8a0c8908869", - "allocation_pools":[{"start":"192.0.0.2","end":"192.255.255.254"}], - "gateway_ip":"192.0.0.1","ip_version":4,"cidr":"192.0.0.0/8", - "enable_dhcp":false}}) + .put(urlJoin('/v2.0/subnets', currentSubnet.id), { + "subnet": { + "name": "my_subnet", + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "gateway_ip": "192.0.0.1", + "ip_version": 4, + "cidr": "192.0.0.0/8", + "enable_dhcp": false + } + }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); } } @@ -395,20 +425,29 @@ function setupSubnetsMock(client, provider, servers) { function setupCreateSubnetMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', - {subnet: {name: 'create-test-ids2'}}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', { + subnet: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); } else if (provider === 'hp') { servers.server - .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', - {subnet: {name: 'create-test-ids2'}}) + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', { + subnet: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); } else if (provider === 'rackspace') { servers.server - .post('/v2.0/subnets', - {subnet: {name: 'create-test-ids2'}}) + .post('/v2.0/subnets', { + subnet: { + name: 'create-test-ids2' + } + }) .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); } } @@ -434,20 +473,29 @@ function setupRefreshSubnetMock(client, provider, servers, subnet) { function setupSubnetModelCreateMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', - {subnet: {name: 'model created network'}}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', { + subnet: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); } else if (provider === 'hp') { servers.server - .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', - {subnet: {name: 'model created network'}}) + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', { + subnet: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); } else if (provider === 'rackspace') { servers.server - .post('/v2.0/subnets', - {subnet: {name: 'model created network'}}) + .post('/v2.0/subnets', { + subnet: { + name: 'model created network' + } + }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); } } From 3bd764ef4ec15868054a6a25638fbba05be89e1e Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 12:15:03 -0800 Subject: [PATCH 238/460] Extracting variable for '/networks' --- lib/pkgcloud/openstack/network/client/networks.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 5217896b5..262910a3c 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -12,6 +12,8 @@ var async = require('async'), urlJoin = require('url-join'), _ = require('underscore'); +var networksResourcePath = '/networks'; + /** * client.getNetworks * @@ -29,7 +31,7 @@ exports.getNetworks = function (options, callback) { } var getNetworkOpts = { - path: '/networks' + path: networksResourcePath }; this._request(getNetworkOpts, function (err, body) { @@ -59,7 +61,7 @@ exports.getNetwork = function (network, callback) { self = this; self.emit('log::trace', 'Getting details for network', networkId); this._request({ - path: urlJoin('/networks', networkId), + path: urlJoin(networksResourcePath, networkId), method: 'GET' }, function (err, body, res) { if (err) { @@ -91,7 +93,7 @@ exports.createNetwork = function (options, callback) { var createNetworkOpts = { method: 'POST', - path: '/networks', + path: networksResourcePath, body: { 'network' : network} }; @@ -118,7 +120,7 @@ exports.updateNetwork = function (network, callback) { var updateNetworkOpts = { method: 'PUT', - path: urlJoin('/networks', networkId), + path: urlJoin(networksResourcePath, networkId), contentType: 'application/json', body: { 'network' : networkToUpdate} }; @@ -144,7 +146,7 @@ exports.destroyNetwork = function (network, callback) { self = this; self.emit('log::trace', 'Deleting network', networkId); this._request({ - path: urlJoin('/networks',networkId), + path: urlJoin(networksResourcePath,networkId), method: 'DELETE' }, function (err, body, res) { if (err) { From ac68bba18869ab445992e2f427e4c1f09c7541a3 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 12:15:13 -0800 Subject: [PATCH 239/460] Extracting variable for '/ports' --- lib/pkgcloud/openstack/network/client/ports.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index 32e2e916e..40445a2e3 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -12,6 +12,8 @@ var async = require('async'), urlJoin = require('url-join'), _ = require('underscore'); +var portsResourcePath = '/ports'; + /** * client.getPorts * @@ -29,7 +31,7 @@ exports.getPorts = function (options, callback) { } var getPortOpts = { - path: '/ports' + path: portsResourcePath }; this._request(getPortOpts, function (err, body) { @@ -59,7 +61,7 @@ exports.getPort = function (port, callback) { self = this; self.emit('log::trace', 'Getting details for port', portId); this._request({ - path: urlJoin('/ports', portId), + path: urlJoin(portsResourcePath, portId), method: 'GET' }, function (err, body, res) { if (err) { @@ -91,7 +93,7 @@ exports.createPort = function (options, callback) { var createPortOpts = { method: 'POST', - path: '/ports', + path: portsResourcePath, body: { 'port' : port} }; @@ -118,7 +120,7 @@ exports.updatePort = function (port, callback) { port = _convertPortToWireFormat(port); var updatePortOpts = { method: 'PUT', - path: urlJoin('/ports', portId), + path: urlJoin(portsResourcePath, portId), contentType: 'application/json', body: { 'port' : port} }; @@ -144,7 +146,7 @@ exports.destroyPort = function (port, callback) { self = this; self.emit('log::trace', 'Deleting port', portId); this._request({ - path: urlJoin('/ports',portId), + path: urlJoin(portsResourcePath,portId), method: 'DELETE' }, function (err, body, res) { if (err) { From ebf9c0fcb3dc90591d2a6bec3ba594c2f8027a48 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 12:15:20 -0800 Subject: [PATCH 240/460] Extracting variable for '/subnets' --- lib/pkgcloud/openstack/network/client/subnets.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index a305173f0..4bff2d4f8 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -12,6 +12,8 @@ var async = require('async'), urlJoin = require('url-join'), _ = require('underscore'); +var subnetsResourcePath = '/subnets'; + /** * client.getSubnets * @@ -32,7 +34,7 @@ exports.getSubnets = function (options, callback) { } var getSubnetOpts = { - path: '/subnets', + path: subnetsResourcePath, }; this._request(getSubnetOpts, function (err, body) { @@ -62,7 +64,7 @@ exports.getSubnet = function (subnet, callback) { self = this; self.emit('log::trace', 'Getting details for subnet', subnetId); this._request({ - path: urlJoin('/subnets', subnetId), + path: urlJoin(subnetsResourcePath, subnetId), method: 'GET' }, function (err, body, res) { if (err) { @@ -94,7 +96,7 @@ exports.createSubnet = function (options, callback) { var createSubnetOpts = { method: 'POST', - path: '/subnets', + path: subnetsResourcePath, body: { 'subnet' : subnet} }; @@ -121,7 +123,7 @@ exports.updateSubnet = function (subnet, callback) { var updateSubnetOpts = { method: 'PUT', - path: urlJoin('/subnets', subnetId), + path: urlJoin(subnetsResourcePath, subnetId), contentType: 'application/json', body: { 'subnet' : subnetToUpdate} }; @@ -147,7 +149,7 @@ exports.destroySubnet = function (subnet, callback) { self = this; self.emit('log::trace', 'Deleting subnet', subnetId); this._request({ - path: urlJoin('/subnets',subnetId), + path: urlJoin(subnetsResourcePath,subnetId), method: 'DELETE' }, function (err, body, res) { if (err) { From 19eb62bff7fd3d5302090a22abdffd8cfa8678f8 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 12:19:31 -0800 Subject: [PATCH 241/460] Removing mock response bodies for 204 responses --- test/common/network/network-test.js | 12 ++++++------ test/common/network/port-test.js | 12 ++++++------ test/common/network/subnet-test.js | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 634c89b49..98516d6d0 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -247,17 +247,17 @@ function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/networks', currentNetwork.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } } @@ -304,17 +304,17 @@ function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwor if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/networks', currentNetwork.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } } diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index dc728f297..140faeb23 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -249,17 +249,17 @@ function setupDestroyPortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/ports', currentPort.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } } @@ -330,17 +330,17 @@ function setupModelDestroyedPortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/ports', currentPort.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index c74dffbba..d51e0426f 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -249,17 +249,17 @@ function setupDestroySubnetMock(client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } } @@ -333,17 +333,17 @@ function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet) if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) - .reply(204, helpers.getOpenstackAuthResponse()); + .reply(204) } } From b6846aedc6953e60c41819a81c1177fa7bb4b521 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 24 Nov 2014 13:15:45 -0800 Subject: [PATCH 242/460] Adding Rackspace fixtures --- test/common/network/network-test.js | 12 ++++---- test/common/network/port-test.js | 12 ++++---- test/common/network/subnet-test.js | 12 ++++---- test/fixtures/rackspace/network.json | 11 ++++++++ test/fixtures/rackspace/networks.json | 24 ++++++++++++++++ test/fixtures/rackspace/port.json | 20 ++++++++++++++ test/fixtures/rackspace/ports.json | 40 +++++++++++++++++++++++++++ test/fixtures/rackspace/subnet.json | 20 ++++++++++++++ test/fixtures/rackspace/subnets.json | 40 +++++++++++++++++++++++++++ 9 files changed, 173 insertions(+), 18 deletions(-) create mode 100644 test/fixtures/rackspace/network.json create mode 100644 test/fixtures/rackspace/networks.json create mode 100644 test/fixtures/rackspace/port.json create mode 100644 test/fixtures/rackspace/ports.json create mode 100644 test/fixtures/rackspace/subnet.json create mode 100644 test/fixtures/rackspace/subnets.json diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 98516d6d0..4fc370b4f 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -296,7 +296,7 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ "tenant_id": "4fd44f30292945e481c7b8a0c8908869" } }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } } @@ -389,7 +389,7 @@ function setupNetworksMock(client, provider, servers) { servers.server .get('/v2.0/networks') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/networks.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/networks.json'); } } @@ -419,7 +419,7 @@ function setupNetworkMock(client, provider, servers) { name: 'create-test-ids2' } }) - .replyWithFile(201, __dirname + '/../../fixtures/openstack/network.json'); + .replyWithFile(201, __dirname + '/../../fixtures/rackspace/network.json'); } } @@ -437,7 +437,7 @@ function setupRefreshNetworkMock(client, provider, servers, network) { else if (provider === 'rackspace') { servers.server .get(urlJoin('/v2.0/networks',network.id)) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } } @@ -467,7 +467,7 @@ function setupNetworkModelCreateMock(client, provider, servers) { name: 'model created network' } }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } } @@ -485,7 +485,7 @@ function setupGetNetworkMock(client, provider, servers) { else if (provider === 'rackspace') { servers.server .get('/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } } diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 140faeb23..12f9f9a3b 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -322,7 +322,7 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ "network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3" } }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } } @@ -415,7 +415,7 @@ function setupPortsMock(client, provider, servers) { servers.server .get('/v2.0/ports') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/ports.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/ports.json'); } } @@ -445,7 +445,7 @@ function setupCreatePortMock(client, provider, servers) { name: 'create-test-ids2' } }) - .replyWithFile(201, __dirname + '/../../fixtures/openstack/port.json'); + .replyWithFile(201, __dirname + '/../../fixtures/rackspace/port.json'); } } @@ -463,7 +463,7 @@ function setupRefreshPortMock(client, provider, servers, port) { else if (provider === 'rackspace') { servers.server .get(urlJoin('/v2.0/ports', port.id)) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } } @@ -493,7 +493,7 @@ function setupPortModelCreateMock(client, provider, servers) { name: 'model created network' } }) - .replyWithFile(202, __dirname + '/../../fixtures/openstack/port.json'); + .replyWithFile(202, __dirname + '/../../fixtures/rackspace/port.json'); } } @@ -511,6 +511,6 @@ function setupGetPortMock(client, provider, servers, currentPort) { else if (provider === 'rackspace') { servers.server .get(urlJoin('/v2.0/ports', currentPort.id)) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index d51e0426f..191b188d4 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -325,7 +325,7 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ "enable_dhcp": false } }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } } @@ -418,7 +418,7 @@ function setupSubnetsMock(client, provider, servers) { servers.server .get('/v2.0/subnets') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnets.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnets.json'); } } @@ -448,7 +448,7 @@ function setupCreateSubnetMock(client, provider, servers) { name: 'create-test-ids2' } }) - .replyWithFile(201, __dirname + '/../../fixtures/openstack/subnet.json'); + .replyWithFile(201, __dirname + '/../../fixtures/rackspace/subnet.json'); } } @@ -466,7 +466,7 @@ function setupRefreshSubnetMock(client, provider, servers, subnet) { else if (provider === 'rackspace') { servers.server .get(urlJoin('/v2.0/subnets', subnet.id)) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } } @@ -496,7 +496,7 @@ function setupSubnetModelCreateMock(client, provider, servers) { name: 'model created network' } }) - .replyWithFile(202, __dirname + '/../../fixtures/openstack/subnet.json'); + .replyWithFile(202, __dirname + '/../../fixtures/rackspace/subnet.json'); } } @@ -514,6 +514,6 @@ function setupGetSubnetMock(client, provider, servers, currentSubnet) { else if (provider === 'rackspace') { servers.server .get(urlJoin('/v2.0/subnets', currentSubnet.id)) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } } diff --git a/test/fixtures/rackspace/network.json b/test/fixtures/rackspace/network.json new file mode 100644 index 000000000..ca228f174 --- /dev/null +++ b/test/fixtures/rackspace/network.json @@ -0,0 +1,11 @@ +{ + "network": { + "name": "private-network", + "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "admin_state_up": false, + "status": "ACTIVE", + "shared": true, + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "subnets": [] + } +} diff --git a/test/fixtures/rackspace/networks.json b/test/fixtures/rackspace/networks.json new file mode 100644 index 000000000..8fb5b53e5 --- /dev/null +++ b/test/fixtures/rackspace/networks.json @@ -0,0 +1,24 @@ +{ + "networks":[ + { + "name": "private-network", + "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "admin_state_up": true, + "status": "ACTIVE", + "shared": false, + "tenant_id": "123456", + "subnets": [ + "96c1b28c-7be1-4035-b41f-247a8d81a61d" + ] + }, + { + "name": "private", + "id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "admin_state_up": true, + "status": "ACTIVE", + "shared": false, + "tenant_id": "123456", + "subnets": [] + } + ] +} diff --git a/test/fixtures/rackspace/port.json b/test/fixtures/rackspace/port.json new file mode 100644 index 000000000..65d222feb --- /dev/null +++ b/test/fixtures/rackspace/port.json @@ -0,0 +1,20 @@ +{ + "port": { + "status": "ACTIVE", + "name": "my_port", + "admin_state_up": true, + "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3", + "tenant_id": "", + "device_owner": "network:router_gateway", + "mac_address": "fa:16:3e:58:42:ed", + "fixed_ips": [ + { + "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", + "ip_address": "172.24.4.2" + } + ], + "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b", + "security_groups": [], + "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824" + } +} diff --git a/test/fixtures/rackspace/ports.json b/test/fixtures/rackspace/ports.json new file mode 100644 index 000000000..8a1406a81 --- /dev/null +++ b/test/fixtures/rackspace/ports.json @@ -0,0 +1,40 @@ +{ + "ports": [ + { + "status": "ACTIVE", + "name": "", + "admin_state_up": true, + "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3", + "tenant_id": "", + "device_owner": "network:router_gateway", + "mac_address": "fa:16:3e:58:42:ed", + "fixed_ips": [ + { + "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", + "ip_address": "172.24.4.2" + } + ], + "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b", + "security_groups": [], + "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824" + }, + { + "status": "ACTIVE", + "name": "", + "admin_state_up": true, + "network_id": "f27aa545-cbdd-4907-b0c6-c9e8b039dcc2", + "tenant_id": "d397de8a63f341818f198abb0966f6f3", + "device_owner": "network:router_interface", + "mac_address": "fa:16:3e:bb:3c:e4", + "fixed_ips": [ + { + "subnet_id": "288bf4a1-51ba-43b6-9d0a-520e9005db17", + "ip_address": "10.0.0.1" + } + ], + "id": "f71a6703-d6de-4be1-a91a-a570ede1d159", + "security_groups": [], + "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824" + } + ] +} diff --git a/test/fixtures/rackspace/subnet.json b/test/fixtures/rackspace/subnet.json new file mode 100644 index 000000000..b369ffe98 --- /dev/null +++ b/test/fixtures/rackspace/subnet.json @@ -0,0 +1,20 @@ +{ + "subnet": { + "name": "my_subnet", + "enable_dhcp": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.0.0.1", + "cidr": "192.0.0.0/8", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + } +} diff --git a/test/fixtures/rackspace/subnets.json b/test/fixtures/rackspace/subnets.json new file mode 100644 index 000000000..2c5ba82ab --- /dev/null +++ b/test/fixtures/rackspace/subnets.json @@ -0,0 +1,40 @@ +{ + "subnets": [ + { + "name": "private-subnet", + "enable_dhcp": true, + "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324", + "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "10.0.0.2", + "end": "10.0.0.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "10.0.0.1", + "cidr": "10.0.0.0/24", + "id": "08eae331-0402-425a-923c-34f7cfe39c1b" + }, + { + "name": "my_subnet", + "enable_dhcp": true, + "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", + "tenant_id": "4fd44f30292945e481c7b8a0c8908869", + "dns_nameservers": [], + "allocation_pools": [ + { + "start": "192.0.0.2", + "end": "192.255.255.254" + } + ], + "host_routes": [], + "ip_version": 4, + "gateway_ip": "192.0.0.1", + "cidr": "192.0.0.0/8", + "id": "54d6f61d-db07-451c-9ab3-b9609b6b6f0b" + } + ] +} From da50e061a83dc01770208bba49ec96c1b9d3a05a Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 25 Nov 2014 10:13:28 -0800 Subject: [PATCH 243/460] Adding missing semicolons --- lib/pkgcloud/hp/network/client/index.js | 2 +- lib/pkgcloud/openstack/network/client/index.js | 2 +- test/common/network/network-test.js | 14 +++++++------- test/common/network/port-test.js | 14 +++++++------- test/common/network/subnet-test.js | 14 +++++++------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js index 8eb979b37..0b2db1787 100644 --- a/lib/pkgcloud/hp/network/client/index.js +++ b/lib/pkgcloud/hp/network/client/index.js @@ -41,7 +41,7 @@ _.extend(Client.prototype, NetworkClient.prototype); */ Client.prototype._getUrl = function(options) { if (options.path) { - options.path = urlJoin('v2.0', options.path) + options.path = urlJoin('v2.0', options.path); } return NetworkClient.prototype._getUrl.call(this, options); }; diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index 074ebd987..9aabbe98b 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -41,7 +41,7 @@ _.extend(Client.prototype, NetworkClient.prototype); */ Client.prototype._getUrl = function(options) { if (options.path) { - options.path = urlJoin('v2.0', options.path) + options.path = urlJoin('v2.0', options.path); } return NetworkClient.prototype._getUrl.call(this, options); }; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 4fc370b4f..8e5cdbe2c 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -49,7 +49,7 @@ providers.filter(function (provider) { function (next) { authServer.listen(12346, next); } - ], done) + ], done); }); it('the getNetworks() function should return a list of networks', function(done) { @@ -247,17 +247,17 @@ function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) - .reply(204) + .reply(204); } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) - .reply(204) + .reply(204); } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/networks', currentNetwork.id)) - .reply(204) + .reply(204); } } @@ -304,17 +304,17 @@ function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwor if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) - .reply(204) + .reply(204); } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id)) - .reply(204) + .reply(204); } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/networks', currentNetwork.id)) - .reply(204) + .reply(204); } } diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 12f9f9a3b..0d002300b 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -49,7 +49,7 @@ providers.filter(function (provider) { function (next) { authServer.listen(12346, next); } - ], done) + ], done); }); it('the getPorts() function should return a list of ports', function(done) { @@ -249,17 +249,17 @@ function setupDestroyPortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) - .reply(204) + .reply(204); } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) - .reply(204) + .reply(204); } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/ports', currentPort.id)) - .reply(204) + .reply(204); } } @@ -330,17 +330,17 @@ function setupModelDestroyedPortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) - .reply(204) + .reply(204); } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id)) - .reply(204) + .reply(204); } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/ports', currentPort.id)) - .reply(204) + .reply(204); } } diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index 191b188d4..32f9f82b7 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -49,7 +49,7 @@ providers.filter(function (provider) { function (next) { authServer.listen(12346, next); } - ], done) + ], done); }); it('the getSubnets() function should return a list of subnets', function(done) { @@ -249,17 +249,17 @@ function setupDestroySubnetMock(client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) - .reply(204) + .reply(204); } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) - .reply(204) + .reply(204); } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) - .reply(204) + .reply(204); } } @@ -333,17 +333,17 @@ function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet) if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) - .reply(204) + .reply(204); } else if (provider === 'hp') { servers.server .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id)) - .reply(204) + .reply(204); } else if (provider === 'rackspace') { servers.server .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) - .reply(204) + .reply(204); } } From 7bead68f87fa623f0f171c691cf1a2c4f95b7a91 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 26 Nov 2014 15:07:53 -0800 Subject: [PATCH 244/460] CHANGELOG ahead of v1.1.0 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 589225017..201d5cf88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.1.0 +* Added support for Google Cloud Storage +* Added support for Rackspace Cloud Networks + ## v1.0.3 * Adding support for Openstack Trove, and adding HP, rackspace providers From fc06673275984d9a8a6c0bcb545089542704dd82 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 26 Nov 2014 15:09:49 -0800 Subject: [PATCH 245/460] 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 810ab1544..9b236300e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.0.3", + "version": "1.1.0", "author": "Nodejitsu Inc ", "contributors": [ { From f4ae0602a96f7839c6be77e4ed2d67a954ce8ccb Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 06:56:27 -0800 Subject: [PATCH 246/460] Adding jshint linter --- Makefile | 3 +++ package.json | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index aac56eae4..40145aaa3 100644 --- a/Makefile +++ b/Makefile @@ -31,4 +31,7 @@ test-coveralls: lib-cov ./node_modules/coveralls/bin/coveralls.js < pkgcloud.lcov rm pkgcloud.lcov pkgcloud.lcov.raw +lint: + ./node_modules/.bin/jshint --exclude-path .gitignore . + .PHONY: test diff --git a/package.json b/package.json index 810ab1544..c5d7f844c 100644 --- a/package.json +++ b/package.json @@ -72,13 +72,15 @@ "mocha": "1.21.x", "should": "4.0.x", "mocha-lcov-reporter": "0.0.1", - "coveralls": "2.x.x" + "coveralls": "2.x.x", + "jshint": "2.x.x" }, "main": "./lib/pkgcloud", "scripts": { "test": "make test", "test-cov": "make test-cov", - "test-coveralls": "make test-coveralls" + "test-coveralls": "make test-coveralls", + "lint": "make lint" }, "engines": { "node": ">=0.10.x" From 66370a72e8b7c46746c40dcb5d2428f958206cc2 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 06:56:44 -0800 Subject: [PATCH 247/460] Adding jshint config file to do minimal linting for now --- .jshintrc | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..9def0b7dd --- /dev/null +++ b/.jshintrc @@ -0,0 +1,85 @@ +{ + "maxerr" : 50, // {int} Maximum error before stopping + + // Enforcing + "bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.) + "camelcase" : false, // true: Identifiers must be in camelCase + "curly" : false, // true: Require {} for every new block or scope + "eqeqeq" : false, // true: Require triple equals (===) for comparison + "forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() + "freeze" : false, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. + "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` + "indent" : false, // {int} Number of spaces to use for indentation + "latedef" : false, // true: Require variables/functions to be defined before being used + "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` + "noarg" : false, // true: Prohibit use of `arguments.caller` and `arguments.callee` + "noempty" : false, // true: Prohibit use of empty blocks + "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. + "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) + "plusplus" : false, // true: Prohibit use of `++` & `--` + "quotmark" : false, // Quotation mark consistency: + // false : do nothing (default) + // true : ensure whatever is used is consistent + // "single" : require single quotes + // "double" : require double quotes + "undef" : false, // true: Require all non-global variables to be declared (prevents global leaks) + "unused" : false, // true: Require all defined variables be used + "strict" : false, // true: Requires all functions run in ES5 Strict Mode + "maxparams" : false, // {int} Max number of formal params allowed per function + "maxdepth" : false, // {int} Max depth of nested blocks (within functions) + "maxstatements" : false, // {int} Max number statements per function + "maxcomplexity" : false, // {int} Max cyclomatic complexity per function + "maxlen" : false, // {int} Max number of characters per line + + // Relaxing + "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) + "boss" : true, // true: Tolerate assignments where comparisons would be expected + "debug" : true, // true: Allow debugger statements e.g. browser breakpoints. + "eqnull" : true, // true: Tolerate use of `== null` + "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) + "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) + "moz" : true, // true: Allow Mozilla specific syntax (extends and overrides esnext features) + // (ex: `for each`, multiple try/catch, function expression…) + "evil" : true, // true: Tolerate use of `eval` and `new Function()` + "expr" : true, // true: Tolerate `ExpressionStatement` as Programs + "funcscope" : true, // true: Tolerate defining variables inside control statements + "globalstrict" : true, // true: Allow global "use strict" (also enables 'strict') + "iterator" : true, // true: Tolerate using the `__iterator__` property + "lastsemic" : true, // true: Tolerate omitting a semicolon for the last statement of a 1-line block + "laxbreak" : true, // true: Tolerate possibly unsafe line breakings + "laxcomma" : true, // true: Tolerate comma-first style coding + "loopfunc" : true, // true: Tolerate functions being defined in loops + "multistr" : true, // true: Tolerate multi-line strings + "noyield" : true, // true: Tolerate generator functions with no yield statement in them. + "notypeof" : true, // true: Tolerate invalid typeof operator values + "proto" : true, // true: Tolerate using the `__proto__` property + "scripturl" : true, // true: Tolerate script-targeted URLs + "shadow" : true, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` + "sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation + "supernew" : true, // true: Tolerate `new function () { ... };` and `new Object;` + "validthis" : true, // true: Tolerate using this in a non-constructor function + "-W086" : true, // true: allow fall-through; see https://github.com/jshint/jshint/issues/18 + + // Environments + "browser" : false, // Web Browser (window, document, etc) + "browserify" : false, // Browserify (node.js code in the browser) + "couch" : false, // CouchDB + "devel" : false, // Development/debugging (alert, confirm, etc) + "dojo" : false, // Dojo Toolkit + "jasmine" : false, // Jasmine + "jquery" : false, // jQuery + "mocha" : false, // Mocha + "mootools" : false, // MooTools + "node" : true, // Node.js + "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) + "prototypejs" : false, // Prototype and Scriptaculous + "qunit" : false, // QUnit + "rhino" : false, // Rhino + "shelljs" : false, // ShellJS + "worker" : false, // Web Workers + "wsh" : false, // Windows Scripting Host + "yui" : false, // Yahoo User Interface + + // Custom Globals + "globals" : {} // additional predefined global variables +} From 0db3325daa6197e36793fbe79718f3c563187def Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 06:57:46 -0800 Subject: [PATCH 248/460] Removing duplicate key --- test/openstack/orchestration/create-stacks-test.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/openstack/orchestration/create-stacks-test.js b/test/openstack/orchestration/create-stacks-test.js index ec9e53d0b..8ebe06a87 100644 --- a/test/openstack/orchestration/create-stacks-test.js +++ b/test/openstack/orchestration/create-stacks-test.js @@ -74,10 +74,9 @@ describe('pkgcloud/openstack/orchestration/stacks[createStacks]', function () { hockInstance .post('/v1/72e90ecb69c44d0296072ea39e537041/stacks', { 'stack_name': 'stack-test', - environment: '{}', + environment: JSON.stringify({ parameters: { terms: true } }), 'timeout_mins': 30, - template_url: 'https://raw.githubusercontent.com/rackspace-orchestration-templates/minecraft/master/minecraft-server.yaml', - environment: JSON.stringify({ parameters: { terms: true } }) + template_url: 'https://raw.githubusercontent.com/rackspace-orchestration-templates/minecraft/master/minecraft-server.yaml' }) .reply(201, { stack: { id: 'b39ecc51-8ac0-4396-a178-17fdc63f5d40', From e7097e3f6835c4bbab0fbe5c1a2bf230f03d6b57 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 06:58:03 -0800 Subject: [PATCH 249/460] Using stricter equality check (per linter recommendation) --- test/rackspace/storage/container-test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index 79475ee0f..e93a08a84 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -489,8 +489,8 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); - (container.metadata['web-index'] == undefined).should.be.true; - (container.metadata['web-error'] == undefined).should.be.true; + (container.metadata['web-index'] === undefined).should.be.true; + (container.metadata['web-error'] === undefined).should.be.true; container.setStaticWebsite({indexFile: 'index.htm', errorFile: 'error.htm'}, function (err, container) { should.not.exist(err); @@ -564,8 +564,8 @@ describe('pkgcloud/rackspace/storage/containers', function () { should.exist(container); container.should.be.instanceof(Container); - (container.metadata['web-index'] == undefined).should.be.true; - (container.metadata['web-error'] == undefined).should.be.true; + (container.metadata['web-index'] === undefined).should.be.true; + (container.metadata['web-error'] === undefined).should.be.true; hockInstance && hockInstance.done(); done(); From 1668ee880ab69bc9a17085e0cb56a9e8faf5ebd3 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 07:00:43 -0800 Subject: [PATCH 250/460] Using a function statement instead of function declaration inside function (per linter recommendation) --- lib/pkgcloud/joyent/compute/client/servers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index 3ce979dd0..ab4b4eadc 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -155,7 +155,7 @@ exports.destroyServer = function destroyServer(server, callback) { if (res.statusCode === 202) { var checks = 10; var done = false; - function check() { + var check = function() { if (done) return; checks--; if (checks <= 0) return; From 5b6a02191b395b3f482473665bfcf4a697f3bb68 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 07:08:11 -0800 Subject: [PATCH 251/460] Asking linter to allow leading decimal points --- .jshintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 9def0b7dd..4c654ef8c 100644 --- a/.jshintrc +++ b/.jshintrc @@ -58,7 +58,8 @@ "sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation "supernew" : true, // true: Tolerate `new function () { ... };` and `new Object;` "validthis" : true, // true: Tolerate using this in a non-constructor function - "-W086" : true, // true: allow fall-through; see https://github.com/jshint/jshint/issues/18 + "-W086" : true, // true: Allow fall-through; see https://github.com/jshint/jshint/issues/18 + "-W008" : true, // true: Allow leading decimal point; see https://jslinterrors.com/a-leading-decimal-point-can-be-confused-with-a-dot-a // Environments "browser" : false, // Web Browser (window, document, etc) From a6cf1842de8a16245dcb5287662194d52a581f70 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 07:39:40 -0800 Subject: [PATCH 252/460] Removing extraneous semicolon --- test/mongohq/databases/databases-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mongohq/databases/databases-test.js b/test/mongohq/databases/databases-test.js index 40ab8b187..de64d2ce4 100644 --- a/test/mongohq/databases/databases-test.js +++ b/test/mongohq/databases/databases-test.js @@ -63,7 +63,7 @@ describe('pkgcloud/mongohq/databases', function () { client.remove(context.databaseId, function (err, confirm) { should.not.exist(err); should.exist(confirm); - confirm.should.equal('deleted');; + confirm.should.equal('deleted'); hockInstance && hockInstance.done(); done(); From 85c2b0f9510b7d0b2bdadcb11dc50f4edd39582c Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 08:17:02 -0800 Subject: [PATCH 253/460] Adding missing comma --- test/common/databases/errors-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/databases/errors-test.js b/test/common/databases/errors-test.js index 0edffee97..986ecc656 100644 --- a/test/common/databases/errors-test.js +++ b/test/common/databases/errors-test.js @@ -6,7 +6,7 @@ */ var should = require('should'), - helpers = require('../../helpers') + helpers = require('../../helpers'), providers = require('../../configs/providers.json'); providers.filter(function (provider) { From 8d5a68265df85ce632249c43c9623d0a358593b7 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 08:35:08 -0800 Subject: [PATCH 254/460] Removing extraneous semicolon --- lib/pkgcloud/openstack/storage/client/containers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/storage/client/containers.js b/lib/pkgcloud/openstack/storage/client/containers.js index be9374243..08f25a6b4 100644 --- a/lib/pkgcloud/openstack/storage/client/containers.js +++ b/lib/pkgcloud/openstack/storage/client/containers.js @@ -38,7 +38,7 @@ exports.getContainers = function (options, callback) { format: 'json' }, _.pick(options, ['limit', 'marker', 'end_marker'])) }; - ; + this._request(getContainerOpts, function (err, body) { if (err) { return callback(err); From 5e051dd646ff8f14b73d9d7de0b23808cc69e74b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 08:39:16 -0800 Subject: [PATCH 255/460] Adding missing comma --- lib/pkgcloud/amazon/compute/image.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/amazon/compute/image.js b/lib/pkgcloud/amazon/compute/image.js index 5edd28e83..2d276257e 100644 --- a/lib/pkgcloud/amazon/compute/image.js +++ b/lib/pkgcloud/amazon/compute/image.js @@ -6,7 +6,7 @@ */ var util = require('util'), - base = require('../../core/compute/image') + base = require('../../core/compute/image'), _ = require('underscore'); var Image = exports.Image = function Image(client, details) { @@ -25,4 +25,4 @@ Image.prototype._setProperties = function (details) { Image.prototype.toJSON = function () { return _.pick(this, ['id', 'name', 'created', 'blockDeviceMappings']); -}; \ No newline at end of file +}; From a8742e90f98cc46929624fd10c202bfc95655f4e Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 08:41:33 -0800 Subject: [PATCH 256/460] Asking contributors to run unit and lint tests --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index efe0ab59f..724ed2a39 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,8 @@ The only issues we accept are bug reports or feature requests. Bugs must be isol - Please tag your commit depending what it does (`[misc]`, `[docs]`, `[database]`, `[compute]`) - Follow the style guide in code and docs. - Your pull request should pass the tests and the `travis-ci` build. This will be reviewed by the maintainer. - + - Before making the pull request, please run the unit tests using `npm test`. + - Before making the pull request, please run the lint tests using `npm run lint`. ## Coding standards: JS From b3fce0b43d51ab040140bf29c027a7b34138da40 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 08:42:07 -0800 Subject: [PATCH 257/460] Adding a whole bunch of missing semicolons --- examples/database/rackspace.js | 4 +- examples/storage/rackspace.js | 4 +- lib/pkgcloud/amazon/compute/client/images.js | 2 +- .../amazon/storage/client/containers.js | 2 +- lib/pkgcloud/amazon/storage/client/files.js | 2 +- lib/pkgcloud/core/base/client.js | 2 +- lib/pkgcloud/joyent/compute/client/servers.js | 4 +- .../compute/client/extensions/floating-ips.js | 4 +- .../client/extensions/networks-base.js | 2 +- .../orchestration/client/templates.js | 2 +- .../openstack/storage/client/containers.js | 2 +- .../openstack/storage/client/files.js | 2 +- .../openstack/storage/storageClient.js | 2 +- lib/pkgcloud/rackspace/dns/client/zones.js | 4 +- .../loadbalancer/client/loadbalancers.js | 4 +- .../rackspace/loadbalancer/virtualip.js | 4 +- .../storage/client/cdn-containers.js | 8 ++-- test/azure/databases/test-database.js | 2 +- test/azure/storage/test-upload.js | 2 +- test/common/compute/base-test.js | 4 +- test/common/compute/meta-test.js | 6 +-- test/common/compute/server-test.js | 14 +++--- test/common/databases/databases-test.js | 4 +- test/common/databases/flavor-test.js | 8 ++-- test/common/databases/instances-test.js | 46 +++++++++---------- test/common/databases/users-test.js | 2 +- test/common/storage/base-test.js | 28 +++++------ test/common/storage/upload-test.js | 8 ++-- test/helpers/azureNock.js | 2 +- test/helpers/index.js | 6 +-- test/hp/macros.js | 12 ++--- test/hp/storage/authentication-test.js | 2 +- test/mongolab/databases/databases-test.js | 8 ++-- .../compute/client/startServer-test.js | 2 +- .../compute/client/stopServer-test.js | 2 +- test/openstack/identity/identity-test.js | 2 +- test/openstack/identity/service-test.js | 2 +- .../orchestration/create-stacks-test.js | 2 +- .../orchestration/get-stacks-test.js | 2 +- test/rackspace/blockstorage/volumes-test.js | 4 +- test/rackspace/compute/authentication-test.js | 2 +- test/rackspace/compute/image-test.js | 4 +- .../databases/authentication-test.js | 2 +- test/rackspace/macros.js | 12 ++--- test/rackspace/storage/container-test.js | 10 ++-- test/rackspace/storage/storage-object-test.js | 2 +- test/redistogo/databases/databases-test.js | 2 +- 47 files changed, 129 insertions(+), 129 deletions(-) diff --git a/examples/database/rackspace.js b/examples/database/rackspace.js index 10ca0843c..08fbc4848 100644 --- a/examples/database/rackspace.js +++ b/examples/database/rackspace.js @@ -46,5 +46,5 @@ client.getFlavors(function (err, flavors) { console.log(database); }); }); - }) -}); \ No newline at end of file + }); +}); diff --git a/examples/storage/rackspace.js b/examples/storage/rackspace.js index 3333613fc..604fa7f38 100644 --- a/examples/storage/rackspace.js +++ b/examples/storage/rackspace.js @@ -105,6 +105,6 @@ rackspace.getContainer('sample-container', function (err, container) { return; } - console.log('Container ' + container.name + ' was successfully destroyed.') + console.log('Container ' + container.name + ' was successfully destroyed.'); }); -}); \ No newline at end of file +}); diff --git a/lib/pkgcloud/amazon/compute/client/images.js b/lib/pkgcloud/amazon/compute/client/images.js index a32798062..adba2f431 100644 --- a/lib/pkgcloud/amazon/compute/client/images.js +++ b/lib/pkgcloud/amazon/compute/client/images.js @@ -79,7 +79,7 @@ exports.getImage = function getImage(image, callback) { return; } - callback(new Error('Image not found')) + callback(new Error('Image not found')); }); }; diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index aff429cb0..3b41efe1c 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -129,7 +129,7 @@ exports.destroyContainer = function (container, callback) { } function deleteFiles(files, next) { - async.forEachLimit(files, 10, destroyFile, next) + async.forEachLimit(files, 10, destroyFile, next); } function destroyFile(file, next) { diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index b94548a33..0540af2b3 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -138,7 +138,7 @@ exports.getFiles = function (container, options, callback) { } if (options.maxKeys) { - s3Options.MaxKeys = options.maxKeys + s3Options.MaxKeys = options.maxKeys; } self.s3.listObjects(s3Options, function(err, data) { diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index ccc81ca27..bd50e8380 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -165,7 +165,7 @@ Client.prototype._defaultRequestHandler = function (callback) { }); callback(err, body, res); - } + }; }; Client.prototype._parseError = function(response, body) { diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index ab4b4eadc..d89b72108 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -179,7 +179,7 @@ exports.destroyServer = function destroyServer(server, callback) { }); setTimeout(check, 5000); - } + }; check(); return; @@ -261,4 +261,4 @@ exports.renameServer = function renameServer(server, name, callback) { errs.create({ message: 'Not supported by Joyent.' }), callback ); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js b/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js index ff44c9bb5..00fd6b929 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js @@ -115,7 +115,7 @@ exports.deallocateFloatingIp = function (floatingIp, callback) { * @returns {*} */ exports.addFloatingIp = function (server, floatingIp, callback) { - var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp + var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp; return this._doServerAction(server, { addFloatingIp: { @@ -137,7 +137,7 @@ exports.addFloatingIp = function (server, floatingIp, callback) { * @returns {*} */ exports.removeFloatingIp = function (server, floatingIp, callback) { - var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp + var floatingIpAddress = (typeof floatingIp === 'object') ? floatingIp.ip : floatingIp; return this._doServerAction(server, { removeFloatingIp: { diff --git a/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js b/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js index 393e21244..128766746 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js @@ -236,7 +236,7 @@ exports.createNetworkExtension = function(prefix) { return callback(err); }); } - } + }; }; diff --git a/lib/pkgcloud/openstack/orchestration/client/templates.js b/lib/pkgcloud/openstack/orchestration/client/templates.js index 9937c1fbd..4c022bb15 100644 --- a/lib/pkgcloud/openstack/orchestration/client/templates.js +++ b/lib/pkgcloud/openstack/orchestration/client/templates.js @@ -82,7 +82,7 @@ exports.validateTemplate = function (template, callback) { requestOpts.body.template = template; } else { - callback(new Error('please provide either a template object, or a templateUrl')) + callback(new Error('please provide either a template object, or a templateUrl')); } return self._request(requestOpts, function (err, body) { diff --git a/lib/pkgcloud/openstack/storage/client/containers.js b/lib/pkgcloud/openstack/storage/client/containers.js index 08f25a6b4..fdaeb2d78 100644 --- a/lib/pkgcloud/openstack/storage/client/containers.js +++ b/lib/pkgcloud/openstack/storage/client/containers.js @@ -44,7 +44,7 @@ exports.getContainers = function (options, callback) { return callback(err); } else if (!body || !(body instanceof Array)) { - return new Error('Malformed API Response') + return new Error('Malformed API Response'); } return callback(null, body.map(function (container) { diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index c52f8c4bb..f066fafc5 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -351,7 +351,7 @@ exports._getFiles = function (container, options, callback) { return callback(err); } else if (!body || !(body instanceof Array)) { - return new Error('Malformed API Response') + return new Error('Malformed API Response'); } return callback(null, body.map(function (file) { diff --git a/lib/pkgcloud/openstack/storage/storageClient.js b/lib/pkgcloud/openstack/storage/storageClient.js index 22373fea1..469445de7 100644 --- a/lib/pkgcloud/openstack/storage/storageClient.js +++ b/lib/pkgcloud/openstack/storage/storageClient.js @@ -18,7 +18,7 @@ const OBJECT_REMOVE_META_PREFIX = 'x-object-remove-meta-'; var Client = exports.StorageClient = function () { this.serviceType = 'object-store'; -} +}; /** * client._getUrl diff --git a/lib/pkgcloud/rackspace/dns/client/zones.js b/lib/pkgcloud/rackspace/dns/client/zones.js index 1017542d3..eced07297 100644 --- a/lib/pkgcloud/rackspace/dns/client/zones.js +++ b/lib/pkgcloud/rackspace/dns/client/zones.js @@ -346,7 +346,7 @@ module.exports = { if (options.since) { requestOptions.qs = { since: options.since.toString() - } + }; } self._request(requestOptions, function (err, body, res) { @@ -438,4 +438,4 @@ module.exports = { }), res); }); } -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js index 6f621ad5e..ba1bbc17d 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js @@ -552,7 +552,7 @@ module.exports = { type: details.type, delay: details.delay, timeout: details.timeout - } + }; } else if (details.type === 'HTTP' || details.type === 'HTTPS') { requestOptions.body = { @@ -563,7 +563,7 @@ module.exports = { bodyRegex: details.bodyRegex, path: details.path, statusRegex: details.statusRegex - } + }; if (details.hostHeader) { requestOptions.body.hostHeader = details.hostHeader; diff --git a/lib/pkgcloud/rackspace/loadbalancer/virtualip.js b/lib/pkgcloud/rackspace/loadbalancer/virtualip.js index f9c29b6b4..4c208c485 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/virtualip.js +++ b/lib/pkgcloud/rackspace/loadbalancer/virtualip.js @@ -9,7 +9,7 @@ var VirtualIp = function (details) { if (!details) { - throw new Error('VirtualIp must be constructed with at-least basic details.') + throw new Error('VirtualIp must be constructed with at-least basic details.'); } this._setProperties(details); @@ -37,4 +37,4 @@ exports.VirtualIp = VirtualIp; exports.VirtualIpTypes = { PUBLIC: 'PUBLIC', SERVICENET: 'SERVICENET' -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 115474459..36893f01c 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -42,7 +42,7 @@ exports.getContainers = function (options, callback) { return callback(err); } else if (!body || !(body instanceof Array)) { - return new Error('Malformed API Response') + return new Error('Malformed API Response'); } if (!options.loadCDNAttributes) { @@ -62,7 +62,7 @@ exports.getContainers = function (options, callback) { return next(err); } next(); - }) + }); }, function (err) { callback(err, containers); }); @@ -373,7 +373,7 @@ exports.setTemporaryUrlKey = function(key, callback) { 'X-Account-Meta-Temp-Url-Key': key } }, function (err) { - callback(err) + callback(err); }); }; @@ -427,4 +427,4 @@ exports.generateTempUrl = function(container, file, method, time, key, callback) callback(null, url + "?temp_url_sig=" + hash + "&temp_url_expires=" + expiry); } -}; \ No newline at end of file +}; diff --git a/test/azure/databases/test-database.js b/test/azure/databases/test-database.js index 83613cd42..63ca325a9 100644 --- a/test/azure/databases/test-database.js +++ b/test/azure/databases/test-database.js @@ -4,7 +4,7 @@ var helpers = require('../../helpers'); var options = { name: 'test10' -} +}; var client = helpers.createClient('azure', 'database'); diff --git a/test/azure/storage/test-upload.js b/test/azure/storage/test-upload.js index 787dfeaa7..3b43f46ec 100644 --- a/test/azure/storage/test-upload.js +++ b/test/azure/storage/test-upload.js @@ -24,7 +24,7 @@ var stream = client.upload(options, function (err, res) { var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); file.pipe(stream); -options.remote = 'bigfile.raw' +options.remote = 'bigfile.raw'; var stream2 = client.upload(options, function (err, res) { if (err) { console.dir(err); diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 0d2f117d3..a7b4172a8 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -61,7 +61,7 @@ providers.filter(function (provider) { function (next) { authServer.listen(12346, next); } - ], done) + ], done); }); it('the getVersion() method with no arguments should return the version', function (done) { @@ -212,7 +212,7 @@ providers.filter(function (provider) { function (next) { server.close(next); } - ], done) + ], done); }); }); }); diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index 557600146..6c95590a8 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -50,7 +50,7 @@ providers.filter(function (provider) { function (next) { authServer.listen(12346, next); } - ], done) + ], done); }); it('the getImages() function should return a list of images', function(done) { @@ -118,7 +118,7 @@ providers.filter(function (provider) { function (next) { server.close(next); } - ], done) + ], done); }); }); @@ -159,6 +159,6 @@ function setupImagesMock(client, provider, servers) { servers.server .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); } } diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index eea9f4054..5d9c005a0 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -60,7 +60,7 @@ providers.filter(function (provider) { function (next) { authServer.listen(12346, next); } - ], done) + ], done); }); it('the getImages() function should return a list of images', function(done) { @@ -225,7 +225,7 @@ providers.filter(function (provider) { function (next) { server.close(next); } - ], done) + ], done); }); }); @@ -476,7 +476,7 @@ function setupServerMock(client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') - .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) + .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } else if (provider === 'hp') { servers.server @@ -510,7 +510,7 @@ function setupGetServersMock(client, provider, servers) { .post('/', { Action: 'DescribeInstances' }, { 'User-Agent': client.userAgent }) - .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml') + .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml'); } else if (provider === 'azure') { @@ -521,7 +521,7 @@ function setupGetServersMock(client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices') .reply(200, "https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z") .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') - .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) + .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } else if (provider === 'digitalocean') { var account = require(__dirname + '/../../configs/mock/digitalocean'); @@ -559,7 +559,7 @@ function setupGetServerMock(client, provider, servers) { servers.server .filteringRequestBody(helpers.authFilter) .post('/?Action=DescribeInstances', {}) - .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml') + .replyWithFile(200, __dirname + '/../../fixtures/amazon/running-server.xml'); } else if (provider === 'azure') { @@ -570,7 +570,7 @@ function setupGetServerMock(client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices') .reply(200, "https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z") .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') - .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')) + .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } else if (provider === 'hp') { servers.server diff --git a/test/common/databases/databases-test.js b/test/common/databases/databases-test.js index eea62c614..457bfd846 100644 --- a/test/common/databases/databases-test.js +++ b/test/common/databases/databases-test.js @@ -143,7 +143,7 @@ providers.filter(function (provider) { client.getDatabases({ instance: instance }, function (err, list) { should.not.exist(err); should.exist(list); - should.exist(list[0]) + should.exist(list[0]); list[0].name.should.equal('TestDatabase'); list[0].name.should.be.a.String; hockInstance && hockInstance.done(); @@ -305,7 +305,7 @@ providers.filter(function (provider) { function (next) { authServer.close(next); } - ], done) + ], done); }); }); diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index 51bd96836..71efb4d9c 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -115,7 +115,7 @@ providers.filter(function (provider) { function (next) { authServer.close(next); } - ], done) + ], done); }); }); }); @@ -124,18 +124,18 @@ providers.filter(function (provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/flavors') - .reply(200, helpers.loadFixture('rackspace/databaseFlavors.json')) + .reply(200, helpers.loadFixture('rackspace/databaseFlavors.json')); } else if (provider === 'openstack') { hockInstance .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') - .reply(200, helpers.loadFixture('openstack/databaseFlavors.json')) + .reply(200, helpers.loadFixture('openstack/databaseFlavors.json')); } else if (provider === 'hp') { hockInstance .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors') - .reply(200, helpers.loadFixture('hp/databaseFlavors.json')) + .reply(200, helpers.loadFixture('hp/databaseFlavors.json')); } } }); diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index 0187a4bc6..cc5efd37e 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -89,7 +89,7 @@ providers.filter(function (provider) { describe('the getInstances() method', function() { describe('without options', function() { - var err, instances, offset + var err, instances, offset; before(function(done) { @@ -152,7 +152,7 @@ providers.filter(function (provider) { describe('with limit', function () { - var err, instances, offset + var err, instances, offset; before(function (done) { @@ -230,7 +230,7 @@ providers.filter(function (provider) { if (mock) { hockInstance .get('/v1.0/123456/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262') - .reply(200, helpers.loadFixture('rackspace/databaseInstanceOffset.json')) + .reply(200, helpers.loadFixture('rackspace/databaseInstanceOffset.json')); } client.getInstances({ offset: testContext.marker }, function (err, instances, offset) { @@ -253,7 +253,7 @@ providers.filter(function (provider) { if (mock) { hockInstance .get('/v1.0/123456/instances?limit=1&marker=55041e91-98ab-4cd5-8148-f3b3978b3262') - .reply(200, helpers.loadFixture('rackspace/databaseInstanceLimitOffset.json')) + .reply(200, helpers.loadFixture('rackspace/databaseInstanceLimitOffset.json')); } client.getInstances({limit: 1, offset: testContext.marker }, function (err, instances, offset) { @@ -391,14 +391,14 @@ providers.filter(function (provider) { client.createInstance(function(err) { should.exist(err); done(); - }) + }); }); it('without flavor should respond with errors', function (done) { client.createInstance({ name: 'test-without-flavor' }, function (err) { should.exist(err); done(); - }) + }); }); it('with invalid size should respond with errors', function (done) { @@ -425,7 +425,7 @@ providers.filter(function (provider) { client.restartInstance(function (err) { should.exist(err); done(); - }) + }); }); it('with valid instance should restart', function (done) { @@ -455,7 +455,7 @@ providers.filter(function (provider) { function (next) { authServer.close(next); } - ], done) + ], done); }); }); }); @@ -524,17 +524,17 @@ function setupGetInstancesMock(hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); } else if (provider === 'openstack') { hockInstance .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); } else if (provider === 'hp') { hockInstance .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .reply(200, helpers.loadFixture('hp/databaseInstances.json')); } } @@ -542,17 +542,17 @@ function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances?limit=2') - .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')) + .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')); } else if (provider === 'openstack') { hockInstance .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances?limit=2') - .reply(200, helpers.loadFixture('openstack/databaseInstancesLimit2.json')) + .reply(200, helpers.loadFixture('openstack/databaseInstancesLimit2.json')); } else if (provider === 'hp') { hockInstance .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances?limit=2') - .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')) + .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')); } } @@ -562,21 +562,21 @@ function setupDestroyInstanceMock(hockInstance, provider) { .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202) + .reply(202); } else if (provider === 'openstack') { hockInstance .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202) + .reply(202); } else if (provider === 'hp') { hockInstance .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') .reply(200, helpers.loadFixture('hp/databaseInstances.json')) .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202) + .reply(202); } } @@ -602,17 +602,17 @@ function setGetFlavorsMock(hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/flavors/2') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) + .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')); } else if (provider === 'openstack') { hockInstance .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') - .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')) + .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')); } else if (provider === 'hp') { hockInstance .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') - .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')) + .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')); } } @@ -724,20 +724,20 @@ function setupRestartInstanceMock (hockInstance, provider) { .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202) + .reply(202); } else if (provider === 'openstack') { hockInstance .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202) + .reply(202); } else if (provider === 'hp') { hockInstance .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') .reply(200, helpers.loadFixture('hp/databaseInstances.json')) .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202) + .reply(202); } } diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index 3aa95ab18..1fc782e0f 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -280,7 +280,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { function (next) { authServer.close(next); } - ], done) + ], done); }); }); }); diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index f554730ff..364f37aad 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -408,7 +408,7 @@ providers.filter(function (provider) { function (next) { authServer.close(next); } - ], done) + ], done); }); }); }); @@ -558,7 +558,7 @@ function setupGetContainersMock(provider, client, servers) { else if (provider === 'azure') { servers.server .get('/?comp=list') - .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()) + .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()); } else if (provider === 'google') { servers.server @@ -597,7 +597,7 @@ function setupUploadStreamMock(provider, client, servers) { .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', "block000000000000000") .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})) + .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); } else if (provider === 'hp') { servers.server @@ -612,7 +612,7 @@ function setupDownloadStreamMock(provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2}) + .reply(200, fillerama, { 'content-length': fillerama.length + 2}); } else if (provider === 'amazon') { servers.server @@ -622,7 +622,7 @@ function setupDownloadStreamMock(provider, client, servers) { else if (provider === 'azure') { servers.server .get('/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})) + .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})); } else if (provider === 'google') { servers.server @@ -634,7 +634,7 @@ function setupDownloadStreamMock(provider, client, servers) { else if (provider === 'hp') { servers.server .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2}) + .reply(200, fillerama, { 'content-length': fillerama.length + 2}); } } @@ -642,17 +642,17 @@ function setupGetFileMock(provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }) + .reply(200, '', { 'content-length': fillerama.length + 2 }); } else if (provider === 'amazon') { servers.server .head('/test-file.txt') - .reply(200, '', { 'content-length': fillerama.length + 2 }) + .reply(200, '', { 'content-length': fillerama.length + 2 }); } else if (provider === 'azure') { servers.server .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})) + .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); } else if (provider === 'google') { servers.server @@ -662,7 +662,7 @@ function setupGetFileMock(provider, client, servers) { else if (provider === 'hp') { servers.server .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }) + .reply(200, '', { 'content-length': fillerama.length + 2 }); } } @@ -679,12 +679,12 @@ function setupGetFilesMock(provider, client, servers) { else if (provider === 'amazon') { servers.server .get('/') - .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml')) + .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml')); } else if (provider === 'azure') { servers.server .get('/pkgcloud-test-container?restype=container&comp=list') - .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})) + .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})); } else if (provider === 'google') { servers.server @@ -716,7 +716,7 @@ function setupRemoveFileMock(provider, client, servers) { else if (provider === 'azure') { servers.server .delete('/pkgcloud-test-container/test-file.txt') - .reply(202, '', helpers.azureDeleteResponseHeaders()) + .reply(202, '', helpers.azureDeleteResponseHeaders()); } else if (provider === 'google') { servers.server @@ -835,7 +835,7 @@ function setupGetContainers2Mock(provider, client, servers) { else if (provider === 'azure') { servers.server .get('/?comp=list') - .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()) + .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()); } else if (provider === 'google') { servers.server diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index 6865da9f9..46092d646 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -107,7 +107,7 @@ providers.filter(function (provider) { function (next) { authServer.close(next); } - ], done) + ], done); }); }); }); @@ -127,7 +127,7 @@ function setupUploadStreamError(provider, client, servers) { servers.server .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', 'foo') - .reply(400) + .reply(400); } else if (provider === 'openstack') { servers.authServer @@ -155,12 +155,12 @@ function setupUploadStreamError(provider, client, servers) { servers.server .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', 'foo') - .reply(400) + .reply(400); } else if (provider === 'amazon') { servers.server .post('/test-file.txt?uploads') - .reply(400) + .reply(400); } else if (provider === 'azure') { diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index 138627d30..223443a60 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -110,7 +110,7 @@ exports.serverTest = function (nock, testHelpers) { nock('https://management.core.windows.net') .defaultReplyHeaders({'x-ms-request-id': requestId, 'Content-Type': 'application/xml'}) .delete('/azure-account-subscription-id/services/disks/create-test-ids2-create-test-ids2-0-20121111181413') - .reply(200, "", {}) + .reply(200, "", {}); // VM image blob nock('http://test-storage-account.' + azureApi.STORAGE_ENDPOINT) diff --git a/test/helpers/index.js b/test/helpers/index.js index f54a6e1dd..85b0b3a33 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -108,7 +108,7 @@ helpers.selectInstance = function selectInstance(client, callback) { client.getInstances(function (err, instances) { if (err) throw new Error(err); if (instances.length === 0) { - throw new Error({ message:'No instances found.' }) + throw new Error({ message:'No instances found.' }); } callback(filterInstances(instances)); }); @@ -194,7 +194,7 @@ helpers._getOpenstackStandardResponse = function(file, time) { response.access.token.expires = time.toString(); return response; -} +}; helpers.setupAuthenticationMock = function (authHockInstance, provider) { if (provider === 'rackspace') { @@ -259,6 +259,6 @@ helpers.setupAuthenticationMock = function (authHockInstance, provider) { else { throw new Error('provider ['+provider+'] not supported'); } -} +}; helpers.pkgcloud = pkgcloud; diff --git a/test/hp/macros.js b/test/hp/macros.js index 89bbc1341..ceef56992 100644 --- a/test/hp/macros.js +++ b/test/hp/macros.js @@ -19,7 +19,7 @@ exports.shouldHaveCreds = function (client) { assert.include(client.config, 'apiKey'); assert.isFunction(client.auth); - } + }; }; exports.shouldCreateContainer = function (client, name, message) { @@ -48,7 +48,7 @@ exports.shouldDestroyContainer = function (client, name) { "The pkgcloud Rackspace storage client": { "the destroyContainer() method": { topic: function () { - client.destroyContainer(name, this.callback) + client.destroyContainer(name, this.callback); }, "should return true": function (err, success) { assert.isTrue(success); @@ -69,7 +69,7 @@ exports.upload.fullpath = function (client, options) { "should raise the `end` event": function () { assert.isTrue(true); } - } + }; }; exports.upload.stream = function (client, container, local, remote) { @@ -87,7 +87,7 @@ exports.upload.stream = function (client, container, local, remote) { "should raise the `end` event": function () { assert.isTrue(true); } - } + }; }; exports.upload.piped = function (client, container, local, remote) { @@ -99,10 +99,10 @@ exports.upload.piped = function (client, container, local, remote) { }, function () { }); filed(local).pipe(ustream); - ustream.on('end', this.callback) + ustream.on('end', this.callback); }, "should raise the `end` event": function () { assert.isTrue(true); } - } + }; }; diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index f6aac39a6..bdfd92c7c 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -22,7 +22,7 @@ describe('pkgcloud/hp/storage/authentication', function () { describe('the auth() method', function() { describe('with a valid user name and api key', function() { - var authHockInstance, authServer + var authHockInstance, authServer; before(function(done) { if (!mock) { diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js index d6d08038e..4fc194e31 100644 --- a/test/mongolab/databases/databases-test.js +++ b/test/mongolab/databases/databases-test.js @@ -37,7 +37,7 @@ describe('pkgcloud/mongolab/databases', function () { email: 'daniel@nodejitsu.com' } }) - .reply(200, helpers.loadFixture('mongolab/user.json')) + .reply(200, helpers.loadFixture('mongolab/user.json')); } client.createAccount({ @@ -153,7 +153,7 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance .get('/api/1/partners/nodejitsu/accounts') - .reply(200, helpers.loadFixture('mongolab/userList.json')) + .reply(200, helpers.loadFixture('mongolab/userList.json')); } client.getAccounts(function(err, accounts) { @@ -339,7 +339,7 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases/nodejitsu_daniel_testDatabase') - .reply(200, " null ") + .reply(200, " null "); } client.remove({ @@ -406,7 +406,7 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel') - .reply(200, " null ") + .reply(200, " null "); } client.deleteAccount(context.account.username, diff --git a/test/openstack/compute/client/startServer-test.js b/test/openstack/compute/client/startServer-test.js index 4f534c0b9..a2e86f1d4 100644 --- a/test/openstack/compute/client/startServer-test.js +++ b/test/openstack/compute/client/startServer-test.js @@ -99,7 +99,7 @@ var options = {}; function (next) { authServer.close(next); } - ], done) + ], done); }); }); diff --git a/test/openstack/compute/client/stopServer-test.js b/test/openstack/compute/client/stopServer-test.js index c818f15ac..e85891983 100644 --- a/test/openstack/compute/client/stopServer-test.js +++ b/test/openstack/compute/client/stopServer-test.js @@ -99,7 +99,7 @@ var options = {}; function (next) { authServer.close(next); } - ], done) + ], done); }); }); diff --git a/test/openstack/identity/identity-test.js b/test/openstack/identity/identity-test.js index 984bd476d..6c1cfedd7 100644 --- a/test/openstack/identity/identity-test.js +++ b/test/openstack/identity/identity-test.js @@ -208,7 +208,7 @@ describe('pkgcloud/openstack/identity', function () { tenantId: '72e90ecb69c44d0296072ea39e537041' } }) - .reply(200, helpers.getOpenstackAuthResponse()) + .reply(200, helpers.getOpenstackAuthResponse()); adminHockInstance diff --git a/test/openstack/identity/service-test.js b/test/openstack/identity/service-test.js index 18ef4e65a..9b79227e6 100644 --- a/test/openstack/identity/service-test.js +++ b/test/openstack/identity/service-test.js @@ -65,7 +65,7 @@ describe('pkgcloud openstack context Service Class', function() { (function() { service.getEndpointUrl({ - region: 'ORD' }) + region: 'ORD' }); }).should.throw('Unable to identify endpoint url'); }); diff --git a/test/openstack/orchestration/create-stacks-test.js b/test/openstack/orchestration/create-stacks-test.js index 8ebe06a87..591ace60a 100644 --- a/test/openstack/orchestration/create-stacks-test.js +++ b/test/openstack/orchestration/create-stacks-test.js @@ -120,7 +120,7 @@ describe('pkgcloud/openstack/orchestration/stacks[createStacks]', function () { function (next) { authServer.close(next); } - ], done) + ], done); }); }); diff --git a/test/openstack/orchestration/get-stacks-test.js b/test/openstack/orchestration/get-stacks-test.js index 749009b30..58f9f2082 100644 --- a/test/openstack/orchestration/get-stacks-test.js +++ b/test/openstack/orchestration/get-stacks-test.js @@ -194,7 +194,7 @@ describe('pkgcloud/openstack/orchestration/stacks[getStacks]', function () { function (next) { authServer.close(next); } - ], done) + ], done); }); }); diff --git a/test/rackspace/blockstorage/volumes-test.js b/test/rackspace/blockstorage/volumes-test.js index 5a467933b..883892d72 100644 --- a/test/rackspace/blockstorage/volumes-test.js +++ b/test/rackspace/blockstorage/volumes-test.js @@ -177,6 +177,6 @@ describe('pkgcloud/rackspace/blockstorage/volumes', function () { function (next) { authServer.close(next); } - ], done) + ], done); }); -}); \ No newline at end of file +}); diff --git a/test/rackspace/compute/authentication-test.js b/test/rackspace/compute/authentication-test.js index 1b3ac93d9..ab6a111e2 100644 --- a/test/rackspace/compute/authentication-test.js +++ b/test/rackspace/compute/authentication-test.js @@ -265,7 +265,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { function (next) { authServer.close(next); } - ], done) + ], done); }); }); }); diff --git a/test/rackspace/compute/image-test.js b/test/rackspace/compute/image-test.js index 0ee3538c2..fbd83dd6c 100644 --- a/test/rackspace/compute/image-test.js +++ b/test/rackspace/compute/image-test.js @@ -125,6 +125,6 @@ describe('pkgcloud/rackspace/compute/images', function () { function (next) { authServer.close(next); } - ], done) + ], done); }); -}); \ No newline at end of file +}); diff --git a/test/rackspace/databases/authentication-test.js b/test/rackspace/databases/authentication-test.js index d42527149..a37cdf633 100644 --- a/test/rackspace/databases/authentication-test.js +++ b/test/rackspace/databases/authentication-test.js @@ -190,6 +190,6 @@ describe('pkgcloud/rackspace/database/authentication', function() { function (next) { authServer.close(next); } - ], done) + ], done); }); }); diff --git a/test/rackspace/macros.js b/test/rackspace/macros.js index 89bbc1341..ceef56992 100644 --- a/test/rackspace/macros.js +++ b/test/rackspace/macros.js @@ -19,7 +19,7 @@ exports.shouldHaveCreds = function (client) { assert.include(client.config, 'apiKey'); assert.isFunction(client.auth); - } + }; }; exports.shouldCreateContainer = function (client, name, message) { @@ -48,7 +48,7 @@ exports.shouldDestroyContainer = function (client, name) { "The pkgcloud Rackspace storage client": { "the destroyContainer() method": { topic: function () { - client.destroyContainer(name, this.callback) + client.destroyContainer(name, this.callback); }, "should return true": function (err, success) { assert.isTrue(success); @@ -69,7 +69,7 @@ exports.upload.fullpath = function (client, options) { "should raise the `end` event": function () { assert.isTrue(true); } - } + }; }; exports.upload.stream = function (client, container, local, remote) { @@ -87,7 +87,7 @@ exports.upload.stream = function (client, container, local, remote) { "should raise the `end` event": function () { assert.isTrue(true); } - } + }; }; exports.upload.piped = function (client, container, local, remote) { @@ -99,10 +99,10 @@ exports.upload.piped = function (client, container, local, remote) { }, function () { }); filed(local).pipe(ustream); - ustream.on('end', this.callback) + ustream.on('end', this.callback); }, "should raise the `end` event": function () { assert.isTrue(true); } - } + }; }; diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index e93a08a84..1333d7ab1 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -156,7 +156,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { 'content-length': '0', 'x-trans-id': 'tx8a8acb8f3f7142c8bd36f27a18415996', date: 'Wed, 12 Jun 2013 19:04:25 GMT', - connection: 'keep-alive' }) + connection: 'keep-alive' }); } @@ -349,7 +349,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { 'content-length': '0', 'x-trans-id': 'tx8a8acb8f3f7142c8bd36f27a18415996', date: 'Wed, 12 Jun 2013 19:04:25 GMT', - connection: 'keep-alive' }) + connection: 'keep-alive' }); } client.getContainer('0.1.3-85', function (err, container) { @@ -411,7 +411,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { 'x-cdn-streaming-uri': 'http://e5addf7be8783adf8c6d-edfcb31ae70ea7c07367728d50539bc7.r63.stream.cf1.rackcdn.com', 'content-length': '0', 'x-trans-id': 'tx8a8acb8f3f7142c8bd36f27a18415996', - date: 'Wed, 12 Jun 2013 19:04:25'}) + date: 'Wed, 12 Jun 2013 19:04:25'}); } client.getContainer('0.1.3-85', function (err, container) { @@ -575,7 +575,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { it('updateContainerMetadata should throw if passed non container', function() { (function() { - client.updateContainerMetadata({ name: 'foo' }) + client.updateContainerMetadata({ name: 'foo' }); }).should.throw(); }); @@ -591,7 +591,7 @@ describe('pkgcloud/rackspace/storage/containers', function () { function (next) { server.close(next); } - ], done) + ], done); }); }); }); diff --git a/test/rackspace/storage/storage-object-test.js b/test/rackspace/storage/storage-object-test.js index 96e8f9988..16721d48f 100755 --- a/test/rackspace/storage/storage-object-test.js +++ b/test/rackspace/storage/storage-object-test.js @@ -301,7 +301,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { function (next) { authServer.close(next); } - ], done) + ], done); }); }); }); diff --git a/test/redistogo/databases/databases-test.js b/test/redistogo/databases/databases-test.js index 06c09be6d..136541990 100644 --- a/test/redistogo/databases/databases-test.js +++ b/test/redistogo/databases/databases-test.js @@ -126,6 +126,6 @@ describe('pkgcloud/redistogo/databases', function () { else { done(); } - }) + }); }); From c00a0852eb7650883c86a7b2efb920ce9d02703b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 08:42:31 -0800 Subject: [PATCH 258/460] Run lint test as part of travis build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 55979cfb0..a389e75f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,4 @@ before_script: - ./configure - make - popd + - npm run lint From c0390f4b5fed3d092932e4d608dea18f6744f410 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 27 Nov 2014 08:53:04 -0800 Subject: [PATCH 259/460] Adding node-jscoverage as Travis will clone it and we want jshint to ignore it --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 17168f4e1..a307754e3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ azure_error coverage.html .coveralls.yml pkgcloud.lcov* +node-jscoverage \ No newline at end of file From 2ac05d80b3bb1868fac410118ea3f43f4872e2c6 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 28 Nov 2014 09:43:15 -0800 Subject: [PATCH 260/460] Backing out == -> === change; Ignoring resulting linter warning --- .jshintrc | 1 + test/rackspace/storage/container-test.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.jshintrc b/.jshintrc index 4c654ef8c..4b55dd107 100644 --- a/.jshintrc +++ b/.jshintrc @@ -60,6 +60,7 @@ "validthis" : true, // true: Tolerate using this in a non-constructor function "-W086" : true, // true: Allow fall-through; see https://github.com/jshint/jshint/issues/18 "-W008" : true, // true: Allow leading decimal point; see https://jslinterrors.com/a-leading-decimal-point-can-be-confused-with-a-dot-a + "-W041" : true, // true: Ignore strict comparison checking; see https://github.com/jshint/jshint/blob/a643f3fec0632249dcd78d0cf5f200d9166b587d/src/messages.js#L115 // Environments "browser" : false, // Web Browser (window, document, etc) diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index 1333d7ab1..0499c0375 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -489,8 +489,8 @@ describe('pkgcloud/rackspace/storage/containers', function () { container.should.be.instanceof(Container); - (container.metadata['web-index'] === undefined).should.be.true; - (container.metadata['web-error'] === undefined).should.be.true; + (container.metadata['web-index'] == undefined).should.be.true; + (container.metadata['web-error'] == undefined).should.be.true; container.setStaticWebsite({indexFile: 'index.htm', errorFile: 'error.htm'}, function (err, container) { should.not.exist(err); @@ -564,8 +564,8 @@ describe('pkgcloud/rackspace/storage/containers', function () { should.exist(container); container.should.be.instanceof(Container); - (container.metadata['web-index'] === undefined).should.be.true; - (container.metadata['web-error'] === undefined).should.be.true; + (container.metadata['web-index'] == undefined).should.be.true; + (container.metadata['web-error'] == undefined).should.be.true; hockInstance && hockInstance.done(); done(); From 88d30006a849d121c8fddfabe3f59efeda73bde4 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 28 Nov 2014 09:47:30 -0800 Subject: [PATCH 261/460] Backing out function statement change; Ignorning resulting linter warning --- .jshintrc | 1 + lib/pkgcloud/joyent/compute/client/servers.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.jshintrc b/.jshintrc index 4b55dd107..6998ce959 100644 --- a/.jshintrc +++ b/.jshintrc @@ -61,6 +61,7 @@ "-W086" : true, // true: Allow fall-through; see https://github.com/jshint/jshint/issues/18 "-W008" : true, // true: Allow leading decimal point; see https://jslinterrors.com/a-leading-decimal-point-can-be-confused-with-a-dot-a "-W041" : true, // true: Ignore strict comparison checking; see https://github.com/jshint/jshint/blob/a643f3fec0632249dcd78d0cf5f200d9166b587d/src/messages.js#L115 + "-W082" : true, // true: Allow function declarations inside blocks; see https://jslinterrors.com/function-statements-should-not-be-placed-in-blocks // Environments "browser" : false, // Web Browser (window, document, etc) diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index d89b72108..81341199f 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -155,7 +155,7 @@ exports.destroyServer = function destroyServer(server, callback) { if (res.statusCode === 202) { var checks = 10; var done = false; - var check = function() { + function check() { if (done) return; checks--; if (checks <= 0) return; @@ -179,7 +179,7 @@ exports.destroyServer = function destroyServer(server, callback) { }); setTimeout(check, 5000); - }; + } check(); return; From 1a6fbdf304efaabb13e2ae625ab20ef5aea9195d Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 28 Nov 2014 13:24:35 -0800 Subject: [PATCH 262/460] Adding `single` quote rule to jshint - Fixed all code references - Related to #360 --- .jshintrc | 2 +- examples/compute/azure.js | 18 ++-- examples/database/azure.js | 6 +- examples/database/iriscouch.js | 24 +++--- examples/database/mongohq.js | 8 +- examples/database/redistogo.js | 6 +- examples/storage/azure.js | 4 +- lib/pkgcloud/amazon/compute/client/servers.js | 2 +- lib/pkgcloud/azure/compute/client/servers.js | 2 +- lib/pkgcloud/azure/compute/server.js | 6 +- .../azure/database/client/databases.js | 2 +- lib/pkgcloud/azure/storage/client/files.js | 2 +- lib/pkgcloud/azure/utils/sharedkey.js | 2 +- .../digitalocean/compute/client/servers.js | 4 +- lib/pkgcloud/digitalocean/compute/server.js | 2 +- .../iriscouch/database/client/index.js | 28 +++--- lib/pkgcloud/joyent/client.js | 4 +- lib/pkgcloud/joyent/compute/client/servers.js | 4 +- lib/pkgcloud/joyent/compute/flavor.js | 2 +- lib/pkgcloud/joyent/compute/image.js | 2 +- lib/pkgcloud/openstack/compute/server.js | 4 +- .../openstack/database/client/instances.js | 2 +- .../rackspace/loadbalancer/protocols.js | 72 ++++++++-------- .../storage/client/cdn-containers.js | 2 +- .../redistogo/database/client/index.js | 14 +-- test/azure/compute/client/test-createImage.js | 4 +- .../azure/compute/client/test-createServer.js | 22 ++--- .../azure/compute/client/test-rebootServer.js | 26 +++--- test/azure/databases/databases-test.js | 2 +- test/azure/utils/test-cert.js | 2 +- test/common/base/client-test.js | 8 +- test/common/base/pkgcloud-test.js | 4 +- test/common/compute/meta-test.js | 9 +- test/common/compute/server-test.js | 4 +- test/common/network/network-test.js | 38 ++++---- test/common/network/port-test.js | 66 +++++++------- test/common/network/subnet-test.js | 74 ++++++++-------- test/common/storage/base-test.js | 2 +- test/helpers/azureNock.js | 28 +++--- test/helpers/index.js | 20 ++--- test/hp/common/client-test.js | 84 +++++++++--------- test/hp/macros.js | 20 ++--- .../databases/databases-redis-test.js | 10 +-- test/mongohq/databases/databases-test.js | 4 +- test/mongolab/databases/databases-test.js | 8 +- .../compute/client/startServer-test.js | 3 +- .../compute/client/stopServer-test.js | 3 +- test/openstack/identity/service-test.js | 86 +++++++++---------- test/rackspace/compute/personality-test.js | 4 +- .../databases/authentication-test.js | 12 +-- test/rackspace/macros.js | 20 ++--- test/rackspace/storage/storage-object-test.js | 22 ++--- test/redistogo/databases/databases-test.js | 2 +- 53 files changed, 408 insertions(+), 403 deletions(-) diff --git a/.jshintrc b/.jshintrc index 6998ce959..17277c695 100644 --- a/.jshintrc +++ b/.jshintrc @@ -17,7 +17,7 @@ "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : false, // Quotation mark consistency: + "quotmark" : "single", // Quotation mark consistency: // false : do nothing (default) // true : ensure whatever is used is consistent // "single" : require single quotes diff --git a/examples/compute/azure.js b/examples/compute/azure.js index d523babba..2acd9b62c 100644 --- a/examples/compute/azure.js +++ b/examples/compute/azure.js @@ -8,9 +8,9 @@ var pkgcloud = require('../../lib/pkgcloud'), // options = { provider: 'azure', - "storageAccount": "test-storage-account", - "storageAccessKey": "test-storage-access-key", - "subscriptionId": "azure-account-subscription-id", + storageAccount: 'test-storage-account', + storageAccessKey: 'test-storage-access-key', + subscriptionId: 'azure-account-subscription-id', key: fs.readFileSync('path to your account management key file', 'ascii'), cert: fs.readFileSync('path to your account management certificate pem file', 'ascii') }; @@ -39,15 +39,15 @@ options = { // Azure ports (endpoints) ports: [ { - name : "foo", // name of port - protocol : "tcp", // tcp or udp - port: "12333", // external port number - localPort: "12333" // internal port number + name : 'foo', // name of port + protocol : 'tcp', // tcp or udp + port: '12333', // external port number + localPort: '12333' // internal port number } ] }; -console.log("creating server..."); +console.log('creating server...'); client.createServer(options, function (err, server) { if (err) { @@ -55,7 +55,7 @@ client.createServer(options, function (err, server) { } else { // Wait for the server to reach the RUNNING state. // This may take several minutes. - console.log("waiting for server RUNNING state..."); + console.log('waiting for server RUNNING state...'); server.setWait({ status: server.STATUS.running }, 10000, function (err, server) { if (err) { console.log(err); diff --git a/examples/database/azure.js b/examples/database/azure.js index 8cbb26593..b60f7917a 100644 --- a/examples/database/azure.js +++ b/examples/database/azure.js @@ -2,15 +2,15 @@ var pkgcloud = require('../../lib/pkgcloud'); var client = pkgcloud.database.createClient({ provider: 'azure', - storageAccount: "storage-account-name", // Name of your Azure storage account - storageAccessKey: "storage-account-access-key" // Access key for storage account + storageAccount: 'storage-account-name', // Name of your Azure storage account + storageAccessKey: 'storage-account-access-key' // Access key for storage account }); // // Create an Azure Table // client.create({ - name: "testing123" + name: 'testing123' }, function (err, result) { // // Check the result diff --git a/examples/database/iriscouch.js b/examples/database/iriscouch.js index 3297e100e..c13f7533b 100644 --- a/examples/database/iriscouch.js +++ b/examples/database/iriscouch.js @@ -2,18 +2,18 @@ var pkgcloud = require('../../lib/pkgcloud'); var client = pkgcloud.database.createClient({ provider: 'iriscouch', - username: "bob", - password: "1234" + username: 'bob', + password: '1234' }); // // Create a couch database // client.create({ - subdomain: "pkgcloud-nodejitsu-test-5", - first_name: "pkgcloud", - last_name: "pkgcloud", - email: "info@nodejitsu.com" + subdomain: 'pkgcloud-nodejitsu-test-5', + first_name: 'pkgcloud', + last_name: 'pkgcloud', + email: 'info@nodejitsu.com' }, function (err, result) { // // Check now exists @ http://pkgcloud-nodejitsu-test-5.iriscouch.com @@ -25,18 +25,18 @@ client.create({ // Crate a redis database // client.create({ - subdomain: "pkgcloud-nodejitsu-test-6", - first_name: "pkgcloud", - last_name: "pkgcloud", - email: "info@nodejitsu.com", + subdomain: 'pkgcloud-nodejitsu-test-6', + first_name: 'pkgcloud', + last_name: 'pkgcloud', + email: 'info@nodejitsu.com', // // For redis instead of couch just put type to redis // - type: "redis", + type: 'redis', // // AND ADD A PASSWORD! (required) // - password: "mys3cur3p4ssw0rd" + password: 'mys3cur3p4ssw0rd' }, function (err, result) { // // Check the connection, use result.host and result.password values diff --git a/examples/database/mongohq.js b/examples/database/mongohq.js index e19c69015..444500f85 100644 --- a/examples/database/mongohq.js +++ b/examples/database/mongohq.js @@ -2,16 +2,16 @@ var pkgcloud = require('../../lib/pkgcloud'); var client = pkgcloud.database.createClient({ provider: 'mongohq', - username: "bob", - password: "1234" + username: 'bob', + password: '1234' }); // // Create a MongoDB // client.create({ - name: "mongo-instance", - plan: "free", + name: 'mongo-instance', + plan: 'free', }, function (err, result) { // // Check the result diff --git a/examples/database/redistogo.js b/examples/database/redistogo.js index 73aa041ed..c136a34b8 100644 --- a/examples/database/redistogo.js +++ b/examples/database/redistogo.js @@ -2,15 +2,15 @@ var pkgcloud = require('../../lib/pkgcloud'); var client = pkgcloud.database.createClient({ provider: 'redistogo', - username: "bob", - password: "1234" + username: 'bob', + password: '1234' }); // // Create a redis // client.create({ - plan: "nano", + plan: 'nano' }, function (err, result) { // // Log the result diff --git a/examples/storage/azure.js b/examples/storage/azure.js index 3cf9bf908..6ea6ccbb5 100644 --- a/examples/storage/azure.js +++ b/examples/storage/azure.js @@ -2,6 +2,6 @@ var pkgcloud = require('../../lib/pkgcloud'); var azure = pkgcloud.storage.createClient({ provider: 'azure', - storageAccount: "test-storage-account", // Name of your storage account - storageAccessKey: "test-storage-access-key" // Access key for storage account + storageAccount: 'test-storage-account', // Name of your storage account + storageAccessKey: 'test-storage-access-key' // Access key for storage account }); diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index 24beaf1c2..625beba12 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -32,7 +32,7 @@ exports.getVersion = function getVersion(callback) { // exports.getLimits = function getLimits(callback) { return errs.handle( - errs.create({ message: "AWS's API is not rate limited" }), + errs.create({ message: 'AWS\'s API is not rate limited' }), callback ); }; diff --git a/lib/pkgcloud/azure/compute/client/servers.js b/lib/pkgcloud/azure/compute/client/servers.js index 5bf226f59..1cb1d943a 100644 --- a/lib/pkgcloud/azure/compute/client/servers.js +++ b/lib/pkgcloud/azure/compute/client/servers.js @@ -29,7 +29,7 @@ exports.getVersion = function getVersion(callback) { // exports.getLimits = function getLimits(callback) { return errs.handle( - errs.create({ message: "Azure's API is not rate limited" }), + errs.create({ message: 'Azure\'s API is not rate limited' }), callback ); }; diff --git a/lib/pkgcloud/azure/compute/server.js b/lib/pkgcloud/azure/compute/server.js index 398f47cea..cf0fc1804 100644 --- a/lib/pkgcloud/azure/compute/server.js +++ b/lib/pkgcloud/azure/compute/server.js @@ -19,14 +19,14 @@ Server.prototype._setProperties = function (details) { var roleInstance = null; details = details || {}; - this.id = details.Name || ""; - this.name = details.Name || ""; + this.id = details.Name || ''; + this.name = details.Name || ''; if (details.RoleInstanceList && details.RoleInstanceList.RoleInstance) { roleInstance = details.RoleInstanceList.RoleInstance; } - //console.log("Status: " + details.Status + ' RoleInstanceList: ' + roleInstance ? roleInstance.InstanceStatus : 'UNKNOWN'); + //console.log('Status: ' + details.Status + ' RoleInstanceList: ' + roleInstance ? roleInstance.InstanceStatus : 'UNKNOWN'); // azure can return an inconsistent RoleInstance status (not in azure rest api docs) so we check everything. // an azure vm has a complicated state machine. We need to check the status of both the deployment and the role. diff --git a/lib/pkgcloud/azure/database/client/databases.js b/lib/pkgcloud/azure/database/client/databases.js index 2c1700c0a..66717a8d9 100644 --- a/lib/pkgcloud/azure/database/client/databases.js +++ b/lib/pkgcloud/azure/database/client/databases.js @@ -110,7 +110,7 @@ exports.remove = function (id, callback) { }), Array.prototype.slice.call(arguments).pop()); } - path = encodeTableUriComponent("Tables('" + id + "')"); + path = encodeTableUriComponent('Tables(\'' + id + '\')'); this._xmlRequest({ method: 'DELETE', path: path diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index a3862578e..249bc7b2d 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -120,7 +120,7 @@ exports.upload = function (options) { }; var getBlockId = function (a, b) { - return "block" + ((1e15 + a + "").slice(-b)); + return 'block' + ((1e15 + a + '').slice(-b)); }; exports.multipartUpload = function (options) { diff --git a/lib/pkgcloud/azure/utils/sharedkey.js b/lib/pkgcloud/azure/utils/sharedkey.js index 7b75b59f6..63c3d6342 100644 --- a/lib/pkgcloud/azure/utils/sharedkey.js +++ b/lib/pkgcloud/azure/utils/sharedkey.js @@ -153,7 +153,7 @@ SharedKey.prototype._getCanonicalizedHeaders = function (req) { canonicalizedHeadersArray.sort(); for (var headerName in canonicalizedHeadersArray) { - canonicalizedHeaders += canonicalizedHeadersArray[headerName].toLowerCase() + ":" + req.headers[canonicalizedHeadersArray[headerName]] + '\n'; + canonicalizedHeaders += canonicalizedHeadersArray[headerName].toLowerCase() + ':' + req.headers[canonicalizedHeadersArray[headerName]] + '\n'; } } diff --git a/lib/pkgcloud/digitalocean/compute/client/servers.js b/lib/pkgcloud/digitalocean/compute/client/servers.js index 235b788b5..340fb238b 100644 --- a/lib/pkgcloud/digitalocean/compute/client/servers.js +++ b/lib/pkgcloud/digitalocean/compute/client/servers.js @@ -18,7 +18,7 @@ var request = require('request'), // exports.getVersion = function getVersion(callback) { return errs.handle( - errs.create({ message: "DigitalOcean's API does not support versioning" }), + errs.create({ message: 'DigitalOcean\'s API does not support versioning' }), callback ); }; @@ -31,7 +31,7 @@ exports.getVersion = function getVersion(callback) { // exports.getLimits = function getLimits(callback) { return errs.handle( - errs.create({ message: "DigitalOcean's API is not rate limited" }), + errs.create({ message: 'DigitalOcean\'s API is not rate limited' }), callback ); }; diff --git a/lib/pkgcloud/digitalocean/compute/server.js b/lib/pkgcloud/digitalocean/compute/server.js index 49475e23b..aea4f05e7 100644 --- a/lib/pkgcloud/digitalocean/compute/server.js +++ b/lib/pkgcloud/digitalocean/compute/server.js @@ -27,7 +27,7 @@ Server.prototype._setProperties = function (details) { switch (details.status && details.status.toUpperCase()) { case 'ACTIVE': - this.status = "RUNNING"; + this.status = 'RUNNING'; break; case 'NEW': default: diff --git a/lib/pkgcloud/iriscouch/database/client/index.js b/lib/pkgcloud/iriscouch/database/client/index.js index b0c0b2dc8..d506be294 100644 --- a/lib/pkgcloud/iriscouch/database/client/index.js +++ b/lib/pkgcloud/iriscouch/database/client/index.js @@ -49,13 +49,13 @@ Client.prototype.create = function (attrs, callback) { couch = { // The ID needs the prefix of the type of database _id: ((attrs['type'] && - attrs['type'] === 'redis') ? "Redis/" : "Server/") + attrs.subdomain, + attrs['type'] === 'redis') ? 'Redis/' : 'Server/') + attrs.subdomain, partner: this.username, creation: { - "first_name": attrs.first_name, - "last_name": attrs.last_name, - "email": attrs.email, - "subdomain": attrs.subdomain + first_name: attrs.first_name, + last_name: attrs.last_name, + email: attrs.email, + subdomain: attrs.subdomain } }; @@ -71,7 +71,7 @@ Client.prototype.create = function (attrs, callback) { followRedirect: false, headers: { 'Content-Type': 'application/json', - 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64'), + 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64'), 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) } }; @@ -113,17 +113,17 @@ Client.prototype.create = function (attrs, callback) { } } else { - callback("There was an issue creating the couch", { "created": false }); + callback('There was an issue creating the couch', { created: false }); } } else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { - callback("incorrect partner name or password.", { "created": false }); + callback('incorrect partner name or password.', { created: false }); } else if (response.statusCode === 409) { - callback("subdomain is already taken.", { "created": false }); + callback('subdomain is already taken.', { created: false }); } else { - callback("unknown error", { "created": false }); + callback('unknown error', { created: false }); } }); }; @@ -166,14 +166,14 @@ Client.prototype._checkCouch = function (couchName, callback) { t = function () { count = count + 1; if (count > maxAttempts) { - return callback("Max Attempts hit", { "created": false }); + return callback('Max Attempts hit', { created: false }); } request(options, function (err, response, body) { if (err) { - return callback(err, { "created": false }); + return callback(err, { created: false }); } if (response.statusCode === 200) { - return callback(null, { "created": true }); + return callback(null, { created: true }); } setTimeout(t, interval); }); @@ -182,7 +182,7 @@ Client.prototype._checkCouch = function (couchName, callback) { }; Client.prototype.remove = function (id, callback) { - callback("Destroy method not available for iriscouch."); + callback('Destroy method not available for iriscouch.'); }; // This function gets overriden in tests to trap the polling request diff --git a/lib/pkgcloud/joyent/client.js b/lib/pkgcloud/joyent/client.js index c682fd07e..77a5ce136 100644 --- a/lib/pkgcloud/joyent/client.js +++ b/lib/pkgcloud/joyent/client.js @@ -73,8 +73,8 @@ var Client = exports.Client = function (opts) { this.before.push(function setReqHeaders(req) { req.json = true; - if (typeof req.headers["X-Api-Version"] === 'undefined') { - req.headers["x-api-version"] = opts.apiVersion; + if (typeof req.headers['X-Api-Version'] === 'undefined') { + req.headers['x-api-version'] = opts.apiVersion; req.headers.Accept = 'application/json'; req.headers['content-type'] = 'application/json'; } diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index 81341199f..f70760c84 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -34,7 +34,7 @@ exports.getVersion = function getVersion(callback) { // exports.getLimits = function getLimits(callback) { return errs.handle( - errs.create({message: "Joyent's API is not rate limited"}), callback); + errs.create({message: 'Joyent\'s API is not rate limited'}), callback); }; // @@ -109,7 +109,7 @@ exports.createServer = function createServer(options, callback) { } }); if (options.flavor) { - createOptions.body["package"] = options.flavor instanceof base.Flavor + createOptions.body['package'] = options.flavor instanceof base.Flavor ? options.flavor.id : options.flavor; diff --git a/lib/pkgcloud/joyent/compute/flavor.js b/lib/pkgcloud/joyent/compute/flavor.js index b11157b26..83372eaa7 100644 --- a/lib/pkgcloud/joyent/compute/flavor.js +++ b/lib/pkgcloud/joyent/compute/flavor.js @@ -24,6 +24,6 @@ Flavor.prototype._setProperties = function (details) { // Joyent specific // this.swap = details.swap; - this["default"] = details["default"]; + this['default'] = details['default']; this.original = this.joyent = details; }; \ No newline at end of file diff --git a/lib/pkgcloud/joyent/compute/image.js b/lib/pkgcloud/joyent/compute/image.js index e80a4ad06..04766ebfa 100644 --- a/lib/pkgcloud/joyent/compute/image.js +++ b/lib/pkgcloud/joyent/compute/image.js @@ -27,7 +27,7 @@ Image.prototype._setProperties = function (details) { this.os = details.os; this.type = details.type; this.description = details.description; - this["default"] = details["default"]; + this['default'] = details['default']; this.version = details.version; this.requirements = details.requirements; this.original = this.rackspace = details; diff --git a/lib/pkgcloud/openstack/compute/server.js b/lib/pkgcloud/openstack/compute/server.js index f593310ac..47e9d69e2 100644 --- a/lib/pkgcloud/openstack/compute/server.js +++ b/lib/pkgcloud/openstack/compute/server.js @@ -94,13 +94,13 @@ Server.prototype._setProperties = function (details) { } // Try to set the flavorId using a flavor object - if (typeof this.flavorId === "undefined" && + if (typeof this.flavorId === 'undefined' && details.flavor && details.flavor.id) { this.flavorId = details.flavor.id; } // Try to set the imageId using an image object - if (typeof this.imageId === "undefined" && + if (typeof this.imageId === 'undefined' && details.image && details.image.id) { this.imageId = details.image.id; } diff --git a/lib/pkgcloud/openstack/database/client/instances.js b/lib/pkgcloud/openstack/database/client/instances.js index 1ee7d8a59..790c1f244 100644 --- a/lib/pkgcloud/openstack/database/client/instances.js +++ b/lib/pkgcloud/openstack/database/client/instances.js @@ -52,7 +52,7 @@ exports.createInstance = function createInstance(options, callback) { // This template is according to the defaults of rackspace. options['databases'][idx] = { name: item, - character_set: "utf8", + character_set: 'utf8', collate: 'utf8_general_ci' }; } diff --git a/lib/pkgcloud/rackspace/loadbalancer/protocols.js b/lib/pkgcloud/rackspace/loadbalancer/protocols.js index 732b92141..24d274310 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/protocols.js +++ b/lib/pkgcloud/rackspace/loadbalancer/protocols.js @@ -11,75 +11,75 @@ exports.Protocols = { DNS_TCP: { - "name": "DNS_TCP", - "port": 53 + name: 'DNS_TCP', + port: 53 }, DNS_UDP: { - "name": "DNS_UDP", - "port": 53 + name: 'DNS_UDP', + port: 53 }, FTP: { - "name": "FTP", - "port": 21 + name: 'FTP', + port: 21 }, HTTP: { - "name": "HTTP", - "port": 80 + name: 'HTTP', + port: 80 }, HTTPS: { - "name": "HTTPS", - "port": 443 + name: 'HTTPS', + port: 443 }, IMAPS: { - "name": "IMAPS", - "port": 993 + name: 'IMAPS', + port: 993 }, IMAPv4: { - "name": "IMAPv4", - "port": 143 + name: 'IMAPv4', + port: 143 }, LDAP: { - "name": "LDAP", - "port": 389 + name: 'LDAP', + port: 389 }, LDAPS: { - "name": "LDAPS", - "port": 636 + name: 'LDAPS', + port: 636 }, MYSQL: { - "name": "MYSQL", - "port": 3306 + name: 'MYSQL', + port: 3306 }, POP3: { - "name": "POP3", - "port": 110 + name: 'POP3', + port: 110 }, POP3S: { - "name": "POP3S", - "port": 995 + name: 'POP3S', + port: 995 }, SMTP: { - "name": "SMTP", - "port": 25 + name: 'SMTP', + port: 25 }, TCP: { - "name": "TCP", - "port": 0 + name: 'TCP', + port: 0 }, TCP_CLIENT_FIRST: { - "name": "TCP_CLIENT_FIRST", - "port": 0 + name: 'TCP_CLIENT_FIRST', + port: 0 }, UDP: { - "name": "UDP", - "port": 0 + name: 'UDP', + port: 0 }, UDP_STREAM: { - "name": "UDP_STREAM", - "port": 0 + name: 'UDP_STREAM', + port: 0 }, SFTP: { - "name": "SFTP", - "port": 22 + name: 'SFTP', + port: 22 } }; \ No newline at end of file diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 36893f01c..5cef42185 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -425,6 +425,6 @@ exports.generateTempUrl = function(container, file, method, time, key, callback) var hash = crypto.createHmac('sha1', key).update(hmac_body).digest('hex'); - callback(null, url + "?temp_url_sig=" + hash + "&temp_url_expires=" + expiry); + callback(null, url + '?temp_url_sig=' + hash + '&temp_url_expires=' + expiry); } }; diff --git a/lib/pkgcloud/redistogo/database/client/index.js b/lib/pkgcloud/redistogo/database/client/index.js index 5011f3f46..69e1e25f6 100644 --- a/lib/pkgcloud/redistogo/database/client/index.js +++ b/lib/pkgcloud/redistogo/database/client/index.js @@ -13,7 +13,7 @@ var util = require('util'), var Client = exports.Client = function (options) { this.username = options.username; this.password = options.password; - this._url = options.url || "https://redistogo.com"; + this._url = options.url || 'https://redistogo.com'; }; Client.prototype._getUrl = function () { @@ -34,15 +34,15 @@ Client.prototype._request = function (options, callback) { return callback(err); } if (response.statusCode == 401 || response.statusCode == 403) { - return callback("Unauthorized"); + return callback('Unauthorized'); } - if (options.method !== "DELETE") { + if (options.method !== 'DELETE') { var database; if (typeof body !== 'object') { try { database = JSON.parse(body); } catch (e) { - return callback("Bad response from server.", body); + return callback('Bad response from server.', body); } } else { database = body; } database = self.formatResponse(database); @@ -76,7 +76,7 @@ Client.prototype.create = function (attrs, callback) { method : 'POST', body : 'instance%5Bplan%5D=' + attrs.plan, headers: { - 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64') + 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64') } }; this._request(options, callback); @@ -102,7 +102,7 @@ Client.prototype.get = function (id, callback) { uri : this._getUrl() + path + '.json', method : 'GET', headers: { - 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64') + 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64') } }; this._request(options, callback); @@ -125,7 +125,7 @@ Client.prototype.remove = function (id, callback) { uri : this._getUrl() + path + '.json', method : 'DELETE', headers: { - 'Authorization': "Basic " + new Buffer(this.username + ':' + this.password).toString('base64'), + 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64'), 'Content-Length': 0 } }; diff --git a/test/azure/compute/client/test-createImage.js b/test/azure/compute/client/test-createImage.js index 40166126f..e5c7144b6 100644 --- a/test/azure/compute/client/test-createImage.js +++ b/test/azure/compute/client/test-createImage.js @@ -9,8 +9,8 @@ var async = require('async'); var client = helpers.createClient('azure', 'compute'); var options = { - name: "pkgcloud1", - server: "pkgcloud1" + name: 'pkgcloud1', + server: 'pkgcloud1' }; client.createImage(options, function (err, result) { diff --git a/test/azure/compute/client/test-createServer.js b/test/azure/compute/client/test-createServer.js index f9e13ff80..54529bc22 100644 --- a/test/azure/compute/client/test-createServer.js +++ b/test/azure/compute/client/test-createServer.js @@ -25,8 +25,8 @@ var options = { }, ports: [ { - name: "foo", - protocol: "tcp", + name: 'foo', + protocol: 'tcp', port: 12333, localPort: 12333 } @@ -40,13 +40,13 @@ function testCreateServer(client) { var name = 'azure', test = {}; - test["The pkgcloud " + name + " compute client"] = { - "the createServer() method": { - "with image and flavor ids": { + test['The pkgcloud ' + name + ' compute client'] = { + 'the createServer() method': { + 'with image and flavor ids': { topic: function () { client.createServer(options, this.callback); }, - "should return a valid server": function (err, server) { + 'should return a valid server': function (err, server) { testContext.server = server; assert.isNull(err); @@ -67,13 +67,13 @@ function testSetWait(client) { var name = 'azure', test = {}; - test["The pkgcloud " + name + " compute client"] = { - "the setWait() method": { - "with setWait({ status: testContext.server.STATUS.running },": { + test['The pkgcloud ' + name + ' compute client'] = { + 'the setWait() method': { + 'with setWait({ status: testContext.server.STATUS.running },': { topic: function () { testContext.server.setWait({ status: testContext.server.STATUS.running }, 1000, this.callback); }, - "should return a running server": function (err, server) { + 'should return a running server': function (err, server) { testContext.server = server; assert.isNull(err); if (err === null) { @@ -102,7 +102,7 @@ vows .describe('pkgcloud/azure/compute/createServer') .addBatch(testCreateServer(client)) .addBatch(testSetWait(client)) - ["export"](module); + ['export'](module); diff --git a/test/azure/compute/client/test-rebootServer.js b/test/azure/compute/client/test-rebootServer.js index 97b57b9b4..b20235af2 100644 --- a/test/azure/compute/client/test-rebootServer.js +++ b/test/azure/compute/client/test-rebootServer.js @@ -23,9 +23,9 @@ function testCreateServer(client) { var name = 'azure', test = {}; - test["The pkgcloud " + name + " compute client"] = { - "the createServer() method": { - "with image and flavor ids": { + test['The pkgcloud ' + name + ' compute client'] = { + 'the createServer() method': { + 'with image and flavor ids': { topic: function () { client.createServer({ name: options.name, @@ -33,7 +33,7 @@ function testCreateServer(client) { flavor: options.flavor }, this.callback); }, - "should return a valid server": function (err, server) { + 'should return a valid server': function (err, server) { testContext.server = server; assert.isNull(err); @@ -54,13 +54,13 @@ function testSetWait(client) { var name = 'azure', test = {}; - test["The pkgcloud " + name + " compute client"] = { - "the setWait() method": { - "with setWait({ status: testContext.server.STATUS.running },": { + test['The pkgcloud ' + name + ' compute client'] = { + 'the setWait() method': { + 'with setWait({ status: testContext.server.STATUS.running },': { topic: function () { testContext.server.setWait({ status: testContext.server.STATUS.running }, 1000, this.callback); }, - "should return a running server": function (err, server) { + 'should return a running server': function (err, server) { testContext.server = server; assert.isNull(err); if (err === null) { @@ -81,13 +81,13 @@ function testRebootServer(client) { var name = 'azure', test = {}; - test["The pkgcloud " + name + " compute client"] = { - "the rebootServer() method": { - "rebooting server": { + test['The pkgcloud ' + name + ' compute client'] = { + 'the rebootServer() method': { + 'rebooting server': { topic: function () { client.rebootServer(testContext.server, this.callback); }, - "should return a valid server": function (err, res) { + 'should return a valid server': function (err, res) { assert.isNull(err); if (err === null) { @@ -117,6 +117,6 @@ vows .addBatch(testSetWait(client)) .addBatch(testRebootServer(client)) .addBatch(testSetWait(client)) - ["export"](module); + ['export'](module); diff --git a/test/azure/databases/databases-test.js b/test/azure/databases/databases-test.js index 58b2e3b51..71dde426d 100644 --- a/test/azure/databases/databases-test.js +++ b/test/azure/databases/databases-test.js @@ -103,7 +103,7 @@ describe('pkgcloud/azure/databases', function () { if (mock) { hockInstance - .delete("/Tables%28%27testDatabase%27%29") + .delete('/Tables%28%27testDatabase%27%29') .reply(204, '', {'content-length': '0'}); } diff --git a/test/azure/utils/test-cert.js b/test/azure/utils/test-cert.js index c6ea9f8c8..e7c19f5d0 100644 --- a/test/azure/utils/test-cert.js +++ b/test/azure/utils/test-cert.js @@ -4,7 +4,7 @@ var azureCert = require('../../../lib/pkgcloud/azure/utils/cert.js'); // load azure config file (you need to set this up with your azure account info) -var config = JSON.parse(fs.readFileSync("../configs/azure.json",'utf8')); +var config = JSON.parse(fs.readFileSync('../configs/azure.json','utf8')); azureCert.getAzureCert('../../fixtures/azure/cert/management/management.pem', function (err, result) { diff --git a/test/common/base/client-test.js b/test/common/base/client-test.js index fa142793e..60a5d74d6 100644 --- a/test/common/base/client-test.js +++ b/test/common/base/client-test.js @@ -13,7 +13,7 @@ describe('pkgcloud/core/base/client', function () { it('with a wrong request with a cb', function(done) { var cli = new Client(); cli._getUrl = function () { - return "badurl"; + return 'badurl'; }; cli.failCodes = {}; cli._request({ path: '/' }, function(err) { @@ -26,7 +26,7 @@ describe('pkgcloud/core/base/client', function () { var cli = new Client(); cli._getUrl = function () { - return "badurl"; + return 'badurl'; }; cli.failCodes = {}; var stream = cli._request({ path: '/' }); @@ -47,7 +47,7 @@ describe('pkgcloud/core/base/client', function () { it('the before filters throwing an error with a callback should return the error on the cb', function(done) { var cli = new Client(); cli._getUrl = function () { - return "badurl"; + return 'badurl'; }; cli.failCodes = {}; cli.before = [function () { @@ -63,7 +63,7 @@ describe('pkgcloud/core/base/client', function () { var cli = new Client(); cli._getUrl = function () { - return "badurl"; + return 'badurl'; }; cli.failCodes = {}; var stream = cli._request({ path: '/' }); diff --git a/test/common/base/pkgcloud-test.js b/test/common/base/pkgcloud-test.js index 33e55191a..aae497d30 100644 --- a/test/common/base/pkgcloud-test.js +++ b/test/common/base/pkgcloud-test.js @@ -4,7 +4,7 @@ var should = require('should'), describe('pkgcloud/pkgcloud', function() { it('should throw an Error when the provider is not supported', function() { (function () { - pkgcloud.storage.createClient({"provider":"in-memory"}); - }).should.throw(new Error("in-memory is not a supported provider")); + pkgcloud.storage.createClient({ provider: 'in-memory' }); + }).should.throw(new Error('in-memory is not a supported provider')); }); }); diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index 6c95590a8..c1981371b 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -18,7 +18,7 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; -var providers=["openstack"]; +var providers=['openstack']; providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].compute; @@ -88,7 +88,7 @@ providers.filter(function (provider) { }); } - var testMetadata = {"os_type" : "windows"}; + var testMetadata = {os_type: 'windows'}; client.updateImageMeta(context.images[0].id, testMetadata, function (err, reply) { should.not.exist(err); @@ -127,7 +127,10 @@ providers.filter(function (provider) { function setupMetaMock(client, provider, servers) { if (provider === 'openstack') { servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata',{"metadata":{"os_type" : "windows"}}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata', + { metadata: { + os_type :'windows' + }}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/metaResponse.json'); } } diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 5d9c005a0..341c86c12 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -519,7 +519,7 @@ function setupGetServersMock(client, provider, servers) { servers.server .defaultReplyHeaders({'x-ms-request-id': requestId, 'Content-Type': 'application/xml'}) .get('/azure-account-subscription-id/services/hostedservices') - .reply(200, "https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z") + .reply(200, 'https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z') .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } @@ -568,7 +568,7 @@ function setupGetServerMock(client, provider, servers) { servers.server .defaultReplyHeaders({'x-ms-request-id': requestId, 'Content-Type': 'application/xml'}) .get('/azure-account-subscription-id/services/hostedservices') - .reply(200, "https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z") + .reply(200, 'https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z') .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 8e5cdbe2c..889d02d6f 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -174,7 +174,7 @@ providers.filter(function (provider) { } var network = new Network(client); - network.name = "model created network"; + network.name = 'model created network'; network.create(function (err, createdNetwork) { should.not.exist(err); should.exist(createdNetwork); @@ -188,7 +188,7 @@ providers.filter(function (provider) { var m = mock ? 0.1 : 10; var network = new Network(client); - network.id = "d32019d3-bc6e-4319-9c1d-6722fc136a22"; + network.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; if (mock) { setupRefreshNetworkMock(client, provider, { @@ -209,8 +209,8 @@ providers.filter(function (provider) { it('the network.destroy() method should delete a network', function (done) { var network = new Network(client); - network.name = "model deleted network"; - network.id = "THISISANETWORKID"; + network.name = 'model deleted network'; + network.id = 'THISISANETWORKID'; if (mock) { setupModelDestroyedNetworkMock(client, provider, { @@ -265,11 +265,11 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id), { - "network": { - "admin_state_up": false, - "name": "private-network", - "shared": true, - "tenant_id": "4fd44f30292945e481c7b8a0c8908869" + network: { + admin_state_up: false, + name: 'private-network', + shared: true, + tenant_id: '4fd44f30292945e481c7b8a0c8908869' } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); @@ -277,11 +277,11 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ else if (provider === 'hp') { servers.server .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/networks', currentNetwork.id), { - "network": { - "admin_state_up": false, - "name": "private-network", - "shared": true, - "tenant_id": "4fd44f30292945e481c7b8a0c8908869" + network: { + admin_state_up: false, + name: 'private-network', + shared: true, + tenant_id: '4fd44f30292945e481c7b8a0c8908869' } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/network.json'); @@ -289,11 +289,11 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ else if (provider === 'rackspace') { servers.server .put(urlJoin('/v2.0/networks', currentNetwork.id), { - "network": { - "admin_state_up": false, - "name": "private-network", - "shared": true, - "tenant_id": "4fd44f30292945e481c7b8a0c8908869" + network: { + admin_state_up: false, + name: 'private-network', + shared: true, + tenant_id: '4fd44f30292945e481c7b8a0c8908869' } }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 0d002300b..08eb3ba34 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -176,7 +176,7 @@ providers.filter(function (provider) { } var port = new Port(client); - port.name= "model created network"; + port.name= 'model created network'; port.create(function (err, createdPort) { should.not.exist(err); should.exist(createdPort); @@ -211,8 +211,8 @@ providers.filter(function (provider) { it('the port.destroy() method should delete a port', function (done) { var port = new Port(client); - port.name = "model deleted port"; - port.id = "THISISANETWORKID"; + port.name = 'model deleted port'; + port.id = 'THISISANETWORKID'; if (mock) { setupModelDestroyedPortMock(client, provider, { @@ -267,19 +267,19 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id), { - "port": { - "status": "ACTIVE", - "name": "my_port", - "admin_state_up": false, - "mac_address": "fa:16:3e:58:42:ed", - "fixed_ips": [ + port: { + status: 'ACTIVE', + name: 'my_port', + admin_state_up: false, + mac_address: 'fa:16:3e:58:42:ed', + fixed_ips: [ { - "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", - "ip_address":"172.24.4.2" + subnet_id: '008ba151-0b8c-4a67-98b5-0d2b87666062', + ip_address: '172.24.4.2' } ], - "security_groups":[], - "network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3" + security_groups:[], + network_id: '70c1db1f-b701-45bd-96e0-a313ee3430b3' } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); @@ -287,19 +287,19 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ else if (provider === 'hp') { servers.server .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/ports', currentPort.id), { - "port": { - "status": "ACTIVE", - "name": "my_port", - "admin_state_up": false, - "mac_address": "fa:16:3e:58:42:ed", - "fixed_ips": [ + port: { + status: 'ACTIVE', + name: 'my_port', + admin_state_up: false, + mac_address: 'fa:16:3e:58:42:ed', + fixed_ips: [ { - "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", - "ip_address":"172.24.4.2" + subnet_id: '008ba151-0b8c-4a67-98b5-0d2b87666062', + ip_address: '172.24.4.2' } ], - "security_groups":[], - "network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3" + security_groups:[], + network_id: '70c1db1f-b701-45bd-96e0-a313ee3430b3' } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/port.json'); @@ -307,19 +307,19 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ else if (provider === 'rackspace') { servers.server .put(urlJoin('/v2.0/ports', currentPort.id), { - "port": { - "status": "ACTIVE", - "name": "my_port", - "admin_state_up": false, - "mac_address": "fa:16:3e:58:42:ed", - "fixed_ips": [ + port: { + status: 'ACTIVE', + name: 'my_port', + admin_state_up: false, + mac_address: 'fa:16:3e:58:42:ed', + fixed_ips: [ { - "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062", - "ip_address":"172.24.4.2" + subnet_id: '008ba151-0b8c-4a67-98b5-0d2b87666062', + ip_address: '172.24.4.2' } ], - "security_groups":[], - "network_id":"70c1db1f-b701-45bd-96e0-a313ee3430b3" + security_groups:[], + network_id: '70c1db1f-b701-45bd-96e0-a313ee3430b3' } }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index 32f9f82b7..a4abf240c 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -176,7 +176,7 @@ providers.filter(function (provider) { } var subnet = new Subnet(client); - subnet.name= "model created network"; + subnet.name= 'model created network'; subnet.create(function (err, createdSubnet) { should.not.exist(err); should.exist(createdSubnet); @@ -190,7 +190,7 @@ providers.filter(function (provider) { var m = mock ? 0.1 : 10; var subnet = new Subnet(client); - subnet.id = "d32019d3-bc6e-4319-9c1d-6722fc136a22"; + subnet.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; if (mock) { setupRefreshSubnetMock(client, provider, { @@ -211,8 +211,8 @@ providers.filter(function (provider) { it('the subnet.destroy() method should delete a subnet', function (done) { var subnet = new Subnet(client); - subnet.name = "model deleted subnet"; - subnet.id = "THISISANETWORKID"; + subnet.name = 'model deleted subnet'; + subnet.id = 'THISISANETWORKID'; if (mock) { setupModelDestroyedSubnetMock(client, provider, { @@ -267,20 +267,20 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id), { - "subnet": { - "name": "my_subnet", - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "allocation_pools": [ + subnet: { + name: 'my_subnet', + network_id: 'd32019d3-bc6e-4319-9c1d-6722fc136a22', + tenant_id: '4fd44f30292945e481c7b8a0c8908869', + allocation_pools: [ { - "start": "192.0.0.2", - "end": "192.255.255.254" + start: '192.0.0.2', + end: '192.255.255.254' } ], - "gateway_ip": "192.0.0.1", - "ip_version": 4, - "cidr": "192.0.0.0/8", - "enable_dhcp": false + gateway_ip: '192.0.0.1', + ip_version: 4, + cidr: '192.0.0.0/8', + enable_dhcp: false } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); @@ -288,20 +288,20 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ else if (provider === 'hp') { servers.server .put(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/subnets', currentSubnet.id), { - "subnet": { - "name": "my_subnet", - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "allocation_pools": [ + subnet: { + name: 'my_subnet', + network_id: 'd32019d3-bc6e-4319-9c1d-6722fc136a22', + tenant_id: '4fd44f30292945e481c7b8a0c8908869', + allocation_pools: [ { - "start": "192.0.0.2", - "end": "192.255.255.254" + start: '192.0.0.2', + end: '192.255.255.254' } ], - "gateway_ip": "192.0.0.1", - "ip_version": 4, - "cidr": "192.0.0.0/8", - "enable_dhcp": false + gateway_ip: '192.0.0.1', + ip_version: 4, + cidr: '192.0.0.0/8', + enable_dhcp: false } }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/subnet.json'); @@ -309,20 +309,20 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ else if (provider === 'rackspace') { servers.server .put(urlJoin('/v2.0/subnets', currentSubnet.id), { - "subnet": { - "name": "my_subnet", - "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22", - "tenant_id": "4fd44f30292945e481c7b8a0c8908869", - "allocation_pools": [ + subnet: { + name: 'my_subnet', + network_id: 'd32019d3-bc6e-4319-9c1d-6722fc136a22', + tenant_id: '4fd44f30292945e481c7b8a0c8908869', + allocation_pools: [ { - "start": "192.0.0.2", - "end": "192.255.255.254" + start: '192.0.0.2', + end: '192.255.255.254' } ], - "gateway_ip": "192.0.0.1", - "ip_version": 4, - "cidr": "192.0.0.0/8", - "enable_dhcp": false + gateway_ip: '192.0.0.1', + ip_version: 4, + cidr: '192.0.0.0/8', + enable_dhcp: false } }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 364f37aad..3dbf3daf6 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -594,7 +594,7 @@ function setupUploadStreamMock(provider, client, servers) { servers.server .put('/pkgcloud-test-container/test-file.txt?comp=block&blockid=block000000000000000', fillerama) .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) - .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', "block000000000000000") + .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', 'block000000000000000') .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) .get('/pkgcloud-test-container/test-file.txt') .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index 223443a60..8fd5c1bab 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -47,19 +47,19 @@ exports.serverTest = function (nock, testHelpers) { .defaultReplyHeaders({'x-ms-request-id': requestId, 'Content-Type': 'application/xml'}) // createServer() create-test-ids2 .post('/azure-account-subscription-id/services/hostedservices/create-test-ids2/deployments', helpers.loadFixture('azure/create-test-ids2.xml')) - .reply(202, "", {}) + .reply(202, '', {}) // createServer() test-reboot .post('/azure-account-subscription-id/services/hostedservices/test-reboot/deployments', helpers.loadFixture('azure/create-test-reboot.xml')) - .reply(202, "", {}) + .reply(202, '', {}) // destroyServer() .delete('/azure-account-subscription-id/services/hostedservices/create-test-ids2/deployments/create-test-ids2') - .reply(202, "", {}) + .reply(202, '', {}) // shutDown server .post('/azure-account-subscription-id/services/hostedservices/create-test-ids2/deployments/create-test-ids2/roleInstances/create-test-ids2/Operations', helpers.loadFixture('azure/shutdown-role.xml')) - .reply(201, "", {}) + .reply(201, '', {}) // rebootServer() .post('/azure-account-subscription-id/services/hostedservices/test-reboot/deployments/test-reboot/roleInstances/test-reboot/Operations', 'RestartRoleOperation') - .reply(202, "", {}); + .reply(202, '', {}); // getServer() status nock('https://management.core.windows.net') @@ -91,31 +91,31 @@ exports.serverTest = function (nock, testHelpers) { nock('https://management.core.windows.net') .defaultReplyHeaders({'x-ms-request-id': requestId, 'Content-Type': 'application/xml'}) .get('/azure-account-subscription-id/services/hostedservices') - .reply(200, "https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z", {}) + .reply(200, 'https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z', {}) .get('/azure-account-subscription-id/services/hostedservices') - .reply(200, "https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z", {}) + .reply(200, 'https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z', {}) .get('/azure-account-subscription-id/services/hostedservices/test-reboot?embed-detail=true') .reply(404,helpers.loadFixture('azure/hosted-service-404.xml'),{}) .post('/azure-account-subscription-id/services/hostedservices', helpers.loadFixture('azure/create-test-reboot-hosted-service.xml')) - .reply(201, "", {}) + .reply(201, '', {}) //delete hosted service .delete('/azure-account-subscription-id/services/hostedservices/create-test-ids2') - .reply(200, "", {}) + .reply(200, '', {}) .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(404,helpers.loadFixture('azure/hosted-service-404.xml'),{}) .post('/azure-account-subscription-id/services/hostedservices', helpers.loadFixture('azure/create-test-ids2-hosted-service.xml')) - .reply(201, "", {}); + .reply(201, '', {}); // VM OSImage disk nock('https://management.core.windows.net') .defaultReplyHeaders({'x-ms-request-id': requestId, 'Content-Type': 'application/xml'}) .delete('/azure-account-subscription-id/services/disks/create-test-ids2-create-test-ids2-0-20121111181413') - .reply(200, "", {}); + .reply(200, '', {}); // VM image blob nock('http://test-storage-account.' + azureApi.STORAGE_ENDPOINT) .delete('/vhd/create-test-ids2.vhd') - .reply(202, "", helpers.azureDeleteResponseHeaders()); + .reply(202, '', helpers.azureDeleteResponseHeaders()); // Certificates nock('https://management.core.windows.net') @@ -123,9 +123,9 @@ exports.serverTest = function (nock, testHelpers) { // need to filter request body because base64 of cert is different on mac/windows .filteringRequestBody(/.*/, '*') .post('/azure-account-subscription-id/services/hostedservices/test-reboot/certificates', '*') - .reply(202, "", {}) + .reply(202, '', {}) .post('/azure-account-subscription-id/services/hostedservices/create-test-ids2/certificates', '*') - .reply(202, "", {}); + .reply(202, '', {}); // Get Operations status requests // we need a lot of these diff --git a/test/helpers/index.js b/test/helpers/index.js index 85b0b3a33..f95ca4aeb 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -36,7 +36,7 @@ helpers.createClient = function createClient(provider, service, config) { config.keyId = '/' + config.account + '/keys/' + config.keyId; config.key = fs.readFileSync(config.identity,'ascii'); } else { - throw new Error("Can't test without username and account"); + throw new Error('Can\'t test without username and account'); } } } @@ -80,16 +80,16 @@ helpers.loadFixture = function loadFixture(path, json) { helpers.personalityPost = function persPost(pubkey) { return JSON.stringify({ - "server": { - "name": "create-personality-test", - "image": 49, - "flavor": 1, - "personality": [{ - "path": "/root/.ssh/authorized_keys", - "contents": pubkey.toString('base64') + server: { + name: 'create-personality-test', + image: 49, + flavor: 1, + personality: [{ + path: '/root/.ssh/authorized_keys', + contents: pubkey.toString('base64') }], - "flavorId": 1, - "imageId": 49 + flavorId: 1, + imageId: 49 } }); }; diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js index 1af01beca..222058923 100644 --- a/test/hp/common/client-test.js +++ b/test/hp/common/client-test.js @@ -18,31 +18,31 @@ describe('pkgcloud/hp/client', function () { it('User should specify region: compute client', function() { (function () { pkgcloud.compute.createClient({ - "provider": "hp", - "username": "username", - "password": "password" + provider: 'hp', + username: 'username', + password: 'password' }); - }).should.throw(new Error("region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)');")); + }).should.throw(new Error('region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)\');')); }); it('User should specify region: storage client', function() { (function () { pkgcloud.storage.createClient({ - "provider": "hp", - "username": "username", - "password": "password" + provider: 'hp', + username: 'username', + password: 'password' }); - }).should.throw(new Error("region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)');")); + }).should.throw(new Error('region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)\');')); }); it('User can specify custom region: storage client', function() { var customRegionClient = pkgcloud.storage.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "region": "mycustomregion", - "authUrl": "http://my-identity-service.com" + provider: 'hp', + username: 'username', + password: 'password', + region: 'mycustomregion', + authUrl: 'http://my-identity-service.com' }); customRegionClient.config.should.have.property('region','mycustomregion'); @@ -50,11 +50,11 @@ describe('pkgcloud/hp/client', function () { it('User can specify custom region: compute client', function() { var customRegionClient = pkgcloud.compute.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "region": "mycustomregion", - "authUrl": "http://my-identity-service.com" + provider: 'hp', + username: 'username', + password: 'password', + region: 'mycustomregion', + authUrl: 'http://my-identity-service.com' }); customRegionClient.config.should.have.property('region','mycustomregion'); @@ -66,35 +66,35 @@ describe('pkgcloud/hp/client', function () { it('Client will not resolve URI if useInternal is true : East US',function(){ (function () { pkgcloud.compute.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "useInternal": true, - "region": eastUSRegion + provider: 'hp', + username: 'username', + password: 'password', + useInternal: true, + region: eastUSRegion }); - }).should.throw("authUrl is invalid"); + }).should.throw('authUrl is invalid'); }); it('Client will not resolve URI if useInternal is true : West US',function(){ (function () { pkgcloud.compute.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "useInternal": true, - "region": westUSRegion + provider: 'hp', + username: 'username', + password: 'password', + useInternal: true, + region: westUSRegion }); - }).should.throw("authUrl is invalid"); + }).should.throw('authUrl is invalid'); it('User can specify custom url for private cloud : West US',function(){ var privateClient = pkgcloud.compute.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "useInternal": true, - "authUrl": "http://my-internal-identity-service.com", - "region": westUSRegion + provider: 'hp', + username: 'username', + password: 'password', + useInternal: true, + authUrl: 'http://my-internal-identity-service.com', + region: westUSRegion }); privateClient.config.should.have.property('authUrl','http://my-internal-identity-service.com'); @@ -102,12 +102,12 @@ describe('pkgcloud/hp/client', function () { it('User can specify custom url for private cloud : East US',function(){ var privateClient = pkgcloud.compute.createClient({ - "provider": "hp", - "username": "username", - "password": "password", - "useInternal": true, - "authUrl": "http://my-internal-identity-service.com", - "region": eastUSRegion + provider: 'hp', + username: 'username', + password: 'password', + useInternal: true, + authUrl: 'http://my-internal-identity-service.com', + region: eastUSRegion }); privateClient.config.should.have.property('authUrl','http://my-internal-identity-service.com'); diff --git a/test/hp/macros.js b/test/hp/macros.js index ceef56992..0a1225c45 100644 --- a/test/hp/macros.js +++ b/test/hp/macros.js @@ -23,34 +23,34 @@ exports.shouldHaveCreds = function (client) { }; exports.shouldCreateContainer = function (client, name, message) { - message = message || "when creating a container"; + message = message || 'when creating a container'; var context = {}; context[message] = { topic: function () { client.createContainer(name, this.callback); }, - "should return a valid container": function (err, container) { + 'should return a valid container': function (err, container) { assert.isNull(err); assert.assertContainer(container); } }; return { - "The pkgcloud Rackspace storage client": { - "the createContainer() method": context + 'The pkgcloud Rackspace storage client': { + 'the createContainer() method': context } }; }; exports.shouldDestroyContainer = function (client, name) { return { - "The pkgcloud Rackspace storage client": { - "the destroyContainer() method": { + 'The pkgcloud Rackspace storage client': { + 'the destroyContainer() method': { topic: function () { client.destroyContainer(name, this.callback); }, - "should return true": function (err, success) { + 'should return true': function (err, success) { assert.isTrue(success); } } @@ -66,7 +66,7 @@ exports.upload.fullpath = function (client, options) { client.upload(options, function () { }) .on('end', this.callback); }, - "should raise the `end` event": function () { + 'should raise the `end` event': function () { assert.isTrue(true); } }; @@ -84,7 +84,7 @@ exports.upload.stream = function (client, container, local, remote) { } }, function () { }).on('end', this.callback); }, - "should raise the `end` event": function () { + 'should raise the `end` event': function () { assert.isTrue(true); } }; @@ -101,7 +101,7 @@ exports.upload.piped = function (client, container, local, remote) { filed(local).pipe(ustream); ustream.on('end', this.callback); }, - "should raise the `end` event": function () { + 'should raise the `end` event': function () { assert.isTrue(true); } }; diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js index a6cb0ba2a..1919133ae 100644 --- a/test/iriscouch/databases/databases-redis-test.js +++ b/test/iriscouch/databases/databases-redis-test.js @@ -29,7 +29,7 @@ describe('pkgcloud/iriscouch/databases-redis', function () { it('the create() method with correct options should respond correctly', function(done) { var subdomain = (mock ? 'nodejitsudb43639' : 'nodejitsudb' + Math.floor(Math.random() * 100000)); - context.tempPassword = (mock ? 'sTTi:lh9vCF[' : randomPassword(12).replace("\\", "")); + context.tempPassword = (mock ? 'sTTi:lh9vCF[' : randomPassword(12).replace('\\', '')); if (mock) { hockInstance @@ -42,10 +42,10 @@ describe('pkgcloud/iriscouch/databases-redis', function () { client.create({ subdomain: subdomain, - first_name: "Marak", - last_name: "Squires", - email: "marak.squires@gmail.com", - type: "redis", // For redis instead of couch just put type to redis + first_name: 'Marak', + last_name: 'Squires', + email: 'marak.squires@gmail.com', + type: 'redis', // For redis instead of couch just put type to redis password: context.tempPassword }, function(err, database) { should.not.exist(err); diff --git a/test/mongohq/databases/databases-test.js b/test/mongohq/databases/databases-test.js index de64d2ce4..4a360439d 100644 --- a/test/mongohq/databases/databases-test.js +++ b/test/mongohq/databases/databases-test.js @@ -31,7 +31,7 @@ describe('pkgcloud/mongohq/databases', function () { if (mock) { hockInstance - .post('/provider/resources', "app_id=testDatabase&plan=free") + .post('/provider/resources', 'app_id=testDatabase&plan=free') .reply(200, helpers.loadFixture('mongohq/database.json')); } @@ -57,7 +57,7 @@ describe('pkgcloud/mongohq/databases', function () { if (mock) { hockInstance .delete('/provider/resources/63562') - .reply(200, "OK"); + .reply(200, 'OK'); } client.remove(context.databaseId, function (err, confirm) { diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js index 4fc194e31..4094ddc59 100644 --- a/test/mongolab/databases/databases-test.js +++ b/test/mongolab/databases/databases-test.js @@ -62,7 +62,7 @@ describe('pkgcloud/mongolab/databases', function () { // if (mock) { // server // .delete('/provider/resources/63562') -// .reply(200, "OK"); +// .reply(200, 'OK'); // } // // client.remove(context.databaseId, function (err, confirm) { @@ -339,7 +339,7 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases/nodejitsu_daniel_testDatabase') - .reply(200, " null "); + .reply(200, ' null '); } client.remove({ @@ -406,7 +406,7 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel') - .reply(200, " null "); + .reply(200, ' null '); } client.deleteAccount(context.account.username, @@ -423,7 +423,7 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_custompassword') - .reply(200, " null "); + .reply(200, ' null '); } client.deleteAccount(context.custompw.username, function (err, databases) { diff --git a/test/openstack/compute/client/startServer-test.js b/test/openstack/compute/client/startServer-test.js index a2e86f1d4..dc8036735 100644 --- a/test/openstack/compute/client/startServer-test.js +++ b/test/openstack/compute/client/startServer-test.js @@ -71,7 +71,8 @@ var options = {}; .reply(200, helpers.getOpenstackAuthResponse()); hockInstance - .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', {"os-start":null}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', + { 'os-start': null }) .reply(202, ''); } diff --git a/test/openstack/compute/client/stopServer-test.js b/test/openstack/compute/client/stopServer-test.js index e85891983..0dfff491d 100644 --- a/test/openstack/compute/client/stopServer-test.js +++ b/test/openstack/compute/client/stopServer-test.js @@ -71,7 +71,8 @@ var options = {}; .reply(200, helpers.getOpenstackAuthResponse()); hockInstance - .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', {"os-stop":null}) + .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', + { 'os-stop' : null }) .reply(202, ''); } diff --git a/test/openstack/identity/service-test.js b/test/openstack/identity/service-test.js index 9b79227e6..662ba9836 100644 --- a/test/openstack/identity/service-test.js +++ b/test/openstack/identity/service-test.js @@ -17,16 +17,16 @@ describe('pkgcloud openstack context Service Class', function() { it('with valid options should return a service', function () { var service = new context.Service({ - "endpoints": [ + endpoints: [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + adminURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + internalURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + publicURL: 'http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041' } ], - "endpoints_links": [], - "type": "volume", - "name": "volume" + endpoints_links: [], + type: 'volume', + name: 'volume' }); service.should.be.instanceOf(context.Service); @@ -34,16 +34,16 @@ describe('pkgcloud openstack context Service Class', function() { it('with valid options getEndpointUrl should return a endpoint URL', function () { var service = new context.Service({ - "endpoints": [ + endpoints: [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + adminURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + internalURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + publicURL: 'http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041' } ], - "endpoints_links": [], - "type": "volume", - "name": "volume" + endpoints_links: [], + type: 'volume', + name: 'volume' }); service.getEndpointUrl().should.equal('http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041'); @@ -51,16 +51,16 @@ describe('pkgcloud openstack context Service Class', function() { it('with valid options getEndpointUrl with invalid region should throw', function () { var service = new context.Service({ - "endpoints": [ + endpoints: [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + adminURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + internalURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + publicURL: 'http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041' } ], - "endpoints_links": [], - "type": "volume", - "name": "volume" + endpoints_links: [], + type: 'volume', + name: 'volume' }); (function() { @@ -71,22 +71,22 @@ describe('pkgcloud openstack context Service Class', function() { it('with valid options getEndpointUrl with valid region return correctly', function () { var service = new context.Service({ - "endpoints": [ + endpoints: [ { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + adminURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + internalURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + publicURL: 'http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041' }, { - "adminURL": "http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume2.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041", - "region":"ORD" + adminURL: 'http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041', + internalURL: 'http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041', + publicURL: 'http://volume2.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041', + region:'ORD' } ], - "endpoints_links": [], - "type": "volume", - "name": "volume" + endpoints_links: [], + type: 'volume', + name: 'volume' }); service.getEndpointUrl({ region: 'ORD' }) @@ -95,23 +95,23 @@ describe('pkgcloud openstack context Service Class', function() { it('with valid options getEndpointUrl without region when region is available return correctly', function () { var service = new context.Service({ - "endpoints": [ + endpoints: [ { - "adminURL": "http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume2.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041", - "region": "ORD" + adminURL: 'http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041', + internalURL: 'http://10.225.0.9:8776/v1/72e90ecb69c44d0296072ea39e537041', + publicURL: 'http://volume2.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041', + region: 'ORD' }, { - "adminURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "internalURL": "http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041", - "publicURL": "http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041" + adminURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + internalURL: 'http://10.225.0.8:8776/v1/72e90ecb69c44d0296072ea39e537041', + publicURL: 'http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041' } ], - "endpoints_links": [], - "type": "volume", - "name": "volume" + endpoints_links: [], + type: 'volume', + name: 'volume' }); service.getEndpointUrl().should.equal('http://volume.myownendpoint.org:8776/v1/72e90ecb69c44d0296072ea39e537041'); diff --git a/test/rackspace/compute/personality-test.js b/test/rackspace/compute/personality-test.js index e5ae5aed0..c19f84523 100644 --- a/test/rackspace/compute/personality-test.js +++ b/test/rackspace/compute/personality-test.js @@ -33,7 +33,7 @@ describe('pkgcloud/rackspace/compute/personality', function () { flavor: 1, // 256 server personality: [ { - path: "/root/.ssh/authorized_keys", + path: '/root/.ssh/authorized_keys', contents: keyBuffer.toString('base64') } ] @@ -56,7 +56,7 @@ describe('pkgcloud/rackspace/compute/personality', function () { '-q', '-o', 'StrictHostKeyChecking no', - 'root@' + testServer.addresses["public"][0], + 'root@' + testServer.addresses['public'][0], 'cat /root/.ssh/authorized_keys' ]); diff --git a/test/rackspace/databases/authentication-test.js b/test/rackspace/databases/authentication-test.js index a37cdf633..562a6addb 100644 --- a/test/rackspace/databases/authentication-test.js +++ b/test/rackspace/databases/authentication-test.js @@ -63,13 +63,13 @@ describe('pkgcloud/rackspace/database/authentication', function() { .reply(200, { versions: [ { - "status": "CURRENT", - "updated": "2012-08-01T00:00:00Z", - "id": "v1.0", - "links": [ + status: 'CURRENT', + updated: '2012-08-01T00:00:00Z', + id: 'v1.0', + links: [ { - "href": "http://dfw.databases.api.rackspacecloud.com/v1.0/", - "rel": "self" + href: 'http://dfw.databases.api.rackspacecloud.com/v1.0/', + rel: 'self' } ] } diff --git a/test/rackspace/macros.js b/test/rackspace/macros.js index ceef56992..0a1225c45 100644 --- a/test/rackspace/macros.js +++ b/test/rackspace/macros.js @@ -23,34 +23,34 @@ exports.shouldHaveCreds = function (client) { }; exports.shouldCreateContainer = function (client, name, message) { - message = message || "when creating a container"; + message = message || 'when creating a container'; var context = {}; context[message] = { topic: function () { client.createContainer(name, this.callback); }, - "should return a valid container": function (err, container) { + 'should return a valid container': function (err, container) { assert.isNull(err); assert.assertContainer(container); } }; return { - "The pkgcloud Rackspace storage client": { - "the createContainer() method": context + 'The pkgcloud Rackspace storage client': { + 'the createContainer() method': context } }; }; exports.shouldDestroyContainer = function (client, name) { return { - "The pkgcloud Rackspace storage client": { - "the destroyContainer() method": { + 'The pkgcloud Rackspace storage client': { + 'the destroyContainer() method': { topic: function () { client.destroyContainer(name, this.callback); }, - "should return true": function (err, success) { + 'should return true': function (err, success) { assert.isTrue(success); } } @@ -66,7 +66,7 @@ exports.upload.fullpath = function (client, options) { client.upload(options, function () { }) .on('end', this.callback); }, - "should raise the `end` event": function () { + 'should raise the `end` event': function () { assert.isTrue(true); } }; @@ -84,7 +84,7 @@ exports.upload.stream = function (client, container, local, remote) { } }, function () { }).on('end', this.callback); }, - "should raise the `end` event": function () { + 'should raise the `end` event': function () { assert.isTrue(true); } }; @@ -101,7 +101,7 @@ exports.upload.piped = function (client, container, local, remote) { filed(local).pipe(ustream); ustream.on('end', this.callback); }, - "should raise the `end` event": function () { + 'should raise the `end` event': function () { assert.isTrue(true); } }; diff --git a/test/rackspace/storage/storage-object-test.js b/test/rackspace/storage/storage-object-test.js index 16721d48f..cdcb9b5a9 100755 --- a/test/rackspace/storage/storage-object-test.js +++ b/test/rackspace/storage/storage-object-test.js @@ -16,7 +16,7 @@ var path = require('path'), hock = require('hock'), File = require('../../../lib/pkgcloud/core/storage/file').File, mock = !!process.env.MOCK, - Buffer = require("buffer").Buffer; + Buffer = require('buffer').Buffer; if (!mock) { return; // these tests are disabled when running for real @@ -37,17 +37,17 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { var generateFilesResponse = function (start, end) { var files = []; function padToFive(number) { - if (number<=99999) { number = ("0000"+number).slice(-5); } + if (number<=99999) { number = ('0000'+number).slice(-5); } return number; } for (var i = start; i < end; i++) { files.push({ - "hash": "cb5c530452af82fb875dc0fb1a00a2c4", - "last_modified": "2013-05-20T22:48:08.059180", - "bytes": 2027, - "name": "FILE" + padToFive(i), - "content_type": "application/octet-stream" + hash: 'cb5c530452af82fb875dc0fb1a00a2c4', + last_modified: '2013-05-20T22:48:08.059180', + bytes: 2027, + name: 'FILE' + padToFive(i), + content_type: 'application/octet-stream' }); } @@ -252,9 +252,9 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { it('extract should ask server to extract the uploaded tar file', function(done) { - var data = "H4sIABub81EAA+3TzUrEMBAH8CiIeNKTXvMC1nxuVzx58CiC9uBNam1kQZt1N4X1XXwDX9IJXVi6UDxo6sH/D4akadJOmY7z/owlJkhubTdOulEo040dJpXMTS6tjuuSriTjNnViUbsM5YJztvCPs+atHdxH25wbI6FxOap/9hDqZcjCKqR5RyzwxJjB+iurN/WXiuqvpdGMizTp9P3z+rO94322y9h1WfGbO37P1+IaO6BQFO8U8fqzd/Jo6JGXRXG7nsYTHxSHW1t2NusnlX/Nyvn8pc6KehWumso/zZpnutkGdzq9kNrQv3E+Nb/yudAX+z9t93/f/0LIrf5XNEP/j0H+dQIAAAAAAAAAAAAAAAAAAADwY194ELb5ACgAAA=="; - var tmp = "./foo.tar.gz"; - fs.writeFileSync(tmp, new Buffer(data, "base64")); + var data = 'H4sIABub81EAA+3TzUrEMBAH8CiIeNKTXvMC1nxuVzx58CiC9uBNam1kQZt1N4X1XXwDX9IJXVi6UDxo6sH/D4akadJOmY7z/owlJkhubTdOulEo040dJpXMTS6tjuuSriTjNnViUbsM5YJztvCPs+atHdxH25wbI6FxOap/9hDqZcjCKqR5RyzwxJjB+iurN/WXiuqvpdGMizTp9P3z+rO94322y9h1WfGbO37P1+IaO6BQFO8U8fqzd/Jo6JGXRXG7nsYTHxSHW1t2NusnlX/Nyvn8pc6KehWumso/zZpnutkGdzq9kNrQv3E+Nb/yudAX+z9t93/f/0LIrf5XNEP/j0H+dQIAAAAAAAAAAAAAAAAAAADwY194ELb5ACgAAA=='; + var tmp = './foo.tar.gz'; + fs.writeFileSync(tmp, new Buffer(data, 'base64')); if (mock) { authHockInstance @@ -269,7 +269,7 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { .reply(200, helpers.getRackspaceAuthResponse()); hockInstance - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?extract-archive=tar.gz', new Buffer(data, "base64").toString()) + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?extract-archive=tar.gz', new Buffer(data, 'base64').toString()) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/extract.json'); } diff --git a/test/redistogo/databases/databases-test.js b/test/redistogo/databases/databases-test.js index 136541990..03f85ef14 100644 --- a/test/redistogo/databases/databases-test.js +++ b/test/redistogo/databases/databases-test.js @@ -35,7 +35,7 @@ describe('pkgcloud/redistogo/databases', function () { if (mock) { hockInstance - .post('/instances.json', "instance%5Bplan%5D=nano") + .post('/instances.json', 'instance%5Bplan%5D=nano') .replyWithFile(201, __dirname + '/../../fixtures/redistogo/database.json'); } From bb736077554faa8902f0e5c07d2351da28fc83ee Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 1 Dec 2014 07:38:41 -0800 Subject: [PATCH 263/460] Adding `freeze` to jshint config - part of #360 --- .jshintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 17277c695..8d412fe2a 100644 --- a/.jshintrc +++ b/.jshintrc @@ -7,7 +7,7 @@ "curly" : false, // true: Require {} for every new block or scope "eqeqeq" : false, // true: Require triple equals (===) for comparison "forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() - "freeze" : false, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. + "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` "indent" : false, // {int} Number of spaces to use for indentation "latedef" : false, // true: Require variables/functions to be defined before being used From 907474186eedafa6c80a271a8ed3d6a44c54e9a4 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 1 Dec 2014 07:54:26 -0800 Subject: [PATCH 264/460] Add jshint config to require curly braces for blocks - Part of #360 --- .jshintrc | 2 +- lib/pkgcloud/amazon/compute/client/images.js | 9 ++++++-- lib/pkgcloud/amazon/compute/client/servers.js | 5 ++++- lib/pkgcloud/amazon/compute/flavor.js | 4 +++- lib/pkgcloud/azure/compute/client/images.js | 9 ++++++-- lib/pkgcloud/azure/compute/flavor.js | 4 +++- lib/pkgcloud/azure/storage/utils.js | 22 ++++++++++++++----- lib/pkgcloud/core/compute/server.js | 5 ++++- lib/pkgcloud/joyent/compute/client/servers.js | 14 +++++++++--- lib/pkgcloud/openstack/database/database.js | 9 ++++++-- lib/pkgcloud/rackspace/dns/client/zones.js | 10 +++++---- test/helpers/index.js | 5 ++++- 12 files changed, 74 insertions(+), 24 deletions(-) diff --git a/.jshintrc b/.jshintrc index 17277c695..6ba47b01c 100644 --- a/.jshintrc +++ b/.jshintrc @@ -4,7 +4,7 @@ // Enforcing "bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.) "camelcase" : false, // true: Identifiers must be in camelCase - "curly" : false, // true: Require {} for every new block or scope + "curly" : true, // true: Require {} for every new block or scope "eqeqeq" : false, // true: Require triple equals (===) for comparison "forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() "freeze" : false, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. diff --git a/lib/pkgcloud/amazon/compute/client/images.js b/lib/pkgcloud/amazon/compute/client/images.js index adba2f431..8f9b8b97a 100644 --- a/lib/pkgcloud/amazon/compute/client/images.js +++ b/lib/pkgcloud/amazon/compute/client/images.js @@ -96,8 +96,13 @@ exports.getImage = function getImage(image, callback) { exports.createImage = function createImage(options, callback) { options || (options = {}); - if (!options.name) throw new TypeError('`name` is a required option'); - if (!options.server) throw new TypeError('`server` is a required option'); + if (!options.name) { + throw new TypeError('`name` is a required option'); + } + + if (!options.server) { + throw new TypeError('`server` is a required option'); + } var self = this, serverId = options.server instanceof base.Server diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index 625beba12..d000b22d6 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -252,7 +252,10 @@ exports.getServer = function getServer(server, callback) { } self._getDetails(server, function (err, server) { - if (err) return callback(err); + if (err) { + return callback(err); + } + callback(null, new compute.Server(self, server)); }); } diff --git a/lib/pkgcloud/amazon/compute/flavor.js b/lib/pkgcloud/amazon/compute/flavor.js index 036ae2f22..55e8409a9 100644 --- a/lib/pkgcloud/amazon/compute/flavor.js +++ b/lib/pkgcloud/amazon/compute/flavor.js @@ -63,7 +63,9 @@ Flavor.options = { Flavor.prototype._setProperties = function (details) { var id = details.name || 'm1.small'; - if (!Flavor.options[id]) throw new TypeError('No such AWS Flavor: ' + id); + if (!Flavor.options[id]) { + throw new TypeError('No such AWS Flavor: ' + id); + } this.id = id; this.name = id; diff --git a/lib/pkgcloud/azure/compute/client/images.js b/lib/pkgcloud/azure/compute/client/images.js index 50976b49f..075f61b88 100644 --- a/lib/pkgcloud/azure/compute/client/images.js +++ b/lib/pkgcloud/azure/compute/client/images.js @@ -78,8 +78,13 @@ exports.getImage = function getImage(image, callback) { exports.createImage = function createImage(options, callback) { options || (options = {}); - if (!options.name) throw new TypeError('`name` is a required option'); - if (!options.server) throw new TypeError('`server` is a required option'); + if (!options.name) { + throw new TypeError('`name` is a required option'); + } + + if (!options.server) { + throw new TypeError('`server` is a required option'); + } var self = this, serverId = options.server instanceof base.Server diff --git a/lib/pkgcloud/azure/compute/flavor.js b/lib/pkgcloud/azure/compute/flavor.js index d2b93b5a6..ee2f5f66d 100644 --- a/lib/pkgcloud/azure/compute/flavor.js +++ b/lib/pkgcloud/azure/compute/flavor.js @@ -25,7 +25,9 @@ Flavor.options = { Flavor.prototype._setProperties = function (details) { var id = details.name || details.id || 'ExtraSmall'; - if (!Flavor.options[id]) throw new TypeError('No such Azure Flavor: ' + id); + if (!Flavor.options[id]) { + throw new TypeError('No such Azure Flavor: ' + id); + } this.id = id; this.name = id; diff --git a/lib/pkgcloud/azure/storage/utils.js b/lib/pkgcloud/azure/storage/utils.js index c10963d33..54a342a18 100644 --- a/lib/pkgcloud/azure/storage/utils.js +++ b/lib/pkgcloud/azure/storage/utils.js @@ -30,7 +30,9 @@ ChunkedStream.prototype.write = function write(data, encoding) { parts = []; this.buffer = this.buffer.filter(function (part) { - if (total >= this.chunk) return true; + if (total >= this.chunk) { + return true; + } parts.push(part); total += part.length; @@ -54,11 +56,15 @@ ChunkedStream.prototype.write = function write(data, encoding) { this.size -= this.chunk; } - if (this.paused) return false; + if (this.paused) { + return false; + } }; ChunkedStream.prototype.end = function end() { - if (this.ended) return; + if (this.ended) { + return; + } // Emit all left data var self = this; @@ -80,12 +86,18 @@ ChunkedStream.prototype.emitChunk = function emitChunk(chunk) { }; ChunkedStream.prototype.pause = function pause() { - if (this.paused) return; + if (this.paused) { + return; + } + this.paused = true; }; ChunkedStream.prototype.resume = function resume() { - if (!this.paused) return; + if (!this.paused) { + return; + } + this.paused = false; // Emit all accumulated data diff --git a/lib/pkgcloud/core/compute/server.js b/lib/pkgcloud/core/compute/server.js index 1eac79980..efc111a55 100644 --- a/lib/pkgcloud/core/compute/server.js +++ b/lib/pkgcloud/core/compute/server.js @@ -18,7 +18,10 @@ util.inherits(Server, model.Model); Server.prototype.refresh = function (callback) { var self = this; return self.client.getServer(this, function (err, server) { - if (!err) self._setProperties(server.original); + if (!err) { + self._setProperties(server.original); + } + return callback.apply(this, arguments); }); }; diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index f70760c84..91f249f92 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -151,14 +151,22 @@ exports.destroyServer = function destroyServer(server, callback) { }; return this._request(stopOptions, function (err, body, res) { - if (err) { return callback && callback(err); } + if (err) { + return callback && callback(err); + } + if (res.statusCode === 202) { var checks = 10; var done = false; + // TODO refactor this setWait function check() { - if (done) return; + if (done) { + return; + } checks--; - if (checks <= 0) return; + if (checks <= 0) { + return; + } if (checks === 0) { done = true; finish(new Error('Machine unresponsive to STOP')); diff --git a/lib/pkgcloud/openstack/database/database.js b/lib/pkgcloud/openstack/database/database.js index 0de734182..0ef39e94b 100644 --- a/lib/pkgcloud/openstack/database/database.js +++ b/lib/pkgcloud/openstack/database/database.js @@ -22,6 +22,11 @@ Database.prototype._setProperties = function (details) { // @todo Check for characters that CANNOT be used in the Database Name // @todo There is a length restrictions for database name. 64 this.name = details.name; - if (details.characterSet) this.characterSet = details.characterSet; - if (details.collation) this.collation = details.collation; + if (details.characterSet) { + this.characterSet = details.characterSet; + } + + if (details.collation) { + this.collation = details.collation; + } }; diff --git a/lib/pkgcloud/rackspace/dns/client/zones.js b/lib/pkgcloud/rackspace/dns/client/zones.js index eced07297..59ea44dd6 100644 --- a/lib/pkgcloud/rackspace/dns/client/zones.js +++ b/lib/pkgcloud/rackspace/dns/client/zones.js @@ -108,8 +108,9 @@ module.exports = { var listOfZones = []; _.each(zones, function (zone) { ['name', 'email'].forEach(function (required) { - if (!zone[required]) throw new Error('details.' + - required + ' is a required argument.'); + if (!zone[required]) { + throw new Error('details.' + required + ' is a required argument.'); + } }); var newZone = { @@ -160,8 +161,9 @@ module.exports = { var self = this; ['contentType', 'contents'].forEach(function (required) { - if (!details[required]) throw new Error('details.' + - required + ' is a required argument.'); + if (!details[required]) { + throw new Error('details.' + required + ' is a required argument.'); + } }); if (details.contentType !== 'BIND_9') { diff --git a/test/helpers/index.js b/test/helpers/index.js index f95ca4aeb..64a3a7c9e 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -106,7 +106,10 @@ helpers.selectInstance = function selectInstance(client, callback) { } client.getInstances(function (err, instances) { - if (err) throw new Error(err); + if (err) { + throw new Error(err); + } + if (instances.length === 0) { throw new Error({ message:'No instances found.' }); } From 1773af73289367574f32d36d6f4c8a997964a685 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 1 Dec 2014 08:04:41 -0800 Subject: [PATCH 265/460] Adding `newcap` jshint config - part of #360 --- .jshintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 17277c695..8bb6e189f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -11,7 +11,7 @@ "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` "indent" : false, // {int} Number of spaces to use for indentation "latedef" : false, // true: Require variables/functions to be defined before being used - "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` + "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` "noarg" : false, // true: Prohibit use of `arguments.caller` and `arguments.callee` "noempty" : false, // true: Prohibit use of empty blocks "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. From c5254966fecf1db9bfb163578c380816130ce13c Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 1 Dec 2014 08:12:04 -0800 Subject: [PATCH 266/460] Added `noempty` to jshint config - part of #360 --- .jshintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 17277c695..682d7fdbc 100644 --- a/.jshintrc +++ b/.jshintrc @@ -13,7 +13,7 @@ "latedef" : false, // true: Require variables/functions to be defined before being used "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` "noarg" : false, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : false, // true: Prohibit use of empty blocks + "noempty" : true, // true: Prohibit use of empty blocks "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) "plusplus" : false, // true: Prohibit use of `++` & `--` From ebfae7e9d222dd43c81331dc79adefbb91f1099e Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 1 Dec 2014 08:10:39 -0800 Subject: [PATCH 267/460] Adding `noarg` to jshint config - part of #360 --- .jshintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index e0a9a98d4..a87f4dab3 100644 --- a/.jshintrc +++ b/.jshintrc @@ -12,7 +12,7 @@ "indent" : false, // {int} Number of spaces to use for indentation "latedef" : false, // true: Require variables/functions to be defined before being used "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : false, // true: Prohibit use of `arguments.caller` and `arguments.callee` + "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` "noempty" : true, // true: Prohibit use of empty blocks "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) From 12bd457cd9a899b07e9a5ac00da0b59c15541164 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 2 Dec 2014 13:08:41 -0500 Subject: [PATCH 268/460] Use blanket for coverage, add make targets --- Makefile | 45 +++++++++++++++++++-------------------------- package.json | 17 ++++++++++++----- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 40145aaa3..ee21a6c77 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,28 @@ -MOCHA_OPTS=-t 4000 test/*/*/*-test.js test/*/*/*/*-test.js -REPORTER = spec +MOCHA_CMD = MOCK=on ./node_modules/.bin/mocha +MOCHA_OPTS = --require blanket -t 4000 test/*/*/*-test.js test/*/*/*/*-test.js +DEFAULT_REPORT_OPTS = --reporter spec +HTML_REPORT_OPTS = --reporter html-cov > coverage.html +COVERALLS_REPORT_OPTS = --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js check: test test: test-unit +cov: test-cov-html + +travis: lint test-unit test-cov-coveralls + test-unit: - @NODE_ENV=test MOCK=on ./node_modules/.bin/mocha \ - --reporter $(REPORTER) \ - $(MOCHA_OPTS) - -lib-cov: - jscoverage --encoding=UTF-8 lib lib-cov - -test-cov: lib-cov - mv lib lib-bak - mv lib-cov lib - $(MAKE) test REPORTER=html-cov > coverage.html - rm -rf lib - mv lib-bak lib - -test-coveralls: lib-cov - echo TRAVIS_JOB_ID $(TRAVIS_JOB_ID) - mv lib lib-bak - mv lib-cov lib - $(MAKE) test REPORTER=mocha-lcov-reporter > pkgcloud.lcov.raw - rm -rf lib - mv lib-bak lib - sed "s#SF:#SF:$(PWD)/lib/#g" pkgcloud.lcov.raw > pkgcloud.lcov - ./node_modules/coveralls/bin/coveralls.js < pkgcloud.lcov - rm pkgcloud.lcov pkgcloud.lcov.raw + @echo "$(MOCHA_CMD) $(MOCHA_OPTS) $(REPORT_OPTS)" + @NODE_ENV=test $(MOCHA_CMD) $(MOCHA_OPTS) $(REPORT_OPTS) + +test-cov-html: + @echo "$(MOCHA_CMD) $(MOCHA_OPTS) $(HTML_REPORT_OPTS)" + @NODE_ENV=test $(MOCHA_CMD) $(MOCHA_OPTS) $(HTML_REPORT_OPTS) + +test-cov-coveralls: + @echo "$(MOCHA_CMD) $(MOCHA_OPTS) $(COVERALLS_REPORT_OPTS)" + @NODE_ENV=test $(MOCHA_CMD) $(MOCHA_OPTS) $(COVERALLS_REPORT_OPTS) lint: ./node_modules/.bin/jshint --exclude-path .gitignore . diff --git a/package.json b/package.json index c5d7f844c..fcdf5e5e0 100644 --- a/package.json +++ b/package.json @@ -68,20 +68,27 @@ "xml2js": "0.1.x" }, "devDependencies": { + "blanket": "^1.1.6", + "coveralls": "^2.11.2", "hock": "1.0.x", + "jshint": "2.x.x", "mocha": "1.21.x", - "should": "4.0.x", "mocha-lcov-reporter": "0.0.1", - "coveralls": "2.x.x", - "jshint": "2.x.x" + "should": "4.0.x" }, "main": "./lib/pkgcloud", "scripts": { "test": "make test", - "test-cov": "make test-cov", - "test-coveralls": "make test-coveralls", + "cov": "make cov", + "travis": "make travis", "lint": "make lint" }, + "config": { + "blanket": { + "pattern": "/lib/", + "data-cover-never": "node_modules" + } + }, "engines": { "node": ">=0.10.x" } From 3eea550b40a7684ba7611d468f2b0a41e3a21de9 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 2 Dec 2014 13:09:10 -0500 Subject: [PATCH 269/460] Set travis to use new make target that performs linting, testing, and coverage --- .travis.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index a389e75f9..14f11d4dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,5 @@ notifications: - travis@nodejitsu.com irc: "irc.freenode.org#pkgcloud" -before_script: - - git clone git://github.com/visionmedia/node-jscoverage.git - - pushd node-jscoverage - - ./configure - - make - - popd - - npm run lint +script: + - npm run travis From 29519f9b38cc0f4e551029e821791962c3181274 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 2 Dec 2014 12:09:04 -0800 Subject: [PATCH 270/460] Adding some slack notifications for pkgcloud --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14f11d4dd..e783eb39a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: node_js node_js: - - "0.10" - +- '0.10' notifications: email: - - travis@nodejitsu.com - irc: "irc.freenode.org#pkgcloud" - + - ken.perkins@rackspace.com + irc: irc.freenode.org#pkgcloud + slack: + secure: RjlcoxHiKzep+CdLSC4UcL6Wsrv/4F3mzCwnDhIFsoH53XZ4t5oexLyaQxZFVq6KYes7nv2D/w2jUX7z7LBCZ6N0p8Sf/ao2s5O71ETDYDajtQjdEC1/w8PflC61b1EsVfE1tDbDtkFJtVXWKCBUAfbvrMYZwP0f8Ffhf3Bvg2I= script: - - npm run travis +- npm run travis From 86b0fdee9bf3a6a5f81ac16ed6813afa7084979f Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Dec 2014 02:52:45 -0800 Subject: [PATCH 271/460] Enabling latedef lint check. --- .jshintrc | 2 +- examples/compute/rackspace.js | 56 +- .../azure/database/client/databases.js | 24 +- lib/pkgcloud/azure/storage/client/files.js | 13 +- lib/pkgcloud/azure/utils/azureApi.js | 784 ++++----- lib/pkgcloud/azure/utils/hmacsha256sign.js | 6 +- lib/pkgcloud/azure/utils/sharedkey.js | 10 +- lib/pkgcloud/azure/utils/sharedkeytable.js | 8 +- lib/pkgcloud/joyent/compute/client/servers.js | 25 +- .../openstack/compute/client/servers.js | 48 +- lib/pkgcloud/openstack/context/identity.js | 65 +- lib/pkgcloud/openstack/context/service.js | 22 +- .../openstack/database/client/users.js | 34 +- .../openstack/orchestration/client/events.js | 80 +- .../orchestration/client/resources.js | 55 +- .../openstack/orchestration/client/stacks.js | 72 +- .../orchestration/client/templates.js | 29 +- .../openstack/storage/client/files.js | 13 +- .../loadbalancer/client/loadbalancers.js | 112 +- .../storage/client/cdn-containers.js | 27 +- .../azure/compute/client/test-createServer.js | 4 +- .../azure/compute/client/test-rebootServer.js | 4 +- test/common/compute/base-test.js | 378 ++--- test/common/compute/meta-test.js | 84 +- test/common/compute/server-test.js | 446 +++--- test/common/databases/databases-test.js | 382 ++--- test/common/databases/flavor-test.js | 37 +- test/common/databases/instances-test.js | 930 +++++------ test/common/databases/users-test.js | 983 ++++++------ test/common/network/network-test.js | 446 +++--- test/common/network/port-test.js | 450 +++--- test/common/network/subnet-test.js | 450 +++--- test/common/storage/base-test.js | 1406 ++++++++--------- test/common/storage/upload-test.js | 174 +- test/helpers/azureNock.js | 47 +- .../databases/databases-redis-test.js | 20 +- test/rackspace/databases/user-limit-test.js | 226 +-- 37 files changed, 3982 insertions(+), 3970 deletions(-) diff --git a/.jshintrc b/.jshintrc index a87f4dab3..f9dc1bda6 100644 --- a/.jshintrc +++ b/.jshintrc @@ -10,7 +10,7 @@ "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` "indent" : false, // {int} Number of spaces to use for indentation - "latedef" : false, // true: Require variables/functions to be defined before being used + "latedef" : true, // true: Require variables/functions to be defined before being used "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` "noempty" : true, // true: Prohibit use of empty blocks diff --git a/examples/compute/rackspace.js b/examples/compute/rackspace.js index f768bed58..5695e44db 100644 --- a/examples/compute/rackspace.js +++ b/examples/compute/rackspace.js @@ -8,6 +8,34 @@ var client = pkgcloud.providers.rackspace.compute.createClient({ region: 'DFW' }); +// This function will handle our server creation, +// as well as waiting for the server to come online after we've +// created it. +function handleServerResponse(err, server) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); + + // Wait for status: ACTIVE on our server, and then callback + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER INFO'); + console.log(server.name); + console.log(server.status); + console.log(server.id); + + console.log('Make sure you DELETE server: ' + server.id + + ' in order to not accrue billing charges'); + }); +} + // first we're going to get our flavors client.getFlavors(function (err, flavors) { if (err) { @@ -43,31 +71,3 @@ client.getFlavors(function (err, flavors) { }, handleServerResponse); }); }); - -// This function will handle our server creation, -// as well as waiting for the server to come online after we've -// created it. -function handleServerResponse(err, server) { - if (err) { - console.dir(err); - return; - } - - console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); - - // Wait for status: ACTIVE on our server, and then callback - server.setWait({ status: server.STATUS.running }, 5000, function (err) { - if (err) { - console.dir(err); - return; - } - - console.log('SERVER INFO'); - console.log(server.name); - console.log(server.status); - console.log(server.id); - - console.log('Make sure you DELETE server: ' + server.id + - ' in order to not accrue billing charges'); - }); -} diff --git a/lib/pkgcloud/azure/database/client/databases.js b/lib/pkgcloud/azure/database/client/databases.js index 66717a8d9..89c14a745 100644 --- a/lib/pkgcloud/azure/database/client/databases.js +++ b/lib/pkgcloud/azure/database/client/databases.js @@ -13,6 +13,18 @@ var errs = require('errs'), _ = require('underscore'), url = require('url'); +// Encode a uri according to Azure Table rules +// ### @options {uri} The uri to encode +// ### @return {String} The encoded uri. +var encodeTableUriComponent = function (uri) { + return encodeURIComponent(uri) + .replace(/!/g, '%21') + .replace(/'/g, '%27') + .replace(/\(/g, '%28') + .replace(/\)/g, '%29') + .replace(/\*/g, '%2A'); +}; + // Create a new Azure Table Database // Need name of table to create // ### @options {Object} table create options. @@ -120,15 +132,3 @@ exports.remove = function (id, callback) { : callback(null, res.statusCode === 204); }); }; - -// Encode a uri according to Azure Table rules -// ### @options {uri} The uri to encode -// ### @return {String} The encoded uri. -var encodeTableUriComponent = function (uri) { - return encodeURIComponent(uri) - .replace(/!/g, '%21') - .replace(/'/g, '%27') - .replace(/\(/g, '%28') - .replace(/\)/g, '%29') - .replace(/\*/g, '%2A'); -}; diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 249bc7b2d..5003f5e91 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -267,11 +267,6 @@ exports.uploadBlock = function(options) { }; exports.download = function (options, callback) { - var self = this, - success = callback ? onDownload : null, - container = options.container, - lstream, - rstream; // // Optional helper function passed to `this._request` @@ -281,11 +276,17 @@ exports.download = function (options, callback) { return err ? callback(err) : callback(null, new (storage.File)(self, _.extend(res.headers, { - container: container, + container: options.container, name: options.remote }))); } + var self = this, + success = callback ? onDownload : null, + container = options.container, + lstream, + rstream; + if (container instanceof storage.Container) { container = container.name; } diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index af2e4da7a..7e766cac1 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -31,121 +31,69 @@ var TABLES_API_VERSION = exports.TABLES_API_VERSION = '2012-02-12'; var MINIMUM_POLL_INTERVAL = exports.MINIMUM_POLL_INTERVAL = 3000; /** - * createServer() - * - * In order to deploy a vm, Azure requires us to do the following - * before we can actually try to create the vm. - * 1. get or create a Hosted Service (we use the same name as the vm) - * 2. resolve the OSImage url to a container on the user's account - * 3. upload SSH certificate (if necessary) - * 4. create the VM - * - * Note: creating a VM on Azure will fail if one of the following is true - * 1. The VM (with the same name) already exists - * 2. The blob storage (with the same name) for the OSImage already exists - * 3. The VM disk (with the same name) for the OSImage already exists - * 4. The storage account is in a different azure location than the vm - * (East US, West US...) - * - * Note: createServer() must wait for Azure to respond if the createDeployment (vm) - * request succeeded. createServer() asynchronously polls Azure to get - * the result. Once the result is received, the callback function will be called - * with the server information or error. The state of returned server will most likely - * be PROVISIONING or STOPPED. Use server.setWait() to continue polling the server until - * its status is RUNNING. This entire process may take several minutes. + * pollRequestStatus + * uses Get Operation Status + * GET https://management.core.windows.net//operations/ */ -var createServer = exports.createServer = function (client, options, callback) { - var vmOptions = {}, - ssh; +var pollRequestStatus = function (client, requestId, interval, callback) { + var checkStatus = function () { + var path = client.subscriptionId + '/operations/' + requestId; + client.get(path, function (err, body, res) { + if (err) { + return callback(err); + } + switch (body.Status) { + case 'InProgress': + setTimeout(checkStatus, interval); + break; + case 'Failed': + callback(body.Error); + break; + case 'Succeeded': + callback(null); + break; + } + }); + }; + + checkStatus(); +}; + +var makeTemplateRequest = function (client, path, templateName, params, callback) { + var headers = {}, + body; // async execute the following tasks one by one and bail if there is an error async.waterfall([ function (next) { - // validate createServer options - validateCreateOptions(options, client.config, next); - }, - function (next) { - getHostedServiceProperties(client, options.name, next); - }, - function (service, next) { - // if the HostedService does not exist, create it - vmOptions.hostedService = service; - if (vmOptions.hostedService === null) { - createHostedService(client, options, function (err, service) { - if (err) { - next(err); - } else { - vmOptions.hostedService = service; - next(null); - } - }); - } else { - next(null); - } + templates.load(templateName, next); }, - function (next) { - // get the server's OSImage info - getOSImage(client, options.image, function (err, res) { + function (template, next) { + // compile template with params + body = _.template(template, params); + headers['content-length'] = body.length; + headers['content-type'] = 'application/xml'; + headers['accept'] = 'application/xml'; + client._request({ + method: 'POST', + path: path, + body: body, + headers: headers + }, function (err, body, res) { if (err) { - next(err); - } else { - vmOptions.image = res; - next(null); + return next(err); } + // poll azure for result of request + pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, next); }); - }, - function (next) { - ssh = options.ssh; - if (ssh) { - vmOptions.sshCertInfo = cert.getAzureCertInfo(ssh.cert); - } - next(); - }, - function (next) { - // add the ssh certificate to the service - if (vmOptions.sshCertInfo) { - addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { - next(err); - }); - } else { - next(null); - } - }, - function (next) { - // create the VM and wait for response - createVM(client, options, vmOptions, next); - }, - function (next) { - // now get the actual server info - getServer(client, options.name, next); }], function (err, result) { - if (err) { - callback(err); - } else { - // return the server info - callback(null, result); - } + callback(err); } ); }; -var createVM = function (client, options, vmOptions, callback) { - // check OS type of image to determine if we are creating a linux or windows VM - switch (vmOptions.image.OS.toLowerCase()) { - case 'linux': - createLinuxVM(client, options, vmOptions, callback); - break; - case 'windows': - createWindowsVM(client, options, vmOptions, callback); - break; - default: - callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); - break; - } -}; - var getMediaLinkUrl = function (storageAccount, fileName) { return 'http://' + storageAccount + '.' + STORAGE_ENDPOINT + '/vhd/' + fileName; }; @@ -201,6 +149,21 @@ var createWindowsVM = function (client, options, vmOptions, callback) { makeTemplateRequest(client, path, 'windowsDeployment.xml', configParams, callback); }; +var createVM = function (client, options, vmOptions, callback) { + // check OS type of image to determine if we are creating a linux or windows VM + switch (vmOptions.image.OS.toLowerCase()) { + case 'linux': + createLinuxVM(client, options, vmOptions, callback); + break; + case 'windows': + createWindowsVM(client, options, vmOptions, callback); + break; + default: + callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); + break; + } +}; + var captureServer = function (client, serverName, targetImageName, callback) { // /services/hostedservices//deployments//roleinstances//operations var path = client.subscriptionId + '/services/hostedservices/' + @@ -244,6 +207,75 @@ var validateCreateOptions = function (options, config, callback) { callback(); }; +var isVM = function (deployment) { + if (deployment.RoleList && deployment.RoleList.Role) { + if (deployment.RoleList.Role.RoleType === 'PersistentVMRole') { + return true; + } + } + + return false; +}; + +/** + Get Hosted Service Properties + GET https://management.core.windows.net//services/hostedservices/?embed-detail=true + A successful operation returns status code 200 (OK). + */ +var getHostedServiceProperties = function (client, serviceName, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '?embed-detail=true'; + + var onError = function (err) { + return err.failCode === 'Item not found' + ? callback(null, null) + : callback(err); + }; + + client.get(path, function (err, body, res) { + return err + ? onError(err) + : callback(null, body); + }); +}; + +/** + * getServersFromService + * Retrieves all servers (VMs) from a Hosted Service + */ +var getServersFromService = function (client, serviceName, callback) { + var servers = []; + getHostedServiceProperties(client, serviceName, function (err, result) { + if (err) { + return callback(err); + } + + if (result && result.Deployments && result.Deployments.Deployment) { + if (isVM(result.Deployments.Deployment)) { + servers.push(result.Deployments.Deployment); + } + } + + callback(null, servers); + }); +}; + +/** + * getServersFromServices + * Retrieves all servers (VMs) from the list of services + */ +var getServersFromServices = function (client, services, callback) { + var task = function (service, next) { + getServersFromService(client, service.ServiceName, function (err, servers) { + next(err, servers); + }); + }; + + // Check each service for deployed VMs. + async.concat(services, task, function (err, servers) { + callback(err, servers); + }); +}; + /** * getServer */ @@ -255,66 +287,283 @@ var getServer = exports.getServer = function (client, serverName, callback) { }); }; -var getServers = exports.getServers = function (client, callback) { - // async execute the following tasks one by one and bail if there is an error - async.waterfall([ - function (next) { - // get the list of Hosted Services - getHostedServices(client, next); - }, - function (hostedServices, next) { - // get the list of Servers from the Hosted Services - getServersFromServices(client, hostedServices, next); - }], - function (err, servers) { - callback(err, servers); - } - ); +var createHostedService = exports.createHostedService = function (client, options, callback) { + var path = client.subscriptionId + '/services/hostedservices'; + var params = { + NAME: options.name, + LABEL_BASE64: new Buffer(options.name).toString('base64'), + LOCATION: options.location + }; + + makeTemplateRequest(client, path, 'createHostedService.xml', params, callback); }; -var makeTemplateRequest = function (client, path, templateName, params, callback) { - var headers = {}, - body; +var addCertificate = function (client, serviceName, cert, password, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + + serviceName + '/certificates'; + + var params = { + CERT_BASE64: new Buffer(cert, 'utf8').toString('base64'), + PASSWORD: password + }; + + makeTemplateRequest(client, path, 'addCertificate.xml', params, callback); +}; + +var deleteServer = function (client, serverName, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + serverName; + path += '/deployments/' + serverName; + + client._request({ + method: 'DELETE', + path: path + }, function (err, body, res) { + if (err) { + return callback(err); + } + // poll azure for result of request + pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); + }); +}; + +var getStorageInfoFromUri = exports.getStorageInfoFromUri = function (uri, callback) { + var u, tokens, path, + info = {}; + + u = URL.parse(uri); + if (!u.host || !u.path) { + return callback(errs.create({message: 'invalid Azure container or blob uri'})); + } + + tokens = u.host.split('.'); + info.storage = tokens[0]; + + path = u.path; + // if necessary, remove leading '/' from path + if (path.charAt(0) === '/') { + path = path.substr(1); + } + tokens = path.split('/'); + info.container = tokens.shift(); + info.file = tokens.join('/'); + + callback(null, info); +}; + +var deleteOSBlob = function (client, server, callback) { + var blob = null; + + if (server && server.RoleList && server.RoleList.Role) { + if (server.RoleList.Role.OSVirtualHardDisk) { + blob = server.RoleList.Role.OSVirtualHardDisk.MediaLink; + } + } + + if (blob === null) { + callback(null); + return; + } + + getStorageInfoFromUri(blob, function (err, info) { + if (err) { + callback(err); + } else { + var storage = pkgcloud.storage.createClient(client.config); + storage.removeFile(info.container, info.file, function (err, result) { + callback(err); + }); + } + }); +}; + +var deleteOSDisk = function (client, server, callback) { + var diskName = null, + path; + + if (server && server.RoleList && server.RoleList.Role) { + if (server.RoleList.Role.OSVirtualHardDisk) { + diskName = server.RoleList.Role.OSVirtualHardDisk.DiskName; + } + } + + if (diskName === null) { + callback(null); + return; + } + + // https://management.core.windows.net//services/disks/ + path = client.subscriptionId + '/services/disks/' + diskName; + + client._request({ + method: 'DELETE', + path: path + }, function (err, body, res) { + if (err) { + return callback(err); + } + // poll azure for result of request + pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); + }); +}; + +var getOSImage = exports.getOSImage = function (client, imageName, callback) { + var path = '/' + client.subscriptionId + '/services/images/' + imageName; + + var onError = function (err) { + if (err.failCode === 'Item not found') { + callback(null, null); + + } else { + callback(err); + } + }; + + client.get(path, function (err, body, res) { + return err + ? onError(err) + : callback(null, body); + }); +}; + +/** + * createServer() + * + * In order to deploy a vm, Azure requires us to do the following + * before we can actually try to create the vm. + * 1. get or create a Hosted Service (we use the same name as the vm) + * 2. resolve the OSImage url to a container on the user's account + * 3. upload SSH certificate (if necessary) + * 4. create the VM + * + * Note: creating a VM on Azure will fail if one of the following is true + * 1. The VM (with the same name) already exists + * 2. The blob storage (with the same name) for the OSImage already exists + * 3. The VM disk (with the same name) for the OSImage already exists + * 4. The storage account is in a different azure location than the vm + * (East US, West US...) + * + * Note: createServer() must wait for Azure to respond if the createDeployment (vm) + * request succeeded. createServer() asynchronously polls Azure to get + * the result. Once the result is received, the callback function will be called + * with the server information or error. The state of returned server will most likely + * be PROVISIONING or STOPPED. Use server.setWait() to continue polling the server until + * its status is RUNNING. This entire process may take several minutes. + */ + +var createServer = exports.createServer = function (client, options, callback) { + var vmOptions = {}, + ssh; // async execute the following tasks one by one and bail if there is an error async.waterfall([ function (next) { - templates.load(templateName, next); + // validate createServer options + validateCreateOptions(options, client.config, next); }, - function (template, next) { - // compile template with params - body = _.template(template, params); - headers['content-length'] = body.length; - headers['content-type'] = 'application/xml'; - headers['accept'] = 'application/xml'; - client._request({ - method: 'POST', - path: path, - body: body, - headers: headers - }, function (err, body, res) { + function (next) { + getHostedServiceProperties(client, options.name, next); + }, + function (service, next) { + // if the HostedService does not exist, create it + vmOptions.hostedService = service; + if (vmOptions.hostedService === null) { + createHostedService(client, options, function (err, service) { + if (err) { + next(err); + } else { + vmOptions.hostedService = service; + next(null); + } + }); + } else { + next(null); + } + }, + function (next) { + // get the server's OSImage info + getOSImage(client, options.image, function (err, res) { if (err) { - return next(err); + next(err); + } else { + vmOptions.image = res; + next(null); } - // poll azure for result of request - pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, next); }); + }, + function (next) { + ssh = options.ssh; + if (ssh) { + vmOptions.sshCertInfo = cert.getAzureCertInfo(ssh.cert); + } + next(); + }, + function (next) { + // add the ssh certificate to the service + if (vmOptions.sshCertInfo) { + addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { + next(err); + }); + } else { + next(null); + } + }, + function (next) { + // create the VM and wait for response + createVM(client, options, vmOptions, next); + }, + function (next) { + // now get the actual server info + getServer(client, options.name, next); }], function (err, result) { - callback(err); + if (err) { + callback(err); + } else { + // return the server info + callback(null, result); + } } ); }; -var createHostedService = exports.createHostedService = function (client, options, callback) { - var path = client.subscriptionId + '/services/hostedservices'; - var params = { - NAME: options.name, - LABEL_BASE64: new Buffer(options.name).toString('base64'), - LOCATION: options.location - }; +var getHostedServices = exports.getHostedServices = function (client, callback) { + var path = client.subscriptionId + '/services/hostedservices', + services = []; - makeTemplateRequest(client, path, 'createHostedService.xml', params, callback); + client.get(path, function (err, body, res) { + if (err) { + return callback(err); + } + if (body.HostedService) { + // need to check if azure returned an array or single object + if (Array.isArray(body.HostedService)) { + body.HostedService.forEach(function (service) { + services.push(service); + }); + } else { + services.push(body.HostedService); + } + } + + callback(null, services); + }); +}; + +var getServers = exports.getServers = function (client, callback) { + // async execute the following tasks one by one and bail if there is an error + async.waterfall([ + function (next) { + // get the list of Hosted Services + getHostedServices(client, next); + }, + function (hostedServices, next) { + // get the list of Servers from the Hosted Services + getServersFromServices(client, hostedServices, next); + }], + function (err, servers) { + callback(err, servers); + } + ); }; /** @@ -347,18 +596,6 @@ var stopServer = exports.stopServer = function (client, serviceName, callback) { makeTemplateRequest(client, path, 'shutdownRole.xml', {}, callback); }; -var addCertificate = function (client, serviceName, cert, password, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + - serviceName + '/certificates'; - - var params = { - CERT_BASE64: new Buffer(cert, 'utf8').toString('base64'), - PASSWORD: password - }; - - makeTemplateRequest(client, path, 'addCertificate.xml', params, callback); -}; - var deleteHostedService = exports.deleteHostedService = function (client, serviceName, callback) { // DELETE https://management.core.windows.net//services/hostedservices/ var path = client.subscriptionId + '/services/hostedservices/' + serviceName; @@ -375,29 +612,6 @@ var deleteHostedService = exports.deleteHostedService = function (client, servic }); }; -var getHostedServices = exports.getHostedServices = function (client, callback) { - var path = client.subscriptionId + '/services/hostedservices', - services = []; - - client.get(path, function (err, body, res) { - if (err) { - return callback(err); - } - if (body.HostedService) { - // need to check if azure returned an array or single object - if (Array.isArray(body.HostedService)) { - body.HostedService.forEach(function (service) { - services.push(service); - }); - } else { - services.push(body.HostedService); - } - } - - callback(null, services); - }); -}; - /** * destroyServer * uses Delete Deployment @@ -438,220 +652,6 @@ var destroyServer = exports.destroyServer = function (client, serverName, callba ); }; -var deleteServer = function (client, serverName, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + serverName; - path += '/deployments/' + serverName; - - client._request({ - method: 'DELETE', - path: path - }, function (err, body, res) { - if (err) { - return callback(err); - } - // poll azure for result of request - pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); - }); -}; - -var getOSImage = exports.getOSImage = function (client, imageName, callback) { - var path = '/' + client.subscriptionId + '/services/images/' + imageName; - - var onError = function (err) { - if (err.failCode === 'Item not found') { - callback(null, null); - - } else { - callback(err); - } - }; - - client.get(path, function (err, body, res) { - return err - ? onError(err) - : callback(null, body); - }); -}; - -var deleteOSDisk = function (client, server, callback) { - var diskName = null, - path; - - if (server && server.RoleList && server.RoleList.Role) { - if (server.RoleList.Role.OSVirtualHardDisk) { - diskName = server.RoleList.Role.OSVirtualHardDisk.DiskName; - } - } - - if (diskName === null) { - callback(null); - return; - } - - // https://management.core.windows.net//services/disks/ - path = client.subscriptionId + '/services/disks/' + diskName; - - client._request({ - method: 'DELETE', - path: path - }, function (err, body, res) { - if (err) { - return callback(err); - } - // poll azure for result of request - pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); - }); -}; - -var deleteOSBlob = function (client, server, callback) { - var blob = null; - - if (server && server.RoleList && server.RoleList.Role) { - if (server.RoleList.Role.OSVirtualHardDisk) { - blob = server.RoleList.Role.OSVirtualHardDisk.MediaLink; - } - } - - if (blob === null) { - callback(null); - return; - } - - getStorageInfoFromUri(blob, function (err, info) { - if (err) { - callback(err); - } else { - var storage = pkgcloud.storage.createClient(client.config); - storage.removeFile(info.container, info.file, function (err, result) { - callback(err); - }); - } - }); -}; - -/** - * getServersFromServices - * Retrieves all servers (VMs) from the list of services - */ -var getServersFromServices = function (client, services, callback) { - var task = function (service, next) { - getServersFromService(client, service.ServiceName, function (err, servers) { - next(err, servers); - }); - }; - - // Check each service for deployed VMs. - async.concat(services, task, function (err, servers) { - callback(err, servers); - }); -}; - -/** - * getServersFromServices - * Retrieves all servers (VMs) from a Hosted Service - */ -var getServersFromService = function (client, serviceName, callback) { - var servers = []; - getHostedServiceProperties(client, serviceName, function (err, result) { - if (err) { - return callback(err); - } - - if (result && result.Deployments && result.Deployments.Deployment) { - if (isVM(result.Deployments.Deployment)) { - servers.push(result.Deployments.Deployment); - } - } - - callback(null, servers); - }); -}; - -var isVM = function (deployment) { - if (deployment.RoleList && deployment.RoleList.Role) { - if (deployment.RoleList.Role.RoleType === 'PersistentVMRole') { - return true; - } - } - - return false; -}; - -/** - Get Hosted Service Properties - GET https://management.core.windows.net//services/hostedservices/?embed-detail=true - A successful operation returns status code 200 (OK). - */ -var getHostedServiceProperties = function (client, serviceName, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '?embed-detail=true'; - - var onError = function (err) { - return err.failCode === 'Item not found' - ? callback(null, null) - : callback(err); - }; - - client.get(path, function (err, body, res) { - return err - ? onError(err) - : callback(null, body); - }); -}; - -/** - * pollRequestStatus - * uses Get Operation Status - * GET https://management.core.windows.net//operations/ - */ - -var pollRequestStatus = function (client, requestId, interval, callback) { - var checkStatus = function () { - var path = client.subscriptionId + '/operations/' + requestId; - client.get(path, function (err, body, res) { - if (err) { - return callback(err); - } - switch (body.Status) { - case 'InProgress': - setTimeout(checkStatus, interval); - break; - case 'Failed': - callback(body.Error); - break; - case 'Succeeded': - callback(null); - break; - } - }); - }; - - checkStatus(); -}; - -var getStorageInfoFromUri = exports.getStorageInfoFromUri = function (uri, callback) { - var u, tokens, path, - info = {}; - - u = URL.parse(uri); - if (!u.host || !u.path) { - return callback(errs.create({message: 'invalid Azure container or blob uri'})); - } - - tokens = u.host.split('.'); - info.storage = tokens[0]; - - path = u.path; - // if necessary, remove leading '/' from path - if (path.charAt(0) === '/') { - path = path.substr(1); - } - tokens = path.split('/'); - info.container = tokens.shift(); - info.file = tokens.join('/'); - - callback(null, info); -}; - /** * createImage() * 1. Check if the server exists @@ -696,4 +696,4 @@ var destroyImage = exports.destroyImage = function (client, imageName, callback) exports._updateMinimumPollInterval = function(interval) { MINIMUM_POLL_INTERVAL = interval; -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/azure/utils/hmacsha256sign.js b/lib/pkgcloud/azure/utils/hmacsha256sign.js index ae86f09bc..b7d1b3878 100644 --- a/lib/pkgcloud/azure/utils/hmacsha256sign.js +++ b/lib/pkgcloud/azure/utils/hmacsha256sign.js @@ -16,9 +16,6 @@ // Module dependencies. var crypto = require('crypto'); -// Expose 'HmacSHA256Sign'. -exports = module.exports = HmacSha256Sign; - /** * Creates a new HmacSHA256Sign object. * @@ -41,3 +38,6 @@ HmacSha256Sign.prototype.sign = function (stringToSign) { return crypto.createHmac('sha256', this._decodedAccessKey).update(stringToSign).digest('base64'); }; + +// Expose 'HmacSHA256Sign'. +exports = module.exports = HmacSha256Sign; diff --git a/lib/pkgcloud/azure/utils/sharedkey.js b/lib/pkgcloud/azure/utils/sharedkey.js index 63c3d6342..aa114dd3f 100644 --- a/lib/pkgcloud/azure/utils/sharedkey.js +++ b/lib/pkgcloud/azure/utils/sharedkey.js @@ -21,10 +21,7 @@ var HeaderConstants = require('./constants').HeaderConstants; var HmacSha256Sign = require('./hmacsha256sign'); var URL = require('url'); -var azureApi = require('./azureApi'), - -// Expose 'SharedKey'. -exports = module.exports = SharedKey; +var azureApi = require('./azureApi'); /** * Creates a new SharedKey object. @@ -158,4 +155,7 @@ SharedKey.prototype._getCanonicalizedHeaders = function (req) { } return canonicalizedHeaders; -}; \ No newline at end of file +}; + +// Expose 'SharedKey'. +exports = module.exports = SharedKey; diff --git a/lib/pkgcloud/azure/utils/sharedkeytable.js b/lib/pkgcloud/azure/utils/sharedkeytable.js index cee68144f..a1b822ba5 100644 --- a/lib/pkgcloud/azure/utils/sharedkeytable.js +++ b/lib/pkgcloud/azure/utils/sharedkeytable.js @@ -19,9 +19,6 @@ var HmacSha256Sign = require('./hmacsha256sign'), azureApi = require('../utils/azureApi'), URL = require('url'); -// Expose 'SharedKeyTable'. -exports = module.exports = SharedKeyTable; - /** * Creates a new SharedKeyTable object. * @@ -101,4 +98,7 @@ SharedKeyTable.prototype._getCanonicalizedResource = function (req) { } } return canonicalizedResource; -}; \ No newline at end of file +}; + +// Expose 'SharedKeyTable'. +exports = module.exports = SharedKeyTable; diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index 91f249f92..d09ebbec5 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -155,6 +155,19 @@ exports.destroyServer = function destroyServer(server, callback) { return callback && callback(err); } + function finish() { + var destroyOptions = { + method: 'DELETE', + path: self.account + '/machines/' + serverId + }; + + self._request(destroyOptions, function (err, body, res) { + return err + ? callback && callback(err) + : callback && callback(err, {ok: serverId}, res); + }); + } + if (res.statusCode === 202) { var checks = 10; var done = false; @@ -196,18 +209,6 @@ exports.destroyServer = function destroyServer(server, callback) { finish(); } - function finish() { - var destroyOptions = { - method: 'DELETE', - path: self.account + '/machines/' + serverId - }; - - self._request(destroyOptions, function (err, body, res) { - return err - ? callback && callback(err) - : callback && callback(err, {ok: serverId}, res); - }); - } }); }; diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index 36fc5753d..d8a713bfd 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -16,6 +16,30 @@ var request = require('request'), var _urlPrefix = '/servers'; +/** + * validateProperties + * + * @description local helper function for validating arguments + * + * @param {Array} required The list of required properties + * @param {object} options The options object to validate + * @param {String} formatString String formatter for the error message + * @param {Function} callback + * @returns {boolean} + */ +function validateProperties(required, options, formatString, callback) { + return !required.some(function (item) { + if (typeof(options[item]) === 'undefined') { + errs.handle( + errs.create({ message: util.format(formatString, item) }), + callback + ); + return true; + } + return false; + }); +} + /** * client._doServerAction * @@ -367,27 +391,3 @@ exports.getServerAddresses = function (server, type, callback) { : callback(null, body.addresses || body); }); }; - -/** - * validateProperties - * - * @description local helper function for validating arguments - * - * @param {Array} required The list of required properties - * @param {object} options The options object to validate - * @param {String} formatString String formatter for the error message - * @param {Function} callback - * @returns {boolean} - */ -function validateProperties(required, options, formatString, callback) { - return !required.some(function (item) { - if (typeof(options[item]) === 'undefined') { - errs.handle( - errs.create({ message: util.format(formatString, item) }), - callback - ); - return true; - } - return false; - }); -} diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index fb1c65c49..5570a48b1 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -32,6 +32,38 @@ var failCodes = { 503: 'Service Unavailable' }; +function getError(err, res, body) { + if (err) { + return err; + } + + var statusCode = res.statusCode.toString(), + err2; + + if (Object.keys(failCodes).indexOf(statusCode) !== -1) { + // + // TODO: Support more than JSON errors here + // + err2 = { + failCode: failCodes[statusCode], + statusCode: res.statusCode, + message: 'Error (' + + statusCode + '): ' + failCodes[statusCode], + href: res.request.uri.href, + method: res.request.method, + headers: res.headers + }; + + try { + err2.result = typeof body === 'string' ? JSON.parse(body) : body; + } catch (e) { + err2.result = { err: body }; + } + + return err2; + } +} + /** * Identity object * @@ -269,36 +301,3 @@ Identity.prototype.getServiceEndpointUrl = function (options) { return this.options.url; } }; - - -function getError(err, res, body) { - if (err) { - return err; - } - - var statusCode = res.statusCode.toString(), - err2; - - if (Object.keys(failCodes).indexOf(statusCode) !== -1) { - // - // TODO: Support more than JSON errors here - // - err2 = { - failCode: failCodes[statusCode], - statusCode: res.statusCode, - message: 'Error (' + - statusCode + '): ' + failCodes[statusCode], - href: res.request.uri.href, - method: res.request.method, - headers: res.headers - }; - - try { - err2.result = typeof body === 'string' ? JSON.parse(body) : body; - } catch (e) { - err2.result = { err: body }; - } - - return err2; - } -} diff --git a/lib/pkgcloud/openstack/context/service.js b/lib/pkgcloud/openstack/context/service.js index b0b1cb749..37d1f065b 100644 --- a/lib/pkgcloud/openstack/context/service.js +++ b/lib/pkgcloud/openstack/context/service.js @@ -8,6 +8,17 @@ var _ = require('underscore'); +function matchRegion(a, b) { + if (!a && !b) { + return true; + } + else if ((!a && b) || (a && !b)) { + return false; + } + + return a.toLowerCase() === b.toLowerCase(); +} + /** * Service class * @@ -108,14 +119,3 @@ Service.prototype.getEndpointUrl = function (options) { }; exports.Service = Service; - -function matchRegion(a, b) { - if (!a && !b) { - return true; - } - else if ((!a && b) || (a && !b)) { - return false; - } - - return a.toLowerCase() === b.toLowerCase(); -} diff --git a/lib/pkgcloud/openstack/database/client/users.js b/lib/pkgcloud/openstack/database/client/users.js index 7199e0316..eda92379c 100644 --- a/lib/pkgcloud/openstack/database/client/users.js +++ b/lib/pkgcloud/openstack/database/client/users.js @@ -28,23 +28,6 @@ exports.createUser = function createUser(options, callback) { instanceId, count = 0; - // Check for options - if (!options || typeof options === 'function') { - return errs.handle(errs.create({ - message: 'Options required for create an instance.' - }), options); - } - - // Not as clean as I'd like but async didn't seem to work properly. - if (options instanceof Array) { - for (var i = 0; i < options.length; i++) { - assessOptions(options[i]); - } - } - else { - assessOptions(options); - } - function assessOptions(opts) { var databases = [], calledBack = false; @@ -144,6 +127,23 @@ exports.createUser = function createUser(options, callback) { } } + // Check for options + if (!options || typeof options === 'function') { + return errs.handle(errs.create({ + message: 'Options required for create an instance.' + }), options); + } + + // Not as clean as I'd like but async didn't seem to work properly. + if (options instanceof Array) { + for (var i = 0; i < options.length; i++) { + assessOptions(options[i]); + } + } + else { + assessOptions(options); + } + function makeRequest() { var createOptions = { method: 'POST', diff --git a/lib/pkgcloud/openstack/orchestration/client/events.js b/lib/pkgcloud/openstack/orchestration/client/events.js index 191c7b521..447578910 100644 --- a/lib/pkgcloud/openstack/orchestration/client/events.js +++ b/lib/pkgcloud/openstack/orchestration/client/events.js @@ -29,6 +29,20 @@ var _urlPrefix = '/stacks'; exports.getEvent = function (stack, resource, eventId, callback) { var self = this; + function getEvent(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', + resource instanceof orchestration.Resource ? resource.name : resource, 'events', eventId) + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.event); + + }); + } + if (stack instanceof orchestration.Stack) { getEvent(stack); } @@ -43,19 +57,6 @@ exports.getEvent = function (stack, resource, eventId, callback) { }); } - function getEvent(stack) { - return self._request({ - path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', - resource instanceof orchestration.Resource ? resource.name : resource, 'events', eventId) - }, function (err, body) { - if (err) { - return callback(err); - } - - callback(null, body.event); - - }); - } }; /** @@ -70,6 +71,19 @@ exports.getEvent = function (stack, resource, eventId, callback) { exports.getEvents = function(stack, callback) { var self = this; + function getEvents(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'events') + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.events); + + }); + } + if (stack instanceof orchestration.Stack) { getEvents(stack); } @@ -84,18 +98,6 @@ exports.getEvents = function(stack, callback) { }); } - function getEvents(stack) { - return self._request({ - path: urlJoin(_urlPrefix, stack.name, stack.id, 'events') - }, function (err, body) { - if (err) { - return callback(err); - } - - callback(null, body.events); - - }); - } }; /** @@ -111,20 +113,6 @@ exports.getEvents = function(stack, callback) { exports.getResourceEvents = function (stack, resource, callback) { var self = this; - if (stack instanceof orchestration.Stack) { - getEvents(stack); - } - else if (typeof stack === 'string') { - self.getStack(stack, function (err, stack) { - if (err) { - callback(err); - return; - } - - getEvents(stack); - }); - } - function getEvents(stack) { return self._request({ path: urlJoin(_urlPrefix, stack.name, stack.id, 'resources', @@ -138,4 +126,18 @@ exports.getResourceEvents = function (stack, resource, callback) { }); } + + if (stack instanceof orchestration.Stack) { + getEvents(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function (err, stack) { + if (err) { + callback(err); + return; + } + + getEvents(stack); + }); + } }; diff --git a/lib/pkgcloud/openstack/orchestration/client/resources.js b/lib/pkgcloud/openstack/orchestration/client/resources.js index bb1b158cb..bdecf3f60 100644 --- a/lib/pkgcloud/openstack/orchestration/client/resources.js +++ b/lib/pkgcloud/openstack/orchestration/client/resources.js @@ -28,6 +28,19 @@ var _urlPrefix = '/resource_types'; exports.getResource = function (stack, resource, callback) { var self = this; + function getResource(stack) { + return self._request({ + path: urlJoin('/stacks', stack.name, stack.id, 'resources', + resource instanceof orchestration.Resource ? resource.name : resource) + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, new orchestration.Resource(self, _.extend({ stack: stack }, body.resource))); + }); + } + if (stack instanceof orchestration.Stack) { getResource(stack); } @@ -41,19 +54,6 @@ exports.getResource = function (stack, resource, callback) { getResource(stack); }); } - - function getResource(stack) { - return self._request({ - path: urlJoin('/stacks', stack.name, stack.id, 'resources', - resource instanceof orchestration.Resource ? resource.name : resource) - }, function (err, body) { - if (err) { - return callback(err); - } - - callback(null, new orchestration.Resource(self, _.extend({ stack: stack }, body.resource))); - }); - } }; /** @@ -68,6 +68,20 @@ exports.getResource = function (stack, resource, callback) { exports.getResources = function (stack, callback) { var self = this; + function getResources(stack) { + return self._request({ + path: urlJoin('/stacks', stack.name, stack.id, 'resources') + }, function (err, body) { + if (err) { + return callback(err); + } + + callback(null, body.resources.map(function(resource) { + return new orchestration.Resource(self, _.extend({ stack: stack }, resource)); + })); + }); + } + if (stack instanceof orchestration.Stack) { getResources(stack); } @@ -82,19 +96,6 @@ exports.getResources = function (stack, callback) { }); } - function getResources(stack) { - return self._request({ - path: urlJoin('/stacks', stack.name, stack.id, 'resources') - }, function (err, body) { - if (err) { - return callback(err); - } - - callback(null, body.resources.map(function(resource) { - return new orchestration.Resource(self, _.extend({ stack: stack }, resource)); - })); - }); - } }; /** @@ -163,4 +164,4 @@ exports.getResourceTemplate = function (resourceType, callback) { callback(null, template); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 485866ce9..96abf471f 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -16,6 +16,30 @@ var request = require('request'), var _urlPrefix = '/stacks'; +/** + * validateProperties + * + * @description local helper function for validating arguments + * + * @param {Array} required The list of required properties + * @param {object} options The options object to validate + * @param {String} formatString String formatter for the error message + * @param {Function} callback + * @returns {boolean} + */ +function validateProperties(required, options, formatString, callback) { + return !required.some(function (item) { + if (typeof(options[item]) === 'undefined') { + errs.handle( + errs.create({ message: util.format(formatString, item) }), + callback + ); + return true; + } + return false; + }); +} + /** * client.getStack * @@ -299,6 +323,19 @@ exports.deleteStack = function (stack, callback) { exports.abandonStack = function (stack, callback) { var self = this; + function abandon(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id, 'abandon'), + method: 'DELETE' + }, function (err, abandonStackData) { + if (err) { + return callback(err); + } + + callback(err, abandonStackData); + }); + } + if (typeof stack === 'string') { self.getStack(stack, function(err, stack) { if (err) { @@ -318,40 +355,5 @@ exports.abandonStack = function (stack, callback) { abandon(stack); - function abandon(stack) { - return self._request({ - path: urlJoin(_urlPrefix, stack.name, stack.id, 'abandon'), - method: 'DELETE' - }, function (err, abandonStackData) { - if (err) { - return callback(err); - } - - callback(err, abandonStackData); - }); - } }; -/** - * validateProperties - * - * @description local helper function for validating arguments - * - * @param {Array} required The list of required properties - * @param {object} options The options object to validate - * @param {String} formatString String formatter for the error message - * @param {Function} callback - * @returns {boolean} - */ -function validateProperties(required, options, formatString, callback) { - return !required.some(function (item) { - if (typeof(options[item]) === 'undefined') { - errs.handle( - errs.create({ message: util.format(formatString, item) }), - callback - ); - return true; - } - return false; - }); -} diff --git a/lib/pkgcloud/openstack/orchestration/client/templates.js b/lib/pkgcloud/openstack/orchestration/client/templates.js index 4c022bb15..95d054494 100644 --- a/lib/pkgcloud/openstack/orchestration/client/templates.js +++ b/lib/pkgcloud/openstack/orchestration/client/templates.js @@ -27,20 +27,6 @@ var _urlPrefix = '/stacks'; exports.getTemplate = function (stack, callback) { var self = this; - if (stack instanceof orchestration.Stack) { - getTemplate(stack); - } - else if (typeof stack === 'string') { - self.getStack(stack, function(err, stack) { - if (err) { - callback(err); - return; - } - - getTemplate(stack); - }); - } - function getTemplate(stack) { return self._request({ path: urlJoin(_urlPrefix, stack.name, stack.id, 'template') @@ -56,6 +42,21 @@ exports.getTemplate = function (stack, callback) { } }); } + + if (stack instanceof orchestration.Stack) { + getTemplate(stack); + } + else if (typeof stack === 'string') { + self.getStack(stack, function(err, stack) { + if (err) { + callback(err); + return; + } + + getTemplate(stack); + }); + } + }; /** diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index f066fafc5..d2ee892e0 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -180,11 +180,6 @@ exports.upload = function (options) { * @returns {request|*} */ exports.download = function (options, callback) { - var self = this, - success = callback ? onDownload : null, - container = options.container, - inputStream, - apiStream; // // Optional helper function passed to `this._request` @@ -194,11 +189,17 @@ exports.download = function (options, callback) { return err ? callback(err) : callback(null, new self.models.File(self, _.extend(res.headers, { - container: container, + container: options.container, name: options.remote }))); } + var self = this, + success = callback ? onDownload : null, + container = options.container, + inputStream, + apiStream; + if (container instanceof self.models.Container) { container = container.name; } diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js index ba1bbc17d..b622e73a9 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js @@ -16,6 +16,62 @@ var base = require('../../../core/dns'), var _urlPrefix = 'loadbalancers'; +// Private function for validation of createLoadBalancer Inputs +var validateLbInputs = function (inputs) { + + var errors = { + requiredParametersMissing: [], + invalidInputs: [] + }, response; + + if (!inputs.name) { + errors.requiredParametersMissing.push('name'); + } + + if (!inputs.nodes) { + errors.requiredParametersMissing.push('nodes'); + } + + if (!inputs.protocol) { + errors.requiredParametersMissing.push('protocol'); + } + + if (!inputs.port) { + errors.requiredParametersMissing.push('port'); + } + + if (!inputs.virtualIps) { + errors.requiredParametersMissing.push('virtualIps'); + } + + if (inputs.name && inputs.name.length > 128) { + errors.invalidInputs.push('name exceeds maximum 128 length'); + } + + if (!inputs.protocol || + typeof(inputs.protocol) !== 'string' || !lb.Protocols[inputs.protocol]) { + errors.invalidInputs.push('please specify a valid protocol'); + } + + // TODO Node validation + + if (errors.requiredParametersMissing.length) { + response ? response.requiredParametersMissing = errors.requiredParametersMissing : + response = { + requiredParametersMissing: errors.requiredParametersMissing + }; + } + + if (errors.invalidInputs.length) { + response ? response.invalidInputs = errors.invalidInputs : + response = { + invalidInputs: errors.invalidInputs + }; + } + + return response; +}; + module.exports = { /** @@ -1124,59 +1180,3 @@ module.exports = { }); } }; - -// Private function for validation of createLoadBalancer Inputs -var validateLbInputs = function (inputs) { - - var errors = { - requiredParametersMissing: [], - invalidInputs: [] - }, response; - - if (!inputs.name) { - errors.requiredParametersMissing.push('name'); - } - - if (!inputs.nodes) { - errors.requiredParametersMissing.push('nodes'); - } - - if (!inputs.protocol) { - errors.requiredParametersMissing.push('protocol'); - } - - if (!inputs.port) { - errors.requiredParametersMissing.push('port'); - } - - if (!inputs.virtualIps) { - errors.requiredParametersMissing.push('virtualIps'); - } - - if (inputs.name && inputs.name.length > 128) { - errors.invalidInputs.push('name exceeds maximum 128 length'); - } - - if (!inputs.protocol || - typeof(inputs.protocol) !== 'string' || !lb.Protocols[inputs.protocol]) { - errors.invalidInputs.push('please specify a valid protocol'); - } - - // TODO Node validation - - if (errors.requiredParametersMissing.length) { - response ? response.requiredParametersMissing = errors.requiredParametersMissing : - response = { - requiredParametersMissing: errors.requiredParametersMissing - }; - } - - if (errors.invalidInputs.length) { - response ? response.invalidInputs = errors.invalidInputs : - response = { - invalidInputs: errors.invalidInputs - }; - } - - return response; -}; diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 5cef42185..8dbb5fcbe 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -396,6 +396,20 @@ exports.generateTempUrl = function(container, file, method, time, key, callback) self = this, split = '/v1'; + function createUrl() { + // construct our hmac signature + var expiry = parseInt(new Date().getTime() / 1000) + time, + url = self._getUrl({ + container: containerName, + path: fileName + }), + hmac_body = method.toUpperCase() + '\n' + expiry + '\n' + split + url.split(split)[1]; + + var hash = crypto.createHmac('sha1', key).update(hmac_body).digest('hex'); + + callback(null, url + '?temp_url_sig=' + hash + '&temp_url_expires=' + expiry); + } + // We have to be authed to make sure we have the service catalog // this is required to validate the service url @@ -414,17 +428,4 @@ exports.generateTempUrl = function(container, file, method, time, key, callback) createUrl(); - function createUrl() { - // construct our hmac signature - var expiry = parseInt(new Date().getTime() / 1000) + time, - url = self._getUrl({ - container: containerName, - path: fileName - }), - hmac_body = method.toUpperCase() + '\n' + expiry + '\n' + split + url.split(split)[1]; - - var hash = crypto.createHmac('sha1', key).update(hmac_body).digest('hex'); - - callback(null, url + '?temp_url_sig=' + hash + '&temp_url_expires=' + expiry); - } }; diff --git a/test/azure/compute/client/test-createServer.js b/test/azure/compute/client/test-createServer.js index 54529bc22..4f121723f 100644 --- a/test/azure/compute/client/test-createServer.js +++ b/test/azure/compute/client/test-createServer.js @@ -13,6 +13,8 @@ var fs = require('fs'), azureNock = require('../../../helpers/azureNock'), nock = require('nock'); +var testContext = {}; + var options = { name: 'create-test-ids2', flavor: 'ExtraSmall', @@ -92,8 +94,6 @@ function testSetWait(client) { var client = helpers.createClient('azure', 'compute'); -var testContext = {}; - if (process.env.MOCK) { azureNock.serverTest(nock, helpers); } diff --git a/test/azure/compute/client/test-rebootServer.js b/test/azure/compute/client/test-rebootServer.js index b20235af2..acacfbaf5 100644 --- a/test/azure/compute/client/test-rebootServer.js +++ b/test/azure/compute/client/test-rebootServer.js @@ -19,6 +19,8 @@ var options = { image: 'CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd' }; +var testContext = {}; + function testCreateServer(client) { var name = 'azure', test = {}; @@ -105,8 +107,6 @@ function testRebootServer(client) { var client = helpers.createClient('azure', 'compute'); -var testContext = {}; - if (process.env.MOCK) { azureNock.serverTest(nock, helpers); } diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index a7b4172a8..b5981e935 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -28,195 +28,6 @@ var azureOptions = require('../../fixtures/azure/azure-options.json'); azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].compute; -}).forEach(function(provider) { - describe('pkgcloud/common/compute/base [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'compute'), - context = {}, - authServer, server, - authHockInstance, - hockInstance; - - before(function(done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function(next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getVersion() method with no arguments should return the version', function (done) { - if (mock) { - var errors = setupVersionMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - if (errors) { - client.getVersion(function (err) { - err.should.be.an.instanceof(Error); - done(); - }); - } - else { - client.getVersion(function (err, version) { - should.not.exist(err); - should.exist(version); - version.should.equal(versions[provider]); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - } - }); - - it('the getFlavors() method should return a list of flavors', function(done) { - if (mock) { - setupFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getFlavors(function (err, flavors) { - should.not.exist(err); - should.exist(flavors); - - flavors.forEach(function (flavor) { - flavor.should.be.instanceOf(Flavor); - }); - - context.flavors = flavors; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getImages() method should return a list of images', function (done) { - if (mock) { - setupImagesMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getImages(function (err, images) { - should.not.exist(err); - should.exist(images); - - images.forEach(function (image) { - image.should.be.instanceOf(Image); - }); - - context.images = images; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the setWait() method waiting for a server to be operational should return a running server', function (done) { - var m = mock ? 0.1 : 100; - - if (mock) { - setupServerMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createServer(_.extend({ - name: 'create-test-setWait', - image: context.images[0].id, - flavor: context.flavors[0].id - }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { - should.not.exist(err); - should.exist(srv1); - - srv1.setWait({ status: srv1.STATUS.running }, 100 * m, 1000, function (err, srv2) { - should.not.exist(err); - should.exist(srv2); - srv2.should.be.instanceOf(Server); - srv2.name.should.equal('create-test-setWait'); - srv2.status.should.equal(srv2.STATUS.running); - context.server = srv2; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - }); - - it('the setWait() method waiting for a server to be operational should return a running server', function (done) { - // TODO enable destroy tests for all providers - if (provider === 'joyent' || provider === 'amazon' || provider === 'azure') { - done(); - return; - } - - if (mock) { - setupDestroyMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.destroyServer(context.server, function (err, result) { - should.not.exist(err); - should.exist(result); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - after(function(done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - authServer.close(next); - }, - function (next) { - server.close(next); - } - ], done); - }); - }); -}); - function setupVersionMock(client, provider, servers) { if (provider === 'digitalocean') { return true; @@ -585,3 +396,192 @@ function setupDestroyMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/destroy-server.json'); } } + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function(provider) { + describe('pkgcloud/common/compute/base [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'compute'), + context = {}, + authServer, server, + authHockInstance, + hockInstance; + + before(function(done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function(next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getVersion() method with no arguments should return the version', function (done) { + if (mock) { + var errors = setupVersionMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + if (errors) { + client.getVersion(function (err) { + err.should.be.an.instanceof(Error); + done(); + }); + } + else { + client.getVersion(function (err, version) { + should.not.exist(err); + should.exist(version); + version.should.equal(versions[provider]); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + } + }); + + it('the getFlavors() method should return a list of flavors', function(done) { + if (mock) { + setupFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getFlavors(function (err, flavors) { + should.not.exist(err); + should.exist(flavors); + + flavors.forEach(function (flavor) { + flavor.should.be.instanceOf(Flavor); + }); + + context.flavors = flavors; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getImages() method should return a list of images', function (done) { + if (mock) { + setupImagesMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getImages(function (err, images) { + should.not.exist(err); + should.exist(images); + + images.forEach(function (image) { + image.should.be.instanceOf(Image); + }); + + context.images = images; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the setWait() method waiting for a server to be operational should return a running server', function (done) { + var m = mock ? 0.1 : 100; + + if (mock) { + setupServerMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createServer(_.extend({ + name: 'create-test-setWait', + image: context.images[0].id, + flavor: context.flavors[0].id + }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + + srv1.setWait({ status: srv1.STATUS.running }, 100 * m, 1000, function (err, srv2) { + should.not.exist(err); + should.exist(srv2); + srv2.should.be.instanceOf(Server); + srv2.name.should.equal('create-test-setWait'); + srv2.status.should.equal(srv2.STATUS.running); + context.server = srv2; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + }); + + it('the setWait() method waiting for a server to be operational should return a running server', function (done) { + // TODO enable destroy tests for all providers + if (provider === 'joyent' || provider === 'amazon' || provider === 'azure') { + done(); + return; + } + + if (mock) { + setupDestroyMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.destroyServer(context.server, function (err, result) { + should.not.exist(err); + should.exist(result); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + after(function(done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + }); +}); diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index c1981371b..d87c3302a 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -18,6 +18,48 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; +function setupMetaMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata', + { metadata: { + os_type :'windows' + }}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/metaResponse.json'); + } +} + +function setupImagesMock(client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); + } +} + var providers=['openstack']; providers.filter(function (provider) { @@ -123,45 +165,3 @@ providers.filter(function (provider) { }); }); - -function setupMetaMock(client, provider, servers) { - if (provider === 'openstack') { - servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata', - { metadata: { - os_type :'windows' - }}) - .replyWithFile(202, __dirname + '/../../fixtures/openstack/metaResponse.json'); - } -} - -function setupImagesMock(client, provider, servers) { - if (provider === 'openstack') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } - } - }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' - } - }) - .reply(200, helpers.getOpenstackAuthResponse()); - - servers.server - .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); - } -} diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 341c86c12..68187315f 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -27,209 +27,27 @@ var azureOptions = require('../../fixtures/azure/azure-options.json'); azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].compute; -}).forEach(function (provider) { - describe('pkgcloud/common/compute/server [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'compute'), - context = {}, - authServer, server, - authHockInstance, - hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getImages() function should return a list of images', function(done) { - - if (mock) { - setupImagesMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getImages(function (err, images) { - should.not.exist(err); - should.exist(images); - - context.images = images; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getFlavors() function should return a list of flavors', function (done) { - - if (mock) { - setupFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getFlavors(function (err, flavors) { - should.not.exist(err); - should.exist(flavors); - - context.flavors = flavors; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the createServer() method with image and flavor should create a server', function (done) { - var m = mock ? .1 : 10; - - if (mock) { - setupServerMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createServer(_.extend({ - name: 'create-test-ids2', - image: context.images[0].id, - flavor: context.flavors[0].id - }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { - should.not.exist(err); - should.exist(srv1); - - srv1.setWait({ status: srv1.STATUS.running }, 100 * m, function (err, srv2) { - should.not.exist(err); - should.exist(srv2); - srv2.should.be.instanceOf(Server); - srv2.name.should.equal('create-test-ids2'); - srv2.imageId.should.equal(context.images[0].id); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('the getServers() method should return a list of servers', function (done) { - if (mock) { - setupGetServersMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getServers(function (err, servers) { - should.not.exist(err); - should.exist(servers); - - servers.should.be.an.Array; - - servers.forEach(function(srv) { - srv.should.be.instanceOf(Server); - }); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it.skip('the getServer() method should get a server instance', function (done) { - if (mock) { - setupGetServerMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getServer(context.servers[0].id, function (err, srv) { - should.not.exist(err); - should.exist(srv); - - srv.should.be.instanceOf(Server); - - context.currentServer = hockInstance; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it.skip('the server.rebootServer() method should restart a server instance', function (done) { - if (mock) { - setupRebootMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - context.currentServer.reboot(function(err) { - done(); - }); - }); - - it.skip('the destroyServer() method should delete a server instance', function (done) { - if (mock) { - setupRebootMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - context.currentServer.reboot(function (err) { - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } +/** + * serverStatusReply() + * fills in the nock xml reply from the server with server name and status + * @param name - name of the server + * @param status - status to be returned in reply + * status should be: + * ReadyRole - server is RUNNING + * VMStopped - server is still PROVISIONING + * Provisioning - server is still PROVISIONING + * see lib/pkgcloud/azure/compute/server.js for more status values + * + * @return {String} - the xml reply containing the server name and status + */ +var serverStatusReply = function (name, status) { - async.parallel([ - function (next) { - authServer.close(next); - }, - function (next) { - server.close(next); - } - ], done); - }); + var template = helpers.loadFixture('azure/server-status-template.xml'), + params = {NAME: name, STATUS: status}; - }); -}); + var result = _.template(template, params); + return result; +}; function setupImagesMock(client, provider, servers) { if (provider === 'rackspace') { @@ -578,6 +396,211 @@ function setupGetServerMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } } + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function (provider) { + describe('pkgcloud/common/compute/server [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'compute'), + context = {}, + authServer, server, + authHockInstance, + hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getImages() function should return a list of images', function(done) { + + if (mock) { + setupImagesMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getImages(function (err, images) { + should.not.exist(err); + should.exist(images); + + context.images = images; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getFlavors() function should return a list of flavors', function (done) { + + if (mock) { + setupFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getFlavors(function (err, flavors) { + should.not.exist(err); + should.exist(flavors); + + context.flavors = flavors; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the createServer() method with image and flavor should create a server', function (done) { + var m = mock ? .1 : 10; + + if (mock) { + setupServerMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createServer(_.extend({ + name: 'create-test-ids2', + image: context.images[0].id, + flavor: context.flavors[0].id + }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + + srv1.setWait({ status: srv1.STATUS.running }, 100 * m, function (err, srv2) { + should.not.exist(err); + should.exist(srv2); + srv2.should.be.instanceOf(Server); + srv2.name.should.equal('create-test-ids2'); + srv2.imageId.should.equal(context.images[0].id); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the getServers() method should return a list of servers', function (done) { + if (mock) { + setupGetServersMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getServers(function (err, servers) { + should.not.exist(err); + should.exist(servers); + + servers.should.be.an.Array; + + servers.forEach(function(srv) { + srv.should.be.instanceOf(Server); + }); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it.skip('the getServer() method should get a server instance', function (done) { + if (mock) { + setupGetServerMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getServer(context.servers[0].id, function (err, srv) { + should.not.exist(err); + should.exist(srv); + + srv.should.be.instanceOf(Server); + + context.currentServer = hockInstance; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it.skip('the server.rebootServer() method should restart a server instance', function (done) { + if (mock) { + setupRebootMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + context.currentServer.reboot(function(err) { + done(); + }); + }); + + it.skip('the destroyServer() method should delete a server instance', function (done) { + if (mock) { + setupRebootMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + context.currentServer.reboot(function (err) { + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + + }); +}); + // //function batchThree(providerClient, providerName) { // var name = providerName || 'rackspace', @@ -935,27 +958,6 @@ function setupGetServerMock(client, provider, servers) { // .export(module) // ; // });z -/** - * serverStatusReply() - * fills in the nock xml reply from the server with server name and status - * @param name - name of the server - * @param status - status to be returned in reply - * status should be: - * ReadyRole - server is RUNNING - * VMStopped - server is still PROVISIONING - * Provisioning - server is still PROVISIONING - * see lib/pkgcloud/azure/compute/server.js for more status values - * - * @return {String} - the xml reply containing the server name and status - */ -var serverStatusReply = function (name, status) { - - var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; - - var result = _.template(template, params); - return result; -}; var filterPath = function (path) { var name = PATH.basename(path); diff --git a/test/common/databases/databases-test.js b/test/common/databases/databases-test.js index 457bfd846..4d6156942 100644 --- a/test/common/databases/databases-test.js +++ b/test/common/databases/databases-test.js @@ -13,6 +13,197 @@ var should = require('should'), providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; +function setupCreateDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } +} + +function setupCreateDatabasesForPaginationMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } +} + +function setupModelCreateDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } +} + + + +function setupGetDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } +} + +function setupDestroyDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } +} + +function setupDestroyLastDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } +} + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { @@ -311,194 +502,3 @@ providers.filter(function (provider) { }); }); }); - -function setupCreateDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabase' } - ] - }) - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabase' } - ] - }) - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabase' } - ] - }) - .reply(202); - } -} - -function setupCreateDatabasesForPaginationMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseTwo' } - ] - }) - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseTwo' } - ] - }) - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseTwo' } - ] - }) - .reply(202); - } -} - -function setupModelCreateDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseThree' } - ] - }) - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseThree' } - ] - }) - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseThree' } - ] - }) - .reply(202); - } -} - - - -function setupGetDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); - } -} - -function setupDestroyDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') - .reply(202); - } -} - -function setupDestroyLastDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') - .reply(202); - } -} diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index 71efb4d9c..713004152 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -14,6 +14,24 @@ var should = require('should'), providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; +function setupGetFlavorMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/3') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor3.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/3') + .reply(200, helpers.loadFixture('openstack/databaseFlavor3.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/3') + .reply(200, helpers.loadFixture('hp/databaseFlavor3.json')); + } +} + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { @@ -139,22 +157,3 @@ providers.filter(function (provider) { } } }); - - -function setupGetFlavorMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/3') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor3.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/3') - .reply(200, helpers.loadFixture('openstack/databaseFlavor3.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/3') - .reply(200, helpers.loadFixture('hp/databaseFlavor3.json')); - } -} diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index cc5efd37e..6e3b5e624 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -14,6 +14,288 @@ var should = require('should'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, Instance = require('../../../lib/pkgcloud/openstack/database/instance').Instance, mock = !!process.env.MOCK; + +function assertLinks(links) { + links.should.be.an.Array; + links.forEach(function (link) { + should.exist(link.href); + should.exist(link.rel); + }); +} + +function setupCreateInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/1') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) + .post('/v1.0/123456/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') + .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') + .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } +} + +function setupGetInstancesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')); + } +} + +function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances?limit=2') + .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances?limit=2') + .reply(200, helpers.loadFixture('openstack/databaseInstancesLimit2.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances?limit=2') + .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')); + } +} + +function setupDestroyInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202); + } +} + +function setGetInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('rackspace/databaseInstance.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('openstack/databaseInstance.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('hp/databaseInstance.json')); + } +} + +function setGetFlavorsMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/2') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') + .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') + .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')); + } +} + +function setupSetFlavorMock(hockInstance, provider) { + if (provider ==='rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/flavors/2') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + } + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') + .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + } + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') + .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + } + }) + .reply(202); + } +} + +function setupResizeMock (hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 + } + } + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 + } + } + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 + } + } + }) + .reply(202); + } +} + +function setupGetOneFlavorMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/1') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') + .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') + .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')); + } +} + +function setupRestartInstanceMock (hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202); + } +} + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { @@ -229,515 +511,235 @@ providers.filter(function (provider) { if (mock) { hockInstance - .get('/v1.0/123456/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262') - .reply(200, helpers.loadFixture('rackspace/databaseInstanceOffset.json')); - } - - client.getInstances({ offset: testContext.marker }, function (err, instances, offset) { - should.not.exist(err); - should.exist(instances); - instances.should.be.an.Array; - should.ok(instances.length >= 2 - && instances.length < testContext.instancesQuantity); - hockInstance && hockInstance.done(); - done(); - }); - - }); - - it('with limit and offset should respond just one result with more next points', function (done) { - if(provider !== 'rackspace') { - return done(); - } - - if (mock) { - hockInstance - .get('/v1.0/123456/instances?limit=1&marker=55041e91-98ab-4cd5-8148-f3b3978b3262') - .reply(200, helpers.loadFixture('rackspace/databaseInstanceLimitOffset.json')); - } - - client.getInstances({limit: 1, offset: testContext.marker }, function (err, instances, offset) { - should.not.exist(err); - should.exist(instances); - instances.should.be.an.Array; - should.exist(offset); - instances.should.have.length(1); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - describe('the setFlavor() method', function () { - it('without instance and flavor parameters should get errors', function (done) { - client.setFlavor(function (err) { - should.exist(err); - done(); - }); - }); - - it('without flavor parameter should get errors', function (done) { - - if (mock) { - setupGetInstancesMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.setFlavor(instance, function (err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('without instance parameter should get errors', function (done) { - - if (mock) { - setGetFlavorsMock(hockInstance, provider); - } - - client.getFlavor(2, function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - - client.setFlavor(flavor, function(err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with correct inputs should respond correctly', function (done) { - - if (mock) { - setupSetFlavorMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - var newFlavor = (Number(instance.flavor.id) === 4) ? 1 : Number(instance.flavor.id) + 1; - client.getFlavor(newFlavor, function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - client.setFlavor(instance, flavor, function (err) { - should.not.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - }); - - describe('the setVolumeSize() method', function() { - it('without instance and size parameters should get errors', function(done) { - client.setVolumeSize(function(err) { - should.exist(err); - done(); - }); - }); - - it('without size parameter should get errors', function (done) { - - if (mock) { - setupGetInstancesMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.setVolumeSize(instance, function (err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('without invalid size parameter should get errors', function (done) { - - if (mock) { - setupGetInstancesMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.setVolumeSize(instance, 12, function (err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); - }); + .get('/v1.0/123456/instances?marker=55041e91-98ab-4cd5-8148-f3b3978b3262') + .reply(200, helpers.loadFixture('rackspace/databaseInstanceOffset.json')); + } + + client.getInstances({ offset: testContext.marker }, function (err, instances, offset) { + should.not.exist(err); + should.exist(instances); + instances.should.be.an.Array; + should.ok(instances.length >= 2 + && instances.length < testContext.instancesQuantity); + hockInstance && hockInstance.done(); + done(); }); + }); - it('with correct inputs should respond correctly', function (done) { + it('with limit and offset should respond just one result with more next points', function (done) { + if(provider !== 'rackspace') { + return done(); + } if (mock) { - setupResizeMock (hockInstance, provider); + hockInstance + .get('/v1.0/123456/instances?limit=1&marker=55041e91-98ab-4cd5-8148-f3b3978b3262') + .reply(200, helpers.loadFixture('rackspace/databaseInstanceLimitOffset.json')); } - helpers.selectInstance(client, function (instance) { - var newSize = (Number(instance.volume.size) === 8) ? 1 : Number(instance.volume.size) + 1; - - client.setVolumeSize(instance, newSize, function (err) { - should.not.exist(err); - hockInstance && hockInstance.done(); - done(); - }); + client.getInstances({limit: 1, offset: testContext.marker }, function (err, instances, offset) { + should.not.exist(err); + should.exist(instances); + instances.should.be.an.Array; + should.exist(offset); + instances.should.have.length(1); + hockInstance && hockInstance.done(); + done(); }); }); }); - describe('the create() method with errors', function () { - it('should respond with errors', function (done) { - client.createInstance(function(err) { + describe('the setFlavor() method', function () { + it('without instance and flavor parameters should get errors', function (done) { + client.setFlavor(function (err) { should.exist(err); done(); }); }); - it('without flavor should respond with errors', function (done) { - client.createInstance({ name: 'test-without-flavor' }, function (err) { - should.exist(err); - done(); - }); - }); + it('without flavor parameter should get errors', function (done) { - it('with invalid size should respond with errors', function (done) { if (mock) { - setupGetOneFlavorMock(hockInstance, provider); + setupGetInstancesMock(hockInstance, provider); } - client.getFlavor(1, function (err, flavor) { - client.createInstance({ - name: 'test-instance', - flavor: flavor, - size: '1' - }, function(err) { + helpers.selectInstance(client, function (instance) { + client.setFlavor(instance, function (err) { should.exist(err); hockInstance && hockInstance.done(); done(); }); }); }); - }); - describe('the restartInstance() method', function () { - it('with no instance should return error', function (done) { - client.restartInstance(function (err) { - should.exist(err); - done(); - }); - }); + it('without instance parameter should get errors', function (done) { - it('with valid instance should restart', function (done) { if (mock) { - setupRestartInstanceMock (hockInstance, provider); + setGetFlavorsMock(hockInstance, provider); } - helpers.selectInstance(client, function (instance) { - client.restartInstance(instance, function (err) { - should.not.exist(err); + client.getFlavor(2, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + + client.setFlavor(flavor, function(err) { + should.exist(err); hockInstance && hockInstance.done(); done(); }); }); }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - }); - }); - -}); -function assertLinks(links) { - links.should.be.an.Array; - links.forEach(function (link) { - should.exist(link.href); - should.exist(link.rel); - }); -} - -function setupCreateInstanceMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/1') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) - .post('/v1.0/123456/instances', { - instance: { - name: 'test-instance', - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], - volume: { - size:1 - } - } - }) - .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') - .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances', { - instance: { - name: 'test-instance', - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], - volume: { - size:1 - } - } - }) - .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') - .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances', { - instance: { - name: 'test-instance', - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], - volume: { - size:1 - } - } - }) - .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); - } -} - -function setupGetInstancesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')); - } -} - -function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances?limit=2') - .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances?limit=2') - .reply(200, helpers.loadFixture('openstack/databaseInstancesLimit2.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances?limit=2') - .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')); - } -} - -function setupDestroyInstanceMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202); - } -} - -function setGetInstanceMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(200, helpers.loadFixture('rackspace/databaseInstance.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(200, helpers.loadFixture('openstack/databaseInstance.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(200, helpers.loadFixture('hp/databaseInstance.json')); - } -} -function setGetFlavorsMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/2') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') - .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') - .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')); - } -} + it('with correct inputs should respond correctly', function (done) { -function setupSetFlavorMock(hockInstance, provider) { - if (provider ==='rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/flavors/2') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + if (mock) { + setupSetFlavorMock(hockInstance, provider); } - }) - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') - .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + + helpers.selectInstance(client, function (instance) { + var newFlavor = (Number(instance.flavor.id) === 4) ? 1 : Number(instance.flavor.id) + 1; + client.getFlavor(newFlavor, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + client.setFlavor(instance, flavor, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + }); + + describe('the setVolumeSize() method', function() { + it('without instance and size parameters should get errors', function(done) { + client.setVolumeSize(function(err) { + should.exist(err); + done(); + }); + }); + + it('without size parameter should get errors', function (done) { + + if (mock) { + setupGetInstancesMock(hockInstance, provider); } - }) - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') - .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' + + helpers.selectInstance(client, function (instance) { + client.setVolumeSize(instance, function (err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('without invalid size parameter should get errors', function (done) { + + if (mock) { + setupGetInstancesMock(hockInstance, provider); } - }) - .reply(202); - } -} -function setupResizeMock (hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - volume :{ - size :2 + helpers.selectInstance(client, function (instance) { + client.setVolumeSize(instance, 12, function (err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with correct inputs should respond correctly', function (done) { + + if (mock) { + setupResizeMock (hockInstance, provider); } - } - }) - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - volume :{ - size :2 + + helpers.selectInstance(client, function (instance) { + var newSize = (Number(instance.volume.size) === 8) ? 1 : Number(instance.volume.size) + 1; + + client.setVolumeSize(instance, newSize, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + describe('the create() method with errors', function () { + it('should respond with errors', function (done) { + client.createInstance(function(err) { + should.exist(err); + done(); + }); + }); + + it('without flavor should respond with errors', function (done) { + client.createInstance({ name: 'test-without-flavor' }, function (err) { + should.exist(err); + done(); + }); + }); + + it('with invalid size should respond with errors', function (done) { + if (mock) { + setupGetOneFlavorMock(hockInstance, provider); } - } - }) - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - volume :{ - size :2 + + client.getFlavor(1, function (err, flavor) { + client.createInstance({ + name: 'test-instance', + flavor: flavor, + size: '1' + }, function(err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + describe('the restartInstance() method', function () { + it('with no instance should return error', function (done) { + client.restartInstance(function (err) { + should.exist(err); + done(); + }); + }); + + it('with valid instance should restart', function (done) { + if (mock) { + setupRestartInstanceMock (hockInstance, provider); } + + helpers.selectInstance(client, function (instance) { + client.restartInstance(instance, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + after(function (done) { + if (!mock) { + return done(); } - }) - .reply(202); - } -} -function setupGetOneFlavorMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/1') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') - .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') - .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')); - } -} + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + }); + }); -function setupRestartInstanceMock (hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202); - } -} +}); diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index 1fc782e0f..1a648527f 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -13,278 +13,6 @@ var should = require('should'), User = require('../../../lib/pkgcloud/openstack/database/user').User, providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; -}).forEach(function (provider) { -describe('pkgcloud/['+provider+']/databases/users', function () { - var testContext = {}, - client, authHockInstance, hockInstance, authServer, server; - - describe('The pkgcloud '+provider+' Database client', function () { - - before(function (done) { - client = helpers.createClient(provider, 'database'); - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the createUser() method should respond correctly', function (done) { - if (mock) { - setupAuthenticationMock(authHockInstance, hockInstance, provider); - setupCreateUserMock(authHockInstance, hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.createUser({ - username: 'joeTest', - password: 'joepasswd', - database: 'TestDatabase', - instance: instance - }, function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - }); - - it('the createUser() method should work with databases argument', function (done) { - if (mock) { - setupCreateUserMock(authHockInstance, hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.createUser({ - username: 'joeTest', - password: 'joepasswd', - databases: ['TestDatabase'], - instance: instance - }, function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - }); - - it('create an other user for test pagination should response correctly', function (done) { - - if (mock) { - setupCreateAnotherUserMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.createUser({ - username: 'joeTestTwo', - password: 'joepasswd', - database: 'TestDatabase', - instance: instance - }, function () { - client.createUser({ - username: 'joeTestThree', - password: 'joepasswd', - database: 'TestDatabase', - instance: instance - }, function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - - it('create multiple users in one request should response correctly', function (done) { - - if (mock) { - setupCreateMultiplsUsersMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.createUser([ - { - username: 'joeTestFour', - password: 'joepasswd', - database: 'TestDatabase', - instance: instance - }, - { - username: 'joeTestFive', - password: 'joepasswd', - database: 'TestDatabase', - instance: instance - } - ], function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('create users with questionable characters should respond with error', function (done) { - - if (mock) { - setupCreateUsersWithRestrictedCharacters(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.createUser({ - username: '@joeTestSix', - password: 'joepasswd', - database: 'TestDatabase', - instance: instance - }, function (err, response) { - should.exist(err); - should.not.exist(response); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('the getUsers() method should get the list of users', function (done) { - - if (mock) { - setupGetUsersMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance }, function (err, list) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.forEach(function (user) { - user.should.be.instanceOf(User); - }); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - describe('the destroyUsers() method', function() { - it('should respond correctly', function(done) { - - if (mock) { - setupDestroyUsersMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.destroyUser(instance, 'joeTest', function(err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('should destroy the user used for pagination', function(done) { - - if (mock) { - setupDestroyUsersMockWithPagination(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.destroyUser(instance, 'joeTestTwo', function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - - it('the enableRoot() method should respond correctly', function(done) { - - if (mock) { - setupEnableRootMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.enableRoot(instance, function(err, user, response) { - should.not.exist(err); - should.exist(user); - should.exist(response); - response.statusCode.should.equal(200); - should.exist(response.body); - response.body.user.should.be.a.Object; - should.exist(response.body.user.password); - response.body.user.name.should.equal('root'); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('the enableRoot() method should respond correctly', function (done) { - - if (mock) { - setupEnableRootMockWithStatus(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.rootEnabled(instance, function (err, root, response) { - should.not.exist(err); - should.exist(root); - should.exist(response); - response.statusCode.should.equal(200); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - }); -}); -}); function setupAuthenticationMock (authHockInstance, hockInstance, provider) { if (provider === 'rackspace') { @@ -518,240 +246,513 @@ function setupCreateAnotherUserMock(hockInstance, provider) { } } -function setupCreateMultiplsUsersMock(hockInstance, provider) { +function setupCreateMultiplsUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else { + throw new Error('not supported'); + } +} + +function setupCreateUsersWithRestrictedCharacters(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')); + } + else { + throw new Error('not supported'); + } +} + +function setupGetUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('openstack/databaseUsers.json')); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('hp/databaseUsers.json')); + } + else { + throw new Error('not supported'); + } + +} + +function setupEnableRootMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' + } + }); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' + } + }); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' + } + }); + } +} + +function setupEnableRootMockWithStatus(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } +} + +function setupDestroyUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } +} + +function setupDestroyUsersMockWithPagination(hockInstance, provider) { if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestFour', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - }, - { - name: 'joeTestFive', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); - } - else if ( provider === 'hp' ){ hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestFour', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - }, - { - name: 'joeTestFive', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); } - else if ( provider === 'openstack' ){ - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestFour', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - }, - { - name: 'joeTestFive', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); } - else { - throw new Error('not supported'); + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); } } -function setupCreateUsersWithRestrictedCharacters(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); - } - else if ( provider === 'openstack' ){ - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); - } - else if ( provider === 'hp' ){ - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')); - } - else { - throw new Error('not supported'); - } -} +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; +}).forEach(function (provider) { +describe('pkgcloud/['+provider+']/databases/users', function () { + var testContext = {}, + client, authHockInstance, hockInstance, authServer, server; + + describe('The pkgcloud '+provider+' Database client', function () { + + before(function (done) { + client = helpers.createClient(provider, 'database'); + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the createUser() method should respond correctly', function (done) { + if (mock) { + setupAuthenticationMock(authHockInstance, hockInstance, provider); + setupCreateUserMock(authHockInstance, hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.createUser({ + username: 'joeTest', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + }, function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + }); + + it('the createUser() method should work with databases argument', function (done) { + if (mock) { + setupCreateUserMock(authHockInstance, hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.createUser({ + username: 'joeTest', + password: 'joepasswd', + databases: ['TestDatabase'], + instance: instance + }, function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + }); + + it('create an other user for test pagination should response correctly', function (done) { + + if (mock) { + setupCreateAnotherUserMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.createUser({ + username: 'joeTestTwo', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + }, function () { + client.createUser({ + username: 'joeTestThree', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + }, function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + it('create multiple users in one request should response correctly', function (done) { + + if (mock) { + setupCreateMultiplsUsersMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.createUser([ + { + username: 'joeTestFour', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + }, + { + username: 'joeTestFive', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + } + ], function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('create users with questionable characters should respond with error', function (done) { + + if (mock) { + setupCreateUsersWithRestrictedCharacters(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.createUser({ + username: '@joeTestSix', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + }, function (err, response) { + should.exist(err); + should.not.exist(response); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the getUsers() method should get the list of users', function (done) { -function setupGetUsersMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); - } - else if ( provider === 'openstack' ){ - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('openstack/databaseUsers.json')); - } - else if ( provider === 'hp' ){ - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('hp/databaseUsers.json')); - } - else { - throw new Error('not supported'); - } + if (mock) { + setupGetUsersMock(hockInstance, provider); + } -} + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance }, function (err, list) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.forEach(function (user) { + user.should.be.instanceOf(User); + }); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); -function setupEnableRootMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { - user: { - password: 'dbba235b-d078-42ec-b992-dec1464c49cc', - name: 'root' + describe('the destroyUsers() method', function() { + it('should respond correctly', function(done) { + + if (mock) { + setupDestroyUsersMock(hockInstance, provider); } + + helpers.selectInstance(client, function (instance) { + client.destroyUser(instance, 'joeTest', function(err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); }); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { - user: { - password: 'dbba235b-d078-42ec-b992-dec1464c49cc', - name: 'root' + + it('should destroy the user used for pagination', function(done) { + + if (mock) { + setupDestroyUsersMockWithPagination(hockInstance, provider); } + + helpers.selectInstance(client, function (instance) { + client.destroyUser(instance, 'joeTestTwo', function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); }); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { - user: { - password: 'dbba235b-d078-42ec-b992-dec1464c49cc', - name: 'root' - } + }); + + it('the enableRoot() method should respond correctly', function(done) { + + if (mock) { + setupEnableRootMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.enableRoot(instance, function(err, user, response) { + should.not.exist(err); + should.exist(user); + should.exist(response); + response.statusCode.should.equal(200); + should.exist(response.body); + response.body.user.should.be.a.Object; + should.exist(response.body.user.password); + response.body.user.name.should.equal('root'); + hockInstance && hockInstance.done(); + done(); + }); }); - } -} + }); -function setupEnableRootMockWithStatus(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { rootEnabled: true }); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { rootEnabled: true }); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { rootEnabled: true }); - } -} + it('the enableRoot() method should respond correctly', function (done) { -function setupDestroyUsersMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') - .reply(202); - } -} + if (mock) { + setupEnableRootMockWithStatus(hockInstance, provider); + } -function setupDestroyUsersMockWithPagination(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') - .reply(202); - } -} + helpers.selectInstance(client, function (instance) { + client.rootEnabled(instance, function (err, root, response) { + should.not.exist(err); + should.exist(root); + should.exist(response); + response.statusCode.should.equal(200); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + }); +}); +}); diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 889d02d6f..45aeef6a7 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -20,229 +20,6 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].network; -}).forEach(function (provider) { - describe('pkgcloud/common/network/networks [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'network'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getNetworks() function should return a list of networks', function(done) { - - if (mock) { - setupNetworksMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getNetworks(function (err, networks) { - should.not.exist(err); - should.exist(networks); - - context.networks = networks; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getNetwork() method should get a network instance', function (done) { - if (mock) { - setupGetNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getNetwork(context.networks[0].id, function (err, network) { - should.not.exist(err); - should.exist(network); - network.should.be.an.instanceOf(Network); - network.should.have.property('id', context.networks[0].id); - context.currentNetwork = network; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the createNetwork() method should create a network', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createNetwork(_.extend({ - name: 'create-test-ids2' - }), function (err, network) { - should.not.exist(err); - should.exist(network); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the destroyNetwork() method should delete a network', function (done) { - if (mock) { - setupDestroyNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentNetwork); - } - - client.destroyNetwork(context.currentNetwork, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the destroyNetwork() method should take an id, delete a network', function (done) { - if (mock) { - setupDestroyNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentNetwork); - } - - client.destroyNetwork(context.currentNetwork.id, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the updateNetwork() method should update a network', function (done) { - - var networkToUpdate = context.currentNetwork; - networkToUpdate.adminStateUp = false; - - if (mock) { - setupUpdateNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, networkToUpdate); - } - - client.updateNetwork(networkToUpdate, function(err,network){ - should.not.exist(err); - done(); - }); - }); - - it('the network.create() method should create a network', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupNetworkModelCreateMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - var network = new Network(client); - network.name = 'model created network'; - network.create(function (err, createdNetwork) { - should.not.exist(err); - should.exist(createdNetwork); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the network.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - - var network = new Network(client); - network.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; - - if (mock) { - setupRefreshNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, network); - } - - network.refresh(function (err, refreshedNetwork) { - should.not.exist(err); - should.exist(refreshedNetwork); - refreshedNetwork.should.have.property('name', 'private-network'); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the network.destroy() method should delete a network', function (done) { - var network = new Network(client); - network.name = 'model deleted network'; - network.id = 'THISISANETWORKID'; - - if (mock) { - setupModelDestroyedNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, network); - } - - network.destroy(function (err) { - should.not.exist(err); - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - - }); -}); - function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server @@ -506,3 +283,226 @@ var filterPath = function (path) { return path; }; + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/networks [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getNetworks() function should return a list of networks', function(done) { + + if (mock) { + setupNetworksMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getNetworks(function (err, networks) { + should.not.exist(err); + should.exist(networks); + + context.networks = networks; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getNetwork() method should get a network instance', function (done) { + if (mock) { + setupGetNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getNetwork(context.networks[0].id, function (err, network) { + should.not.exist(err); + should.exist(network); + network.should.be.an.instanceOf(Network); + network.should.have.property('id', context.networks[0].id); + context.currentNetwork = network; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createNetwork() method should create a network', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createNetwork(_.extend({ + name: 'create-test-ids2' + }), function (err, network) { + should.not.exist(err); + should.exist(network); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroyNetwork() method should delete a network', function (done) { + if (mock) { + setupDestroyNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentNetwork); + } + + client.destroyNetwork(context.currentNetwork, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroyNetwork() method should take an id, delete a network', function (done) { + if (mock) { + setupDestroyNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentNetwork); + } + + client.destroyNetwork(context.currentNetwork.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updateNetwork() method should update a network', function (done) { + + var networkToUpdate = context.currentNetwork; + networkToUpdate.adminStateUp = false; + + if (mock) { + setupUpdateNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, networkToUpdate); + } + + client.updateNetwork(networkToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the network.create() method should create a network', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupNetworkModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var network = new Network(client); + network.name = 'model created network'; + network.create(function (err, createdNetwork) { + should.not.exist(err); + should.exist(createdNetwork); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the network.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var network = new Network(client); + network.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; + + if (mock) { + setupRefreshNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, network); + } + + network.refresh(function (err, refreshedNetwork) { + should.not.exist(err); + should.exist(refreshedNetwork); + refreshedNetwork.should.have.property('name', 'private-network'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the network.destroy() method should delete a network', function (done) { + var network = new Network(client); + network.name = 'model deleted network'; + network.id = 'THISISANETWORKID'; + + if (mock) { + setupModelDestroyedNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, network); + } + + network.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 08eb3ba34..be6900d87 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -20,231 +20,6 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].network; -}).forEach(function (provider) { - describe('pkgcloud/common/network/ports [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'network'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getPorts() function should return a list of ports', function(done) { - - if (mock) { - setupPortsMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getPorts(function (err, ports) { - should.not.exist(err); - should.exist(ports); - - context.ports = ports; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getPort() method should get a port instance', function (done) { - if (mock) { - setupGetPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.ports[0]); - } - - client.getPort(context.ports[0].id, function (err, port) { - should.not.exist(err); - should.exist(port); - port.should.be.an.instanceOf(Port); - port.should.have.property('id', context.ports[0].id); - context.currentPort = port; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the createPort() method should create a port', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupCreatePortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createPort({ - name: 'create-test-ids2' - }, function (err, port) { - should.not.exist(err); - should.exist(port); - port.should.be.an.instanceOf(Port); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the destroyPort() method should delete a port', function (done) { - if (mock) { - setupDestroyPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentPort); - } - - client.destroyPort(context.currentPort, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the destroyPort() method should take an id, delete a port', function (done) { - if (mock) { - setupDestroyPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentPort); - } - - client.destroyPort(context.currentPort.id, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the updatePort() method should update a port', function (done) { - - var portToUpdate = context.currentPort; - portToUpdate.adminStateUp = false; - - if (mock) { - setupUpdatePortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, portToUpdate); - } - - client.updatePort(portToUpdate, function(err,network){ - should.not.exist(err); - done(); - }); - }); - - it('the port.create() method should create a port', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupPortModelCreateMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - var port = new Port(client); - port.name= 'model created network'; - port.create(function (err, createdPort) { - should.not.exist(err); - should.exist(createdPort); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the port.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - - var port = new Port(client); - port.id = context.ports[0].id; - - if (mock) { - setupRefreshPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, port); - } - - port.refresh(function (err, refreshedPort) { - should.not.exist(err); - should.exist(refreshedPort); - refreshedPort.should.have.property('name', 'my_port'); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the port.destroy() method should delete a port', function (done) { - var port = new Port(client); - port.name = 'model deleted port'; - port.id = 'THISISANETWORKID'; - - if (mock) { - setupModelDestroyedPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, port); - } - - port.destroy(function (err) { - should.not.exist(err); - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - - }); -}); - function setupDestroyPortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server @@ -514,3 +289,228 @@ function setupGetPortMock(client, provider, servers, currentPort) { .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } } + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/ports [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getPorts() function should return a list of ports', function(done) { + + if (mock) { + setupPortsMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getPorts(function (err, ports) { + should.not.exist(err); + should.exist(ports); + + context.ports = ports; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getPort() method should get a port instance', function (done) { + if (mock) { + setupGetPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.ports[0]); + } + + client.getPort(context.ports[0].id, function (err, port) { + should.not.exist(err); + should.exist(port); + port.should.be.an.instanceOf(Port); + port.should.have.property('id', context.ports[0].id); + context.currentPort = port; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createPort() method should create a port', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupCreatePortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createPort({ + name: 'create-test-ids2' + }, function (err, port) { + should.not.exist(err); + should.exist(port); + port.should.be.an.instanceOf(Port); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroyPort() method should delete a port', function (done) { + if (mock) { + setupDestroyPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentPort); + } + + client.destroyPort(context.currentPort, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroyPort() method should take an id, delete a port', function (done) { + if (mock) { + setupDestroyPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentPort); + } + + client.destroyPort(context.currentPort.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updatePort() method should update a port', function (done) { + + var portToUpdate = context.currentPort; + portToUpdate.adminStateUp = false; + + if (mock) { + setupUpdatePortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, portToUpdate); + } + + client.updatePort(portToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the port.create() method should create a port', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupPortModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var port = new Port(client); + port.name= 'model created network'; + port.create(function (err, createdPort) { + should.not.exist(err); + should.exist(createdPort); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the port.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var port = new Port(client); + port.id = context.ports[0].id; + + if (mock) { + setupRefreshPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, port); + } + + port.refresh(function (err, refreshedPort) { + should.not.exist(err); + should.exist(refreshedPort); + refreshedPort.should.have.property('name', 'my_port'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the port.destroy() method should delete a port', function (done) { + var port = new Port(client); + port.name = 'model deleted port'; + port.id = 'THISISANETWORKID'; + + if (mock) { + setupModelDestroyedPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, port); + } + + port.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index a4abf240c..ab7e4a0d2 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -20,231 +20,6 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].network; -}).forEach(function (provider) { - describe('pkgcloud/common/network/subnets [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'network'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getSubnets() function should return a list of subnets', function(done) { - - if (mock) { - setupSubnetsMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getSubnets(function (err, subnets) { - should.not.exist(err); - should.exist(subnets); - - context.subnets = subnets; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getSubnet() method should get a subnet instance', function (done) { - if (mock) { - setupGetSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - },context.subnets[0]); - } - - client.getSubnet(context.subnets[0].id, function (err, subnet) { - should.not.exist(err); - should.exist(subnet); - subnet.should.be.an.instanceOf(Subnet); - subnet.should.have.property('id', context.subnets[0].id); - context.currentSubnet = subnet; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the createSubnet() method should create a subnet', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupCreateSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createSubnet({ - name: 'create-test-ids2' - }, function (err, subnet) { - should.not.exist(err); - should.exist(subnet); - subnet.should.be.an.instanceOf(Subnet); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the destroySubnet() method should delete a subnet', function (done) { - if (mock) { - setupDestroySubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentSubnet); - } - - client.destroySubnet(context.currentSubnet, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the destroySubnet() method should take an id, delete a subnet', function (done) { - if (mock) { - setupDestroySubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentSubnet); - } - - client.destroySubnet(context.currentSubnet.id, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the updateSubnet() method should update a subnet', function (done) { - - var subnetToUpdate = context.currentSubnet; - subnetToUpdate.enableDhcp = false; - - if (mock) { - setupUpdateSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, subnetToUpdate); - } - - client.updateSubnet(subnetToUpdate, function(err,network){ - should.not.exist(err); - done(); - }); - }); - - it('the subnet.create() method should create a subnet', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupSubnetModelCreateMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - var subnet = new Subnet(client); - subnet.name= 'model created network'; - subnet.create(function (err, createdSubnet) { - should.not.exist(err); - should.exist(createdSubnet); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the subnet.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - - var subnet = new Subnet(client); - subnet.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; - - if (mock) { - setupRefreshSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, subnet); - } - - subnet.refresh(function (err, refreshedSubnet) { - should.not.exist(err); - should.exist(refreshedSubnet); - refreshedSubnet.should.have.property('name', 'my_subnet'); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the subnet.destroy() method should delete a subnet', function (done) { - var subnet = new Subnet(client); - subnet.name = 'model deleted subnet'; - subnet.id = 'THISISANETWORKID'; - - if (mock) { - setupModelDestroyedSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, subnet); - } - - subnet.destroy(function (err) { - should.not.exist(err); - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - - }); -}); - function setupDestroySubnetMock(client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server @@ -517,3 +292,228 @@ function setupGetSubnetMock(client, provider, servers, currentSubnet) { .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } } + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/subnets [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getSubnets() function should return a list of subnets', function(done) { + + if (mock) { + setupSubnetsMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getSubnets(function (err, subnets) { + should.not.exist(err); + should.exist(subnets); + + context.subnets = subnets; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getSubnet() method should get a subnet instance', function (done) { + if (mock) { + setupGetSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + },context.subnets[0]); + } + + client.getSubnet(context.subnets[0].id, function (err, subnet) { + should.not.exist(err); + should.exist(subnet); + subnet.should.be.an.instanceOf(Subnet); + subnet.should.have.property('id', context.subnets[0].id); + context.currentSubnet = subnet; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createSubnet() method should create a subnet', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupCreateSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createSubnet({ + name: 'create-test-ids2' + }, function (err, subnet) { + should.not.exist(err); + should.exist(subnet); + subnet.should.be.an.instanceOf(Subnet); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroySubnet() method should delete a subnet', function (done) { + if (mock) { + setupDestroySubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSubnet); + } + + client.destroySubnet(context.currentSubnet, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroySubnet() method should take an id, delete a subnet', function (done) { + if (mock) { + setupDestroySubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSubnet); + } + + client.destroySubnet(context.currentSubnet.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updateSubnet() method should update a subnet', function (done) { + + var subnetToUpdate = context.currentSubnet; + subnetToUpdate.enableDhcp = false; + + if (mock) { + setupUpdateSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, subnetToUpdate); + } + + client.updateSubnet(subnetToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the subnet.create() method should create a subnet', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupSubnetModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var subnet = new Subnet(client); + subnet.name= 'model created network'; + subnet.create(function (err, createdSubnet) { + should.not.exist(err); + should.exist(createdSubnet); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the subnet.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var subnet = new Subnet(client); + subnet.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; + + if (mock) { + setupRefreshSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, subnet); + } + + subnet.refresh(function (err, refreshedSubnet) { + should.not.exist(err); + should.exist(refreshedSubnet); + refreshedSubnet.should.have.property('name', 'my_subnet'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the subnet.destroy() method should delete a subnet', function (done) { + var subnet = new Subnet(client); + subnet.name = 'model deleted subnet'; + subnet.id = 'THISISANETWORKID'; + + if (mock) { + setupModelDestroyedSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, subnet); + } + + subnet.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 3dbf3daf6..07e71ebd4 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -27,330 +27,515 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].storage; -}).forEach(function (provider) { - describe('pkgcloud/common/storage/base [' + provider + ']', function () { - - var config = null; - - if (!mock && provider === 'google') { - config = { - keyFilename: process.env.GCLOUD_KEYFILE, - projectId: process.env.GCLOUD_PROJECT_ID - }; - } - - var client = helpers.createClient(provider, 'storage', config), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); +function setupCreateContainerMock(provider, client, servers) { + if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } } - ], done); - }); - - it('the createContainer() method should return newly created container', function(done) { + }) + .reply(200, helpers.getRackspaceAuthResponse()); - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); + servers.server + .defaultReplyHeaders(helpers.rackspaceResponseHeaders()) + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } + else if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } } - - setupCreateContainerMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.createContainer('pkgcloud-test-container', function(err, container) { - should.not.exist(err); - should.exist(container); - container.should.be.instanceOf(Container); - - context.container = container; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the getContainers() method should return newly created container', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.getOpenstackAuthResponse()); - setupGetContainersMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.getContainers(function (err, containers) { - should.not.exist(err); - should.exist(containers); - containers.should.be.an.Array; + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } + else if (provider === 'amazon') { + servers.server + .put('/', 'us-west-2') + .reply(200); + } + else if (provider === 'azure') { - containers.forEach(function(container) { - container.should.be.instanceOf(Container); - }); + // Override the clients getUrl method as it tries to prefix the container name onto the request + client._getUrl = function (options) { + options = options || {}; - // TODO Name check - hockInstance && hockInstance.done(); - done(); + return urlJoin('http://localhost:12345/', + (typeof options === 'string' + ? options + : options.path)); + }; - }); - }); + servers.server + .put('/pkgcloud-test-container?restype=container') + .reply(201, '', helpers.azureResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .post('/storage/v1/b?project=test-project', { + name: 'pkgcloud-test-container' + }) + .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); - it('the upload() method with container and filename should succeed', function (done) { + client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + callback(null, reqOpts); + }; - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } + client.storage.connection_.req = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + client.storage.connection_.requester(reqOpts, callback); + }; - setupUploadStreamMock(provider, client, { - server: hockInstance, - authServer: authHockInstance + client.storage.connection_.requester = function (reqOpts, callback) { + if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { + var stream = through(); + stream.on('finish', function () { + fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { + if (err) { + return stream.emit('error', err); + } + stream.emit('complete', { body: JSON.parse(file) }); + }); }); + return stream; } - var stream = client.upload({ - container: context.container, - remote: 'test-file.txt', - headers: {'x-amz-acl': 'public-read'} - }); - - stream.on('error', function(err, response) { - should.not.exist(err); - should.not.exist(response); - done(); - }); - - stream.on('success', function(file) { - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - file.should.be.an.instanceof(File); - - context.file = { - name: 'test-file.txt', - size: Buffer.byteLength(fillerama) - }; - - done(); - }); - - var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); - file.pipe(stream); - }); - - it('the download() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); + return request(reqOpts, callback); + }; + } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.gethpAuthResponse()); - setupDownloadStreamMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } + servers.server + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } +} - var stream = client.download({ - container: context.container, - remote: context.file.name - }); - - context.fileContents = ''; - - stream.on('data', function (data) { - context.fileContents += data; - }); - - stream.on('end', function() { - context.fileContents.should.equal(fillerama); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the getFile() method with container and filename should succeed', function (done) { +function setupGetContainersMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('rackspace/postContainers.json')); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-buckets.xml')); + } + else if (provider === 'azure') { + servers.server + .get('/?comp=list') + .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b?project=test-project') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/postContainers.json')); + } +} - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } +function setupUploadStreamMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .reply(200) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'amazon') { + servers.server + .post('/test-file.txt?uploads') + .reply(200, '\npkgcloud-test-containertest-file.txtU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) + .put('/test-file.txt?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', fillerama) + .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/test-file.txtpkgcloud-test-containertest-file.txt"b2286fe4aac65809a1b7a053d07fc99f-1"') + .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') + .reply(200); - setupGetFileMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } + } + else if (provider === 'azure') { + servers.server + .put('/pkgcloud-test-container/test-file.txt?comp=block&blockid=block000000000000000', fillerama) + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) + .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', 'block000000000000000') + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) + .get('/pkgcloud-test-container/test-file.txt') + .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); + } + else if (provider === 'hp') { + servers.server + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .reply(200) + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } +} - client.getFile(context.container, context.file.name, function (err, file) { - should.not.exist(err); - should.exist(file); +function setupDownloadStreamMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2}); + } + else if (provider === 'amazon') { + servers.server + .get('/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'azure') { + servers.server + .get('/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) + .get('/mediaLink') + .reply(200, fillerama); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2}); + } +} - file.name.should.equal(context.file.name); - file.size.should.equal(context.file.size); +function setupGetFileMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'amazon') { + servers.server + .head('/test-file.txt') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'azure') { + servers.server + .get('/pkgcloud-test-container/test-file.txt') + .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); + } + else if (provider === 'hp') { + servers.server + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } +} - hockInstance && hockInstance.done(); - done(); - }); - }); +function setupGetFilesMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [{ + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + }]); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml')); + } + else if (provider === 'azure') { + servers.server + .get('/pkgcloud-test-container?restype=container&comp=list') + .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [{ + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + }]); + } +} - it('the getFiles() method with container should succeed', function (done) { +function setupRemoveFileMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, ''); + } + else if (provider === 'amazon') { + servers.server + .delete('/test-file.txt') + .reply(204); + } + else if (provider === 'azure') { + servers.server + .delete('/pkgcloud-test-container/test-file.txt') + .reply(202, '', helpers.azureDeleteResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(204, {}); + } + else if (provider === 'hp') { + servers.server + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, ''); + } +} - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); +function setupDestroyContainerMock(provider, client, servers) { + if (provider === 'openstack') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' } + ]) + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } + else if (provider === 'rackspace') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml'), {}) + .delete('/') + .reply(204) + .delete('/test-file.txt') + .reply(204); + } + else if (provider === 'azure') { + servers.server + .delete('/pkgcloud-test-container?restype=container') + .reply(202, '', helpers.azureDeleteResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json') + .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(204, {}) + .delete('/storage/v1/b/pkgcloud-test-container') + .reply(204, {}); + } + else if (provider === 'hp') { + servers.server + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } +} - setupGetFilesMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.getFiles(context.container, null, function (err, files) { - should.not.exist(err); - should.exist(files); - - files.should.be.an.Array; - - files.forEach(function(file) { - file.should.be.instanceOf(File); - }); - - // TODO look for context.file in array - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the removeFile() method with container and filename should succeed', function (done) { +function setupGetContainers2Mock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('rackspace/preContainers.json')); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-buckets2.xml')); + } + else if (provider === 'azure') { + servers.server + .get('/?comp=list') + .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b?project=test-project') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/preContainers.json')); + } +} - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].storage; +}).forEach(function (provider) { + describe('pkgcloud/common/storage/base [' + provider + ']', function () { - setupRemoveFileMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } + var config = null; - client.removeFile(context.container, context.file.name, function (err, ok) { - should.not.exist(err); - should.exist(ok); + if (!mock && provider === 'google') { + config = { + keyFilename: process.env.GCLOUD_KEYFILE, + projectId: process.env.GCLOUD_PROJECT_ID + }; + } - hockInstance && hockInstance.done(); - done(); - }); - }); + var client = helpers.createClient(provider, 'storage', config), + context = {}, + authServer, server, + authHockInstance, hockInstance; - it('the upload() method with large file should succeed', function (done) { + before(function (done) { - if (mock) { + if (!mock) { return done(); - // TODO mock these out } - var stream = client.upload({ - container: context.container, - remote: 'bigfile.raw' - }, function (err, ok) { - should.not.exist(err); - should.exist(ok); + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); - context.file = { - name: 'bigfile.raw', - size: fs.readFileSync(helpers.fixturePath('bigfile.raw')).length - }; + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); - done(); - }); + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); - var file = fs.createReadStream(helpers.fixturePath('bigfile.raw')); - file.pipe(stream); + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); }); - it('the download() method with large file should succeed', function (done) { + it('the createContainer() method should return newly created container', function(done) { if (mock) { - return done(); - // TODO mock these out - } + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } - var stream = client.download({ - container: context.container, - remote: context.file.name - }, function (err, file) { + setupCreateContainerMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + client.createContainer('pkgcloud-test-container', function(err, container) { should.not.exist(err); - should.exist(file); - file.should.be.instanceOf(File); - - file.name.should.equal(context.file.name); - file.size.should.equal(context.fileContentsSize); - - context.fileContents = Buffer.concat(context.fileContents, - file.size); + should.exist(container); + container.should.be.instanceOf(Container); - // Compare byte by byte - var original = fs.readFileSync(helpers.fixturePath('bigfile.raw')); - for (var i = 0; i < file.size; i++) { - assert.equal(context.fileContents[i], original[i]); - } + context.container = container; + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); done(); - }); - context.fileContents = []; - context.fileContentsSize = 0; - stream.on('data', function (data) { - context.fileContents.push(data); - context.fileContentsSize += data.length; }); - stream.end(); }); - it('the destroyContainer() method with container should succeed', function (done) { + it('the getContainers() method should return newly created container', function (done) { if (mock) { if (provider === 'joyent') { @@ -358,22 +543,29 @@ providers.filter(function (provider) { return done(); } - setupDestroyContainerMock(provider, client, { + setupGetContainersMock(provider, client, { server: hockInstance, authServer: authHockInstance }); } - client.destroyContainer(context.container, function (err, ok) { + client.getContainers(function (err, containers) { should.not.exist(err); - should.exist(ok); + should.exist(containers); + containers.should.be.an.Array; + containers.forEach(function(container) { + container.should.be.instanceOf(Container); + }); + + // TODO Name check hockInstance && hockInstance.done(); done(); + }); }); - it('the getContainers() method should succeed', function (done) { + it('the upload() method with container and filename should succeed', function (done) { if (mock) { if (provider === 'joyent') { @@ -381,470 +573,278 @@ providers.filter(function (provider) { return done(); } - setupGetContainers2Mock(provider, client, { + setupUploadStreamMock(provider, client, { server: hockInstance, authServer: authHockInstance }); } - client.getContainers(function (err, ok) { + var stream = client.upload({ + container: context.container, + remote: 'test-file.txt', + headers: {'x-amz-acl': 'public-read'} + }); + + stream.on('error', function(err, response) { should.not.exist(err); - should.exist(ok); + should.not.exist(response); + done(); + }); + stream.on('success', function(file) { + authHockInstance && authHockInstance.done(); hockInstance && hockInstance.done(); + file.should.be.an.instanceof(File); + + context.file = { + name: 'test-file.txt', + size: Buffer.byteLength(fillerama) + }; + done(); }); - }); - after(function (done) { - if (!mock) { - return done(); - } + var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); + file.pipe(stream); + }); - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); + it('the download() method with container and filename should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); } - ], done); + + setupDownloadStreamMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + var stream = client.download({ + container: context.container, + remote: context.file.name + }); + + context.fileContents = ''; + + stream.on('data', function (data) { + context.fileContents += data; + }); + + stream.on('end', function() { + context.fileContents.should.equal(fillerama); + hockInstance && hockInstance.done(); + done(); + }); }); - }); -}); -function setupCreateContainerMock(provider, client, servers) { - if (provider === 'rackspace') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - 'RAX-KSKEY:apiKeyCredentials': { - username: 'MOCK-USERNAME', - apiKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, helpers.getRackspaceAuthResponse()); + it('the getFile() method with container and filename should succeed', function (done) { - servers.server - .defaultReplyHeaders(helpers.rackspaceResponseHeaders()) - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(201); - } - else if (provider === 'openstack') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } - } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers.getOpenstackAuthResponse()); - servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(201); - } - else if (provider === 'amazon') { - servers.server - .put('/', 'us-west-2') - .reply(200); - } - else if (provider === 'azure') { + setupGetFileMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } - // Override the clients getUrl method as it tries to prefix the container name onto the request - client._getUrl = function (options) { - options = options || {}; + client.getFile(context.container, context.file.name, function (err, file) { + should.not.exist(err); + should.exist(file); - return urlJoin('http://localhost:12345/', - (typeof options === 'string' - ? options - : options.path)); - }; + file.name.should.equal(context.file.name); + file.size.should.equal(context.file.size); - servers.server - .put('/pkgcloud-test-container?restype=container') - .reply(201, '', helpers.azureResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .post('/storage/v1/b?project=test-project', { - name: 'pkgcloud-test-container' - }) - .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); + hockInstance && hockInstance.done(); + done(); + }); + }); - client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { - reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - callback(null, reqOpts); - }; + it('the getFiles() method with container should succeed', function (done) { - client.storage.connection_.req = function (reqOpts, callback) { - reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - client.storage.connection_.requester(reqOpts, callback); - }; + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } - client.storage.connection_.requester = function (reqOpts, callback) { - if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { - var stream = through(); - stream.on('finish', function () { - fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { - if (err) { - return stream.emit('error', err); - } - stream.emit('complete', { body: JSON.parse(file) }); - }); + setupGetFilesMock(provider, client, { + server: hockInstance, + authServer: authHockInstance }); - return stream; } - return request(reqOpts, callback); - }; - } - else if (provider === 'hp') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - apiAccessKeyCredentials: { - accessKey: 'MOCK-USERNAME', - secretKey: 'MOCK-API-KEY' - } - } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') - .post('/v2.0/tokens', { - auth: { - apiAccessKeyCredentials: { - accessKey: 'MOCK-USERNAME', - secretKey: 'MOCK-API-KEY' - }, - tenantId: '5ACED3DC3AA740ABAA41711243CC6949' - } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers.gethpAuthResponse()); + client.getFiles(context.container, null, function (err, files) { + should.not.exist(err); + should.exist(files); - servers.server - .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(201); - } -} + files.should.be.an.Array; -function setupGetContainersMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('rackspace/postContainers.json')); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-buckets.xml')); - } - else if (provider === 'azure') { - servers.server - .get('/?comp=list') - .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b?project=test-project') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('hp/postContainers.json')); - } -} + files.forEach(function(file) { + file.should.be.instanceOf(File); + }); -function setupUploadStreamMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) - .reply(200) - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'amazon') { - servers.server - .post('/test-file.txt?uploads') - .reply(200, '\npkgcloud-test-containertest-file.txtU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) - .put('/test-file.txt?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', fillerama) - .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/test-file.txtpkgcloud-test-containertest-file.txt"b2286fe4aac65809a1b7a053d07fc99f-1"') - .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') - .reply(200); + // TODO look for context.file in array - } - else if (provider === 'azure') { - servers.server - .put('/pkgcloud-test-container/test-file.txt?comp=block&blockid=block000000000000000', fillerama) - .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) - .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', 'block000000000000000') - .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) - .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); - } - else if (provider === 'hp') { - servers.server - .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) - .reply(200) - .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } -} + hockInstance && hockInstance.done(); + done(); + }); + }); -function setupDownloadStreamMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2}); - } - else if (provider === 'amazon') { - servers.server - .get('/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'azure') { - servers.server - .get('/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) - .get('/mediaLink') - .reply(200, fillerama); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2}); - } -} + it('the removeFile() method with container and filename should succeed', function (done) { -function setupGetFileMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'amazon') { - servers.server - .head('/test-file.txt') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'azure') { - servers.server - .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); - } - else if (provider === 'hp') { - servers.server - .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } -} + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } -function setupGetFilesMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') - .reply(200, [{ - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' - }]); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml')); - } - else if (provider === 'azure') { - servers.server - .get('/pkgcloud-test-container?restype=container&comp=list') - .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') - .reply(200, [{ - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' - }]); - } -} + setupRemoveFileMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } -function setupRemoveFileMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, ''); - } - else if (provider === 'amazon') { - servers.server - .delete('/test-file.txt') - .reply(204); - } - else if (provider === 'azure') { - servers.server - .delete('/pkgcloud-test-container/test-file.txt') - .reply(202, '', helpers.azureDeleteResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .reply(204, {}); - } - else if (provider === 'hp') { - servers.server - .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, ''); - } -} + client.removeFile(context.container, context.file.name, function (err, ok) { + should.not.exist(err); + should.exist(ok); -function setupDestroyContainerMock(provider, client, servers) { - if (provider === 'openstack') { - servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') - .reply(200, [ - { - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the upload() method with large file should succeed', function (done) { + + if (mock) { + return done(); + // TODO mock these out + } + + var stream = client.upload({ + container: context.container, + remote: 'bigfile.raw' + }, function (err, ok) { + should.not.exist(err); + should.exist(ok); + + context.file = { + name: 'bigfile.raw', + size: fs.readFileSync(helpers.fixturePath('bigfile.raw')).length + }; + + done(); + }); + + var file = fs.createReadStream(helpers.fixturePath('bigfile.raw')); + file.pipe(stream); + }); + + it('the download() method with large file should succeed', function (done) { + + if (mock) { + return done(); + // TODO mock these out + } + + var stream = client.download({ + container: context.container, + remote: context.file.name + }, function (err, file) { + + should.not.exist(err); + should.exist(file); + file.should.be.instanceOf(File); + + file.name.should.equal(context.file.name); + file.size.should.equal(context.fileContentsSize); + + context.fileContents = Buffer.concat(context.fileContents, + file.size); + + // Compare byte by byte + var original = fs.readFileSync(helpers.fixturePath('bigfile.raw')); + for (var i = 0; i < file.size; i++) { + assert.equal(context.fileContents[i], original[i]); } - ]) - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, '') - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(204); - } - else if (provider === 'rackspace') { - servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') - .reply(200, [ - { - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' + + done(); + }); + + context.fileContents = []; + context.fileContentsSize = 0; + stream.on('data', function (data) { + context.fileContents.push(data); + context.fileContentsSize += data.length; + }); + stream.end(); + }); + + it('the destroyContainer() method with container should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); } - ]) - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, '') - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(204); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml'), {}) - .delete('/') - .reply(204) - .delete('/test-file.txt') - .reply(204); - } - else if (provider === 'azure') { - servers.server - .delete('/pkgcloud-test-container?restype=container') - .reply(202, '', helpers.azureDeleteResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json') - .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .reply(204, {}) - .delete('/storage/v1/b/pkgcloud-test-container') - .reply(204, {}); - } - else if (provider === 'hp') { - servers.server - .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') - .reply(200, [ - { - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' + + setupDestroyContainerMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + client.destroyContainer(context.container, function (err, ok) { + should.not.exist(err); + should.exist(ok); + + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the getContainers() method should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); } - ]) - .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, '') - .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(204); - } -} -function setupGetContainers2Mock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('rackspace/preContainers.json')); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-buckets2.xml')); - } - else if (provider === 'azure') { - servers.server - .get('/?comp=list') - .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b?project=test-project') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('hp/preContainers.json')); - } -} + setupGetContainers2Mock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + client.getContainers(function (err, ok) { + should.not.exist(err); + should.exist(ok); + + hockInstance && hockInstance.done(); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + }); +}); diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index 46092d646..ba3c16bf4 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -25,93 +25,6 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].storage; -}).forEach(function (provider) { - describe('pkgcloud/common/storage/base [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'storage'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the client.upload stream should emit error', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupUploadStreamError(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - var stream = client.upload({ - container: 'pkgcloud-test-container', - remote: 'test-file.txt' - }); - - stream.on('error', function (err) { - should.exist(err); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - - stream.on('success', function (file) { - should.not.exist(file); - done(); - }); - - stream.end('foo'); - }); - - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - }); -}); - function setupUploadStreamError(provider, client, servers) { if (provider === 'rackspace') { servers.authServer @@ -207,3 +120,90 @@ function setupUploadStreamError(provider, client, servers) { .reply(400); } } + +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].storage; +}).forEach(function (provider) { + describe('pkgcloud/common/storage/base [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'storage'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the client.upload stream should emit error', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupUploadStreamError(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + var stream = client.upload({ + container: 'pkgcloud-test-container', + remote: 'test-file.txt' + }); + + stream.on('error', function (err) { + should.exist(err); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + + stream.on('success', function (file) { + should.not.exist(file); + done(); + }); + + stream.end('foo'); + }); + + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + }); +}); diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index 8fd5c1bab..bad506a67 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -28,6 +28,29 @@ var azureApi = require('../../lib/pkgcloud/azure/utils/azureApi'), PATH = require('path'), helpers; +/** + * serverStatusReply() + * fills in the nock xml reply from the server with server name and status + * @param name - name of the server + * @param status - status to be returned in reply + * status should be: + * ReadyRole - server is RUNNING + * VMStopped - server is still PROVISIONING + * Provisioning - server is still PROVISIONING + * see lib/pkgcloud/azure/compute/server.js for more status values + * + * @param helpers - test helper object + * @return {String} - the xml reply containing the server name and status + */ +var serverStatusReply = function (name, status) { + + var template = helpers.loadFixture('azure/server-status-template.xml'), + params = {NAME: name, STATUS: status}; + + var result = _.template(template, params); + return result; +}; + exports.serverTest = function (nock, testHelpers) { helpers = testHelpers; @@ -175,28 +198,6 @@ exports.serverTest = function (nock, testHelpers) { .reply(200,helpers.loadFixture('azure/operation-succeeded.xml'),{}); }; -/** - * serverStatusReply() - * fills in the nock xml reply from the server with server name and status - * @param name - name of the server - * @param status - status to be returned in reply - * status should be: - * ReadyRole - server is RUNNING - * VMStopped - server is still PROVISIONING - * Provisioning - server is still PROVISIONING - * see lib/pkgcloud/azure/compute/server.js for more status values - * - * @param helpers - test helper object - * @return {String} - the xml reply containing the server name and status - */ -var serverStatusReply = function (name, status) { - - var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; - - var result = _.template(template, params); - return result; -}; var filterPath = function (path) { var name = PATH.basename(path); @@ -206,5 +207,3 @@ var filterPath = function (path) { return path; }; - - diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js index 1919133ae..ba2a7cf7b 100644 --- a/test/iriscouch/databases/databases-redis-test.js +++ b/test/iriscouch/databases/databases-redis-test.js @@ -12,6 +12,16 @@ var helpers = require('../../helpers'), http = require('http'), mock = !!process.env.MOCK; +// +// Just a quick and lazy random password generator +// +function randomPassword(length) { + if (length == 1) { + return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48); + } + return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48) + randomPassword(length - 1); +} + describe('pkgcloud/iriscouch/databases-redis', function () { var context = {}, client, hockInstance, server; @@ -120,13 +130,3 @@ describe('pkgcloud/iriscouch/databases-redis', function () { }); }); - -// -// Just a quick and lazy random password generator -// -function randomPassword(length) { - if (length == 1) { - return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48); - } - return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48) + randomPassword(length - 1); -} \ No newline at end of file diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js index ec6d5f52c..cfbd1ff87 100644 --- a/test/rackspace/databases/user-limit-test.js +++ b/test/rackspace/databases/user-limit-test.js @@ -14,119 +14,6 @@ var should = require('should'), User = require('../../../lib/pkgcloud/openstack/database/user').User, mock = !!process.env.MOCK; - describe.skip('pkgcloud/[rackspace]/databases/users/limits', function () { - var testContext = {}, - client, authHockInstance, hockInstance, authServer, - server, err, list, offset; - - before(function (done) { - client = helpers.createClient('rackspace', 'database'); - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - - if (mock) { - setupAuthenticationMock(authHockInstance); - setupGetUsersMock(hockInstance); - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') - .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance, limit: 1 }, function (e, l, o) { - err = e; - list = l; - offset = o; - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with limit should respond with one element', function () { - should.not.exist(err); - should.exist(list); - list.should.have.length(1); - }); - - it('with limitshould pass as third argument the offset mark', function () { - should.exist(offset); - testContext.marker = offset; - }); - - it('with offset should respond less quantity', function (done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?marker=joeTest') - .reply(200, { - users: [ - { name: 'joeTestTwo', databases: []}, - { name: 'joeTestThree', databases: []} - ] - }); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance, offset: testContext.marker }, function (err, list, offset) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.should.have.length(2); - should.not.exist(offset); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with limit and offset should responsd with just result with more next points', function(done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1&marker=joeTest') - .reply(200, helpers.loadFixture('rackspace/databaseUsersLimitOffset.json')); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ - instance: instance, - limit: 1, - offset:testContext.marker }, function(err, list, offset) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.should.have.length(1); - should.exist(offset); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - function setupGetUsersMock(hockInstance) { hockInstance .get('/v1.0/123456/instances') @@ -147,3 +34,116 @@ function setupAuthenticationMock (authHockInstance) { }) .reply(200, helpers.getRackspaceAuthResponse()); } + +describe.skip('pkgcloud/[rackspace]/databases/users/limits', function () { + var testContext = {}, + client, authHockInstance, hockInstance, authServer, + server, err, list, offset; + + before(function (done) { + client = helpers.createClient('rackspace', 'database'); + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + + if (mock) { + setupAuthenticationMock(authHockInstance); + setupGetUsersMock(hockInstance); + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') + .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance, limit: 1 }, function (e, l, o) { + err = e; + list = l; + offset = o; + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with limit should respond with one element', function () { + should.not.exist(err); + should.exist(list); + list.should.have.length(1); + }); + + it('with limitshould pass as third argument the offset mark', function () { + should.exist(offset); + testContext.marker = offset; + }); + + it('with offset should respond less quantity', function (done) { + + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?marker=joeTest') + .reply(200, { + users: [ + { name: 'joeTestTwo', databases: []}, + { name: 'joeTestThree', databases: []} + ] + }); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance, offset: testContext.marker }, function (err, list, offset) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.should.have.length(2); + should.not.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with limit and offset should responsd with just result with more next points', function(done) { + + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1&marker=joeTest') + .reply(200, helpers.loadFixture('rackspace/databaseUsersLimitOffset.json')); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ + instance: instance, + limit: 1, + offset:testContext.marker }, function(err, list, offset) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.should.have.length(1); + should.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); +}); From e4f88de1c294a04a313c35573779e45a340c405e Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Dec 2014 11:49:16 -0800 Subject: [PATCH 272/460] Reverting changes to test code per review with @kenperkins. --- .../azure/compute/client/test-createServer.js | 4 +- .../azure/compute/client/test-rebootServer.js | 4 +- test/common/compute/base-test.js | 378 ++--- test/common/compute/meta-test.js | 84 +- test/common/compute/server-test.js | 446 +++--- test/common/databases/databases-test.js | 382 +++--- test/common/databases/flavor-test.js | 37 +- test/common/databases/instances-test.js | 788 ++++++----- test/common/databases/users-test.js | 1219 ++++++++--------- test/common/network/network-test.js | 446 +++--- test/common/network/port-test.js | 450 +++--- test/common/network/subnet-test.js | 450 +++--- test/common/storage/base-test.js | 1128 +++++++-------- test/common/storage/upload-test.js | 174 +-- test/helpers/azureNock.js | 47 +- .../databases/databases-redis-test.js | 20 +- test/rackspace/databases/user-limit-test.js | 226 +-- 17 files changed, 3140 insertions(+), 3143 deletions(-) diff --git a/test/azure/compute/client/test-createServer.js b/test/azure/compute/client/test-createServer.js index 4f121723f..54529bc22 100644 --- a/test/azure/compute/client/test-createServer.js +++ b/test/azure/compute/client/test-createServer.js @@ -13,8 +13,6 @@ var fs = require('fs'), azureNock = require('../../../helpers/azureNock'), nock = require('nock'); -var testContext = {}; - var options = { name: 'create-test-ids2', flavor: 'ExtraSmall', @@ -94,6 +92,8 @@ function testSetWait(client) { var client = helpers.createClient('azure', 'compute'); +var testContext = {}; + if (process.env.MOCK) { azureNock.serverTest(nock, helpers); } diff --git a/test/azure/compute/client/test-rebootServer.js b/test/azure/compute/client/test-rebootServer.js index acacfbaf5..b20235af2 100644 --- a/test/azure/compute/client/test-rebootServer.js +++ b/test/azure/compute/client/test-rebootServer.js @@ -19,8 +19,6 @@ var options = { image: 'CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd' }; -var testContext = {}; - function testCreateServer(client) { var name = 'azure', test = {}; @@ -107,6 +105,8 @@ function testRebootServer(client) { var client = helpers.createClient('azure', 'compute'); +var testContext = {}; + if (process.env.MOCK) { azureNock.serverTest(nock, helpers); } diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index b5981e935..a7b4172a8 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -28,6 +28,195 @@ var azureOptions = require('../../fixtures/azure/azure-options.json'); azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function(provider) { + describe('pkgcloud/common/compute/base [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'compute'), + context = {}, + authServer, server, + authHockInstance, + hockInstance; + + before(function(done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function(next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getVersion() method with no arguments should return the version', function (done) { + if (mock) { + var errors = setupVersionMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + if (errors) { + client.getVersion(function (err) { + err.should.be.an.instanceof(Error); + done(); + }); + } + else { + client.getVersion(function (err, version) { + should.not.exist(err); + should.exist(version); + version.should.equal(versions[provider]); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + } + }); + + it('the getFlavors() method should return a list of flavors', function(done) { + if (mock) { + setupFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getFlavors(function (err, flavors) { + should.not.exist(err); + should.exist(flavors); + + flavors.forEach(function (flavor) { + flavor.should.be.instanceOf(Flavor); + }); + + context.flavors = flavors; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getImages() method should return a list of images', function (done) { + if (mock) { + setupImagesMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getImages(function (err, images) { + should.not.exist(err); + should.exist(images); + + images.forEach(function (image) { + image.should.be.instanceOf(Image); + }); + + context.images = images; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the setWait() method waiting for a server to be operational should return a running server', function (done) { + var m = mock ? 0.1 : 100; + + if (mock) { + setupServerMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createServer(_.extend({ + name: 'create-test-setWait', + image: context.images[0].id, + flavor: context.flavors[0].id + }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + + srv1.setWait({ status: srv1.STATUS.running }, 100 * m, 1000, function (err, srv2) { + should.not.exist(err); + should.exist(srv2); + srv2.should.be.instanceOf(Server); + srv2.name.should.equal('create-test-setWait'); + srv2.status.should.equal(srv2.STATUS.running); + context.server = srv2; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + }); + + it('the setWait() method waiting for a server to be operational should return a running server', function (done) { + // TODO enable destroy tests for all providers + if (provider === 'joyent' || provider === 'amazon' || provider === 'azure') { + done(); + return; + } + + if (mock) { + setupDestroyMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.destroyServer(context.server, function (err, result) { + should.not.exist(err); + should.exist(result); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + after(function(done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + }); +}); + function setupVersionMock(client, provider, servers) { if (provider === 'digitalocean') { return true; @@ -396,192 +585,3 @@ function setupDestroyMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/destroy-server.json'); } } - -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].compute; -}).forEach(function(provider) { - describe('pkgcloud/common/compute/base [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'compute'), - context = {}, - authServer, server, - authHockInstance, - hockInstance; - - before(function(done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function(next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getVersion() method with no arguments should return the version', function (done) { - if (mock) { - var errors = setupVersionMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - if (errors) { - client.getVersion(function (err) { - err.should.be.an.instanceof(Error); - done(); - }); - } - else { - client.getVersion(function (err, version) { - should.not.exist(err); - should.exist(version); - version.should.equal(versions[provider]); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - } - }); - - it('the getFlavors() method should return a list of flavors', function(done) { - if (mock) { - setupFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getFlavors(function (err, flavors) { - should.not.exist(err); - should.exist(flavors); - - flavors.forEach(function (flavor) { - flavor.should.be.instanceOf(Flavor); - }); - - context.flavors = flavors; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getImages() method should return a list of images', function (done) { - if (mock) { - setupImagesMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getImages(function (err, images) { - should.not.exist(err); - should.exist(images); - - images.forEach(function (image) { - image.should.be.instanceOf(Image); - }); - - context.images = images; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the setWait() method waiting for a server to be operational should return a running server', function (done) { - var m = mock ? 0.1 : 100; - - if (mock) { - setupServerMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createServer(_.extend({ - name: 'create-test-setWait', - image: context.images[0].id, - flavor: context.flavors[0].id - }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { - should.not.exist(err); - should.exist(srv1); - - srv1.setWait({ status: srv1.STATUS.running }, 100 * m, 1000, function (err, srv2) { - should.not.exist(err); - should.exist(srv2); - srv2.should.be.instanceOf(Server); - srv2.name.should.equal('create-test-setWait'); - srv2.status.should.equal(srv2.STATUS.running); - context.server = srv2; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - }); - - it('the setWait() method waiting for a server to be operational should return a running server', function (done) { - // TODO enable destroy tests for all providers - if (provider === 'joyent' || provider === 'amazon' || provider === 'azure') { - done(); - return; - } - - if (mock) { - setupDestroyMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.destroyServer(context.server, function (err, result) { - should.not.exist(err); - should.exist(result); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - after(function(done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - authServer.close(next); - }, - function (next) { - server.close(next); - } - ], done); - }); - }); -}); diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index d87c3302a..c1981371b 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -18,48 +18,6 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; -function setupMetaMock(client, provider, servers) { - if (provider === 'openstack') { - servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata', - { metadata: { - os_type :'windows' - }}) - .replyWithFile(202, __dirname + '/../../fixtures/openstack/metaResponse.json'); - } -} - -function setupImagesMock(client, provider, servers) { - if (provider === 'openstack') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } - } - }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' - } - }) - .reply(200, helpers.getOpenstackAuthResponse()); - - servers.server - .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); - } -} - var providers=['openstack']; providers.filter(function (provider) { @@ -165,3 +123,45 @@ providers.filter(function (provider) { }); }); + +function setupMetaMock(client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata', + { metadata: { + os_type :'windows' + }}) + .replyWithFile(202, __dirname + '/../../fixtures/openstack/metaResponse.json'); + } +} + +function setupImagesMock(client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); + } +} diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 68187315f..341c86c12 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -27,27 +27,209 @@ var azureOptions = require('../../fixtures/azure/azure-options.json'); azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); -/** - * serverStatusReply() - * fills in the nock xml reply from the server with server name and status - * @param name - name of the server - * @param status - status to be returned in reply - * status should be: - * ReadyRole - server is RUNNING - * VMStopped - server is still PROVISIONING - * Provisioning - server is still PROVISIONING - * see lib/pkgcloud/azure/compute/server.js for more status values - * - * @return {String} - the xml reply containing the server name and status - */ -var serverStatusReply = function (name, status) { +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].compute; +}).forEach(function (provider) { + describe('pkgcloud/common/compute/server [' + provider + ']', function () { - var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; + var client = helpers.createClient(provider, 'compute'), + context = {}, + authServer, server, + authHockInstance, + hockInstance; - var result = _.template(template, params); - return result; -}; + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getImages() function should return a list of images', function(done) { + + if (mock) { + setupImagesMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getImages(function (err, images) { + should.not.exist(err); + should.exist(images); + + context.images = images; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getFlavors() function should return a list of flavors', function (done) { + + if (mock) { + setupFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getFlavors(function (err, flavors) { + should.not.exist(err); + should.exist(flavors); + + context.flavors = flavors; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the createServer() method with image and flavor should create a server', function (done) { + var m = mock ? .1 : 10; + + if (mock) { + setupServerMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createServer(_.extend({ + name: 'create-test-ids2', + image: context.images[0].id, + flavor: context.flavors[0].id + }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + + srv1.setWait({ status: srv1.STATUS.running }, 100 * m, function (err, srv2) { + should.not.exist(err); + should.exist(srv2); + srv2.should.be.instanceOf(Server); + srv2.name.should.equal('create-test-ids2'); + srv2.imageId.should.equal(context.images[0].id); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the getServers() method should return a list of servers', function (done) { + if (mock) { + setupGetServersMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getServers(function (err, servers) { + should.not.exist(err); + should.exist(servers); + + servers.should.be.an.Array; + + servers.forEach(function(srv) { + srv.should.be.instanceOf(Server); + }); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it.skip('the getServer() method should get a server instance', function (done) { + if (mock) { + setupGetServerMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getServer(context.servers[0].id, function (err, srv) { + should.not.exist(err); + should.exist(srv); + + srv.should.be.instanceOf(Server); + + context.currentServer = hockInstance; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it.skip('the server.rebootServer() method should restart a server instance', function (done) { + if (mock) { + setupRebootMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + context.currentServer.reboot(function(err) { + done(); + }); + }); + + it.skip('the destroyServer() method should delete a server instance', function (done) { + if (mock) { + setupRebootMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + context.currentServer.reboot(function (err) { + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + authServer.close(next); + }, + function (next) { + server.close(next); + } + ], done); + }); + + }); +}); function setupImagesMock(client, provider, servers) { if (provider === 'rackspace') { @@ -396,211 +578,6 @@ function setupGetServerMock(client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } } - -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].compute; -}).forEach(function (provider) { - describe('pkgcloud/common/compute/server [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'compute'), - context = {}, - authServer, server, - authHockInstance, - hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/ec2\.us-west-2\.amazonaws\.com([?\w\-\.\_0-9\/]*)/g, '$1'); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getImages() function should return a list of images', function(done) { - - if (mock) { - setupImagesMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getImages(function (err, images) { - should.not.exist(err); - should.exist(images); - - context.images = images; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getFlavors() function should return a list of flavors', function (done) { - - if (mock) { - setupFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getFlavors(function (err, flavors) { - should.not.exist(err); - should.exist(flavors); - - context.flavors = flavors; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the createServer() method with image and flavor should create a server', function (done) { - var m = mock ? .1 : 10; - - if (mock) { - setupServerMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createServer(_.extend({ - name: 'create-test-ids2', - image: context.images[0].id, - flavor: context.flavors[0].id - }, provider === 'azure' ? azureOptions : {}), function (err, srv1) { - should.not.exist(err); - should.exist(srv1); - - srv1.setWait({ status: srv1.STATUS.running }, 100 * m, function (err, srv2) { - should.not.exist(err); - should.exist(srv2); - srv2.should.be.instanceOf(Server); - srv2.name.should.equal('create-test-ids2'); - srv2.imageId.should.equal(context.images[0].id); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('the getServers() method should return a list of servers', function (done) { - if (mock) { - setupGetServersMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getServers(function (err, servers) { - should.not.exist(err); - should.exist(servers); - - servers.should.be.an.Array; - - servers.forEach(function(srv) { - srv.should.be.instanceOf(Server); - }); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it.skip('the getServer() method should get a server instance', function (done) { - if (mock) { - setupGetServerMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getServer(context.servers[0].id, function (err, srv) { - should.not.exist(err); - should.exist(srv); - - srv.should.be.instanceOf(Server); - - context.currentServer = hockInstance; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it.skip('the server.rebootServer() method should restart a server instance', function (done) { - if (mock) { - setupRebootMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - context.currentServer.reboot(function(err) { - done(); - }); - }); - - it.skip('the destroyServer() method should delete a server instance', function (done) { - if (mock) { - setupRebootMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - context.currentServer.reboot(function (err) { - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - authServer.close(next); - }, - function (next) { - server.close(next); - } - ], done); - }); - - }); -}); - // //function batchThree(providerClient, providerName) { // var name = providerName || 'rackspace', @@ -958,6 +935,27 @@ providers.filter(function (provider) { // .export(module) // ; // });z +/** + * serverStatusReply() + * fills in the nock xml reply from the server with server name and status + * @param name - name of the server + * @param status - status to be returned in reply + * status should be: + * ReadyRole - server is RUNNING + * VMStopped - server is still PROVISIONING + * Provisioning - server is still PROVISIONING + * see lib/pkgcloud/azure/compute/server.js for more status values + * + * @return {String} - the xml reply containing the server name and status + */ +var serverStatusReply = function (name, status) { + + var template = helpers.loadFixture('azure/server-status-template.xml'), + params = {NAME: name, STATUS: status}; + + var result = _.template(template, params); + return result; +}; var filterPath = function (path) { var name = PATH.basename(path); diff --git a/test/common/databases/databases-test.js b/test/common/databases/databases-test.js index 4d6156942..457bfd846 100644 --- a/test/common/databases/databases-test.js +++ b/test/common/databases/databases-test.js @@ -13,197 +13,6 @@ var should = require('should'), providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; -function setupCreateDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabase' } - ] - }) - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabase' } - ] - }) - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabase' } - ] - }) - .reply(202); - } -} - -function setupCreateDatabasesForPaginationMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseTwo' } - ] - }) - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseTwo' } - ] - }) - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseTwo' } - ] - }) - .reply(202); - } -} - -function setupModelCreateDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseThree' } - ] - }) - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseThree' } - ] - }) - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', - { - databases: [ - { name: 'TestDatabaseThree' } - ] - }) - .reply(202); - } -} - - - -function setupGetDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') - .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); - } -} - -function setupDestroyDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') - .reply(202); - } -} - -function setupDestroyLastDatabasesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') - .reply(202); - } - else if (provider ==='openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') - .reply(202); - } - else if (provider ==='hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') - .reply(202); - } -} - providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { @@ -502,3 +311,194 @@ providers.filter(function (provider) { }); }); }); + +function setupCreateDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabase' } + ] + }) + .reply(202); + } +} + +function setupCreateDatabasesForPaginationMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseTwo' } + ] + }) + .reply(202); + } +} + +function setupModelCreateDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases', + { + databases: [ + { name: 'TestDatabaseThree' } + ] + }) + .reply(202); + } +} + + + +function setupGetDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') + .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); + } +} + +function setupDestroyDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') + .reply(202); + } +} + +function setupDestroyLastDatabasesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } + else if (provider ==='openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } + else if (provider ==='hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') + .reply(202); + } +} diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index 713004152..71efb4d9c 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -14,24 +14,6 @@ var should = require('should'), providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; -function setupGetFlavorMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/3') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor3.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/3') - .reply(200, helpers.loadFixture('openstack/databaseFlavor3.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/3') - .reply(200, helpers.loadFixture('hp/databaseFlavor3.json')); - } -} - providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { @@ -157,3 +139,22 @@ providers.filter(function (provider) { } } }); + + +function setupGetFlavorMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/3') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor3.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/3') + .reply(200, helpers.loadFixture('openstack/databaseFlavor3.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/3') + .reply(200, helpers.loadFixture('hp/databaseFlavor3.json')); + } +} diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index 6e3b5e624..cc5efd37e 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -14,288 +14,6 @@ var should = require('should'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, Instance = require('../../../lib/pkgcloud/openstack/database/instance').Instance, mock = !!process.env.MOCK; - -function assertLinks(links) { - links.should.be.an.Array; - links.forEach(function (link) { - should.exist(link.href); - should.exist(link.rel); - }); -} - -function setupCreateInstanceMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/1') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) - .post('/v1.0/123456/instances', { - instance: { - name: 'test-instance', - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], - volume: { - size:1 - } - } - }) - .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') - .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances', { - instance: { - name: 'test-instance', - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], - volume: { - size:1 - } - } - }) - .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') - .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances', { - instance: { - name: 'test-instance', - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], - volume: { - size:1 - } - } - }) - .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); - } -} - -function setupGetInstancesMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')); - } -} - -function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances?limit=2') - .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances?limit=2') - .reply(200, helpers.loadFixture('openstack/databaseInstancesLimit2.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances?limit=2') - .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')); - } -} - -function setupDestroyInstanceMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(202); - } -} - -function setGetInstanceMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(200, helpers.loadFixture('rackspace/databaseInstance.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(200, helpers.loadFixture('openstack/databaseInstance.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') - .reply(200, helpers.loadFixture('hp/databaseInstance.json')); - } -} - -function setGetFlavorsMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/2') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') - .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') - .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')); - } -} - -function setupSetFlavorMock(hockInstance, provider) { - if (provider ==='rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/flavors/2') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' - } - }) - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') - .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' - } - }) - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') - .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' - } - }) - .reply(202); - } -} - -function setupResizeMock (hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - volume :{ - size :2 - } - } - }) - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - volume :{ - size :2 - } - } - }) - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { - resize: { - volume :{ - size :2 - } - } - }) - .reply(202); - } -} - -function setupGetOneFlavorMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors/1') - .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') - .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') - .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')); - } -} - -function setupRestartInstanceMock (hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) - .reply(202); - } -} - providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { @@ -620,126 +338,406 @@ providers.filter(function (provider) { }); }); - it('without size parameter should get errors', function (done) { + it('without size parameter should get errors', function (done) { + + if (mock) { + setupGetInstancesMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.setVolumeSize(instance, function (err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('without invalid size parameter should get errors', function (done) { + + if (mock) { + setupGetInstancesMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.setVolumeSize(instance, 12, function (err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with correct inputs should respond correctly', function (done) { + + if (mock) { + setupResizeMock (hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + var newSize = (Number(instance.volume.size) === 8) ? 1 : Number(instance.volume.size) + 1; + + client.setVolumeSize(instance, newSize, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + describe('the create() method with errors', function () { + it('should respond with errors', function (done) { + client.createInstance(function(err) { + should.exist(err); + done(); + }); + }); + + it('without flavor should respond with errors', function (done) { + client.createInstance({ name: 'test-without-flavor' }, function (err) { + should.exist(err); + done(); + }); + }); + + it('with invalid size should respond with errors', function (done) { + if (mock) { + setupGetOneFlavorMock(hockInstance, provider); + } + + client.getFlavor(1, function (err, flavor) { + client.createInstance({ + name: 'test-instance', + flavor: flavor, + size: '1' + }, function(err) { + should.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + describe('the restartInstance() method', function () { + it('with no instance should return error', function (done) { + client.restartInstance(function (err) { + should.exist(err); + done(); + }); + }); + + it('with valid instance should restart', function (done) { + if (mock) { + setupRestartInstanceMock (hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.restartInstance(instance, function (err) { + should.not.exist(err); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + }); + }); + +}); +function assertLinks(links) { + links.should.be.an.Array; + links.forEach(function (link) { + should.exist(link.href); + should.exist(link.rel); + }); +} + +function setupCreateInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/1') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')) + .post('/v1.0/123456/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') + .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') + .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances', { + instance: { + name: 'test-instance', + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', + databases: [], + volume: { + size:1 + } + } + }) + .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); + } +} + +function setupGetInstancesMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')); + } +} + +function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances?limit=2') + .reply(200, helpers.loadFixture('rackspace/databaseInstancesLimit2.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances?limit=2') + .reply(200, helpers.loadFixture('openstack/databaseInstancesLimit2.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances?limit=2') + .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')); + } +} + +function setupDestroyInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(202); + } +} + +function setGetInstanceMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('rackspace/databaseInstance.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('openstack/databaseInstance.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') + .reply(200, helpers.loadFixture('hp/databaseInstance.json')); + } +} + +function setGetFlavorsMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/2') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') + .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') + .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')); + } +} - if (mock) { - setupGetInstancesMock(hockInstance, provider); +function setupSetFlavorMock(hockInstance, provider) { + if (provider ==='rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/flavors/2') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor2.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' } - - helpers.selectInstance(client, function (instance) { - client.setVolumeSize(instance, function (err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('without invalid size parameter should get errors', function (done) { - - if (mock) { - setupGetInstancesMock(hockInstance, provider); + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/2') + .reply(200, helpers.loadFixture('openstack/databaseFlavor2.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' } - - helpers.selectInstance(client, function (instance) { - client.setVolumeSize(instance, 12, function (err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with correct inputs should respond correctly', function (done) { - - if (mock) { - setupResizeMock (hockInstance, provider); + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') + .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/2' } + }) + .reply(202); + } +} - helpers.selectInstance(client, function (instance) { - var newSize = (Number(instance.volume.size) === 8) ? 1 : Number(instance.volume.size) + 1; - - client.setVolumeSize(instance, newSize, function (err) { - should.not.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - - describe('the create() method with errors', function () { - it('should respond with errors', function (done) { - client.createInstance(function(err) { - should.exist(err); - done(); - }); - }); - - it('without flavor should respond with errors', function (done) { - client.createInstance({ name: 'test-without-flavor' }, function (err) { - should.exist(err); - done(); - }); - }); - - it('with invalid size should respond with errors', function (done) { - if (mock) { - setupGetOneFlavorMock(hockInstance, provider); +function setupResizeMock (hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 } - - client.getFlavor(1, function (err, flavor) { - client.createInstance({ - name: 'test-instance', - flavor: flavor, - size: '1' - }, function(err) { - should.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - - describe('the restartInstance() method', function () { - it('with no instance should return error', function (done) { - client.restartInstance(function (err) { - should.exist(err); - done(); - }); - }); - - it('with valid instance should restart', function (done) { - if (mock) { - setupRestartInstanceMock (hockInstance, provider); + } + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 } - - helpers.selectInstance(client, function (instance) { - client.restartInstance(instance, function (err) { - should.not.exist(err); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - }); - - after(function (done) { - if (!mock) { - return done(); } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { + resize: { + volume :{ + size :2 } - ], done); - }); - }); - }); + } + }) + .reply(202); + } +} -}); +function setupGetOneFlavorMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors/1') + .reply(200, helpers.loadFixture('rackspace/databaseFlavor1.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/1') + .reply(200, helpers.loadFixture('openstack/databaseFlavor1.json')); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') + .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')); + } +} + +function setupRestartInstanceMock (hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) + .reply(202); + } +} diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index 1a648527f..1fc782e0f 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -13,477 +13,6 @@ var should = require('should'), User = require('../../../lib/pkgcloud/openstack/database/user').User, providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; - -function setupAuthenticationMock (authHockInstance, hockInstance, provider) { - if (provider === 'rackspace') { - authHockInstance - .post('/v2.0/tokens', { - auth: { - 'RAX-KSKEY:apiKeyCredentials': { - username: 'MOCK-USERNAME', - apiKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, helpers.getRackspaceAuthResponse()); - } - else if (provider === 'openstack') { - authHockInstance - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } - } - }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' - } - }) - .reply(200, helpers.getOpenstackAuthResponse()); - } - else if (provider === 'hp') { - authHockInstance.post('/v2.0/tokens', { - auth: { - apiAccessKeyCredentials: { - accessKey: 'MOCK-USERNAME', - secretKey: 'MOCK-API-KEY' - } - } - }) - .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') - .post('/v2.0/tokens', { - auth: { - apiAccessKeyCredentials: { - accessKey: 'MOCK-USERNAME', - secretKey: 'MOCK-API-KEY' - }, - tenantId: '5ACED3DC3AA740ABAA41711243CC6949' - } - }) - .reply(200, helpers.gethpAuthResponse()); - } - else if (provider === 'openstack') { - authHockInstance.post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } - } - }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' - } - }) - .reply(200, helpers.getOpenstackAuthResponse()); - } - else { - throw new Error('not supported'); - } -} - -function setupCreateUserMock(authHockInstance, hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTest', - password: 'joepasswd', - databases: [ { name: 'TestDatabase' } ] - } - ] - }) - .reply(202); - } - else if ( provider === 'openstack' ){ - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTest', - password: 'joepasswd', - databases: [ { name: 'TestDatabase' } ] - } - ] - }) - .reply(202); - } - else if ( provider === 'hp' ){ - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTest', - password: 'joepasswd', - databases: [ { name: 'TestDatabase' } ] - } - ] - }) - .reply(202); - } - else { - throw new Error('not supported'); - } -} - -function setupCreateAnotherUserMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestTwo', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestThree', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestTwo', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestThree', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestTwo', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestThree', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); - } - else { - throw new Error('not supported'); - } -} - -function setupCreateMultiplsUsersMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestFour', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - }, - { - name: 'joeTestFive', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); - } - else if ( provider === 'hp' ){ - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestFour', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - }, - { - name: 'joeTestFive', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); - } - else if ( provider === 'openstack' ){ - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { - users: [ - { - name: 'joeTestFour', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - }, - { - name: 'joeTestFive', - password: 'joepasswd', - databases: [ - { name: 'TestDatabase' } - ] - } - ] - }) - .reply(202); - } - else { - throw new Error('not supported'); - } -} - -function setupCreateUsersWithRestrictedCharacters(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); - } - else if ( provider === 'openstack' ){ - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); - } - else if ( provider === 'hp' ){ - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')); - } - else { - throw new Error('not supported'); - } -} - -function setupGetUsersMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); - } - else if ( provider === 'openstack' ){ - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('openstack/databaseUsers.json')); - } - else if ( provider === 'hp' ){ - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('hp/databaseUsers.json')); - } - else { - throw new Error('not supported'); - } - -} - -function setupEnableRootMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { - user: { - password: 'dbba235b-d078-42ec-b992-dec1464c49cc', - name: 'root' - } - }); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { - user: { - password: 'dbba235b-d078-42ec-b992-dec1464c49cc', - name: 'root' - } - }); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { - user: { - password: 'dbba235b-d078-42ec-b992-dec1464c49cc', - name: 'root' - } - }); - } -} - -function setupEnableRootMockWithStatus(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { rootEnabled: true }); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { rootEnabled: true }); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') - .reply(200, { rootEnabled: true }); - } -} - -function setupDestroyUsersMock(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') - .reply(202); - } -} - -function setupDestroyUsersMockWithPagination(hockInstance, provider) { - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') - .reply(202); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') - .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') - .reply(202); - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') - .reply(200, helpers.loadFixture('hp/databaseInstances.json')) - .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') - .reply(202); - } -} - providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { @@ -598,161 +127,631 @@ describe('pkgcloud/['+provider+']/databases/users', function () { setupCreateMultiplsUsersMock(hockInstance, provider); } - helpers.selectInstance(client, function (instance) { - client.createUser([ + helpers.selectInstance(client, function (instance) { + client.createUser([ + { + username: 'joeTestFour', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + }, + { + username: 'joeTestFive', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + } + ], function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('create users with questionable characters should respond with error', function (done) { + + if (mock) { + setupCreateUsersWithRestrictedCharacters(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.createUser({ + username: '@joeTestSix', + password: 'joepasswd', + database: 'TestDatabase', + instance: instance + }, function (err, response) { + should.exist(err); + should.not.exist(response); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the getUsers() method should get the list of users', function (done) { + + if (mock) { + setupGetUsersMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance }, function (err, list) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.forEach(function (user) { + user.should.be.instanceOf(User); + }); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + describe('the destroyUsers() method', function() { + it('should respond correctly', function(done) { + + if (mock) { + setupDestroyUsersMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.destroyUser(instance, 'joeTest', function(err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('should destroy the user used for pagination', function(done) { + + if (mock) { + setupDestroyUsersMockWithPagination(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.destroyUser(instance, 'joeTestTwo', function (err, response) { + should.not.exist(err); + should.exist(response); + response.statusCode.should.equal(202); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + + it('the enableRoot() method should respond correctly', function(done) { + + if (mock) { + setupEnableRootMock(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.enableRoot(instance, function(err, user, response) { + should.not.exist(err); + should.exist(user); + should.exist(response); + response.statusCode.should.equal(200); + should.exist(response.body); + response.body.user.should.be.a.Object; + should.exist(response.body.user.password); + response.body.user.name.should.equal('root'); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the enableRoot() method should respond correctly', function (done) { + + if (mock) { + setupEnableRootMockWithStatus(hockInstance, provider); + } + + helpers.selectInstance(client, function (instance) { + client.rootEnabled(instance, function (err, root, response) { + should.not.exist(err); + should.exist(root); + should.exist(response); + response.statusCode.should.equal(200); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + }); +}); +}); + +function setupAuthenticationMock (authHockInstance, hockInstance, provider) { + if (provider === 'rackspace') { + authHockInstance + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + } + else if (provider === 'openstack') { + authHockInstance + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + } + else if (provider === 'hp') { + authHockInstance.post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + } + else if (provider === 'openstack') { + authHockInstance.post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + } + else { + throw new Error('not supported'); + } +} + +function setupCreateUserMock(authHockInstance, hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTest', + password: 'joepasswd', + databases: [ { name: 'TestDatabase' } ] + } + ] + }) + .reply(202); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ { - username: 'joeTestFour', + name: 'joeTest', password: 'joepasswd', - database: 'TestDatabase', - instance: instance - }, + databases: [ { name: 'TestDatabase' } ] + } + ] + }) + .reply(202); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ { - username: 'joeTestFive', + name: 'joeTest', password: 'joepasswd', - database: 'TestDatabase', - instance: instance + databases: [ { name: 'TestDatabase' } ] } - ], function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('create users with questionable characters should respond with error', function (done) { - - if (mock) { - setupCreateUsersWithRestrictedCharacters(hockInstance, provider); - } + ] + }) + .reply(202); + } + else { + throw new Error('not supported'); + } +} - helpers.selectInstance(client, function (instance) { - client.createUser({ - username: '@joeTestSix', - password: 'joepasswd', - database: 'TestDatabase', - instance: instance - }, function (err, response) { - should.exist(err); - should.not.exist(response); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); +function setupCreateAnotherUserMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestTwo', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestThree', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestTwo', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestThree', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestTwo', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestThree', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else { + throw new Error('not supported'); + } +} - it('the getUsers() method should get the list of users', function (done) { +function setupCreateMultiplsUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users', { + users: [ + { + name: 'joeTestFour', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + }, + { + name: 'joeTestFive', + password: 'joepasswd', + databases: [ + { name: 'TestDatabase' } + ] + } + ] + }) + .reply(202); + } + else { + throw new Error('not supported'); + } +} - if (mock) { - setupGetUsersMock(hockInstance, provider); - } +function setupCreateUsersWithRestrictedCharacters(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')); + } + else { + throw new Error('not supported'); + } +} - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance }, function (err, list) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.forEach(function (user) { - user.should.be.instanceOf(User); - }); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); +function setupGetUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); + } + else if ( provider === 'openstack' ){ + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('openstack/databaseUsers.json')); + } + else if ( provider === 'hp' ){ + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') + .reply(200, helpers.loadFixture('hp/databaseUsers.json')); + } + else { + throw new Error('not supported'); + } - describe('the destroyUsers() method', function() { - it('should respond correctly', function(done) { +} - if (mock) { - setupDestroyUsersMock(hockInstance, provider); +function setupEnableRootMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' } - - helpers.selectInstance(client, function (instance) { - client.destroyUser(instance, 'joeTest', function(err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); - }); - }); }); - - it('should destroy the user used for pagination', function(done) { - - if (mock) { - setupDestroyUsersMockWithPagination(hockInstance, provider); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' } - - helpers.selectInstance(client, function (instance) { - client.destroyUser(instance, 'joeTestTwo', function (err, response) { - should.not.exist(err); - should.exist(response); - response.statusCode.should.equal(202); - hockInstance && hockInstance.done(); - done(); - }); - }); }); - }); - - it('the enableRoot() method should respond correctly', function(done) { - - if (mock) { - setupEnableRootMock(hockInstance, provider); - } - - helpers.selectInstance(client, function (instance) { - client.enableRoot(instance, function(err, user, response) { - should.not.exist(err); - should.exist(user); - should.exist(response); - response.statusCode.should.equal(200); - should.exist(response.body); - response.body.user.should.be.a.Object; - should.exist(response.body.user.password); - response.body.user.name.should.equal('root'); - hockInstance && hockInstance.done(); - done(); - }); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + password: 'dbba235b-d078-42ec-b992-dec1464c49cc', + name: 'root' + } }); - }); - - it('the enableRoot() method should respond correctly', function (done) { - - if (mock) { - setupEnableRootMockWithStatus(hockInstance, provider); - } + } +} - helpers.selectInstance(client, function (instance) { - client.rootEnabled(instance, function (err, root, response) { - should.not.exist(err); - should.exist(root); - should.exist(response); - response.statusCode.should.equal(200); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); +function setupEnableRootMockWithStatus(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { rootEnabled: true }); + } +} - after(function (done) { - if (!mock) { - return done(); - } +function setupDestroyUsersMock(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') + .reply(202); + } +} - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - }); -}); -}); +function setupDestroyUsersMockWithPagination(hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .delete('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances') + .reply(200, helpers.loadFixture('openstack/databaseInstances.json')) + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') + .reply(200, helpers.loadFixture('hp/databaseInstances.json')) + .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') + .reply(202); + } +} diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 45aeef6a7..889d02d6f 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -20,6 +20,229 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/networks [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getNetworks() function should return a list of networks', function(done) { + + if (mock) { + setupNetworksMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getNetworks(function (err, networks) { + should.not.exist(err); + should.exist(networks); + + context.networks = networks; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getNetwork() method should get a network instance', function (done) { + if (mock) { + setupGetNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getNetwork(context.networks[0].id, function (err, network) { + should.not.exist(err); + should.exist(network); + network.should.be.an.instanceOf(Network); + network.should.have.property('id', context.networks[0].id); + context.currentNetwork = network; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createNetwork() method should create a network', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createNetwork(_.extend({ + name: 'create-test-ids2' + }), function (err, network) { + should.not.exist(err); + should.exist(network); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroyNetwork() method should delete a network', function (done) { + if (mock) { + setupDestroyNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentNetwork); + } + + client.destroyNetwork(context.currentNetwork, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroyNetwork() method should take an id, delete a network', function (done) { + if (mock) { + setupDestroyNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentNetwork); + } + + client.destroyNetwork(context.currentNetwork.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updateNetwork() method should update a network', function (done) { + + var networkToUpdate = context.currentNetwork; + networkToUpdate.adminStateUp = false; + + if (mock) { + setupUpdateNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, networkToUpdate); + } + + client.updateNetwork(networkToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the network.create() method should create a network', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupNetworkModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var network = new Network(client); + network.name = 'model created network'; + network.create(function (err, createdNetwork) { + should.not.exist(err); + should.exist(createdNetwork); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the network.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var network = new Network(client); + network.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; + + if (mock) { + setupRefreshNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, network); + } + + network.refresh(function (err, refreshedNetwork) { + should.not.exist(err); + should.exist(refreshedNetwork); + refreshedNetwork.should.have.property('name', 'private-network'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the network.destroy() method should delete a network', function (done) { + var network = new Network(client); + network.name = 'model deleted network'; + network.id = 'THISISANETWORKID'; + + if (mock) { + setupModelDestroyedNetworkMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, network); + } + + network.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); + function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server @@ -283,226 +506,3 @@ var filterPath = function (path) { return path; }; - -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].network; -}).forEach(function (provider) { - describe('pkgcloud/common/network/networks [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'network'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getNetworks() function should return a list of networks', function(done) { - - if (mock) { - setupNetworksMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getNetworks(function (err, networks) { - should.not.exist(err); - should.exist(networks); - - context.networks = networks; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getNetwork() method should get a network instance', function (done) { - if (mock) { - setupGetNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getNetwork(context.networks[0].id, function (err, network) { - should.not.exist(err); - should.exist(network); - network.should.be.an.instanceOf(Network); - network.should.have.property('id', context.networks[0].id); - context.currentNetwork = network; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the createNetwork() method should create a network', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createNetwork(_.extend({ - name: 'create-test-ids2' - }), function (err, network) { - should.not.exist(err); - should.exist(network); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the destroyNetwork() method should delete a network', function (done) { - if (mock) { - setupDestroyNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentNetwork); - } - - client.destroyNetwork(context.currentNetwork, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the destroyNetwork() method should take an id, delete a network', function (done) { - if (mock) { - setupDestroyNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentNetwork); - } - - client.destroyNetwork(context.currentNetwork.id, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the updateNetwork() method should update a network', function (done) { - - var networkToUpdate = context.currentNetwork; - networkToUpdate.adminStateUp = false; - - if (mock) { - setupUpdateNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, networkToUpdate); - } - - client.updateNetwork(networkToUpdate, function(err,network){ - should.not.exist(err); - done(); - }); - }); - - it('the network.create() method should create a network', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupNetworkModelCreateMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - var network = new Network(client); - network.name = 'model created network'; - network.create(function (err, createdNetwork) { - should.not.exist(err); - should.exist(createdNetwork); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the network.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - - var network = new Network(client); - network.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; - - if (mock) { - setupRefreshNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, network); - } - - network.refresh(function (err, refreshedNetwork) { - should.not.exist(err); - should.exist(refreshedNetwork); - refreshedNetwork.should.have.property('name', 'private-network'); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the network.destroy() method should delete a network', function (done) { - var network = new Network(client); - network.name = 'model deleted network'; - network.id = 'THISISANETWORKID'; - - if (mock) { - setupModelDestroyedNetworkMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, network); - } - - network.destroy(function (err) { - should.not.exist(err); - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - - }); -}); diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index be6900d87..08eb3ba34 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -20,6 +20,231 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/ports [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getPorts() function should return a list of ports', function(done) { + + if (mock) { + setupPortsMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getPorts(function (err, ports) { + should.not.exist(err); + should.exist(ports); + + context.ports = ports; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getPort() method should get a port instance', function (done) { + if (mock) { + setupGetPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.ports[0]); + } + + client.getPort(context.ports[0].id, function (err, port) { + should.not.exist(err); + should.exist(port); + port.should.be.an.instanceOf(Port); + port.should.have.property('id', context.ports[0].id); + context.currentPort = port; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createPort() method should create a port', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupCreatePortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createPort({ + name: 'create-test-ids2' + }, function (err, port) { + should.not.exist(err); + should.exist(port); + port.should.be.an.instanceOf(Port); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroyPort() method should delete a port', function (done) { + if (mock) { + setupDestroyPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentPort); + } + + client.destroyPort(context.currentPort, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroyPort() method should take an id, delete a port', function (done) { + if (mock) { + setupDestroyPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentPort); + } + + client.destroyPort(context.currentPort.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updatePort() method should update a port', function (done) { + + var portToUpdate = context.currentPort; + portToUpdate.adminStateUp = false; + + if (mock) { + setupUpdatePortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, portToUpdate); + } + + client.updatePort(portToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the port.create() method should create a port', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupPortModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var port = new Port(client); + port.name= 'model created network'; + port.create(function (err, createdPort) { + should.not.exist(err); + should.exist(createdPort); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the port.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var port = new Port(client); + port.id = context.ports[0].id; + + if (mock) { + setupRefreshPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, port); + } + + port.refresh(function (err, refreshedPort) { + should.not.exist(err); + should.exist(refreshedPort); + refreshedPort.should.have.property('name', 'my_port'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the port.destroy() method should delete a port', function (done) { + var port = new Port(client); + port.name = 'model deleted port'; + port.id = 'THISISANETWORKID'; + + if (mock) { + setupModelDestroyedPortMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, port); + } + + port.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); + function setupDestroyPortMock(client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server @@ -289,228 +514,3 @@ function setupGetPortMock(client, provider, servers, currentPort) { .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } } - -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].network; -}).forEach(function (provider) { - describe('pkgcloud/common/network/ports [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'network'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getPorts() function should return a list of ports', function(done) { - - if (mock) { - setupPortsMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getPorts(function (err, ports) { - should.not.exist(err); - should.exist(ports); - - context.ports = ports; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getPort() method should get a port instance', function (done) { - if (mock) { - setupGetPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.ports[0]); - } - - client.getPort(context.ports[0].id, function (err, port) { - should.not.exist(err); - should.exist(port); - port.should.be.an.instanceOf(Port); - port.should.have.property('id', context.ports[0].id); - context.currentPort = port; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the createPort() method should create a port', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupCreatePortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createPort({ - name: 'create-test-ids2' - }, function (err, port) { - should.not.exist(err); - should.exist(port); - port.should.be.an.instanceOf(Port); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the destroyPort() method should delete a port', function (done) { - if (mock) { - setupDestroyPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentPort); - } - - client.destroyPort(context.currentPort, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the destroyPort() method should take an id, delete a port', function (done) { - if (mock) { - setupDestroyPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentPort); - } - - client.destroyPort(context.currentPort.id, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the updatePort() method should update a port', function (done) { - - var portToUpdate = context.currentPort; - portToUpdate.adminStateUp = false; - - if (mock) { - setupUpdatePortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, portToUpdate); - } - - client.updatePort(portToUpdate, function(err,network){ - should.not.exist(err); - done(); - }); - }); - - it('the port.create() method should create a port', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupPortModelCreateMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - var port = new Port(client); - port.name= 'model created network'; - port.create(function (err, createdPort) { - should.not.exist(err); - should.exist(createdPort); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the port.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - - var port = new Port(client); - port.id = context.ports[0].id; - - if (mock) { - setupRefreshPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, port); - } - - port.refresh(function (err, refreshedPort) { - should.not.exist(err); - should.exist(refreshedPort); - refreshedPort.should.have.property('name', 'my_port'); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the port.destroy() method should delete a port', function (done) { - var port = new Port(client); - port.name = 'model deleted port'; - port.id = 'THISISANETWORKID'; - - if (mock) { - setupModelDestroyedPortMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, port); - } - - port.destroy(function (err) { - should.not.exist(err); - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - - }); -}); diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index ab7e4a0d2..a4abf240c 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -20,6 +20,231 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function (provider) { + describe('pkgcloud/common/network/subnets [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getSubnets() function should return a list of subnets', function(done) { + + if (mock) { + setupSubnetsMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getSubnets(function (err, subnets) { + should.not.exist(err); + should.exist(subnets); + + context.subnets = subnets; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getSubnet() method should get a subnet instance', function (done) { + if (mock) { + setupGetSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + },context.subnets[0]); + } + + client.getSubnet(context.subnets[0].id, function (err, subnet) { + should.not.exist(err); + should.exist(subnet); + subnet.should.be.an.instanceOf(Subnet); + subnet.should.have.property('id', context.subnets[0].id); + context.currentSubnet = subnet; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createSubnet() method should create a subnet', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupCreateSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createSubnet({ + name: 'create-test-ids2' + }, function (err, subnet) { + should.not.exist(err); + should.exist(subnet); + subnet.should.be.an.instanceOf(Subnet); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroySubnet() method should delete a subnet', function (done) { + if (mock) { + setupDestroySubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSubnet); + } + + client.destroySubnet(context.currentSubnet, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroySubnet() method should take an id, delete a subnet', function (done) { + if (mock) { + setupDestroySubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSubnet); + } + + client.destroySubnet(context.currentSubnet.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the updateSubnet() method should update a subnet', function (done) { + + var subnetToUpdate = context.currentSubnet; + subnetToUpdate.enableDhcp = false; + + if (mock) { + setupUpdateSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, subnetToUpdate); + } + + client.updateSubnet(subnetToUpdate, function(err,network){ + should.not.exist(err); + done(); + }); + }); + + it('the subnet.create() method should create a subnet', function (done) { + var m = mock ? 0.1 : 10; + + if (mock) { + setupSubnetModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var subnet = new Subnet(client); + subnet.name= 'model created network'; + subnet.create(function (err, createdSubnet) { + should.not.exist(err); + should.exist(createdSubnet); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the subnet.refresh() method should get a network', function (done) { + var m = mock ? 0.1 : 10; + + var subnet = new Subnet(client); + subnet.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; + + if (mock) { + setupRefreshSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, subnet); + } + + subnet.refresh(function (err, refreshedSubnet) { + should.not.exist(err); + should.exist(refreshedSubnet); + refreshedSubnet.should.have.property('name', 'my_subnet'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the subnet.destroy() method should delete a subnet', function (done) { + var subnet = new Subnet(client); + subnet.name = 'model deleted subnet'; + subnet.id = 'THISISANETWORKID'; + + if (mock) { + setupModelDestroyedSubnetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, subnet); + } + + subnet.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); + function setupDestroySubnetMock(client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server @@ -292,228 +517,3 @@ function setupGetSubnetMock(client, provider, servers, currentSubnet) { .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } } - -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].network; -}).forEach(function (provider) { - describe('pkgcloud/common/network/subnets [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'network'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the getSubnets() function should return a list of subnets', function(done) { - - if (mock) { - setupSubnetsMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getSubnets(function (err, subnets) { - should.not.exist(err); - should.exist(subnets); - - context.subnets = subnets; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the getSubnet() method should get a subnet instance', function (done) { - if (mock) { - setupGetSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - },context.subnets[0]); - } - - client.getSubnet(context.subnets[0].id, function (err, subnet) { - should.not.exist(err); - should.exist(subnet); - subnet.should.be.an.instanceOf(Subnet); - subnet.should.have.property('id', context.subnets[0].id); - context.currentSubnet = subnet; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the createSubnet() method should create a subnet', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupCreateSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createSubnet({ - name: 'create-test-ids2' - }, function (err, subnet) { - should.not.exist(err); - should.exist(subnet); - subnet.should.be.an.instanceOf(Subnet); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the destroySubnet() method should delete a subnet', function (done) { - if (mock) { - setupDestroySubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentSubnet); - } - - client.destroySubnet(context.currentSubnet, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the destroySubnet() method should take an id, delete a subnet', function (done) { - if (mock) { - setupDestroySubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, context.currentSubnet); - } - - client.destroySubnet(context.currentSubnet.id, function (err) { - should.not.exist(err); - done(); - }); - }); - - it('the updateSubnet() method should update a subnet', function (done) { - - var subnetToUpdate = context.currentSubnet; - subnetToUpdate.enableDhcp = false; - - if (mock) { - setupUpdateSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, subnetToUpdate); - } - - client.updateSubnet(subnetToUpdate, function(err,network){ - should.not.exist(err); - done(); - }); - }); - - it('the subnet.create() method should create a subnet', function (done) { - var m = mock ? 0.1 : 10; - - if (mock) { - setupSubnetModelCreateMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - var subnet = new Subnet(client); - subnet.name= 'model created network'; - subnet.create(function (err, createdSubnet) { - should.not.exist(err); - should.exist(createdSubnet); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the subnet.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - - var subnet = new Subnet(client); - subnet.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; - - if (mock) { - setupRefreshSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, subnet); - } - - subnet.refresh(function (err, refreshedSubnet) { - should.not.exist(err); - should.exist(refreshedSubnet); - refreshedSubnet.should.have.property('name', 'my_subnet'); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the subnet.destroy() method should delete a subnet', function (done) { - var subnet = new Subnet(client); - subnet.name = 'model deleted subnet'; - subnet.id = 'THISISANETWORKID'; - - if (mock) { - setupModelDestroyedSubnetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }, subnet); - } - - subnet.destroy(function (err) { - should.not.exist(err); - done(); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - - }); -}); diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 07e71ebd4..3dbf3daf6 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -27,593 +27,157 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); -function setupCreateContainerMock(provider, client, servers) { - if (provider === 'rackspace') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - 'RAX-KSKEY:apiKeyCredentials': { - username: 'MOCK-USERNAME', - apiKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, helpers.getRackspaceAuthResponse()); +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].storage; +}).forEach(function (provider) { + describe('pkgcloud/common/storage/base [' + provider + ']', function () { - servers.server - .defaultReplyHeaders(helpers.rackspaceResponseHeaders()) - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(201); - } - else if (provider === 'openstack') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } + var config = null; + + if (!mock && provider === 'google') { + config = { + keyFilename: process.env.GCLOUD_KEYFILE, + projectId: process.env.GCLOUD_PROJECT_ID + }; + } + + var client = helpers.createClient(provider, 'storage', config), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' + ], done); + }); + + it('the createContainer() method should return newly created container', function(done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers.getOpenstackAuthResponse()); - servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(201); - } - else if (provider === 'amazon') { - servers.server - .put('/', 'us-west-2') - .reply(200); - } - else if (provider === 'azure') { + setupCreateContainerMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } - // Override the clients getUrl method as it tries to prefix the container name onto the request - client._getUrl = function (options) { - options = options || {}; + client.createContainer('pkgcloud-test-container', function(err, container) { + should.not.exist(err); + should.exist(container); + container.should.be.instanceOf(Container); - return urlJoin('http://localhost:12345/', - (typeof options === 'string' - ? options - : options.path)); - }; + context.container = container; - servers.server - .put('/pkgcloud-test-container?restype=container') - .reply(201, '', helpers.azureResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .post('/storage/v1/b?project=test-project', { - name: 'pkgcloud-test-container' - }) - .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); - client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { - reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - callback(null, reqOpts); - }; + }); + }); - client.storage.connection_.req = function (reqOpts, callback) { - reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - client.storage.connection_.requester(reqOpts, callback); - }; + it('the getContainers() method should return newly created container', function (done) { - client.storage.connection_.requester = function (reqOpts, callback) { - if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { - var stream = through(); - stream.on('finish', function () { - fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { - if (err) { - return stream.emit('error', err); - } - stream.emit('complete', { body: JSON.parse(file) }); - }); + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupGetContainersMock(provider, client, { + server: hockInstance, + authServer: authHockInstance }); - return stream; } - return request(reqOpts, callback); - }; - } - else if (provider === 'hp') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - apiAccessKeyCredentials: { - accessKey: 'MOCK-USERNAME', - secretKey: 'MOCK-API-KEY' - } - } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') - .post('/v2.0/tokens', { - auth: { - apiAccessKeyCredentials: { - accessKey: 'MOCK-USERNAME', - secretKey: 'MOCK-API-KEY' - }, - tenantId: '5ACED3DC3AA740ABAA41711243CC6949' - } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(200, helpers.gethpAuthResponse()); + client.getContainers(function (err, containers) { + should.not.exist(err); + should.exist(containers); + containers.should.be.an.Array; - servers.server - .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(201); - } -} + containers.forEach(function(container) { + container.should.be.instanceOf(Container); + }); -function setupGetContainersMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('rackspace/postContainers.json')); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-buckets.xml')); - } - else if (provider === 'azure') { - servers.server - .get('/?comp=list') - .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b?project=test-project') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('hp/postContainers.json')); - } -} + // TODO Name check + hockInstance && hockInstance.done(); + done(); -function setupUploadStreamMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) - .reply(200) - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'amazon') { - servers.server - .post('/test-file.txt?uploads') - .reply(200, '\npkgcloud-test-containertest-file.txtU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) - .put('/test-file.txt?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', fillerama) - .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/test-file.txtpkgcloud-test-containertest-file.txt"b2286fe4aac65809a1b7a053d07fc99f-1"') - .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') - .reply(200); + }); + }); - } - else if (provider === 'azure') { - servers.server - .put('/pkgcloud-test-container/test-file.txt?comp=block&blockid=block000000000000000', fillerama) - .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) - .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', 'block000000000000000') - .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) - .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); - } - else if (provider === 'hp') { - servers.server - .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) - .reply(200) - .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } -} + it('the upload() method with container and filename should succeed', function (done) { -function setupDownloadStreamMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2}); - } - else if (provider === 'amazon') { - servers.server - .get('/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'azure') { - servers.server - .get('/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) - .get('/mediaLink') - .reply(200, fillerama); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(200, fillerama, { 'content-length': fillerama.length + 2}); - } -} + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } -function setupGetFileMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'amazon') { - servers.server - .head('/test-file.txt') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } - else if (provider === 'azure') { - servers.server - .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); - } - else if (provider === 'hp') { - servers.server - .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') - .reply(200, '', { 'content-length': fillerama.length + 2 }); - } -} + setupUploadStreamMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } -function setupGetFilesMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') - .reply(200, [{ - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' - }]); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml')); - } - else if (provider === 'azure') { - servers.server - .get('/pkgcloud-test-container?restype=container&comp=list') - .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') - .reply(200, [{ - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' - }]); - } -} + var stream = client.upload({ + container: context.container, + remote: 'test-file.txt', + headers: {'x-amz-acl': 'public-read'} + }); -function setupRemoveFileMock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, ''); - } - else if (provider === 'amazon') { - servers.server - .delete('/test-file.txt') - .reply(204); - } - else if (provider === 'azure') { - servers.server - .delete('/pkgcloud-test-container/test-file.txt') - .reply(202, '', helpers.azureDeleteResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .reply(204, {}); - } - else if (provider === 'hp') { - servers.server - .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, ''); - } -} + stream.on('error', function(err, response) { + should.not.exist(err); + should.not.exist(response); + done(); + }); -function setupDestroyContainerMock(provider, client, servers) { - if (provider === 'openstack') { - servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') - .reply(200, [ - { - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' - } - ]) - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, '') - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(204); - } - else if (provider === 'rackspace') { - servers.server - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') - .reply(200, [ - { - bytes: fillerama.length, - name: 'test-file.txt', - content_type: 'text/plain' - } - ]) - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, '') - .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(204); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml'), {}) - .delete('/') - .reply(204) - .delete('/test-file.txt') - .reply(204); - } - else if (provider === 'azure') { - servers.server - .delete('/pkgcloud-test-container?restype=container') - .reply(202, '', helpers.azureDeleteResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b/pkgcloud-test-container/o') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json') - .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') - .reply(204, {}) - .delete('/storage/v1/b/pkgcloud-test-container') - .reply(204, {}); - } - else if (provider === 'hp') { - servers.server - .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(200, {}, { - 'x-container-object-count': 1, - 'x-container-bytes-used': fillerama.length - }) - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') - .reply(200, [ - { - bytes: fillerama.length, + stream.on('success', function(file) { + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + file.should.be.an.instanceof(File); + + context.file = { name: 'test-file.txt', - content_type: 'text/plain' - } - ]) - .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') - .reply(204, '') - .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') - .reply(204); - } -} - -function setupGetContainers2Mock(provider, client, servers) { - if (provider === 'rackspace' || provider === 'openstack') { - servers.server - .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('rackspace/preContainers.json')); - } - else if (provider === 'amazon') { - servers.server - .get('/') - .reply(200, helpers.loadFixture('amazon/list-buckets2.xml')); - } - else if (provider === 'azure') { - servers.server - .get('/?comp=list') - .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()); - } - else if (provider === 'google') { - servers.server - .get('/storage/v1/b?project=test-project') - .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); - } - else if (provider === 'hp') { - servers.server - .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') - .reply(200, helpers.loadFixture('hp/preContainers.json')); - } -} - -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].storage; -}).forEach(function (provider) { - describe('pkgcloud/common/storage/base [' + provider + ']', function () { - - var config = null; - - if (!mock && provider === 'google') { - config = { - keyFilename: process.env.GCLOUD_KEYFILE, - projectId: process.env.GCLOUD_PROJECT_ID - }; - } - - var client = helpers.createClient(provider, 'storage', config), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the createContainer() method should return newly created container', function(done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupCreateContainerMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.createContainer('pkgcloud-test-container', function(err, container) { - should.not.exist(err); - should.exist(container); - container.should.be.instanceOf(Container); - - context.container = container; - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the getContainers() method should return newly created container', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupGetContainersMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - client.getContainers(function (err, containers) { - should.not.exist(err); - should.exist(containers); - containers.should.be.an.Array; - - containers.forEach(function(container) { - container.should.be.instanceOf(Container); - }); - - // TODO Name check - hockInstance && hockInstance.done(); - done(); - - }); - }); - - it('the upload() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupUploadStreamMock(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - var stream = client.upload({ - container: context.container, - remote: 'test-file.txt', - headers: {'x-amz-acl': 'public-read'} - }); - - stream.on('error', function(err, response) { - should.not.exist(err); - should.not.exist(response); - done(); - }); - - stream.on('success', function(file) { - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - file.should.be.an.instanceof(File); - - context.file = { - name: 'test-file.txt', - size: Buffer.byteLength(fillerama) - }; - - done(); - }); - - var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); - file.pipe(stream); - }); - - it('the download() method with container and filename should succeed', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); + size: Buffer.byteLength(fillerama) + }; + + done(); + }); + + var file = fs.createReadStream(helpers.fixturePath('fillerama.txt')); + file.pipe(stream); + }); + + it('the download() method with container and filename should succeed', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); } setupDownloadStreamMock(provider, client, { @@ -848,3 +412,439 @@ providers.filter(function (provider) { }); }); }); + +function setupCreateContainerMock(provider, client, servers) { + if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + + servers.server + .defaultReplyHeaders(helpers.rackspaceResponseHeaders()) + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } + else if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } + else if (provider === 'amazon') { + servers.server + .put('/', 'us-west-2') + .reply(200); + } + else if (provider === 'azure') { + + // Override the clients getUrl method as it tries to prefix the container name onto the request + client._getUrl = function (options) { + options = options || {}; + + return urlJoin('http://localhost:12345/', + (typeof options === 'string' + ? options + : options.path)); + }; + + servers.server + .put('/pkgcloud-test-container?restype=container') + .reply(201, '', helpers.azureResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .post('/storage/v1/b?project=test-project', { + name: 'pkgcloud-test-container' + }) + .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); + + client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + callback(null, reqOpts); + }; + + client.storage.connection_.req = function (reqOpts, callback) { + reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); + client.storage.connection_.requester(reqOpts, callback); + }; + + client.storage.connection_.requester = function (reqOpts, callback) { + if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { + var stream = through(); + stream.on('finish', function () { + fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { + if (err) { + return stream.emit('error', err); + } + stream.emit('complete', { body: JSON.parse(file) }); + }); + }); + return stream; + } + + return request(reqOpts, callback); + }; + } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) + .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(201); + } +} + +function setupGetContainersMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('rackspace/postContainers.json')); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-buckets.xml')); + } + else if (provider === 'azure') { + servers.server + .get('/?comp=list') + .reply(200, helpers.loadFixture('azure/list-containers.xml'),helpers.azureResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b?project=test-project') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/postContainers.json')); + } +} + +function setupUploadStreamMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .reply(200) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'amazon') { + servers.server + .post('/test-file.txt?uploads') + .reply(200, '\npkgcloud-test-containertest-file.txtU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) + .put('/test-file.txt?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', fillerama) + .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/test-file.txtpkgcloud-test-containertest-file.txt"b2286fe4aac65809a1b7a053d07fc99f-1"') + .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') + .reply(200); + + } + else if (provider === 'azure') { + servers.server + .put('/pkgcloud-test-container/test-file.txt?comp=block&blockid=block000000000000000', fillerama) + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) + .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', 'block000000000000000') + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) + .get('/pkgcloud-test-container/test-file.txt') + .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); + } + else if (provider === 'hp') { + servers.server + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) + .reply(200) + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } +} + +function setupDownloadStreamMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2}); + } + else if (provider === 'amazon') { + servers.server + .get('/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'azure') { + servers.server + .get('/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2,'content-type': 'text/plain'})); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) + .get('/mediaLink') + .reply(200, fillerama); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(200, fillerama, { 'content-length': fillerama.length + 2}); + } +} + +function setupGetFileMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'amazon') { + servers.server + .head('/test-file.txt') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } + else if (provider === 'azure') { + servers.server + .get('/pkgcloud-test-container/test-file.txt') + .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); + } + else if (provider === 'hp') { + servers.server + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') + .reply(200, '', { 'content-length': fillerama.length + 2 }); + } +} + +function setupGetFilesMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [{ + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + }]); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml')); + } + else if (provider === 'azure') { + servers.server + .get('/pkgcloud-test-container?restype=container&comp=list') + .reply(200, helpers.loadFixture('azure/list-container-files.xml'), helpers.azureResponseHeaders({'content-type': 'application/xml'})); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json'); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') + .reply(200, [{ + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + }]); + } +} + +function setupRemoveFileMock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, ''); + } + else if (provider === 'amazon') { + servers.server + .delete('/test-file.txt') + .reply(204); + } + else if (provider === 'azure') { + servers.server + .delete('/pkgcloud-test-container/test-file.txt') + .reply(202, '', helpers.azureDeleteResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(204, {}); + } + else if (provider === 'hp') { + servers.server + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, ''); + } +} + +function setupDestroyContainerMock(provider, client, servers) { + if (provider === 'openstack') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } + else if (provider === 'rackspace') { + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-bucket-files.xml'), {}) + .delete('/') + .reply(204) + .delete('/test-file.txt') + .reply(204); + } + else if (provider === 'azure') { + servers.server + .delete('/pkgcloud-test-container?restype=container') + .reply(202, '', helpers.azureDeleteResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-files.json') + .delete('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') + .reply(204, {}) + .delete('/storage/v1/b/pkgcloud-test-container') + .reply(204, {}); + } + else if (provider === 'hp') { + servers.server + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(200, {}, { + 'x-container-object-count': 1, + 'x-container-bytes-used': fillerama.length + }) + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json&limit=1001') + .reply(200, [ + { + bytes: fillerama.length, + name: 'test-file.txt', + content_type: 'text/plain' + } + ]) + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') + .reply(204, '') + .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') + .reply(204); + } +} + +function setupGetContainers2Mock(provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('rackspace/preContainers.json')); + } + else if (provider === 'amazon') { + servers.server + .get('/') + .reply(200, helpers.loadFixture('amazon/list-buckets2.xml')); + } + else if (provider === 'azure') { + servers.server + .get('/?comp=list') + .reply(200, helpers.loadFixture('azure/list-containers2.xml'), helpers.azureResponseHeaders()); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b?project=test-project') + .replyWithFile(200, __dirname + '/../../fixtures/google/get-buckets.json'); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') + .reply(200, helpers.loadFixture('hp/preContainers.json')); + } +} diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index ba3c16bf4..46092d646 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -25,6 +25,93 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); +providers.filter(function (provider) { + return !!helpers.pkgcloud.providers[provider].storage; +}).forEach(function (provider) { + describe('pkgcloud/common/storage/base [' + provider + ']', function () { + + var client = helpers.createClient(provider, 'storage'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + // setup a filtering path for aws + hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the client.upload stream should emit error', function (done) { + + if (mock) { + if (provider === 'joyent') { + // TODO figure out why joyent was disabled in vows based tests + return done(); + } + + setupUploadStreamError(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); + } + + var stream = client.upload({ + container: 'pkgcloud-test-container', + remote: 'test-file.txt' + }); + + stream.on('error', function (err) { + should.exist(err); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + + stream.on('success', function (file) { + should.not.exist(file); + done(); + }); + + stream.end('foo'); + }); + + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + }); +}); + function setupUploadStreamError(provider, client, servers) { if (provider === 'rackspace') { servers.authServer @@ -120,90 +207,3 @@ function setupUploadStreamError(provider, client, servers) { .reply(400); } } - -providers.filter(function (provider) { - return !!helpers.pkgcloud.providers[provider].storage; -}).forEach(function (provider) { - describe('pkgcloud/common/storage/base [' + provider + ']', function () { - - var client = helpers.createClient(provider, 'storage'), - context = {}, - authServer, server, - authHockInstance, hockInstance; - - before(function (done) { - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - // setup a filtering path for aws - hockInstance.filteringPathRegEx(/https:\/\/[\w\-\.]*s3-us-west-2\.amazonaws\.com([\w\-\.\_0-9\/]*)/g, '$1'); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); - - it('the client.upload stream should emit error', function (done) { - - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - - setupUploadStreamError(provider, client, { - server: hockInstance, - authServer: authHockInstance - }); - } - - var stream = client.upload({ - container: 'pkgcloud-test-container', - remote: 'test-file.txt' - }); - - stream.on('error', function (err) { - should.exist(err); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - done(); - }); - - stream.on('success', function (file) { - should.not.exist(file); - done(); - }); - - stream.end('foo'); - }); - - - after(function (done) { - if (!mock) { - return done(); - } - - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); - }); -}); diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index bad506a67..8fd5c1bab 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -28,29 +28,6 @@ var azureApi = require('../../lib/pkgcloud/azure/utils/azureApi'), PATH = require('path'), helpers; -/** - * serverStatusReply() - * fills in the nock xml reply from the server with server name and status - * @param name - name of the server - * @param status - status to be returned in reply - * status should be: - * ReadyRole - server is RUNNING - * VMStopped - server is still PROVISIONING - * Provisioning - server is still PROVISIONING - * see lib/pkgcloud/azure/compute/server.js for more status values - * - * @param helpers - test helper object - * @return {String} - the xml reply containing the server name and status - */ -var serverStatusReply = function (name, status) { - - var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; - - var result = _.template(template, params); - return result; -}; - exports.serverTest = function (nock, testHelpers) { helpers = testHelpers; @@ -198,6 +175,28 @@ exports.serverTest = function (nock, testHelpers) { .reply(200,helpers.loadFixture('azure/operation-succeeded.xml'),{}); }; +/** + * serverStatusReply() + * fills in the nock xml reply from the server with server name and status + * @param name - name of the server + * @param status - status to be returned in reply + * status should be: + * ReadyRole - server is RUNNING + * VMStopped - server is still PROVISIONING + * Provisioning - server is still PROVISIONING + * see lib/pkgcloud/azure/compute/server.js for more status values + * + * @param helpers - test helper object + * @return {String} - the xml reply containing the server name and status + */ +var serverStatusReply = function (name, status) { + + var template = helpers.loadFixture('azure/server-status-template.xml'), + params = {NAME: name, STATUS: status}; + + var result = _.template(template, params); + return result; +}; var filterPath = function (path) { var name = PATH.basename(path); @@ -207,3 +206,5 @@ var filterPath = function (path) { return path; }; + + diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js index ba2a7cf7b..1919133ae 100644 --- a/test/iriscouch/databases/databases-redis-test.js +++ b/test/iriscouch/databases/databases-redis-test.js @@ -12,16 +12,6 @@ var helpers = require('../../helpers'), http = require('http'), mock = !!process.env.MOCK; -// -// Just a quick and lazy random password generator -// -function randomPassword(length) { - if (length == 1) { - return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48); - } - return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48) + randomPassword(length - 1); -} - describe('pkgcloud/iriscouch/databases-redis', function () { var context = {}, client, hockInstance, server; @@ -130,3 +120,13 @@ describe('pkgcloud/iriscouch/databases-redis', function () { }); }); + +// +// Just a quick and lazy random password generator +// +function randomPassword(length) { + if (length == 1) { + return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48); + } + return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48) + randomPassword(length - 1); +} \ No newline at end of file diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js index cfbd1ff87..ec6d5f52c 100644 --- a/test/rackspace/databases/user-limit-test.js +++ b/test/rackspace/databases/user-limit-test.js @@ -14,6 +14,119 @@ var should = require('should'), User = require('../../../lib/pkgcloud/openstack/database/user').User, mock = !!process.env.MOCK; + describe.skip('pkgcloud/[rackspace]/databases/users/limits', function () { + var testContext = {}, + client, authHockInstance, hockInstance, authServer, + server, err, list, offset; + + before(function (done) { + client = helpers.createClient('rackspace', 'database'); + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + + if (mock) { + setupAuthenticationMock(authHockInstance); + setupGetUsersMock(hockInstance); + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') + .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance, limit: 1 }, function (e, l, o) { + err = e; + list = l; + offset = o; + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with limit should respond with one element', function () { + should.not.exist(err); + should.exist(list); + list.should.have.length(1); + }); + + it('with limitshould pass as third argument the offset mark', function () { + should.exist(offset); + testContext.marker = offset; + }); + + it('with offset should respond less quantity', function (done) { + + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?marker=joeTest') + .reply(200, { + users: [ + { name: 'joeTestTwo', databases: []}, + { name: 'joeTestThree', databases: []} + ] + }); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ instance: instance, offset: testContext.marker }, function (err, list, offset) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.should.have.length(2); + should.not.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('with limit and offset should responsd with just result with more next points', function(done) { + + if (mock) { + hockInstance + .get('/v1.0/123456/instances') + .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1&marker=joeTest') + .reply(200, helpers.loadFixture('rackspace/databaseUsersLimitOffset.json')); + } + + helpers.selectInstance(client, function (instance) { + client.getUsers({ + instance: instance, + limit: 1, + offset:testContext.marker }, function(err, list, offset) { + should.not.exist(err); + should.exist(list); + list.should.be.an.Array; + list.should.have.length(1); + should.exist(offset); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + }); + function setupGetUsersMock(hockInstance) { hockInstance .get('/v1.0/123456/instances') @@ -34,116 +147,3 @@ function setupAuthenticationMock (authHockInstance) { }) .reply(200, helpers.getRackspaceAuthResponse()); } - -describe.skip('pkgcloud/[rackspace]/databases/users/limits', function () { - var testContext = {}, - client, authHockInstance, hockInstance, authServer, - server, err, list, offset; - - before(function (done) { - client = helpers.createClient('rackspace', 'database'); - if (!mock) { - return done(); - } - - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - - if (mock) { - setupAuthenticationMock(authHockInstance); - setupGetUsersMock(hockInstance); - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') - .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance, limit: 1 }, function (e, l, o) { - err = e; - list = l; - offset = o; - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with limit should respond with one element', function () { - should.not.exist(err); - should.exist(list); - list.should.have.length(1); - }); - - it('with limitshould pass as third argument the offset mark', function () { - should.exist(offset); - testContext.marker = offset; - }); - - it('with offset should respond less quantity', function (done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?marker=joeTest') - .reply(200, { - users: [ - { name: 'joeTestTwo', databases: []}, - { name: 'joeTestThree', databases: []} - ] - }); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ instance: instance, offset: testContext.marker }, function (err, list, offset) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.should.have.length(2); - should.not.exist(offset); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('with limit and offset should responsd with just result with more next points', function(done) { - - if (mock) { - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1&marker=joeTest') - .reply(200, helpers.loadFixture('rackspace/databaseUsersLimitOffset.json')); - } - - helpers.selectInstance(client, function (instance) { - client.getUsers({ - instance: instance, - limit: 1, - offset:testContext.marker }, function(err, list, offset) { - should.not.exist(err); - should.exist(list); - list.should.be.an.Array; - list.should.have.length(1); - should.exist(offset); - hockInstance && hockInstance.done(); - done(); - }); - }); - }); -}); From 84d9398b8ecec1ffe9268f0cf45ba83187f759c1 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Dec 2014 12:09:14 -0800 Subject: [PATCH 273/460] Defining variable before use. --- test/azure/compute/client/test-createServer.js | 4 ++-- test/azure/compute/client/test-rebootServer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/azure/compute/client/test-createServer.js b/test/azure/compute/client/test-createServer.js index 54529bc22..4f121723f 100644 --- a/test/azure/compute/client/test-createServer.js +++ b/test/azure/compute/client/test-createServer.js @@ -13,6 +13,8 @@ var fs = require('fs'), azureNock = require('../../../helpers/azureNock'), nock = require('nock'); +var testContext = {}; + var options = { name: 'create-test-ids2', flavor: 'ExtraSmall', @@ -92,8 +94,6 @@ function testSetWait(client) { var client = helpers.createClient('azure', 'compute'); -var testContext = {}; - if (process.env.MOCK) { azureNock.serverTest(nock, helpers); } diff --git a/test/azure/compute/client/test-rebootServer.js b/test/azure/compute/client/test-rebootServer.js index b20235af2..915a24af7 100644 --- a/test/azure/compute/client/test-rebootServer.js +++ b/test/azure/compute/client/test-rebootServer.js @@ -13,6 +13,8 @@ var fs = require('fs'), azureNock = require('../../../helpers/azureNock'), nock = require('nock'); +var testContext = {}; + var options = { name: 'test-reboot', flavor: 'ExtraSmall', @@ -105,8 +107,6 @@ function testRebootServer(client) { var client = helpers.createClient('azure', 'compute'); -var testContext = {}; - if (process.env.MOCK) { azureNock.serverTest(nock, helpers); } From 3f3acdc0471c447928084a3e28805988de6f816c Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Dec 2014 12:09:41 -0800 Subject: [PATCH 274/460] Declaring variables before use (and definition). --- test/common/compute/base-test.js | 3 +++ test/common/compute/meta-test.js | 3 +++ test/common/compute/server-test.js | 4 ++++ test/common/databases/databases-test.js | 5 +++++ test/common/databases/flavor-test.js | 3 +++ test/common/databases/instances-test.js | 7 +++++++ test/common/databases/users-test.js | 7 +++++++ test/common/network/network-test.js | 5 +++++ test/common/network/port-test.js | 5 +++++ test/common/network/subnet-test.js | 5 +++++ test/common/storage/base-test.js | 5 +++++ test/common/storage/upload-test.js | 3 +++ test/helpers/azureNock.js | 3 +++ test/iriscouch/databases/databases-redis-test.js | 5 ++++- test/rackspace/databases/user-limit-test.js | 3 +++ 15 files changed, 65 insertions(+), 1 deletion(-) diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index a7b4172a8..a63718005 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -26,6 +26,9 @@ var fs = require('fs'), var azureOptions = require('../../fixtures/azure/azure-options.json'); +// Declaring variables for helper functions defined later +var setupVersionMock, setupFlavorMock, setupImagesMock, setupServerMock, setupDestroyMock; + azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); providers.filter(function (provider) { diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index c1981371b..d4ce121fa 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -18,6 +18,9 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; +// Declaring variables for helper functions defined later +var setupMetaMock, setupImagesMock; + var providers=['openstack']; providers.filter(function (provider) { diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 341c86c12..0d4dc5395 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -25,6 +25,10 @@ var fs = require('fs'), var azureOptions = require('../../fixtures/azure/azure-options.json'); +// Declaring variables for helper functions defined later +var setupImagesMock, setupFlavorMock, setupServerMock, setupGetServersMock, + setupGetServerMock, serverStatusReply; + azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); providers.filter(function (provider) { diff --git a/test/common/databases/databases-test.js b/test/common/databases/databases-test.js index 457bfd846..1776427e0 100644 --- a/test/common/databases/databases-test.js +++ b/test/common/databases/databases-test.js @@ -13,6 +13,11 @@ var should = require('should'), providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; +// Declaring variables for helper functions defined later +var setupCreateDatabasesMock, setupCreateDatabasesForPaginationMock, + setupModelCreateDatabasesMock, setupGetDatabasesMock, + setupDestroyDatabasesMock, setupDestroyLastDatabasesMock; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index 71efb4d9c..f12246fc5 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -14,6 +14,9 @@ var should = require('should'), providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; +// Declaring variables for helper functions defined later +var setupGetFlavorMock; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index cc5efd37e..ef75c9b21 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -14,6 +14,13 @@ var should = require('should'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, Instance = require('../../../lib/pkgcloud/openstack/database/instance').Instance, mock = !!process.env.MOCK; + +// Declaring variables for helper functions defined later +var assertLinks, setupCreateInstanceMock, setupGetInstancesMock, + setupGetDatabaseInstancesWithLimitMock, setupDestroyInstanceMock, + setGetInstanceMock, setGetFlavorsMock, setupSetFlavorMock, setupResizeMock, + setupGetOneFlavorMock, setupRestartInstanceMock; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index 1fc782e0f..cf6441733 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -13,6 +13,13 @@ var should = require('should'), User = require('../../../lib/pkgcloud/openstack/database/user').User, providers = require('../../configs/providers.json'), mock = !!process.env.MOCK; + +// Declaring variables for helper functions defined later +var setupAuthenticationMock, setupCreateUserMock, setupCreateAnotherUserMock, + setupCreateMultiplsUsersMock, setupCreateUsersWithRestrictedCharacters, + setupGetUsersMock, setupEnableRootMock, setupEnableRootMockWithStatus, + setupDestroyUsersMock, setupDestroyUsersMockWithPagination; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 889d02d6f..9008069af 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -20,6 +20,11 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); +// Declaring variables for helper functions defined later +var setupDestroyNetworkMock, setupUpdateNetworkMock, setupModelDestroyedNetworkMock, + setupNetworksMock, setupNetworkMock, setupRefreshNetworkMock, + setupNetworkModelCreateMock, setupGetNetworkMock; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].network; }).forEach(function (provider) { diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 08eb3ba34..b7f19d2ba 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -20,6 +20,11 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); +// Declaring variables for helper functions defined later +var setupDestroyPortMock, setupUpdatePortMock, setupModelDestroyedPortMock, + setupPortsMock, setupCreatePortMock, setupRefreshPortMock, + setupPortModelCreateMock, setupGetPortMock; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].network; }).forEach(function (provider) { diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index a4abf240c..812072eb5 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -20,6 +20,11 @@ var fs = require('fs'), mock = !!process.env.MOCK, urlJoin = require('url-join'); +// Declaring variables for helper functions defined later +var setupDestroySubnetMock, setupUpdateSubnetMock, setupModelDestroyedSubnetMock, + setupSubnetsMock, setupCreateSubnetMock, setupRefreshSubnetMock, + setupSubnetModelCreateMock, setupGetSubnetMock; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].network; }).forEach(function (provider) { diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 3dbf3daf6..ad2a89eb0 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -27,6 +27,11 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); +// Declaring variables for helper functions defined later +var setupCreateContainerMock, setupGetContainersMock, setupUploadStreamMock, + setupDownloadStreamMock, setupGetFileMock, setupGetFilesMock, + setupRemoveFileMock, setupDestroyContainerMock, setupGetContainers2Mock; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].storage; }).forEach(function (provider) { diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index 46092d646..07b50e160 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -25,6 +25,9 @@ var fs = require('fs'), pkgcloud = require('../../../lib/pkgcloud'), fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); +// Declaring variables for helper functions defined later +var setupUploadStreamError; + providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].storage; }).forEach(function (provider) { diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index 8fd5c1bab..7745d2066 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -28,6 +28,9 @@ var azureApi = require('../../lib/pkgcloud/azure/utils/azureApi'), PATH = require('path'), helpers; +// Declaring variables for helper functions defined later +var serverStatusReply; + exports.serverTest = function (nock, testHelpers) { helpers = testHelpers; diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js index 1919133ae..c476fdd28 100644 --- a/test/iriscouch/databases/databases-redis-test.js +++ b/test/iriscouch/databases/databases-redis-test.js @@ -12,6 +12,9 @@ var helpers = require('../../helpers'), http = require('http'), mock = !!process.env.MOCK; +// Declaring variables for helper functions defined later +var randomPassword; + describe('pkgcloud/iriscouch/databases-redis', function () { var context = {}, client, hockInstance, server; @@ -129,4 +132,4 @@ function randomPassword(length) { return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48); } return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48) + randomPassword(length - 1); -} \ No newline at end of file +} diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js index ec6d5f52c..a12c9ed15 100644 --- a/test/rackspace/databases/user-limit-test.js +++ b/test/rackspace/databases/user-limit-test.js @@ -14,6 +14,9 @@ var should = require('should'), User = require('../../../lib/pkgcloud/openstack/database/user').User, mock = !!process.env.MOCK; +// Declaring variables for helper functions defined later +var setupAuthenticationMock, setupGetUsersMock; + describe.skip('pkgcloud/[rackspace]/databases/users/limits', function () { var testContext = {}, client, authHockInstance, hockInstance, authServer, From ac53675eecf41448d1c77be675d4f58f83820345 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Dec 2014 12:16:44 -0800 Subject: [PATCH 275/460] Declaring variables before use (and definition). --- lib/pkgcloud/azure/utils/azureApi.js | 791 ++++++++++++++------------- 1 file changed, 399 insertions(+), 392 deletions(-) diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index 7e766cac1..450090076 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -30,70 +30,129 @@ var TABLES_ENDPOINT = exports.TABLES_ENDPOINT = 'table.core.windows.net'; var TABLES_API_VERSION = exports.TABLES_API_VERSION = '2012-02-12'; var MINIMUM_POLL_INTERVAL = exports.MINIMUM_POLL_INTERVAL = 3000; +// Declaring variables for helper functions defined later +var createVM, createLinuxVM, createWindowsVM, validateCreateOptions, getServer, + makeTemplateRequest, createHostedService, addCertificate, getHostedServices, + deleteServer, getOSImage, deleteOSDisk, deleteOSBlob, getServersFromServices, + getServersFromService, isVM, getHostedServiceProperties, pollRequestStatus, + getStorageInfoFromUri; + /** - * pollRequestStatus - * uses Get Operation Status - * GET https://management.core.windows.net//operations/ + * createServer() + * + * In order to deploy a vm, Azure requires us to do the following + * before we can actually try to create the vm. + * 1. get or create a Hosted Service (we use the same name as the vm) + * 2. resolve the OSImage url to a container on the user's account + * 3. upload SSH certificate (if necessary) + * 4. create the VM + * + * Note: creating a VM on Azure will fail if one of the following is true + * 1. The VM (with the same name) already exists + * 2. The blob storage (with the same name) for the OSImage already exists + * 3. The VM disk (with the same name) for the OSImage already exists + * 4. The storage account is in a different azure location than the vm + * (East US, West US...) + * + * Note: createServer() must wait for Azure to respond if the createDeployment (vm) + * request succeeded. createServer() asynchronously polls Azure to get + * the result. Once the result is received, the callback function will be called + * with the server information or error. The state of returned server will most likely + * be PROVISIONING or STOPPED. Use server.setWait() to continue polling the server until + * its status is RUNNING. This entire process may take several minutes. */ -var pollRequestStatus = function (client, requestId, interval, callback) { - var checkStatus = function () { - var path = client.subscriptionId + '/operations/' + requestId; - client.get(path, function (err, body, res) { - if (err) { - return callback(err); - } - switch (body.Status) { - case 'InProgress': - setTimeout(checkStatus, interval); - break; - case 'Failed': - callback(body.Error); - break; - case 'Succeeded': - callback(null); - break; - } - }); - }; - - checkStatus(); -}; - -var makeTemplateRequest = function (client, path, templateName, params, callback) { - var headers = {}, - body; +var createServer = exports.createServer = function (client, options, callback) { + var vmOptions = {}, + ssh; // async execute the following tasks one by one and bail if there is an error async.waterfall([ function (next) { - templates.load(templateName, next); + // validate createServer options + validateCreateOptions(options, client.config, next); }, - function (template, next) { - // compile template with params - body = _.template(template, params); - headers['content-length'] = body.length; - headers['content-type'] = 'application/xml'; - headers['accept'] = 'application/xml'; - client._request({ - method: 'POST', - path: path, - body: body, - headers: headers - }, function (err, body, res) { + function (next) { + getHostedServiceProperties(client, options.name, next); + }, + function (service, next) { + // if the HostedService does not exist, create it + vmOptions.hostedService = service; + if (vmOptions.hostedService === null) { + createHostedService(client, options, function (err, service) { + if (err) { + next(err); + } else { + vmOptions.hostedService = service; + next(null); + } + }); + } else { + next(null); + } + }, + function (next) { + // get the server's OSImage info + getOSImage(client, options.image, function (err, res) { if (err) { - return next(err); + next(err); + } else { + vmOptions.image = res; + next(null); } - // poll azure for result of request - pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, next); }); + }, + function (next) { + ssh = options.ssh; + if (ssh) { + vmOptions.sshCertInfo = cert.getAzureCertInfo(ssh.cert); + } + next(); + }, + function (next) { + // add the ssh certificate to the service + if (vmOptions.sshCertInfo) { + addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { + next(err); + }); + } else { + next(null); + } + }, + function (next) { + // create the VM and wait for response + createVM(client, options, vmOptions, next); + }, + function (next) { + // now get the actual server info + getServer(client, options.name, next); }], function (err, result) { - callback(err); + if (err) { + callback(err); + } else { + // return the server info + callback(null, result); + } } ); }; +var createVM = function (client, options, vmOptions, callback) { + // check OS type of image to determine if we are creating a linux or windows VM + switch (vmOptions.image.OS.toLowerCase()) { + case 'linux': + createLinuxVM(client, options, vmOptions, callback); + break; + case 'windows': + createWindowsVM(client, options, vmOptions, callback); + break; + default: + callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); + break; + } +}; + var getMediaLinkUrl = function (storageAccount, fileName) { return 'http://' + storageAccount + '.' + STORAGE_ENDPOINT + '/vhd/' + fileName; }; @@ -149,21 +208,6 @@ var createWindowsVM = function (client, options, vmOptions, callback) { makeTemplateRequest(client, path, 'windowsDeployment.xml', configParams, callback); }; -var createVM = function (client, options, vmOptions, callback) { - // check OS type of image to determine if we are creating a linux or windows VM - switch (vmOptions.image.OS.toLowerCase()) { - case 'linux': - createLinuxVM(client, options, vmOptions, callback); - break; - case 'windows': - createWindowsVM(client, options, vmOptions, callback); - break; - default: - callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); - break; - } -}; - var captureServer = function (client, serverName, targetImageName, callback) { // /services/hostedservices//deployments//roleinstances//operations var path = client.subscriptionId + '/services/hostedservices/' + @@ -207,75 +251,6 @@ var validateCreateOptions = function (options, config, callback) { callback(); }; -var isVM = function (deployment) { - if (deployment.RoleList && deployment.RoleList.Role) { - if (deployment.RoleList.Role.RoleType === 'PersistentVMRole') { - return true; - } - } - - return false; -}; - -/** - Get Hosted Service Properties - GET https://management.core.windows.net//services/hostedservices/?embed-detail=true - A successful operation returns status code 200 (OK). - */ -var getHostedServiceProperties = function (client, serviceName, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '?embed-detail=true'; - - var onError = function (err) { - return err.failCode === 'Item not found' - ? callback(null, null) - : callback(err); - }; - - client.get(path, function (err, body, res) { - return err - ? onError(err) - : callback(null, body); - }); -}; - -/** - * getServersFromService - * Retrieves all servers (VMs) from a Hosted Service - */ -var getServersFromService = function (client, serviceName, callback) { - var servers = []; - getHostedServiceProperties(client, serviceName, function (err, result) { - if (err) { - return callback(err); - } - - if (result && result.Deployments && result.Deployments.Deployment) { - if (isVM(result.Deployments.Deployment)) { - servers.push(result.Deployments.Deployment); - } - } - - callback(null, servers); - }); -}; - -/** - * getServersFromServices - * Retrieves all servers (VMs) from the list of services - */ -var getServersFromServices = function (client, services, callback) { - var task = function (service, next) { - getServersFromService(client, service.ServiceName, function (err, servers) { - next(err, servers); - }); - }; - - // Check each service for deployed VMs. - async.concat(services, task, function (err, servers) { - callback(err, servers); - }); -}; - /** * getServer */ @@ -287,283 +262,66 @@ var getServer = exports.getServer = function (client, serverName, callback) { }); }; -var createHostedService = exports.createHostedService = function (client, options, callback) { - var path = client.subscriptionId + '/services/hostedservices'; - var params = { - NAME: options.name, - LABEL_BASE64: new Buffer(options.name).toString('base64'), - LOCATION: options.location - }; - - makeTemplateRequest(client, path, 'createHostedService.xml', params, callback); +var getServers = exports.getServers = function (client, callback) { + // async execute the following tasks one by one and bail if there is an error + async.waterfall([ + function (next) { + // get the list of Hosted Services + getHostedServices(client, next); + }, + function (hostedServices, next) { + // get the list of Servers from the Hosted Services + getServersFromServices(client, hostedServices, next); + }], + function (err, servers) { + callback(err, servers); + } + ); }; -var addCertificate = function (client, serviceName, cert, password, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + - serviceName + '/certificates'; - - var params = { - CERT_BASE64: new Buffer(cert, 'utf8').toString('base64'), - PASSWORD: password - }; - - makeTemplateRequest(client, path, 'addCertificate.xml', params, callback); -}; - -var deleteServer = function (client, serverName, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + serverName; - path += '/deployments/' + serverName; - - client._request({ - method: 'DELETE', - path: path - }, function (err, body, res) { - if (err) { - return callback(err); - } - // poll azure for result of request - pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); - }); -}; - -var getStorageInfoFromUri = exports.getStorageInfoFromUri = function (uri, callback) { - var u, tokens, path, - info = {}; - - u = URL.parse(uri); - if (!u.host || !u.path) { - return callback(errs.create({message: 'invalid Azure container or blob uri'})); - } - - tokens = u.host.split('.'); - info.storage = tokens[0]; - - path = u.path; - // if necessary, remove leading '/' from path - if (path.charAt(0) === '/') { - path = path.substr(1); - } - tokens = path.split('/'); - info.container = tokens.shift(); - info.file = tokens.join('/'); - - callback(null, info); -}; - -var deleteOSBlob = function (client, server, callback) { - var blob = null; - - if (server && server.RoleList && server.RoleList.Role) { - if (server.RoleList.Role.OSVirtualHardDisk) { - blob = server.RoleList.Role.OSVirtualHardDisk.MediaLink; - } - } - - if (blob === null) { - callback(null); - return; - } - - getStorageInfoFromUri(blob, function (err, info) { - if (err) { - callback(err); - } else { - var storage = pkgcloud.storage.createClient(client.config); - storage.removeFile(info.container, info.file, function (err, result) { - callback(err); - }); - } - }); -}; - -var deleteOSDisk = function (client, server, callback) { - var diskName = null, - path; - - if (server && server.RoleList && server.RoleList.Role) { - if (server.RoleList.Role.OSVirtualHardDisk) { - diskName = server.RoleList.Role.OSVirtualHardDisk.DiskName; - } - } - - if (diskName === null) { - callback(null); - return; - } - - // https://management.core.windows.net//services/disks/ - path = client.subscriptionId + '/services/disks/' + diskName; - - client._request({ - method: 'DELETE', - path: path - }, function (err, body, res) { - if (err) { - return callback(err); - } - // poll azure for result of request - pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); - }); -}; - -var getOSImage = exports.getOSImage = function (client, imageName, callback) { - var path = '/' + client.subscriptionId + '/services/images/' + imageName; - - var onError = function (err) { - if (err.failCode === 'Item not found') { - callback(null, null); - - } else { - callback(err); - } - }; - - client.get(path, function (err, body, res) { - return err - ? onError(err) - : callback(null, body); - }); -}; - -/** - * createServer() - * - * In order to deploy a vm, Azure requires us to do the following - * before we can actually try to create the vm. - * 1. get or create a Hosted Service (we use the same name as the vm) - * 2. resolve the OSImage url to a container on the user's account - * 3. upload SSH certificate (if necessary) - * 4. create the VM - * - * Note: creating a VM on Azure will fail if one of the following is true - * 1. The VM (with the same name) already exists - * 2. The blob storage (with the same name) for the OSImage already exists - * 3. The VM disk (with the same name) for the OSImage already exists - * 4. The storage account is in a different azure location than the vm - * (East US, West US...) - * - * Note: createServer() must wait for Azure to respond if the createDeployment (vm) - * request succeeded. createServer() asynchronously polls Azure to get - * the result. Once the result is received, the callback function will be called - * with the server information or error. The state of returned server will most likely - * be PROVISIONING or STOPPED. Use server.setWait() to continue polling the server until - * its status is RUNNING. This entire process may take several minutes. - */ - -var createServer = exports.createServer = function (client, options, callback) { - var vmOptions = {}, - ssh; +var makeTemplateRequest = function (client, path, templateName, params, callback) { + var headers = {}, + body; // async execute the following tasks one by one and bail if there is an error async.waterfall([ function (next) { - // validate createServer options - validateCreateOptions(options, client.config, next); - }, - function (next) { - getHostedServiceProperties(client, options.name, next); - }, - function (service, next) { - // if the HostedService does not exist, create it - vmOptions.hostedService = service; - if (vmOptions.hostedService === null) { - createHostedService(client, options, function (err, service) { - if (err) { - next(err); - } else { - vmOptions.hostedService = service; - next(null); - } - }); - } else { - next(null); - } + templates.load(templateName, next); }, - function (next) { - // get the server's OSImage info - getOSImage(client, options.image, function (err, res) { + function (template, next) { + // compile template with params + body = _.template(template, params); + headers['content-length'] = body.length; + headers['content-type'] = 'application/xml'; + headers['accept'] = 'application/xml'; + client._request({ + method: 'POST', + path: path, + body: body, + headers: headers + }, function (err, body, res) { if (err) { - next(err); - } else { - vmOptions.image = res; - next(null); + return next(err); } + // poll azure for result of request + pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, next); }); - }, - function (next) { - ssh = options.ssh; - if (ssh) { - vmOptions.sshCertInfo = cert.getAzureCertInfo(ssh.cert); - } - next(); - }, - function (next) { - // add the ssh certificate to the service - if (vmOptions.sshCertInfo) { - addCertificate(client, options.name, vmOptions.sshCertInfo.cert, ssh.pemPassword, function (err) { - next(err); - }); - } else { - next(null); - } - }, - function (next) { - // create the VM and wait for response - createVM(client, options, vmOptions, next); - }, - function (next) { - // now get the actual server info - getServer(client, options.name, next); }], function (err, result) { - if (err) { - callback(err); - } else { - // return the server info - callback(null, result); - } + callback(err); } ); }; -var getHostedServices = exports.getHostedServices = function (client, callback) { - var path = client.subscriptionId + '/services/hostedservices', - services = []; - - client.get(path, function (err, body, res) { - if (err) { - return callback(err); - } - if (body.HostedService) { - // need to check if azure returned an array or single object - if (Array.isArray(body.HostedService)) { - body.HostedService.forEach(function (service) { - services.push(service); - }); - } else { - services.push(body.HostedService); - } - } - - callback(null, services); - }); -}; - -var getServers = exports.getServers = function (client, callback) { - // async execute the following tasks one by one and bail if there is an error - async.waterfall([ - function (next) { - // get the list of Hosted Services - getHostedServices(client, next); - }, - function (hostedServices, next) { - // get the list of Servers from the Hosted Services - getServersFromServices(client, hostedServices, next); - }], - function (err, servers) { - callback(err, servers); - } - ); +var createHostedService = exports.createHostedService = function (client, options, callback) { + var path = client.subscriptionId + '/services/hostedservices'; + var params = { + NAME: options.name, + LABEL_BASE64: new Buffer(options.name).toString('base64'), + LOCATION: options.location + }; + + makeTemplateRequest(client, path, 'createHostedService.xml', params, callback); }; /** @@ -596,6 +354,18 @@ var stopServer = exports.stopServer = function (client, serviceName, callback) { makeTemplateRequest(client, path, 'shutdownRole.xml', {}, callback); }; +var addCertificate = function (client, serviceName, cert, password, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + + serviceName + '/certificates'; + + var params = { + CERT_BASE64: new Buffer(cert, 'utf8').toString('base64'), + PASSWORD: password + }; + + makeTemplateRequest(client, path, 'addCertificate.xml', params, callback); +}; + var deleteHostedService = exports.deleteHostedService = function (client, serviceName, callback) { // DELETE https://management.core.windows.net//services/hostedservices/ var path = client.subscriptionId + '/services/hostedservices/' + serviceName; @@ -612,6 +382,29 @@ var deleteHostedService = exports.deleteHostedService = function (client, servic }); }; +var getHostedServices = exports.getHostedServices = function (client, callback) { + var path = client.subscriptionId + '/services/hostedservices', + services = []; + + client.get(path, function (err, body, res) { + if (err) { + return callback(err); + } + if (body.HostedService) { + // need to check if azure returned an array or single object + if (Array.isArray(body.HostedService)) { + body.HostedService.forEach(function (service) { + services.push(service); + }); + } else { + services.push(body.HostedService); + } + } + + callback(null, services); + }); +}; + /** * destroyServer * uses Delete Deployment @@ -652,6 +445,220 @@ var destroyServer = exports.destroyServer = function (client, serverName, callba ); }; +var deleteServer = function (client, serverName, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + serverName; + path += '/deployments/' + serverName; + + client._request({ + method: 'DELETE', + path: path + }, function (err, body, res) { + if (err) { + return callback(err); + } + // poll azure for result of request + pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); + }); +}; + +var getOSImage = exports.getOSImage = function (client, imageName, callback) { + var path = '/' + client.subscriptionId + '/services/images/' + imageName; + + var onError = function (err) { + if (err.failCode === 'Item not found') { + callback(null, null); + + } else { + callback(err); + } + }; + + client.get(path, function (err, body, res) { + return err + ? onError(err) + : callback(null, body); + }); +}; + +var deleteOSDisk = function (client, server, callback) { + var diskName = null, + path; + + if (server && server.RoleList && server.RoleList.Role) { + if (server.RoleList.Role.OSVirtualHardDisk) { + diskName = server.RoleList.Role.OSVirtualHardDisk.DiskName; + } + } + + if (diskName === null) { + callback(null); + return; + } + + // https://management.core.windows.net//services/disks/ + path = client.subscriptionId + '/services/disks/' + diskName; + + client._request({ + method: 'DELETE', + path: path + }, function (err, body, res) { + if (err) { + return callback(err); + } + // poll azure for result of request + pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, callback); + }); +}; + +var deleteOSBlob = function (client, server, callback) { + var blob = null; + + if (server && server.RoleList && server.RoleList.Role) { + if (server.RoleList.Role.OSVirtualHardDisk) { + blob = server.RoleList.Role.OSVirtualHardDisk.MediaLink; + } + } + + if (blob === null) { + callback(null); + return; + } + + getStorageInfoFromUri(blob, function (err, info) { + if (err) { + callback(err); + } else { + var storage = pkgcloud.storage.createClient(client.config); + storage.removeFile(info.container, info.file, function (err, result) { + callback(err); + }); + } + }); +}; + +/** + * getServersFromServices + * Retrieves all servers (VMs) from the list of services + */ +var getServersFromServices = function (client, services, callback) { + var task = function (service, next) { + getServersFromService(client, service.ServiceName, function (err, servers) { + next(err, servers); + }); + }; + + // Check each service for deployed VMs. + async.concat(services, task, function (err, servers) { + callback(err, servers); + }); +}; + +/** + * getServersFromServices + * Retrieves all servers (VMs) from a Hosted Service + */ +var getServersFromService = function (client, serviceName, callback) { + var servers = []; + getHostedServiceProperties(client, serviceName, function (err, result) { + if (err) { + return callback(err); + } + + if (result && result.Deployments && result.Deployments.Deployment) { + if (isVM(result.Deployments.Deployment)) { + servers.push(result.Deployments.Deployment); + } + } + + callback(null, servers); + }); +}; + +var isVM = function (deployment) { + if (deployment.RoleList && deployment.RoleList.Role) { + if (deployment.RoleList.Role.RoleType === 'PersistentVMRole') { + return true; + } + } + + return false; +}; + +/** + Get Hosted Service Properties + GET https://management.core.windows.net//services/hostedservices/?embed-detail=true + A successful operation returns status code 200 (OK). + */ +var getHostedServiceProperties = function (client, serviceName, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '?embed-detail=true'; + + var onError = function (err) { + return err.failCode === 'Item not found' + ? callback(null, null) + : callback(err); + }; + + client.get(path, function (err, body, res) { + return err + ? onError(err) + : callback(null, body); + }); +}; + +/** + * pollRequestStatus + * uses Get Operation Status + * GET https://management.core.windows.net//operations/ + */ + +var pollRequestStatus = function (client, requestId, interval, callback) { + var checkStatus = function () { + var path = client.subscriptionId + '/operations/' + requestId; + client.get(path, function (err, body, res) { + if (err) { + return callback(err); + } + switch (body.Status) { + case 'InProgress': + setTimeout(checkStatus, interval); + break; + case 'Failed': + callback(body.Error); + break; + case 'Succeeded': + callback(null); + break; + } + }); + }; + + checkStatus(); +}; + +var getStorageInfoFromUri = exports.getStorageInfoFromUri = function (uri, callback) { + var u, tokens, path, + info = {}; + + u = URL.parse(uri); + if (!u.host || !u.path) { + return callback(errs.create({message: 'invalid Azure container or blob uri'})); + } + + tokens = u.host.split('.'); + info.storage = tokens[0]; + + path = u.path; + // if necessary, remove leading '/' from path + if (path.charAt(0) === '/') { + path = path.substr(1); + } + tokens = path.split('/'); + info.container = tokens.shift(); + info.file = tokens.join('/'); + + callback(null, info); +}; + /** * createImage() * 1. Check if the server exists From cb6dcd2fc2a6dbfcd35bb9c63bdd661f51d9a33f Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Dec 2014 12:24:22 -0800 Subject: [PATCH 276/460] Defining success in terms of anonymous function to avoid late definition. --- lib/pkgcloud/azure/storage/client/files.js | 18 ++++++---------- .../openstack/storage/client/files.js | 21 +++++++------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 5003f5e91..f7fcd27ce 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -267,25 +267,19 @@ exports.uploadBlock = function(options) { }; exports.download = function (options, callback) { + var self = this, + container = options.container, + lstream, + rstream; - // - // Optional helper function passed to `this._request` - // in the case when no callback is passed to `.download(options)`. - // - function onDownload(err, body, res) { + var success = !callback ? null : function (err, body, res) { return err ? callback(err) : callback(null, new (storage.File)(self, _.extend(res.headers, { container: options.container, name: options.remote }))); - } - - var self = this, - success = callback ? onDownload : null, - container = options.container, - lstream, - rstream; + }; if (container instanceof storage.Container) { container = container.name; diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index d2ee892e0..a3feeaebc 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -180,26 +180,21 @@ exports.upload = function (options) { * @returns {request|*} */ exports.download = function (options, callback) { + var self = this, + success = callback ? onDownload : null, + container = options.container, + inputStream, + apiStream; - // - // Optional helper function passed to `this._request` - // in the case when no callback is passed to `.download(options)`. - // - function onDownload(err, body, res) { + var success = !callback ? null : function (err, body, res) { return err ? callback(err) : callback(null, new self.models.File(self, _.extend(res.headers, { container: options.container, name: options.remote }))); - } - - var self = this, - success = callback ? onDownload : null, - container = options.container, - inputStream, - apiStream; - + }; + if (container instanceof self.models.Container) { container = container.name; } From b5deef3bac4cc13c2e3326213ce090488169ee5b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 18:42:58 +0000 Subject: [PATCH 277/460] Fixing signature of callback in test to match implementation. --- test/mongolab/databases/databases-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js index 4094ddc59..528409f42 100644 --- a/test/mongolab/databases/databases-test.js +++ b/test/mongolab/databases/databases-test.js @@ -426,7 +426,7 @@ describe('pkgcloud/mongolab/databases', function () { .reply(200, ' null '); } - client.deleteAccount(context.custompw.username, function (err, databases) { + client.deleteAccount(context.custompw.username, function (err) { should.not.exist(err); hockInstance && hockInstance.done(); From f9b4670b310ac8b19abae19a977ce9d28b706f90 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 18:44:04 +0000 Subject: [PATCH 278/460] Mock responses properly using fixtures. --- test/openstack/identity/identity-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/openstack/identity/identity-test.js b/test/openstack/identity/identity-test.js index 6c1cfedd7..d4646da7a 100644 --- a/test/openstack/identity/identity-test.js +++ b/test/openstack/identity/identity-test.js @@ -154,7 +154,7 @@ describe('pkgcloud/openstack/identity', function () { }) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/realToken-admin.json')) .get('/v2.0/tokens/4bc7c5dabf3e4a49918683437d386b8a?belongsTo=72e90ecb69c44d0296072ea39e537041') - .reply(200); + .replyWithFile(200, __dirname + '/../../fixtures/openstack/validateToken-admin.json'); } var userClient = identity.createClient({ @@ -234,7 +234,7 @@ describe('pkgcloud/openstack/identity', function () { }) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/realToken-admin.json')) .get('/v2.0/tenants/72e90ecb69c44d0296072ea39e537041', { 'X-Auth-Token': '4bc7c5dabf3e4a49918683437d386b8b' }) - .reply(200) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantInfo-admin.json') .get('/v2.0/tenants/72e90ecb69c44d0296072ea39e537123', { 'X-Auth-Token': '4bc7c5dabf3e4a49918683437d386b8a' }) .reply(403); From 10ac5b5f3cec1dbe159ce9ec2c593f398231cc45 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 20:35:56 +0000 Subject: [PATCH 279/460] Removing unused module requires. --- lib/pkgcloud/amazon/client.js | 1 - lib/pkgcloud/amazon/compute/client/groups.js | 1 - lib/pkgcloud/amazon/compute/client/images.js | 1 - lib/pkgcloud/amazon/compute/client/index.js | 2 -- lib/pkgcloud/amazon/compute/client/keys.js | 3 +-- lib/pkgcloud/amazon/compute/client/servers.js | 1 - lib/pkgcloud/amazon/storage/client/files.js | 5 +---- lib/pkgcloud/amazon/storage/client/index.js | 1 - lib/pkgcloud/azure/client.js | 1 - lib/pkgcloud/azure/compute/client/images.js | 1 - lib/pkgcloud/azure/compute/client/index.js | 3 +-- lib/pkgcloud/azure/compute/client/keys.js | 3 +-- lib/pkgcloud/azure/compute/client/servers.js | 3 +-- lib/pkgcloud/azure/database/client/databases.js | 3 +-- lib/pkgcloud/azure/storage/client/containers.js | 4 +--- lib/pkgcloud/azure/storage/client/files.js | 6 +----- lib/pkgcloud/azure/storage/container.js | 1 - lib/pkgcloud/azure/utils/sharedkey.js | 2 -- lib/pkgcloud/common/auth.js | 3 +-- lib/pkgcloud/common/azure-signature.js | 5 +---- lib/pkgcloud/common/http-signature.js | 4 +--- lib/pkgcloud/core/base/client.js | 4 +--- lib/pkgcloud/core/storage/file.js | 3 +-- lib/pkgcloud/digitalocean/client.js | 2 -- lib/pkgcloud/digitalocean/compute/client/keys.js | 3 +-- .../digitalocean/compute/client/servers.js | 3 +-- lib/pkgcloud/digitalocean/compute/server.js | 1 - lib/pkgcloud/google/storage/client/files.js | 4 +--- lib/pkgcloud/hp/database/client/index.js | 1 - lib/pkgcloud/hp/identity/hpIdentity.js | 3 +-- lib/pkgcloud/joyent/compute/client/keys.js | 3 +-- lib/pkgcloud/joyent/compute/client/servers.js | 3 +-- lib/pkgcloud/joyent/compute/server.js | 3 +-- lib/pkgcloud/mongohq/database/client/index.js | 3 --- lib/pkgcloud/mongolab/database/client/accounts.js | 3 +-- lib/pkgcloud/mongolab/database/client/databases.js | 4 +--- .../openstack/blockstorage/client/snapshots.js | 3 +-- .../openstack/blockstorage/client/volumes.js | 3 +-- .../openstack/blockstorage/client/volumetypes.js | 3 +-- lib/pkgcloud/openstack/client.js | 1 - .../compute/client/extensions/floating-ips.js | 3 +-- .../openstack/compute/client/extensions/index.js | 3 +-- .../compute/client/extensions/networks.js | 3 +-- .../client/extensions/security-group-rules.js | 4 +--- .../openstack/compute/client/extensions/servers.js | 2 -- lib/pkgcloud/openstack/compute/client/servers.js | 3 +-- lib/pkgcloud/openstack/context/identity.js | 6 +----- lib/pkgcloud/openstack/context/serviceCatalog.js | 4 +--- lib/pkgcloud/openstack/database/client/index.js | 1 - lib/pkgcloud/openstack/database/client/users.js | 1 - lib/pkgcloud/openstack/identity/client/index.js | 3 +-- lib/pkgcloud/openstack/network/client/networks.js | 6 +----- lib/pkgcloud/openstack/network/client/ports.js | 6 +----- lib/pkgcloud/openstack/network/client/subnets.js | 6 +----- lib/pkgcloud/openstack/network/networkClient.js | 3 +-- .../openstack/orchestration/client/events.js | 6 +----- .../openstack/orchestration/client/resources.js | 5 +---- .../openstack/orchestration/client/stacks.js | 3 +-- .../openstack/orchestration/client/templates.js | 6 +----- .../openstack/storage/client/containers.js | 3 --- lib/pkgcloud/openstack/storage/client/files.js | 10 ++-------- lib/pkgcloud/openstack/storage/client/index.js | 1 - .../client/extensions/virtual-interfacesv2.js | 3 +-- lib/pkgcloud/rackspace/database/client/index.js | 1 - lib/pkgcloud/rackspace/dns/client/records.js | 4 +--- lib/pkgcloud/rackspace/dns/client/zones.js | 4 +--- .../rackspace/identity/rackspaceIdentity.js | 3 +-- .../rackspace/loadbalancer/client/loadbalancers.js | 4 +--- .../rackspace/loadbalancer/client/nodes.js | 4 +--- lib/pkgcloud/rackspace/network/client/index.js | 1 - .../rackspace/storage/client/cdn-containers.js | 3 --- lib/pkgcloud/rackspace/storage/client/files.js | 7 ------- test/azure/compute/client/test-createImage.js | 4 ---- test/azure/compute/client/test-destroyImage.js | 5 ----- test/azure/compute/client/test-destroyServer.js | 2 -- test/azure/compute/client/test-getImages.js | 1 - test/azure/compute/client/test-getServer.js | 1 - test/azure/compute/client/test-getServers.js | 1 - test/azure/compute/client/test-rebootServer.js | 4 +--- test/azure/compute/client/test-stopServer.js | 1 - .../azure/compute/templates/test-linuxConfigSet.js | 4 ---- test/azure/databases/test-deleteTable.js | 1 - test/azure/databases/test-getTables.js | 2 -- test/azure/storage/test-download.js | 6 ------ test/azure/storage/test-files.js | 3 --- test/azure/storage/test-removeFile.js | 3 --- test/azure/storage/test-upload.js | 3 --- test/azure/utils/test-cert.js | 1 - test/azure/utils/test-createHostedService.js | 1 - test/azure/utils/test-createServer.js | 1 - test/azure/utils/test-createWindowsServer.js | 1 - test/azure/utils/test-getOSImage.js | 1 - test/common/base/pkgcloud-test.js | 3 +-- test/common/compute/base-test.js | 4 +--- test/common/compute/meta-test.js | 7 +------ test/common/compute/server-test.js | 8 +------- test/common/compute/signature-test.js | 4 +--- test/common/network/base-test.js | 14 ++------------ test/common/network/network-test.js | 6 +----- test/common/network/port-test.js | 7 +------ test/common/network/signature-test.js | 3 +-- test/common/network/subnet-test.js | 7 +------ test/common/storage/base-test.js | 3 --- test/common/storage/upload-test.js | 13 ++----------- test/helpers/azureNock.js | 1 - test/hp/common/client-test.js | 7 +------ test/hp/macros.js | 5 +---- test/hp/storage/authentication-test.js | 1 - test/openstack/compute/client/startServer-test.js | 2 -- test/openstack/compute/client/stopServer-test.js | 2 -- test/openstack/identity/service-test.js | 3 +-- test/openstack/orchestration/create-stacks-test.js | 1 - test/openstack/orchestration/get-stacks-test.js | 1 - test/rackspace/blockstorage/volumes-test.js | 4 +--- test/rackspace/compute/image-test.js | 4 +--- test/rackspace/compute/personality-test.js | 2 -- test/rackspace/databases/user-limit-test.js | 1 - test/rackspace/macros.js | 5 +---- test/rackspace/storage/authentication-test.js | 1 - test/rackspace/storage/container-test.js | 5 +---- test/rackspace/storage/storage-object-test.js | 4 +--- 121 files changed, 71 insertions(+), 332 deletions(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index 602908d3c..617283f5d 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -7,7 +7,6 @@ var util = require('util'), AWS = require('aws-sdk'), - request = require('request'), pkgcloud = require('../../../../pkgcloud'), base = require('../core/base'); diff --git a/lib/pkgcloud/amazon/compute/client/groups.js b/lib/pkgcloud/amazon/compute/client/groups.js index e0f23bd2c..c513bbae7 100644 --- a/lib/pkgcloud/amazon/compute/client/groups.js +++ b/lib/pkgcloud/amazon/compute/client/groups.js @@ -4,7 +4,6 @@ */ var errs = require('errs'), - util = require('util'), _ = require('underscore'); // diff --git a/lib/pkgcloud/amazon/compute/client/images.js b/lib/pkgcloud/amazon/compute/client/images.js index 8f9b8b97a..cc8052fc5 100644 --- a/lib/pkgcloud/amazon/compute/client/images.js +++ b/lib/pkgcloud/amazon/compute/client/images.js @@ -6,7 +6,6 @@ */ var pkgcloud = require('../../../../../lib/pkgcloud'), base = require('../../../core/compute'), - errs = require('errs'), compute = pkgcloud.providers.amazon.compute; // diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index 5476e1d4a..82e7d4702 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -6,9 +6,7 @@ */ var AWS = require('aws-sdk'), - qs = require('querystring'), util = require('util'), - urlJoin = require('url-join'), amazon = require('../../client'), _ = require('underscore'); diff --git a/lib/pkgcloud/amazon/compute/client/keys.js b/lib/pkgcloud/amazon/compute/client/keys.js index a506e26e7..a1cc05db1 100644 --- a/lib/pkgcloud/amazon/compute/client/keys.js +++ b/lib/pkgcloud/amazon/compute/client/keys.js @@ -5,8 +5,7 @@ * */ -var errs = require('errs'), - util = require('util'); +var errs = require('errs'); // // ### function listKeys (options, callback) diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index d000b22d6..6bec5dbf4 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -5,7 +5,6 @@ * */ var async = require('async'), - request = require('request'), base = require('../../../core/compute'), pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 0540af2b3..aca20b70b 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -5,10 +5,7 @@ * */ -var fs = require('fs'), - request = require('request'), - util = require('util'), - base = require('../../../core/storage'), +var base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), through = require('through2'), storage = pkgcloud.providers.amazon.storage, diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index a9dcbbf9e..162d7c594 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -8,7 +8,6 @@ var util = require('util'), AWS = require('aws-sdk'), s3Stream = require('s3-upload-stream'), - pkgcloud = require('../../../../pkgcloud'), amazon = require('../../client'), _ = require('underscore'); diff --git a/lib/pkgcloud/azure/client.js b/lib/pkgcloud/azure/client.js index e915c2d23..9ef30a2e2 100644 --- a/lib/pkgcloud/azure/client.js +++ b/lib/pkgcloud/azure/client.js @@ -6,7 +6,6 @@ */ var util = require('util'), - request = require('request'), base = require('../core/base'); var Client = exports.Client = function (options) { diff --git a/lib/pkgcloud/azure/compute/client/images.js b/lib/pkgcloud/azure/compute/client/images.js index 075f61b88..869b80a9c 100644 --- a/lib/pkgcloud/azure/compute/client/images.js +++ b/lib/pkgcloud/azure/compute/client/images.js @@ -6,7 +6,6 @@ */ var pkgcloud = require('../../../../../lib/pkgcloud'), base = require('../../../core/compute'), - errs = require('errs'), compute = pkgcloud.providers.azure.compute, azureApi = require('../../utils/azureApi'); diff --git a/lib/pkgcloud/azure/compute/client/index.js b/lib/pkgcloud/azure/compute/client/index.js index 54883a7ee..79e488889 100644 --- a/lib/pkgcloud/azure/compute/client/index.js +++ b/lib/pkgcloud/azure/compute/client/index.js @@ -5,8 +5,7 @@ * */ -var qs = require('querystring'), - util = require('util'), +var util = require('util'), urlJoin = require('url-join'), https = require('https'), auth = require('../../../common/auth'), diff --git a/lib/pkgcloud/azure/compute/client/keys.js b/lib/pkgcloud/azure/compute/client/keys.js index 1d61125a0..73a3b7567 100644 --- a/lib/pkgcloud/azure/compute/client/keys.js +++ b/lib/pkgcloud/azure/compute/client/keys.js @@ -5,8 +5,7 @@ * */ -var errs = require('errs'), - util = require('util'); +var errs = require('errs'); // // ### function listKeys (options, callback) diff --git a/lib/pkgcloud/azure/compute/client/servers.js b/lib/pkgcloud/azure/compute/client/servers.js index 1cb1d943a..ae9cc5274 100644 --- a/lib/pkgcloud/azure/compute/client/servers.js +++ b/lib/pkgcloud/azure/compute/client/servers.js @@ -4,8 +4,7 @@ * (C) Microsoft Open Technologies, Inc. * */ -var async = require('async'), - base = require('../../../core/compute'), +var base = require('../../../core/compute'), pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), azureApi = require('../../utils/azureApi'), diff --git a/lib/pkgcloud/azure/database/client/databases.js b/lib/pkgcloud/azure/database/client/databases.js index 89c14a745..4301f6f4f 100644 --- a/lib/pkgcloud/azure/database/client/databases.js +++ b/lib/pkgcloud/azure/database/client/databases.js @@ -10,8 +10,7 @@ var errs = require('errs'), templates = require('../../utils/templates'), PATH = require('path'), xml2js = require('xml2js'), - _ = require('underscore'), - url = require('url'); + _ = require('underscore'); // Encode a uri according to Azure Table rules // ### @options {uri} The uri to encode diff --git a/lib/pkgcloud/azure/storage/client/containers.js b/lib/pkgcloud/azure/storage/client/containers.js index c505407fc..aa20ccc21 100644 --- a/lib/pkgcloud/azure/storage/client/containers.js +++ b/lib/pkgcloud/azure/storage/client/containers.js @@ -5,9 +5,7 @@ * */ -var async = require('async'), - request = require('request'), - base = require('../../../core/storage'), +var base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), storage = pkgcloud.providers.azure.storage; diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index f7fcd27ce..79ba85947 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -5,14 +5,10 @@ * */ -var fs = require('fs'), - filed = require('filed'), +var filed = require('filed'), through = require('through2'), mime = require('mime'), - request = require('request'), - util = require('util'), urlJoin = require('url-join'), - qs = require('querystring'), base = require('../../../core/storage'), AzureConstants = require('../../utils/constants'), pkgcloud = require('../../../../../lib/pkgcloud'), diff --git a/lib/pkgcloud/azure/storage/container.js b/lib/pkgcloud/azure/storage/container.js index 0e800b0fc..65d587d0c 100644 --- a/lib/pkgcloud/azure/storage/container.js +++ b/lib/pkgcloud/azure/storage/container.js @@ -6,7 +6,6 @@ */ var util = require('util'), - storage = require('../storage'), _ = require('underscore'), base = require('../../core/storage/container'); diff --git a/lib/pkgcloud/azure/utils/sharedkey.js b/lib/pkgcloud/azure/utils/sharedkey.js index aa114dd3f..7ebdbd6d8 100644 --- a/lib/pkgcloud/azure/utils/sharedkey.js +++ b/lib/pkgcloud/azure/utils/sharedkey.js @@ -20,8 +20,6 @@ // Module dependencies. var HeaderConstants = require('./constants').HeaderConstants; var HmacSha256Sign = require('./hmacsha256sign'); -var URL = require('url'); -var azureApi = require('./azureApi'); /** * Creates a new SharedKey object. diff --git a/lib/pkgcloud/common/auth.js b/lib/pkgcloud/common/auth.js index 961920aca..98ddde72e 100644 --- a/lib/pkgcloud/common/auth.js +++ b/lib/pkgcloud/common/auth.js @@ -6,8 +6,7 @@ */ var httpSignature = require('./http-signature'), - azureSignature = require('./azure-signature'), - util = require('util'); + azureSignature = require('./azure-signature'); var auth = exports; diff --git a/lib/pkgcloud/common/azure-signature.js b/lib/pkgcloud/common/azure-signature.js index d28239651..2bf8f88c6 100644 --- a/lib/pkgcloud/common/azure-signature.js +++ b/lib/pkgcloud/common/azure-signature.js @@ -5,10 +5,7 @@ * */ -var url = require('url'), - qs = require('querystring'), - https = require('https'), - azureApi = require('../azure/utils/azureApi'), +var azureApi = require('../azure/utils/azureApi'), SharedKey = require('../azure/utils/sharedkey'), SharedTableKey = require('../azure/utils/sharedkeytable'); diff --git a/lib/pkgcloud/common/http-signature.js b/lib/pkgcloud/common/http-signature.js index 46ee1fb10..bcdc869a9 100644 --- a/lib/pkgcloud/common/http-signature.js +++ b/lib/pkgcloud/common/http-signature.js @@ -8,9 +8,7 @@ * */ -var assert = require('assert'), - crypto = require('crypto'), - http = require('http'); +var crypto = require('crypto'); // // ## Globals diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index bd50e8380..0241e449d 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -5,12 +5,10 @@ * */ -var fs = require('fs'), - events = require('eventemitter2'), +var events = require('eventemitter2'), request = require('request'), util = require('util'), qs = require('qs'), - common = require('../../common'), pkgcloud = require('../../../pkgcloud'), errs = require('errs'); diff --git a/lib/pkgcloud/core/storage/file.js b/lib/pkgcloud/core/storage/file.js index d2f1a945e..517a0f6cb 100644 --- a/lib/pkgcloud/core/storage/file.js +++ b/lib/pkgcloud/core/storage/file.js @@ -5,8 +5,7 @@ * */ -var fs = require('fs'), - util = require('util'), +var util = require('util'), model = require('../base/model'), storage = require('../storage'); diff --git a/lib/pkgcloud/digitalocean/client.js b/lib/pkgcloud/digitalocean/client.js index e04690f1a..c2523c89d 100644 --- a/lib/pkgcloud/digitalocean/client.js +++ b/lib/pkgcloud/digitalocean/client.js @@ -6,8 +6,6 @@ */ var util = require('util'), - fs = require('fs'), - auth = require('../common/auth'), base = require('../core/base'); // diff --git a/lib/pkgcloud/digitalocean/compute/client/keys.js b/lib/pkgcloud/digitalocean/compute/client/keys.js index f7aa21dc8..6c32bdf6d 100644 --- a/lib/pkgcloud/digitalocean/compute/client/keys.js +++ b/lib/pkgcloud/digitalocean/compute/client/keys.js @@ -5,8 +5,7 @@ * */ -var errs = require('errs'), - util = require('util'); +var errs = require('errs'); // // ### function listKeys (callback) diff --git a/lib/pkgcloud/digitalocean/compute/client/servers.js b/lib/pkgcloud/digitalocean/compute/client/servers.js index 340fb238b..0a38fffcd 100644 --- a/lib/pkgcloud/digitalocean/compute/client/servers.js +++ b/lib/pkgcloud/digitalocean/compute/client/servers.js @@ -4,8 +4,7 @@ * (C) 2012 Nodejitsu Inc. * */ -var request = require('request'), - base = require('../../../core/compute'), +var base = require('../../../core/compute'), pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), compute = pkgcloud.providers.digitalocean.compute; diff --git a/lib/pkgcloud/digitalocean/compute/server.js b/lib/pkgcloud/digitalocean/compute/server.js index aea4f05e7..987020155 100644 --- a/lib/pkgcloud/digitalocean/compute/server.js +++ b/lib/pkgcloud/digitalocean/compute/server.js @@ -6,7 +6,6 @@ */ var util = require('util'), - compute = require('../../core/compute'), base = require('../../core/compute/server'); var Server = exports.Server = function Server(client, details) { diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index 69920e88f..9a370ab68 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -5,9 +5,7 @@ * */ -var fs = require('fs'), - util = require('util'), - pkgcloud = require('../../../../../lib/pkgcloud'), +var pkgcloud = require('../../../../../lib/pkgcloud'), through = require('through2'), storage = pkgcloud.providers.google.storage, _ = require('underscore'); diff --git a/lib/pkgcloud/hp/database/client/index.js b/lib/pkgcloud/hp/database/client/index.js index 1b4fbcf89..f811f2361 100644 --- a/lib/pkgcloud/hp/database/client/index.js +++ b/lib/pkgcloud/hp/database/client/index.js @@ -7,7 +7,6 @@ var util = require('util'), urlJoin = require('url-join'), - request = require('request'), hp = require('../../client'), auth = require('../../../common/auth.js'), _ = require('underscore'); diff --git a/lib/pkgcloud/hp/identity/hpIdentity.js b/lib/pkgcloud/hp/identity/hpIdentity.js index e57630507..8d47cecb2 100644 --- a/lib/pkgcloud/hp/identity/hpIdentity.js +++ b/lib/pkgcloud/hp/identity/hpIdentity.js @@ -6,8 +6,7 @@ * */ -var _ = require('underscore'), - identity = require('../../openstack/context'), +var identity = require('../../openstack/context'), events = require('eventemitter2'), Identity = identity.Identity, util = require('util'); diff --git a/lib/pkgcloud/joyent/compute/client/keys.js b/lib/pkgcloud/joyent/compute/client/keys.js index 3dbfc2bef..b636b879e 100644 --- a/lib/pkgcloud/joyent/compute/client/keys.js +++ b/lib/pkgcloud/joyent/compute/client/keys.js @@ -5,8 +5,7 @@ * */ -var errs = require('errs'), - util = require('util'); +var errs = require('errs'); // // ### function listKeys (callback) diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index d09ebbec5..28beb1720 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -4,8 +4,7 @@ * (C) 2012 Nodejitsu Inc. * */ -var request = require('request'), - base = require('../../../core/compute'), +var base = require('../../../core/compute'), pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), compute = pkgcloud.providers.joyent.compute; diff --git a/lib/pkgcloud/joyent/compute/server.js b/lib/pkgcloud/joyent/compute/server.js index 05f71237e..1810a9802 100644 --- a/lib/pkgcloud/joyent/compute/server.js +++ b/lib/pkgcloud/joyent/compute/server.js @@ -7,8 +7,7 @@ var util = require('util'), compute = require('../../core/compute'), - base = require('../../core/compute/server'), - computeStatus = require('../../common/status').compute; + base = require('../../core/compute/server'); var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); diff --git a/lib/pkgcloud/mongohq/database/client/index.js b/lib/pkgcloud/mongohq/database/client/index.js index d23f9fd84..cbffb27ad 100644 --- a/lib/pkgcloud/mongohq/database/client/index.js +++ b/lib/pkgcloud/mongohq/database/client/index.js @@ -9,9 +9,6 @@ var util = require('util'), urlJoin = require('url-join'), base = require('../../../core/base'), auth = require('../../../common/auth'), - url = require('url'), - request = require('request'), - errs = require('errs'), _ = require('underscore'); var Client = exports.Client = function (options) { diff --git a/lib/pkgcloud/mongolab/database/client/accounts.js b/lib/pkgcloud/mongolab/database/client/accounts.js index 922088d34..e066286d5 100644 --- a/lib/pkgcloud/mongolab/database/client/accounts.js +++ b/lib/pkgcloud/mongolab/database/client/accounts.js @@ -5,8 +5,7 @@ * */ -var pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'); +var errs = require('errs'); // Create Account // ### @options {Object} Set of options can be diff --git a/lib/pkgcloud/mongolab/database/client/databases.js b/lib/pkgcloud/mongolab/database/client/databases.js index 1ab883ce0..8505c6c27 100644 --- a/lib/pkgcloud/mongolab/database/client/databases.js +++ b/lib/pkgcloud/mongolab/database/client/databases.js @@ -5,9 +5,7 @@ * */ -var pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), - qs = require('querystring'), +var errs = require('errs'), url = require('url'); diff --git a/lib/pkgcloud/openstack/blockstorage/client/snapshots.js b/lib/pkgcloud/openstack/blockstorage/client/snapshots.js index a0fddec4d..13e492f4f 100644 --- a/lib/pkgcloud/openstack/blockstorage/client/snapshots.js +++ b/lib/pkgcloud/openstack/blockstorage/client/snapshots.js @@ -7,8 +7,7 @@ * * */ -var errs = require('errs'), - Snapshot = require('../snapshot').Snapshot, +var Snapshot = require('../snapshot').Snapshot, urlJoin = require('url-join'); var _urlPrefix = 'snapshots'; diff --git a/lib/pkgcloud/openstack/blockstorage/client/volumes.js b/lib/pkgcloud/openstack/blockstorage/client/volumes.js index 106151af3..4937b76b2 100644 --- a/lib/pkgcloud/openstack/blockstorage/client/volumes.js +++ b/lib/pkgcloud/openstack/blockstorage/client/volumes.js @@ -7,8 +7,7 @@ * * */ -var errs = require('errs'), - Volume = require('../volume').Volume, +var Volume = require('../volume').Volume, VolumeType = require('../volumetype').VolumeType, urlJoin = require('url-join'); diff --git a/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js b/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js index 438b668ed..18e54d8b9 100644 --- a/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js +++ b/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js @@ -7,8 +7,7 @@ * * */ -var errs = require('errs'), - VolumeType = require('../volumetype').VolumeType, +var VolumeType = require('../volumetype').VolumeType, urlJoin = require('url-join'); var _urlPrefix = 'types'; diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 8c10cb3d5..193979933 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -6,7 +6,6 @@ */ var util = require('util'), - request = require('request'), through = require('through2'), base = require('../core/base'), errs = require('errs'), diff --git a/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js b/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js index 00fd6b929..54bb1668e 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/floating-ips.js @@ -7,8 +7,7 @@ * */ -var Server = require('../../server').Server, - urlJoin = require('url-join'); +var urlJoin = require('url-join'); var _extension = 'os-floating-ips'; diff --git a/lib/pkgcloud/openstack/compute/client/extensions/index.js b/lib/pkgcloud/openstack/compute/client/extensions/index.js index 2ed95e588..20bbba366 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/index.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/index.js @@ -8,8 +8,7 @@ * (updated by Alvaro M. Reol) */ -var util = require('util'), - _ = require('underscore'); +var _ = require('underscore'); var extensions = { getExtensions: function(callback) { diff --git a/lib/pkgcloud/openstack/compute/client/extensions/networks.js b/lib/pkgcloud/openstack/compute/client/extensions/networks.js index 862648437..1d2f3deb8 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/networks.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/networks.js @@ -8,7 +8,6 @@ * */ -var urlJoin = require('url-join'), - networks = require('./networks-base'); +var networks = require('./networks-base'); module.exports = networks.createNetworkExtension('os-networks'); diff --git a/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js b/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js index 291946bd8..2ec96d753 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js @@ -5,9 +5,7 @@ * */ -var urlJoin = require('url-join'), - _ = require('underscore'), - async = require('async'); +var async = require('async'); var _extension = 'os-security-group-rules'; diff --git a/lib/pkgcloud/openstack/compute/client/extensions/servers.js b/lib/pkgcloud/openstack/compute/client/extensions/servers.js index cc099330b..c72997592 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/servers.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/servers.js @@ -7,8 +7,6 @@ * */ -var Server = require('../../server').Server, - urlJoin = require('url-join'); var _extension = 'servers'; diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index d8a713bfd..8407eef6d 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -4,8 +4,7 @@ * (C) 2013 Nodejitsu Inc. * */ -var request = require('request'), - base = require('../../../core/compute'), +var base = require('../../../core/compute'), pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), urlJoin = require('url-join'), diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index 5570a48b1..f6333946b 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -8,15 +8,11 @@ var _ = require('underscore'), events = require('eventemitter2'), - fs = require('fs'), request = require('request'), ServiceCatalog = require('./serviceCatalog').ServiceCatalog, - svcCat = require('./serviceCatalog'), - url = require('url'), urlJoin = require('url-join'), util = require('util'), - pkgcloud = require('../../../pkgcloud'), - errs = require('errs'); + pkgcloud = require('../../../pkgcloud'); // TODO refactor failCodes, getError into global handlers var failCodes = { diff --git a/lib/pkgcloud/openstack/context/serviceCatalog.js b/lib/pkgcloud/openstack/context/serviceCatalog.js index 91b3f41cc..4f045565d 100644 --- a/lib/pkgcloud/openstack/context/serviceCatalog.js +++ b/lib/pkgcloud/openstack/context/serviceCatalog.js @@ -6,9 +6,7 @@ * */ -var service = require('./service'), - Service = require('./service').Service, - async = require('async'), +var Service = require('./service').Service, _ = require('underscore'); /** diff --git a/lib/pkgcloud/openstack/database/client/index.js b/lib/pkgcloud/openstack/database/client/index.js index bfb54fd7c..f51a0bbd1 100644 --- a/lib/pkgcloud/openstack/database/client/index.js +++ b/lib/pkgcloud/openstack/database/client/index.js @@ -7,7 +7,6 @@ var util = require('util'), urlJoin = require('url-join'), - request = require('request'), rackspace = require('../../client'), auth = require('../../../common/auth.js'), _ = require('underscore'); diff --git a/lib/pkgcloud/openstack/database/client/users.js b/lib/pkgcloud/openstack/database/client/users.js index eda92379c..65f77e328 100644 --- a/lib/pkgcloud/openstack/database/client/users.js +++ b/lib/pkgcloud/openstack/database/client/users.js @@ -10,7 +10,6 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), Instance = pkgcloud.providers.rackspace.database.Instance, User = pkgcloud.providers.rackspace.database.User, errs = require('errs'), - async = require('async'), qs = require('querystring'); // Create a User(s) for a Database. diff --git a/lib/pkgcloud/openstack/identity/client/index.js b/lib/pkgcloud/openstack/identity/client/index.js index 3e532382f..1c2ebb713 100644 --- a/lib/pkgcloud/openstack/identity/client/index.js +++ b/lib/pkgcloud/openstack/identity/client/index.js @@ -8,8 +8,7 @@ var util = require('util'), urlJoin = require('url-join'), - openstack = require('../../client'), - _ = require('underscore'); + openstack = require('../../client'); var Client = exports.Client = function (options) { openstack.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 262910a3c..44ea02139 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -6,11 +6,7 @@ * */ -var async = require('async'), - request = require('request'), - pkgcloud = require('../../../../pkgcloud'), - urlJoin = require('url-join'), - _ = require('underscore'); +var urlJoin = require('url-join'); var networksResourcePath = '/networks'; diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index 40445a2e3..c6526650c 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -6,11 +6,7 @@ * */ -var async = require('async'), - request = require('request'), - pkgcloud = require('../../../../pkgcloud'), - urlJoin = require('url-join'), - _ = require('underscore'); +var urlJoin = require('url-join'); var portsResourcePath = '/ports'; diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index 4bff2d4f8..403a1eaf6 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -6,11 +6,7 @@ * */ -var async = require('async'), - request = require('request'), - pkgcloud = require('../../../../pkgcloud'), - urlJoin = require('url-join'), - _ = require('underscore'); +var urlJoin = require('url-join'); var subnetsResourcePath = '/subnets'; diff --git a/lib/pkgcloud/openstack/network/networkClient.js b/lib/pkgcloud/openstack/network/networkClient.js index 3b31be306..d98763a4f 100644 --- a/lib/pkgcloud/openstack/network/networkClient.js +++ b/lib/pkgcloud/openstack/network/networkClient.js @@ -5,8 +5,7 @@ * */ -var urlJoin = require('url-join'), - _ = require('underscore'); +var urlJoin = require('url-join'); var Client = exports.NetworkClient = function () { this.serviceType = 'network'; diff --git a/lib/pkgcloud/openstack/orchestration/client/events.js b/lib/pkgcloud/openstack/orchestration/client/events.js index 447578910..8b0a7c862 100644 --- a/lib/pkgcloud/openstack/orchestration/client/events.js +++ b/lib/pkgcloud/openstack/orchestration/client/events.js @@ -5,12 +5,8 @@ * Ken Perkins * MIT LICENSE */ -var request = require('request'), - pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), +var pkgcloud = require('../../../../../lib/pkgcloud'), urlJoin = require('url-join'), - util = require('util'), - _ = require('underscore'), orchestration = pkgcloud.providers.openstack.orchestration; var _urlPrefix = '/stacks'; diff --git a/lib/pkgcloud/openstack/orchestration/client/resources.js b/lib/pkgcloud/openstack/orchestration/client/resources.js index bdecf3f60..a3641ca46 100644 --- a/lib/pkgcloud/openstack/orchestration/client/resources.js +++ b/lib/pkgcloud/openstack/orchestration/client/resources.js @@ -5,11 +5,8 @@ * Ken Perkins * MIT LICENSE */ -var request = require('request'), - pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), +var pkgcloud = require('../../../../../lib/pkgcloud'), urlJoin = require('url-join'), - util = require('util'), _ = require('underscore'), orchestration = pkgcloud.providers.openstack.orchestration; diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index 96abf471f..fc5879a69 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -6,8 +6,7 @@ * MIT LICENSE */ -var request = require('request'), - pkgcloud = require('../../../../../lib/pkgcloud'), +var pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), urlJoin = require('url-join'), util = require('util'), diff --git a/lib/pkgcloud/openstack/orchestration/client/templates.js b/lib/pkgcloud/openstack/orchestration/client/templates.js index 95d054494..c4482234b 100644 --- a/lib/pkgcloud/openstack/orchestration/client/templates.js +++ b/lib/pkgcloud/openstack/orchestration/client/templates.js @@ -5,12 +5,8 @@ * Ken Perkins * MIT LICENSE */ -var request = require('request'), - pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), +var pkgcloud = require('../../../../../lib/pkgcloud'), urlJoin = require('url-join'), - util = require('util'), - _ = require('underscore'), orchestration = pkgcloud.providers.openstack.orchestration; var _urlPrefix = '/stacks'; diff --git a/lib/pkgcloud/openstack/storage/client/containers.js b/lib/pkgcloud/openstack/storage/client/containers.js index fdaeb2d78..82f3852de 100644 --- a/lib/pkgcloud/openstack/storage/client/containers.js +++ b/lib/pkgcloud/openstack/storage/client/containers.js @@ -8,9 +8,6 @@ */ var async = require('async'), - request = require('request'), - base = require('../../../core/storage'), - pkgcloud = require('../../../../pkgcloud'), _ = require('underscore'); /** diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index a3feeaebc..a422b0ac7 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -6,18 +6,12 @@ * */ -var fs = require('fs'), - filed = require('filed'), +var filed = require('filed'), mime = require('mime'), - request = require('request'), - util = require('util'), base = require('../../../core/storage'), - pkgcloud = require('../../../../pkgcloud'), - errs = require('errs'), through = require('through2'), _ = require('underscore'), - urlJoin = require('url-join'), - storage = pkgcloud.providers.openstack.storage; + urlJoin = require('url-join'); /** * client.removeFile diff --git a/lib/pkgcloud/openstack/storage/client/index.js b/lib/pkgcloud/openstack/storage/client/index.js index 8fa11ef4c..d524280b8 100644 --- a/lib/pkgcloud/openstack/storage/client/index.js +++ b/lib/pkgcloud/openstack/storage/client/index.js @@ -7,7 +7,6 @@ */ var util = require('util'), - urlJoin = require('url-join'), openstack = require('../../client'), StorageClient = require('../storageClient').StorageClient, _ = require('underscore'); diff --git a/lib/pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js b/lib/pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js index 7121b424c..99935c9ed 100644 --- a/lib/pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js +++ b/lib/pkgcloud/rackspace/compute/client/extensions/virtual-interfacesv2.js @@ -9,8 +9,7 @@ */ var Server = require('../../server').Server, - urlJoin = require('url-join'), - _ = require('underscore'); + urlJoin = require('url-join'); var _servers = 'servers', _extension = 'os-virtual-interfacesv2'; diff --git a/lib/pkgcloud/rackspace/database/client/index.js b/lib/pkgcloud/rackspace/database/client/index.js index 617476f78..4945fe569 100644 --- a/lib/pkgcloud/rackspace/database/client/index.js +++ b/lib/pkgcloud/rackspace/database/client/index.js @@ -7,7 +7,6 @@ var util = require('util'), urlJoin = require('url-join'), - request = require('request'), rackspace = require('../../client'), auth = require('../../../common/auth.js'), _ = require('underscore'); diff --git a/lib/pkgcloud/rackspace/dns/client/records.js b/lib/pkgcloud/rackspace/dns/client/records.js index 2ac118179..d5f2982db 100644 --- a/lib/pkgcloud/rackspace/dns/client/records.js +++ b/lib/pkgcloud/rackspace/dns/client/records.js @@ -7,10 +7,8 @@ * */ -var base = require('../../../core/dns'), - urlJoin = require('url-join'), +var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), _ = require('underscore'), dns = pkgcloud.providers.rackspace.dns; diff --git a/lib/pkgcloud/rackspace/dns/client/zones.js b/lib/pkgcloud/rackspace/dns/client/zones.js index 59ea44dd6..c6e53a1d6 100644 --- a/lib/pkgcloud/rackspace/dns/client/zones.js +++ b/lib/pkgcloud/rackspace/dns/client/zones.js @@ -7,10 +7,8 @@ * */ -var base = require('../../../core/dns'), - urlJoin = require('url-join'), +var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), _ = require('underscore'), dns = pkgcloud.providers.rackspace.dns; diff --git a/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js b/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js index b518016ff..49373f6f2 100644 --- a/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js +++ b/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js @@ -7,8 +7,7 @@ * */ -var _ = require('underscore'), - identity = require('../../openstack/context'), +var identity = require('../../openstack/context'), events = require('eventemitter2'), Identity = identity.Identity, util = require('util'); diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js index b622e73a9..e024bfc9b 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js @@ -7,10 +7,8 @@ * */ -var base = require('../../../core/dns'), - urlJoin = require('url-join'), +var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), _ = require('underscore'), lb = pkgcloud.providers.rackspace.loadbalancer; diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js index 2c5754bec..cfffa79f2 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js @@ -7,10 +7,8 @@ * */ -var base = require('../../../core/dns'), - urlJoin = require('url-join'), +var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), _ = require('underscore'), lb = pkgcloud.providers.rackspace.loadbalancer; diff --git a/lib/pkgcloud/rackspace/network/client/index.js b/lib/pkgcloud/rackspace/network/client/index.js index f18a70f43..24ea3ba10 100644 --- a/lib/pkgcloud/rackspace/network/client/index.js +++ b/lib/pkgcloud/rackspace/network/client/index.js @@ -9,7 +9,6 @@ var util = require('util'), rackspace = require('../../client'), NetworkClient = require('../../../openstack/network/networkClient').NetworkClient, - urlJoin = require('url-join'), _ = require('underscore'); var Client = exports.Client = function (options) { diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 8dbb5fcbe..600587a40 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -7,9 +7,6 @@ var async = require('async'), crypto = require('crypto'), - request = require('request'), - base = require('../../../openstack'), - pkgcloud = require('../../../../pkgcloud'), _ = require('underscore'); /** diff --git a/lib/pkgcloud/rackspace/storage/client/files.js b/lib/pkgcloud/rackspace/storage/client/files.js index 498b83dc9..795f1e765 100644 --- a/lib/pkgcloud/rackspace/storage/client/files.js +++ b/lib/pkgcloud/rackspace/storage/client/files.js @@ -6,13 +6,6 @@ * */ -var fs = require('fs'), - request = require('request'), - util = require('util'), - base = require('../../../core/storage'), - pkgcloud = require('../../../../pkgcloud'), - _ = require('underscore'); - // // ### function purgeFileFromCdn (container, file, emails, callback) // #### @container {string} Name of the container to destroy the file in diff --git a/test/azure/compute/client/test-createImage.js b/test/azure/compute/client/test-createImage.js index e5c7144b6..a3f55422f 100644 --- a/test/azure/compute/client/test-createImage.js +++ b/test/azure/compute/client/test-createImage.js @@ -1,11 +1,7 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); -var fs = require('fs'); -var async = require('async'); - var client = helpers.createClient('azure', 'compute'); var options = { diff --git a/test/azure/compute/client/test-destroyImage.js b/test/azure/compute/client/test-destroyImage.js index 8cdb4ac0c..6a578e6d7 100644 --- a/test/azure/compute/client/test-destroyImage.js +++ b/test/azure/compute/client/test-destroyImage.js @@ -1,14 +1,9 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); -var fs = require('fs'); -var async = require('async'); - var client = helpers.createClient('azure', 'compute'); - client.destroyImage('pkgcloud1', function (err, result) { if (err) { console.dir(err); diff --git a/test/azure/compute/client/test-destroyServer.js b/test/azure/compute/client/test-destroyServer.js index 6063a56e1..871fcd5e5 100644 --- a/test/azure/compute/client/test-destroyServer.js +++ b/test/azure/compute/client/test-destroyServer.js @@ -1,8 +1,6 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); -var pkgcloud = require('../../../../lib/pkgcloud'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/compute/client/test-getImages.js b/test/azure/compute/client/test-getImages.js index 25e899435..2dfa38b6f 100644 --- a/test/azure/compute/client/test-getImages.js +++ b/test/azure/compute/client/test-getImages.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/compute/client/test-getServer.js b/test/azure/compute/client/test-getServer.js index d232b2a87..de0bcad82 100644 --- a/test/azure/compute/client/test-getServer.js +++ b/test/azure/compute/client/test-getServer.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/compute/client/test-getServers.js b/test/azure/compute/client/test-getServers.js index 7193abbc1..67d623c1e 100644 --- a/test/azure/compute/client/test-getServers.js +++ b/test/azure/compute/client/test-getServers.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/compute/client/test-rebootServer.js b/test/azure/compute/client/test-rebootServer.js index 915a24af7..945467ea4 100644 --- a/test/azure/compute/client/test-rebootServer.js +++ b/test/azure/compute/client/test-rebootServer.js @@ -5,9 +5,7 @@ * */ -var fs = require('fs'), - path = require('path'), - vows = require('vows'), +var vows = require('vows'), assert = require('../../../helpers/assert'), helpers = require('../../../helpers'), azureNock = require('../../../helpers/azureNock'), diff --git a/test/azure/compute/client/test-stopServer.js b/test/azure/compute/client/test-stopServer.js index 688f577b7..71c675d66 100644 --- a/test/azure/compute/client/test-stopServer.js +++ b/test/azure/compute/client/test-stopServer.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/compute/templates/test-linuxConfigSet.js b/test/azure/compute/templates/test-linuxConfigSet.js index 217c4af4a..9495bebd4 100644 --- a/test/azure/compute/templates/test-linuxConfigSet.js +++ b/test/azure/compute/templates/test-linuxConfigSet.js @@ -1,12 +1,8 @@ //TODO: Make this a vows test -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; -var helpers = require('../../../helpers'); var templates = require('../../../../lib/pkgcloud/azure/compute/templates/templates'); var _ = require('underscore'); -var fs = require('fs'); - var params = { HOSTNAME: 'pkgcloud1', USERNAME: 'pkgcloud', diff --git a/test/azure/databases/test-deleteTable.js b/test/azure/databases/test-deleteTable.js index c5fab9c8e..1788a4cc2 100644 --- a/test/azure/databases/test-deleteTable.js +++ b/test/azure/databases/test-deleteTable.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var client = helpers.createClient('azure', 'database'); diff --git a/test/azure/databases/test-getTables.js b/test/azure/databases/test-getTables.js index b799b5bea..dfc6547a4 100644 --- a/test/azure/databases/test-getTables.js +++ b/test/azure/databases/test-getTables.js @@ -1,11 +1,9 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var client = helpers.createClient('azure', 'database'); - client.list(function (err, res) { if (err) { console.dir(err); diff --git a/test/azure/storage/test-download.js b/test/azure/storage/test-download.js index 18c1d478c..ea7635456 100644 --- a/test/azure/storage/test-download.js +++ b/test/azure/storage/test-download.js @@ -1,9 +1,6 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); -var fs = require('fs'); -var async = require('async'); var client = helpers.createClient('azure', 'storage'); @@ -12,9 +9,6 @@ var options = { remote: 'test-file.txt' }; - - - var stream = client.download(options, function (err, res) { if (err) { console.dir(err); diff --git a/test/azure/storage/test-files.js b/test/azure/storage/test-files.js index 96d47c4be..43c7a663a 100644 --- a/test/azure/storage/test-files.js +++ b/test/azure/storage/test-files.js @@ -1,12 +1,9 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); -var async = require('async'); var client = helpers.createClient('azure', 'storage'); - client.getFile('pkgcloud-test-container', 'test-file.txt', function (err, res) { if (err) { console.dir(err); diff --git a/test/azure/storage/test-removeFile.js b/test/azure/storage/test-removeFile.js index 244c5fc35..9489a5eb8 100644 --- a/test/azure/storage/test-removeFile.js +++ b/test/azure/storage/test-removeFile.js @@ -1,12 +1,9 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); -var async = require('async'); var client = helpers.createClient('azure', 'storage'); - client.removeFile('pkgcloud-test-container', 'test-file.txt', function (err, res) { if (err) { console.dir(err); diff --git a/test/azure/storage/test-upload.js b/test/azure/storage/test-upload.js index 3b43f46ec..c7183c7db 100644 --- a/test/azure/storage/test-upload.js +++ b/test/azure/storage/test-upload.js @@ -1,9 +1,7 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var fs = require('fs'); -var async = require('async'); var client = helpers.createClient('azure', 'storage'); @@ -12,7 +10,6 @@ var options = { remote: 'test-file.txt' }; - var stream = client.upload(options, function (err, res) { if (err) { console.dir(err); diff --git a/test/azure/utils/test-cert.js b/test/azure/utils/test-cert.js index e7c19f5d0..b68e9f6a4 100644 --- a/test/azure/utils/test-cert.js +++ b/test/azure/utils/test-cert.js @@ -1,5 +1,4 @@ //TODO: Make this a vows test -var fs = require('fs'); var azureCert = require('../../../lib/pkgcloud/azure/utils/cert.js'); diff --git a/test/azure/utils/test-createHostedService.js b/test/azure/utils/test-createHostedService.js index 20fa84f05..9affe7aa1 100644 --- a/test/azure/utils/test-createHostedService.js +++ b/test/azure/utils/test-createHostedService.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/utils/test-createServer.js b/test/azure/utils/test-createServer.js index dc7ce09ec..a998bdf41 100644 --- a/test/azure/utils/test-createServer.js +++ b/test/azure/utils/test-createServer.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/utils/test-createWindowsServer.js b/test/azure/utils/test-createWindowsServer.js index 038a2adcb..59f119a6a 100644 --- a/test/azure/utils/test-createWindowsServer.js +++ b/test/azure/utils/test-createWindowsServer.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/azure/utils/test-getOSImage.js b/test/azure/utils/test-getOSImage.js index 16fec27f2..65c775565 100644 --- a/test/azure/utils/test-getOSImage.js +++ b/test/azure/utils/test-getOSImage.js @@ -1,6 +1,5 @@ //TODO: Make this a vows test -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'); var client = helpers.createClient('azure', 'compute'); diff --git a/test/common/base/pkgcloud-test.js b/test/common/base/pkgcloud-test.js index aae497d30..b38e476ea 100644 --- a/test/common/base/pkgcloud-test.js +++ b/test/common/base/pkgcloud-test.js @@ -1,5 +1,4 @@ -var should = require('should'), - pkgcloud = require('../../../lib/pkgcloud'); +var pkgcloud = require('../../../lib/pkgcloud'); describe('pkgcloud/pkgcloud', function() { it('should throw an Error when the provider is not supported', function() { diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index a63718005..7e82d0d50 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -5,9 +5,7 @@ * */ -var fs = require('fs'), - path = require('path'), - should = require('should'), +var should = require('should'), qs = require('qs'), util = require('util'), async = require('async'), diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index d4ce121fa..2af6a73d3 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -5,17 +5,12 @@ * */ -var fs = require('fs'), - path = require('path'), - qs = require('qs'), - should = require('should'), +var should = require('should'), helpers = require('../../helpers'), http = require('http'), hock = require('hock'), async = require('async'), - _ = require('underscore'), Image = require('../../../lib/pkgcloud/core/compute/image').Image, - pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; // Declaring variables for helper functions defined later diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 0d4dc5395..04585a84d 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -5,22 +5,16 @@ * */ -var fs = require('fs'), - path = require('path'), - qs = require('qs'), +var qs = require('qs'), should = require('should'), - util = require('util'), async = require('async'), helpers = require('../../helpers'), http = require('http'), hock = require('hock'), _ = require('underscore'), providers = require('../../configs/providers.json'), - Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, - Image = require('../../../lib/pkgcloud/core/compute/image').Image, Server = require('../../../lib/pkgcloud/core/compute/server').Server, azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'), - pkgcloud = require('../../../lib/pkgcloud'), mock = !!process.env.MOCK; var azureOptions = require('../../fixtures/azure/azure-options.json'); diff --git a/test/common/compute/signature-test.js b/test/common/compute/signature-test.js index 3b53323f9..2f072b10e 100644 --- a/test/common/compute/signature-test.js +++ b/test/common/compute/signature-test.js @@ -7,9 +7,7 @@ var should = require('should'), providers = require('../../configs/providers.json'), - pkgcloud = require('../../../lib/pkgcloud'), - helpers = require('../../helpers'), - _ = require('underscore'); + helpers = require('../../helpers'); providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].compute; diff --git a/test/common/network/base-test.js b/test/common/network/base-test.js index 56ad8570d..39b24a42e 100644 --- a/test/common/network/base-test.js +++ b/test/common/network/base-test.js @@ -5,19 +5,9 @@ * */ -var fs = require('fs'), - path = require('path'), - should = require('should'), - qs = require('qs'), - util = require('util'), - async = require('async'), +var should = require('should'), helpers = require('../../helpers'), - hock = require('hock'), - _ = require('underscore'), - providers = require('../../configs/providers.json'), - versions = require('../../fixtures/versions.json'), - pkgcloud = require('../../../lib/pkgcloud'), - mock = !!process.env.MOCK; + providers = require('../../configs/providers.json'); providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].network; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 9008069af..d0630382d 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -5,11 +5,7 @@ * */ -var fs = require('fs'), - path = require('path'), - qs = require('qs'), - should = require('should'), - util = require('util'), +var should = require('should'), async = require('async'), helpers = require('../../helpers'), http = require('http'), diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index b7f19d2ba..22b52c888 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -5,16 +5,11 @@ * */ -var fs = require('fs'), - path = require('path'), - qs = require('qs'), - should = require('should'), - util = require('util'), +var should = require('should'), async = require('async'), helpers = require('../../helpers'), hock = require('hock'), http = require('http'), - _ = require('underscore'), providers = require('../../configs/providers.json'), Port = require('../../../lib/pkgcloud/core/network/port').Port, mock = !!process.env.MOCK, diff --git a/test/common/network/signature-test.js b/test/common/network/signature-test.js index 546ee88f9..843cef022 100644 --- a/test/common/network/signature-test.js +++ b/test/common/network/signature-test.js @@ -7,8 +7,7 @@ var should = require('should'), providers = require('../../configs/providers.json'), - helpers = require('../../helpers'), - _ = require('underscore'); + helpers = require('../../helpers'); providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].network; diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index 812072eb5..c88030fee 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -5,16 +5,11 @@ * */ -var fs = require('fs'), - path = require('path'), - qs = require('qs'), - should = require('should'), - util = require('util'), +var should = require('should'), async = require('async'), helpers = require('../../helpers'), http = require('http'), hock = require('hock'), - _ = require('underscore'), providers = require('../../configs/providers.json'), Subnet = require('../../../lib/pkgcloud/core/network/subnet').Subnet, mock = !!process.env.MOCK, diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index ad2a89eb0..ddb0ada6e 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -6,7 +6,6 @@ */ var fs = require('fs'), - path = require('path'), Buffer = require('buffer').Buffer, assert = require('../../helpers/assert'), helpers = require('../../helpers'), @@ -16,11 +15,9 @@ var fs = require('fs'), hock = require('hock'), http = require('http'), urlJoin = require('url-join'), - _ = require('underscore'), request = require('request'), through = require('through2'), providers = require('../../configs/providers.json'), - versions = require('../../fixtures/versions.json'), Container = require('../../../lib/pkgcloud/core/storage/container').Container, File = require('../../../lib/pkgcloud/core/storage/file').File, mock = !!process.env.MOCK, diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index 07b50e160..e3dfc9bea 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -5,25 +5,16 @@ * */ -var fs = require('fs'), - path = require('path'), - Buffer = require('buffer').Buffer, - assert = require('../../helpers/assert'), - helpers = require('../../helpers'), +var helpers = require('../../helpers'), should = require('should'), util = require('util'), async = require('async'), hock = require('hock'), http = require('http'), urlJoin = require('url-join'), - _ = require('underscore'), providers = require('../../configs/providers.json'), - versions = require('../../fixtures/versions.json'), - Container = require('../../../lib/pkgcloud/core/storage/container').Container, - File = require('../../../lib/pkgcloud/core/storage/file').File, mock = !!process.env.MOCK, - pkgcloud = require('../../../lib/pkgcloud'), - fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); + pkgcloud = require('../../../lib/pkgcloud'); // Declaring variables for helper functions defined later var setupUploadStreamError; diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index 7745d2066..c559404e9 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -25,7 +25,6 @@ var azureApi = require('../../lib/pkgcloud/azure/utils/azureApi'), _ = require('underscore'), requestId = 'b67cc525-ecc5-4661-8fd6-fb3e57d724f5', - PATH = require('path'), helpers; // Declaring variables for helper functions defined later diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js index 222058923..d224a0a05 100644 --- a/test/hp/common/client-test.js +++ b/test/hp/common/client-test.js @@ -5,16 +5,11 @@ * */ -var should = require('should'), - async = require('async'), - hock = require('hock'), - pkgcloud = require('../../../lib/pkgcloud'), - mock = !!process.env.MOCK; +var pkgcloud = require('../../../lib/pkgcloud'); describe('pkgcloud/hp/client', function () { describe('Region validation', function () { - var eastUSRegion = 'region-b.geo-1', westUSRegion='region-a.geo-1'; it('User should specify region: compute client', function() { (function () { pkgcloud.compute.createClient({ diff --git a/test/hp/macros.js b/test/hp/macros.js index 0a1225c45..910703197 100644 --- a/test/hp/macros.js +++ b/test/hp/macros.js @@ -7,10 +7,7 @@ var fs = require('fs'), filed = require('filed'), - assert = require('../helpers/assert'), - should = require('should'), - helpers = require('../helpers'), - mock = !!process.env.MOCK; + assert = require('../helpers/assert'); exports.shouldHaveCreds = function (client) { return function () { diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index bdfd92c7c..380de8355 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -8,7 +8,6 @@ var should = require('should'), macros = require('../macros'), helpers = require('../../helpers'), - async = require('async'), hock = require('hock'), http = require('http'), mock = !!process.env.MOCK; diff --git a/test/openstack/compute/client/startServer-test.js b/test/openstack/compute/client/startServer-test.js index dc8036735..785cc8ec1 100644 --- a/test/openstack/compute/client/startServer-test.js +++ b/test/openstack/compute/client/startServer-test.js @@ -4,8 +4,6 @@ * */ - -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); var should = require('should'), diff --git a/test/openstack/compute/client/stopServer-test.js b/test/openstack/compute/client/stopServer-test.js index 0dfff491d..d80220486 100644 --- a/test/openstack/compute/client/stopServer-test.js +++ b/test/openstack/compute/client/stopServer-test.js @@ -4,8 +4,6 @@ * */ - -var Client = new require('../../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../../helpers'); var should = require('should'), diff --git a/test/openstack/identity/service-test.js b/test/openstack/identity/service-test.js index 662ba9836..9e0028938 100644 --- a/test/openstack/identity/service-test.js +++ b/test/openstack/identity/service-test.js @@ -1,5 +1,4 @@ -var context = require('../../../lib/pkgcloud/openstack/context'), - should = require('should'); +var context = require('../../../lib/pkgcloud/openstack/context'); describe('pkgcloud openstack context Service Class', function() { diff --git a/test/openstack/orchestration/create-stacks-test.js b/test/openstack/orchestration/create-stacks-test.js index 591ace60a..9b9dd8be6 100644 --- a/test/openstack/orchestration/create-stacks-test.js +++ b/test/openstack/orchestration/create-stacks-test.js @@ -6,7 +6,6 @@ * MIT LICENSE */ -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var should = require('should'), diff --git a/test/openstack/orchestration/get-stacks-test.js b/test/openstack/orchestration/get-stacks-test.js index 58f9f2082..3b763e1ee 100644 --- a/test/openstack/orchestration/get-stacks-test.js +++ b/test/openstack/orchestration/get-stacks-test.js @@ -6,7 +6,6 @@ * MIT LICENSE */ -var Client = new require('../../../lib/pkgcloud/core/base/client').Client; var helpers = require('../../helpers'); var should = require('should'), diff --git a/test/rackspace/blockstorage/volumes-test.js b/test/rackspace/blockstorage/volumes-test.js index 883892d72..2b4e19ed2 100644 --- a/test/rackspace/blockstorage/volumes-test.js +++ b/test/rackspace/blockstorage/volumes-test.js @@ -6,9 +6,7 @@ * MIT LICENSE * */ -var fs = require('fs'), - path = require('path'), - should = require('should'), +var should = require('should'), async = require('async'), hock = require('hock'), http = require('http'), diff --git a/test/rackspace/compute/image-test.js b/test/rackspace/compute/image-test.js index fbd83dd6c..549518e6a 100644 --- a/test/rackspace/compute/image-test.js +++ b/test/rackspace/compute/image-test.js @@ -6,9 +6,7 @@ * */ -var fs = require('fs'), - path = require('path'), - should = require('should'), +var should = require('should'), async = require('async'), hock = require('hock'), http = require('http'), diff --git a/test/rackspace/compute/personality-test.js b/test/rackspace/compute/personality-test.js index c19f84523..254537af2 100644 --- a/test/rackspace/compute/personality-test.js +++ b/test/rackspace/compute/personality-test.js @@ -8,10 +8,8 @@ */ var fs = require('fs'), - path = require('path'), spawn = require('child_process').spawn, should = require('should'), - pkgcloud = require('../../../lib/pkgcloud'), helpers = require('../../helpers'), mock = !!process.env.MOCK; diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js index a12c9ed15..289d4c8bc 100644 --- a/test/rackspace/databases/user-limit-test.js +++ b/test/rackspace/databases/user-limit-test.js @@ -11,7 +11,6 @@ var should = require('should'), hock = require('hock'), http = require('http'), helpers = require('../../helpers'), - User = require('../../../lib/pkgcloud/openstack/database/user').User, mock = !!process.env.MOCK; // Declaring variables for helper functions defined later diff --git a/test/rackspace/macros.js b/test/rackspace/macros.js index 0a1225c45..910703197 100644 --- a/test/rackspace/macros.js +++ b/test/rackspace/macros.js @@ -7,10 +7,7 @@ var fs = require('fs'), filed = require('filed'), - assert = require('../helpers/assert'), - should = require('should'), - helpers = require('../helpers'), - mock = !!process.env.MOCK; + assert = require('../helpers/assert'); exports.shouldHaveCreds = function (client) { return function () { diff --git a/test/rackspace/storage/authentication-test.js b/test/rackspace/storage/authentication-test.js index 0146d1078..5c40e75c4 100644 --- a/test/rackspace/storage/authentication-test.js +++ b/test/rackspace/storage/authentication-test.js @@ -8,7 +8,6 @@ var should = require('should'), macros = require('../macros'), helpers = require('../../helpers'), - async = require('async'), http = require('http'), hock = require('hock'), mock = !!process.env.MOCK; diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index 0499c0375..d2ba58849 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -6,10 +6,7 @@ * */ -var path = require('path'), - fs = require('fs'), - should = require('should'), - pkgcloud = require('../../../lib/pkgcloud'), +var should = require('should'), helpers = require('../../helpers'), async = require('async'), hock = require('hock'), diff --git a/test/rackspace/storage/storage-object-test.js b/test/rackspace/storage/storage-object-test.js index cdcb9b5a9..be7610e77 100755 --- a/test/rackspace/storage/storage-object-test.js +++ b/test/rackspace/storage/storage-object-test.js @@ -6,10 +6,8 @@ * */ -var path = require('path'), - fs = require('fs'), +var fs = require('fs'), should = require('should'), - pkgcloud = require('../../../lib/pkgcloud'), helpers = require('../../helpers'), async = require('async'), http = require('http'), From c30e573fd960c9f0794f94df6356227db5929847 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 20:38:17 +0000 Subject: [PATCH 280/460] Adding missing test fixtures refernced in earlier commit. --- test/fixtures/openstack/tenantInfo-admin.json | 8 ++++++++ test/fixtures/openstack/validateToken-admin.json | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/fixtures/openstack/tenantInfo-admin.json create mode 100644 test/fixtures/openstack/validateToken-admin.json diff --git a/test/fixtures/openstack/tenantInfo-admin.json b/test/fixtures/openstack/tenantInfo-admin.json new file mode 100644 index 000000000..68b7cafe3 --- /dev/null +++ b/test/fixtures/openstack/tenantInfo-admin.json @@ -0,0 +1,8 @@ +{ + "tenant": { + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "ACME corp", + "description": "A description ...", + "enabled": true + } +} diff --git a/test/fixtures/openstack/validateToken-admin.json b/test/fixtures/openstack/validateToken-admin.json new file mode 100644 index 000000000..5f3eea3d4 --- /dev/null +++ b/test/fixtures/openstack/validateToken-admin.json @@ -0,0 +1,12 @@ +{ + "access": { + "token": { + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "expires": "2010-11-01T03:32:15-05:00", + "tenant": { + "id": "72e90ecb69c44d0296072ea39e537041", + "name": "My Project" + } + } + } +} From 443607b697a8f154da960e9123ca73c22ea0c664 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 20:39:15 +0000 Subject: [PATCH 281/460] Removing unused variable references. --- lib/pkgcloud/amazon/compute/client/keys.js | 2 +- lib/pkgcloud/amazon/storage/file.js | 4 +- lib/pkgcloud/azure/compute/client/keys.js | 8 +- lib/pkgcloud/azure/compute/client/servers.js | 9 +- lib/pkgcloud/azure/compute/server.js | 1 - .../azure/database/client/databases.js | 4 +- .../azure/storage/client/containers.js | 10 +-- lib/pkgcloud/azure/storage/client/files.js | 2 +- lib/pkgcloud/azure/storage/container.js | 2 - lib/pkgcloud/azure/storage/utils.js | 1 - lib/pkgcloud/azure/utils/azureApi.js | 82 +++++++++---------- lib/pkgcloud/azure/utils/cert.js | 2 +- lib/pkgcloud/azure/utils/sharedkey.js | 4 +- lib/pkgcloud/common/azure-signature.js | 3 - lib/pkgcloud/common/http-signature.js | 4 +- lib/pkgcloud/core/compute/index.js | 1 - .../digitalocean/compute/client/flavors.js | 2 +- .../digitalocean/compute/client/images.js | 5 +- .../digitalocean/compute/client/keys.js | 10 +-- .../digitalocean/compute/client/servers.js | 3 +- lib/pkgcloud/google/client.js | 2 - .../google/storage/client/containers.js | 3 +- .../iriscouch/database/client/index.js | 2 +- lib/pkgcloud/joyent/compute/client/keys.js | 10 +-- lib/pkgcloud/joyent/compute/client/servers.js | 2 +- lib/pkgcloud/joyent/compute/server.js | 2 +- .../mongohq/database/client/databases.js | 6 +- lib/pkgcloud/mongohq/database/client/index.js | 2 +- .../mongolab/database/client/accounts.js | 10 +-- .../mongolab/database/client/databases.js | 8 +- .../blockstorage/client/snapshots.js | 6 +- .../openstack/blockstorage/client/volumes.js | 2 +- .../blockstorage/client/volumetypes.js | 2 +- .../compute/client/extensions/servers.js | 3 - .../openstack/database/client/databases.js | 4 +- .../openstack/database/client/instances.js | 6 +- .../openstack/database/client/users.js | 4 +- .../openstack/identity/client/index.js | 6 +- .../openstack/network/client/networks.js | 4 +- .../openstack/network/client/ports.js | 4 +- .../openstack/network/client/subnets.js | 4 +- lib/pkgcloud/openstack/storage/file.js | 2 +- lib/pkgcloud/rackspace/dns/client/records.js | 6 +- lib/pkgcloud/rackspace/dns/client/zones.js | 2 +- lib/pkgcloud/rackspace/dns/status.js | 2 +- .../loadbalancer/client/loadbalancers.js | 10 +-- .../rackspace/loadbalancer/client/nodes.js | 2 +- .../redistogo/database/client/index.js | 8 +- test/amazon/compute/client/groups-test.js | 2 +- test/amazon/compute/client/keys-test.js | 2 +- .../azure/compute/client/test-createServer.js | 2 +- .../compute/client/test-destroyServer.js | 2 +- test/azure/compute/client/test-getImages.js | 2 - test/azure/compute/client/test-getServer.js | 2 - test/azure/compute/client/test-getServers.js | 2 - .../azure/compute/client/test-rebootServer.js | 2 +- test/azure/compute/client/test-stopServer.js | 2 - test/azure/utils/test-cert.js | 5 -- test/azure/utils/test-createHostedService.js | 2 - test/azure/utils/test-getOSImage.js | 2 - test/common/compute/base-test.js | 20 ++--- test/common/compute/meta-test.js | 8 +- test/common/compute/server-test.js | 34 ++++---- test/common/databases/databases-test.js | 26 +++--- test/common/databases/flavor-test.js | 4 +- test/common/databases/instances-test.js | 46 ++++++----- test/common/databases/users-test.js | 43 +++++----- test/common/network/network-test.js | 43 +++++----- test/common/network/port-test.js | 39 ++++----- test/common/network/subnet-test.js | 39 ++++----- test/common/storage/base-test.js | 36 ++++---- test/common/storage/upload-test.js | 5 +- test/helpers/azureNock.js | 13 +-- test/hp/compute/authentication-test.js | 4 +- test/hp/network/authentication-test.js | 4 +- test/hp/storage/authentication-test.js | 1 + .../databases/databases-redis-test.js | 4 +- .../compute/client/startServer-test.js | 3 - .../compute/client/stopServer-test.js | 3 - test/openstack/identity/identity-test.js | 3 + test/openstack/identity/service-test.js | 4 +- .../orchestration/create-stacks-test.js | 2 - .../orchestration/get-stacks-test.js | 2 - test/rackspace/blockstorage/volumes-test.js | 2 +- test/rackspace/compute/authentication-test.js | 4 +- test/rackspace/compute/personality-test.js | 3 +- .../databases/authentication-test.js | 6 +- test/rackspace/databases/user-limit-test.js | 8 +- test/rackspace/storage/authentication-test.js | 1 + 89 files changed, 315 insertions(+), 405 deletions(-) diff --git a/lib/pkgcloud/amazon/compute/client/keys.js b/lib/pkgcloud/amazon/compute/client/keys.js index a1cc05db1..8a2420c4b 100644 --- a/lib/pkgcloud/amazon/compute/client/keys.js +++ b/lib/pkgcloud/amazon/compute/client/keys.js @@ -95,4 +95,4 @@ exports.destroyKey = function (name, callback) { ? callback(err) : callback(null, true); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index d1ea8623f..370dbe33f 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -16,8 +16,6 @@ var File = exports.File = function File(client, details) { util.inherits(File, base.File); File.prototype._setProperties = function (details) { - var self = this; - this.name = details.name || details.Key; this.etag = details.ETag || details.etag || null; this.lastModified = details.LastModified || details.lastModified || null; @@ -33,4 +31,4 @@ File.prototype._setProperties = function (details) { File.prototype.toJSON = function () { return _.pick(this, ['name', 'etag', 'size', 'storageClass', 'lastModified', 'container', 'location' ]); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/azure/compute/client/keys.js b/lib/pkgcloud/azure/compute/client/keys.js index 73a3b7567..500008670 100644 --- a/lib/pkgcloud/azure/compute/client/keys.js +++ b/lib/pkgcloud/azure/compute/client/keys.js @@ -23,7 +23,7 @@ exports.listKeys = function (options, callback) { var self = this; options = options || {}; - return this._query('DescribeKeyPairs', options, function (err, body, res) { + return this._query('DescribeKeyPairs', options, function (err, body) { return err ? callback(err) : callback(null, self._toArray(body.keySet.item)); @@ -70,7 +70,7 @@ exports.addKey = function (options, callback) { KeyName: options.name, PublicKeyMaterial: new Buffer(options.key).toString('base64') }, - function (err, body, res) { + function (err) { return err ? callback(err) : callback(null, true); @@ -89,10 +89,10 @@ exports.destroyKey = function (name, callback) { return this._query( 'DeleteKeyPair', { KeyName: name }, - function (err, body, res) { + function (err) { return err ? callback(err) : callback(null, true); } ); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/azure/compute/client/servers.js b/lib/pkgcloud/azure/compute/client/servers.js index ae9cc5274..4d47ca16c 100644 --- a/lib/pkgcloud/azure/compute/client/servers.js +++ b/lib/pkgcloud/azure/compute/client/servers.js @@ -41,8 +41,7 @@ exports.getLimits = function getLimits(callback) { // Lists all servers available to your account. // exports.getServers = function getServers(callback) { - var self = this, - servers = []; + var self = this; azureApi.getServers(this, function (err, results) { if (err) { @@ -122,7 +121,7 @@ exports.createServer = function createServer(options, callback) { exports.destroyServer = function destroyServer(server, callback) { var serverId = server instanceof base.Server ? server.id : server; - azureApi.destroyServer(this, serverId, function (err, res) { + azureApi.destroyServer(this, serverId, function (err) { if (callback) { return !err ? callback && callback(null, { ok: serverId }) @@ -141,7 +140,7 @@ exports.destroyServer = function destroyServer(server, callback) { exports.stopServer = function stopServer(server, callback) { var serverId = server instanceof base.Server ? server.id : server; - azureApi.stopServer(this, serverId, function (err, res) { + azureApi.stopServer(this, serverId, function (err) { return !err ? callback(null, { ok: serverId }) : callback(err); @@ -173,7 +172,7 @@ exports.createHostedService = function createHostedService(serviceName, callback exports.rebootServer = function rebootServer(server, callback) { var serverId = server instanceof base.Server ? server.id : server; - azureApi.rebootServer(this, serverId, function (err, res) { + azureApi.rebootServer(this, serverId, function (err) { return !err ? callback(null, { ok: serverId }) : callback(err); diff --git a/lib/pkgcloud/azure/compute/server.js b/lib/pkgcloud/azure/compute/server.js index cf0fc1804..af78a4ed9 100644 --- a/lib/pkgcloud/azure/compute/server.js +++ b/lib/pkgcloud/azure/compute/server.js @@ -101,7 +101,6 @@ Server.prototype._setProperties = function (details) { // TODO: Need to clean up once I understand what is private ip? if (roleInstance) { - var ip = roleInstance.IpAddress; addresses.public.push(roleInstance.InstanceEndpoints.InstanceEndpoint.Vip); addresses.private.push(roleInstance.IpAddress); } else { diff --git a/lib/pkgcloud/azure/database/client/databases.js b/lib/pkgcloud/azure/database/client/databases.js index 4301f6f4f..fc24f8daa 100644 --- a/lib/pkgcloud/azure/database/client/databases.js +++ b/lib/pkgcloud/azure/database/client/databases.js @@ -66,7 +66,7 @@ exports.create = function (options, callback) { path: 'Tables', body: body, headers: headers - }, function (err, body, res) { + }, function (err, body) { if (err) { return next(err); } var parser = new xml2js.Parser(); @@ -94,7 +94,7 @@ exports.list = function (callback) { this._xmlRequest({ method: 'GET', path: 'Tables' - }, function (err, body, res) { + }, function (err, body) { if (err) { return callback(err); } if (body && body.entry) { if (Array.isArray(body.entry)) { diff --git a/lib/pkgcloud/azure/storage/client/containers.js b/lib/pkgcloud/azure/storage/client/containers.js index aa20ccc21..b8d0b30c8 100644 --- a/lib/pkgcloud/azure/storage/client/containers.js +++ b/lib/pkgcloud/azure/storage/client/containers.js @@ -44,8 +44,7 @@ exports.getContainers = function (callback) { // exports.getContainer = function (container, callback) { var containerName = container instanceof storage.Container ? container.name : container, - self = this, - options; + self = this; this._xmlRequest({ method: 'GET', @@ -53,7 +52,7 @@ exports.getContainer = function (container, callback) { qs: { restype: 'container' } - }, function (err, body, res) { + }, function (err, body) { return err ? callback(err) : callback(null, new (storage.Container)(self, body)); @@ -83,7 +82,7 @@ exports.createContainer = function (options, callback) { qs: { restype: 'container' } - }, function (err, body, res) { + }, function (err) { return err ? callback(err) : callback(null, new (storage.Container)(self, options)); @@ -102,8 +101,7 @@ exports.createContainer = function (options, callback) { // of the same name during this cleanup period, your call returns an error immediately. // exports.destroyContainer = function (container, callback) { - var containerName = container instanceof base.Container ? container.name : container, - self = this; + var containerName = container instanceof base.Container ? container.name : container; this._xmlRequest({ method: 'DELETE', diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 79ba85947..2912124a2 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -336,7 +336,7 @@ exports.getFiles = function (container, options, callback) { restype: 'container', comp: 'list' } - }, function (err, body, res) { + }, function (err, body) { if (err) { return callback(err); } diff --git a/lib/pkgcloud/azure/storage/container.js b/lib/pkgcloud/azure/storage/container.js index 65d587d0c..ff8782165 100644 --- a/lib/pkgcloud/azure/storage/container.js +++ b/lib/pkgcloud/azure/storage/container.js @@ -16,8 +16,6 @@ var Container = exports.Container = function Container(client, details) { util.inherits(Container, base.Container); Container.prototype._setProperties = function (details) { - var self = this; - if (typeof details === 'string') { this.name = details; return; diff --git a/lib/pkgcloud/azure/storage/utils.js b/lib/pkgcloud/azure/storage/utils.js index 54a342a18..9a600cf71 100644 --- a/lib/pkgcloud/azure/storage/utils.js +++ b/lib/pkgcloud/azure/storage/utils.js @@ -67,7 +67,6 @@ ChunkedStream.prototype.end = function end() { } // Emit all left data - var self = this; this.ended = true; this.emitChunk(Buffer.concat(this.buffer, this.size)); this.buffer = []; diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index 450090076..38cd405ab 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -22,12 +22,12 @@ var URL = require('url'); var cert = require('../utils/cert'); var pkgcloud = require('../../../../../pkgcloud'); -var MANAGEMENT_API_VERSION = exports.MANAGEMENT_API_VERSION = '2012-03-01'; -var MANAGEMENT_ENDPOINT = exports.MANAGEMENT_ENDPOINT = 'management.core.windows.net'; +exports.MANAGEMENT_API_VERSION = '2012-03-01'; +exports.MANAGEMENT_ENDPOINT = 'management.core.windows.net'; var STORAGE_ENDPOINT = exports.STORAGE_ENDPOINT = 'blob.core.windows.net'; -var STORAGE_API_VERSION = exports.STORAGE_API_VERSION = HeaderConstants.TARGET_STORAGE_VERSION; -var TABLES_ENDPOINT = exports.TABLES_ENDPOINT = 'table.core.windows.net'; -var TABLES_API_VERSION = exports.TABLES_API_VERSION = '2012-02-12'; +exports.STORAGE_API_VERSION = HeaderConstants.TARGET_STORAGE_VERSION; +exports.TABLES_ENDPOINT = 'table.core.windows.net'; +exports.TABLES_API_VERSION = '2012-02-12'; var MINIMUM_POLL_INTERVAL = exports.MINIMUM_POLL_INTERVAL = 3000; // Declaring variables for helper functions defined later @@ -62,7 +62,7 @@ var createVM, createLinuxVM, createWindowsVM, validateCreateOptions, getServer, * its status is RUNNING. This entire process may take several minutes. */ -var createServer = exports.createServer = function (client, options, callback) { +exports.createServer = function (client, options, callback) { var vmOptions = {}, ssh; @@ -138,7 +138,7 @@ var createServer = exports.createServer = function (client, options, callback) { ); }; -var createVM = function (client, options, vmOptions, callback) { +createVM = function (client, options, vmOptions, callback) { // check OS type of image to determine if we are creating a linux or windows VM switch (vmOptions.image.OS.toLowerCase()) { case 'linux': @@ -153,11 +153,11 @@ var createVM = function (client, options, vmOptions, callback) { } }; -var getMediaLinkUrl = function (storageAccount, fileName) { +getMediaLinkUrl = function (storageAccount, fileName) { return 'http://' + storageAccount + '.' + STORAGE_ENDPOINT + '/vhd/' + fileName; }; -var createEndpoints = function (ports) { +createEndpoints = function (ports) { var endPoints = '', template = templates.loadSync('endpoint.xml'); @@ -167,7 +167,7 @@ var createEndpoints = function (ports) { return endPoints; }; -var createLinuxVM = function (client, options, vmOptions, callback) { +createLinuxVM = function (client, options, vmOptions, callback) { var path = client.subscriptionId + '/services/hostedservices/' + options.name + '/deployments'; var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); var label = new Buffer(options.name).toString('base64'); @@ -189,7 +189,7 @@ var createLinuxVM = function (client, options, vmOptions, callback) { makeTemplateRequest(client, path, 'linuxDeployment.xml', configParams, callback); }; -var createWindowsVM = function (client, options, vmOptions, callback) { +createWindowsVM = function (client, options, vmOptions, callback) { var path = client.subscriptionId + '/services/hostedservices/' + options.name + '/deployments'; var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); var label = new Buffer(options.name).toString('base64'); @@ -208,7 +208,7 @@ var createWindowsVM = function (client, options, vmOptions, callback) { makeTemplateRequest(client, path, 'windowsDeployment.xml', configParams, callback); }; -var captureServer = function (client, serverName, targetImageName, callback) { +captureServer = function (client, serverName, targetImageName, callback) { // /services/hostedservices//deployments//roleinstances//operations var path = client.subscriptionId + '/services/hostedservices/' + serverName + '/deployments/' + @@ -233,7 +233,7 @@ var deleteImage = function (client, image, callback) { makeTemplateRequest(client, path, 'deleteImage.xml', configParams, callback); }; -var validateCreateOptions = function (options, config, callback) { +validateCreateOptions = function (options, config, callback) { if (typeof options === 'function') { options = {}; } @@ -254,7 +254,7 @@ var validateCreateOptions = function (options, config, callback) { /** * getServer */ -var getServer = exports.getServer = function (client, serverName, callback) { +getServer = exports.getServer = function (client, serverName, callback) { getServersFromService(client, serverName, function (err, servers) { return !err ? callback(err, servers[0] ? servers[0] : null) @@ -262,7 +262,7 @@ var getServer = exports.getServer = function (client, serverName, callback) { }); }; -var getServers = exports.getServers = function (client, callback) { +getServers = exports.getServers = function (client, callback) { // async execute the following tasks one by one and bail if there is an error async.waterfall([ function (next) { @@ -279,7 +279,7 @@ var getServers = exports.getServers = function (client, callback) { ); }; -var makeTemplateRequest = function (client, path, templateName, params, callback) { +makeTemplateRequest = function (client, path, templateName, params, callback) { var headers = {}, body; @@ -307,13 +307,13 @@ var makeTemplateRequest = function (client, path, templateName, params, callback pollRequestStatus(client, res.headers['x-ms-request-id'], MINIMUM_POLL_INTERVAL, next); }); }], - function (err, result) { + function (err) { callback(err); } ); }; -var createHostedService = exports.createHostedService = function (client, options, callback) { +createHostedService = exports.createHostedService = function (client, options, callback) { var path = client.subscriptionId + '/services/hostedservices'; var params = { NAME: options.name, @@ -330,7 +330,7 @@ var createHostedService = exports.createHostedService = function (client, option * POST https://management.core.windows.net//services/hostedservices//deployments//roleinstances//operations * A successful operation returns status code 201 (Created). Need to poll for success? */ -var rebootServer = exports.rebootServer = function (client, serviceName, callback) { +rebootServer = exports.rebootServer = function (client, serviceName, callback) { var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '/deployments/' + serviceName + '/roleInstances/' + @@ -354,7 +354,7 @@ var stopServer = exports.stopServer = function (client, serviceName, callback) { makeTemplateRequest(client, path, 'shutdownRole.xml', {}, callback); }; -var addCertificate = function (client, serviceName, cert, password, callback) { +addCertificate = function (client, serviceName, cert, password, callback) { var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '/certificates'; @@ -366,7 +366,7 @@ var addCertificate = function (client, serviceName, cert, password, callback) { makeTemplateRequest(client, path, 'addCertificate.xml', params, callback); }; -var deleteHostedService = exports.deleteHostedService = function (client, serviceName, callback) { +deleteHostedService = exports.deleteHostedService = function (client, serviceName, callback) { // DELETE https://management.core.windows.net//services/hostedservices/ var path = client.subscriptionId + '/services/hostedservices/' + serviceName; @@ -382,11 +382,11 @@ var deleteHostedService = exports.deleteHostedService = function (client, servic }); }; -var getHostedServices = exports.getHostedServices = function (client, callback) { +getHostedServices = exports.getHostedServices = function (client, callback) { var path = client.subscriptionId + '/services/hostedservices', services = []; - client.get(path, function (err, body, res) { + client.get(path, function (err, body) { if (err) { return callback(err); } @@ -413,7 +413,7 @@ var getHostedServices = exports.getHostedServices = function (client, callback) * To determine the status code for the operation once it is complete, call Get Operation Status. * Because Delete Deployment is an asynchronous operation, it always returns status code 202 (Accept). */ -var destroyServer = exports.destroyServer = function (client, serverName, callback) { +destroyServer = exports.destroyServer = function (client, serverName, callback) { var server = null; // async execute the following tasks one by one and bail if there is an error @@ -439,13 +439,13 @@ var destroyServer = exports.destroyServer = function (client, serverName, callba function (next) { deleteHostedService(client, serverName, next); }], - function (err, result) { + function (err) { callback(err, true); } ); }; -var deleteServer = function (client, serverName, callback) { +deleteServer = function (client, serverName, callback) { var path = client.subscriptionId + '/services/hostedservices/' + serverName; path += '/deployments/' + serverName; @@ -461,7 +461,7 @@ var deleteServer = function (client, serverName, callback) { }); }; -var getOSImage = exports.getOSImage = function (client, imageName, callback) { +getOSImage = exports.getOSImage = function (client, imageName, callback) { var path = '/' + client.subscriptionId + '/services/images/' + imageName; var onError = function (err) { @@ -473,14 +473,14 @@ var getOSImage = exports.getOSImage = function (client, imageName, callback) { } }; - client.get(path, function (err, body, res) { + client.get(path, function (err, body) { return err ? onError(err) : callback(null, body); }); }; -var deleteOSDisk = function (client, server, callback) { +deleteOSDisk = function (client, server, callback) { var diskName = null, path; @@ -510,7 +510,7 @@ var deleteOSDisk = function (client, server, callback) { }); }; -var deleteOSBlob = function (client, server, callback) { +deleteOSBlob = function (client, server, callback) { var blob = null; if (server && server.RoleList && server.RoleList.Role) { @@ -529,7 +529,7 @@ var deleteOSBlob = function (client, server, callback) { callback(err); } else { var storage = pkgcloud.storage.createClient(client.config); - storage.removeFile(info.container, info.file, function (err, result) { + storage.removeFile(info.container, info.file, function (err) { callback(err); }); } @@ -540,7 +540,7 @@ var deleteOSBlob = function (client, server, callback) { * getServersFromServices * Retrieves all servers (VMs) from the list of services */ -var getServersFromServices = function (client, services, callback) { +getServersFromServices = function (client, services, callback) { var task = function (service, next) { getServersFromService(client, service.ServiceName, function (err, servers) { next(err, servers); @@ -557,7 +557,7 @@ var getServersFromServices = function (client, services, callback) { * getServersFromServices * Retrieves all servers (VMs) from a Hosted Service */ -var getServersFromService = function (client, serviceName, callback) { +getServersFromService = function (client, serviceName, callback) { var servers = []; getHostedServiceProperties(client, serviceName, function (err, result) { if (err) { @@ -574,7 +574,7 @@ var getServersFromService = function (client, serviceName, callback) { }); }; -var isVM = function (deployment) { +isVM = function (deployment) { if (deployment.RoleList && deployment.RoleList.Role) { if (deployment.RoleList.Role.RoleType === 'PersistentVMRole') { return true; @@ -589,7 +589,7 @@ var isVM = function (deployment) { GET https://management.core.windows.net//services/hostedservices/?embed-detail=true A successful operation returns status code 200 (OK). */ -var getHostedServiceProperties = function (client, serviceName, callback) { +getHostedServiceProperties = function (client, serviceName, callback) { var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '?embed-detail=true'; var onError = function (err) { @@ -598,7 +598,7 @@ var getHostedServiceProperties = function (client, serviceName, callback) { : callback(err); }; - client.get(path, function (err, body, res) { + client.get(path, function (err, body) { return err ? onError(err) : callback(null, body); @@ -611,10 +611,10 @@ var getHostedServiceProperties = function (client, serviceName, callback) { * GET https://management.core.windows.net//operations/ */ -var pollRequestStatus = function (client, requestId, interval, callback) { +pollRequestStatus = function (client, requestId, interval, callback) { var checkStatus = function () { var path = client.subscriptionId + '/operations/' + requestId; - client.get(path, function (err, body, res) { + client.get(path, function (err, body) { if (err) { return callback(err); } @@ -635,7 +635,7 @@ var pollRequestStatus = function (client, requestId, interval, callback) { checkStatus(); }; -var getStorageInfoFromUri = exports.getStorageInfoFromUri = function (uri, callback) { +getStorageInfoFromUri = exports.getStorageInfoFromUri = function (uri, callback) { var u, tokens, path, info = {}; @@ -665,7 +665,7 @@ var getStorageInfoFromUri = exports.getStorageInfoFromUri = function (uri, callb * 2. stop server if it is running * 3. capture server image */ -var createImage = exports.createImage = function (client, serverName, targetImageName, callback) { +createImage = exports.createImage = function (client, serverName, targetImageName, callback) { async.waterfall([ function (next) { // stop the server @@ -686,7 +686,7 @@ var createImage = exports.createImage = function (client, serverName, targetImag * 1. get the requested image * 2. delete the image using its label */ -var destroyImage = exports.destroyImage = function (client, imageName, callback) { +destroyImage = exports.destroyImage = function (client, imageName, callback) { async.waterfall([ function (next) { // stop the server diff --git a/lib/pkgcloud/azure/utils/cert.js b/lib/pkgcloud/azure/utils/cert.js index 903053d46..4979aab87 100644 --- a/lib/pkgcloud/azure/utils/cert.js +++ b/lib/pkgcloud/azure/utils/cert.js @@ -85,7 +85,7 @@ var getFingerPrint = function (pem) { return sha1.digest('hex').toUpperCase(); }; -var getAzureCertInfo = exports.getAzureCertInfo = function (cert) { +exports.getAzureCertInfo = function (cert) { return { cert: cert, fingerprint: getFingerPrint(cert.toString()) diff --git a/lib/pkgcloud/azure/utils/sharedkey.js b/lib/pkgcloud/azure/utils/sharedkey.js index 7ebdbd6d8..0f795d37f 100644 --- a/lib/pkgcloud/azure/utils/sharedkey.js +++ b/lib/pkgcloud/azure/utils/sharedkey.js @@ -42,11 +42,9 @@ var getvalueToAppend = function (value) { * Signs a request with the Authentication header. * * @param {req} The request request object. - * @param {options} The request options to be signed. - * @param {function (error)} callback The callback function. * @return {undefined} */ -SharedKey.prototype.signRequest = function (req, options) { +SharedKey.prototype.signRequest = function (req) { var httpVerb = req.method || 'GET'; diff --git a/lib/pkgcloud/common/azure-signature.js b/lib/pkgcloud/common/azure-signature.js index 2bf8f88c6..cfc7ed376 100644 --- a/lib/pkgcloud/common/azure-signature.js +++ b/lib/pkgcloud/common/azure-signature.js @@ -9,9 +9,6 @@ var azureApi = require('../azure/utils/azureApi'), SharedKey = require('../azure/utils/sharedkey'), SharedTableKey = require('../azure/utils/sharedkeytable'); -var MANAGEMENT_API_VERSION = azureApi.MANAGEMENT_API_VERSION; -var STORAGE_API_VERSION = azureApi.STORAGE_API_VERSION; - exports.managementSignature = function managementSignature(req, options) { req.headers = req.headers || {}; diff --git a/lib/pkgcloud/common/http-signature.js b/lib/pkgcloud/common/http-signature.js index bcdc869a9..c5ab23339 100644 --- a/lib/pkgcloud/common/http-signature.js +++ b/lib/pkgcloud/common/http-signature.js @@ -23,8 +23,6 @@ var Algorithms = { 'hmac-sha512': true }; -var Authorization = 'Signature keyId="%s",algorithm="%s",headers="%s" %s'; - // // ## Specific Errors // @@ -125,4 +123,4 @@ module.exports = { return req; } -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/core/compute/index.js b/lib/pkgcloud/core/compute/index.js index cbececd00..77cb9be96 100644 --- a/lib/pkgcloud/core/compute/index.js +++ b/lib/pkgcloud/core/compute/index.js @@ -57,7 +57,6 @@ exports.serverIp = function (server, options) { isPrivate = options.isPrivate || exports.isPrivate, interfaces, addresses, - networks, pub; if (server.ips) { diff --git a/lib/pkgcloud/digitalocean/compute/client/flavors.js b/lib/pkgcloud/digitalocean/compute/client/flavors.js index 8d203af0d..0a42e4889 100644 --- a/lib/pkgcloud/digitalocean/compute/client/flavors.js +++ b/lib/pkgcloud/digitalocean/compute/client/flavors.js @@ -46,7 +46,7 @@ exports.getFlavor = function getFlavor(flavor, callback) { return this._request({ path: '/sizes' - }, function (err, body, res) { + }, function (err, body) { if (err || !body.sizes) { return callback(err || new Error('No flavors found.')); } diff --git a/lib/pkgcloud/digitalocean/compute/client/images.js b/lib/pkgcloud/digitalocean/compute/client/images.js index 9a0bce4fc..c123a4a2c 100644 --- a/lib/pkgcloud/digitalocean/compute/client/images.js +++ b/lib/pkgcloud/digitalocean/compute/client/images.js @@ -78,8 +78,7 @@ exports.createImage = function createImage(options, callback) { // Destroys an image in DigitalOcean // exports.destroyImage = function destroyImage(image, callback) { - var imageId = image instanceof base.Image ? image.id : image, - self = this; + var imageId = image instanceof base.Image ? image.id : image; return this._request({ path: '/images/' + imageId + '/destroy' @@ -88,4 +87,4 @@ exports.destroyImage = function destroyImage(image, callback) { ? callback(err) : callback(null, { ok: imageId }, res); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/digitalocean/compute/client/keys.js b/lib/pkgcloud/digitalocean/compute/client/keys.js index 6c32bdf6d..798e439d5 100644 --- a/lib/pkgcloud/digitalocean/compute/client/keys.js +++ b/lib/pkgcloud/digitalocean/compute/client/keys.js @@ -16,7 +16,7 @@ var errs = require('errs'); exports.listKeys = function (callback) { return this._request({ path: '/ssh_keys' - }, function (err, body, res) { + }, function (err, body) { return err ? callback(err) : callback(null, body.ssh_keys); @@ -33,7 +33,7 @@ exports.listKeys = function (callback) { exports.getKey = function (name, callback) { return this._request({ path: '/ssh_keys/' + name - }, function (err, body, res) { + }, function (err, body) { return err ? callback(err) : callback(null, body.ssh_key); @@ -63,7 +63,7 @@ exports.addKey = function (options, callback) { name: options.name, ssh_pub_key: options.key } - }, function (err, body, res) { + }, function (err) { return err ? callback(err) : callback(null, true); @@ -80,9 +80,9 @@ exports.addKey = function (options, callback) { exports.destroyKey = function (name, callback) { return this._request({ path: '/ssh_keys/' + name + '/destroy', - }, function (err, body, res) { + }, function (err) { return err ? callback(err) : callback(null, true); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/digitalocean/compute/client/servers.js b/lib/pkgcloud/digitalocean/compute/client/servers.js index 0a38fffcd..dff9a9de7 100644 --- a/lib/pkgcloud/digitalocean/compute/client/servers.js +++ b/lib/pkgcloud/digitalocean/compute/client/servers.js @@ -149,8 +149,7 @@ exports.createServer = function createServer(options, callback) { // Destroy a server in DigitalOcean. // exports.destroyServer = function destroyServer(server, options, callback) { - var serverId = server instanceof base.Server ? server.id : server, - self = this; + var serverId = server instanceof base.Server ? server.id : server; if (typeof options === 'function') { callback = options; diff --git a/lib/pkgcloud/google/client.js b/lib/pkgcloud/google/client.js index e073406cb..f6d28852f 100644 --- a/lib/pkgcloud/google/client.js +++ b/lib/pkgcloud/google/client.js @@ -10,8 +10,6 @@ var util = require('util'), base = require('../core/base'); var Client = exports.Client = function (options) { - var self = this; - base.Client.call(this, options); options = options || {}; diff --git a/lib/pkgcloud/google/storage/client/containers.js b/lib/pkgcloud/google/storage/client/containers.js index 2d4183fdb..22ed03797 100644 --- a/lib/pkgcloud/google/storage/client/containers.js +++ b/lib/pkgcloud/google/storage/client/containers.js @@ -81,8 +81,7 @@ exports.createContainer = function (options, callback) { * @param {function} callback - Continuation to respond to when complete. */ exports.destroyContainer = function (container, callback) { - var self = this, - bucket = this._getBucket(container); + var bucket = this._getBucket(container); function deleteContainer() { bucket.delete(function(err) { diff --git a/lib/pkgcloud/iriscouch/database/client/index.js b/lib/pkgcloud/iriscouch/database/client/index.js index d506be294..62fcfb531 100644 --- a/lib/pkgcloud/iriscouch/database/client/index.js +++ b/lib/pkgcloud/iriscouch/database/client/index.js @@ -168,7 +168,7 @@ Client.prototype._checkCouch = function (couchName, callback) { if (count > maxAttempts) { return callback('Max Attempts hit', { created: false }); } - request(options, function (err, response, body) { + request(options, function (err, response) { if (err) { return callback(err, { created: false }); } diff --git a/lib/pkgcloud/joyent/compute/client/keys.js b/lib/pkgcloud/joyent/compute/client/keys.js index b636b879e..71e5d3989 100644 --- a/lib/pkgcloud/joyent/compute/client/keys.js +++ b/lib/pkgcloud/joyent/compute/client/keys.js @@ -16,7 +16,7 @@ var errs = require('errs'); exports.listKeys = function (callback) { return this._request({ path: this.account + '/keys' - }, function (err, body, res) { + }, function (err, body) { return err ? callback(err) : callback(null, body); @@ -33,7 +33,7 @@ exports.listKeys = function (callback) { exports.getKey = function (name, callback) { return this._request({ path: this.account + '/keys/' + name - }, function (err, body, res) { + }, function (err, body) { return err ? callback(err) : callback(null, body); @@ -61,7 +61,7 @@ exports.addKey = function (options, callback) { method: 'POST', path: this.account + '/keys', body: options - }, function (err, body, res) { + }, function (err) { return err ? callback(err) : callback(null, true); @@ -79,9 +79,9 @@ exports.destroyKey = function (name, callback) { return this._request({ method: 'DELETE', path: this.account + '/keys/' + name - }, function (err, body, res) { + }, function (err) { return err ? callback(err) : callback(null, true); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index 28beb1720..dd29c180c 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -189,7 +189,7 @@ exports.destroyServer = function destroyServer(server, callback) { path: self.account + '/machines/' + serverId }; - self._request(checkOptions, function (err, body, res) { + self._request(checkOptions, function (err, body) { if (err) { return callback && callback(err) } if (body && body.state === 'stopped') { done = true; diff --git a/lib/pkgcloud/joyent/compute/server.js b/lib/pkgcloud/joyent/compute/server.js index 1810a9802..02b132f27 100644 --- a/lib/pkgcloud/joyent/compute/server.js +++ b/lib/pkgcloud/joyent/compute/server.js @@ -64,4 +64,4 @@ Server.prototype._setProperties = function (details) { this.adminPass = details.metadata && details.metadata.credentials && details.metadata.credentials.admin; -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/mongohq/database/client/databases.js b/lib/pkgcloud/mongohq/database/client/databases.js index 02254345b..c227130a1 100644 --- a/lib/pkgcloud/mongohq/database/client/databases.js +++ b/lib/pkgcloud/mongohq/database/client/databases.js @@ -60,7 +60,7 @@ exports.create = function create(options, callback) { body : 'app_id=' + options.name + '&plan=' + options.plan }; - this._request(createOptions, function (err, b, response) { + this._request(createOptions, function (err, b) { if (err) { return callback(err); } @@ -94,9 +94,9 @@ exports.remove = function remove(id, callback) { method : 'DELETE' }; - this._request(deleteOptions, function (err, body, response) { + this._request(deleteOptions, function (err) { return err ? callback(err) : callback(null, 'deleted'); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/mongohq/database/client/index.js b/lib/pkgcloud/mongohq/database/client/index.js index cbffb27ad..6cbfed270 100644 --- a/lib/pkgcloud/mongohq/database/client/index.js +++ b/lib/pkgcloud/mongohq/database/client/index.js @@ -55,4 +55,4 @@ Client.prototype.successCodes = { 202: 'Accepted', 203: 'Non-authoritative information', 204: 'No content' -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/mongolab/database/client/accounts.js b/lib/pkgcloud/mongolab/database/client/accounts.js index e066286d5..cb3d819a1 100644 --- a/lib/pkgcloud/mongolab/database/client/accounts.js +++ b/lib/pkgcloud/mongolab/database/client/accounts.js @@ -57,7 +57,7 @@ exports.createAccount = function createAccount(options, callback) { } }; - this._request(createOptions, function (err, body, response) { + this._request(createOptions, function (err, body) { return err ? callback(err) : callback(null, { account: body.adminUser }); @@ -80,7 +80,7 @@ exports.deleteAccount = function deleteAccount(name, callback) { path: 'accounts/' + name }; - this._request(deleteOptions, function (err, body, response) { + this._request(deleteOptions, function (err) { return err ? callback(err) : callback(null); @@ -90,7 +90,7 @@ exports.deleteAccount = function deleteAccount(name, callback) { // List all accounts // ### @callback {Function} Continuation to respond to when complete. exports.getAccounts = function getAccounts(callback) { - this._request({ path: 'accounts' }, function (err, body, response) { + this._request({ path: 'accounts' }, function (err, body) { return err ? callback(err) : callback(null, body.map(function (account) { @@ -108,9 +108,9 @@ exports.getAccount = function getAccount(name, callback) { }), name); } - this._request({ path: 'accounts/' + name }, function (err, body, response) { + this._request({ path: 'accounts/' + name }, function (err, body) { return err ? callback(err) : callback(null, body.adminUser); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/mongolab/database/client/databases.js b/lib/pkgcloud/mongolab/database/client/databases.js index 8505c6c27..790eca37e 100644 --- a/lib/pkgcloud/mongolab/database/client/databases.js +++ b/lib/pkgcloud/mongolab/database/client/databases.js @@ -84,7 +84,7 @@ exports.create = function create(options, callback) { } }; - this._request(createOptions, function (err, body, response) { + this._request(createOptions, function (err, body) { return err ? callback(err) : callback(null, formatResponse(body)); @@ -102,7 +102,7 @@ exports.getDatabases = function getDatabases(owner, callback) { }), owner); } - this._request({ path: 'accounts/' + owner + '/databases' }, function (err, body, response) { + this._request({ path: 'accounts/' + owner + '/databases' }, function (err, body) { return err ? callback(err) : callback(null, body); @@ -143,7 +143,7 @@ exports.getDatabase = function getDatabase(options, callback) { var path = ['accounts', options['owner'], 'databases', options['name']].join('/'); - this._request({ path: path }, function (err, body, response) { + this._request({ path: path }, function (err, body) { return err ? callback(err) : callback(null, body); @@ -182,7 +182,7 @@ exports.remove = function remove(options, callback) { path: ['accounts', options['owner'], 'databases', options['name']].join('/') }; - this._request(deleteOptions, function (err, body, response) { + this._request(deleteOptions, function (err) { return err ? callback(err) : callback(null); diff --git a/lib/pkgcloud/openstack/blockstorage/client/snapshots.js b/lib/pkgcloud/openstack/blockstorage/client/snapshots.js index 13e492f4f..fc88fb007 100644 --- a/lib/pkgcloud/openstack/blockstorage/client/snapshots.js +++ b/lib/pkgcloud/openstack/blockstorage/client/snapshots.js @@ -95,7 +95,7 @@ exports.createSnapshot = function(details, callback) { } }; - self._request(createOptions, function(err, body, res) { + self._request(createOptions, function(err, body) { return err ? callback(err) : callback(null, new Snapshot(self, body.snapshot)); @@ -126,7 +126,7 @@ exports.updateSnapshot = function (snapshot, callback) { } }; - self._request(updateOptions, function (err, body, res) { + self._request(updateOptions, function (err, body) { return err ? callback(err) : callback(null, new Snapshot(self, body.snapshot)); @@ -153,4 +153,4 @@ exports.deleteSnapshot = function (snapshot, callback) { ? callback(err) : callback(null, true); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/blockstorage/client/volumes.js b/lib/pkgcloud/openstack/blockstorage/client/volumes.js index 4937b76b2..ed4d5b547 100644 --- a/lib/pkgcloud/openstack/blockstorage/client/volumes.js +++ b/lib/pkgcloud/openstack/blockstorage/client/volumes.js @@ -165,4 +165,4 @@ exports.deleteVolume = function (volume, callback) { ? callback(err) : callback(); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js b/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js index 18e54d8b9..e345b053d 100644 --- a/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js +++ b/lib/pkgcloud/openstack/blockstorage/client/volumetypes.js @@ -53,4 +53,4 @@ exports.getVolumeType = function (volumeType, callback) { ? callback(err) : callback(null, new VolumeType(self, body['volume_type'])); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/compute/client/extensions/servers.js b/lib/pkgcloud/openstack/compute/client/extensions/servers.js index c72997592..b0fc93c01 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/servers.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/servers.js @@ -7,9 +7,6 @@ * */ - -var _extension = 'servers'; - /** * client.startServer * diff --git a/lib/pkgcloud/openstack/database/client/databases.js b/lib/pkgcloud/openstack/database/client/databases.js index 0447a9b2b..f70ed0822 100644 --- a/lib/pkgcloud/openstack/database/client/databases.js +++ b/lib/pkgcloud/openstack/database/client/databases.js @@ -20,8 +20,6 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), // #### options['collate'] {string} Should be a valid Collate for mysql. Default to 'utf8_general_ci' // For more info about character_set and collate for mysql see http://dev.mysql.com/doc/refman/5.6/en/charset-mysql.html exports.createDatabase = exports.create = function createDatabase(options, callback) { - var self = this; - // Check for options if (!options || typeof options === 'function') { return errs.handle(errs.create({ @@ -108,7 +106,7 @@ exports.getDatabases = function getDatabases(options, callback) { requestOptions.qs = completeUrl; requestOptions.path = 'instances/' + instanceId + '/databases'; - this._request(requestOptions, function (err, body, response) { + this._request(requestOptions, function (err, body) { if (err) { return callback(err); } diff --git a/lib/pkgcloud/openstack/database/client/instances.js b/lib/pkgcloud/openstack/database/client/instances.js index 790c1f244..1b1a4b122 100644 --- a/lib/pkgcloud/openstack/database/client/instances.js +++ b/lib/pkgcloud/openstack/database/client/instances.js @@ -89,7 +89,7 @@ exports.createInstance = function createInstance(options, callback) { } }; - this._request(createOptions, function (err, body, response) { + this._request(createOptions, function (err, body) { return err ? callback(err) : callback(null, new Instance(self, body.instance)); @@ -124,7 +124,7 @@ exports.getInstances = function getInstances(options, callback) { requestOptions.qs = completeUrl; requestOptions.path = 'instances'; - this._request(requestOptions, function (err, body, res) { + this._request(requestOptions, function (err, body) { if (err) { return callback(err); } @@ -177,7 +177,7 @@ exports.getInstance = function getInstance(instance, callback) { var instanceId = instance instanceof Instance ? instance.id : instance; this._request({ path: 'instances/' + instanceId - }, function (err, body, response) { + }, function (err, body) { return err ? callback(err) : callback(null, new Instance(self, body.instance)); diff --git a/lib/pkgcloud/openstack/database/client/users.js b/lib/pkgcloud/openstack/database/client/users.js index 65f77e328..5e1e26a04 100644 --- a/lib/pkgcloud/openstack/database/client/users.js +++ b/lib/pkgcloud/openstack/database/client/users.js @@ -69,7 +69,7 @@ exports.createUser = function createUser(options, callback) { if (opts && opts['databases'] && opts['databases'] instanceof Array && opts['databases'].length > 0) { - opts['databases'].forEach(function (item, idx) { + opts['databases'].forEach(function (item) { if (typeof item === 'string') { databases.push({'name' : item}); } else if (item instanceof Database) { @@ -197,7 +197,7 @@ exports.getUsers = function getUsers(options, callback) { requestOptions.qs = completeUrl; requestOptions.path = 'instances/' + instanceId + '/users'; - this._request(requestOptions, function (err, body, res) { + this._request(requestOptions, function (err, body) { if (err) { return callback(err); } diff --git a/lib/pkgcloud/openstack/identity/client/index.js b/lib/pkgcloud/openstack/identity/client/index.js index 1c2ebb713..e74c259d6 100644 --- a/lib/pkgcloud/openstack/identity/client/index.js +++ b/lib/pkgcloud/openstack/identity/client/index.js @@ -66,7 +66,7 @@ Client.prototype.validateToken = function (token, belongsTo, callback) { }; } - this._request(options, function (err, body, res) { + this._request(options, function (err, body) { return err ? callback(err) : callback(err, body); @@ -93,10 +93,10 @@ Client.prototype.getTenantInfo = function (tenantId, callback) { path: urlJoin('/v2.0/tenants', tenantId ? tenantId : '') }; - this._request(options, function (err, body, res) { + this._request(options, function (err, body) { return err ? callback(err) : callback(err, body); }); -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 44ea02139..df4a51558 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -59,7 +59,7 @@ exports.getNetwork = function (network, callback) { this._request({ path: urlJoin(networksResourcePath, networkId), method: 'GET' - }, function (err, body, res) { + }, function (err, body) { if (err) { return callback(err); } @@ -144,7 +144,7 @@ exports.destroyNetwork = function (network, callback) { this._request({ path: urlJoin(networksResourcePath,networkId), method: 'DELETE' - }, function (err, body, res) { + }, function (err) { if (err) { return callback(err); } diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index c6526650c..2210f47e2 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -59,7 +59,7 @@ exports.getPort = function (port, callback) { this._request({ path: urlJoin(portsResourcePath, portId), method: 'GET' - }, function (err, body, res) { + }, function (err, body) { if (err) { return callback(err); } @@ -144,7 +144,7 @@ exports.destroyPort = function (port, callback) { this._request({ path: urlJoin(portsResourcePath,portId), method: 'DELETE' - }, function (err, body, res) { + }, function (err) { if (err) { return callback(err); } diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index 403a1eaf6..c9b660d92 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -62,7 +62,7 @@ exports.getSubnet = function (subnet, callback) { this._request({ path: urlJoin(subnetsResourcePath, subnetId), method: 'GET' - }, function (err, body, res) { + }, function (err, body) { if (err) { return callback(err); } @@ -147,7 +147,7 @@ exports.destroySubnet = function (subnet, callback) { this._request({ path: urlJoin(subnetsResourcePath,subnetId), method: 'DELETE' - }, function (err, body, res) { + }, function (err) { if (err) { return callback(err); } diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index 32ba5e485..751a61c61 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -31,7 +31,7 @@ File.prototype.copy = function (container, destination, callback) { } }; - this.client._request(copyOptions, function (err, body, res) { + this.client._request(copyOptions, function (err) { return err ? callback(err) : callback(null, true); diff --git a/lib/pkgcloud/rackspace/dns/client/records.js b/lib/pkgcloud/rackspace/dns/client/records.js index d5f2982db..8ea27b42c 100644 --- a/lib/pkgcloud/rackspace/dns/client/records.js +++ b/lib/pkgcloud/rackspace/dns/client/records.js @@ -64,7 +64,7 @@ module.exports = { path: urlJoin(_urlPrefix, zoneId, _recordFragment, recordId) }; - self._request(requestOptions, function (err, body, res) { + self._request(requestOptions, function (err, body) { return err ? callback(err) : callback(err, new dns.Record(self, body)); @@ -253,8 +253,8 @@ module.exports = { method: 'DELETE' }; - self._asyncRequest(requestOptions, function (err, result) { + self._asyncRequest(requestOptions, function (err) { return callback(err); }); } -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/rackspace/dns/client/zones.js b/lib/pkgcloud/rackspace/dns/client/zones.js index c6e53a1d6..59f4db5bd 100644 --- a/lib/pkgcloud/rackspace/dns/client/zones.js +++ b/lib/pkgcloud/rackspace/dns/client/zones.js @@ -349,7 +349,7 @@ module.exports = { }; } - self._request(requestOptions, function (err, body, res) { + self._request(requestOptions, function (err, body) { return err ? callback(err) : callback(err, body); diff --git a/lib/pkgcloud/rackspace/dns/status.js b/lib/pkgcloud/rackspace/dns/status.js index 36f4263e1..d0ee9956c 100644 --- a/lib/pkgcloud/rackspace/dns/status.js +++ b/lib/pkgcloud/rackspace/dns/status.js @@ -31,7 +31,7 @@ Status.prototype.getDetails = function (callback) { qs: { showDetails: true } }; - self.client._request(requestOptions, function (err, body, res) { + self.client._request(requestOptions, function (err, body) { if (err) { return callback(err); } diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js index e024bfc9b..e4665343c 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js @@ -91,7 +91,7 @@ module.exports = { options = {}; } - self._request(requestOptions, function (err, body, res) { + self._request(requestOptions, function (err, body) { if (err) { return callback(err); } @@ -124,7 +124,7 @@ module.exports = { self._request({ path: urlJoin(_urlPrefix, loadBalancerId) - }, function (err, body, res) { + }, function (err, body) { if (err) { return callback(err); } @@ -387,7 +387,7 @@ module.exports = { self._request({ path: urlJoin(_urlPrefix, loadBalancerId, 'ssltermination'), method: 'DELETE' - }, function (err, body, res) { + }, function (err) { callback(err); }); }, @@ -409,7 +409,7 @@ module.exports = { self._request({ path: urlJoin(_urlPrefix, loadBalancerId, 'accesslist') - }, function (err, body, res) { + }, function (err, body) { return callback(err, body.accessList); }); }, @@ -502,7 +502,7 @@ module.exports = { self._request({ path: urlJoin(_urlPrefix, loadBalancerId, 'accesslist', '?id=' + list.join('&id=')), method: 'DELETE' - }, function (err, body, res) { + }, function (err) { return callback(err); }); }, diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js index cfffa79f2..118bdfd6e 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js @@ -212,4 +212,4 @@ module.exports = { : callback(err, body.nodeServiceEvents); }); } -}; \ No newline at end of file +}; diff --git a/lib/pkgcloud/redistogo/database/client/index.js b/lib/pkgcloud/redistogo/database/client/index.js index 69e1e25f6..73c8ebb48 100644 --- a/lib/pkgcloud/redistogo/database/client/index.js +++ b/lib/pkgcloud/redistogo/database/client/index.js @@ -93,8 +93,7 @@ Client.prototype.get = function (id, callback) { }), Array.prototype.slice.call(arguments).pop()); } var options, - path = '/instances', - self = this; + path = '/instances'; if (id !== null) { path = path + '/' + id; } @@ -119,8 +118,7 @@ Client.prototype.remove = function (id, callback) { }), Array.prototype.slice.call(arguments).pop()); } var options, - path = '/instances/' + id, - self = this; + path = '/instances/' + id; options = { uri : this._getUrl() + path + '.json', method : 'DELETE', @@ -143,4 +141,4 @@ Client.prototype.formatResponse = function (response) { metadata: response }; return database; -}; \ No newline at end of file +}; diff --git a/test/amazon/compute/client/groups-test.js b/test/amazon/compute/client/groups-test.js index 13fc49e69..fd810656e 100644 --- a/test/amazon/compute/client/groups-test.js +++ b/test/amazon/compute/client/groups-test.js @@ -97,7 +97,7 @@ describe('pkgcloud/amazon/groups', function () { client.getGroup('unit test', function (err, data) { should.not.exist(err); - // TODO + should.exist(data); hockInstance && hockInstance.done(); done(); }); diff --git a/test/amazon/compute/client/keys-test.js b/test/amazon/compute/client/keys-test.js index 2f5eea3c7..9e6284f53 100644 --- a/test/amazon/compute/client/keys-test.js +++ b/test/amazon/compute/client/keys-test.js @@ -96,7 +96,7 @@ describe('pkgcloud/amazon/keys', function () { client.getKey('unittest', function (err, data) { should.not.exist(err); - // TODO + should.exist(data); hockInstance && hockInstance.done(); done(); }); diff --git a/test/azure/compute/client/test-createServer.js b/test/azure/compute/client/test-createServer.js index 4f121723f..f21da9dc3 100644 --- a/test/azure/compute/client/test-createServer.js +++ b/test/azure/compute/client/test-createServer.js @@ -65,7 +65,7 @@ function testCreateServer(client) { return test; } -function testSetWait(client) { +function testSetWait() { var name = 'azure', test = {}; diff --git a/test/azure/compute/client/test-destroyServer.js b/test/azure/compute/client/test-destroyServer.js index 871fcd5e5..39b76ea7a 100644 --- a/test/azure/compute/client/test-destroyServer.js +++ b/test/azure/compute/client/test-destroyServer.js @@ -8,7 +8,7 @@ client.destroyServer('test-reboot', function (err, result) { if (err) { console.log(err); } else { - console.log('ok'); + console.log(result); } }); diff --git a/test/azure/compute/client/test-getImages.js b/test/azure/compute/client/test-getImages.js index 2dfa38b6f..e66894105 100644 --- a/test/azure/compute/client/test-getImages.js +++ b/test/azure/compute/client/test-getImages.js @@ -4,8 +4,6 @@ var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); -var options = {}; - /* client.getImages(options, function (err, result) { if (err) { diff --git a/test/azure/compute/client/test-getServer.js b/test/azure/compute/client/test-getServer.js index de0bcad82..7ee322074 100644 --- a/test/azure/compute/client/test-getServer.js +++ b/test/azure/compute/client/test-getServer.js @@ -4,8 +4,6 @@ var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); -var options = {}; - client.getServer('pkgcloud2', function (err, result) { if (err) { console.log(err); diff --git a/test/azure/compute/client/test-getServers.js b/test/azure/compute/client/test-getServers.js index 67d623c1e..e6025f68e 100644 --- a/test/azure/compute/client/test-getServers.js +++ b/test/azure/compute/client/test-getServers.js @@ -4,8 +4,6 @@ var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); -var options = {}; - client.getServers(function (err, result) { if (err) { console.log(err); diff --git a/test/azure/compute/client/test-rebootServer.js b/test/azure/compute/client/test-rebootServer.js index 945467ea4..360b2debf 100644 --- a/test/azure/compute/client/test-rebootServer.js +++ b/test/azure/compute/client/test-rebootServer.js @@ -50,7 +50,7 @@ function testCreateServer(client) { return test; } -function testSetWait(client) { +function testSetWait() { var name = 'azure', test = {}; diff --git a/test/azure/compute/client/test-stopServer.js b/test/azure/compute/client/test-stopServer.js index 71c675d66..4d985eb6a 100644 --- a/test/azure/compute/client/test-stopServer.js +++ b/test/azure/compute/client/test-stopServer.js @@ -4,8 +4,6 @@ var helpers = require('../../../helpers'); var client = helpers.createClient('azure', 'compute'); -var options = {}; - client.stopServer('pkgcloud1', function (err, result) { if (err) { console.log(err); diff --git a/test/azure/utils/test-cert.js b/test/azure/utils/test-cert.js index b68e9f6a4..e3d93f04a 100644 --- a/test/azure/utils/test-cert.js +++ b/test/azure/utils/test-cert.js @@ -1,11 +1,6 @@ //TODO: Make this a vows test var azureCert = require('../../../lib/pkgcloud/azure/utils/cert.js'); - -// load azure config file (you need to set this up with your azure account info) -var config = JSON.parse(fs.readFileSync('../configs/azure.json','utf8')); - - azureCert.getAzureCert('../../fixtures/azure/cert/management/management.pem', function (err, result) { if (err) { console.dir(err); diff --git a/test/azure/utils/test-createHostedService.js b/test/azure/utils/test-createHostedService.js index 9affe7aa1..db66bce3f 100644 --- a/test/azure/utils/test-createHostedService.js +++ b/test/azure/utils/test-createHostedService.js @@ -4,8 +4,6 @@ var helpers = require('../../helpers'); var azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'); var client = helpers.createClient('azure', 'compute'); -var options = {}; - azureApi.createHostedService(client, 'pkgcloud4', function (err, result) { if (err) { console.log(err); diff --git a/test/azure/utils/test-getOSImage.js b/test/azure/utils/test-getOSImage.js index 65c775565..ab37a02a9 100644 --- a/test/azure/utils/test-getOSImage.js +++ b/test/azure/utils/test-getOSImage.js @@ -4,8 +4,6 @@ var helpers = require('../../helpers'); var azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'); var client = helpers.createClient('azure', 'compute'); -var options = {}; - azureApi.getOSImage(client, 'OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd', function (err, result) { if (err) { console.log(err); diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 7e82d0d50..ad7a43f2b 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -218,7 +218,7 @@ providers.filter(function (provider) { }); }); -function setupVersionMock(client, provider, servers) { +setupVersionMock = function (client, provider, servers) { if (provider === 'digitalocean') { return true; } @@ -300,9 +300,9 @@ function setupVersionMock(client, provider, servers) { {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .reply(200, '', { 'x-api-version': '6.5.0' }); } -} +}; -function setupFlavorMock(client, provider, servers) { +setupFlavorMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .get('/v2/123456/flavors/detail', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) @@ -335,9 +335,9 @@ function setupFlavorMock(client, provider, servers) { {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); } -} +}; -function setupImagesMock(client, provider, servers) { +setupImagesMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .get('/v2/123456/images/detail', @@ -384,9 +384,9 @@ function setupImagesMock(client, provider, servers) { {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); } -} +}; -function setupServerMock(client, provider, servers) { +setupServerMock = function (client, provider, servers) { if (provider === 'digitalocean') { var account = require(__dirname + '/../../configs/mock/digitalocean'); @@ -555,9 +555,9 @@ function setupServerMock(client, provider, servers) { {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) .replyWithFile(200, __dirname + '/../../fixtures/hp/serverCreated.json'); } -} +}; -function setupDestroyMock(client, provider, servers) { +setupDestroyMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .delete('/v2/123456/servers/a0a5f183-b94e-4a41-a854-64cff53375bf', @@ -585,4 +585,4 @@ function setupDestroyMock(client, provider, servers) { })) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/destroy-server.json'); } -} +}; diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index 2af6a73d3..1c08571a9 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -122,7 +122,7 @@ providers.filter(function (provider) { }); }); -function setupMetaMock(client, provider, servers) { +setupMetaMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/images/506d077e-66bf-44ff-907a-588c5c79fa66/metadata', @@ -131,9 +131,9 @@ function setupMetaMock(client, provider, servers) { }}) .replyWithFile(202, __dirname + '/../../fixtures/openstack/metaResponse.json'); } -} +}; -function setupImagesMock(client, provider, servers) { +setupImagesMock = function (client, provider, servers) { if (provider === 'openstack') { servers.authServer .post('/v2.0/tokens', { @@ -162,4 +162,4 @@ function setupImagesMock(client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); } -} +}; diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 04585a84d..dfe151328 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -194,6 +194,7 @@ providers.filter(function (provider) { } context.currentServer.reboot(function(err) { + should.not.exist(err); done(); }); }); @@ -207,6 +208,7 @@ providers.filter(function (provider) { } context.currentServer.reboot(function (err) { + should.not.exist(err); done(); }); }); @@ -229,7 +231,7 @@ providers.filter(function (provider) { }); }); -function setupImagesMock(client, provider, servers) { +setupImagesMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.authServer .post('/v2.0/tokens', { @@ -330,9 +332,9 @@ function setupImagesMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); } -} +}; -function setupFlavorMock(client, provider, servers) { +setupFlavorMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .get('/v2/123456/flavors/detail') @@ -362,9 +364,9 @@ function setupFlavorMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); } -} +}; -function setupServerMock(client, provider, servers) { +setupServerMock = function (client, provider, servers) { if (provider === 'digitalocean') { var account = require(__dirname + '/../../configs/mock/digitalocean'); @@ -484,9 +486,9 @@ function setupServerMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } -} +}; -function setupGetServersMock(client, provider, servers) { +setupGetServersMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .get('/v2/123456/servers/detail') @@ -535,9 +537,9 @@ function setupGetServersMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/serverList.json'); } -} +}; -function setupGetServerMock(client, provider, servers) { +setupGetServerMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .get('/v1.0/537645/servers/20578901') @@ -575,7 +577,8 @@ function setupGetServerMock(client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } -} +}; + // //function batchThree(providerClient, providerName) { // var name = providerName || 'rackspace', @@ -946,7 +949,7 @@ function setupGetServerMock(client, provider, servers) { * * @return {String} - the xml reply containing the server name and status */ -var serverStatusReply = function (name, status) { +serverStatusReply = function (name, status) { var template = helpers.loadFixture('azure/server-status-template.xml'), params = {NAME: name, STATUS: status}; @@ -954,12 +957,3 @@ var serverStatusReply = function (name, status) { var result = _.template(template, params); return result; }; - -var filterPath = function (path) { - var name = PATH.basename(path); - if (path.search('embed-detail=true') !== -1) { - return '/getStatus?name=' + name; - } - - return path; -}; diff --git a/test/common/databases/databases-test.js b/test/common/databases/databases-test.js index 1776427e0..08c20c639 100644 --- a/test/common/databases/databases-test.js +++ b/test/common/databases/databases-test.js @@ -317,7 +317,7 @@ providers.filter(function (provider) { }); }); -function setupCreateDatabasesMock(hockInstance, provider) { +setupCreateDatabasesMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -354,9 +354,9 @@ function setupCreateDatabasesMock(hockInstance, provider) { }) .reply(202); } -} +}; -function setupCreateDatabasesForPaginationMock(hockInstance, provider) { +setupCreateDatabasesForPaginationMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -393,9 +393,9 @@ function setupCreateDatabasesForPaginationMock(hockInstance, provider) { }) .reply(202); } -} +}; -function setupModelCreateDatabasesMock(hockInstance, provider) { +setupModelCreateDatabasesMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -432,11 +432,9 @@ function setupModelCreateDatabasesMock(hockInstance, provider) { }) .reply(202); } -} +}; - - -function setupGetDatabasesMock(hockInstance, provider) { +setupGetDatabasesMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -458,9 +456,9 @@ function setupGetDatabasesMock(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases') .reply(200, {databases: [{name: 'TestDatabase'}, {name: 'TestDatabaseTwo'}]}); } -} +}; -function setupDestroyDatabasesMock(hockInstance, provider) { +setupDestroyDatabasesMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -482,9 +480,9 @@ function setupDestroyDatabasesMock(hockInstance, provider) { .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabase') .reply(202); } -} +}; -function setupDestroyLastDatabasesMock(hockInstance, provider) { +setupDestroyLastDatabasesMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -506,4 +504,4 @@ function setupDestroyLastDatabasesMock(hockInstance, provider) { .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/databases/TestDatabaseTwo') .reply(202); } -} +}; diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index f12246fc5..dc5ff4650 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -144,7 +144,7 @@ providers.filter(function (provider) { }); -function setupGetFlavorMock(hockInstance, provider) { +setupGetFlavorMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/flavors/3') @@ -160,4 +160,4 @@ function setupGetFlavorMock(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/3') .reply(200, helpers.loadFixture('hp/databaseFlavor3.json')); } -} +}; diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index ef75c9b21..82ee78d74 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -243,6 +243,7 @@ providers.filter(function (provider) { client.getInstances({ offset: testContext.marker }, function (err, instances, offset) { should.not.exist(err); should.exist(instances); + should.not.exist(offset); instances.should.be.an.Array; should.ok(instances.length >= 2 && instances.length < testContext.instancesQuantity); @@ -468,15 +469,16 @@ providers.filter(function (provider) { }); }); -function assertLinks(links) { + +assertLinks = function (links) { links.should.be.an.Array; links.forEach(function (link) { should.exist(link.href); should.exist(link.rel); }); -} +}; -function setupCreateInstanceMock(hockInstance, provider) { +setupCreateInstanceMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/flavors/1') @@ -525,9 +527,9 @@ function setupCreateInstanceMock(hockInstance, provider) { }) .reply(200, helpers.loadFixture('rackspace/createdDatabaseInstance.json')); } -} +}; -function setupGetInstancesMock(hockInstance, provider) { +setupGetInstancesMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -543,9 +545,9 @@ function setupGetInstancesMock(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances') .reply(200, helpers.loadFixture('hp/databaseInstances.json')); } -} +}; -function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { +setupGetDatabaseInstancesWithLimitMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances?limit=2') @@ -561,9 +563,9 @@ function setupGetDatabaseInstancesWithLimitMock(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances?limit=2') .reply(200, helpers.loadFixture('hp/databaseInstancesLimit2.json')); } -} +}; -function setupDestroyInstanceMock(hockInstance, provider) { +setupDestroyInstanceMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -585,9 +587,9 @@ function setupDestroyInstanceMock(hockInstance, provider) { .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') .reply(202); } -} +}; -function setGetInstanceMock(hockInstance, provider) { +setGetInstanceMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') @@ -603,9 +605,9 @@ function setGetInstanceMock(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f') .reply(200, helpers.loadFixture('hp/databaseInstance.json')); } -} +}; -function setGetFlavorsMock(hockInstance, provider) { +setGetFlavorsMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/flavors/2') @@ -621,9 +623,9 @@ function setGetFlavorsMock(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/2') .reply(200, helpers.loadFixture('hp/databaseFlavor2.json')); } -} +}; -function setupSetFlavorMock(hockInstance, provider) { +setupSetFlavorMock = function (hockInstance, provider) { if (provider ==='rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -663,9 +665,9 @@ function setupSetFlavorMock(hockInstance, provider) { }) .reply(202); } -} +}; -function setupResizeMock (hockInstance, provider) { +setupResizeMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -705,9 +707,9 @@ function setupResizeMock (hockInstance, provider) { }) .reply(202); } -} +}; -function setupGetOneFlavorMock(hockInstance, provider) { +setupGetOneFlavorMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/flavors/1') @@ -723,9 +725,9 @@ function setupGetOneFlavorMock(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors/1') .reply(200, helpers.loadFixture('hp/databaseFlavor1.json')); } -} +}; -function setupRestartInstanceMock (hockInstance, provider) { +setupRestartInstanceMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -747,4 +749,4 @@ function setupRestartInstanceMock (hockInstance, provider) { .post('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/action', { restart :{}}) .reply(202); } -} +}; diff --git a/test/common/databases/users-test.js b/test/common/databases/users-test.js index cf6441733..c2e990106 100644 --- a/test/common/databases/users-test.js +++ b/test/common/databases/users-test.js @@ -24,8 +24,7 @@ providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; }).forEach(function (provider) { describe('pkgcloud/['+provider+']/databases/users', function () { - var testContext = {}, - client, authHockInstance, hockInstance, authServer, server; + var client, authHockInstance, hockInstance, authServer, server; describe('The pkgcloud '+provider+' Database client', function () { @@ -293,7 +292,7 @@ describe('pkgcloud/['+provider+']/databases/users', function () { }); }); -function setupAuthenticationMock (authHockInstance, hockInstance, provider) { +setupAuthenticationMock = function (authHockInstance, hockInstance, provider) { if (provider === 'rackspace') { authHockInstance .post('/v2.0/tokens', { @@ -379,9 +378,9 @@ function setupAuthenticationMock (authHockInstance, hockInstance, provider) { else { throw new Error('not supported'); } -} +}; -function setupCreateUserMock(authHockInstance, hockInstance, provider) { +setupCreateUserMock = function (authHockInstance, hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -430,9 +429,9 @@ function setupCreateUserMock(authHockInstance, hockInstance, provider) { else { throw new Error('not supported'); } -} +}; -function setupCreateAnotherUserMock(hockInstance, provider) { +setupCreateAnotherUserMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -523,9 +522,9 @@ function setupCreateAnotherUserMock(hockInstance, provider) { else { throw new Error('not supported'); } -} +}; -function setupCreateMultiplsUsersMock(hockInstance, provider) { +setupCreateMultiplsUsersMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -601,9 +600,9 @@ function setupCreateMultiplsUsersMock(hockInstance, provider) { else { throw new Error('not supported'); } -} +}; -function setupCreateUsersWithRestrictedCharacters(hockInstance, provider) { +setupCreateUsersWithRestrictedCharacters = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -622,9 +621,9 @@ function setupCreateUsersWithRestrictedCharacters(hockInstance, provider) { else { throw new Error('not supported'); } -} +}; -function setupGetUsersMock(hockInstance, provider) { +setupGetUsersMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -650,9 +649,9 @@ function setupGetUsersMock(hockInstance, provider) { throw new Error('not supported'); } -} +}; -function setupEnableRootMock(hockInstance, provider) { +setupEnableRootMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -689,9 +688,9 @@ function setupEnableRootMock(hockInstance, provider) { } }); } -} +}; -function setupEnableRootMockWithStatus(hockInstance, provider) { +setupEnableRootMockWithStatus = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -713,9 +712,9 @@ function setupEnableRootMockWithStatus(hockInstance, provider) { .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') .reply(200, { rootEnabled: true }); } -} +}; -function setupDestroyUsersMock(hockInstance, provider) { +setupDestroyUsersMock = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -737,9 +736,9 @@ function setupDestroyUsersMock(hockInstance, provider) { .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTest') .reply(202); } -} +}; -function setupDestroyUsersMockWithPagination(hockInstance, provider) { +setupDestroyUsersMockWithPagination = function (hockInstance, provider) { if (provider === 'rackspace') { hockInstance .get('/v1.0/123456/instances') @@ -761,4 +760,4 @@ function setupDestroyUsersMockWithPagination(hockInstance, provider) { .delete('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users/joeTestTwo') .reply(202); } -} +}; diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index d0630382d..01b910aeb 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -98,8 +98,6 @@ providers.filter(function (provider) { }); it('the createNetwork() method should create a network', function (done) { - var m = mock ? 0.1 : 10; - if (mock) { setupNetworkMock(client, provider, { authServer: authHockInstance, @@ -160,13 +158,12 @@ providers.filter(function (provider) { client.updateNetwork(networkToUpdate, function(err,network){ should.not.exist(err); + should.exist(network); done(); }); }); it('the network.create() method should create a network', function (done) { - var m = mock ? 0.1 : 10; - if (mock) { setupNetworkModelCreateMock(client, provider, { authServer: authHockInstance, @@ -186,8 +183,6 @@ providers.filter(function (provider) { }); it('the network.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - var network = new Network(client); network.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; @@ -244,7 +239,7 @@ providers.filter(function (provider) { }); }); -function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ +setupDestroyNetworkMock = function (client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) @@ -260,9 +255,9 @@ function setupDestroyNetworkMock(client, provider, servers, currentNetwork){ .delete(urlJoin('/v2.0/networks', currentNetwork.id)) .reply(204); } -} +}; -function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ +setupUpdateNetworkMock = function (client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id), { @@ -299,9 +294,9 @@ function setupUpdateNetworkMock(client, provider, servers, currentNetwork){ }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } -} +}; -function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwork){ +setupModelDestroyedNetworkMock = function (client, provider, servers, currentNetwork){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', currentNetwork.id)) @@ -317,9 +312,9 @@ function setupModelDestroyedNetworkMock(client, provider, servers, currentNetwor .delete(urlJoin('/v2.0/networks', currentNetwork.id)) .reply(204); } -} +}; -function setupNetworksMock(client, provider, servers) { +setupNetworksMock = function (client, provider, servers) { if (provider === 'openstack') { servers.authServer .post('/v2.0/tokens', { @@ -392,9 +387,9 @@ function setupNetworksMock(client, provider, servers) { .get('/v2.0/networks') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/networks.json'); } -} +}; -function setupNetworkMock(client, provider, servers) { +setupNetworkMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', { @@ -422,9 +417,9 @@ function setupNetworkMock(client, provider, servers) { }) .replyWithFile(201, __dirname + '/../../fixtures/rackspace/network.json'); } -} +}; -function setupRefreshNetworkMock(client, provider, servers, network) { +setupRefreshNetworkMock = function (client, provider, servers, network) { if (provider === 'openstack') { servers.server .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks',network.id)) @@ -440,9 +435,9 @@ function setupRefreshNetworkMock(client, provider, servers, network) { .get(urlJoin('/v2.0/networks',network.id)) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } -} +}; -function setupNetworkModelCreateMock(client, provider, servers) { +setupNetworkModelCreateMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks', { @@ -470,9 +465,9 @@ function setupNetworkModelCreateMock(client, provider, servers) { }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } -} +}; -function setupGetNetworkMock(client, provider, servers) { +setupGetNetworkMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') @@ -488,9 +483,9 @@ function setupGetNetworkMock(client, provider, servers) { .get('/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } -} +}; -var serverStatusReply = function (name, status) { +serverStatusReply = function (name, status) { var template = helpers.loadFixture('azure/server-status-template.xml'), params = {NAME: name, STATUS: status}; @@ -499,7 +494,7 @@ var serverStatusReply = function (name, status) { return result; }; -var filterPath = function (path) { +filterPath = function (path) { var name = PATH.basename(path); if (path.search('embed-detail=true') !== -1) { return '/getStatus?name=' + name; diff --git a/test/common/network/port-test.js b/test/common/network/port-test.js index 22b52c888..55cb5e4b3 100644 --- a/test/common/network/port-test.js +++ b/test/common/network/port-test.js @@ -97,8 +97,6 @@ providers.filter(function (provider) { }); it('the createPort() method should create a port', function (done) { - var m = mock ? 0.1 : 10; - if (mock) { setupCreatePortMock(client, provider, { authServer: authHockInstance, @@ -161,13 +159,12 @@ providers.filter(function (provider) { client.updatePort(portToUpdate, function(err,network){ should.not.exist(err); + should.exist(network); done(); }); }); it('the port.create() method should create a port', function (done) { - var m = mock ? 0.1 : 10; - if (mock) { setupPortModelCreateMock(client, provider, { authServer: authHockInstance, @@ -187,8 +184,6 @@ providers.filter(function (provider) { }); it('the port.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - var port = new Port(client); port.id = context.ports[0].id; @@ -245,7 +240,7 @@ providers.filter(function (provider) { }); }); -function setupDestroyPortMock(client, provider, servers, currentPort){ +setupDestroyPortMock = function (client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) @@ -261,9 +256,9 @@ function setupDestroyPortMock(client, provider, servers, currentPort){ .delete(urlJoin('/v2.0/ports', currentPort.id)) .reply(204); } -} +}; -function setupUpdatePortMock(client, provider, servers, currentPort){ +setupUpdatePortMock = function (client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id), { @@ -324,9 +319,9 @@ function setupUpdatePortMock(client, provider, servers, currentPort){ }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } -} +}; -function setupModelDestroyedPortMock(client, provider, servers, currentPort){ +setupModelDestroyedPortMock = function (client, provider, servers, currentPort){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) @@ -342,9 +337,9 @@ function setupModelDestroyedPortMock(client, provider, servers, currentPort){ .delete(urlJoin('/v2.0/ports', currentPort.id)) .reply(204); } -} +}; -function setupPortsMock(client, provider, servers) { +setupPortsMock = function (client, provider, servers) { if (provider === 'openstack') { servers.authServer .post('/v2.0/tokens', { @@ -417,9 +412,9 @@ function setupPortsMock(client, provider, servers) { .get('/v2.0/ports') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/ports.json'); } -} +}; -function setupCreatePortMock(client, provider, servers) { +setupCreatePortMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', { @@ -447,9 +442,9 @@ function setupCreatePortMock(client, provider, servers) { }) .replyWithFile(201, __dirname + '/../../fixtures/rackspace/port.json'); } -} +}; -function setupRefreshPortMock(client, provider, servers, port) { +setupRefreshPortMock = function (client, provider, servers, port) { if (provider === 'openstack') { servers.server .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', port.id)) @@ -465,9 +460,9 @@ function setupRefreshPortMock(client, provider, servers, port) { .get(urlJoin('/v2.0/ports', port.id)) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } -} +}; -function setupPortModelCreateMock(client, provider, servers) { +setupPortModelCreateMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', { @@ -495,9 +490,9 @@ function setupPortModelCreateMock(client, provider, servers) { }) .replyWithFile(202, __dirname + '/../../fixtures/rackspace/port.json'); } -} +}; -function setupGetPortMock(client, provider, servers, currentPort) { +setupGetPortMock = function (client, provider, servers, currentPort) { if (provider === 'openstack') { servers.server .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/ports', currentPort.id)) @@ -513,4 +508,4 @@ function setupGetPortMock(client, provider, servers, currentPort) { .get(urlJoin('/v2.0/ports', currentPort.id)) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/port.json'); } -} +}; diff --git a/test/common/network/subnet-test.js b/test/common/network/subnet-test.js index c88030fee..80ccff35b 100644 --- a/test/common/network/subnet-test.js +++ b/test/common/network/subnet-test.js @@ -97,8 +97,6 @@ providers.filter(function (provider) { }); it('the createSubnet() method should create a subnet', function (done) { - var m = mock ? 0.1 : 10; - if (mock) { setupCreateSubnetMock(client, provider, { authServer: authHockInstance, @@ -161,13 +159,12 @@ providers.filter(function (provider) { client.updateSubnet(subnetToUpdate, function(err,network){ should.not.exist(err); + should.exist(network); done(); }); }); it('the subnet.create() method should create a subnet', function (done) { - var m = mock ? 0.1 : 10; - if (mock) { setupSubnetModelCreateMock(client, provider, { authServer: authHockInstance, @@ -187,8 +184,6 @@ providers.filter(function (provider) { }); it('the subnet.refresh() method should get a network', function (done) { - var m = mock ? 0.1 : 10; - var subnet = new Subnet(client); subnet.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; @@ -245,7 +240,7 @@ providers.filter(function (provider) { }); }); -function setupDestroySubnetMock(client, provider, servers, currentSubnet){ +setupDestroySubnetMock = function (client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) @@ -261,9 +256,9 @@ function setupDestroySubnetMock(client, provider, servers, currentSubnet){ .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) .reply(204); } -} +}; -function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ +setupUpdateSubnetMock = function (client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server .put(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id), { @@ -327,9 +322,9 @@ function setupUpdateSubnetMock(client, provider, servers, currentSubnet){ }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } -} +}; -function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet){ +setupModelDestroyedSubnetMock = function (client, provider, servers, currentSubnet){ if (provider === 'openstack') { servers.server .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) @@ -345,9 +340,9 @@ function setupModelDestroyedSubnetMock(client, provider, servers, currentSubnet) .delete(urlJoin('/v2.0/subnets', currentSubnet.id)) .reply(204); } -} +}; -function setupSubnetsMock(client, provider, servers) { +setupSubnetsMock = function (client, provider, servers) { if (provider === 'openstack') { servers.authServer .post('/v2.0/tokens', { @@ -420,9 +415,9 @@ function setupSubnetsMock(client, provider, servers) { .get('/v2.0/subnets') .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnets.json'); } -} +}; -function setupCreateSubnetMock(client, provider, servers) { +setupCreateSubnetMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', { @@ -450,9 +445,9 @@ function setupCreateSubnetMock(client, provider, servers) { }) .replyWithFile(201, __dirname + '/../../fixtures/rackspace/subnet.json'); } -} +}; -function setupRefreshSubnetMock(client, provider, servers, subnet) { +setupRefreshSubnetMock = function (client, provider, servers, subnet) { if (provider === 'openstack') { servers.server .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', subnet.id)) @@ -468,9 +463,9 @@ function setupRefreshSubnetMock(client, provider, servers, subnet) { .get(urlJoin('/v2.0/subnets', subnet.id)) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } -} +}; -function setupSubnetModelCreateMock(client, provider, servers) { +setupSubnetModelCreateMock = function (client, provider, servers) { if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', { @@ -498,9 +493,9 @@ function setupSubnetModelCreateMock(client, provider, servers) { }) .replyWithFile(202, __dirname + '/../../fixtures/rackspace/subnet.json'); } -} +}; -function setupGetSubnetMock(client, provider, servers, currentSubnet) { +setupGetSubnetMock= function (client, provider, servers, currentSubnet) { if (provider === 'openstack') { servers.server .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/subnets', currentSubnet.id)) @@ -516,4 +511,4 @@ function setupGetSubnetMock(client, provider, servers, currentSubnet) { .get(urlJoin('/v2.0/subnets', currentSubnet.id)) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/subnet.json'); } -} +}; diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index ddb0ada6e..bf1c1982e 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -415,7 +415,7 @@ providers.filter(function (provider) { }); }); -function setupCreateContainerMock(provider, client, servers) { +setupCreateContainerMock = function (provider, client, servers) { if (provider === 'rackspace') { servers.authServer .post('/v2.0/tokens', { @@ -544,9 +544,9 @@ function setupCreateContainerMock(provider, client, servers) { .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') .reply(201); } -} +}; -function setupGetContainersMock(provider, client, servers) { +setupGetContainersMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') @@ -572,9 +572,9 @@ function setupGetContainersMock(provider, client, servers) { .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/postContainers.json')); } -} +}; -function setupUploadStreamMock(provider, client, servers) { +setupUploadStreamMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', fillerama) @@ -608,9 +608,9 @@ function setupUploadStreamMock(provider, client, servers) { .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') .reply(200, '', { 'content-length': fillerama.length + 2 }); } -} +}; -function setupDownloadStreamMock(provider, client, servers) { +setupDownloadStreamMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') @@ -638,9 +638,9 @@ function setupDownloadStreamMock(provider, client, servers) { .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(200, fillerama, { 'content-length': fillerama.length + 2}); } -} +}; -function setupGetFileMock(provider, client, servers) { +setupGetFileMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') @@ -666,9 +666,9 @@ function setupGetFileMock(provider, client, servers) { .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt?format=json') .reply(200, '', { 'content-length': fillerama.length + 2 }); } -} +}; -function setupGetFilesMock(provider, client, servers) { +setupGetFilesMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container?format=json') @@ -702,9 +702,9 @@ function setupGetFilesMock(provider, client, servers) { content_type: 'text/plain' }]); } -} +}; -function setupRemoveFileMock(provider, client, servers) { +setupRemoveFileMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .delete('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') @@ -730,9 +730,9 @@ function setupRemoveFileMock(provider, client, servers) { .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt') .reply(204, ''); } -} +}; -function setupDestroyContainerMock(provider, client, servers) { +setupDestroyContainerMock = function (provider, client, servers) { if (provider === 'openstack') { servers.server .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') @@ -821,9 +821,9 @@ function setupDestroyContainerMock(provider, client, servers) { .delete('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container') .reply(204); } -} +}; -function setupGetContainers2Mock(provider, client, servers) { +setupGetContainers2Mock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') @@ -849,4 +849,4 @@ function setupGetContainers2Mock(provider, client, servers) { .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?format=json') .reply(200, helpers.loadFixture('hp/preContainers.json')); } -} +}; diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index e3dfc9bea..0b275eb7f 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -25,7 +25,6 @@ providers.filter(function (provider) { describe('pkgcloud/common/storage/base [' + provider + ']', function () { var client = helpers.createClient(provider, 'storage'), - context = {}, authServer, server, authHockInstance, hockInstance; @@ -106,7 +105,7 @@ providers.filter(function (provider) { }); }); -function setupUploadStreamError(provider, client, servers) { +setupUploadStreamError = function (provider, client, servers) { if (provider === 'rackspace') { servers.authServer .post('/v2.0/tokens', { @@ -200,4 +199,4 @@ function setupUploadStreamError(provider, client, servers) { .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/test-file.txt', 'foo') .reply(400); } -} +}; diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index c559404e9..8554b255c 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -191,7 +191,7 @@ exports.serverTest = function (nock, testHelpers) { * @param helpers - test helper object * @return {String} - the xml reply containing the server name and status */ -var serverStatusReply = function (name, status) { +serverStatusReply = function (name, status) { var template = helpers.loadFixture('azure/server-status-template.xml'), params = {NAME: name, STATUS: status}; @@ -199,14 +199,3 @@ var serverStatusReply = function (name, status) { var result = _.template(template, params); return result; }; - -var filterPath = function (path) { - var name = PATH.basename(path); - if (path.search('embed-detail=true') !== -1) { - return '/getStatus?name=' + name; - } - - return path; -}; - - diff --git a/test/hp/compute/authentication-test.js b/test/hp/compute/authentication-test.js index 34a6e6efc..a5db897de 100644 --- a/test/hp/compute/authentication-test.js +++ b/test/hp/compute/authentication-test.js @@ -46,8 +46,6 @@ describe('pkgcloud/hp/compute/authentication', function () { }); describe('the auth() method with a valid username and api key', function () { - var err, res; - beforeEach(function (done) { client = helpers.createClient('hp', 'compute'); @@ -86,7 +84,7 @@ describe('pkgcloud/hp/compute/authentication', function () { region: 'custom region' }); - var err, res; + var err; beforeEach(function (done) { diff --git a/test/hp/network/authentication-test.js b/test/hp/network/authentication-test.js index a3e8875ce..613d625cb 100644 --- a/test/hp/network/authentication-test.js +++ b/test/hp/network/authentication-test.js @@ -46,8 +46,6 @@ describe('pkgcloud/hp/network/authentication', function () { }); describe('the auth() method with a valid username and api key', function () { - var err, res; - beforeEach(function (done) { client = helpers.createClient('hp', 'compute'); @@ -86,7 +84,7 @@ describe('pkgcloud/hp/network/authentication', function () { region: 'custom region' }); - var err, res; + var err; beforeEach(function (done) { diff --git a/test/hp/storage/authentication-test.js b/test/hp/storage/authentication-test.js index 380de8355..c3ddb6eae 100644 --- a/test/hp/storage/authentication-test.js +++ b/test/hp/storage/authentication-test.js @@ -134,6 +134,7 @@ describe('pkgcloud/hp/storage/authentication', function () { badClient.auth(function (err, res) { should.exist(err); + should.not.exist(res); authHockInstance && authHockInstance.done(); done(); }); diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js index c476fdd28..efe2a1ab1 100644 --- a/test/iriscouch/databases/databases-redis-test.js +++ b/test/iriscouch/databases/databases-redis-test.js @@ -127,9 +127,9 @@ describe('pkgcloud/iriscouch/databases-redis', function () { // // Just a quick and lazy random password generator // -function randomPassword(length) { +randomPassword = function(length) { if (length == 1) { return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48); } return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48) + randomPassword(length - 1); -} +}; diff --git a/test/openstack/compute/client/startServer-test.js b/test/openstack/compute/client/startServer-test.js index 785cc8ec1..8fde5b6c0 100644 --- a/test/openstack/compute/client/startServer-test.js +++ b/test/openstack/compute/client/startServer-test.js @@ -12,11 +12,8 @@ var should = require('should'), http = require('http'), mock = !!process.env.MOCK; - var client = helpers.createClient('openstack', 'compute'); -var options = {}; - describe('pkgcloud/common/compute/server[openstack]', function () { var authHockInstance, hockInstance, authServer, server; diff --git a/test/openstack/compute/client/stopServer-test.js b/test/openstack/compute/client/stopServer-test.js index d80220486..ec1378f33 100644 --- a/test/openstack/compute/client/stopServer-test.js +++ b/test/openstack/compute/client/stopServer-test.js @@ -12,11 +12,8 @@ var should = require('should'), http = require('http'), mock = !!process.env.MOCK; - var client = helpers.createClient('openstack', 'compute'); -var options = {}; - describe('pkgcloud/common/compute/server[openstack]', function () { var authHockInstance, hockInstance, authServer, server; diff --git a/test/openstack/identity/identity-test.js b/test/openstack/identity/identity-test.js index d4646da7a..db59b6dd8 100644 --- a/test/openstack/identity/identity-test.js +++ b/test/openstack/identity/identity-test.js @@ -180,6 +180,7 @@ describe('pkgcloud/openstack/identity', function () { userClient._identity.token.tenant.id, function (err, body) { should.not.exist(err); + should.exist(body); done(); }); }); @@ -264,12 +265,14 @@ describe('pkgcloud/openstack/identity', function () { function (next) { adminClient.getTenantInfo(userClient._identity.token.tenant.id, function (err, success) { should.not.exist(err); + should.exist(success); next(); }); }, function (next) { userClient.getTenantInfo(userClient._identity.token.tenant.id, function (err, success) { should.exist(err); + should.not.exist(success); next(); }); } diff --git a/test/openstack/identity/service-test.js b/test/openstack/identity/service-test.js index 9e0028938..a26c7cd60 100644 --- a/test/openstack/identity/service-test.js +++ b/test/openstack/identity/service-test.js @@ -4,13 +4,13 @@ describe('pkgcloud openstack context Service Class', function() { it('with no options should throw an error', function() { (function() { - var x = new context.Service(); + new context.Service(); }).should.throw('details are a required argument'); }); it('with no details should throw an error', function () { (function () { - var x = new context.Service('ORD'); + new context.Service('ORD'); }).should.throw('details are a required argument'); }); diff --git a/test/openstack/orchestration/create-stacks-test.js b/test/openstack/orchestration/create-stacks-test.js index 9b9dd8be6..fa323d63a 100644 --- a/test/openstack/orchestration/create-stacks-test.js +++ b/test/openstack/orchestration/create-stacks-test.js @@ -17,8 +17,6 @@ var should = require('should'), var client = helpers.createClient('openstack', 'orchestration'); -var options = {}; - describe('pkgcloud/openstack/orchestration/stacks[createStacks]', function () { var authHockInstance, hockInstance, authServer, server; diff --git a/test/openstack/orchestration/get-stacks-test.js b/test/openstack/orchestration/get-stacks-test.js index 3b763e1ee..00c156b33 100644 --- a/test/openstack/orchestration/get-stacks-test.js +++ b/test/openstack/orchestration/get-stacks-test.js @@ -16,8 +16,6 @@ var should = require('should'), var client = helpers.createClient('openstack', 'orchestration'); -var options = {}; - describe('pkgcloud/openstack/orchestration/stacks[getStacks]', function () { var authHockInstance, hockInstance, authServer, server; diff --git a/test/rackspace/blockstorage/volumes-test.js b/test/rackspace/blockstorage/volumes-test.js index 2b4e19ed2..201cc4689 100644 --- a/test/rackspace/blockstorage/volumes-test.js +++ b/test/rackspace/blockstorage/volumes-test.js @@ -16,7 +16,7 @@ var should = require('should'), describe('pkgcloud/rackspace/blockstorage/volumes', function () { var client, - testContext = {}, authHockInstance, hockInstance, server, authServer; + authHockInstance, hockInstance, server, authServer; before(function (done) { client = helpers.createClient('rackspace', 'blockstorage'); diff --git a/test/rackspace/compute/authentication-test.js b/test/rackspace/compute/authentication-test.js index ab6a111e2..df884616f 100644 --- a/test/rackspace/compute/authentication-test.js +++ b/test/rackspace/compute/authentication-test.js @@ -76,8 +76,6 @@ describe('pkgcloud/rackspace/compute/authentication', function () { describe('the auth() method with a valid username and api key', function () { - var err, res; - beforeEach(function (done) { client = helpers.createClient('rackspace', 'compute'); @@ -134,7 +132,7 @@ describe('pkgcloud/rackspace/compute/authentication', function () { protocol: 'http://' }); - var err, res; + var err; beforeEach(function (done) { diff --git a/test/rackspace/compute/personality-test.js b/test/rackspace/compute/personality-test.js index 254537af2..c44e8369d 100644 --- a/test/rackspace/compute/personality-test.js +++ b/test/rackspace/compute/personality-test.js @@ -45,7 +45,7 @@ describe('pkgcloud/rackspace/compute/personality', function () { it('should connect over ssh without a password prompt and validate the key', function(done) { - var data; + var data, errorData; testServer.setWait({ status: testServer.STATUS.running }, 5000, function () { var ssh = spawn('ssh', [ @@ -64,6 +64,7 @@ describe('pkgcloud/rackspace/compute/personality', function () { ssh.stderr.on('error', onError); ssh.stderr.on('data', function (chunk) { + errorData += chunk; }); ssh.stdout.on('error', onError); ssh.stdout.on('data', function (chunk) { diff --git a/test/rackspace/databases/authentication-test.js b/test/rackspace/databases/authentication-test.js index 562a6addb..63aecd34f 100644 --- a/test/rackspace/databases/authentication-test.js +++ b/test/rackspace/databases/authentication-test.js @@ -15,7 +15,7 @@ var should = require('should'), mock = process.env.MOCK; describe('pkgcloud/rackspace/database/authentication', function() { - var client, testContext = {}, authHockInstance, hockInstance, authServer, server; + var client, authHockInstance, hockInstance, authServer, server; before(function(done) { client = helpers.createClient('rackspace', 'database'); @@ -92,7 +92,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { describe('the auth() method with a valid username and api key', function() { var client = helpers.createClient('rackspace', 'database'), - err, res; + err; beforeEach(function(done) { @@ -143,7 +143,7 @@ describe('pkgcloud/rackspace/database/authentication', function() { authUrl: 'localhost:12346' }); - var err, res; + var err; beforeEach(function (done) { diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js index 289d4c8bc..e6debdded 100644 --- a/test/rackspace/databases/user-limit-test.js +++ b/test/rackspace/databases/user-limit-test.js @@ -129,15 +129,15 @@ var setupAuthenticationMock, setupGetUsersMock; }); }); -function setupGetUsersMock(hockInstance) { +setupGetUsersMock = function(hockInstance) { hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); -} +}; -function setupAuthenticationMock (authHockInstance) { +setupAuthenticationMock = function(authHockInstance) { authHockInstance .post('/v2.0/tokens', { auth: { @@ -148,4 +148,4 @@ function setupAuthenticationMock (authHockInstance) { } }) .reply(200, helpers.getRackspaceAuthResponse()); -} +}; diff --git a/test/rackspace/storage/authentication-test.js b/test/rackspace/storage/authentication-test.js index 5c40e75c4..ce5a23ea4 100644 --- a/test/rackspace/storage/authentication-test.js +++ b/test/rackspace/storage/authentication-test.js @@ -133,6 +133,7 @@ describe('pkgcloud/rackspace/storage/authentication', function () { badClient.auth(function (err, res) { should.exist(err); + should.not.exist(res); authHockInstance && authHockInstance.done(); done(); }); From 2aa79a7881733cee71da7e0ab0ab0c698a77ca20 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 20:39:46 +0000 Subject: [PATCH 282/460] Enabling "unused" lint check. --- .jshintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index f9dc1bda6..c20f57fe7 100644 --- a/.jshintrc +++ b/.jshintrc @@ -23,7 +23,7 @@ // "single" : require single quotes // "double" : require double quotes "undef" : false, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : false, // true: Require all defined variables be used + "unused" : true, // true: Require all defined variables be used "strict" : false, // true: Requires all functions run in ES5 Strict Mode "maxparams" : false, // {int} Max number of formal params allowed per function "maxdepth" : false, // {int} Max depth of nested blocks (within functions) From b823882fbd0b340223af125ea0e397f47f5ec96c Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 20:52:13 +0000 Subject: [PATCH 283/460] Printing unused variables in examples (so they are no longer unused). --- examples/compute/amazon.js | 2 ++ examples/compute/joyent.js | 3 +++ examples/storage/amazon.js | 2 ++ examples/storage/azure.js | 2 ++ examples/storage/rackspace.js | 2 ++ 5 files changed, 11 insertions(+) diff --git a/examples/compute/amazon.js b/examples/compute/amazon.js index f0c19f743..ded5465e4 100644 --- a/examples/compute/amazon.js +++ b/examples/compute/amazon.js @@ -5,3 +5,5 @@ var client = pkgcloud.compute.createClient({ accessKey: 'asdfkjas;dkj43498aj3n', accessKeyId: '98kja34lkj' }); + +console.log(client); diff --git a/examples/compute/joyent.js b/examples/compute/joyent.js index 102608754..ff6971bbb 100644 --- a/examples/compute/joyent.js +++ b/examples/compute/joyent.js @@ -12,6 +12,8 @@ var client = pkgcloud.compute.createClient({ key: fs.readFileSync(path.join(process.env.HOME, '.ssh/id_rsa'), 'ascii') }); +console.log(client); + // // Alternatively create a client with a username / password pair // @@ -21,3 +23,4 @@ var otherClient = pkgcloud.compute.createClient({ password: 'your-password' }); +console.log(otherClient); diff --git a/examples/storage/amazon.js b/examples/storage/amazon.js index 42fc98ebd..eeecfc009 100644 --- a/examples/storage/amazon.js +++ b/examples/storage/amazon.js @@ -5,3 +5,5 @@ var client = pkgcloud.storage.createClient({ accessKey: 'asdfkjas;dkj43498aj3n', accessKeyId: '98kja34lkj' }); + +console.log(client); diff --git a/examples/storage/azure.js b/examples/storage/azure.js index 6ea6ccbb5..ac08a3271 100644 --- a/examples/storage/azure.js +++ b/examples/storage/azure.js @@ -5,3 +5,5 @@ var azure = pkgcloud.storage.createClient({ storageAccount: 'test-storage-account', // Name of your storage account storageAccessKey: 'test-storage-access-key' // Access key for storage account }); + +console.log(azure); diff --git a/examples/storage/rackspace.js b/examples/storage/rackspace.js index 604fa7f38..83331a0e1 100644 --- a/examples/storage/rackspace.js +++ b/examples/storage/rackspace.js @@ -88,6 +88,7 @@ rackspace.getContainer('container-name', function (err, container) { return; } console.log('Successfully set bucket as CDN bucket'); + console.log(cont); }); }); @@ -106,5 +107,6 @@ rackspace.getContainer('sample-container', function (err, container) { } console.log('Container ' + container.name + ' was successfully destroyed.'); + console.log(result); }); }); From 3b8ff3568da3c566fae7951851bf5e2a808412a2 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 5 Dec 2014 13:01:19 -0800 Subject: [PATCH 284/460] Cleaning up examples to actually do something --- examples/compute/amazon.js | 10 +++++++++- examples/compute/joyent.js | 21 +++++++++++++++++++-- examples/storage/amazon.js | 10 +++++++++- examples/storage/azure.js | 10 +++++++++- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/examples/compute/amazon.js b/examples/compute/amazon.js index ded5465e4..a1bc22674 100644 --- a/examples/compute/amazon.js +++ b/examples/compute/amazon.js @@ -6,4 +6,12 @@ var client = pkgcloud.compute.createClient({ accessKeyId: '98kja34lkj' }); -console.log(client); +client.getServers(function (err, servers) { + if (err) { + console.error(err); + } + + servers.forEach(function (server) { + console.log(server.toJSON()); + }); +}); diff --git a/examples/compute/joyent.js b/examples/compute/joyent.js index ff6971bbb..3db687231 100644 --- a/examples/compute/joyent.js +++ b/examples/compute/joyent.js @@ -12,7 +12,15 @@ var client = pkgcloud.compute.createClient({ key: fs.readFileSync(path.join(process.env.HOME, '.ssh/id_rsa'), 'ascii') }); -console.log(client); +client.getServers(function (err, servers) { + if (err) { + console.error(err); + } + + servers.forEach(function (server) { + console.log(server.toJSON()); + }); +}); // // Alternatively create a client with a username / password pair @@ -23,4 +31,13 @@ var otherClient = pkgcloud.compute.createClient({ password: 'your-password' }); -console.log(otherClient); +client.otherClient(function (err, servers) { + if (err) { + console.error(err); + } + + servers.forEach(function (server) { + console.log(server.toJSON()); + }); +}); + diff --git a/examples/storage/amazon.js b/examples/storage/amazon.js index eeecfc009..c42338b64 100644 --- a/examples/storage/amazon.js +++ b/examples/storage/amazon.js @@ -6,4 +6,12 @@ var client = pkgcloud.storage.createClient({ accessKeyId: '98kja34lkj' }); -console.log(client); +amazon.getContainers(function (err, containers) { + if (err) { + console.error(err); + } + + containers.forEach(function (container) { + console.log(container.toJSON()); + }); +}); \ No newline at end of file diff --git a/examples/storage/azure.js b/examples/storage/azure.js index ac08a3271..8028b3d99 100644 --- a/examples/storage/azure.js +++ b/examples/storage/azure.js @@ -6,4 +6,12 @@ var azure = pkgcloud.storage.createClient({ storageAccessKey: 'test-storage-access-key' // Access key for storage account }); -console.log(azure); +azure.getContainers(function (err, containers) { + if (err) { + console.error(err); + } + + containers.forEach(function (container) { + console.log(container.toJSON()); + }); +}); \ No newline at end of file From bc57f62c1a84601c57018e85a3c0e622bb9e74ec Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Fri, 5 Dec 2014 13:06:22 -0800 Subject: [PATCH 285/460] Fixing a typo in the joyent example --- examples/compute/joyent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/compute/joyent.js b/examples/compute/joyent.js index 3db687231..6164545a9 100644 --- a/examples/compute/joyent.js +++ b/examples/compute/joyent.js @@ -31,7 +31,7 @@ var otherClient = pkgcloud.compute.createClient({ password: 'your-password' }); -client.otherClient(function (err, servers) { +otherClient.getServers(function (err, servers) { if (err) { console.error(err); } From b167f200543e3bdfc526518410569121c105c1cb Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 5 Dec 2014 21:14:37 +0000 Subject: [PATCH 286/460] Fixing typo. --- examples/storage/amazon.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/storage/amazon.js b/examples/storage/amazon.js index c42338b64..3dd2d643c 100644 --- a/examples/storage/amazon.js +++ b/examples/storage/amazon.js @@ -6,7 +6,7 @@ var client = pkgcloud.storage.createClient({ accessKeyId: '98kja34lkj' }); -amazon.getContainers(function (err, containers) { +client.getContainers(function (err, containers) { if (err) { console.error(err); } @@ -14,4 +14,4 @@ amazon.getContainers(function (err, containers) { containers.forEach(function (container) { console.log(container.toJSON()); }); -}); \ No newline at end of file +}); From a7a90d4b9cfa0e7ab3f3d38e64f730f2999c8886 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:05:32 +0000 Subject: [PATCH 287/460] Removing unused functions. --- test/common/network/network-test.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index 01b910aeb..bc2d41fc4 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -484,21 +484,3 @@ setupGetNetworkMock = function (client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/rackspace/network.json'); } }; - -serverStatusReply = function (name, status) { - - var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; - - var result = _.template(template, params); - return result; -}; - -filterPath = function (path) { - var name = PATH.basename(path); - if (path.search('embed-detail=true') !== -1) { - return '/getStatus?name=' + name; - } - - return path; -}; From 2e5ae3c0018c2b6ffff10617cf0d43a3cb874c48 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:06:00 +0000 Subject: [PATCH 288/460] Removing old variable definition. --- lib/pkgcloud/openstack/storage/client/files.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index a422b0ac7..3bd212a47 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -175,7 +175,6 @@ exports.upload = function (options) { */ exports.download = function (options, callback) { var self = this, - success = callback ? onDownload : null, container = options.container, inputStream, apiStream; From 6ddfca8a810fb6680c848a0a55ba8984f8ff706c Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:13:31 +0000 Subject: [PATCH 289/460] Adding undefined variables for required modules. --- examples/compute/joyent.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/compute/joyent.js b/examples/compute/joyent.js index 6164545a9..2b06895c5 100644 --- a/examples/compute/joyent.js +++ b/examples/compute/joyent.js @@ -1,4 +1,6 @@ -var pkgcloud = require('../../lib/pkgcloud'); +var fs = require('fs'), + path = require('path'), + pkgcloud = require('../../lib/pkgcloud'); // // Joyent requires a username / password or key / keyId combo. From 7737576e6b267b39057f004c43d17fec8b5ca939 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:14:28 +0000 Subject: [PATCH 290/460] Declaring variables, not just defining them. --- lib/pkgcloud/hp/identity/hpIdentity.js | 2 +- lib/pkgcloud/rackspace/identity/rackspaceIdentity.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/hp/identity/hpIdentity.js b/lib/pkgcloud/hp/identity/hpIdentity.js index 8d47cecb2..89d340011 100644 --- a/lib/pkgcloud/hp/identity/hpIdentity.js +++ b/lib/pkgcloud/hp/identity/hpIdentity.js @@ -11,7 +11,7 @@ var identity = require('../../openstack/context'), Identity = identity.Identity, util = require('util'); -exports.Identity = HPIdentity = function (options) { +var HPIdentity = exports.Identity = function (options) { this.options = options; this.name = 'HPIdentity'; diff --git a/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js b/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js index 49373f6f2..7909b8fe1 100644 --- a/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js +++ b/lib/pkgcloud/rackspace/identity/rackspaceIdentity.js @@ -12,7 +12,7 @@ var identity = require('../../openstack/context'), Identity = identity.Identity, util = require('util'); -exports.Identity = RackspaceIdentity = function (options) { +var RackspaceIdentity = exports.Identity = function (options) { this.options = options; this.name = 'RackspaceIdentity'; From f8e6bbee83108541c5acb41b74e2e829c3b0e1f1 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:15:02 +0000 Subject: [PATCH 291/460] Declaring variables before defining and using them. --- lib/pkgcloud/openstack/network/client/networks.js | 3 +++ lib/pkgcloud/openstack/network/client/ports.js | 3 +++ lib/pkgcloud/openstack/network/client/subnets.js | 3 +++ 3 files changed, 9 insertions(+) diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index df4a51558..076c2d897 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -10,6 +10,9 @@ var urlJoin = require('url-join'); var networksResourcePath = '/networks'; +// Declaring variables for helper functions defined later +var _convertNetworkToWireFormat; + /** * client.getNetworks * diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index 2210f47e2..8193a726b 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -10,6 +10,9 @@ var urlJoin = require('url-join'); var portsResourcePath = '/ports'; +// Declaring variables for helper functions defined later +var _convertPortToWireFormat; + /** * client.getPorts * diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index c9b660d92..babae75f0 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -10,6 +10,9 @@ var urlJoin = require('url-join'); var subnetsResourcePath = '/subnets'; +// Declaring variables for helper functions defined later +var _convertSubnetToWireFormat; + /** * client.getSubnets * From b084fdeb26eeeedad6782243525c636457b05f09 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:16:07 +0000 Subject: [PATCH 292/460] Declaring and defining variable so it can be referenced from skipped test. --- test/common/compute/server-test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index dfe151328..f84f5eb07 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -21,7 +21,7 @@ var azureOptions = require('../../fixtures/azure/azure-options.json'); // Declaring variables for helper functions defined later var setupImagesMock, setupFlavorMock, setupServerMock, setupGetServersMock, - setupGetServerMock, serverStatusReply; + setupGetServerMock, setupRebootMock, serverStatusReply; azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); @@ -579,6 +579,10 @@ setupGetServerMock = function (client, provider, servers) { } }; +setupRebootMock = function() { + // TODO +}; + // //function batchThree(providerClient, providerName) { // var name = providerName || 'rackspace', From aab33f903f124f0f3ee93b277bde9f05aa1a7c3d Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:16:22 +0000 Subject: [PATCH 293/460] Moving helper functions towards bottom; declaring their variables at top. --- lib/pkgcloud/azure/utils/azureApi.js | 228 ++++++++++++++------------- 1 file changed, 115 insertions(+), 113 deletions(-) diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index 38cd405ab..7a90eaa85 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -32,6 +32,8 @@ var MINIMUM_POLL_INTERVAL = exports.MINIMUM_POLL_INTERVAL = 3000; // Declaring variables for helper functions defined later var createVM, createLinuxVM, createWindowsVM, validateCreateOptions, getServer, + getServers, rebootServer, deleteHostedService, destroyServer, createImage, + captureServer, destroyImage, getMediaLinkUrl, createEndpoints, makeTemplateRequest, createHostedService, addCertificate, getHostedServices, deleteServer, getOSImage, deleteOSDisk, deleteOSBlob, getServersFromServices, getServersFromService, isVM, getHostedServiceProperties, pollRequestStatus, @@ -138,119 +140,6 @@ exports.createServer = function (client, options, callback) { ); }; -createVM = function (client, options, vmOptions, callback) { - // check OS type of image to determine if we are creating a linux or windows VM - switch (vmOptions.image.OS.toLowerCase()) { - case 'linux': - createLinuxVM(client, options, vmOptions, callback); - break; - case 'windows': - createWindowsVM(client, options, vmOptions, callback); - break; - default: - callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); - break; - } -}; - -getMediaLinkUrl = function (storageAccount, fileName) { - return 'http://' + storageAccount + '.' + STORAGE_ENDPOINT + '/vhd/' + fileName; -}; - -createEndpoints = function (ports) { - var endPoints = '', - template = templates.loadSync('endpoint.xml'); - - (ports || []).forEach(function (port) { - endPoints += templates.compileSync(template, port); - }); - return endPoints; -}; - -createLinuxVM = function (client, options, vmOptions, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + options.name + '/deployments'; - var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); - var label = new Buffer(options.name).toString('base64'); - - var configParams = { - NAME: options.name, - LABEL_BASE64: label, - USERNAME: options.username, - PASSWORD: options.password, - SSH_CERTIFICATE_FINGERPRINT: vmOptions.sshCertInfo.fingerprint, - PORT: options.ssh.port || '22', - LOCAL_PORT: options.ssh.localPort || '22', - ROLESIZE: options.flavor, - ENDPOINTS: createEndpoints(options.ports), - OS_SOURCE_IMAGE_NAME: vmOptions.image.Name, - OS_IMAGE_MEDIALINK: mediaLink - }; - - makeTemplateRequest(client, path, 'linuxDeployment.xml', configParams, callback); -}; - -createWindowsVM = function (client, options, vmOptions, callback) { - var path = client.subscriptionId + '/services/hostedservices/' + options.name + '/deployments'; - var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); - var label = new Buffer(options.name).toString('base64'); - - var configParams = { - NAME: options.name, - COMPUTER_NAME: options.computerName || options.name.slice(0, 15), - LABEL_BASE64: label, - PASSWORD: options.password, - ROLESIZE: options.flavor, - ENDPOINTS: createEndpoints(options.ports), - OS_SOURCE_IMAGE_NAME: vmOptions.image.Name, - OS_IMAGE_MEDIALINK: mediaLink - }; - - makeTemplateRequest(client, path, 'windowsDeployment.xml', configParams, callback); -}; - -captureServer = function (client, serverName, targetImageName, callback) { - // /services/hostedservices//deployments//roleinstances//operations - var path = client.subscriptionId + '/services/hostedservices/' + - serverName + '/deployments/' + - serverName + '/roleInstances/' + - serverName + '/Operations'; - - var configParams = { - NAME: targetImageName - }; - - makeTemplateRequest(client, path, 'captureRole.xml', configParams, callback); -}; - -var deleteImage = function (client, image, callback) { - // https://management.core.windows.net//services/images/ - var path = client.subscriptionId + '/services/images/' + image.Name; - - var configParams = { - LABEL: image.LABEL - }; - - makeTemplateRequest(client, path, 'deleteImage.xml', configParams, callback); -}; - -validateCreateOptions = function (options, config, callback) { - if (typeof options === 'function') { - options = {}; - } - options = options || {}; // no args - - // check required options values - ['flavor', 'image', 'name', 'username', 'password', 'location'].forEach(function (member) { - if (!options[member]) { - errs.handle( - errs.create({ message: 'options.' + member + ' is a required argument.' }), - callback - ); - } - }); - callback(); -}; - /** * getServer */ @@ -681,6 +570,17 @@ createImage = exports.createImage = function (client, serverName, targetImageNam ); }; +var deleteImage = function (client, image, callback) { + // https://management.core.windows.net//services/images/ + var path = client.subscriptionId + '/services/images/' + image.Name; + + var configParams = { + LABEL: image.LABEL + }; + + makeTemplateRequest(client, path, 'deleteImage.xml', configParams, callback); +}; + /** * destroyImage() * 1. get the requested image @@ -701,6 +601,108 @@ destroyImage = exports.destroyImage = function (client, imageName, callback) { ); }; +createVM = function (client, options, vmOptions, callback) { + // check OS type of image to determine if we are creating a linux or windows VM + switch (vmOptions.image.OS.toLowerCase()) { + case 'linux': + createLinuxVM(client, options, vmOptions, callback); + break; + case 'windows': + createWindowsVM(client, options, vmOptions, callback); + break; + default: + callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS})); + break; + } +}; + +getMediaLinkUrl = function (storageAccount, fileName) { + return 'http://' + storageAccount + '.' + STORAGE_ENDPOINT + '/vhd/' + fileName; +}; + +createEndpoints = function (ports) { + var endPoints = '', + template = templates.loadSync('endpoint.xml'); + + (ports || []).forEach(function (port) { + endPoints += templates.compileSync(template, port); + }); + return endPoints; +}; + +createLinuxVM = function (client, options, vmOptions, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + options.name + '/deployments'; + var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); + var label = new Buffer(options.name).toString('base64'); + + var configParams = { + NAME: options.name, + LABEL_BASE64: label, + USERNAME: options.username, + PASSWORD: options.password, + SSH_CERTIFICATE_FINGERPRINT: vmOptions.sshCertInfo.fingerprint, + PORT: options.ssh.port || '22', + LOCAL_PORT: options.ssh.localPort || '22', + ROLESIZE: options.flavor, + ENDPOINTS: createEndpoints(options.ports), + OS_SOURCE_IMAGE_NAME: vmOptions.image.Name, + OS_IMAGE_MEDIALINK: mediaLink + }; + + makeTemplateRequest(client, path, 'linuxDeployment.xml', configParams, callback); +}; + +createWindowsVM = function (client, options, vmOptions, callback) { + var path = client.subscriptionId + '/services/hostedservices/' + options.name + '/deployments'; + var mediaLink = getMediaLinkUrl(client.config.storageAccount, options.name + '.vhd'); + var label = new Buffer(options.name).toString('base64'); + + var configParams = { + NAME: options.name, + COMPUTER_NAME: options.computerName || options.name.slice(0, 15), + LABEL_BASE64: label, + PASSWORD: options.password, + ROLESIZE: options.flavor, + ENDPOINTS: createEndpoints(options.ports), + OS_SOURCE_IMAGE_NAME: vmOptions.image.Name, + OS_IMAGE_MEDIALINK: mediaLink + }; + + makeTemplateRequest(client, path, 'windowsDeployment.xml', configParams, callback); +}; + +captureServer = function (client, serverName, targetImageName, callback) { + // /services/hostedservices//deployments//roleinstances//operations + var path = client.subscriptionId + '/services/hostedservices/' + + serverName + '/deployments/' + + serverName + '/roleInstances/' + + serverName + '/Operations'; + + var configParams = { + NAME: targetImageName + }; + + makeTemplateRequest(client, path, 'captureRole.xml', configParams, callback); +}; + +validateCreateOptions = function (options, config, callback) { + if (typeof options === 'function') { + options = {}; + } + options = options || {}; // no args + + // check required options values + ['flavor', 'image', 'name', 'username', 'password', 'location'].forEach(function (member) { + if (!options[member]) { + errs.handle( + errs.create({ message: 'options.' + member + ' is a required argument.' }), + callback + ); + } + }); + callback(); +}; + exports._updateMinimumPollInterval = function(interval) { MINIMUM_POLL_INTERVAL = interval; }; From ec75ea53a0329d504e1e1656d09521fec90f0501 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 6 Dec 2014 07:16:55 +0000 Subject: [PATCH 294/460] Enabling undef lint check; Turning on mocha mode. --- .jshintrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.jshintrc b/.jshintrc index c20f57fe7..c233af9b6 100644 --- a/.jshintrc +++ b/.jshintrc @@ -22,7 +22,7 @@ // true : ensure whatever is used is consistent // "single" : require single quotes // "double" : require double quotes - "undef" : false, // true: Require all non-global variables to be declared (prevents global leaks) + "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) "unused" : true, // true: Require all defined variables be used "strict" : false, // true: Requires all functions run in ES5 Strict Mode "maxparams" : false, // {int} Max number of formal params allowed per function @@ -71,7 +71,7 @@ "dojo" : false, // Dojo Toolkit "jasmine" : false, // Jasmine "jquery" : false, // jQuery - "mocha" : false, // Mocha + "mocha" : true, // Mocha "mootools" : false, // MooTools "node" : true, // Node.js "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) From de4b836e111fa5c7a3814a2765b35c1c1f325a81 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 9 Dec 2014 11:36:20 +0530 Subject: [PATCH 295/460] Missed moving a couple of variable declarations to top of file. --- lib/pkgcloud/azure/utils/azureApi.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index 7a90eaa85..f3cd2b9c9 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -32,8 +32,8 @@ var MINIMUM_POLL_INTERVAL = exports.MINIMUM_POLL_INTERVAL = 3000; // Declaring variables for helper functions defined later var createVM, createLinuxVM, createWindowsVM, validateCreateOptions, getServer, - getServers, rebootServer, deleteHostedService, destroyServer, createImage, - captureServer, destroyImage, getMediaLinkUrl, createEndpoints, + getServers, rebootServer, stopServer, deleteHostedService, destroyServer, createImage, + captureServer, deleteImage, destroyImage, getMediaLinkUrl, createEndpoints, makeTemplateRequest, createHostedService, addCertificate, getHostedServices, deleteServer, getOSImage, deleteOSDisk, deleteOSBlob, getServersFromServices, getServersFromService, isVM, getHostedServiceProperties, pollRequestStatus, @@ -234,7 +234,7 @@ rebootServer = exports.rebootServer = function (client, serviceName, callback) { * POST https://management.core.windows.net//services/hostedservices//deployments//roleinstances//operations * A successful operation returns status code 201 (Created). Need to poll for success? */ -var stopServer = exports.stopServer = function (client, serviceName, callback) { +stopServer = exports.stopServer = function (client, serviceName, callback) { var path = client.subscriptionId + '/services/hostedservices/' + serviceName + '/deployments/' + serviceName + '/roleInstances/' + @@ -570,7 +570,7 @@ createImage = exports.createImage = function (client, serverName, targetImageNam ); }; -var deleteImage = function (client, image, callback) { +deleteImage = function (client, image, callback) { // https://management.core.windows.net//services/images/ var path = client.subscriptionId + '/services/images/' + image.Name; From 158e85b16f1c3912c2dd0fe1dcc6e602525b58b1 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 8 Dec 2014 22:20:15 -0800 Subject: [PATCH 296/460] Cleaning up client name in examples - Fixes #372 --- examples/dns/rackspace.js | 18 +++++++++--------- examples/storage/azure.js | 4 ++-- examples/storage/rackspace.js | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/dns/rackspace.js b/examples/dns/rackspace.js index 2a9a402b9..5d8c21366 100644 --- a/examples/dns/rackspace.js +++ b/examples/dns/rackspace.js @@ -1,7 +1,7 @@ var pkgcloud = require('../../lib/pkgcloud'), _ = require('underscore'); -var rackspace = pkgcloud.dns.createClient({ +var client = pkgcloud.dns.createClient({ provider: 'rackspace', username: 'rax-user-id', apiKey: '1234567890asdbchehe' @@ -12,7 +12,7 @@ var rackspace = pkgcloud.dns.createClient({ // and illustration purposes. // 1 - Get all DNS "Zones" associates with your account -rackspace.getZones(function (err, zones) { +client.getZones(function (err, zones) { if (err) { console.dir(err); return; @@ -34,7 +34,7 @@ var details = { comment: 'I pity .foo' }; -rackspace.createZone(details, function (err, zone) { +client.createZone(details, function (err, zone) { if (err) { console.dir(err); return; @@ -46,7 +46,7 @@ rackspace.createZone(details, function (err, zone) { // 3 - Get the "Zone" we just created and get its records -rackspace.getZones({ name: 'example.org' }, function (err, zones) { +client.getZones({ name: 'example.org' }, function (err, zones) { if (err) { console.dir(err); return; @@ -54,7 +54,7 @@ rackspace.getZones({ name: 'example.org' }, function (err, zones) { if (zones.length) { console.log('We have parent Zone'); - rackspace.getRecords(zones[0], function (err, records) { + client.getRecords(zones[0], function (err, records) { if (err) { console.dir(err); return; @@ -74,7 +74,7 @@ var _rec = { data: '127.0.0.1' }; -rackspace.getZones({ name: 'example.org' }, function (err, zones) { +client.getZones({ name: 'example.org' }, function (err, zones) { if (err) { console.dir(err); return; @@ -82,7 +82,7 @@ rackspace.getZones({ name: 'example.org' }, function (err, zones) { if (zones.length) { console.log('We have parent Zone'); - rackspace.createRecord(zones[0], _rec, function (err, rec) { + client.createRecord(zones[0], _rec, function (err, rec) { if (err) { console.dir(err); return; @@ -96,7 +96,7 @@ rackspace.getZones({ name: 'example.org' }, function (err, zones) { }); // 5 - Now let's remove the "Zone" and all of its children records. -rackspace.getZones({ name: 'example.org' }, function (err, zones) { +client.getZones({ name: 'example.org' }, function (err, zones) { if (err) { console.dir(err); return; @@ -104,7 +104,7 @@ rackspace.getZones({ name: 'example.org' }, function (err, zones) { if (zones.length) { console.log('We have parent Zone'); - rackspace.deleteZone(zones[0], function (err) { + client.deleteZone(zones[0], function (err) { if (err) { console.dir(err); return; diff --git a/examples/storage/azure.js b/examples/storage/azure.js index 8028b3d99..ef6462fdc 100644 --- a/examples/storage/azure.js +++ b/examples/storage/azure.js @@ -1,12 +1,12 @@ var pkgcloud = require('../../lib/pkgcloud'); -var azure = pkgcloud.storage.createClient({ +var client = pkgcloud.storage.createClient({ provider: 'azure', storageAccount: 'test-storage-account', // Name of your storage account storageAccessKey: 'test-storage-access-key' // Access key for storage account }); -azure.getContainers(function (err, containers) { +client.getContainers(function (err, containers) { if (err) { console.error(err); } diff --git a/examples/storage/rackspace.js b/examples/storage/rackspace.js index 83331a0e1..a29e545c7 100644 --- a/examples/storage/rackspace.js +++ b/examples/storage/rackspace.js @@ -2,7 +2,7 @@ var fs = require('fs'), pkgcloud = require('../../lib/pkgcloud'), _ = require('underscore'); -var rackspace = pkgcloud.storage.createClient({ +var client = pkgcloud.storage.createClient({ provider: 'rackspace', username: 'rackspace_id', apiKey: '1234567890poiiuytrrewq', @@ -14,7 +14,7 @@ var rackspace = pkgcloud.storage.createClient({ // and illustration purposes. // 1 -- to create a container -rackspace.createContainer({ +client.createContainer({ name: 'sample-container-test', metadata: { callme: 'maybe' @@ -31,7 +31,7 @@ rackspace.createContainer({ }); // 2 -- to list our containers -rackspace.getContainers(function (err, containers) { +client.getContainers(function (err, containers) { if (err) { console.dir(err); return; @@ -44,7 +44,7 @@ rackspace.getContainers(function (err, containers) { }); // 3 -- to create a container and upload a file to it -rackspace.createContainer({ +client.createContainer({ name: 'sample-container', metadata: { callme: 'maybe' @@ -57,7 +57,7 @@ rackspace.createContainer({ var myPicture = fs.createReadStream('/path/to/some/file/picture.jpg'); - var upload = rackspace.upload({ + var upload = client.upload({ container: container.name, remote: 'profile-picture.jpg' }); @@ -74,7 +74,7 @@ rackspace.createContainer({ }); // 4 -- setup container as CDN -rackspace.getContainer('container-name', function (err, container) { +client.getContainer('container-name', function (err, container) { if(err){ console.log('There was an error retrieving container:\n'); console.dir(err); @@ -93,14 +93,14 @@ rackspace.getContainer('container-name', function (err, container) { }); // 5 -- to get a container, empty it, then finally destroying it -rackspace.getContainer('sample-container', function (err, container) { +client.getContainer('sample-container', function (err, container) { if (err) { console.dir(err); return; } // destroying a container automatically calls the remove file API to empty before delete - rackspace.destroyContainer(container, function (err, result) { + client.destroyContainer(container, function (err, result) { if (err) { console.dir(err); return; From 485d68e330c92767b1e636e5be6c7f375df3eda8 Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Thu, 11 Dec 2014 08:04:56 -0600 Subject: [PATCH 297/460] Fix error grammar (node is a required arg...) --- lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js index 118bdfd6e..b3373eb88 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js @@ -120,7 +120,7 @@ module.exports = { loadBalancer instanceof lb.LoadBalancer ? loadBalancer.id : loadBalancer; if (!(node instanceof lb.Node) && (typeof node !== 'object')) { - throw new Error('node is require argument and must be an object'); + throw new Error('node is a required argument and must be an object'); } self._request({ From 1c89b52c841a2c5906601b1ce6cf9d8f64aafd09 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 25 Dec 2014 14:17:25 +0000 Subject: [PATCH 298/460] Adding implementation for OpenStack CDN service. --- lib/pkgcloud/openstack/cdn/client/flavors.js | 183 ++++++++++++ lib/pkgcloud/openstack/cdn/client/index.js | 46 +++ lib/pkgcloud/openstack/cdn/client/services.js | 281 ++++++++++++++++++ lib/pkgcloud/openstack/cdn/flavor.js | 27 ++ lib/pkgcloud/openstack/cdn/index.js | 15 + lib/pkgcloud/openstack/cdn/service.js | 34 +++ 6 files changed, 586 insertions(+) create mode 100644 lib/pkgcloud/openstack/cdn/client/flavors.js create mode 100644 lib/pkgcloud/openstack/cdn/client/index.js create mode 100644 lib/pkgcloud/openstack/cdn/client/services.js create mode 100644 lib/pkgcloud/openstack/cdn/flavor.js create mode 100644 lib/pkgcloud/openstack/cdn/index.js create mode 100644 lib/pkgcloud/openstack/cdn/service.js diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js new file mode 100644 index 000000000..b482b4966 --- /dev/null +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -0,0 +1,183 @@ +/* + * flavors.js: Instance methods for working with flavors from Openstack CDN + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + urlJoin = require('url-join'), + util = require('util'), + _ = require('underscore'), + cdn = pkgcloud.providers.openstack.cdn; + +var _urlPrefix = '/flavors'; + +/** + * validateProperties + * + * @description local helper function for validating arguments + * + * @param {Array} required The list of required properties + * @param {object} options The options object to validate + * @param {String} formatString String formatter for the error message + * @param {Function} callback + * @returns {boolean} + */ +function validateProperties(required, options, formatString, callback) { + return !required.some(function (item) { + if (typeof(options[item]) === 'undefined') { + errs.handle( + errs.create({ message: util.format(formatString, item) }), + callback + ); + return true; + } + return false; + }); +} + +/** + * client.getFlavor + * + * @description Gets a flavor from the account + * + * @param {String|object} flavor The flavor or flavorName to fetch + * @param {Function} callback + * @returns {request|*} + */ +exports.getFlavor = function (flavor, callback) { + var self = this, + path = flavor instanceof cdn.Flavor + ? urlJoin(_urlPrefix, flavor.name) + : urlJoin(_urlPrefix, flavor); + + return this._request({ + path: path + }, function (err, body) { + if (err) { + return callback(err); + } + if (!body) { + return new Error('Unexpected empty response'); + } + else { + callback(null, new cdn.Flavor(self, body)); + } + }); +}; + +/** + * client.getFlavors + * + * @description get the list of flavors for the current account + * + * @param {object|Function} [options] A set of options for the getFlavors call + * @param {function} callback f(err, flavors) where flavors is an array of Flavor + * @returns {*} + */ +exports.getFlavors = function getFlavors(options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var requestOptions = { + path: _urlPrefix + }; + + return this._request(requestOptions, function (err, body) { + if (err) { + callback(err); + return; + } + + callback(err, body.flavors.map(function(flavor) { + return new cdn.Flavor(self, flavor); + })); + }); +}; + +/** + * client.createFlavor + * + * @description Creates a flavor with the specified options. + + * @param {object} details the details to create this flavor + * @param {String} details.id the id of the new flavor + * @param {Array} details.providers list of providers for the new flavor + * @param {Object} details.providers[n] information about a provider + * @param {String} details.providers[n].provider the provider's name + * @param {Array} details.providers[n].links list of links for the provider + * @param {Object} details.providers[n].links[n] information about a provider's link + * @param {String} details.providers[n].links[n].href the URL of the link + * @param {String} details.providers[n].links[n].rel the relationship of the link + * @param callback + * @returns {request|null} + */ +exports.createFlavor = function (details, callback) { + if (typeof details === 'function') { + callback = details; + details = {}; + } + + details = details || {}; + + if (!validateProperties(['id', 'providers'], details, + 'options.%s is a required argument.', callback)) { + return; + } + + var self = this, + createOptions = { + method: 'POST', + path: _urlPrefix, + body: { + id: details.id, + providers: details.providers + } + }; + + return self._request(createOptions, function (err, body) { + if (err) { + return callback(err); + } + + if (!body) { + return new Error('Flavor not passed back from Openstack.'); + } + + // since createFlavor returns an href to the flavor, lets go fetch it + self.getFlavor(body.id, callback); + }); +}; + +/** + * client.deleteFlavor + * + * @description Delete a flavor from the account + * + * @param {String|object} flavor The flavor or flavorId to delete + * @param {Function} callback + * @returns {request|*} + */ +exports.deleteFlavor = function (flavor, callback) { + var path = flavor instanceof cdn.Flavor + ? urlJoin(_urlPrefix, flavor.id) + : urlJoin(_urlPrefix, flavor); + + return this._request({ + path: path, + method: 'DELETE' + }, function (err) { + if (err) { + return callback(err); + } + + callback(err, true); + }); +}; diff --git a/lib/pkgcloud/openstack/cdn/client/index.js b/lib/pkgcloud/openstack/cdn/client/index.js new file mode 100644 index 000000000..5c8b4e5f8 --- /dev/null +++ b/lib/pkgcloud/openstack/cdn/client/index.js @@ -0,0 +1,46 @@ +/* + * index.js: CDN client for OpenStack + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var util = require('util'), + openstack = require('../../client'), + urlJoin = require('url-join'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + openstack.Client.call(this, options); + + _.extend(this, require('./services')); + _.extend(this, require('./flavors')); + + this.serviceType = 'cdn'; + +}; + +util.inherits(Client, openstack.Client); + +/** + * client._getUrl + * + * @description get the url for the current CDN service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function (options) { + options = options || {}; + + if (!this._serviceUrl) { + throw new Error('Service url not found'); + } + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); +}; diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js new file mode 100644 index 000000000..1e1a5f9b0 --- /dev/null +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -0,0 +1,281 @@ +/* + * services.js: Instance methods for working with services from Openstack CDN + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + urlJoin = require('url-join'), + util = require('util'), + _ = require('underscore'), + cdn = pkgcloud.providers.openstack.cdn; + +var _urlPrefix = '/services'; + +/** + * validateProperties + * + * @description local helper function for validating arguments + * + * @param {Array} required The list of required properties + * @param {object} options The options object to validate + * @param {String} formatString String formatter for the error message + * @param {Function} callback + * @returns {boolean} + */ +function validateProperties(required, options, formatString, callback) { + return !required.some(function (item) { + if (typeof(options[item]) === 'undefined') { + errs.handle( + errs.create({ message: util.format(formatString, item) }), + callback + ); + return true; + } + return false; + }); +} + +/** + * client.getService + * + * @description Gets a service from the account + * + * @param {String|object} service The service or serviceName to fetch + * @param {Function} callback + * @returns {request|*} + */ +exports.getService = function (service, callback) { + var self = this, + path = service instanceof cdn.Service + ? urlJoin(_urlPrefix, service.name) + : urlJoin(_urlPrefix, service); + + return this._request({ + path: path + }, function (err, body) { + if (err) { + return callback(err); + } + if (!body) { + return new Error('Unexpected empty response'); + } + else { + callback(null, new cdn.Service(self, body)); + } + }); +}; + +/** + * client.getServices + * + * @description get the list of services for the current account + * + * @param {object|Function} [options] A set of options for the getServices call + * @param {function} callback f(err, services) where services is an array of Service + * @returns {*} + */ +exports.getServices = function getServices(options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var requestOptions = { + path: _urlPrefix + }; + + requestOptions.qs = _.pick(options, + 'limit', + 'marker'); + + return this._request(requestOptions, function (err, body) { + if (err) { + callback(err); + return; + } + + callback(err, body.services.map(function(service) { + return new cdn.Service(self, service); + })); + }); +}; + +/** + * client.createService + * + * @description Creates a service with the specified options. + + * @param {object} details the details to create this service + * @param {String} details.name the name of the new service + * @param {Array} details.domains list of domains for the new service + * @param {Object} details.domains[n] information about a domain + * @param {String} details.domains[n].domain the domain name + * @param {String} [details.domains[n].protocol] the protocol used to access the domain; default = http + * @param {Array} details.origins list of origin servers for the new service + * @param {Object} details.origins[n] information about an origin server + * @param {String} details.origins[n].origin origin server address + * @param {Number} [details.origins[n].port] origin server port; default = 80 + * @param {Boolean} [details.origins[n].ssl] whether origin server uses SSL; default = false + * @param {Array} [details.origins[n].rules] list of rules defining the conditions when this origin should be accessed + * @param {Object} [details.origins[n].rules[n]] information about an access rule + * @param {String} [details.origins[n].rules[n].name] the name of the rule + * @param {String} [details.origins[n].rules[n].request_url] the request URL this rule should match (regex supported) + * @param {Array} [details.caching] list of TTL rules for assets of this service + * @param {Object} [details.caching[n]] information about a TTL rule + * @param {String} [details.caching[n].name] the name of the TTL rule + * @param {Number} [details.caching[n].ttl] the TTL value, in seconds? + * @param {Array} [details.caching[n].rules] list of rules that determine if this TTL should be applied to an asset + * @param {Object} [details.caching[n].rules[n]] information about a TTL rule + * @param {String} [details.caching[n].rules[n].name] the name of the TTL rule + * @param {String} [details.caching[n].rules[n].request_url] the request URL this rule should match (regex supported) + * @param {Array} [details.restrictions] list of restrictions on who can access new service + * @param {Object} [details.restrictions[n]] information about an access restriction + * @param {String} [details.restrictions[n].name] the name of the restriction + * @param {Array} [details.restrictions[n].rules] list of restrition rules + * @param {Object} [details.restrictions[n].rules[n]] information about a restriction rule + * @param {String} [details.restrictions[n].rules[n].name] the name of the restriction rule + * @param {String} [details.restrictions[n].rules[n].referrer] the domain from which the new service can be accessed + * @param {String} details.flavorId the ID of the flavor to use for this service + * @param callback + * @returns {request|null} + */ +exports.createService = function (details, callback) { + if (typeof details === 'function') { + callback = details; + details = {}; + } + + details = details || {}; + + if (!validateProperties(['name', 'domains', 'origins', 'flavorId'], details, + 'options.%s is a required argument.', callback)) { + return; + } + + var self = this, + createOptions = { + method: 'POST', + path: _urlPrefix, + body: { + name: details.name, + domains: details.domains, + origins: details.origins, + flavor_id: details.flavorId + } + }; + + if (details.caching) { + createOptions.body.caching = details.caching; + } + + if (details.restrictions) { + createOptions.body.restrictions = details.restrictions; + } + + return self._request(createOptions, function (err, body) { + if (err) { + return callback(err); + } + + if (!body) { + return new Error('Service not passed back from Openstack.'); + } + + // since createService returns an href to the service, lets go fetch it + self.getService(body.name, callback); + }); +}; + +/** + * client.updateService + * + * @description Update a service + * + * @param {String|object} service The service or serviceName to update + * @param {Function} callback + * @returns {request|*} + */ +exports.updateService = function (service, callback) { + if (!service instanceof cdn.Service) { + callback(new Error('you must provide a service to update')); + return; + } + + return this._request({ + path: urlJoin(_urlPrefix, service.name), + body: { + domains: service.domains, + origins: service.origins, + flavor_id: service.flavorId, + caching: service.caching, + restrictions: service.restrictions + }, + method: 'PATCH' + }, function (err) { + if (err) { + return callback(err); + } + + callback(err, service); + }); +}; + +/** + * client.deleteService + * + * @description Delete a service from the account + * + * @param {String|object} service The service or serviceName to delete + * @param {Function} callback + * @returns {request|*} + */ +exports.deleteService = function (service, callback) { + var path = service instanceof cdn.Service + ? urlJoin(_urlPrefix, service.name) + : urlJoin(_urlPrefix, service); + + return this._request({ + path: path, + method: 'DELETE' + }, function (err) { + if (err) { + return callback(err); + } + + callback(err, true); + }); +}; + +/** + * client.deleteServiceCachedAssets + * + * @description Delete cached assets of a service + * + * @param {String|object} service The service or serviceName to delete + * @param {String|null} assetUrl The URL of the asset to delete; default = delete all assets + * @param {Function} callback + * @returns {request|*} + */ +exports.deleteServiceCachedAssets = function (service, assetUrl, callback) { + var path = service instanceof cdn.Service + ? urlJoin(_urlPrefix, service.name) + : urlJoin(_urlPrefix, service); + + return this._request({ + path: urlJoin(path, 'assets'), + qs: assetUrl ? { url: assetUrl } : { all: true }, + method: 'DELETE' + }, function (err) { + if (err) { + return callback(err); + } + + callback(err, true); + }); +}; diff --git a/lib/pkgcloud/openstack/cdn/flavor.js b/lib/pkgcloud/openstack/cdn/flavor.js new file mode 100644 index 000000000..c4c91a7b5 --- /dev/null +++ b/lib/pkgcloud/openstack/cdn/flavor.js @@ -0,0 +1,27 @@ +/* + * flavor.js: OpenStack CDN Flavor + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + * + */ + +var util = require('util'), + base = require('../../core/base'), + _ = require('underscore'); + +var Flavor = exports.Flavor = function Flavor(client, details) { + base.Model.call(this, client, details); +}; + +util.inherits(Flavor, base.Model); + +Flavor.prototype._setProperties = function (details) { + this.id = details.id || details['id']; + this.providers = details.providers || details['providers']; +}; + +Flavor.prototype.toJSON = function () { + return _.pick(this, ['id', 'providers']); +}; diff --git a/lib/pkgcloud/openstack/cdn/index.js b/lib/pkgcloud/openstack/cdn/index.js new file mode 100644 index 000000000..69b49ac76 --- /dev/null +++ b/lib/pkgcloud/openstack/cdn/index.js @@ -0,0 +1,15 @@ +/* + * index.js: Top-level include for the OpenStack CDN module + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +exports.Client = require('./client').Client; +exports.Service = require('./service').Service; +exports.Flavor = require('./flavor').Flavor; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/openstack/cdn/service.js b/lib/pkgcloud/openstack/cdn/service.js new file mode 100644 index 000000000..96e6f9b07 --- /dev/null +++ b/lib/pkgcloud/openstack/cdn/service.js @@ -0,0 +1,34 @@ +/* + * service.js: OpenStack CDN Service + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + * + */ + +var util = require('util'), + base = require('../../core/base'), + _ = require('underscore'); + +var Service = exports.Service = function Service(client, details) { + base.Model.call(this, client, details); +}; + +util.inherits(Service, base.Model); + +Service.prototype._setProperties = function (details) { + this.name = details.name || details['name']; + this.domains = details.domains || details['domains']; + this.origins = details.origins || details['origins']; + this.caching = details.caching || details['caching']; + this.restrictions = details.restrictions || details['restrictions']; + this.flavorId = details.flavorId || details['flavor_id']; + this.status = details.status || details['status']; + this.links = details.links; +}; + +Service.prototype.toJSON = function () { + return _.pick(this, ['name', 'domains', 'origins', 'caching', + 'restrictions', 'flavorId', 'status', 'links']); +}; From 50213145cb3c60c5c8753201bd471a58d53e092b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 26 Dec 2014 03:38:08 -0800 Subject: [PATCH 299/460] Removing unused variable definition. --- lib/pkgcloud/openstack/cdn/client/flavors.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index b482b4966..5ef488e7e 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -10,7 +10,6 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), urlJoin = require('url-join'), util = require('util'), - _ = require('underscore'), cdn = pkgcloud.providers.openstack.cdn; var _urlPrefix = '/flavors'; From cc3720096afd6ee212754d9ce4e17242e62eeb43 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 00:25:24 -0800 Subject: [PATCH 300/460] Flavors use id not name. --- lib/pkgcloud/openstack/cdn/client/flavors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index 5ef488e7e..1d299dc2b 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -43,14 +43,14 @@ function validateProperties(required, options, formatString, callback) { * * @description Gets a flavor from the account * - * @param {String|object} flavor The flavor or flavorName to fetch + * @param {String|object} flavor The flavor or flavorId to fetch * @param {Function} callback * @returns {request|*} */ exports.getFlavor = function (flavor, callback) { var self = this, path = flavor instanceof cdn.Flavor - ? urlJoin(_urlPrefix, flavor.name) + ? urlJoin(_urlPrefix, flavor.id) : urlJoin(_urlPrefix, flavor); return this._request({ From a3acc310afcd3d706e742c252201c18a98b38c91 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 00:26:15 -0800 Subject: [PATCH 301/460] No need for body. --- lib/pkgcloud/openstack/cdn/client/flavors.js | 9 ++------- lib/pkgcloud/openstack/cdn/client/services.js | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index 1d299dc2b..ff9cf8bb3 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -141,17 +141,12 @@ exports.createFlavor = function (details, callback) { } }; - return self._request(createOptions, function (err, body) { + return self._request(createOptions, function (err) { if (err) { return callback(err); } - if (!body) { - return new Error('Flavor not passed back from Openstack.'); - } - - // since createFlavor returns an href to the flavor, lets go fetch it - self.getFlavor(body.id, callback); + return self.getFlavor(details.id, callback); }); }; diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 1e1a5f9b0..80ef6867b 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -178,17 +178,12 @@ exports.createService = function (details, callback) { createOptions.body.restrictions = details.restrictions; } - return self._request(createOptions, function (err, body) { + return self._request(createOptions, function (err) { if (err) { return callback(err); } - if (!body) { - return new Error('Service not passed back from Openstack.'); - } - - // since createService returns an href to the service, lets go fetch it - self.getService(body.name, callback); + return self.getService(details.name, callback); }); }; From 502156e9494daf6d676ec8e0f65c4776539104cf Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 00:26:27 -0800 Subject: [PATCH 302/460] No need to pass any arguments to callback upon successful delete. --- lib/pkgcloud/openstack/cdn/client/flavors.js | 2 +- lib/pkgcloud/openstack/cdn/client/services.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index ff9cf8bb3..1684574f1 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -172,6 +172,6 @@ exports.deleteFlavor = function (flavor, callback) { return callback(err); } - callback(err, true); + callback(); }); }; diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 80ef6867b..24700bc5c 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -243,7 +243,7 @@ exports.deleteService = function (service, callback) { return callback(err); } - callback(err, true); + callback(); }); }; @@ -271,6 +271,6 @@ exports.deleteServiceCachedAssets = function (service, assetUrl, callback) { return callback(err); } - callback(err, true); + callback(); }); }; From 332c5345a27fb981683a332101576aac17ae0d43 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 00:27:50 -0800 Subject: [PATCH 303/460] Allow assetUrl parameter to be optional. --- lib/pkgcloud/openstack/cdn/client/services.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 24700bc5c..8166932ea 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -262,6 +262,11 @@ exports.deleteServiceCachedAssets = function (service, assetUrl, callback) { ? urlJoin(_urlPrefix, service.name) : urlJoin(_urlPrefix, service); + if (!callback) { + callback = assetUrl; + assetUrl = null; + } + return this._request({ path: urlJoin(path, 'assets'), qs: assetUrl ? { url: assetUrl } : { all: true }, From b346610e2dd2ce98e9f0735f8fc84f5e6077d9ac Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 00:28:07 -0800 Subject: [PATCH 304/460] Enable CDN service in OpenStack. --- lib/pkgcloud/openstack/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index 719b099a2..bab094966 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -12,3 +12,4 @@ exports.orchestration = require('./orchestration'); exports.network = require('./network'); exports.storage = require('./storage'); exports.database = require('./database'); +exports.cdn = require('./cdn'); From 7157f6b03b8b0307c8e108d41f2756cea65dfc2e Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 00:28:39 -0800 Subject: [PATCH 305/460] Adding unit tests for OpenStack CDN service. --- test/fixtures/openstack/cdnFlavor.json | 20 ++ test/fixtures/openstack/cdnFlavors.json | 24 ++ test/fixtures/openstack/cdnService.json | 48 +++ test/fixtures/openstack/cdnServices.json | 58 ++++ test/fixtures/openstack/realToken.json | 10 + test/openstack/cdn/flavors-test.js | 289 ++++++++++++++++ test/openstack/cdn/services-test.js | 398 +++++++++++++++++++++++ 7 files changed, 847 insertions(+) create mode 100644 test/fixtures/openstack/cdnFlavor.json create mode 100644 test/fixtures/openstack/cdnFlavors.json create mode 100644 test/fixtures/openstack/cdnService.json create mode 100644 test/fixtures/openstack/cdnServices.json create mode 100644 test/openstack/cdn/flavors-test.js create mode 100644 test/openstack/cdn/services-test.js diff --git a/test/fixtures/openstack/cdnFlavor.json b/test/fixtures/openstack/cdnFlavor.json new file mode 100644 index 000000000..c4f585250 --- /dev/null +++ b/test/fixtures/openstack/cdnFlavor.json @@ -0,0 +1,20 @@ +{ + "id": "cdn", + "providers": [ + { + "provider": "akamai", + "links": [ + { + "href": "http://www.akamai.com", + "rel": "provider_url" + } + ] + } + ], + "links": [ + { + "href": "http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn", + "rel": "self" + } + ] +} diff --git a/test/fixtures/openstack/cdnFlavors.json b/test/fixtures/openstack/cdnFlavors.json new file mode 100644 index 000000000..602899330 --- /dev/null +++ b/test/fixtures/openstack/cdnFlavors.json @@ -0,0 +1,24 @@ +{ + "flavors": [ + { + "id": "cdn", + "providers": [ + { + "provider": "akamai", + "links": [ + { + "href": "http://www.akamai.com", + "rel": "provider_url" + } + ] + } + ], + "links": [ + { + "href": "http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn", + "rel": "self" + } + ] + } + ] +} diff --git a/test/fixtures/openstack/cdnService.json b/test/fixtures/openstack/cdnService.json new file mode 100644 index 000000000..3be862c77 --- /dev/null +++ b/test/fixtures/openstack/cdnService.json @@ -0,0 +1,48 @@ +{ + "name":"pkgcloud-site", + "domains":[ + { + "domain":"pkgcloud.com", + "protocol":"http" + }, + { + "domain":"www.pkgcloud.com", + "protocol":"http" + } + ], + "origins":[ + { + "origin":"origin.pkgcloud.com", + "port":80, + "ssl":false, + "rules":[ + + ] + } + ], + "restrictions":[ + + ], + "caching":[ + + ], + "status":"deployed", + "flavor_id":"cdn", + "errors":[ + + ], + "links":[ + { + "href":"http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site", + "rel":"self" + }, + { + "href":"http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn", + "rel":"flavor" + }, + { + "href":"http://www.pkgcloud.com.cdn369.altcdn.com", + "rel":"access_url" + } + ] +} diff --git a/test/fixtures/openstack/cdnServices.json b/test/fixtures/openstack/cdnServices.json new file mode 100644 index 000000000..6d7a97912 --- /dev/null +++ b/test/fixtures/openstack/cdnServices.json @@ -0,0 +1,58 @@ +{ + "services":[ + { + "name":"pkgcloud-site", + "domains":[ + { + "domain":"pkgcloud.com", + "protocol":"http" + }, + { + "domain":"www.pkgcloud.com", + "protocol":"http" + } + ], + "origins":[ + { + "origin":"origin.pkgcloud.com", + "port":80, + "ssl":false, + "rules":[ + + ] + } + ], + "restrictions":[ + + ], + "caching":[ + + ], + "status":"deployed", + "flavor_id":"cdn", + "errors":[ + + ], + "links":[ + { + "href":"http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site", + "rel":"self" + }, + { + "href":"http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn", + "rel":"flavor" + }, + { + "href":"http://www.pkgcloud.com.cdn92.altcdn.com", + "rel":"access_url" + } + ] + } + ], + "links":[ + { + "href":"http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services?marker=pkgcloud-site&limit=10", + "rel":"next" + } + ] +} diff --git a/test/fixtures/openstack/realToken.json b/test/fixtures/openstack/realToken.json index e494bfeb7..4b798d34e 100644 --- a/test/fixtures/openstack/realToken.json +++ b/test/fixtures/openstack/realToken.json @@ -106,6 +106,16 @@ } ], "type": "orchestration" + }, + { + "name": "poppy", + "endpoints": [ + { + "region": "Calxeda-AUS1", + "publicURL": "http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041" + } + ], + "type": "cdn" } ], "user": { diff --git a/test/openstack/cdn/flavors-test.js b/test/openstack/cdn/flavors-test.js new file mode 100644 index 000000000..807f36a3a --- /dev/null +++ b/test/openstack/cdn/flavors-test.js @@ -0,0 +1,289 @@ +/* + * flavors-test.js: Unit tests for the CDN flavors resource + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var providers = require('../../configs/providers.json'), + helpers = require('../../helpers'), + mock = !!process.env.MOCK, + hock = require('hock'), + http = require('http'), + async = require('async'), + should = require('should'), + Flavor = require('../../../lib/pkgcloud/openstack/cdn/flavor').Flavor; + +// Declaring variables for helper functions defined later +var setupCreateFlavorMock, setupGetFlavorsMock, setupGetFlavorMock, + setupDeleteFlavorMock; + +// Run all unit tests for all providers that support the CDN flavor +providers.filter(function(provider) { + return !!helpers.pkgcloud.providers[provider].cdn; +}).forEach(function (provider) { + + describe('pkgcloud/openstack/cdn/flavors [' + provider + ']', function() { + + // Create CDN flavor client for provider + var client = helpers.createClient(provider, 'cdn'), + context = {}, + authHockInstance, hockInstance, + authServer, server; + + // Runs before all unit tests are run + before(function (done) { + + if (!mock) { + return done(); + } + + // Spin up an authentication server as well as a CDN flavor server + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + // Runs after all unit tests have run + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + + }); + + // Unit tests follow... + + it('the client.createFlavor() method should create a flavor', function(done) { + + if (mock) { + setupCreateFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createFlavor({ + id: 'cdn', + providers: [ + { + provider: 'akamai', + links: [ + { + 'rel': 'provider_url', + 'href': 'http://www.akamai.com' + } + ] + } + ] + }, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.getFlavors() method should return a list of flavors', function(done) { + + if (mock) { + setupGetFlavorsMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getFlavors(function (err, flavors) { + should.not.exist(err); + should.exist(flavors); + + context.flavors = flavors; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.getFlavor() method should return a flavor instance', function(done) { + + if (mock) { + setupGetFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getFlavor(context.flavors[0], function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.an.instanceOf(Flavor); + flavor.should.have.property('id', context.flavors[0].id); + + context.currentFlavor = flavor; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.getFlavor() method should take a id, return a flavor instance', function(done) { + + if (mock) { + setupGetFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getFlavor(context.flavors[0].id, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.an.instanceOf(Flavor); + flavor.should.have.property('id', context.flavors[0].id); + + context.currentFlavor = flavor; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.deleteFlavor() method should delete a flavor', function(done) { + if (mock) { + setupDeleteFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteFlavor(context.currentFlavor, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.deleteFlavor() method should take a id, delete a flavor', function(done) { + if (mock) { + setupDeleteFlavorMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteFlavor(context.currentFlavor.id, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + }); + +}); + +setupCreateFlavorMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors', { + id: 'cdn', + providers: [ + { + provider: 'akamai', + links: [ + { + 'rel': 'provider_url', + 'href': 'http://www.akamai.com' + } + ] + } + ] + }) + .reply(201, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn' }) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); + } +}; + +setupGetFlavorsMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavors.json'); + } +}; + +setupGetFlavorMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); + } +}; + +setupDeleteFlavorMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') + .reply(204); + } +}; diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js new file mode 100644 index 000000000..d7d42c51d --- /dev/null +++ b/test/openstack/cdn/services-test.js @@ -0,0 +1,398 @@ +/* + * services-test.js: Unit tests for the CDN services resource + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var providers = require('../../configs/providers.json'), + helpers = require('../../helpers'), + mock = !!process.env.MOCK, + hock = require('hock'), + http = require('http'), + async = require('async'), + should = require('should'), + Service = require('../../../lib/pkgcloud/openstack/cdn/service').Service; + +// Declaring variables for helper functions defined later +var setupCreateServiceMock, setupGetServicesMock, setupGetServiceMock, + setupUpdateServiceMock, setupDeleteServiceMock; + +// Run all unit tests for all providers that support the CDN service +providers.filter(function(provider) { + return !!helpers.pkgcloud.providers[provider].cdn; +}).forEach(function (provider) { + + describe('pkgcloud/openstack/cdn/services [' + provider + ']', function() { + + // Create CDN service client for provider + var client = helpers.createClient(provider, 'cdn'), + context = {}, + authHockInstance, hockInstance, + authServer, server; + + // Runs before all unit tests are run + before(function (done) { + + if (!mock) { + return done(); + } + + // Spin up an authentication server as well as a CDN service server + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + // Runs after all unit tests have run + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + + }); + + // Unit tests follow... + + it('the client.createService() method should create a service', function(done) { + + if (mock) { + setupCreateServiceMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createService({ + name: 'pkgcloud-site', + domains: [ + { + domain: 'pkgcloud.com' + }, + { + domain: 'www.pkgcloud.com' + } + ], + origins: [ + { + origin: 'origin.pkgcloud.com' + } + ], + flavorId: 'cdn' + }, function (err, service) { + should.not.exist(err); + should.exist(service); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.getServices() method should return a list of services', function(done) { + + if (mock) { + setupGetServicesMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getServices(function (err, services) { + should.not.exist(err); + should.exist(services); + + context.services = services; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.getService() method should return a service instance', function(done) { + + if (mock) { + setupGetServiceMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getService(context.services[0], function (err, service) { + should.not.exist(err); + should.exist(service); + service.should.be.an.instanceOf(Service); + service.should.have.property('name', context.services[0].name); + + context.currentService = service; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.getService() method should take a name, return a service instance', function(done) { + + if (mock) { + setupGetServiceMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getService(context.services[0].name, function (err, service) { + should.not.exist(err); + should.exist(service); + service.should.be.an.instanceOf(Service); + service.should.have.property('name', context.services[0].name); + + context.currentService = service; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + // TODO: Re-enable once https://github.com/mmalecki/hock/pull/20 is merged + // and published to npm + it.skip('the client.updateService() method should update a service', function(done) { + + var serviceToUpdate = context.currentService; + serviceToUpdate.origins[0].origin = 'updated-origin.pkgcloud.net'; + + if (mock) { + setupUpdateServiceMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.updateService(serviceToUpdate, function (err, service) { + should.not.exist(err); + should.exist(service); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.deleteService() method should delete a service', function(done) { + if (mock) { + setupDeleteServiceMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteService(context.currentService, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.deleteService() method should take a name, delete a service', function(done) { + if (mock) { + setupDeleteServiceMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteService(context.currentService.name, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.deleteServiceCachedAssets() method should delete all cached assets of a service', function(done) { + if (mock) { + setupDeleteServiceAllCachedAssetsMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteServiceCachedAssets(context.currentService, function (err) { + console.log(err); + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.deleteServiceCachedAssets() method should take an asset URL, delete that cached asset of a service', function(done) { + if (mock) { + setupDeleteServiceCachedAssetMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteServiceCachedAssets(context.currentService, '/images/logo.png', function (err) { + console.log(err); + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + }); + +}); + +setupCreateServiceMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/services', { + name: 'pkgcloud-site', + domains: [ + { + domain: 'pkgcloud.com' + }, + { + domain: 'www.pkgcloud.com' + } + ], + origins: [ + { + origin: 'origin.pkgcloud.com' + } + ], + flavor_id: 'cdn' + }) + .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); + } +}; + +setupGetServicesMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnServices.json'); + } +}; + +setupGetServiceMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); + } +}; + +setupUpdateServiceMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site', { + name: 'pkgcloud-site', + domains: [ + { + domain: 'pkgcloud.com' + }, + { + domain: 'www.pkgcloud.com' + } + ], + origins: [ + { + origin: 'origin-updated.pkgcloud.com' + } + ], + flavor_id: 'cdn' + }) + .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }); + } +}; + +setupDeleteServiceMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .reply(202); + } +}; + +setupDeleteServiceAllCachedAssetsMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?all=true') + .reply(202); + } +}; + +setupDeleteServiceCachedAssetMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?url=%2Fimages%2Flogo.png') + .reply(202); + } +}; From af3391169c2f323c54fe67bb6ac6a76568d03503 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 00:32:35 -0800 Subject: [PATCH 306/460] Declaring variables before use. --- test/openstack/cdn/services-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js index d7d42c51d..02cd71689 100644 --- a/test/openstack/cdn/services-test.js +++ b/test/openstack/cdn/services-test.js @@ -17,7 +17,8 @@ var providers = require('../../configs/providers.json'), // Declaring variables for helper functions defined later var setupCreateServiceMock, setupGetServicesMock, setupGetServiceMock, - setupUpdateServiceMock, setupDeleteServiceMock; + setupUpdateServiceMock, setupDeleteServiceMock, + setupDeleteServiceAllCachedAssetsMock, setupDeleteServiceCachedAssetMock; // Run all unit tests for all providers that support the CDN service providers.filter(function(provider) { From 94b7f2db52d3503ffaa6f6e32434292e00b4e2ed Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 05:44:41 -0800 Subject: [PATCH 307/460] Adding documentation. --- README.md | 48 +++++++++++++++++- docs/providers/openstack/cdn.md | 87 +++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 docs/providers/openstack/cdn.md diff --git a/README.md b/README.md index 948047a61..58a1aed55 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ pkgcloud is a standard library for node.js that abstracts away differences among * [Load Balancers](#load-balancers----beta) *(beta)* * [Orchestration](#orchestration----beta) *(beta)* * [Network](#network----beta) *(beta)* +* [CDN](#cdn----beta) *(beta)* * _Fine Print_ * [Installation](#installation) * [Tests](#tests) @@ -33,7 +34,7 @@ You can install `pkgcloud` via `npm` or add to it to [dependencies](https://npmj npm install pkgcloud ``` -Currently there are six service types which are handled by pkgcloud: +Currently there are nine service types which are handled by pkgcloud: * [Compute](#compute) * [Storage](#storage) @@ -43,6 +44,7 @@ Currently there are six service types which are handled by pkgcloud: * [Load Balancers](#load-balancers----beta) *(beta)* * [Network](#network----beta) *(beta)* * [Orchestration](#orchestration----beta) *(beta)* +* [CDN](#cdn----beta) *(beta)* In our [Roadmap](#roadmap), we plan to add support for more services, such as Queueing, Monitoring, and more. Additionally, we plan to implement more providers for the *beta* services, thus moving them out of *beta*. @@ -131,6 +133,8 @@ If a service does not have at least two providers, it is considered a *beta* int * [HP](docs/providers/hp/network.md) * [Openstack](docs/providers/openstack/network.md) * [Rackspace](docs/providers/rackspace/network.md) +* **[CDN](#cdn----beta)** + * [Openstack](docs/providers/openstack/cdn.md) ## Compute @@ -528,6 +532,48 @@ Each instance of `pkgcloud.orchestration.Client` returned from `pkgcloud.orchest ### Templates * `client.validateTemplate(template, function (err, template) { })` +## CDN -- Beta + +##### Note: CDN is considered Beta until there are multiple providers; presently only Openstack is supported. + +The `pkgcloud.cdn` service is designed to allow you to access Openstack Poppy via node.js. You can manage services and flavors from within any node.js application. + +To get started with a `pkgcloud.cdn` client just create one: + +``` js + var client = require('pkgcloud').cdn.createClient({ + // + // The name of the provider (e.g. "openstack") + // + provider: 'provider-name', + + // + // ... Provider specific credentials + // + }); +``` + +#### Providers + +* [Openstack](docs/providers/openstack/cdn.md) + +Each instance of `pkgcloud.cdn.Client` returned from `pkgcloud.cdn.createClient` has a set of uniform APIs: + +### Service +* `client.getService(service, function (err, service) { })` +* `client.getServices(options, function (err, services) { })` +* `client.createService(details, function (err, service) { })` +* `client.updateService(service, function (err, service) { })` +* `client.deleteService(service, function (err) { })` + +### Service Assets +* `client.deleteServiceCachedAssets(service, assetUrl, function(err) { })` + +### Flavors +* `client.getFlavor(flavor, function (err, flavor) { })` +* `client.getFlavors(options, function (err, flavors) { })` +* `client.deleteFlavor(flavor, function (err) { })` + ## Installation ``` bash diff --git a/docs/providers/openstack/cdn.md b/docs/providers/openstack/cdn.md new file mode 100644 index 000000000..bf4c4e095 --- /dev/null +++ b/docs/providers/openstack/cdn.md @@ -0,0 +1,87 @@ +##Using the Openstack CDN provider + +Creating a client is straight-forward: + +``` js + var openstack = pkgcloud.cdn.createClient({ + provider: 'openstack', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +## Services + +#### client.createService(options, callback) +Creates a service with the options specified. + +Options are as follows: + +```js +{ + name: 'my-service-name', // name of service, required + domains: [ ... ], // list of domains for service, required + origins: [ ... ], // list of origins for service, required + caching: [ ... ], // list of caching rules for service, optional + restrictions: [ ... ], // list of restrictions on where service can be accessed from, optional + flavorId: 'cdn' // ID of CDN flavor to use, required +} +``` +Callback is `f(err, service)`, where `service` is the created service. + +#### client.getServices([options], callback) + +Lists all created services. Callback is `f(err, services)` where `services` +is an `Array`. + +#### client.getService(service, callback) + +Retrieve the created service for the provided service or serviceName. Callback is `f(err, +service)`. + +#### client.updateService(service, callback) + +Update the provided service. + +The following values from the provided service are updatable. + +```js +{ + name: 'my-service-name', // name of service, required + domains: [ ... ], // list of domains for service, required + origins: [ ... ], // list of origins for service, required + flavorId: 'cdn' // ID of CDN flavor to use, required +} +``` + +#### client.deleteService(service, callback) + +Delete the created service. Callback is `f(err)`. + +## Service Assets + +#### client.deleteServiceCachedAssets(service, assetUrl, callback) + +Purge the service's cached asset (if `assetUrl` is specified) or all cached +assets (if `assetUrl` is not specified). Callback is `f(err)`. + +## Flavors + +#### client.getFlavors(options, callback) + +Lists all available CDN flavors. Callback is `f(err, flavors)` where +`flavors` is an Array. + +#### client.getFlavor(flavor, callback) + +Retrieve the CDN flavor for a provided flavor or flavorId. Callback is `f(err, +flavor)`. + +#### client.deleteFlavor(flavor, callback) + +Delete a flavor. Callback is `f(err)`. \ No newline at end of file From 07a7a1bb8e62afa96c45f2f03ce6b30a4cebf9d6 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 06:03:01 -0800 Subject: [PATCH 308/460] Removing unnecessary multi-provider logic. --- test/openstack/cdn/flavors-test.js | 436 ++++++++++---------- test/openstack/cdn/services-test.js | 618 ++++++++++++++-------------- 2 files changed, 508 insertions(+), 546 deletions(-) diff --git a/test/openstack/cdn/flavors-test.js b/test/openstack/cdn/flavors-test.js index 807f36a3a..0b13ddfad 100644 --- a/test/openstack/cdn/flavors-test.js +++ b/test/openstack/cdn/flavors-test.js @@ -6,8 +6,7 @@ * MIT LICENSE */ -var providers = require('../../configs/providers.json'), - helpers = require('../../helpers'), +var helpers = require('../../helpers'), mock = !!process.env.MOCK, hock = require('hock'), http = require('http'), @@ -19,271 +18,256 @@ var providers = require('../../configs/providers.json'), var setupCreateFlavorMock, setupGetFlavorsMock, setupGetFlavorMock, setupDeleteFlavorMock; -// Run all unit tests for all providers that support the CDN flavor -providers.filter(function(provider) { - return !!helpers.pkgcloud.providers[provider].cdn; -}).forEach(function (provider) { +describe('pkgcloud/openstack/cdn/flavors', function() { - describe('pkgcloud/openstack/cdn/flavors [' + provider + ']', function() { + // Create CDN service client + var client = helpers.createClient('openstack', 'cdn'), + context = {}, + authHockInstance, hockInstance, + authServer, server; - // Create CDN flavor client for provider - var client = helpers.createClient(provider, 'cdn'), - context = {}, - authHockInstance, hockInstance, - authServer, server; + // Runs before all unit tests are run + before(function (done) { - // Runs before all unit tests are run - before(function (done) { - - if (!mock) { - return done(); + if (!mock) { + return done(); + } + + // Spin up an authentication server as well as a CDN flavor server + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); } - - // Spin up an authentication server as well as a CDN flavor server - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); + ], done); + }); + + // Runs after all unit tests have run + after(function (done) { + if (!mock) { + return done(); + } - // Runs after all unit tests have run - after(function (done) { - if (!mock) { - return done(); + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); } + ], done); - async.parallel([ - function (next) { - server.close(next); - }, - function (next) { - authServer.close(next); + }); + + // Unit tests follow... + + it('the client.createFlavor() method should create a flavor', function(done) { + + if (mock) { + setupCreateFlavorMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createFlavor({ + id: 'cdn', + providers: [ + { + provider: 'akamai', + links: [ + { + 'rel': 'provider_url', + 'href': 'http://www.akamai.com' + } + ] } - ], done); + ] + }, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); }); - - // Unit tests follow... - - it('the client.createFlavor() method should create a flavor', function(done) { - - if (mock) { - setupCreateFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createFlavor({ - id: 'cdn', - providers: [ - { - provider: 'akamai', - links: [ - { - 'rel': 'provider_url', - 'href': 'http://www.akamai.com' - } - ] - } - ] - }, function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); + }); + + it('the client.getFlavors() method should return a list of flavors', function(done) { + + if (mock) { + setupGetFlavorsMock(client, { + authServer: authHockInstance, + server: hockInstance }); - }); - - it('the client.getFlavors() method should return a list of flavors', function(done) { - - if (mock) { - setupGetFlavorsMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getFlavors(function (err, flavors) { - should.not.exist(err); - should.exist(flavors); + } - context.flavors = flavors; + client.getFlavors(function (err, flavors) { + should.not.exist(err); + should.exist(flavors); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + context.flavors = flavors; - done(); - }); - }); - - it('the client.getFlavor() method should return a flavor instance', function(done) { - - if (mock) { - setupGetFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getFlavor(context.flavors[0], function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - flavor.should.be.an.instanceOf(Flavor); - flavor.should.have.property('id', context.flavors[0].id); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); - context.currentFlavor = flavor; + done(); + }); + }); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + it('the client.getFlavor() method should return a flavor instance', function(done) { - done(); + if (mock) { + setupGetFlavorMock(client, { + authServer: authHockInstance, + server: hockInstance }); - }); - - it('the client.getFlavor() method should take a id, return a flavor instance', function(done) { - - if (mock) { - setupGetFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getFlavor(context.flavors[0].id, function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - flavor.should.be.an.instanceOf(Flavor); - flavor.should.have.property('id', context.flavors[0].id); + } - context.currentFlavor = flavor; + client.getFlavor(context.flavors[0], function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.an.instanceOf(Flavor); + flavor.should.have.property('id', context.flavors[0].id); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + context.currentFlavor = flavor; - done(); - }); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); - - it('the client.deleteFlavor() method should delete a flavor', function(done) { - if (mock) { - setupDeleteFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteFlavor(context.currentFlavor, function (err) { - should.not.exist(err); + }); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + it('the client.getFlavor() method should take a id, return a flavor instance', function(done) { - done(); + if (mock) { + setupGetFlavorMock(client, { + authServer: authHockInstance, + server: hockInstance }); + } + + client.getFlavor(context.flavors[0].id, function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.an.instanceOf(Flavor); + flavor.should.have.property('id', context.flavors[0].id); + + context.currentFlavor = flavor; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); + }); - it('the client.deleteFlavor() method should take a id, delete a flavor', function(done) { - if (mock) { - setupDeleteFlavorMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteFlavor(context.currentFlavor.id, function (err) { - should.not.exist(err); + it('the client.deleteFlavor() method should delete a flavor', function(done) { + if (mock) { + setupDeleteFlavorMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteFlavor(context.currentFlavor, function (err) { + should.not.exist(err); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); - done(); + done(); + }); + }); + + it('the client.deleteFlavor() method should take a id, delete a flavor', function(done) { + if (mock) { + setupDeleteFlavorMock(client, { + authServer: authHockInstance, + server: hockInstance }); + } + + client.deleteFlavor(context.currentFlavor.id, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); - }); }); -setupCreateFlavorMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } +setupCreateFlavorMock = function (client, servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' } - }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors', { + id: 'cdn', + providers: [ + { + provider: 'akamai', + links: [ + { + 'rel': 'provider_url', + 'href': 'http://www.akamai.com' + } + ] } - }) - .reply(200, helpers.getOpenstackAuthResponse()); - - servers.server - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors', { - id: 'cdn', - providers: [ - { - provider: 'akamai', - links: [ - { - 'rel': 'provider_url', - 'href': 'http://www.akamai.com' - } - ] - } - ] - }) - .reply(201, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn' }) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); - } + ] + }) + .reply(201, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn' }) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); }; -setupGetFlavorsMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavors.json'); - } +setupGetFlavorsMock = function (client, servers) { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavors.json'); }; -setupGetFlavorMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); - } +setupGetFlavorMock = function (client, servers) { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); }; -setupDeleteFlavorMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') - .reply(204); - } +setupDeleteFlavorMock = function (client, servers) { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') + .reply(204); }; diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js index 02cd71689..a62caa51b 100644 --- a/test/openstack/cdn/services-test.js +++ b/test/openstack/cdn/services-test.js @@ -6,8 +6,7 @@ * MIT LICENSE */ -var providers = require('../../configs/providers.json'), - helpers = require('../../helpers'), +var helpers = require('../../helpers'), mock = !!process.env.MOCK, hock = require('hock'), http = require('http'), @@ -20,380 +19,359 @@ var setupCreateServiceMock, setupGetServicesMock, setupGetServiceMock, setupUpdateServiceMock, setupDeleteServiceMock, setupDeleteServiceAllCachedAssetsMock, setupDeleteServiceCachedAssetMock; -// Run all unit tests for all providers that support the CDN service -providers.filter(function(provider) { - return !!helpers.pkgcloud.providers[provider].cdn; -}).forEach(function (provider) { +describe('pkgcloud/openstack/cdn/services', function() { - describe('pkgcloud/openstack/cdn/services [' + provider + ']', function() { + // Create CDN service client + var client = helpers.createClient('openstack', 'cdn'), + context = {}, + authHockInstance, hockInstance, + authServer, server; - // Create CDN service client for provider - var client = helpers.createClient(provider, 'cdn'), - context = {}, - authHockInstance, hockInstance, - authServer, server; + // Runs before all unit tests are run + before(function (done) { - // Runs before all unit tests are run - before(function (done) { - - if (!mock) { - return done(); + if (!mock) { + return done(); + } + + // Spin up an authentication server as well as a CDN service server + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); } - - // Spin up an authentication server as well as a CDN service server - hockInstance = hock.createHock({ throwOnUnmatched: false }); - authHockInstance = hock.createHock(); - - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); + ], done); + }); - // Runs after all unit tests have run - after(function (done) { - if (!mock) { - return done(); + // Runs after all unit tests have run + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); } + ], done); + + }); + + // Unit tests follow... - async.parallel([ - function (next) { - server.close(next); + it('the client.createService() method should create a service', function(done) { + + if (mock) { + setupCreateServiceMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createService({ + name: 'pkgcloud-site', + domains: [ + { + domain: 'pkgcloud.com' }, - function (next) { - authServer.close(next); + { + domain: 'www.pkgcloud.com' } - ], done); + ], + origins: [ + { + origin: 'origin.pkgcloud.com' + } + ], + flavorId: 'cdn' + }, function (err, service) { + should.not.exist(err); + should.exist(service); - }); - - // Unit tests follow... - - it('the client.createService() method should create a service', function(done) { - - if (mock) { - setupCreateServiceMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createService({ - name: 'pkgcloud-site', - domains: [ - { - domain: 'pkgcloud.com' - }, - { - domain: 'www.pkgcloud.com' - } - ], - origins: [ - { - origin: 'origin.pkgcloud.com' - } - ], - flavorId: 'cdn' - }, function (err, service) { - should.not.exist(err); - should.exist(service); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - - it('the client.getServices() method should return a list of services', function(done) { - - if (mock) { - setupGetServicesMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getServices(function (err, services) { - should.not.exist(err); - should.exist(services); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); - context.services = services; + done(); + }); + }); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + it('the client.getServices() method should return a list of services', function(done) { - done(); + if (mock) { + setupGetServicesMock(client, { + authServer: authHockInstance, + server: hockInstance }); - }); - - it('the client.getService() method should return a service instance', function(done) { - - if (mock) { - setupGetServiceMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getService(context.services[0], function (err, service) { - should.not.exist(err); - should.exist(service); - service.should.be.an.instanceOf(Service); - service.should.have.property('name', context.services[0].name); + } - context.currentService = service; + client.getServices(function (err, services) { + should.not.exist(err); + should.exist(services); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + context.services = services; - done(); - }); - }); - - it('the client.getService() method should take a name, return a service instance', function(done) { - - if (mock) { - setupGetServiceMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.getService(context.services[0].name, function (err, service) { - should.not.exist(err); - should.exist(service); - service.should.be.an.instanceOf(Service); - service.should.have.property('name', context.services[0].name); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); - context.currentService = service; + done(); + }); + }); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + it('the client.getService() method should return a service instance', function(done) { - done(); + if (mock) { + setupGetServiceMock(client, { + authServer: authHockInstance, + server: hockInstance }); - }); + } - // TODO: Re-enable once https://github.com/mmalecki/hock/pull/20 is merged - // and published to npm - it.skip('the client.updateService() method should update a service', function(done) { - - var serviceToUpdate = context.currentService; - serviceToUpdate.origins[0].origin = 'updated-origin.pkgcloud.net'; - - if (mock) { - setupUpdateServiceMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.updateService(serviceToUpdate, function (err, service) { - should.not.exist(err); - should.exist(service); + client.getService(context.services[0], function (err, service) { + should.not.exist(err); + should.exist(service); + service.should.be.an.instanceOf(Service); + service.should.have.property('name', context.services[0].name); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + context.currentService = service; - done(); - }); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); - - it('the client.deleteService() method should delete a service', function(done) { - if (mock) { - setupDeleteServiceMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteService(context.currentService, function (err) { - should.not.exist(err); + }); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + it('the client.getService() method should take a name, return a service instance', function(done) { - done(); + if (mock) { + setupGetServiceMock(client, { + authServer: authHockInstance, + server: hockInstance }); + } + + client.getService(context.services[0].name, function (err, service) { + should.not.exist(err); + should.exist(service); + service.should.be.an.instanceOf(Service); + service.should.have.property('name', context.services[0].name); + + context.currentService = service; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); - - it('the client.deleteService() method should take a name, delete a service', function(done) { - if (mock) { - setupDeleteServiceMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteService(context.currentService.name, function (err) { - should.not.exist(err); + }); + + // TODO: Re-enable once https://github.com/mmalecki/hock/pull/20 is merged + // and published to npm + it.skip('the client.updateService() method should update a service', function(done) { - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + var serviceToUpdate = context.currentService; + serviceToUpdate.origins[0].origin = 'updated-origin.pkgcloud.net'; - done(); + if (mock) { + setupUpdateServiceMock(client, { + authServer: authHockInstance, + server: hockInstance }); + } + + client.updateService(serviceToUpdate, function (err, service) { + should.not.exist(err); + should.exist(service); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); - - it('the client.deleteServiceCachedAssets() method should delete all cached assets of a service', function(done) { - if (mock) { - setupDeleteServiceAllCachedAssetsMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteServiceCachedAssets(context.currentService, function (err) { - console.log(err); - should.not.exist(err); + }); + + it('the client.deleteService() method should delete a service', function(done) { + if (mock) { + setupDeleteServiceMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + client.deleteService(context.currentService, function (err) { + should.not.exist(err); - done(); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.deleteService() method should take a name, delete a service', function(done) { + if (mock) { + setupDeleteServiceMock(client, { + authServer: authHockInstance, + server: hockInstance }); + } + + client.deleteService(context.currentService.name, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); - - it('the client.deleteServiceCachedAssets() method should take an asset URL, delete that cached asset of a service', function(done) { - if (mock) { - setupDeleteServiceCachedAssetMock(client, provider, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteServiceCachedAssets(context.currentService, '/images/logo.png', function (err) { - console.log(err); - should.not.exist(err); + }); - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); + it('the client.deleteServiceCachedAssets() method should delete all cached assets of a service', function(done) { + if (mock) { + setupDeleteServiceAllCachedAssetsMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteServiceCachedAssets(context.currentService, function (err) { + console.log(err); + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); - done(); + done(); + }); + }); + + it('the client.deleteServiceCachedAssets() method should take an asset URL, delete that cached asset of a service', function(done) { + if (mock) { + setupDeleteServiceCachedAssetMock(client, { + authServer: authHockInstance, + server: hockInstance }); + } + + client.deleteServiceCachedAssets(context.currentService, '/images/logo.png', function (err) { + console.log(err); + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); }); - }); - + }); -setupCreateServiceMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.authServer - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } +setupCreateServiceMock = function (client, servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' } - }) - .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/services', { + name: 'pkgcloud-site', + domains: [ + { + domain: 'pkgcloud.com' + }, + { + domain: 'www.pkgcloud.com' } - }) - .reply(200, helpers.getOpenstackAuthResponse()); - - servers.server - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/services', { - name: 'pkgcloud-site', - domains: [ - { - domain: 'pkgcloud.com' - }, - { - domain: 'www.pkgcloud.com' - } - ], - origins: [ - { - origin: 'origin.pkgcloud.com' - } - ], - flavor_id: 'cdn' - }) - .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); - } + ], + origins: [ + { + origin: 'origin.pkgcloud.com' + } + ], + flavor_id: 'cdn' + }) + .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); }; -setupGetServicesMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnServices.json'); - } +setupGetServicesMock = function (client, servers) { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnServices.json'); }; -setupGetServiceMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); - } +setupGetServiceMock = function (client, servers) { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); }; -setupUpdateServiceMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site', { - name: 'pkgcloud-site', - domains: [ - { - domain: 'pkgcloud.com' - }, - { - domain: 'www.pkgcloud.com' - } - ], - origins: [ - { - origin: 'origin-updated.pkgcloud.com' - } - ], - flavor_id: 'cdn' - }) - .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }); - } +setupUpdateServiceMock = function (client, servers) { + servers.server + .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site', { + name: 'pkgcloud-site', + domains: [ + { + domain: 'pkgcloud.com' + }, + { + domain: 'www.pkgcloud.com' + } + ], + origins: [ + { + origin: 'origin-updated.pkgcloud.com' + } + ], + flavor_id: 'cdn' + }) + .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }); }; -setupDeleteServiceMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') - .reply(202); - } +setupDeleteServiceMock = function (client, servers) { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .reply(202); }; -setupDeleteServiceAllCachedAssetsMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?all=true') - .reply(202); - } +setupDeleteServiceAllCachedAssetsMock = function (client, servers) { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?all=true') + .reply(202); }; -setupDeleteServiceCachedAssetMock = function (client, provider, servers) { - if (provider === 'openstack') { - servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?url=%2Fimages%2Flogo.png') - .reply(202); - } +setupDeleteServiceCachedAssetMock = function (client, servers) { + servers.server + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?url=%2Fimages%2Flogo.png') + .reply(202); }; From ff629fa6b5676d8d2482415f7f167bc7ac825099 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 06:05:52 -0800 Subject: [PATCH 309/460] Adding Rackspace CDN support. --- README.md | 4 +- docs/providers/rackspace/cdn.md | 87 ++++++++++++++++++++++ lib/pkgcloud/rackspace/cdn/client/index.js | 27 +++++++ lib/pkgcloud/rackspace/cdn/index.js | 15 ++++ lib/pkgcloud/rackspace/index.js | 1 + 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 docs/providers/rackspace/cdn.md create mode 100644 lib/pkgcloud/rackspace/cdn/client/index.js create mode 100644 lib/pkgcloud/rackspace/cdn/index.js diff --git a/README.md b/README.md index 58a1aed55..02e102346 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ If a service does not have at least two providers, it is considered a *beta* int * [Rackspace](docs/providers/rackspace/network.md) * **[CDN](#cdn----beta)** * [Openstack](docs/providers/openstack/cdn.md) + * [Rackspace](docs/providers/rackspace/cdn.md) ## Compute @@ -534,7 +535,7 @@ Each instance of `pkgcloud.orchestration.Client` returned from `pkgcloud.orchest ## CDN -- Beta -##### Note: CDN is considered Beta until there are multiple providers; presently only Openstack is supported. +##### Note: CDN is considered Beta until there are multiple providers; presently only Openstack and Rackspace are supported. The `pkgcloud.cdn` service is designed to allow you to access Openstack Poppy via node.js. You can manage services and flavors from within any node.js application. @@ -556,6 +557,7 @@ To get started with a `pkgcloud.cdn` client just create one: #### Providers * [Openstack](docs/providers/openstack/cdn.md) +* [Rackspace](docs/providers/rackspace/cdn.md) Each instance of `pkgcloud.cdn.Client` returned from `pkgcloud.cdn.createClient` has a set of uniform APIs: diff --git a/docs/providers/rackspace/cdn.md b/docs/providers/rackspace/cdn.md new file mode 100644 index 000000000..e988a1179 --- /dev/null +++ b/docs/providers/rackspace/cdn.md @@ -0,0 +1,87 @@ +##Using the Rackspace CDN provider + +Creating a client is straight-forward: + +``` js + var rackspace = pkgcloud.cdn.createClient({ + provider: 'rackspace', // required + username: 'your-user-name', // required + password: 'your-password', // required + authUrl: 'your identity service url' // required + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +## Services + +#### client.createService(options, callback) +Creates a service with the options specified. + +Options are as follows: + +```js +{ + name: 'my-service-name', // name of service, required + domains: [ ... ], // list of domains for service, required + origins: [ ... ], // list of origins for service, required + caching: [ ... ], // list of caching rules for service, optional + restrictions: [ ... ], // list of restrictions on where service can be accessed from, optional + flavorId: 'cdn' // ID of CDN flavor to use, required +} +``` +Callback is `f(err, service)`, where `service` is the created service. + +#### client.getServices([options], callback) + +Lists all created services. Callback is `f(err, services)` where `services` +is an `Array`. + +#### client.getService(service, callback) + +Retrieve the created service for the provided service or serviceName. Callback is `f(err, +service)`. + +#### client.updateService(service, callback) + +Update the provided service. + +The following values from the provided service are updatable. + +```js +{ + name: 'my-service-name', // name of service, required + domains: [ ... ], // list of domains for service, required + origins: [ ... ], // list of origins for service, required + flavorId: 'cdn' // ID of CDN flavor to use, required +} +``` + +#### client.deleteService(service, callback) + +Delete the created service. Callback is `f(err)`. + +## Service Assets + +#### client.deleteServiceCachedAssets(service, assetUrl, callback) + +Purge the service's cached asset (if `assetUrl` is specified) or all cached +assets (if `assetUrl` is not specified). Callback is `f(err)`. + +## Flavors + +#### client.getFlavors(options, callback) + +Lists all available CDN flavors. Callback is `f(err, flavors)` where +`flavors` is an Array. + +#### client.getFlavor(flavor, callback) + +Retrieve the CDN flavor for a provided flavor or flavorId. Callback is `f(err, +flavor)`. + +#### client.deleteFlavor(flavor, callback) + +Delete a flavor. Callback is `f(err)`. \ No newline at end of file diff --git a/lib/pkgcloud/rackspace/cdn/client/index.js b/lib/pkgcloud/rackspace/cdn/client/index.js new file mode 100644 index 000000000..ddf6f26bd --- /dev/null +++ b/lib/pkgcloud/rackspace/cdn/client/index.js @@ -0,0 +1,27 @@ +/* + * client.js: client for Rackspace CDN + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT License + */ + +var util = require('util'), + rackspace = require('../../client'), + _ = require('underscore'); + +var Client = exports.Client = function (options) { + rackspace.Client.call(this, options); + + this.models = { + Service: require('../../../openstack/cdn/service').Service, + Flavor: require('../../../openstack/cdn/flavor').Flavor + }; + + _.extend(this, require('../../../openstack/cdn/client/services')); + _.extend(this, require('../../../openstack/cdn/client/flavors')); + + this.serviceType = 'cdn'; +}; + +util.inherits(Client, rackspace.Client); diff --git a/lib/pkgcloud/rackspace/cdn/index.js b/lib/pkgcloud/rackspace/cdn/index.js new file mode 100644 index 000000000..1a5f56266 --- /dev/null +++ b/lib/pkgcloud/rackspace/cdn/index.js @@ -0,0 +1,15 @@ +/* + * index.js: Top-level include for the Rackspace CDN module. + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +exports.Client = require('./client').Client; +exports.Service = require('../../openstack/cdn/service').Service; +exports.Flavor = require('../../openstack/cdn/flavor').Flavor; + +exports.createClient = function(options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/rackspace/index.js b/lib/pkgcloud/rackspace/index.js index 050f14f40..e6c4b9344 100644 --- a/lib/pkgcloud/rackspace/index.js +++ b/lib/pkgcloud/rackspace/index.js @@ -13,3 +13,4 @@ exports.loadbalancer = require('./loadbalancer'); exports.orchestration = require('./orchestration'); exports.storage = require('./storage'); exports.network = require('./network'); +exports.cdn = require('./cdn'); From 7b5d9e019f9262574107e1e98b4587057af8e54d Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 27 Dec 2014 08:31:28 -0800 Subject: [PATCH 310/460] Re-enabling update service test that uses PATCH. --- lib/pkgcloud/openstack/cdn/client/services.js | 4 +--- package.json | 2 +- test/openstack/cdn/services-test.js | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 8166932ea..9d092a249 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -207,9 +207,7 @@ exports.updateService = function (service, callback) { body: { domains: service.domains, origins: service.origins, - flavor_id: service.flavorId, - caching: service.caching, - restrictions: service.restrictions + flavor_id: service.flavorId }, method: 'PATCH' }, function (err) { diff --git a/package.json b/package.json index fcdf5e5e0..86cdfd452 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "devDependencies": { "blanket": "^1.1.6", "coveralls": "^2.11.2", - "hock": "1.0.x", + "hock": "1.1.x", "jshint": "2.x.x", "mocha": "1.21.x", "mocha-lcov-reporter": "0.0.1", diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js index a62caa51b..726e09471 100644 --- a/test/openstack/cdn/services-test.js +++ b/test/openstack/cdn/services-test.js @@ -176,12 +176,10 @@ describe('pkgcloud/openstack/cdn/services', function() { }); }); - // TODO: Re-enable once https://github.com/mmalecki/hock/pull/20 is merged - // and published to npm - it.skip('the client.updateService() method should update a service', function(done) { + it('the client.updateService() method should update a service', function(done) { var serviceToUpdate = context.currentService; - serviceToUpdate.origins[0].origin = 'updated-origin.pkgcloud.net'; + serviceToUpdate.origins[0].origin = 'updated-origin.pkgcloud.com'; if (mock) { setupUpdateServiceMock(client, { @@ -191,6 +189,7 @@ describe('pkgcloud/openstack/cdn/services', function() { } client.updateService(serviceToUpdate, function (err, service) { + console.log(err); should.not.exist(err); should.exist(service); @@ -339,18 +338,22 @@ setupGetServiceMock = function (client, servers) { setupUpdateServiceMock = function (client, servers) { servers.server .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site', { - name: 'pkgcloud-site', domains: [ { - domain: 'pkgcloud.com' + domain: 'pkgcloud.com', + protocol: 'http' }, { - domain: 'www.pkgcloud.com' + domain: 'www.pkgcloud.com', + protocol: 'http' } ], origins: [ { - origin: 'origin-updated.pkgcloud.com' + origin: 'updated-origin.pkgcloud.com', + port: 80, + ssl: false, + rules: [] } ], flavor_id: 'cdn' From 167250304b09b58eb6076169086a9a7aa56e8a4a Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 29 Dec 2014 07:06:17 -0800 Subject: [PATCH 311/460] Adding client._getUrl method. --- .../openstack/orchestration/client/index.js | 22 ++++++++++++++++++ lib/pkgcloud/rackspace/cdn/client/index.js | 23 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js index 770ba32e5..f9ad624e5 100644 --- a/lib/pkgcloud/openstack/orchestration/client/index.js +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -66,3 +66,25 @@ Client.prototype.buildInfo = function(callback) { callback(null, body); }); }; + +/** + * client._getUrl + * + * @description get the url for the current compute service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function (options) { + options = options || {}; + + if (!this._serviceUrl) { + throw new Error('Service url not found'); + } + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); +}; diff --git a/lib/pkgcloud/rackspace/cdn/client/index.js b/lib/pkgcloud/rackspace/cdn/client/index.js index ddf6f26bd..5f3ded77b 100644 --- a/lib/pkgcloud/rackspace/cdn/client/index.js +++ b/lib/pkgcloud/rackspace/cdn/client/index.js @@ -8,6 +8,7 @@ var util = require('util'), rackspace = require('../../client'), + urlJoin = require('url-join'), _ = require('underscore'); var Client = exports.Client = function (options) { @@ -25,3 +26,25 @@ var Client = exports.Client = function (options) { }; util.inherits(Client, rackspace.Client); + +/** + * client._getUrl + * + * @description get the url for the current compute service + * + * @param options + * @returns {exports|*} + * @private + */ +Client.prototype._getUrl = function (options) { + options = options || {}; + + if (!this._serviceUrl) { + throw new Error('Service url not found'); + } + + return urlJoin(this._serviceUrl, + typeof options === 'string' + ? options + : options.path); +}; From e3209d3f7116aaa211a88fcede3127fb71aefb74 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 29 Dec 2014 07:06:28 -0800 Subject: [PATCH 312/460] Fixing service type for Rackspace client. --- lib/pkgcloud/rackspace/cdn/client/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/rackspace/cdn/client/index.js b/lib/pkgcloud/rackspace/cdn/client/index.js index 5f3ded77b..4cd3e72b5 100644 --- a/lib/pkgcloud/rackspace/cdn/client/index.js +++ b/lib/pkgcloud/rackspace/cdn/client/index.js @@ -22,7 +22,7 @@ var Client = exports.Client = function (options) { _.extend(this, require('../../../openstack/cdn/client/services')); _.extend(this, require('../../../openstack/cdn/client/flavors')); - this.serviceType = 'cdn'; + this.serviceType = 'rax:cdn'; }; util.inherits(Client, rackspace.Client); From cb738d0721e113b55854dec7b6a68e05afd59226 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 29 Dec 2014 09:02:29 -0800 Subject: [PATCH 313/460] Dropping support for administrative operations. --- README.md | 1 - docs/providers/openstack/cdn.md | 4 - docs/providers/rackspace/cdn.md | 4 - lib/pkgcloud/openstack/cdn/client/flavors.js | 101 ------------------- test/openstack/cdn/flavors-test.js | 101 +------------------ 5 files changed, 2 insertions(+), 209 deletions(-) diff --git a/README.md b/README.md index 02e102346..6c46d85ed 100644 --- a/README.md +++ b/README.md @@ -574,7 +574,6 @@ Each instance of `pkgcloud.cdn.Client` returned from `pkgcloud.cdn.createClient` ### Flavors * `client.getFlavor(flavor, function (err, flavor) { })` * `client.getFlavors(options, function (err, flavors) { })` -* `client.deleteFlavor(flavor, function (err) { })` ## Installation diff --git a/docs/providers/openstack/cdn.md b/docs/providers/openstack/cdn.md index bf4c4e095..9b1a57bca 100644 --- a/docs/providers/openstack/cdn.md +++ b/docs/providers/openstack/cdn.md @@ -81,7 +81,3 @@ Lists all available CDN flavors. Callback is `f(err, flavors)` where Retrieve the CDN flavor for a provided flavor or flavorId. Callback is `f(err, flavor)`. - -#### client.deleteFlavor(flavor, callback) - -Delete a flavor. Callback is `f(err)`. \ No newline at end of file diff --git a/docs/providers/rackspace/cdn.md b/docs/providers/rackspace/cdn.md index e988a1179..a41c1200b 100644 --- a/docs/providers/rackspace/cdn.md +++ b/docs/providers/rackspace/cdn.md @@ -81,7 +81,3 @@ Lists all available CDN flavors. Callback is `f(err, flavors)` where Retrieve the CDN flavor for a provided flavor or flavorId. Callback is `f(err, flavor)`. - -#### client.deleteFlavor(flavor, callback) - -Delete a flavor. Callback is `f(err)`. \ No newline at end of file diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index 1684574f1..ba7e694b8 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -7,37 +7,11 @@ */ var pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), urlJoin = require('url-join'), - util = require('util'), cdn = pkgcloud.providers.openstack.cdn; var _urlPrefix = '/flavors'; -/** - * validateProperties - * - * @description local helper function for validating arguments - * - * @param {Array} required The list of required properties - * @param {object} options The options object to validate - * @param {String} formatString String formatter for the error message - * @param {Function} callback - * @returns {boolean} - */ -function validateProperties(required, options, formatString, callback) { - return !required.some(function (item) { - if (typeof(options[item]) === 'undefined') { - errs.handle( - errs.create({ message: util.format(formatString, item) }), - callback - ); - return true; - } - return false; - }); -} - /** * client.getFlavor * @@ -100,78 +74,3 @@ exports.getFlavors = function getFlavors(options, callback) { })); }); }; - -/** - * client.createFlavor - * - * @description Creates a flavor with the specified options. - - * @param {object} details the details to create this flavor - * @param {String} details.id the id of the new flavor - * @param {Array} details.providers list of providers for the new flavor - * @param {Object} details.providers[n] information about a provider - * @param {String} details.providers[n].provider the provider's name - * @param {Array} details.providers[n].links list of links for the provider - * @param {Object} details.providers[n].links[n] information about a provider's link - * @param {String} details.providers[n].links[n].href the URL of the link - * @param {String} details.providers[n].links[n].rel the relationship of the link - * @param callback - * @returns {request|null} - */ -exports.createFlavor = function (details, callback) { - if (typeof details === 'function') { - callback = details; - details = {}; - } - - details = details || {}; - - if (!validateProperties(['id', 'providers'], details, - 'options.%s is a required argument.', callback)) { - return; - } - - var self = this, - createOptions = { - method: 'POST', - path: _urlPrefix, - body: { - id: details.id, - providers: details.providers - } - }; - - return self._request(createOptions, function (err) { - if (err) { - return callback(err); - } - - return self.getFlavor(details.id, callback); - }); -}; - -/** - * client.deleteFlavor - * - * @description Delete a flavor from the account - * - * @param {String|object} flavor The flavor or flavorId to delete - * @param {Function} callback - * @returns {request|*} - */ -exports.deleteFlavor = function (flavor, callback) { - var path = flavor instanceof cdn.Flavor - ? urlJoin(_urlPrefix, flavor.id) - : urlJoin(_urlPrefix, flavor); - - return this._request({ - path: path, - method: 'DELETE' - }, function (err) { - if (err) { - return callback(err); - } - - callback(); - }); -}; diff --git a/test/openstack/cdn/flavors-test.js b/test/openstack/cdn/flavors-test.js index 0b13ddfad..c187dd47e 100644 --- a/test/openstack/cdn/flavors-test.js +++ b/test/openstack/cdn/flavors-test.js @@ -15,8 +15,7 @@ var helpers = require('../../helpers'), Flavor = require('../../../lib/pkgcloud/openstack/cdn/flavor').Flavor; // Declaring variables for helper functions defined later -var setupCreateFlavorMock, setupGetFlavorsMock, setupGetFlavorMock, - setupDeleteFlavorMock; +var setupGetFlavorsMock, setupGetFlavorMock; describe('pkgcloud/openstack/cdn/flavors', function() { @@ -69,39 +68,6 @@ describe('pkgcloud/openstack/cdn/flavors', function() { // Unit tests follow... - it('the client.createFlavor() method should create a flavor', function(done) { - - if (mock) { - setupCreateFlavorMock(client, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.createFlavor({ - id: 'cdn', - providers: [ - { - provider: 'akamai', - links: [ - { - 'rel': 'provider_url', - 'href': 'http://www.akamai.com' - } - ] - } - ] - }, function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - it('the client.getFlavors() method should return a list of flavors', function(done) { if (mock) { @@ -171,46 +137,10 @@ describe('pkgcloud/openstack/cdn/flavors', function() { done(); }); }); - - it('the client.deleteFlavor() method should delete a flavor', function(done) { - if (mock) { - setupDeleteFlavorMock(client, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteFlavor(context.currentFlavor, function (err) { - should.not.exist(err); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - it('the client.deleteFlavor() method should take a id, delete a flavor', function(done) { - if (mock) { - setupDeleteFlavorMock(client, { - authServer: authHockInstance, - server: hockInstance - }); - } - - client.deleteFlavor(context.currentFlavor.id, function (err) { - should.not.exist(err); - - authHockInstance && authHockInstance.done(); - hockInstance && hockInstance.done(); - - done(); - }); - }); - }); -setupCreateFlavorMock = function (client, servers) { +setupGetFlavorsMock = function (client, servers) { servers.authServer .post('/v2.0/tokens', { auth: { @@ -234,27 +164,6 @@ setupCreateFlavorMock = function (client, servers) { }) .reply(200, helpers.getOpenstackAuthResponse()); - servers.server - .post('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors', { - id: 'cdn', - providers: [ - { - provider: 'akamai', - links: [ - { - 'rel': 'provider_url', - 'href': 'http://www.akamai.com' - } - ] - } - ] - }) - .reply(201, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn' }) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') - .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); -}; - -setupGetFlavorsMock = function (client, servers) { servers.server .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavors.json'); @@ -265,9 +174,3 @@ setupGetFlavorMock = function (client, servers) { .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnFlavor.json'); }; - -setupDeleteFlavorMock = function (client, servers) { - servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors/cdn') - .reply(204); -}; From a710999e18bcae91cef4718daaa8d5087b342d6e Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 29 Dec 2014 10:11:22 -0800 Subject: [PATCH 314/460] Pass null when there is no error. --- lib/pkgcloud/openstack/cdn/client/flavors.js | 2 +- lib/pkgcloud/openstack/cdn/client/services.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index ba7e694b8..6cc95a5b7 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -69,7 +69,7 @@ exports.getFlavors = function getFlavors(options, callback) { return; } - callback(err, body.flavors.map(function(flavor) { + callback(null, body.flavors.map(function(flavor) { return new cdn.Flavor(self, flavor); })); }); diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 9d092a249..bb3ab5b3a 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -100,7 +100,7 @@ exports.getServices = function getServices(options, callback) { return; } - callback(err, body.services.map(function(service) { + callback(null, body.services.map(function(service) { return new cdn.Service(self, service); })); }); @@ -215,7 +215,7 @@ exports.updateService = function (service, callback) { return callback(err); } - callback(err, service); + callback(null, service); }); }; From 6e497aca7840f74c78c9284de79bbb341730a0e6 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 29 Dec 2014 10:12:14 -0800 Subject: [PATCH 315/460] Adding support for GET / and GET /ping operations. --- README.md | 4 + docs/providers/openstack/cdn.md | 9 ++ docs/providers/rackspace/cdn.md | 9 ++ lib/pkgcloud/openstack/cdn/client/base.js | 53 +++++++ lib/pkgcloud/openstack/cdn/client/index.js | 1 + lib/pkgcloud/rackspace/cdn/client/index.js | 1 + test/fixtures/openstack/cdnHomeDocument.json | 21 +++ test/openstack/cdn/base-test.js | 143 +++++++++++++++++++ 8 files changed, 241 insertions(+) create mode 100644 lib/pkgcloud/openstack/cdn/client/base.js create mode 100644 test/fixtures/openstack/cdnHomeDocument.json create mode 100644 test/openstack/cdn/base-test.js diff --git a/README.md b/README.md index 6c46d85ed..982b27e38 100644 --- a/README.md +++ b/README.md @@ -561,6 +561,10 @@ To get started with a `pkgcloud.cdn` client just create one: Each instance of `pkgcloud.cdn.Client` returned from `pkgcloud.cdn.createClient` has a set of uniform APIs: +### Base +* `client.getHomeDocument(function (err, homeDocument) { })` +* `client.getPing(function (err) { })` + ### Service * `client.getService(service, function (err, service) { })` * `client.getServices(options, function (err, services) { })` diff --git a/docs/providers/openstack/cdn.md b/docs/providers/openstack/cdn.md index 9b1a57bca..62bf2764d 100644 --- a/docs/providers/openstack/cdn.md +++ b/docs/providers/openstack/cdn.md @@ -15,6 +15,15 @@ Creating a client is straight-forward: ### API Methods +## Base + +#### `client.getHomeDocument(function (err, homeDocument) { })` +Retrieves the home document, which allows you to navigate the remainder of the +API. Callback is `f(err, homeDocument)` where `homeDocument` is an `Object`. + +#### `client.getPing(function (err) { })` +Pings the server for any errors. Callback is `f(err)`. + ## Services #### client.createService(options, callback) diff --git a/docs/providers/rackspace/cdn.md b/docs/providers/rackspace/cdn.md index a41c1200b..271cd22d4 100644 --- a/docs/providers/rackspace/cdn.md +++ b/docs/providers/rackspace/cdn.md @@ -15,6 +15,15 @@ Creating a client is straight-forward: ### API Methods +## Base + +#### `client.getHomeDocument(function (err, homeDocument) { })` +Retrieves the home document, which allows you to navigate the remainder of the +API. Callback is `f(err, homeDocument)` where `homeDocument` is an `Object`. + +#### `client.getPing(function (err) { })` +Pings the server for any errors. Callback is `f(err)`. + ## Services #### client.createService(options, callback) diff --git a/lib/pkgcloud/openstack/cdn/client/base.js b/lib/pkgcloud/openstack/cdn/client/base.js new file mode 100644 index 000000000..ce429c87b --- /dev/null +++ b/lib/pkgcloud/openstack/cdn/client/base.js @@ -0,0 +1,53 @@ +/* + * flavors.js: Instance methods for working with base resources from Openstack CDN + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +/** + * client.getHomeDocument + * + * @description gets the home document for the CDN service + * + * @param callback + * @return {*} + */ +exports.getHomeDocument = function(callback) { + var requestOptions = { + path: '/' + }; + + return this._request(requestOptions, function (err, body) { + if (err) { + callback(err); + return; + } + + callback(null, body); + }); +}; + +/** + * client.getPing + * + * @description gets the server ping response (status response) + * + * @param callback + * @return {*} + */ +exports.getPing = function(callback) { + var requestOptions = { + path: '/ping' + }; + + return this._request(requestOptions, function (err) { + if (err) { + callback(err); + return; + } + + callback(); + }); +}; diff --git a/lib/pkgcloud/openstack/cdn/client/index.js b/lib/pkgcloud/openstack/cdn/client/index.js index 5c8b4e5f8..b06b976c9 100644 --- a/lib/pkgcloud/openstack/cdn/client/index.js +++ b/lib/pkgcloud/openstack/cdn/client/index.js @@ -14,6 +14,7 @@ var util = require('util'), var Client = exports.Client = function (options) { openstack.Client.call(this, options); + _.extend(this, require('./base')); _.extend(this, require('./services')); _.extend(this, require('./flavors')); diff --git a/lib/pkgcloud/rackspace/cdn/client/index.js b/lib/pkgcloud/rackspace/cdn/client/index.js index 4cd3e72b5..ca1df0f16 100644 --- a/lib/pkgcloud/rackspace/cdn/client/index.js +++ b/lib/pkgcloud/rackspace/cdn/client/index.js @@ -19,6 +19,7 @@ var Client = exports.Client = function (options) { Flavor: require('../../../openstack/cdn/flavor').Flavor }; + _.extend(this, require('../../../openstack/cdn/client/base')); _.extend(this, require('../../../openstack/cdn/client/services')); _.extend(this, require('../../../openstack/cdn/client/flavors')); diff --git a/test/fixtures/openstack/cdnHomeDocument.json b/test/fixtures/openstack/cdnHomeDocument.json new file mode 100644 index 000000000..6792894c1 --- /dev/null +++ b/test/fixtures/openstack/cdnHomeDocument.json @@ -0,0 +1,21 @@ +{ + "resources":{ + "rel/cdn":{ + "href-template":"services{?marker,limit}", + "href-vars":{ + "marker":"param/marker", + "limit":"param/limit" + }, + "hints":{ + "allow":[ + "GET" + ], + "formats":{ + "application/json":{ + + } + } + } + } + } +} diff --git a/test/openstack/cdn/base-test.js b/test/openstack/cdn/base-test.js new file mode 100644 index 000000000..b6954df63 --- /dev/null +++ b/test/openstack/cdn/base-test.js @@ -0,0 +1,143 @@ +/* + * base-resource-test.js: Unit tests for the CDN service's base resources + * + * (C) 2014 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var helpers = require('../../helpers'), + mock = !!process.env.MOCK, + hock = require('hock'), + http = require('http'), + async = require('async'), + should = require('should'); + +// Declaring variables for helper functions defined later +var setupGetHomeDocumentMock, setupGetPingMock; + +describe('pkgcloud/openstack/cdn/base', function() { + + // Create CDN service client + var client = helpers.createClient('openstack', 'cdn'), + authHockInstance, hockInstance, + authServer, server; + + // Runs before all unit tests are run + before(function (done) { + + if (!mock) { + return done(); + } + + // Spin up an authentication server as well as a CDN flavor server + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + // Runs after all unit tests have run + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + + }); + + // Unit tests follow... + + it('the client.getHomeDocument() method should return the home document', function(done) { + + if (mock) { + setupGetHomeDocumentMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getHomeDocument(function (err, homeDocument) { + should.not.exist(err); + should.exist(homeDocument); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.getPing() method should return the ping response', function(done) { + + if (mock) { + setupGetPingMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getPing(function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + +}); + +setupGetHomeDocumentMock = function (client, servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnHomeDocument.json'); +}; + +setupGetPingMock = function (client, servers) { + servers.server + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/ping') + .reply(204); +}; From b5d66d1ebfc6495e1424bce3943e7182fda435d9 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 29 Dec 2014 14:49:33 -0800 Subject: [PATCH 316/460] Fixing logic to account for operator precedence. --- lib/pkgcloud/openstack/cdn/client/services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index bb3ab5b3a..6152b18d4 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -197,7 +197,7 @@ exports.createService = function (details, callback) { * @returns {request|*} */ exports.updateService = function (service, callback) { - if (!service instanceof cdn.Service) { + if (!(service instanceof cdn.Service)) { callback(new Error('you must provide a service to update')); return; } From cd97d9da1f3daefe8845a31ef3953b5c60be4430 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 29 Dec 2014 14:50:50 -0800 Subject: [PATCH 317/460] Fixing how error is propagated. --- lib/pkgcloud/openstack/cdn/client/flavors.js | 2 +- lib/pkgcloud/openstack/cdn/client/services.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index 6cc95a5b7..a15e99394 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -34,7 +34,7 @@ exports.getFlavor = function (flavor, callback) { return callback(err); } if (!body) { - return new Error('Unexpected empty response'); + callback(new Error('Unexpected empty response')); } else { callback(null, new cdn.Flavor(self, body)); diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 6152b18d4..c8e52f2f3 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -61,7 +61,7 @@ exports.getService = function (service, callback) { return callback(err); } if (!body) { - return new Error('Unexpected empty response'); + callback(new Error('Unexpected empty response')); } else { callback(null, new cdn.Service(self, body)); From 371e12d8f2007b5c0b57abf01682abf1fefb9cf4 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 30 Dec 2014 05:35:32 -0800 Subject: [PATCH 318/460] Adding errors property to Service model. --- lib/pkgcloud/openstack/cdn/service.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/cdn/service.js b/lib/pkgcloud/openstack/cdn/service.js index 96e6f9b07..4d7ce39ad 100644 --- a/lib/pkgcloud/openstack/cdn/service.js +++ b/lib/pkgcloud/openstack/cdn/service.js @@ -26,9 +26,10 @@ Service.prototype._setProperties = function (details) { this.flavorId = details.flavorId || details['flavor_id']; this.status = details.status || details['status']; this.links = details.links; + this.errors = details.errors; }; Service.prototype.toJSON = function () { return _.pick(this, ['name', 'domains', 'origins', 'caching', - 'restrictions', 'flavorId', 'status', 'links']); + 'restrictions', 'flavorId', 'status', 'links', 'errors']); }; From c9b4a9dc69169eb26050dd4eb5df74d48d20ac16 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 1 Jan 2015 04:23:55 -0800 Subject: [PATCH 319/460] Introduce new id property for service. --- lib/pkgcloud/openstack/cdn/client/services.js | 14 +++++------ lib/pkgcloud/openstack/cdn/service.js | 3 ++- test/fixtures/openstack/cdnService.json | 1 + test/fixtures/openstack/cdnServices.json | 3 ++- test/openstack/cdn/services-test.js | 24 +++++++++---------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index c8e52f2f3..c2b79a07f 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -44,7 +44,7 @@ function validateProperties(required, options, formatString, callback) { * * @description Gets a service from the account * - * @param {String|object} service The service or serviceName to fetch + * @param {String|object} service The service or serviceId to fetch * @param {Function} callback * @returns {request|*} */ @@ -192,7 +192,7 @@ exports.createService = function (details, callback) { * * @description Update a service * - * @param {String|object} service The service or serviceName to update + * @param {String|object} service The service or serviceId to update * @param {Function} callback * @returns {request|*} */ @@ -203,7 +203,7 @@ exports.updateService = function (service, callback) { } return this._request({ - path: urlJoin(_urlPrefix, service.name), + path: urlJoin(_urlPrefix, service.id), body: { domains: service.domains, origins: service.origins, @@ -224,13 +224,13 @@ exports.updateService = function (service, callback) { * * @description Delete a service from the account * - * @param {String|object} service The service or serviceName to delete + * @param {String|object} service The service or serviceId to delete * @param {Function} callback * @returns {request|*} */ exports.deleteService = function (service, callback) { var path = service instanceof cdn.Service - ? urlJoin(_urlPrefix, service.name) + ? urlJoin(_urlPrefix, service.id) : urlJoin(_urlPrefix, service); return this._request({ @@ -250,14 +250,14 @@ exports.deleteService = function (service, callback) { * * @description Delete cached assets of a service * - * @param {String|object} service The service or serviceName to delete + * @param {String|object} service The service or serviceId whose cached assets to delete * @param {String|null} assetUrl The URL of the asset to delete; default = delete all assets * @param {Function} callback * @returns {request|*} */ exports.deleteServiceCachedAssets = function (service, assetUrl, callback) { var path = service instanceof cdn.Service - ? urlJoin(_urlPrefix, service.name) + ? urlJoin(_urlPrefix, service.id) : urlJoin(_urlPrefix, service); if (!callback) { diff --git a/lib/pkgcloud/openstack/cdn/service.js b/lib/pkgcloud/openstack/cdn/service.js index 4d7ce39ad..5d8a453f2 100644 --- a/lib/pkgcloud/openstack/cdn/service.js +++ b/lib/pkgcloud/openstack/cdn/service.js @@ -18,6 +18,7 @@ var Service = exports.Service = function Service(client, details) { util.inherits(Service, base.Model); Service.prototype._setProperties = function (details) { + this.id = details.id || details['id']; this.name = details.name || details['name']; this.domains = details.domains || details['domains']; this.origins = details.origins || details['origins']; @@ -30,6 +31,6 @@ Service.prototype._setProperties = function (details) { }; Service.prototype.toJSON = function () { - return _.pick(this, ['name', 'domains', 'origins', 'caching', + return _.pick(this, ['id', 'name', 'domains', 'origins', 'caching', 'restrictions', 'flavorId', 'status', 'links', 'errors']); }; diff --git a/test/fixtures/openstack/cdnService.json b/test/fixtures/openstack/cdnService.json index 3be862c77..8184b7a7b 100644 --- a/test/fixtures/openstack/cdnService.json +++ b/test/fixtures/openstack/cdnService.json @@ -1,4 +1,5 @@ { + "id": "d49cd860-911f-11e4-b4a9-0800200c9a66", "name":"pkgcloud-site", "domains":[ { diff --git a/test/fixtures/openstack/cdnServices.json b/test/fixtures/openstack/cdnServices.json index 6d7a97912..d00595585 100644 --- a/test/fixtures/openstack/cdnServices.json +++ b/test/fixtures/openstack/cdnServices.json @@ -1,6 +1,7 @@ { "services":[ { + "id": "d49cd860-911f-11e4-b4a9-0800200c9a66", "name":"pkgcloud-site", "domains":[ { @@ -51,7 +52,7 @@ ], "links":[ { - "href":"http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services?marker=pkgcloud-site&limit=10", + "href":"http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services?marker=d49cd860-911f-11e4-b4a9-0800200c9a66&limit=10", "rel":"next" } ] diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js index 726e09471..fd3a2a6f6 100644 --- a/test/openstack/cdn/services-test.js +++ b/test/openstack/cdn/services-test.js @@ -152,7 +152,7 @@ describe('pkgcloud/openstack/cdn/services', function() { }); }); - it('the client.getService() method should take a name, return a service instance', function(done) { + it('the client.getService() method should take an id, return a service instance', function(done) { if (mock) { setupGetServiceMock(client, { @@ -161,7 +161,7 @@ describe('pkgcloud/openstack/cdn/services', function() { }); } - client.getService(context.services[0].name, function (err, service) { + client.getService(context.services[0].id, function (err, service) { should.not.exist(err); should.exist(service); service.should.be.an.instanceOf(Service); @@ -218,7 +218,7 @@ describe('pkgcloud/openstack/cdn/services', function() { }); }); - it('the client.deleteService() method should take a name, delete a service', function(done) { + it('the client.deleteService() method should take an id, delete a service', function(done) { if (mock) { setupDeleteServiceMock(client, { authServer: authHockInstance, @@ -226,7 +226,7 @@ describe('pkgcloud/openstack/cdn/services', function() { }); } - client.deleteService(context.currentService.name, function (err) { + client.deleteService(context.currentService.id, function (err) { should.not.exist(err); authHockInstance && authHockInstance.done(); @@ -318,8 +318,8 @@ setupCreateServiceMock = function (client, servers) { ], flavor_id: 'cdn' }) - .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }) - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66' }) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66') .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); }; @@ -331,13 +331,13 @@ setupGetServicesMock = function (client, servers) { setupGetServiceMock = function (client, servers) { servers.server - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66') .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json'); }; setupUpdateServiceMock = function (client, servers) { servers.server - .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site', { + .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66', { domains: [ { domain: 'pkgcloud.com', @@ -358,23 +358,23 @@ setupUpdateServiceMock = function (client, servers) { ], flavor_id: 'cdn' }) - .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site' }); + .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66' }); }; setupDeleteServiceMock = function (client, servers) { servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site') + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66') .reply(202); }; setupDeleteServiceAllCachedAssetsMock = function (client, servers) { servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?all=true') + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66/assets?all=true') .reply(202); }; setupDeleteServiceCachedAssetMock = function (client, servers) { servers.server - .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/pkgcloud-site/assets?url=%2Fimages%2Flogo.png') + .delete('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66/assets?url=%2Fimages%2Flogo.png') .reply(202); }; From d38ff175688d7ec27c697a2cd0fcf33e62c37d73 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 1 Jan 2015 04:24:27 -0800 Subject: [PATCH 320/460] Allow retrieving service by object, ID or URL via private method. --- lib/pkgcloud/openstack/cdn/client/services.js | 63 +++++++++++++------ 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index c2b79a07f..d82615492 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -8,11 +8,15 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), + url = require('url'), urlJoin = require('url-join'), util = require('util'), _ = require('underscore'), cdn = pkgcloud.providers.openstack.cdn; +// Declaring variables for helper functions defined later +var _getService; + var _urlPrefix = '/services'; /** @@ -49,24 +53,7 @@ function validateProperties(required, options, formatString, callback) { * @returns {request|*} */ exports.getService = function (service, callback) { - var self = this, - path = service instanceof cdn.Service - ? urlJoin(_urlPrefix, service.name) - : urlJoin(_urlPrefix, service); - - return this._request({ - path: path - }, function (err, body) { - if (err) { - return callback(err); - } - if (!body) { - callback(new Error('Unexpected empty response')); - } - else { - callback(null, new cdn.Service(self, body)); - } - }); + return _getService(this, service, callback); }; /** @@ -178,12 +165,12 @@ exports.createService = function (details, callback) { createOptions.body.restrictions = details.restrictions; } - return self._request(createOptions, function (err) { + return self._request(createOptions, function (err, body, res) { if (err) { return callback(err); } - return self.getService(details.name, callback); + return _getService(self, res.headers.location, callback); }); }; @@ -277,3 +264,39 @@ exports.deleteServiceCachedAssets = function (service, assetUrl, callback) { callback(); }); }; + +/** + * _getService + * + * @description Gets a service from the account + * + * @param {String|object} service The service or serviceId or serviceUrl to fetch + * @param {Function} callback + * @returns {request|*} + */ +_getService = function (self, service, callback) { + var requestOptions = {}; + + // Determine if service is an object, a URL or a string (serviceId) + if (service instanceof cdn.Service) { + requestOptions.path = urlJoin(_urlPrefix, service.id); + } else { + if (!!url.parse(service).protocol) { + requestOptions.uri = service; + } else { + requestOptions.path = urlJoin(_urlPrefix, service); + } + } + + return self._request(requestOptions, function (err, body) { + if (err) { + return callback(err); + } + if (!body) { + callback(new Error('Unexpected empty response')); + } + else { + callback(null, new cdn.Service(self, body)); + } + }); +}; From 3a705f4f5c8edbb17a5527ea7c2714a6eb112fde Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 1 Jan 2015 04:24:59 -0800 Subject: [PATCH 321/460] Removing debugging statements. --- test/openstack/cdn/services-test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js index fd3a2a6f6..a3794f4e9 100644 --- a/test/openstack/cdn/services-test.js +++ b/test/openstack/cdn/services-test.js @@ -189,7 +189,6 @@ describe('pkgcloud/openstack/cdn/services', function() { } client.updateService(serviceToUpdate, function (err, service) { - console.log(err); should.not.exist(err); should.exist(service); @@ -245,7 +244,6 @@ describe('pkgcloud/openstack/cdn/services', function() { } client.deleteServiceCachedAssets(context.currentService, function (err) { - console.log(err); should.not.exist(err); authHockInstance && authHockInstance.done(); @@ -264,7 +262,6 @@ describe('pkgcloud/openstack/cdn/services', function() { } client.deleteServiceCachedAssets(context.currentService, '/images/logo.png', function (err) { - console.log(err); should.not.exist(err); authHockInstance && authHockInstance.done(); From a2a76f235fa02605144cfe63e1f9db23037f6793 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 5 Jan 2015 18:58:50 -0800 Subject: [PATCH 322/460] Sending a JSON Patch representation for Update Service API. --- lib/pkgcloud/openstack/cdn/client/services.js | 31 +++++++++++------- package.json | 3 +- test/openstack/cdn/services-test.js | 32 ++++++------------- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index d82615492..36f2d4077 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -12,7 +12,8 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), urlJoin = require('url-join'), util = require('util'), _ = require('underscore'), - cdn = pkgcloud.providers.openstack.cdn; + cdn = pkgcloud.providers.openstack.cdn, + jsonpatch = require('fast-json-patch'); // Declaring variables for helper functions defined later var _getService; @@ -184,25 +185,33 @@ exports.createService = function (details, callback) { * @returns {request|*} */ exports.updateService = function (service, callback) { + var self = this; + if (!(service instanceof cdn.Service)) { callback(new Error('you must provide a service to update')); return; } - return this._request({ - path: urlJoin(_urlPrefix, service.id), - body: { - domains: service.domains, - origins: service.origins, - flavor_id: service.flavorId - }, - method: 'PATCH' - }, function (err) { + // Get a pristine copy of service resource from the server + return _getService(self, service, function(err, pristineService) { if (err) { return callback(err); } - callback(null, service); + // Compare passed-in service with pristine copy to generate + // JSON Patch representation + var patch = jsonpatch.compare(pristineService, service); + return self._request({ + path: urlJoin(_urlPrefix, service.id), + body: patch, + method: 'PATCH' + }, function (err) { + if (err) { + return callback(err); + } + + callback(null, service); + }); }); }; diff --git a/package.json b/package.json index 86cdfd452..d6845330b 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,8 @@ "through2": "0.6.x", "underscore": "1.6.x", "url-join": "0.0.x", - "xml2js": "0.1.x" + "xml2js": "0.1.x", + "fast-json-patch": "0.5.x" }, "devDependencies": { "blanket": "^1.1.6", diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js index a3794f4e9..038fb4220 100644 --- a/test/openstack/cdn/services-test.js +++ b/test/openstack/cdn/services-test.js @@ -334,28 +334,16 @@ setupGetServiceMock = function (client, servers) { setupUpdateServiceMock = function (client, servers) { servers.server - .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66', { - domains: [ - { - domain: 'pkgcloud.com', - protocol: 'http' - }, - { - domain: 'www.pkgcloud.com', - protocol: 'http' - } - ], - origins: [ - { - origin: 'updated-origin.pkgcloud.com', - port: 80, - ssl: false, - rules: [] - } - ], - flavor_id: 'cdn' - }) - .reply(202, null, { Location: 'http://localhost:12345/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66' }); + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/cdnService.json') + .patch('/v1.0/72e90ecb69c44d0296072ea39e537041/services/d49cd860-911f-11e4-b4a9-0800200c9a66', [ + { + op: 'replace', + path: '/origins/0/origin', + value: 'updated-origin.pkgcloud.com' + } + ]) + .reply(202); }; setupDeleteServiceMock = function (client, servers) { From 7eecaed5cffe922bfdffc97d962b8b4b2fa866eb Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 10:50:07 -0800 Subject: [PATCH 323/460] Adding examples for CDN service using Rackspace client. --- examples/cdn/rackspace.js | 95 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 examples/cdn/rackspace.js diff --git a/examples/cdn/rackspace.js b/examples/cdn/rackspace.js new file mode 100644 index 000000000..7a441cb83 --- /dev/null +++ b/examples/cdn/rackspace.js @@ -0,0 +1,95 @@ +var fs = require('fs'), + pkgcloud = require('../../lib/pkgcloud'); + +var rackspace = pkgcloud.cdn.createClient({ + provider: 'rackspace', + username: 'rackspace_id', + apiKey: '1234567890poiiuytrrewq' +}); + +// Basic flavor and service operations. Please note that due to the asynchronous nature of Javascript programming, +// the code sample below will cause unexpected results if run as-a-whole and are meant for documentation +// and illustration purposes. + +// 1 -- to list all available CDN flavors +rackspace.getFlavors(function (err, flavors) { + if (err) { + console.dir(err); + return; + } + flavors.forEach(function (flavor) { + console.log(flavor.id); + }); +}); + +// 2 -- to create a service +rackspace.createService({ + name: 'sample-service-test', + domains: [ + { + domain: 'www.acme.com' + }, + { + domain: 'acme.com' + } + ], + origins: [ + { + origin: '12.34.56.78' + } + flavorId: 'cdn' +}, function (err, service) { + if (err) { + console.dir(err); + return; + } + + console.log(service.id); + console.log(service.name); + +}); + +// 2 -- to list our services +rackspace.getServices(function (err, services) { + if (err) { + console.dir(err); + return; + } + + services.forEach(function(service) { + console.log(service.id); + console.log(service.name); + }); + +}); + +// 3 -- to get our service and update it +rackspace.getService(function (err, service) { + if (err) { + console.dir(err); + return; + } + + service.origins[0].origin = '88.88.88.88'; + + rackspace.updateService(service, function (err, service) { + if (err) { + console.dir(err); + return; + } + + console.log(service.origins[0].origin); + + }); + +}); + +// 4 -- to delete our service +rackspace.deleteService('abcdef01-2345-6789-abcd-ef0123456789', function (err) { + if (err) { + console.dir(err); + return; + } + + console.log('Service deletion request was successful.'); +}); From a1076d5957819f8bf3a49de0f927ceb71e26bc60 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 10:53:15 -0800 Subject: [PATCH 324/460] Adding references in READMEs to CDN docs. --- docs/providers/openstack/README.md | 1 + docs/providers/rackspace/README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/providers/openstack/README.md b/docs/providers/openstack/README.md index 6b4521a7e..13d5629a3 100644 --- a/docs/providers/openstack/README.md +++ b/docs/providers/openstack/README.md @@ -8,6 +8,7 @@ The OpenStack provider in pkgcloud supports the following services: * [**Storage**](storage.md) (Swift) * [**Network**](network.md) (Neutron) * [**Orchestration**](orchestration.md) (Heat) +* [**CDN**](cdn.md) (Poppy) ### Getting Started with Compute diff --git a/docs/providers/rackspace/README.md b/docs/providers/rackspace/README.md index 82b0e44fd..432771682 100644 --- a/docs/providers/rackspace/README.md +++ b/docs/providers/rackspace/README.md @@ -10,6 +10,7 @@ The Rackspace provider in pkgcloud supports the following services: * [**Orchestration**](orchestration.md) (Cloud Orchestration) *(beta)* * [**Load Balancers**](loadbalancer.md) (Cloud Load Balancers) *(beta)* * [**Network**](network.md) (Cloud Networks) *(beta)* +* [**CDN**](cdn.md) (Rackspace CDN) *(beta)* ### Getting Started with Compute From 8d953bbb6a6db9fac253811d46319b5269014502 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 10:55:18 -0800 Subject: [PATCH 325/460] Happiness is a warm linter. --- examples/cdn/rackspace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cdn/rackspace.js b/examples/cdn/rackspace.js index 7a441cb83..771e97c17 100644 --- a/examples/cdn/rackspace.js +++ b/examples/cdn/rackspace.js @@ -1,5 +1,4 @@ -var fs = require('fs'), - pkgcloud = require('../../lib/pkgcloud'); +var pkgcloud = require('../../lib/pkgcloud'); var rackspace = pkgcloud.cdn.createClient({ provider: 'rackspace', @@ -37,6 +36,7 @@ rackspace.createService({ { origin: '12.34.56.78' } + ], flavorId: 'cdn' }, function (err, service) { if (err) { From 0892b66cc9a2760e9b44d87d88ab83dd39637df0 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 12:16:03 -0800 Subject: [PATCH 326/460] Always pass err to callback. --- lib/pkgcloud/openstack/cdn/client/base.js | 2 +- lib/pkgcloud/openstack/cdn/client/flavors.js | 4 ++-- lib/pkgcloud/openstack/cdn/client/services.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/base.js b/lib/pkgcloud/openstack/cdn/client/base.js index ce429c87b..03b9ae536 100644 --- a/lib/pkgcloud/openstack/cdn/client/base.js +++ b/lib/pkgcloud/openstack/cdn/client/base.js @@ -25,7 +25,7 @@ exports.getHomeDocument = function(callback) { return; } - callback(null, body); + callback(err, body); }); }; diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index a15e99394..b2a3cc704 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -37,7 +37,7 @@ exports.getFlavor = function (flavor, callback) { callback(new Error('Unexpected empty response')); } else { - callback(null, new cdn.Flavor(self, body)); + callback(err, new cdn.Flavor(self, body)); } }); }; @@ -69,7 +69,7 @@ exports.getFlavors = function getFlavors(options, callback) { return; } - callback(null, body.flavors.map(function(flavor) { + callback(err, body.flavors.map(function(flavor) { return new cdn.Flavor(self, flavor); })); }); diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 36f2d4077..e546686c6 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -88,7 +88,7 @@ exports.getServices = function getServices(options, callback) { return; } - callback(null, body.services.map(function(service) { + callback(err, body.services.map(function(service) { return new cdn.Service(self, service); })); }); @@ -210,7 +210,7 @@ exports.updateService = function (service, callback) { return callback(err); } - callback(null, service); + callback(err, service); }); }); }; @@ -305,7 +305,7 @@ _getService = function (self, service, callback) { callback(new Error('Unexpected empty response')); } else { - callback(null, new cdn.Service(self, body)); + callback(err, new cdn.Service(self, body)); } }); }; From 77580c1c82347e05aa234d96a4e0b345fabc2ddf Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 12:15:25 -0800 Subject: [PATCH 327/460] Simplifying callback calling idiom when there is only an error argument. --- lib/pkgcloud/openstack/cdn/client/base.js | 7 +------ lib/pkgcloud/openstack/cdn/client/services.js | 12 ++---------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/base.js b/lib/pkgcloud/openstack/cdn/client/base.js index 03b9ae536..79f589cbc 100644 --- a/lib/pkgcloud/openstack/cdn/client/base.js +++ b/lib/pkgcloud/openstack/cdn/client/base.js @@ -43,11 +43,6 @@ exports.getPing = function(callback) { }; return this._request(requestOptions, function (err) { - if (err) { - callback(err); - return; - } - - callback(); + return callback(err); }); }; diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index e546686c6..21f4d72e8 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -233,11 +233,7 @@ exports.deleteService = function (service, callback) { path: path, method: 'DELETE' }, function (err) { - if (err) { - return callback(err); - } - - callback(); + return callback(err); }); }; @@ -266,11 +262,7 @@ exports.deleteServiceCachedAssets = function (service, assetUrl, callback) { qs: assetUrl ? { url: assetUrl } : { all: true }, method: 'DELETE' }, function (err) { - if (err) { - return callback(err); - } - - callback(); + return callback(err); }); }; From 065c297b636ce6c292469c576bff020e998e8151 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 12:21:15 -0800 Subject: [PATCH 328/460] Moving _validateProperties to the bottom with other private helper functions. --- lib/pkgcloud/openstack/cdn/client/services.js | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 21f4d72e8..9eabbe4e6 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -16,34 +16,10 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), jsonpatch = require('fast-json-patch'); // Declaring variables for helper functions defined later -var _getService; +var _getService, _validateProperties; var _urlPrefix = '/services'; -/** - * validateProperties - * - * @description local helper function for validating arguments - * - * @param {Array} required The list of required properties - * @param {object} options The options object to validate - * @param {String} formatString String formatter for the error message - * @param {Function} callback - * @returns {boolean} - */ -function validateProperties(required, options, formatString, callback) { - return !required.some(function (item) { - if (typeof(options[item]) === 'undefined') { - errs.handle( - errs.create({ message: util.format(formatString, item) }), - callback - ); - return true; - } - return false; - }); -} - /** * client.getService * @@ -141,7 +117,7 @@ exports.createService = function (details, callback) { details = details || {}; - if (!validateProperties(['name', 'domains', 'origins', 'flavorId'], details, + if (!_validateProperties(['name', 'domains', 'origins', 'flavorId'], details, 'options.%s is a required argument.', callback)) { return; } @@ -301,3 +277,27 @@ _getService = function (self, service, callback) { } }); }; + +/** + * _validateProperties + * + * @description local helper function for validating arguments + * + * @param {Array} required The list of required properties + * @param {object} options The options object to validate + * @param {String} formatString String formatter for the error message + * @param {Function} callback + * @returns {boolean} + */ +_validateProperties = function (required, options, formatString, callback) { + return !required.some(function (item) { + if (typeof(options[item]) === 'undefined') { + errs.handle( + errs.create({ message: util.format(formatString, item) }), + callback + ); + return true; + } + return false; + }); +}; From 00da7b5125c6dba010eb110b6b93ad9ccaf47b70 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 12:24:09 -0800 Subject: [PATCH 329/460] Removing accidental change. --- .../openstack/orchestration/client/index.js | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js index f9ad624e5..770ba32e5 100644 --- a/lib/pkgcloud/openstack/orchestration/client/index.js +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -66,25 +66,3 @@ Client.prototype.buildInfo = function(callback) { callback(null, body); }); }; - -/** - * client._getUrl - * - * @description get the url for the current compute service - * - * @param options - * @returns {exports|*} - * @private - */ -Client.prototype._getUrl = function (options) { - options = options || {}; - - if (!this._serviceUrl) { - throw new Error('Service url not found'); - } - - return urlJoin(this._serviceUrl, - typeof options === 'string' - ? options - : options.path); -}; From 761f9082a70eb1f9c93d643868f8b38e6ec32c76 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 12:25:10 -0800 Subject: [PATCH 330/460] Sorting dependencies in alphabetical order. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d6845330b..b741d062b 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "aws-sdk": "~2.0.17", "errs": "0.3.x", "eventemitter2": "0.4.x", + "fast-json-patch": "0.5.x", "filed": "0.1.x", "gcloud": "^0.10.0", "ip": "0.3.x", @@ -65,8 +66,7 @@ "through2": "0.6.x", "underscore": "1.6.x", "url-join": "0.0.x", - "xml2js": "0.1.x", - "fast-json-patch": "0.5.x" + "xml2js": "0.1.x" }, "devDependencies": { "blanket": "^1.1.6", From de8d30caa90a29107eb20c6bd2053074ad0e600d Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 6 Jan 2015 14:20:11 -0800 Subject: [PATCH 331/460] Returning callback instead of nothing after callback. --- lib/pkgcloud/openstack/cdn/client/base.js | 3 +-- lib/pkgcloud/openstack/cdn/client/flavors.js | 3 +-- lib/pkgcloud/openstack/cdn/client/services.js | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/base.js b/lib/pkgcloud/openstack/cdn/client/base.js index 79f589cbc..fb8f9536e 100644 --- a/lib/pkgcloud/openstack/cdn/client/base.js +++ b/lib/pkgcloud/openstack/cdn/client/base.js @@ -21,8 +21,7 @@ exports.getHomeDocument = function(callback) { return this._request(requestOptions, function (err, body) { if (err) { - callback(err); - return; + return callback(err); } callback(err, body); diff --git a/lib/pkgcloud/openstack/cdn/client/flavors.js b/lib/pkgcloud/openstack/cdn/client/flavors.js index b2a3cc704..50f155c6f 100644 --- a/lib/pkgcloud/openstack/cdn/client/flavors.js +++ b/lib/pkgcloud/openstack/cdn/client/flavors.js @@ -65,8 +65,7 @@ exports.getFlavors = function getFlavors(options, callback) { return this._request(requestOptions, function (err, body) { if (err) { - callback(err); - return; + return callback(err); } callback(err, body.flavors.map(function(flavor) { diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 9eabbe4e6..2b58d1d3b 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -60,8 +60,7 @@ exports.getServices = function getServices(options, callback) { return this._request(requestOptions, function (err, body) { if (err) { - callback(err); - return; + return callback(err); } callback(err, body.services.map(function(service) { @@ -164,8 +163,7 @@ exports.updateService = function (service, callback) { var self = this; if (!(service instanceof cdn.Service)) { - callback(new Error('you must provide a service to update')); - return; + return callback(new Error('you must provide a service to update')); } // Get a pristine copy of service resource from the server From 57bae425e7d6202069fe501670e59ec3a209e155 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 6 Jan 2015 14:43:59 -0800 Subject: [PATCH 332/460] 1.2.0-alpha.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 600fa1926..4f5f60cc9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "author": "Nodejitsu Inc ", "contributors": [ { From 3fbfc222ad78f6c5a8c70c0bde3296c14ce008c7 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 7 Jan 2015 07:34:32 -0800 Subject: [PATCH 333/460] Changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 201d5cf88..8822b020a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.0 +* Added Support for Openstack CDN (Poppy) + ## v1.1.0 * Added support for Google Cloud Storage * Added support for Rackspace Cloud Networks From 0d5ff1ed92e55919f90dd18831ed042eaa42b7d9 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Wed, 7 Jan 2015 09:27:08 -0800 Subject: [PATCH 334/460] Minor readme cleanup for CDN --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 982b27e38..e12dee025 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ If a service does not have at least two providers, it is considered a *beta* int * [HP](docs/providers/hp/network.md) * [Openstack](docs/providers/openstack/network.md) * [Rackspace](docs/providers/rackspace/network.md) -* **[CDN](#cdn----beta)** +* **[CDN](#cdn----beta)** *(beta)* * [Openstack](docs/providers/openstack/cdn.md) * [Rackspace](docs/providers/rackspace/cdn.md) From 023e73ef12942b0007f70e351d9352d2a00b49c2 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 28 Jan 2015 15:04:29 +0000 Subject: [PATCH 335/460] Added unit tests for openstack copy functionality using the hp storage client. --- package.json | 2 +- test/fixtures/hp/getFile.json | 9 ++ test/hp/storage/file-test.js | 288 ++++++++++++++++++++++++++++++++++ 3 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/hp/getFile.json create mode 100644 test/hp/storage/file-test.js diff --git a/package.json b/package.json index 93c78c7d0..46b16b860 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "s3-upload-stream": "~1.0.0" }, "devDependencies": { - "hock": "1.0.x", + "hock": "1.2.0", "mocha": "1.21.x", "should": "4.0.x", "mocha-lcov-reporter": "0.0.1", diff --git a/test/fixtures/hp/getFile.json b/test/fixtures/hp/getFile.json new file mode 100644 index 000000000..c0c023088 --- /dev/null +++ b/test/fixtures/hp/getFile.json @@ -0,0 +1,9 @@ +[ + { + "hash": "cb5c530452af82fb875dc0fb1a00a2c4", + "last_modified": "2013-05-20T22:48:08.059180", + "bytes": 2027, + "name": "test-file", + "content_type": "application/octet-stream" + } +] \ No newline at end of file diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js new file mode 100644 index 000000000..bbafaefac --- /dev/null +++ b/test/hp/storage/file-test.js @@ -0,0 +1,288 @@ +var fs = require('fs'), + should = require('should'), + helpers = require('../../helpers'), + async = require('async'), + http = require('http'), + hock = require('hock'), + File = require('../../../lib/pkgcloud/core/storage/file').File, + mock = !!process.env.MOCK, + Buffer = require('buffer').Buffer, + _ = require("underscore"); + +var authenticate = function(hockInstance) { + hockInstance + .post('/v2.0/tokens', { + auth: { + 'apiAccessKeyCredentials': { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, { + "access": { + "token": { + "expires": "2016-12-26T18:25:46Z", + "id": "4bc7c5dabf3e4a49918683437d386b8a", + "tenant": { + "enabled": true, + "id": "5ACED3DC3AA740ABAA41711243CC6949", + "name": "MOCK-USERNAME", + "description": "MOCK-USERNAME" + } + }, + "serviceCatalog": [ + { + "endpoints": [ + { + "region": "region-a.geo-1", + "tenantId": "HPCloudFS_00aa00aa", + "publicURL": "http://localhost:12345/v1/HPCloudFS_00aa00aa", + "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/HPCloudFS_00aa00aa" + } + ], + "name": "swift", + "type": "object-store" + } + ], + "user": { + "username": "MOCK-USERNAME", + "roles_links": [], + "id": "bf3b85477d06430c8044d5b2e5e6dc5f", + "roles": [], + "name": "MOCK-USERNAME" + } + } + }); +} + +describe('pkgcloud/openstack/storage/', function () { + + describe('The openstack Storage client', function () { + + describe('copy', function() { + var client, hockInstance, authHockInstance, server, authServer; + + beforeEach(function(done) { + client = helpers.createClient('hp', 'storage'); + + hockInstance = hock.createHock(); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + afterEach(function (done) { + async.parallel([ + function(next) { + server.close(next); + }, function(next) { + authServer.close(next); + }], done); + }); + + it ('should copy within the same container', function(done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2' + }) + .reply(200); + + client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + if (err) done(err); + else { + file.copy({ + sourceContainer: "pkgcloud-test-container-1", + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: "pkgcloud-test-container-1", + destinationFile: 'pkgcloud-test-file-2' + }, done); + } + }); + }); + + it ('should copy within the same container with container objects', function(done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1') + .reply(200) + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2' + }) + .reply(200); + + async.waterfall([ + _.bind(client.getContainer, client, "pkgcloud-test-container-1"), + function(container, next) { + client.getFile(container, 'pkgcloud-test-file-1', function (err, file) { + if (err) done(err); + else { + file.copy({ + sourceContainer: container, + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: container, + destinationFile: 'pkgcloud-test-file-2' + }, next); + } + }) + } + ], done); + }); + + it ('should copy within the same container with headers', function(done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2', + 'x-delete-after': "1209600" + }) + .reply(200); + + client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + if (err) done(err); + else { + file.copy({ + sourceContainer: "pkgcloud-test-container-1", + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: "pkgcloud-test-container-1", + destinationFile: 'pkgcloud-test-file-2', + headers: { 'x-delete-after': 1209600 } + }, done); + } + }); + }); + + it ('should copy to a different container', function(done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-2/pkgcloud-test-file-2' + }) + .reply(200); + + client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + if (err) done(err); + else { + file.copy({ + sourceContainer: "pkgcloud-test-container-1", + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: "pkgcloud-test-container-2", + destinationFile: 'pkgcloud-test-file-2' + }, done); + } + }); + }); + + it ('should copy to a different container defaulting to original file name', function(done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-2/pkgcloud-test-file-1' + }) + .reply(200); + + client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + if (err) done(err); + else { + file.copy({ + sourceContainer: "pkgcloud-test-container-1", + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: "pkgcloud-test-container-2" + }, done); + } + }); + }); + + //testing all permutations of containers and source files as objects and strings + _.each([{ name: "container-1", object: true }, { name: "container-1", object: false }], function(srcContainer) { + _.each([{ name: "container-2", object: true }, { name: "container-2", object: false }], function(dstContainer) { + _.each([ { name: "file-1", object: true }, { name: "file-1", object: false }], function(srcFile) { + + var name = 'should copy from '; + name += srcContainer.object ? 'object src container ' : 'string src container '; + name += 'to '; + name += dstContainer.object ? 'object dst container ' : 'string dst container '; + name += 'with ' + name += srcFile.object ? 'object src file' : 'string src file'; + + it (name, function(done) { + authenticate(authHockInstance); + + async.series({ + sourceContainer: function(next) { + if (srcContainer.object) { + hockInstance + .head('/v1/HPCloudFS_00aa00aa/' + srcContainer.name) + .reply(200); + + client.getContainer(srcContainer.name, next); + } else { + next(null, srcContainer.name); + } + }, + + destinationContainer: function(next) { + if (dstContainer.object) { + hockInstance + .head('/v1/HPCloudFS_00aa00aa/' + dstContainer.name) + .reply(200); + + client.getContainer(dstContainer.name, next); + } else { + next(null, dstContainer.name); + } + } + }, function(err, res) { + if (err) done(err); + else { + hockInstance + .head('/v1/HPCloudFS_00aa00aa/' + srcContainer.name + '/' + srcFile.name + '?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/' + srcContainer.name + '/' + srcFile.name, {}, { + destination: '/' + dstContainer.name + '/' + srcFile.name + }) + .reply(200); + + client.getFile(srcContainer.name, srcFile.name, function (err, file) { + if (err) done(err); + else { + file.copy({ + sourceContainer: res.sourceContainer, + sourceFile: srcFile.object ? file : srcFile.name, + destinationContainer: res.destinationContainer + }, done); + } + }); + } + }); + }); + }); + + }); + }); + + }); + + }); +}); From 40182d99634e0a1d8c308b1c4071dab44fcc1966 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 28 Jan 2015 15:47:06 +0000 Subject: [PATCH 336/460] Replaced usages of double quotes to single quotes. Added missing semicolons. --- .../openstack/storage/client/files.js | 2 +- lib/pkgcloud/openstack/storage/file.js | 2 +- test/hp/storage/file-test.js | 82 +++++++++---------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index c0797de65..80ed1327a 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -418,5 +418,5 @@ exports.copy = function (options, callback) { ? callback(err) : callback(null, true); }); -} +}; diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index ca0e41bb0..c1ae98443 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -21,7 +21,7 @@ File.prototype.updateMetadata = function (callback) { }; File.prototype.copy = function (options, callback) { - this.client.copy(options, callback) + this.client.copy(options, callback); }; File.prototype._setProperties = function (details) { diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index bbafaefac..f130083ac 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -13,44 +13,44 @@ var authenticate = function(hockInstance) { hockInstance .post('/v2.0/tokens', { auth: { - 'apiAccessKeyCredentials': { + apiAccessKeyCredentials: { accessKey: 'MOCK-USERNAME', secretKey: 'MOCK-API-KEY' } } }) .reply(200, { - "access": { - "token": { - "expires": "2016-12-26T18:25:46Z", - "id": "4bc7c5dabf3e4a49918683437d386b8a", - "tenant": { - "enabled": true, - "id": "5ACED3DC3AA740ABAA41711243CC6949", - "name": "MOCK-USERNAME", - "description": "MOCK-USERNAME" + access: { + token: { + expires: '2016-12-26T18:25:46Z', + id: '4bc7c5dabf3e4a49918683437d386b8a', + tenant: { + enabled: true, + id: '5ACED3DC3AA740ABAA41711243CC6949', + name: 'MOCK-USERNAME', + description: 'MOCK-USERNAME' } }, - "serviceCatalog": [ + serviceCatalog: [ { - "endpoints": [ + endpoints: [ { - "region": "region-a.geo-1", - "tenantId": "HPCloudFS_00aa00aa", - "publicURL": "http://localhost:12345/v1/HPCloudFS_00aa00aa", - "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/HPCloudFS_00aa00aa" + region: 'region-a.geo-1', + tenantId: 'HPCloudFS_00aa00aa', + publicURL: 'http://localhost:12345/v1/HPCloudFS_00aa00aa', + internalURL: 'https://snet-storage101.ord1.clouddrive.com/v1/HPCloudFS_00aa00aa' } ], - "name": "swift", - "type": "object-store" + name: 'swift', + type: 'object-store' } ], - "user": { - "username": "MOCK-USERNAME", - "roles_links": [], - "id": "bf3b85477d06430c8044d5b2e5e6dc5f", - "roles": [], - "name": "MOCK-USERNAME" + user: { + username: 'MOCK-USERNAME', + roles_links: [], + id: 'bf3b85477d06430c8044d5b2e5e6dc5f', + roles: [], + name: 'MOCK-USERNAME' } } }); @@ -101,13 +101,13 @@ describe('pkgcloud/openstack/storage/', function () { }) .reply(200); - client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { if (err) done(err); else { file.copy({ - sourceContainer: "pkgcloud-test-container-1", + sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', - destinationContainer: "pkgcloud-test-container-1", + destinationContainer: 'pkgcloud-test-container-1', destinationFile: 'pkgcloud-test-file-2' }, done); } @@ -127,7 +127,7 @@ describe('pkgcloud/openstack/storage/', function () { .reply(200); async.waterfall([ - _.bind(client.getContainer, client, "pkgcloud-test-container-1"), + _.bind(client.getContainer, client, 'pkgcloud-test-container-1'), function(container, next) { client.getFile(container, 'pkgcloud-test-file-1', function (err, file) { if (err) done(err); @@ -151,17 +151,17 @@ describe('pkgcloud/openstack/storage/', function () { .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2', - 'x-delete-after': "1209600" + 'x-delete-after': '1209600' }) .reply(200); - client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { if (err) done(err); else { file.copy({ - sourceContainer: "pkgcloud-test-container-1", + sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', - destinationContainer: "pkgcloud-test-container-1", + destinationContainer: 'pkgcloud-test-container-1', destinationFile: 'pkgcloud-test-file-2', headers: { 'x-delete-after': 1209600 } }, done); @@ -179,13 +179,13 @@ describe('pkgcloud/openstack/storage/', function () { }) .reply(200); - client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { if (err) done(err); else { file.copy({ - sourceContainer: "pkgcloud-test-container-1", + sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', - destinationContainer: "pkgcloud-test-container-2", + destinationContainer: 'pkgcloud-test-container-2', destinationFile: 'pkgcloud-test-file-2' }, done); } @@ -202,22 +202,22 @@ describe('pkgcloud/openstack/storage/', function () { }) .reply(200); - client.getFile("pkgcloud-test-container-1", 'pkgcloud-test-file-1', function (err, file) { + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { if (err) done(err); else { file.copy({ - sourceContainer: "pkgcloud-test-container-1", + sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', - destinationContainer: "pkgcloud-test-container-2" + destinationContainer: 'pkgcloud-test-container-2' }, done); } }); }); //testing all permutations of containers and source files as objects and strings - _.each([{ name: "container-1", object: true }, { name: "container-1", object: false }], function(srcContainer) { - _.each([{ name: "container-2", object: true }, { name: "container-2", object: false }], function(dstContainer) { - _.each([ { name: "file-1", object: true }, { name: "file-1", object: false }], function(srcFile) { + _.each([{ name: 'container-1', object: true }, { name: 'container-1', object: false }], function(srcContainer) { + _.each([{ name: 'container-2', object: true }, { name: 'container-2', object: false }], function(dstContainer) { + _.each([ { name: 'file-1', object: true }, { name: 'file-1', object: false }], function(srcFile) { var name = 'should copy from '; name += srcContainer.object ? 'object src container ' : 'string src container '; From c2f273186c009c58877ddc3d809c4d75be70a8b0 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 28 Jan 2015 15:49:40 +0000 Subject: [PATCH 337/460] Made changes to adhere to coding conventions. --- test/hp/storage/file-test.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index f130083ac..e03967e09 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -54,7 +54,7 @@ var authenticate = function(hockInstance) { } } }); -} +}; describe('pkgcloud/openstack/storage/', function () { @@ -102,8 +102,9 @@ describe('pkgcloud/openstack/storage/', function () { .reply(200); client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) done(err); - else { + if (err) { + done(err); + } else { file.copy({ sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', @@ -139,7 +140,7 @@ describe('pkgcloud/openstack/storage/', function () { destinationFile: 'pkgcloud-test-file-2' }, next); } - }) + }); } ], done); }); @@ -156,8 +157,9 @@ describe('pkgcloud/openstack/storage/', function () { .reply(200); client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) done(err); - else { + if (err) { + done(err); + } else { file.copy({ sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', @@ -203,8 +205,9 @@ describe('pkgcloud/openstack/storage/', function () { .reply(200); client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) done(err); - else { + if (err) { + done(err); + } else { file.copy({ sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', @@ -254,8 +257,9 @@ describe('pkgcloud/openstack/storage/', function () { } } }, function(err, res) { - if (err) done(err); - else { + if (err) { + done(err); + } else { hockInstance .head('/v1/HPCloudFS_00aa00aa/' + srcContainer.name + '/' + srcFile.name + '?format=json') .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') @@ -265,8 +269,9 @@ describe('pkgcloud/openstack/storage/', function () { .reply(200); client.getFile(srcContainer.name, srcFile.name, function (err, file) { - if (err) done(err); - else { + if (err) { + done(err); + } else { file.copy({ sourceContainer: res.sourceContainer, sourceFile: srcFile.object ? file : srcFile.name, From ffc6ab4bbfddd2cfc822ba275fc2fe41535e7ea9 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 28 Jan 2015 16:38:10 +0000 Subject: [PATCH 338/460] Fixed lint failures. --- test/hp/storage/file-test.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index e03967e09..a7c3aeff4 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -1,13 +1,8 @@ -var fs = require('fs'), - should = require('should'), - helpers = require('../../helpers'), +var helpers = require('../../helpers'), async = require('async'), http = require('http'), hock = require('hock'), - File = require('../../../lib/pkgcloud/core/storage/file').File, - mock = !!process.env.MOCK, - Buffer = require('buffer').Buffer, - _ = require("underscore"); + _ = require('underscore'); var authenticate = function(hockInstance) { hockInstance @@ -131,8 +126,9 @@ describe('pkgcloud/openstack/storage/', function () { _.bind(client.getContainer, client, 'pkgcloud-test-container-1'), function(container, next) { client.getFile(container, 'pkgcloud-test-file-1', function (err, file) { - if (err) done(err); - else { + if (err) { + done(err); + } else { file.copy({ sourceContainer: container, sourceFile: 'pkgcloud-test-file-1', @@ -182,8 +178,9 @@ describe('pkgcloud/openstack/storage/', function () { .reply(200); client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) done(err); - else { + if (err) { + done(err); + } else { file.copy({ sourceContainer: 'pkgcloud-test-container-1', sourceFile: 'pkgcloud-test-file-1', @@ -226,7 +223,7 @@ describe('pkgcloud/openstack/storage/', function () { name += srcContainer.object ? 'object src container ' : 'string src container '; name += 'to '; name += dstContainer.object ? 'object dst container ' : 'string dst container '; - name += 'with ' + name += 'with '; name += srcFile.object ? 'object src file' : 'string src file'; it (name, function(done) { From be79ef91c876cc3f86bf9d53fa96320994630613 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Thu, 29 Jan 2015 15:59:23 +0000 Subject: [PATCH 339/460] The sub-directory name is now passed to name if it is a sub directory. --- lib/pkgcloud/openstack/storage/file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index 751a61c61..8acc72f29 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -43,7 +43,7 @@ File.prototype._setProperties = function (details) { this.metadata = {}; this.container = details.container || null; - this.name = details.name || null; + this.name = details.name || details.subdir || null; this.etag = details.etag || details.hash || null; this.contentType = details['content-type'] || details['content_type'] || null; From 5a1c67d7eda84c703149d9269615d4605e1f50c0 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Thu, 29 Jan 2015 16:08:47 +0000 Subject: [PATCH 340/460] Directories now have a content type of 'application/directory'. --- lib/pkgcloud/openstack/storage/file.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index 8acc72f29..5a871b3db 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -45,7 +45,12 @@ File.prototype._setProperties = function (details) { this.container = details.container || null; this.name = details.name || details.subdir || null; this.etag = details.etag || details.hash || null; - this.contentType = details['content-type'] || details['content_type'] || null; + + if (details.subdir) { + this.contentType = 'application/directory'; + } else { + this.contentType = details['content-type'] || details['content_type'] || null; + } this.lastModified = details['last-modified'] ? new Date(details['last-modified']) From 5154bd1b99ae5b8f10d36c454d3a178925fedc4c Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Fri, 6 Feb 2015 10:01:19 -0600 Subject: [PATCH 341/460] Adds missing commas RIP copy-pasters --- docs/providers/amazon.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/providers/amazon.md b/docs/providers/amazon.md index c19aed2ad..44168835a 100644 --- a/docs/providers/amazon.md +++ b/docs/providers/amazon.md @@ -13,7 +13,7 @@ For all of the Amazon services, you create a client with the same options: var client = require('pkgcloud').compute.createClient({ provider: 'amazon', key: 'your-secret-key-id', // secret key - keyId: 'your-access-key-id' // access key id + keyId: 'your-access-key-id', // access key id region: 'us-west-2' // region }); ``` @@ -22,7 +22,7 @@ var client = require('pkgcloud').compute.createClient({ var client = require('pkgcloud').storage.createClient({ provider: 'amazon', key: 'your-secret-key-id', // secret key - keyId: 'your-access-key-id' // access key id + keyId: 'your-access-key-id', // access key id region: 'us-west-2' // region }); -``` \ No newline at end of file +``` From 3e1c6ec2639f56414fc31fc08dd7502d30769741 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 9 Feb 2015 09:44:53 -0800 Subject: [PATCH 342/460] Removing unneeded underscore from some examples --- examples/dns/rackspace.js | 7 +++---- examples/storage/rackspace.js | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/dns/rackspace.js b/examples/dns/rackspace.js index 5d8c21366..7e66ab18b 100644 --- a/examples/dns/rackspace.js +++ b/examples/dns/rackspace.js @@ -1,5 +1,4 @@ -var pkgcloud = require('../../lib/pkgcloud'), - _ = require('underscore'); +var pkgcloud = require('../../lib/pkgcloud'); var client = pkgcloud.dns.createClient({ provider: 'rackspace', @@ -18,7 +17,7 @@ client.getZones(function (err, zones) { return; } - _.each(zones, function (zone) { + zones.forEach(function (zone) { console.log(zone.id + ' ' + zone.name); }); @@ -60,7 +59,7 @@ client.getZones({ name: 'example.org' }, function (err, zones) { return; } - _.each(records, function (record){ + records.forEach(function (record){ console.log(record.toJSON()); }); }); diff --git a/examples/storage/rackspace.js b/examples/storage/rackspace.js index a29e545c7..304b2e470 100644 --- a/examples/storage/rackspace.js +++ b/examples/storage/rackspace.js @@ -1,6 +1,5 @@ var fs = require('fs'), - pkgcloud = require('../../lib/pkgcloud'), - _ = require('underscore'); + pkgcloud = require('../../lib/pkgcloud'); var client = pkgcloud.storage.createClient({ provider: 'rackspace', @@ -37,7 +36,7 @@ client.getContainers(function (err, containers) { return; } - _.each(containers, function(container) { + containers.forEach(function(container) { console.log(container.name); }); From 552c7c963475eaf2075b006be9757489714e8353 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 10 Feb 2015 16:02:28 -0800 Subject: [PATCH 343/460] Add support for prepending a custom user agent - part of #394 - This only affects all clients the derive from core/base/client.js - This is probably 95% of all network traffic - There are some one-offs that need broader investigation on the correct strategy --- lib/pkgcloud/amazon/client.js | 2 +- lib/pkgcloud/core/base/client.js | 26 +++++++++++++++++++++++++- test/common/base/client-test.js | 7 +++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index 617283f5d..a7946d513 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -46,7 +46,7 @@ var Client = exports.Client = function (options) { }); } - this.userAgent = util.format('nodejs-pkgcloud/%s %s', pkgcloud.version, userAgent); + this.userAgent = util.format('%s %s', self.getUserAgent(), userAgent); // Setup a custom user agent for pkgcloud AWS.util.userAgent = function () { diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index 0241e449d..4828aace7 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -27,6 +27,30 @@ var Client = exports.Client = function (options) { util.inherits(Client, events.EventEmitter2); +/** + * Client.setCustomUserAgent + * + * @description allows the caller to specify a custom prefix for the HTTP UserAgent + * for all queries generated during the lifetime of the client. + * + * @param {String} userAgent the new userAgent to be prefixed + */ +Client.prototype.setCustomUserAgent = function (userAgent) { + this._customUserAgent = userAgent; +}; + +/** + * Client.getUserAgent + * + * @description gets the full UserAgent for the current client + * + * @returns {string} + */ +Client.prototype.getUserAgent = function() { + return util.format('%snodejs-pkgcloud/%s', this._customUserAgent ? + this._customUserAgent + ' ' : '', pkgcloud.version); +}; + /** * Client._request * @@ -103,7 +127,7 @@ Client.prototype._request = function (options, callback) { delete opts.signingUrl; // Set our User Agent - opts.headers['User-Agent'] = util.format('nodejs-pkgcloud/%s', pkgcloud.version); + opts.headers['User-Agent'] = self.getUserAgent(); // If we are missing callback if (!callback) { diff --git a/test/common/base/client-test.js b/test/common/base/client-test.js index 60a5d74d6..372c74bb7 100644 --- a/test/common/base/client-test.js +++ b/test/common/base/client-test.js @@ -6,6 +6,7 @@ */ var should = require('should'), + pkgcloud = require('../../../lib/pkgcloud'), Client = new require('../../../lib/pkgcloud/core/base/client').Client; describe('pkgcloud/core/base/client', function () { @@ -59,6 +60,12 @@ describe('pkgcloud/core/base/client', function () { }); }); + it('custom user agents should work', function () { + var cli = new Client(); + cli.setCustomUserAgent('my-app/1.2.3'); + cli.getUserAgent().should.equal('my-app/1.2.3 nodejs-pkgcloud/' + pkgcloud.version); + }); + it('the before filters throwing an error without a callback should return the error on the EE', function(done) { var cli = new Client(); From a17cdfe209545f54ad3c5038192ccba6744d3e13 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 10 Feb 2015 16:06:42 -0800 Subject: [PATCH 344/460] Fixing a linting error from the reworked user agent --- lib/pkgcloud/amazon/client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index a7946d513..2a1985d7a 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -7,7 +7,6 @@ var util = require('util'), AWS = require('aws-sdk'), - pkgcloud = require('../../../../pkgcloud'), base = require('../core/base'); var userAgent = AWS.util.userAgent(); From bba22b4934aeb69ec9708319a47524b905361940 Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 11 Feb 2015 10:39:45 +0000 Subject: [PATCH 345/460] Converted tabs to two spaces --- .../openstack/storage/client/files.js | 136 ++--- lib/pkgcloud/openstack/storage/file.js | 6 +- test/fixtures/hp/getFile.json | 14 +- test/hp/storage/file-test.js | 521 +++++++++--------- 4 files changed, 343 insertions(+), 334 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 80ed1327a..62dba897a 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -7,11 +7,11 @@ */ var filed = require('filed'), - mime = require('mime'), - base = require('../../../core/storage'), - through = require('through2'), - _ = require('underscore'), - urlJoin = require('url-join'); + mime = require('mime'), + base = require('../../../core/storage'), + through = require('through2'), + _ = require('underscore'), + urlJoin = require('url-join'); /** * client.removeFile @@ -24,13 +24,13 @@ var filed = require('filed'), */ exports.removeFile = function (container, file, callback) { var containerName = container instanceof this.models.Container ? container.name : container, - fileName = file instanceof this.models.File ? file.name : file; + fileName = file instanceof this.models.File ? file.name : file; this._request({ method: 'DELETE', container: containerName, path: fileName - }, function(err) { + }, function (err) { return err ? callback(err) : callback(null, true); @@ -47,12 +47,12 @@ exports.removeFile = function (container, file, callback) { * @param {array} files the files or fileNames to delete * @param callback */ -exports.bulkDelete = function(container, files, callback) { +exports.bulkDelete = function (container, files, callback) { var self = this, - containerName = container instanceof this.models.Container ? container.name : container; + containerName = container instanceof this.models.Container ? container.name : container; this._request({ method: 'DELETE', - body: files.map(function(file) { + body: files.map(function (file) { return urlJoin(containerName, (file instanceof self.models.File ? file.name : file)); }).join('\r\n'), headers: { @@ -61,7 +61,7 @@ exports.bulkDelete = function(container, files, callback) { qs: { 'bulk-delete': true } - }, function(err, results) { + }, function (err, results) { return err ? callback(err) : callback(null, results); @@ -95,15 +95,15 @@ exports.upload = function (options) { } var container = options.container, - writableStream, - proxyStream = through(), - uploadOptions = { - method: 'PUT', - upload: true, - container: container, - path: options.remote, - headers: options.headers || {} - }; + writableStream, + proxyStream = through(), + uploadOptions = { + method: 'PUT', + upload: true, + container: container, + path: options.remote, + headers: options.headers || {} + }; if (options.container instanceof this.models.Container) { uploadOptions.container = options.container.name; @@ -123,7 +123,7 @@ exports.upload = function (options) { writableStream = this._request(uploadOptions); - writableStream.on('complete', function(response) { + writableStream.on('complete', function (response) { var err = self._parseError(response); if (err) { @@ -175,19 +175,19 @@ exports.upload = function (options) { */ exports.download = function (options, callback) { var self = this, - container = options.container, - inputStream, - apiStream; + container = options.container, + inputStream, + apiStream; var success = !callback ? null : function (err, body, res) { return err ? callback(err) : callback(null, new self.models.File(self, _.extend(res.headers, { - container: options.container, - name: options.remote - }))); + container: options.container, + name: options.remote + }))); }; - + if (container instanceof self.models.Container) { container = container.name; } @@ -223,7 +223,7 @@ exports.download = function (options, callback) { */ exports.getFile = function (container, file, callback) { var containerName = container instanceof this.models.Container ? container.name : container, - self = this; + self = this; this._request({ method: 'HEAD', @@ -236,9 +236,9 @@ exports.getFile = function (container, file, callback) { return err ? callback(err) : callback(null, new self.models.File(self, _.extend(res.headers, { - container: container, - name: file - }))); + container: container, + name: file + }))); }); }; @@ -277,7 +277,7 @@ exports.getFiles = function (container, options, callback) { var remainingLimit = options.limit; delete options.limit; - var getFilesCallback = function(err, someFiles) { + var getFilesCallback = function (err, someFiles) { if (err) { return callback(err); } @@ -305,33 +305,33 @@ exports.getFiles = function (container, options, callback) { exports._getFiles = function (container, options, callback) { var containerName = container instanceof this.models.Container ? container.name : container, - self = this; + self = this; var getFilesOpts = { - path: containerName, - qs: _.extend({ - format: 'json' - }, _.pick(options, ['limit', 'marker', 'prefix', 'path', 'delimiter'])) - }; + path: containerName, + qs: _.extend({ + format: 'json' + }, _.pick(options, ['limit', 'marker', 'prefix', 'path', 'delimiter'])) + }; - if (options.endMarker) { - getFilesOpts.qs.end_marker = options.endMarker; - } + if (options.endMarker) { + getFilesOpts.qs.end_marker = options.endMarker; + } if (options.end_marker) { getFilesOpts.qs.end_marker = options.end_marker; } if (options.prefix) { - getFilesOpts.qs.prefix = options.prefix; + getFilesOpts.qs.prefix = options.prefix; } if (options.path) { - getFilesOpts.qs.path = options.path; + getFilesOpts.qs.path = options.path; } if (options.delimiter) { - getFilesOpts.qs.delimiter = options.delimiter; + getFilesOpts.qs.delimiter = options.delimiter; } this._request(getFilesOpts, function (err, body) { @@ -362,7 +362,7 @@ exports._getFiles = function (container, options, callback) { */ exports.updateFileMetadata = function (container, file, callback) { var self = this, - containerName = container instanceof self.models.Container ? container.name : container; + containerName = container instanceof self.models.Container ? container.name : container; if (!file instanceof base.File) { throw new Error('Must update an existing file instance'); @@ -396,27 +396,27 @@ exports.updateFileMetadata = function (container, file, callback) { * @param callback */ exports.copy = function (options, callback) { - var self = this, - containerName = options.sourceContainer instanceof self.models.Container ? options.sourceContainer.name : options.sourceContainer, - destContainerName = options.destinationContainer instanceof self.models.Container ? options.destinationContainer.name : options.destinationContainer, - destinationFile = options.destinationFile || options.sourceFile; - - var copyOptions = { - method: 'COPY', - uri: options.sourceFile instanceof self.models.File ? options.sourceFile.fullPath : this._getUrl({ - container: containerName, - path: options.sourceFile - }), - headers: _.extend(options.headers || {}, { - destination: urlJoin('/', destContainerName, - destinationFile instanceof self.models.File ? destinationFile.name : destinationFile) - }) - }; - - this._request(copyOptions, function (err) { - return err - ? callback(err) - : callback(null, true); - }); + var self = this, + containerName = options.sourceContainer instanceof self.models.Container ? options.sourceContainer.name : options.sourceContainer, + destContainerName = options.destinationContainer instanceof self.models.Container ? options.destinationContainer.name : options.destinationContainer, + destinationFile = options.destinationFile || options.sourceFile; + + var copyOptions = { + method: 'COPY', + uri: options.sourceFile instanceof self.models.File ? options.sourceFile.fullPath : this._getUrl({ + container: containerName, + path: options.sourceFile + }), + headers: _.extend(options.headers || {}, { + destination: urlJoin('/', destContainerName, + destinationFile instanceof self.models.File ? destinationFile.name : destinationFile) + }) + }; + + this._request(copyOptions, function (err) { + return err + ? callback(err) + : callback(null, true); + }); }; diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index c1ae98443..1b2639fa9 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -7,8 +7,8 @@ */ var util = require('util'), - _ = require('underscore'), - base = require('../../core/storage/file'); + _ = require('underscore'), + base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); @@ -21,7 +21,7 @@ File.prototype.updateMetadata = function (callback) { }; File.prototype.copy = function (options, callback) { - this.client.copy(options, callback); + this.client.copy(options, callback); }; File.prototype._setProperties = function (details) { diff --git a/test/fixtures/hp/getFile.json b/test/fixtures/hp/getFile.json index c0c023088..c57f0d478 100644 --- a/test/fixtures/hp/getFile.json +++ b/test/fixtures/hp/getFile.json @@ -1,9 +1,9 @@ [ - { - "hash": "cb5c530452af82fb875dc0fb1a00a2c4", - "last_modified": "2013-05-20T22:48:08.059180", - "bytes": 2027, - "name": "test-file", - "content_type": "application/octet-stream" - } + { + "hash": "cb5c530452af82fb875dc0fb1a00a2c4", + "last_modified": "2013-05-20T22:48:08.059180", + "bytes": 2027, + "name": "test-file", + "content_type": "application/octet-stream" + } ] \ No newline at end of file diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index a7c3aeff4..b33c8e463 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -1,290 +1,299 @@ var helpers = require('../../helpers'), - async = require('async'), - http = require('http'), - hock = require('hock'), - _ = require('underscore'); + async = require('async'), + http = require('http'), + hock = require('hock'), + _ = require('underscore'); -var authenticate = function(hockInstance) { - hockInstance - .post('/v2.0/tokens', { - auth: { - apiAccessKeyCredentials: { - accessKey: 'MOCK-USERNAME', - secretKey: 'MOCK-API-KEY' - } - } - }) - .reply(200, { - access: { - token: { - expires: '2016-12-26T18:25:46Z', - id: '4bc7c5dabf3e4a49918683437d386b8a', - tenant: { - enabled: true, - id: '5ACED3DC3AA740ABAA41711243CC6949', - name: 'MOCK-USERNAME', - description: 'MOCK-USERNAME' - } - }, - serviceCatalog: [ - { - endpoints: [ - { - region: 'region-a.geo-1', - tenantId: 'HPCloudFS_00aa00aa', - publicURL: 'http://localhost:12345/v1/HPCloudFS_00aa00aa', - internalURL: 'https://snet-storage101.ord1.clouddrive.com/v1/HPCloudFS_00aa00aa' - } - ], - name: 'swift', - type: 'object-store' - } - ], - user: { - username: 'MOCK-USERNAME', - roles_links: [], - id: 'bf3b85477d06430c8044d5b2e5e6dc5f', - roles: [], - name: 'MOCK-USERNAME' - } - } - }); +var authenticate = function (hockInstance) { + hockInstance + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, { + access: { + token: { + expires: '2016-12-26T18:25:46Z', + id: '4bc7c5dabf3e4a49918683437d386b8a', + tenant: { + enabled: true, + id: '5ACED3DC3AA740ABAA41711243CC6949', + name: 'MOCK-USERNAME', + description: 'MOCK-USERNAME' + } + }, + serviceCatalog: [ + { + endpoints: [ + { + region: 'region-a.geo-1', + tenantId: 'HPCloudFS_00aa00aa', + publicURL: 'http://localhost:12345/v1/HPCloudFS_00aa00aa', + internalURL: 'https://snet-storage101.ord1.clouddrive.com/v1/HPCloudFS_00aa00aa' + } + ], + name: 'swift', + type: 'object-store' + } + ], + user: { + username: 'MOCK-USERNAME', + roles_links: [], + id: 'bf3b85477d06430c8044d5b2e5e6dc5f', + roles: [], + name: 'MOCK-USERNAME' + } + } + }); }; describe('pkgcloud/openstack/storage/', function () { - describe('The openstack Storage client', function () { + describe('The openstack Storage client', function () { - describe('copy', function() { - var client, hockInstance, authHockInstance, server, authServer; + describe('copy', function () { + var client, hockInstance, authHockInstance, server, authServer; - beforeEach(function(done) { - client = helpers.createClient('hp', 'storage'); + beforeEach(function (done) { + client = helpers.createClient('hp', 'storage'); - hockInstance = hock.createHock(); - authHockInstance = hock.createHock(); + hockInstance = hock.createHock(); + authHockInstance = hock.createHock(); - server = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); - async.parallel([ - function (next) { - server.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); - afterEach(function (done) { - async.parallel([ - function(next) { - server.close(next); - }, function(next) { - authServer.close(next); - }], done); - }); + afterEach(function (done) { + async.parallel([ + function (next) { + server.close(next); + }, function (next) { + authServer.close(next); + }], done); + }); - it ('should copy within the same container', function(done) { - authenticate(authHockInstance); - hockInstance - .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') - .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') - .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { - destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2' - }) - .reply(200); + it('should copy within the same container', function (done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2' + }) + .reply(200); - client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) { - done(err); - } else { - file.copy({ - sourceContainer: 'pkgcloud-test-container-1', - sourceFile: 'pkgcloud-test-file-1', - destinationContainer: 'pkgcloud-test-container-1', - destinationFile: 'pkgcloud-test-file-2' - }, done); - } - }); - }); + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { + if (err) { + done(err); + } else { + file.copy({ + sourceContainer: 'pkgcloud-test-container-1', + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: 'pkgcloud-test-container-1', + destinationFile: 'pkgcloud-test-file-2' + }, done); + } + }); + }); - it ('should copy within the same container with container objects', function(done) { - authenticate(authHockInstance); - hockInstance - .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1') - .reply(200) - .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') - .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') - .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { - destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2' - }) - .reply(200); + it('should copy within the same container with container objects', function (done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1') + .reply(200) + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2' + }) + .reply(200); - async.waterfall([ - _.bind(client.getContainer, client, 'pkgcloud-test-container-1'), - function(container, next) { - client.getFile(container, 'pkgcloud-test-file-1', function (err, file) { - if (err) { - done(err); - } else { - file.copy({ - sourceContainer: container, - sourceFile: 'pkgcloud-test-file-1', - destinationContainer: container, - destinationFile: 'pkgcloud-test-file-2' - }, next); - } - }); - } - ], done); - }); + async.waterfall([ + _.bind(client.getContainer, client, 'pkgcloud-test-container-1'), + function (container, next) { + client.getFile(container, 'pkgcloud-test-file-1', function (err, file) { + if (err) { + done(err); + } else { + file.copy({ + sourceContainer: container, + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: container, + destinationFile: 'pkgcloud-test-file-2' + }, next); + } + }); + } + ], done); + }); - it ('should copy within the same container with headers', function(done) { - authenticate(authHockInstance); - hockInstance - .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') - .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') - .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { - destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2', - 'x-delete-after': '1209600' - }) - .reply(200); + it('should copy within the same container with headers', function (done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-1/pkgcloud-test-file-2', + 'x-delete-after': '1209600' + }) + .reply(200); - client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) { - done(err); - } else { - file.copy({ - sourceContainer: 'pkgcloud-test-container-1', - sourceFile: 'pkgcloud-test-file-1', - destinationContainer: 'pkgcloud-test-container-1', - destinationFile: 'pkgcloud-test-file-2', - headers: { 'x-delete-after': 1209600 } - }, done); - } - }); - }); + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { + if (err) { + done(err); + } else { + file.copy({ + sourceContainer: 'pkgcloud-test-container-1', + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: 'pkgcloud-test-container-1', + destinationFile: 'pkgcloud-test-file-2', + headers: { 'x-delete-after': 1209600 } + }, done); + } + }); + }); - it ('should copy to a different container', function(done) { - authenticate(authHockInstance); - hockInstance - .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') - .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') - .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { - destination: '/pkgcloud-test-container-2/pkgcloud-test-file-2' - }) - .reply(200); + it('should copy to a different container', function (done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-2/pkgcloud-test-file-2' + }) + .reply(200); - client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) { - done(err); - } else { - file.copy({ - sourceContainer: 'pkgcloud-test-container-1', - sourceFile: 'pkgcloud-test-file-1', - destinationContainer: 'pkgcloud-test-container-2', - destinationFile: 'pkgcloud-test-file-2' - }, done); - } - }); - }); + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { + if (err) { + done(err); + } else { + file.copy({ + sourceContainer: 'pkgcloud-test-container-1', + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: 'pkgcloud-test-container-2', + destinationFile: 'pkgcloud-test-file-2' + }, done); + } + }); + }); - it ('should copy to a different container defaulting to original file name', function(done) { - authenticate(authHockInstance); - hockInstance - .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') - .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') - .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { - destination: '/pkgcloud-test-container-2/pkgcloud-test-file-1' - }) - .reply(200); + it('should copy to a different container defaulting to original file name', function (done) { + authenticate(authHockInstance); + hockInstance + .head('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/pkgcloud-test-container-1/pkgcloud-test-file-1', {}, { + destination: '/pkgcloud-test-container-2/pkgcloud-test-file-1' + }) + .reply(200); - client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { - if (err) { - done(err); - } else { - file.copy({ - sourceContainer: 'pkgcloud-test-container-1', - sourceFile: 'pkgcloud-test-file-1', - destinationContainer: 'pkgcloud-test-container-2' - }, done); - } - }); - }); + client.getFile('pkgcloud-test-container-1', 'pkgcloud-test-file-1', function (err, file) { + if (err) { + done(err); + } else { + file.copy({ + sourceContainer: 'pkgcloud-test-container-1', + sourceFile: 'pkgcloud-test-file-1', + destinationContainer: 'pkgcloud-test-container-2' + }, done); + } + }); + }); - //testing all permutations of containers and source files as objects and strings - _.each([{ name: 'container-1', object: true }, { name: 'container-1', object: false }], function(srcContainer) { - _.each([{ name: 'container-2', object: true }, { name: 'container-2', object: false }], function(dstContainer) { - _.each([ { name: 'file-1', object: true }, { name: 'file-1', object: false }], function(srcFile) { + //testing all permutations of containers and source files as objects and strings + _.each([ + { name: 'container-1', object: true }, + { name: 'container-1', object: false } + ], function (srcContainer) { + _.each([ + { name: 'container-2', object: true }, + { name: 'container-2', object: false } + ], function (dstContainer) { + _.each([ + { name: 'file-1', object: true }, + { name: 'file-1', object: false } + ], function (srcFile) { - var name = 'should copy from '; - name += srcContainer.object ? 'object src container ' : 'string src container '; - name += 'to '; - name += dstContainer.object ? 'object dst container ' : 'string dst container '; - name += 'with '; - name += srcFile.object ? 'object src file' : 'string src file'; + var name = 'should copy from '; + name += srcContainer.object ? 'object src container ' : 'string src container '; + name += 'to '; + name += dstContainer.object ? 'object dst container ' : 'string dst container '; + name += 'with '; + name += srcFile.object ? 'object src file' : 'string src file'; - it (name, function(done) { - authenticate(authHockInstance); + it(name, function (done) { + authenticate(authHockInstance); - async.series({ - sourceContainer: function(next) { - if (srcContainer.object) { - hockInstance - .head('/v1/HPCloudFS_00aa00aa/' + srcContainer.name) - .reply(200); + async.series({ + sourceContainer: function (next) { + if (srcContainer.object) { + hockInstance + .head('/v1/HPCloudFS_00aa00aa/' + srcContainer.name) + .reply(200); - client.getContainer(srcContainer.name, next); - } else { - next(null, srcContainer.name); - } - }, + client.getContainer(srcContainer.name, next); + } else { + next(null, srcContainer.name); + } + }, - destinationContainer: function(next) { - if (dstContainer.object) { - hockInstance - .head('/v1/HPCloudFS_00aa00aa/' + dstContainer.name) - .reply(200); + destinationContainer: function (next) { + if (dstContainer.object) { + hockInstance + .head('/v1/HPCloudFS_00aa00aa/' + dstContainer.name) + .reply(200); - client.getContainer(dstContainer.name, next); - } else { - next(null, dstContainer.name); - } - } - }, function(err, res) { - if (err) { - done(err); - } else { - hockInstance - .head('/v1/HPCloudFS_00aa00aa/' + srcContainer.name + '/' + srcFile.name + '?format=json') - .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') - .copy('/v1/HPCloudFS_00aa00aa/' + srcContainer.name + '/' + srcFile.name, {}, { - destination: '/' + dstContainer.name + '/' + srcFile.name - }) - .reply(200); + client.getContainer(dstContainer.name, next); + } else { + next(null, dstContainer.name); + } + } + }, function (err, res) { + if (err) { + done(err); + } else { + hockInstance + .head('/v1/HPCloudFS_00aa00aa/' + srcContainer.name + '/' + srcFile.name + '?format=json') + .replyWithFile(200, __dirname + '/../../fixtures/hp/getFile.json') + .copy('/v1/HPCloudFS_00aa00aa/' + srcContainer.name + '/' + srcFile.name, {}, { + destination: '/' + dstContainer.name + '/' + srcFile.name + }) + .reply(200); - client.getFile(srcContainer.name, srcFile.name, function (err, file) { - if (err) { - done(err); - } else { - file.copy({ - sourceContainer: res.sourceContainer, - sourceFile: srcFile.object ? file : srcFile.name, - destinationContainer: res.destinationContainer - }, done); - } - }); - } - }); - }); - }); + client.getFile(srcContainer.name, srcFile.name, function (err, file) { + if (err) { + done(err); + } else { + file.copy({ + sourceContainer: res.sourceContainer, + sourceFile: srcFile.object ? file : srcFile.name, + destinationContainer: res.destinationContainer + }, done); + } + }); + } + }); + }); + }); - }); - }); + }); + }); - }); + }); - }); + }); }); From bce5408df46326079025c008ce78c51a4f50ae3e Mon Sep 17 00:00:00 2001 From: "peter.moffatt" Date: Wed, 11 Feb 2015 14:43:37 +0000 Subject: [PATCH 346/460] Removed changes to code unrelated to copy functionality --- .../openstack/storage/client/files.js | 92 +++++++++---------- lib/pkgcloud/openstack/storage/file.js | 4 +- test/hp/storage/file-test.js | 8 +- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 62dba897a..57c603b5d 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -7,11 +7,11 @@ */ var filed = require('filed'), - mime = require('mime'), - base = require('../../../core/storage'), - through = require('through2'), - _ = require('underscore'), - urlJoin = require('url-join'); + mime = require('mime'), + base = require('../../../core/storage'), + through = require('through2'), + _ = require('underscore'), + urlJoin = require('url-join'); /** * client.removeFile @@ -24,13 +24,13 @@ var filed = require('filed'), */ exports.removeFile = function (container, file, callback) { var containerName = container instanceof this.models.Container ? container.name : container, - fileName = file instanceof this.models.File ? file.name : file; + fileName = file instanceof this.models.File ? file.name : file; this._request({ method: 'DELETE', container: containerName, path: fileName - }, function (err) { + }, function(err) { return err ? callback(err) : callback(null, true); @@ -47,12 +47,12 @@ exports.removeFile = function (container, file, callback) { * @param {array} files the files or fileNames to delete * @param callback */ -exports.bulkDelete = function (container, files, callback) { +exports.bulkDelete = function(container, files, callback) { var self = this, - containerName = container instanceof this.models.Container ? container.name : container; + containerName = container instanceof this.models.Container ? container.name : container; this._request({ method: 'DELETE', - body: files.map(function (file) { + body: files.map(function(file) { return urlJoin(containerName, (file instanceof self.models.File ? file.name : file)); }).join('\r\n'), headers: { @@ -61,7 +61,7 @@ exports.bulkDelete = function (container, files, callback) { qs: { 'bulk-delete': true } - }, function (err, results) { + }, function(err, results) { return err ? callback(err) : callback(null, results); @@ -95,15 +95,15 @@ exports.upload = function (options) { } var container = options.container, - writableStream, - proxyStream = through(), - uploadOptions = { - method: 'PUT', - upload: true, - container: container, - path: options.remote, - headers: options.headers || {} - }; + writableStream, + proxyStream = through(), + uploadOptions = { + method: 'PUT', + upload: true, + container: container, + path: options.remote, + headers: options.headers || {} + }; if (options.container instanceof this.models.Container) { uploadOptions.container = options.container.name; @@ -123,7 +123,7 @@ exports.upload = function (options) { writableStream = this._request(uploadOptions); - writableStream.on('complete', function (response) { + writableStream.on('complete', function(response) { var err = self._parseError(response); if (err) { @@ -175,17 +175,17 @@ exports.upload = function (options) { */ exports.download = function (options, callback) { var self = this, - container = options.container, - inputStream, - apiStream; + container = options.container, + inputStream, + apiStream; var success = !callback ? null : function (err, body, res) { return err ? callback(err) : callback(null, new self.models.File(self, _.extend(res.headers, { - container: options.container, - name: options.remote - }))); + container: options.container, + name: options.remote + }))); }; if (container instanceof self.models.Container) { @@ -223,7 +223,7 @@ exports.download = function (options, callback) { */ exports.getFile = function (container, file, callback) { var containerName = container instanceof this.models.Container ? container.name : container, - self = this; + self = this; this._request({ method: 'HEAD', @@ -236,9 +236,9 @@ exports.getFile = function (container, file, callback) { return err ? callback(err) : callback(null, new self.models.File(self, _.extend(res.headers, { - container: container, - name: file - }))); + container: container, + name: file + }))); }); }; @@ -277,7 +277,7 @@ exports.getFiles = function (container, options, callback) { var remainingLimit = options.limit; delete options.limit; - var getFilesCallback = function (err, someFiles) { + var getFilesCallback = function(err, someFiles) { if (err) { return callback(err); } @@ -305,33 +305,33 @@ exports.getFiles = function (container, options, callback) { exports._getFiles = function (container, options, callback) { var containerName = container instanceof this.models.Container ? container.name : container, - self = this; + self = this; var getFilesOpts = { - path: containerName, - qs: _.extend({ - format: 'json' - }, _.pick(options, ['limit', 'marker', 'prefix', 'path', 'delimiter'])) - }; + path: containerName, + qs: _.extend({ + format: 'json' + }, _.pick(options, ['limit', 'marker', 'prefix', 'path', 'delimiter'])) + }; - if (options.endMarker) { - getFilesOpts.qs.end_marker = options.endMarker; - } + if (options.endMarker) { + getFilesOpts.qs.end_marker = options.endMarker; + } if (options.end_marker) { getFilesOpts.qs.end_marker = options.end_marker; } if (options.prefix) { - getFilesOpts.qs.prefix = options.prefix; + getFilesOpts.qs.prefix = options.prefix; } if (options.path) { - getFilesOpts.qs.path = options.path; + getFilesOpts.qs.path = options.path; } if (options.delimiter) { - getFilesOpts.qs.delimiter = options.delimiter; + getFilesOpts.qs.delimiter = options.delimiter; } this._request(getFilesOpts, function (err, body) { @@ -362,7 +362,7 @@ exports._getFiles = function (container, options, callback) { */ exports.updateFileMetadata = function (container, file, callback) { var self = this, - containerName = container instanceof self.models.Container ? container.name : container; + containerName = container instanceof self.models.Container ? container.name : container; if (!file instanceof base.File) { throw new Error('Must update an existing file instance'); @@ -409,7 +409,7 @@ exports.copy = function (options, callback) { }), headers: _.extend(options.headers || {}, { destination: urlJoin('/', destContainerName, - destinationFile instanceof self.models.File ? destinationFile.name : destinationFile) + destinationFile instanceof self.models.File ? destinationFile.name : destinationFile) }) }; diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index 1b2639fa9..f7a32e7db 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -7,8 +7,8 @@ */ var util = require('util'), - _ = require('underscore'), - base = require('../../core/storage/file'); + _ = require('underscore'), + base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index b33c8e463..b5d181ef5 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -1,8 +1,8 @@ var helpers = require('../../helpers'), - async = require('async'), - http = require('http'), - hock = require('hock'), - _ = require('underscore'); + async = require('async'), + http = require('http'), + hock = require('hock'), + _ = require('underscore'); var authenticate = function (hockInstance) { hockInstance From 0b1a52ed318792a891748a56c5287a72b8470f21 Mon Sep 17 00:00:00 2001 From: Phani Raj Date: Fri, 13 Feb 2015 10:41:41 -0800 Subject: [PATCH 347/460] Pass in strictSSL option to Openstack Identity authorize function Add strictSSL flag to getTeantID --- lib/pkgcloud/openstack/client.js | 3 +++ lib/pkgcloud/openstack/context/identity.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 193979933..9bd3da46c 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -80,6 +80,9 @@ Client.prototype._getIdentityOptions = function() { password: this.config.password }; + options.strictSSL = typeof this.config.strictSSL === 'boolean' + ? this.config.strictSSL : true; + if (this.config.tenantId) { options.tenantId = this.config.tenantId; } diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index f6333946b..c3abe200a 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -107,6 +107,7 @@ Identity.prototype.authorize = function (options, callback) { var authenticationOptions = { uri: urlJoin(options.url || self.options.url, self.basePath), method: 'POST', + strictSSL: options.strictSSL || self.options.strictSSL, headers: { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version), 'Content-Type': 'application/json', @@ -188,6 +189,7 @@ Identity.prototype.authorize = function (options, callback) { var tenantOptions = { uri: endpoint, json: true, + strictSSL: options.strictSSL || self.options.strictSSL, headers: { 'X-Auth-Token': token, 'Content-Type': 'application/json', @@ -269,7 +271,7 @@ Identity.prototype._parseIdentityResponse = function (data) { if (!data) { throw new Error('missing required arguments!'); } - + if (data.access.token) { self.token = data.access.token; self.token.expires = new Date(self.token.expires); From 283bda26afdeb9cddc96410c5ef118da84bd7e36 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 23 Feb 2015 14:51:06 -0800 Subject: [PATCH 348/460] Adding tests for custom user agent --- test/common/base/useragent-test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/common/base/useragent-test.js diff --git a/test/common/base/useragent-test.js b/test/common/base/useragent-test.js new file mode 100644 index 000000000..e9f161082 --- /dev/null +++ b/test/common/base/useragent-test.js @@ -0,0 +1,29 @@ +/* + * useragent-test.js: Tests for pkgcloud base client useragent + * + * (C) 2015 Ken Perkins, Rackspace Inc. + * + */ + +var should = require('should'), + pkgcloud = require('../../../lib/pkgcloud'), + Client = new require('../../../lib/pkgcloud/core/base/client').Client; + +describe('pkgcloud/core/base/client/useragent', function () { + describe('getUserAgent tests', function () { + it('should return the default useragent', function () { + var cli = new Client(); + + cli.getUserAgent().should.equal('nodejs-pkgcloud/' + pkgcloud.version); + }); + }); + + describe('setCustomUserAgent tests', function () { + it('should allow prefixing a custom useragent', function () { + var cli = new Client(); + + cli.setCustomUserAgent('my-app/1.2.3'); + cli.getUserAgent().should.equal('my-app/1.2.3 nodejs-pkgcloud/' + pkgcloud.version); + }); + }); +}); From 797ab2ef75c721526c377f37f2353e0f02978770 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 23 Feb 2015 14:55:02 -0800 Subject: [PATCH 349/460] Updating readme for user agent --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 948047a61..9596a1df1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,21 @@ Currently there are six service types which are handled by pkgcloud: In our [Roadmap](#roadmap), we plan to add support for more services, such as Queueing, Monitoring, and more. Additionally, we plan to implement more providers for the *beta* services, thus moving them out of *beta*. +### User Agent + +By default, all pkgcloud HTTP requests will have a user agent with the library and version: `nodejs-pkgcloud/x.y.z` where `x.y.z` is the current version. + +You can get this from a client at any time by calling `client.getUserAgent();`. Some providers may have an additional suffix as a function of the underlying HTTP stacks. + +You can also set a custom User Agent prefix: + +```javascript +client.setCustomUserAgent('my-app/1.2.3'); + +// returns "my-app/1.2.3 nodejs-pkgcloud/1.1.0" +client.getUserAgent(); +``` + ### Basic APIs for pkgcloud From dfc5faf75a4fb1a692b2c446097885dac2c007cf Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 23 Feb 2015 16:12:02 -0800 Subject: [PATCH 350/460] Fixing jshint errors --- test/common/base/useragent-test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/common/base/useragent-test.js b/test/common/base/useragent-test.js index e9f161082..b12fa243b 100644 --- a/test/common/base/useragent-test.js +++ b/test/common/base/useragent-test.js @@ -5,10 +5,11 @@ * */ -var should = require('should'), - pkgcloud = require('../../../lib/pkgcloud'), +var pkgcloud = require('../../../lib/pkgcloud'), Client = new require('../../../lib/pkgcloud/core/base/client').Client; +require('should'); + describe('pkgcloud/core/base/client/useragent', function () { describe('getUserAgent tests', function () { it('should return the default useragent', function () { From ea9f8d8556bf2048454cd535f3e3b2e7a93c6571 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 23 Feb 2015 20:04:45 -0800 Subject: [PATCH 351/460] Adding a more explicit inline example --- lib/pkgcloud/core/base/client.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index 4828aace7..0d6198f29 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -33,6 +33,10 @@ util.inherits(Client, events.EventEmitter2); * @description allows the caller to specify a custom prefix for the HTTP UserAgent * for all queries generated during the lifetime of the client. * + * Valid user agents should come in the form of app-name/version, for example: + * + * client.setCustomUserAgent("my-app/1.2.3"); + * * @param {String} userAgent the new userAgent to be prefixed */ Client.prototype.setCustomUserAgent = function (userAgent) { From cd05da42dfb2d9dc0178d523530d47aa94df2a88 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Tue, 24 Feb 2015 14:46:02 -0500 Subject: [PATCH 352/460] storage: google: upload: return metadata in success handler - fixes #400 --- lib/pkgcloud/google/storage/client/files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index 9a370ab68..28312fec9 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -51,7 +51,7 @@ exports.upload = function (options) { // we need a proxy stream so we can always return a file model // via the 'success' event - writableStream.on('complete', function(file) { + writableStream.on('complete', function() { proxyStream.emit('success', new storage.File(self, file)); }); From 10cf832ec625ee8bd0977b221a010fe983508271 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Tue, 24 Feb 2015 14:54:17 -0800 Subject: [PATCH 353/460] Adding a refresh method on the stack model - Fixes #398 --- lib/pkgcloud/openstack/orchestration/stack.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/pkgcloud/openstack/orchestration/stack.js b/lib/pkgcloud/openstack/orchestration/stack.js index 3d00cb0c1..0e792693b 100644 --- a/lib/pkgcloud/openstack/orchestration/stack.js +++ b/lib/pkgcloud/openstack/orchestration/stack.js @@ -17,6 +17,17 @@ var Stack = exports.Stack = function Stack(client, details) { util.inherits(Stack, base.Model); +Stack.prototype.refresh = function (callback) { + var self = this; + return self.client.getStack(this, function (err, stack) { + if (!err) { + self._setProperties(stack.original); + } + + return callback.apply(this, arguments); + }); +}; + Stack.prototype._setProperties = function (details) { this.id = details.id; this.name = details.name || details['stack_name']; @@ -33,6 +44,8 @@ Stack.prototype._setProperties = function (details) { this.createdAt = details['creation_time']; this.updatedAt = details['updated_time']; + + this.original = this.openstack = details; }; Stack.prototype.toJSON = function () { From eaabb515ec6a2b56610bfbe822ddf955ffa51341 Mon Sep 17 00:00:00 2001 From: jkorkalainen Date: Sat, 28 Feb 2015 09:41:34 +0200 Subject: [PATCH 354/460] Added template outputs field to stack --- lib/pkgcloud/openstack/orchestration/stack.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/openstack/orchestration/stack.js b/lib/pkgcloud/openstack/orchestration/stack.js index 0e792693b..1dd9cd87a 100644 --- a/lib/pkgcloud/openstack/orchestration/stack.js +++ b/lib/pkgcloud/openstack/orchestration/stack.js @@ -45,15 +45,12 @@ Stack.prototype._setProperties = function (details) { this.createdAt = details['creation_time']; this.updatedAt = details['updated_time']; + this.outputs = details['outputs']; + this.original = this.openstack = details; }; Stack.prototype.toJSON = function () { return _.pick(this, ['id', 'name', 'status', 'description', 'templateDescription', 'statusReason', 'owner', - 'disableRollback', 'parameters', 'capabilities', 'notificationTopics', 'timeout', 'updatedAt', 'createdAt' ]); + 'disableRollback', 'parameters', 'capabilities', 'notificationTopics', 'timeout', 'updatedAt', 'createdAt', 'outputs' ]); }; - - - - - From 54bfd12963d3259f4030dd89250300228221f01f Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 2 Mar 2015 09:22:11 -0800 Subject: [PATCH 355/460] Pinning jshint to 2.5.x to fix broken semver from jshint --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 446401e85..96fdaddcf 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "blanket": "^1.1.6", "coveralls": "^2.11.2", "hock": "1.2.0", - "jshint": "2.x.x", + "jshint": "2.5.x", "mocha": "1.21.x", "mocha-lcov-reporter": "0.0.1", "should": "4.0.x" From b724f8d43912f21cfa4cecafe5c6acbf99324d10 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 2 Mar 2015 09:55:06 -0800 Subject: [PATCH 356/460] Cleaning up formatting for .jshintrc --- .jshintrc | 164 +++++++++++++++++++++++++++--------------------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/.jshintrc b/.jshintrc index c233af9b6..f9524255a 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,88 +1,88 @@ { - "maxerr" : 50, // {int} Maximum error before stopping + "maxerr" : 50, // {int} Maximum error before stopping - // Enforcing - "bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : false, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : false, // true: Require triple equals (===) for comparison - "forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() - "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. - "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "indent" : false, // {int} Number of spaces to use for indentation - "latedef" : true, // true: Require variables/functions to be defined before being used - "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. - "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : "single", // Quotation mark consistency: - // false : do nothing (default) - // true : ensure whatever is used is consistent - // "single" : require single quotes - // "double" : require double quotes - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // true: Require all defined variables be used - "strict" : false, // true: Requires all functions run in ES5 Strict Mode - "maxparams" : false, // {int} Max number of formal params allowed per function - "maxdepth" : false, // {int} Max depth of nested blocks (within functions) - "maxstatements" : false, // {int} Max number statements per function - "maxcomplexity" : false, // {int} Max cyclomatic complexity per function - "maxlen" : false, // {int} Max number of characters per line + // Enforcing + "bitwise" : false, // true: Prohibit bitwise operators (&, |, ^, etc.) + "camelcase" : false, // true: Identifiers must be in camelCase + "curly" : true, // true: Require {} for every new block or scope + "eqeqeq" : false, // true: Require triple equals (===) for comparison + "forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() + "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. + "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` + "indent" : false, // {int} Number of spaces to use for indentation + "latedef" : true, // true: Require variables/functions to be defined before being used + "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` + "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` + "noempty" : true, // true: Prohibit use of empty blocks + "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. + "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) + "plusplus" : false, // true: Prohibit use of `++` & `--` + "quotmark" : "single", // Quotation mark consistency: + // false : do nothing (default) + // true : ensure whatever is used is consistent + // "single" : require single quotes + // "double" : require double quotes + "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) + "unused" : true, // true: Require all defined variables be used + "strict" : false, // true: Requires all functions run in ES5 Strict Mode + "maxparams" : false, // {int} Max number of formal params allowed per function + "maxdepth" : false, // {int} Max depth of nested blocks (within functions) + "maxstatements" : false, // {int} Max number statements per function + "maxcomplexity" : false, // {int} Max cyclomatic complexity per function + "maxlen" : false, // {int} Max number of characters per line - // Relaxing - "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : true, // true: Tolerate assignments where comparisons would be expected - "debug" : true, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : true, // true: Tolerate use of `== null` - "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) - "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) - "moz" : true, // true: Allow Mozilla specific syntax (extends and overrides esnext features) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : true, // true: Tolerate use of `eval` and `new Function()` - "expr" : true, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : true, // true: Tolerate defining variables inside control statements - "globalstrict" : true, // true: Allow global "use strict" (also enables 'strict') - "iterator" : true, // true: Tolerate using the `__iterator__` property - "lastsemic" : true, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : true, // true: Tolerate possibly unsafe line breakings - "laxcomma" : true, // true: Tolerate comma-first style coding - "loopfunc" : true, // true: Tolerate functions being defined in loops - "multistr" : true, // true: Tolerate multi-line strings - "noyield" : true, // true: Tolerate generator functions with no yield statement in them. - "notypeof" : true, // true: Tolerate invalid typeof operator values - "proto" : true, // true: Tolerate using the `__proto__` property - "scripturl" : true, // true: Tolerate script-targeted URLs - "shadow" : true, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : true, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : true, // true: Tolerate using this in a non-constructor function - "-W086" : true, // true: Allow fall-through; see https://github.com/jshint/jshint/issues/18 - "-W008" : true, // true: Allow leading decimal point; see https://jslinterrors.com/a-leading-decimal-point-can-be-confused-with-a-dot-a - "-W041" : true, // true: Ignore strict comparison checking; see https://github.com/jshint/jshint/blob/a643f3fec0632249dcd78d0cf5f200d9166b587d/src/messages.js#L115 - "-W082" : true, // true: Allow function declarations inside blocks; see https://jslinterrors.com/function-statements-should-not-be-placed-in-blocks + // Relaxing + "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) + "boss" : true, // true: Tolerate assignments where comparisons would be expected + "debug" : true, // true: Allow debugger statements e.g. browser breakpoints. + "eqnull" : true, // true: Tolerate use of `== null` + "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) + "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) + "moz" : true, // true: Allow Mozilla specific syntax (extends and overrides esnext features) + // (ex: `for each`, multiple try/catch, function expression…) + "evil" : true, // true: Tolerate use of `eval` and `new Function()` + "expr" : true, // true: Tolerate `ExpressionStatement` as Programs + "funcscope" : true, // true: Tolerate defining variables inside control statements + "globalstrict" : true, // true: Allow global "use strict" (also enables 'strict') + "iterator" : true, // true: Tolerate using the `__iterator__` property + "lastsemic" : true, // true: Tolerate omitting a semicolon for the last statement of a 1-line block + "laxbreak" : true, // true: Tolerate possibly unsafe line breakings + "laxcomma" : true, // true: Tolerate comma-first style coding + "loopfunc" : true, // true: Tolerate functions being defined in loops + "multistr" : true, // true: Tolerate multi-line strings + "noyield" : true, // true: Tolerate generator functions with no yield statement in them. + "notypeof" : true, // true: Tolerate invalid typeof operator values + "proto" : true, // true: Tolerate using the `__proto__` property + "scripturl" : true, // true: Tolerate script-targeted URLs + "shadow" : true, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` + "sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation + "supernew" : true, // true: Tolerate `new function () { ... };` and `new Object;` + "validthis" : true, // true: Tolerate using this in a non-constructor function + "-W086" : true, // true: Allow fall-through; see https://github.com/jshint/jshint/issues/18 + "-W008" : true, // true: Allow leading decimal point; see https://jslinterrors.com/a-leading-decimal-point-can-be-confused-with-a-dot-a + "-W041" : true, // true: Ignore strict comparison checking; see https://github.com/jshint/jshint/blob/a643f3fec0632249dcd78d0cf5f200d9166b587d/src/messages.js#L115 + "-W082" : true, // true: Allow function declarations inside blocks; see https://jslinterrors.com/function-statements-should-not-be-placed-in-blocks - // Environments - "browser" : false, // Web Browser (window, document, etc) - "browserify" : false, // Browserify (node.js code in the browser) - "couch" : false, // CouchDB - "devel" : false, // Development/debugging (alert, confirm, etc) - "dojo" : false, // Dojo Toolkit - "jasmine" : false, // Jasmine - "jquery" : false, // jQuery - "mocha" : true, // Mocha - "mootools" : false, // MooTools - "node" : true, // Node.js - "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) - "prototypejs" : false, // Prototype and Scriptaculous - "qunit" : false, // QUnit - "rhino" : false, // Rhino - "shelljs" : false, // ShellJS - "worker" : false, // Web Workers - "wsh" : false, // Windows Scripting Host - "yui" : false, // Yahoo User Interface + // Environments + "browser" : false, // Web Browser (window, document, etc) + "browserify" : false, // Browserify (node.js code in the browser) + "couch" : false, // CouchDB + "devel" : false, // Development/debugging (alert, confirm, etc) + "dojo" : false, // Dojo Toolkit + "jasmine" : false, // Jasmine + "jquery" : false, // jQuery + "mocha" : true, // Mocha + "mootools" : false, // MooTools + "node" : true, // Node.js + "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) + "prototypejs" : false, // Prototype and Scriptaculous + "qunit" : false, // QUnit + "rhino" : false, // Rhino + "shelljs" : false, // ShellJS + "worker" : false, // Web Workers + "wsh" : false, // Windows Scripting Host + "yui" : false, // Yahoo User Interface - // Custom Globals - "globals" : {} // additional predefined global variables + // Custom Globals + "globals" : {} // additional predefined global variables } From bd377a199d0150e12e91c8294ed60c3930be18e5 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 2 Mar 2015 09:56:24 -0800 Subject: [PATCH 357/460] Updating to current jshint - Opting out "context" from jshint predef warnings --- .jshintrc | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index f9524255a..77bab72f6 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,4 +1,5 @@ { + "predef" : ["-context"], "maxerr" : 50, // {int} Maximum error before stopping // Enforcing diff --git a/package.json b/package.json index 96fdaddcf..446401e85 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "blanket": "^1.1.6", "coveralls": "^2.11.2", "hock": "1.2.0", - "jshint": "2.5.x", + "jshint": "2.x.x", "mocha": "1.21.x", "mocha-lcov-reporter": "0.0.1", "should": "4.0.x" From 2e745bd88c0b543660f5d4290464f10abfd32638 Mon Sep 17 00:00:00 2001 From: jkorkalainen Date: Tue, 3 Mar 2015 10:02:09 +0200 Subject: [PATCH 358/460] Documented getStack request result --- docs/providers/openstack/orchestration.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index fc2a099d0..4a77f4ab2 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -45,6 +45,25 @@ Returns the stack in the callback `f(err, stack)` #### client.getStack(stack, callback) Retrieves the provided stack or stackId from the service. Callback has the signature `f(err, stack)`. +Result stack-object includes following fields +{ + id: , + name: , + status: , + description: , + templateDescription: , + statusReason: , + owner: , + disableRollback: , + parameters: , + capabilities: , + notificationTopics: , + timeout: , + createdAt: , + updatedAt: , + outputs: // Outputs field has value only if outputs are defined in template and the stack has been instantiated. +} + #### client.previewStack(details, callback) Identical to the `client.createStack()` call, except it only previews the creation, instead of actually provisioning the stack. @@ -127,4 +146,4 @@ Get all of the events for a stack and resource. ## Templates #### client.validateTemplate(template, callback) -Validates a provided template, with a callback of `f(err, template)`. \ No newline at end of file +Validates a provided template, with a callback of `f(err, template)`. From db75c34acb3acea8ac07cac1e85640e2ae84f052 Mon Sep 17 00:00:00 2001 From: jkorkalainen Date: Tue, 3 Mar 2015 10:09:04 +0200 Subject: [PATCH 359/460] formatting --- docs/providers/openstack/orchestration.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index 4a77f4ab2..58f4bb7c4 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -46,6 +46,7 @@ Returns the stack in the callback `f(err, stack)` Retrieves the provided stack or stackId from the service. Callback has the signature `f(err, stack)`. Result stack-object includes following fields +```js { id: , name: , @@ -63,6 +64,7 @@ Result stack-object includes following fields updatedAt: , outputs: // Outputs field has value only if outputs are defined in template and the stack has been instantiated. } +... #### client.previewStack(details, callback) Identical to the `client.createStack()` call, except it only previews the creation, instead of actually provisioning From 1f8b59a25382606ba7fff93b930df91a2a039cc7 Mon Sep 17 00:00:00 2001 From: jkorkalainen Date: Tue, 3 Mar 2015 10:09:43 +0200 Subject: [PATCH 360/460] formatting --- docs/providers/openstack/orchestration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index 58f4bb7c4..5e6b1e49d 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -64,7 +64,7 @@ Result stack-object includes following fields updatedAt: , outputs: // Outputs field has value only if outputs are defined in template and the stack has been instantiated. } -... +``` #### client.previewStack(details, callback) Identical to the `client.createStack()` call, except it only previews the creation, instead of actually provisioning From 01753821a023c62bebc0a6273f87355b2ef64f68 Mon Sep 17 00:00:00 2001 From: scaret Date: Fri, 6 Mar 2015 14:47:21 +0800 Subject: [PATCH 361/460] Fixed global singleton of AWS account --- lib/pkgcloud/amazon/client.js | 14 +++++++------- lib/pkgcloud/amazon/compute/client/index.js | 2 +- lib/pkgcloud/amazon/storage/client/index.js | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index 2a1985d7a..b0ff4f542 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -31,18 +31,18 @@ var Client = exports.Client = function (options) { this.config.key = this.config.key || options.accessKey; this.config.keyId = this.config.keyId || options.accessKeyId; - // Configure amazon client - AWS.config.update({ accessKeyId: this.config.keyId, secretAccessKey: this.config.key }); - AWS.config.update({ region: options.region }); + this._awsConfig = { + accessKeyId: this.config.keyId, + secretAccessKey: this.config.key, + region:options.region + }; // TODO think about a proxy option for pkgcloud // enable forwarding to mock test server if (options.serversUrl) { - AWS.config.update({ - httpOptions: { + this._awsConfig.httpOptions = { proxy: options.protocol ? options.protocol + options.serversUrl : 'https://' + options.serversUrl - } - }); + }; } this.userAgent = util.format('%s %s', self.getUserAgent(), userAgent); diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index 82e7d4702..1402f0159 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -21,7 +21,7 @@ var Client = exports.Client = function (options) { _.extend(this, require('./keys')); _.extend(this, require('./groups')); - this.ec2 = new AWS.EC2(); + this.ec2 = new AWS.EC2(this._awsConfig); }; util.inherits(Client, amazon.Client); diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index 162d7c594..0b506c997 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -17,11 +17,10 @@ var Client = exports.Client = function (options) { _.extend(this, require('./containers')); _.extend(this, require('./files')); - this.s3 = new AWS.S3(); + this.s3 = new AWS.S3(this._awsConfig); // configure the s3Stream - s3Stream.client(this.s3); - this.s3Stream = s3Stream; + this.s3Stream = s3Stream(this.s3); }; util.inherits(Client, amazon.Client); From 968322f969cd6bbe879c7f868cc816ff855670cb Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 6 Mar 2015 16:24:57 -0800 Subject: [PATCH 362/460] Adding support for nestedDepth option to getResources method. --- docs/providers/openstack/orchestration.md | 2 +- docs/providers/rackspace/orchestration.md | 2 +- .../orchestration/client/resources.js | 18 ++- .../orchestration/get-stack-resources-test.js | 130 ++++++++++++++++++ 4 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 test/openstack/orchestration/get-stack-resources-test.js diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index fc2a099d0..faba0dfd2 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -95,7 +95,7 @@ Get the template for a provided stack. Will callback with `f(err, template)`. Get the resource for a provided stack and resource or resourceName in the callback `f(err, resource)` -#### client.getResources(stack, callback) +#### client.getResources(stack, [options], callback) Get the resources for a provided stack. Callback is `f(err, resources)`. #### client.getResourceTypes(callback) diff --git a/docs/providers/rackspace/orchestration.md b/docs/providers/rackspace/orchestration.md index 7f53282d2..28122f5e0 100644 --- a/docs/providers/rackspace/orchestration.md +++ b/docs/providers/rackspace/orchestration.md @@ -95,7 +95,7 @@ Get the template for a provided stack. Will callback with `f(err, template)`. Get the resource for a provided stack and resource or resourceName in the callback `f(err, resource)` -#### client.getResources(stack, callback) +#### client.getResources(stack, [options], callback) Get the resources for a provided stack. Callback is `f(err, resources)`. #### client.getResourceTypes(callback) diff --git a/lib/pkgcloud/openstack/orchestration/client/resources.js b/lib/pkgcloud/openstack/orchestration/client/resources.js index a3641ca46..991401917 100644 --- a/lib/pkgcloud/openstack/orchestration/client/resources.js +++ b/lib/pkgcloud/openstack/orchestration/client/resources.js @@ -62,13 +62,25 @@ exports.getResource = function (stack, resource, callback) { * @param {function} callback f(err, resources) where stacks is an array of Resource * @returns {*} */ -exports.getResources = function (stack, callback) { +exports.getResources = function (stack, options, callback) { var self = this; + if (typeof options === 'function') { + callback = options; + options = {}; + } + function getResources(stack) { - return self._request({ + var requestOptions = { path: urlJoin('/stacks', stack.name, stack.id, 'resources') - }, function (err, body) { + }; + + requestOptions.qs = []; + if (options.nestedDepth) { + requestOptions.qs['nested_depth'] = options.nestedDepth; + } + + return self._request(requestOptions, function (err, body) { if (err) { return callback(err); } diff --git a/test/openstack/orchestration/get-stack-resources-test.js b/test/openstack/orchestration/get-stack-resources-test.js new file mode 100644 index 000000000..3ad8ce034 --- /dev/null +++ b/test/openstack/orchestration/get-stack-resources-test.js @@ -0,0 +1,130 @@ +/* + * get-stack-resources-test.js: Test Methods for OpenStack Heat stack resources + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var helpers = require('../../helpers'); + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK; + +var client = helpers.createClient('openstack', 'orchestration'); + +describe('pkgcloud/openstack/orchestration/resources[getResources]', function() { + + var authHockInstance, hockInstance, authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getResources method should return an empty array', function (done) { + if (mock) { + authHockInstance + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack') + .reply(302, {}, { Location: 'http://localhost:12345/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068' }) + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068') + .reply(200, { stack: { id: '87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068', stack_name: 'emptystack' }}) + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068/resources') + .reply(200, { resources: [] }); + } + + client.getResources('emptystack', function (err, resources) { + should.not.exist(err); + resources.should.be.an.Array; + resources.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + it('the getResources method with nested_depth should pass option correctly', function (done) { + if (mock) { + hockInstance + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack') + .reply(302, {}, { Location: 'http://localhost:12345/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068' }) + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068') + .reply(200, { stack: { id: '87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068', stack_name: 'emptystack' }}) + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf-a7xxxxx068/resources?nested_depth=3') + .reply(200, { resources: [] }); + } + + client.getResources('emptystack', { nestedDepth: 3 }, function (err, resources) { + console.log(err); + should.not.exist(err); + resources.should.be.an.Array; + resources.length.should.equal(0); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + +}); From ebb931f9b9f585e8aea3561dfe01ba920662801b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 6 Mar 2015 16:28:06 -0800 Subject: [PATCH 363/460] Adding explanation for available options. --- docs/providers/openstack/orchestration.md | 7 +++++++ docs/providers/rackspace/orchestration.md | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index faba0dfd2..7ec7729f0 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -98,6 +98,13 @@ resource)` #### client.getResources(stack, [options], callback) Get the resources for a provided stack. Callback is `f(err, resources)`. +Options are as follows: +```js +{ + nestedDepth: 3 // include resources from nested stacks up to nestedDepth levels of recursion +} +``` + #### client.getResourceTypes(callback) Get a list of valid resource types. Callback is `f(err, resourceTypes)`. diff --git a/docs/providers/rackspace/orchestration.md b/docs/providers/rackspace/orchestration.md index 28122f5e0..2b43f65f6 100644 --- a/docs/providers/rackspace/orchestration.md +++ b/docs/providers/rackspace/orchestration.md @@ -98,6 +98,13 @@ resource)` #### client.getResources(stack, [options], callback) Get the resources for a provided stack. Callback is `f(err, resources)`. +Options are as follows: +```js +{ + nestedDepth: 3 // include resources from nested stacks up to nestedDepth levels of recursion +} +``` + #### client.getResourceTypes(callback) Get a list of valid resource types. Callback is `f(err, resourceTypes)`. From 413e74533bffdd6cc90c5c87c23e97fe06f36c1d Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 6 Mar 2015 16:32:02 -0800 Subject: [PATCH 364/460] Initialzing requestOptions.qs while initializing requestOptions. --- lib/pkgcloud/openstack/orchestration/client/resources.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/orchestration/client/resources.js b/lib/pkgcloud/openstack/orchestration/client/resources.js index 991401917..300eabb89 100644 --- a/lib/pkgcloud/openstack/orchestration/client/resources.js +++ b/lib/pkgcloud/openstack/orchestration/client/resources.js @@ -72,10 +72,10 @@ exports.getResources = function (stack, options, callback) { function getResources(stack) { var requestOptions = { - path: urlJoin('/stacks', stack.name, stack.id, 'resources') + path: urlJoin('/stacks', stack.name, stack.id, 'resources'), + qs: [] }; - requestOptions.qs = []; if (options.nestedDepth) { requestOptions.qs['nested_depth'] = options.nestedDepth; } From 660f8f4de466639bec4dad6a7570b5da7e5c807b Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 9 Mar 2015 15:14:05 -0700 Subject: [PATCH 365/460] Adding unit tests and implementation for /security-groups APIs. --- lib/pkgcloud/core/network/securityGroup.js | 28 ++ lib/pkgcloud/hp/network/client/index.js | 4 +- lib/pkgcloud/hp/network/index.js | 1 + .../openstack/network/client/index.js | 4 +- .../network/client/securityGroups.js | 145 ++++++ lib/pkgcloud/openstack/network/index.js | 1 + .../openstack/network/securityGroup.js | 30 ++ .../rackspace/network/client/index.js | 4 +- lib/pkgcloud/rackspace/network/index.js | 1 + test/common/network/security-group-test.js | 434 ++++++++++++++++++ test/fixtures/openstack/securityGroup.json | 58 +++ test/fixtures/openstack/securityGroups.json | 60 +++ test/fixtures/rackspace/securityGroup.json | 34 ++ test/fixtures/rackspace/securityGroups.json | 36 ++ 14 files changed, 837 insertions(+), 3 deletions(-) create mode 100644 lib/pkgcloud/core/network/securityGroup.js create mode 100644 lib/pkgcloud/openstack/network/client/securityGroups.js create mode 100644 lib/pkgcloud/openstack/network/securityGroup.js create mode 100644 test/common/network/security-group-test.js create mode 100644 test/fixtures/openstack/securityGroup.json create mode 100644 test/fixtures/openstack/securityGroups.json create mode 100644 test/fixtures/rackspace/securityGroup.json create mode 100644 test/fixtures/rackspace/securityGroups.json diff --git a/lib/pkgcloud/core/network/securityGroup.js b/lib/pkgcloud/core/network/securityGroup.js new file mode 100644 index 000000000..16814c60a --- /dev/null +++ b/lib/pkgcloud/core/network/securityGroup.js @@ -0,0 +1,28 @@ +/* + * securityGroup.js: Base securityGroup from which all pkgcloud securityGroup inherit. + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var util = require('util'), + model = require('../base/model'); + +var SecurityGroup = exports.SecurityGroup = function (client, details) { + model.Model.call(this, client, details); +}; + +util.inherits(SecurityGroup, model.Model); + +SecurityGroup.prototype.create = function (callback) { + this.client.createSecurityGroup(this, callback); +}; + +SecurityGroup.prototype.refresh = function (callback) { + this.client.getSecurityGroup(this.id, callback); +}; + +SecurityGroup.prototype.destroy = function (callback) { + this.client.destroySecurityGroup(this.id, callback); +}; diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js index 0b2db1787..208a7eefa 100644 --- a/lib/pkgcloud/hp/network/client/index.js +++ b/lib/pkgcloud/hp/network/client/index.js @@ -17,12 +17,14 @@ var Client = exports.Client = function (options) { this.models = { Network: require('../../../openstack/network/network').Network, Subnet: require('../../../openstack/network/subnet').Subnet, - Port: require('../../../openstack/network/port').Port + Port: require('../../../openstack/network/port').Port, + SecurityGroup: require('../../../openstack/network/securityGroup').SecurityGroup }; _.extend(this, require('../../../openstack/network/client/networks')); _.extend(this, require('../../../openstack/network/client/subnets')); _.extend(this, require('../../../openstack/network/client/ports')); + _.extend(this, require('../../../openstack/network/client/securityGroups')); this.serviceType = 'network'; }; diff --git a/lib/pkgcloud/hp/network/index.js b/lib/pkgcloud/hp/network/index.js index 39de77514..fb749bc88 100644 --- a/lib/pkgcloud/hp/network/index.js +++ b/lib/pkgcloud/hp/network/index.js @@ -9,6 +9,7 @@ exports.Client = require('./client').Client; exports.Network = require('../../openstack/network/network').Network; exports.Subnet = require('../../openstack/network/subnet').Subnet; exports.Port = require('../../openstack/network/port').Port; +exports.SecurityGroup = require('../../openstack/network/securityGroup').SecurityGroup; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index 9aabbe98b..cb9cb3d01 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -17,12 +17,14 @@ var Client = exports.Client = function (options) { this.models = { Network: require('../network').Network, Subnet: require('../subnet').Subnet, - Port: require('../port').Port + Port: require('../port').Port, + SecurityGroup: require('../securityGroup').SecurityGroup }; _.extend(this, require('./networks')); _.extend(this, require('./subnets')); _.extend(this, require('./ports')); + _.extend(this, require('./securityGroups')); this.serviceType = 'network'; }; diff --git a/lib/pkgcloud/openstack/network/client/securityGroups.js b/lib/pkgcloud/openstack/network/client/securityGroups.js new file mode 100644 index 000000000..618cfd2d7 --- /dev/null +++ b/lib/pkgcloud/openstack/network/client/securityGroups.js @@ -0,0 +1,145 @@ +/* + * securityGroups.js: Instance methods for working with security groups + * for Openstack Networking + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var urlJoin = require('url-join'); + +var securityGroupsResourcePath = '/security-groups'; + +// Declaring variables for helper functions defined later +var _convertSecurityGroupToWireFormat; + +/** + * client.getSecurityGroups + * + * @description get the list of security groups for an account + * + * @param {object|Function} options + * @param {Function} callback + */ +exports.getSecurityGroups = function (options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var getSecurityGroupOpts = { + path: securityGroupsResourcePath + }; + + this._request(getSecurityGroupOpts, function (err, body) { + if (err) { + return callback(err); + } + else if (!body || !body.security_groups || !(body.security_groups instanceof Array)) { + return new Error('Malformed API Response'); + } + + return callback(null, body.security_groups.map(function (securityGroup) { + return new self.models.SecurityGroup(self, securityGroup); + })); + }); +}; + +/** + * client.getSecurityGroup + * + * @description get the details for a specific securityGroup + * + * @param {String|object} securityGroup the securityGroup or securityGroupId + * @param callback + */ +exports.getSecurityGroup = function (securityGroup, callback) { + var securityGroupId = securityGroup instanceof this.models.SecurityGroup ? securityGroup.id : securityGroup, + self = this; + self.emit('log::trace', 'Getting details for security group', securityGroupId); + this._request({ + path: urlJoin(securityGroupsResourcePath, securityGroupId), + method: 'GET' + }, function (err, body) { + if (err) { + return callback(err); + } + + if (!body ||!body.security_group) { + return new Error('Malformed API Response'); + } + + callback(null, new self.models.SecurityGroup(self, body.security_group)); + }); +}; + +/** + * client.createSecurityGroup + * + * @description create a new security group + * + * @param object securityGroup + * @param string securityGroup.name Name of security group. + * @param {string} securityGroup.description Description of security group. + * @param {string} securityGroup.tenantId The ID of the tenant who owns the security group. Only administrative users can specify a tenant ID other than their own. + * @param callback + */ +exports.createSecurityGroup = function (securityGroup, callback) { + var self = this; + + securityGroup = _convertSecurityGroupToWireFormat(securityGroup); + + var createSecurityGroupOpts = { + method: 'POST', + path: securityGroupsResourcePath, + body: { 'security_group' : securityGroup} + }; + + self.emit('log::trace', 'Creating security group', securityGroup); + this._request(createSecurityGroupOpts, function (err,body) { + return err + ? callback(err) + : callback(null, new self.models.SecurityGroup(self, body.securityGroup)); + }); +}; + +/** + * client.destroySecurityGroup + * + * @description Delete a specific securityGroup + * + * @param {String|object} securityGroup the securityGroup or securityGroup ID + * @param callback + */ +exports.destroySecurityGroup = function (securityGroup, callback) { + var securityGroupId = securityGroup instanceof this.models.SecurityGroup ? securityGroup.id : securityGroup, + self = this; + self.emit('log::trace', 'Deleting security group', securityGroupId); + this._request({ + path: urlJoin(securityGroupsResourcePath,securityGroupId), + method: 'DELETE' + }, function (err) { + if (err) { + return callback(err); + } + callback(null, securityGroupId); + }); +}; + +/** + * _convertSecurityGroupToWireFormat + * + * @description convert SecurityGroup instance into its wire representation. + * + * @param {object} details the SecurityGroup instance. + */ +_convertSecurityGroupToWireFormat = function (details){ + var wireFormat = {}; + wireFormat.name = details.name; + wireFormat.description = details.description; + wireFormat.tenant_id = details.tenant_id || details.tenantId; + return wireFormat; +}; diff --git a/lib/pkgcloud/openstack/network/index.js b/lib/pkgcloud/openstack/network/index.js index a4ab73aee..ee35a0cb7 100644 --- a/lib/pkgcloud/openstack/network/index.js +++ b/lib/pkgcloud/openstack/network/index.js @@ -9,6 +9,7 @@ exports.Client = require('./client').Client; exports.Network = require('./network').Network; exports.Subnet = require('./subnet').Subnet; exports.Port = require('./port').Port; +exports.SecurityGroup = require('./securityGroup').SecurityGroup; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/openstack/network/securityGroup.js b/lib/pkgcloud/openstack/network/securityGroup.js new file mode 100644 index 000000000..02533d25f --- /dev/null +++ b/lib/pkgcloud/openstack/network/securityGroup.js @@ -0,0 +1,30 @@ +/* + * network.js: Openstack Security Group object. + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var util = require('util'), + base = require('../../core/network/securityGroup'), + _ = require('underscore'); + +var SecurityGroup = exports.SecurityGroup = function SecurityGroup(client, details) { + base.SecurityGroup.call(this, client, details); +}; + +util.inherits(SecurityGroup, base.SecurityGroup); + +SecurityGroup.prototype._setProperties = function (details) { + + this.id = details.id || this.id; + this.name = details.name || this.name; + this.description = details.description || this.id; + this.tenantId = details.tenant_id || this.tenantId; + this.securityGroupRules = details.security_group_rules || this.securityGroupRules; +}; + +SecurityGroup.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'description', 'securityGroupRules', 'tenantId']); +}; diff --git a/lib/pkgcloud/rackspace/network/client/index.js b/lib/pkgcloud/rackspace/network/client/index.js index 24ea3ba10..a09b80385 100644 --- a/lib/pkgcloud/rackspace/network/client/index.js +++ b/lib/pkgcloud/rackspace/network/client/index.js @@ -17,12 +17,14 @@ var Client = exports.Client = function (options) { this.models = { Network: require('../../../openstack/network/network').Network, Subnet: require('../../../openstack/network/subnet').Subnet, - Port: require('../../../openstack/network/port').Port + Port: require('../../../openstack/network/port').Port, + SecurityGroup: require('../../../openstack/network/securityGroup').SecurityGroup }; _.extend(this, require('../../../openstack/network/client/networks')); _.extend(this, require('../../../openstack/network/client/subnets')); _.extend(this, require('../../../openstack/network/client/ports')); + _.extend(this, require('../../../openstack/network/client/securityGroups')); this.serviceType = 'network'; }; diff --git a/lib/pkgcloud/rackspace/network/index.js b/lib/pkgcloud/rackspace/network/index.js index 2a51364be..6b3d249f9 100644 --- a/lib/pkgcloud/rackspace/network/index.js +++ b/lib/pkgcloud/rackspace/network/index.js @@ -10,6 +10,7 @@ exports.Client = require('./client').Client; exports.Network = require('../../openstack/network/network').Network; exports.Subnet = require('../../openstack/network/subnet').Subnet; exports.Port = require('../../openstack/network/port').Port; +exports.SecurityGroup = require('../../openstack/network/securityGroup').SecurityGroup; exports.createClient = function(options) { return new exports.Client(options); diff --git a/test/common/network/security-group-test.js b/test/common/network/security-group-test.js new file mode 100644 index 000000000..b9584d399 --- /dev/null +++ b/test/common/network/security-group-test.js @@ -0,0 +1,434 @@ +/* + * security-group-test.js: Test for Networking (Neutron)'s security groups + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var helpers = require('../../helpers'); + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + providers = require('../../configs/providers.json'), + SecurityGroup = require('../../../lib/pkgcloud/core/network/securityGroup').SecurityGroup, + mock = !!process.env.MOCK, + urlJoin = require('url-join'); + +// Declaring variables for helper functions defined later +var setupSecurityGroupsMock, setupGetSecurityGroupMock, setupCreateSecurityGroupMock, + setupSecurityGroupModelCreateMock, setupRefreshSecurityGroupMock, + setupModelDestroyedSecurityGroupMock, setupDestroySecurityGroupMock; + +providers.filter(function(provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function(provider) { + + describe('pkgcloud/common/network/security-groups [' + provider + ']', function() { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getSecurityGroups() function should return a list of security groups', function(done) { + + if (mock) { + setupSecurityGroupsMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getSecurityGroups(function (err, securityGroups) { + should.not.exist(err); + should.exist(securityGroups); + + context.securityGroups = securityGroups; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getSecurityGroup() method should get a security group instance', function (done) { + + if (mock) { + setupGetSecurityGroupMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + },context.securityGroups[0]); + } + + client.getSecurityGroup(context.securityGroups[0].id, function (err, securityGroup) { + should.not.exist(err); + should.exist(securityGroup); + securityGroup.should.be.an.instanceOf(SecurityGroup); + securityGroup.should.have.property('id', context.securityGroups[0].id); + context.currentSecurityGroup = securityGroup; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createSecurityGroup() method should create a security group', function (done) { + if (mock) { + setupCreateSecurityGroupMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createSecurityGroup({ + name: 'create-test-ids2' + }, function (err, securityGroup) { + should.not.exist(err); + should.exist(securityGroup); + securityGroup.should.be.an.instanceOf(SecurityGroup); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroySecurityGroup() method should delete a security group', function (done) { + if (mock) { + setupDestroySecurityGroupMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSecurityGroup); + } + + client.destroySecurityGroup(context.currentSecurityGroup, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroySecurityGroup() method should take an id, delete a security group', function (done) { + if (mock) { + setupDestroySecurityGroupMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSecurityGroup); + } + + client.destroySecurityGroup(context.currentSecurityGroup.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the securityGroup.create() method should create a security group', function (done) { + if (mock) { + setupSecurityGroupModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var securityGroup = new SecurityGroup(client); + securityGroup.name= 'model created security group'; + securityGroup.create(function (err, createdSecurityGroup) { + should.not.exist(err); + should.exist(createdSecurityGroup); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the securityGroup.refresh() method should get a security group', function (done) { + var securityGroup = new SecurityGroup(client); + securityGroup.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; + + if (mock) { + setupRefreshSecurityGroupMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, securityGroup); + } + + securityGroup.refresh(function (err, refreshedSecurityGroup) { + should.not.exist(err); + should.exist(refreshedSecurityGroup); + refreshedSecurityGroup.should.have.property('name', 'default'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the securityGroup.destroy() method should delete a security group', function (done) { + var securityGroup = new SecurityGroup(client); + securityGroup.name = 'model deleted securityGroup'; + securityGroup.id = 'THISISASECURITYGROUPID'; + + if (mock) { + setupModelDestroyedSecurityGroupMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, securityGroup); + } + + securityGroup.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); + +setupSecurityGroupsMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-groups') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroups.json'); + } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-groups') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroups.json'); + } + else if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + + servers.server + .get('/v2.0/security-groups') + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/securityGroups.json'); + } +}; + +setupCreateSecurityGroupMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-groups', { + security_group: { + name: 'create-test-ids2' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-groups', { + security_group: { + name: 'create-test-ids2' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/security-groups', { + security_group: { + name: 'create-test-ids2' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/rackspace/securityGroup.json'); + } +}; + +setupRefreshSecurityGroupMock = function (client, provider, servers, securityGroup) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-groups', securityGroup.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-groups', securityGroup.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/security-groups', securityGroup.id)) + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/securityGroup.json'); + } +}; + +setupSecurityGroupModelCreateMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-groups', { + security_group: { + name: 'model created security group' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-groups', { + security_group: { + name: 'model created security group' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/security-groups', { + security_group: { + name: 'model created security group' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/rackspace/securityGroup.json'); + } +}; + +setupGetSecurityGroupMock = function (client, provider, servers, currentSecurityGroup) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-groups', currentSecurityGroup.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-groups', currentSecurityGroup.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroup.json'); + } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/security-groups', currentSecurityGroup.id)) + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/securityGroup.json'); + } +}; + +setupDestroySecurityGroupMock = function (client, provider, servers, currentSecurityGroup){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-groups', currentSecurityGroup.id)) + .reply(204); + } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-groups', currentSecurityGroup.id)) + .reply(204); + } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/security-groups', currentSecurityGroup.id)) + .reply(204); + } +}; + +setupModelDestroyedSecurityGroupMock = function (client, provider, servers, currentSecurityGroup){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-groups', currentSecurityGroup.id)) + .reply(204); + } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-groups', currentSecurityGroup.id)) + .reply(204); + } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/security-groups', currentSecurityGroup.id)) + .reply(204); + } +}; + diff --git a/test/fixtures/openstack/securityGroup.json b/test/fixtures/openstack/securityGroup.json new file mode 100644 index 000000000..126b5d20c --- /dev/null +++ b/test/fixtures/openstack/securityGroup.json @@ -0,0 +1,58 @@ +{ + "security_group": { + "description": "default", + "id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "name": "default", + "security_group_rules": [ + { + "direction": "egress", + "ethertype": "IPv6", + "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "egress", + "ethertype": "IPv4", + "id": "93aa42e5-80db-4581-9391-3a608bd0e448", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "ingress", + "ethertype": "IPv6", + "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "ingress", + "ethertype": "IPv4", + "id": "f7d45c89-008e-4bab-88ad-d6811724c51c", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + } + ], + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + } +} diff --git a/test/fixtures/openstack/securityGroups.json b/test/fixtures/openstack/securityGroups.json new file mode 100644 index 000000000..331792e60 --- /dev/null +++ b/test/fixtures/openstack/securityGroups.json @@ -0,0 +1,60 @@ +{ + "security_groups": [ + { + "description": "default", + "id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "name": "default", + "security_group_rules": [ + { + "direction": "egress", + "ethertype": "IPv6", + "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "egress", + "ethertype": "IPv4", + "id": "93aa42e5-80db-4581-9391-3a608bd0e448", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "ingress", + "ethertype": "IPv6", + "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "ingress", + "ethertype": "IPv4", + "id": "f7d45c89-008e-4bab-88ad-d6811724c51c", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + } + ], + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + } + ] +} diff --git a/test/fixtures/rackspace/securityGroup.json b/test/fixtures/rackspace/securityGroup.json new file mode 100644 index 000000000..51322361c --- /dev/null +++ b/test/fixtures/rackspace/securityGroup.json @@ -0,0 +1,34 @@ +{ + "security_group":{ + "description":"default", + "id":"85cc3048-abc3-43cc-89b3-377341426ac5", + "name":"default", + "security_group_rules":[ + { + "direction":"ingress", + "ethertype":"IPv6", + "id":"c0b09f00-1d49-4e64-a0a7-8a186d928138", + "port_range_max":22, + "port_range_min":22, + "protocol":"TCP", + "remote_group_id":null, + "remote_ip_prefix":null, + "security_group_id":"85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id":"5831008" + }, + { + "direction":"ingress", + "ethertype":"IPv4", + "id":"f7d45c89-008e-4bab-88ad-d6811724c51c", + "port_range_max":22, + "port_range_min":22, + "protocol":"TCP", + "remote_group_id":null, + "remote_ip_prefix":null, + "security_group_id":"85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id":"5831008" + } + ], + "tenant_id":"5831008" + } +} diff --git a/test/fixtures/rackspace/securityGroups.json b/test/fixtures/rackspace/securityGroups.json new file mode 100644 index 000000000..bdbb1da0c --- /dev/null +++ b/test/fixtures/rackspace/securityGroups.json @@ -0,0 +1,36 @@ +{ + "security_groups": [ + { + "description": "default", + "id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "name": "default", + "security_group_rules": [ + { + "direction": "ingress", + "ethertype": "IPv6", + "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138", + "port_range_max": 22, + "port_range_min": 22, + "protocol": "TCP", + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "5831008" + }, + { + "direction": "ingress", + "ethertype": "IPv4", + "id": "f7d45c89-008e-4bab-88ad-d6811724c51c", + "port_range_max": 22, + "port_range_min": 22, + "protocol": "TCP", + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "5831008" + } + ], + "tenant_id": "5831008" + } + ] +} From 7c1b152ea74a81ab3bc95afde7e7df2485bc3f9a Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 9 Mar 2015 16:20:38 -0700 Subject: [PATCH 366/460] Adding unit tests and implementation for /security-group-rules APIs. --- .../core/network/securityGroupRule.js | 28 ++ lib/pkgcloud/hp/network/client/index.js | 4 +- lib/pkgcloud/hp/network/index.js | 1 + .../openstack/network/client/index.js | 4 +- .../network/client/securityGroupRules.js | 156 +++++++ lib/pkgcloud/openstack/network/index.js | 1 + .../openstack/network/securityGroupRule.js | 36 ++ .../rackspace/network/client/index.js | 4 +- .../network/security-group-rule-test.js | 434 ++++++++++++++++++ .../fixtures/openstack/securityGroupRule.json | 14 + .../openstack/securityGroupRules.json | 52 +++ .../fixtures/rackspace/securityGroupRule.json | 14 + .../rackspace/securityGroupRules.json | 28 ++ 13 files changed, 773 insertions(+), 3 deletions(-) create mode 100644 lib/pkgcloud/core/network/securityGroupRule.js create mode 100644 lib/pkgcloud/openstack/network/client/securityGroupRules.js create mode 100644 lib/pkgcloud/openstack/network/securityGroupRule.js create mode 100644 test/common/network/security-group-rule-test.js create mode 100644 test/fixtures/openstack/securityGroupRule.json create mode 100644 test/fixtures/openstack/securityGroupRules.json create mode 100644 test/fixtures/rackspace/securityGroupRule.json create mode 100644 test/fixtures/rackspace/securityGroupRules.json diff --git a/lib/pkgcloud/core/network/securityGroupRule.js b/lib/pkgcloud/core/network/securityGroupRule.js new file mode 100644 index 000000000..4bce78a3c --- /dev/null +++ b/lib/pkgcloud/core/network/securityGroupRule.js @@ -0,0 +1,28 @@ +/* + * securityGroupRule.js: Base securityGroupRule from which all pkgcloud securityGroupRule inherit. + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var util = require('util'), + model = require('../base/model'); + +var SecurityGroupRule = exports.SecurityGroupRule = function (client, details) { + model.Model.call(this, client, details); +}; + +util.inherits(SecurityGroupRule, model.Model); + +SecurityGroupRule.prototype.create = function (callback) { + this.client.createSecurityGroupRule(this, callback); +}; + +SecurityGroupRule.prototype.refresh = function (callback) { + this.client.getSecurityGroupRule(this.id, callback); +}; + +SecurityGroupRule.prototype.destroy = function (callback) { + this.client.destroySecurityGroupRule(this.id, callback); +}; diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js index 208a7eefa..5c87155b0 100644 --- a/lib/pkgcloud/hp/network/client/index.js +++ b/lib/pkgcloud/hp/network/client/index.js @@ -18,13 +18,15 @@ var Client = exports.Client = function (options) { Network: require('../../../openstack/network/network').Network, Subnet: require('../../../openstack/network/subnet').Subnet, Port: require('../../../openstack/network/port').Port, - SecurityGroup: require('../../../openstack/network/securityGroup').SecurityGroup + SecurityGroup: require('../../../openstack/network/securityGroup').SecurityGroup, + SecurityGroupRule: require('../../../openstack/network/securityGroupRule').SecurityGroupRule }; _.extend(this, require('../../../openstack/network/client/networks')); _.extend(this, require('../../../openstack/network/client/subnets')); _.extend(this, require('../../../openstack/network/client/ports')); _.extend(this, require('../../../openstack/network/client/securityGroups')); + _.extend(this, require('../../../openstack/network/client/securityGroupRules')); this.serviceType = 'network'; }; diff --git a/lib/pkgcloud/hp/network/index.js b/lib/pkgcloud/hp/network/index.js index fb749bc88..b11932fee 100644 --- a/lib/pkgcloud/hp/network/index.js +++ b/lib/pkgcloud/hp/network/index.js @@ -10,6 +10,7 @@ exports.Network = require('../../openstack/network/network').Network; exports.Subnet = require('../../openstack/network/subnet').Subnet; exports.Port = require('../../openstack/network/port').Port; exports.SecurityGroup = require('../../openstack/network/securityGroup').SecurityGroup; +exports.SecurityGroupRule = require('../../openstack/network/securityGroupRule').SecurityGroupRule; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index cb9cb3d01..8b0915940 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -18,13 +18,15 @@ var Client = exports.Client = function (options) { Network: require('../network').Network, Subnet: require('../subnet').Subnet, Port: require('../port').Port, - SecurityGroup: require('../securityGroup').SecurityGroup + SecurityGroup: require('../securityGroup').SecurityGroup, + SecurityGroupRule: require('../securityGroupRule').SecurityGroupRule }; _.extend(this, require('./networks')); _.extend(this, require('./subnets')); _.extend(this, require('./ports')); _.extend(this, require('./securityGroups')); + _.extend(this, require('./securityGroupRules')); this.serviceType = 'network'; }; diff --git a/lib/pkgcloud/openstack/network/client/securityGroupRules.js b/lib/pkgcloud/openstack/network/client/securityGroupRules.js new file mode 100644 index 000000000..75d9d95ce --- /dev/null +++ b/lib/pkgcloud/openstack/network/client/securityGroupRules.js @@ -0,0 +1,156 @@ +/* + * securityGroupRules.js: Instance methods for working with security group rules + * for Openstack Networking + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var urlJoin = require('url-join'); + +var securityGroupRulesResourcePath = '/security-group-rules'; + +// Declaring variables for helper functions defined later +var _convertSecurityGroupRuleToWireFormat; + +/** + * client.getSecurityGroupRules + * + * @description get the list of security group rules for an account + * + * @param {object|Function} options + * @param {Function} callback + */ +exports.getSecurityGroupRules = function (options, callback) { + var self = this; + + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var getSecurityGroupRuleOpts = { + path: securityGroupRulesResourcePath + }; + + this._request(getSecurityGroupRuleOpts, function (err, body) { + if (err) { + return callback(err); + } + else if (!body || !body.security_group_rules || !(body.security_group_rules instanceof Array)) { + return new Error('Malformed API Response'); + } + + return callback(null, body.security_group_rules.map(function (securityGroupRule) { + return new self.models.SecurityGroupRule(self, securityGroupRule); + })); + }); +}; + +/** + * client.getSecurityGroupRule + * + * @description get the details for a specific securityGroupRule + * + * @param {String|object} securityGroupRule the securityGroupRule or securityGroupRuleId + * @param callback + */ +exports.getSecurityGroupRule = function (securityGroupRule, callback) { + var securityGroupRuleId = securityGroupRule instanceof this.models.SecurityGroupRule ? securityGroupRule.id : securityGroupRule, + self = this; + self.emit('log::trace', 'Getting details for security group rule', securityGroupRuleId); + this._request({ + path: urlJoin(securityGroupRulesResourcePath, securityGroupRuleId), + method: 'GET' + }, function (err, body) { + if (err) { + return callback(err); + } + + if (!body ||!body.security_group_rule) { + return new Error('Malformed API Response'); + } + + callback(null, new self.models.SecurityGroupRule(self, body.security_group_rule)); + }); +}; + +/** + * client.createSecurityGroupRule + * + * @description create a new securityGroupRule + * + * @param object securityGroupRule + * @param string securityGroupRule.securityGroupId The security group ID to associate with this security group rule. + * @param string securityGroupRule.direction The direction ("ingress" or "egress") in which the security group rule is applied. + * @param {string} securityGroupRule.ethertype "IPv4" or "IPv6". + * @param {int} securityGroupRule.portRangeMin The minimum port number in the range that is matched by the security group rule. + * @param {int} securityGroupRule.portRangeMax The maximum port number in the range that is matched by the security group rule. + * @param {string} securityGroupRule.protocol The protocol ("tcp", "udp", or "icmp") that is matched by the security group rule. + * @param {string} securityGroupRule.remoteGroupId The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix. + * @param {string} securityGroupRule.remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId. + * + * @param callback + */ +exports.createSecurityGroupRule = function (securityGroupRule, callback) { + var self = this; + + securityGroupRule = _convertSecurityGroupRuleToWireFormat(securityGroupRule); + + var createSecurityGroupRuleOpts = { + method: 'POST', + path: securityGroupRulesResourcePath, + body: { 'security_group_rule' : securityGroupRule} + }; + + self.emit('log::trace', 'Creating security group rule', securityGroupRule); + this._request(createSecurityGroupRuleOpts, function (err,body) { + return err + ? callback(err) + : callback(null, new self.models.SecurityGroupRule(self, body.securityGroupRule)); + }); +}; + +/** + * client.destroySecurityGroupRule + * + * @description Delete a specific securityGroupRule + * + * @param {String|object} securityGroupRule the securityGroupRule or securityGroupRule ID + * @param callback + */ +exports.destroySecurityGroupRule = function (securityGroupRule, callback) { + var securityGroupRuleId = securityGroupRule instanceof this.models.SecurityGroupRule ? securityGroupRule.id : securityGroupRule, + self = this; + self.emit('log::trace', 'Deleting security group rule', securityGroupRuleId); + this._request({ + path: urlJoin(securityGroupRulesResourcePath,securityGroupRuleId), + method: 'DELETE' + }, function (err) { + if (err) { + return callback(err); + } + callback(null, securityGroupRuleId); + }); +}; + +/** + * _convertSecurityGroupRuleToWireFormat + * + * @description convert SecurityGroupRule instance into its wire representation. + * + * @param {object} details the SecurityGroupRule instance. + */ +_convertSecurityGroupRuleToWireFormat = function (details){ + var wireFormat = {}; + wireFormat.direction = details.direction; + wireFormat.ethertype = details.ethertype; + wireFormat.security_group_id = details.security_group_id || details.securityGroupId; + wireFormat.port_range_min = details.port_range_min || details.portRangeMin; + wireFormat.port_range_max = details.port_range_max || details.portRangeMax; + wireFormat.protocol = details.protocol; + wireFormat.remote_group_id = details.remote_group_id || details.remoteGroupId; + wireFormat.remote_ip_prefix = details.remote_ip_prefix || details.remoteIpPrefix; + return wireFormat; +}; diff --git a/lib/pkgcloud/openstack/network/index.js b/lib/pkgcloud/openstack/network/index.js index ee35a0cb7..4199b7447 100644 --- a/lib/pkgcloud/openstack/network/index.js +++ b/lib/pkgcloud/openstack/network/index.js @@ -10,6 +10,7 @@ exports.Network = require('./network').Network; exports.Subnet = require('./subnet').Subnet; exports.Port = require('./port').Port; exports.SecurityGroup = require('./securityGroup').SecurityGroup; +exports.SecurityGroupRule = require('./securityGroup').SecurityGroupRule; exports.createClient = function (options) { return new exports.Client(options); diff --git a/lib/pkgcloud/openstack/network/securityGroupRule.js b/lib/pkgcloud/openstack/network/securityGroupRule.js new file mode 100644 index 000000000..60dfcaf72 --- /dev/null +++ b/lib/pkgcloud/openstack/network/securityGroupRule.js @@ -0,0 +1,36 @@ +/* + * network.js: Openstack Security Group Rule object. + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var util = require('util'), + base = require('../../core/network/securityGroupRule'), + _ = require('underscore'); + +var SecurityGroupRule = exports.SecurityGroupRule = function SecurityGroupRule(client, details) { + base.SecurityGroupRule.call(this, client, details); +}; + +util.inherits(SecurityGroupRule, base.SecurityGroupRule); + +SecurityGroupRule.prototype._setProperties = function (details) { + this.id = details.id || this.id; + this.direction = details.direction || this.direction; + this.ethertype = details.ethertype || this.id; + this.securityGroupId = details.security_group_id || this.securityGroupId; + this.portRangeMin = details.port_range_min || this.portRangeMin; + this.portRangeMax = details.port_range_max || this.portRangeMax; + this.protocol = details.protocol || this.protocol; + this.remoteGroupId = details.remote_group_id || this.remoteGroupId; + this.remoteIpPrefix = details.remote_ip_prefix || this.remoteIpPrefix; + this.tenantId = details.tenant_id || this.tenantId; +}; + +SecurityGroupRule.prototype.toJSON = function () { + return _.pick(this, ['id', 'direction', 'ethertype', 'securityGroupId', + 'portRangeMin', 'portRangeMax', 'protocol', + 'remoteGroupId', 'remoteIpPrefix', 'tenantId']); +}; diff --git a/lib/pkgcloud/rackspace/network/client/index.js b/lib/pkgcloud/rackspace/network/client/index.js index a09b80385..1a5e44756 100644 --- a/lib/pkgcloud/rackspace/network/client/index.js +++ b/lib/pkgcloud/rackspace/network/client/index.js @@ -18,13 +18,15 @@ var Client = exports.Client = function (options) { Network: require('../../../openstack/network/network').Network, Subnet: require('../../../openstack/network/subnet').Subnet, Port: require('../../../openstack/network/port').Port, - SecurityGroup: require('../../../openstack/network/securityGroup').SecurityGroup + SecurityGroup: require('../../../openstack/network/securityGroup').SecurityGroup, + SecurityGroupRule: require('../../../openstack/network/securityGroupRule').SecurityGroupRule }; _.extend(this, require('../../../openstack/network/client/networks')); _.extend(this, require('../../../openstack/network/client/subnets')); _.extend(this, require('../../../openstack/network/client/ports')); _.extend(this, require('../../../openstack/network/client/securityGroups')); + _.extend(this, require('../../../openstack/network/client/securityGroupRules')); this.serviceType = 'network'; }; diff --git a/test/common/network/security-group-rule-test.js b/test/common/network/security-group-rule-test.js new file mode 100644 index 000000000..870009e5f --- /dev/null +++ b/test/common/network/security-group-rule-test.js @@ -0,0 +1,434 @@ +/* + * security-group-rule-test.js: Test for Networking (Neutron)'s security group rules + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var helpers = require('../../helpers'); + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + providers = require('../../configs/providers.json'), + SecurityGroupRule = require('../../../lib/pkgcloud/core/network/securityGroupRule').SecurityGroupRule, + mock = !!process.env.MOCK, + urlJoin = require('url-join'); + +// Declaring variables for helper functions defined later +var setupSecurityGroupRulesMock, setupGetSecurityGroupRuleMock, setupCreateSecurityGroupRuleMock, + setupSecurityGroupRuleModelCreateMock, setupRefreshSecurityGroupRuleMock, + setupModelDestroyedSecurityGroupRuleMock, setupDestroySecurityGroupRuleMock; + +providers.filter(function(provider) { + return !!helpers.pkgcloud.providers[provider].network; +}).forEach(function(provider) { + + describe('pkgcloud/common/network/security-group-rules [' + provider + ']', function() { + + var client = helpers.createClient(provider, 'network'), + context = {}, + authServer, server, + authHockInstance, hockInstance; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the getSecurityGroupRules() function should return a list of security group rules', function(done) { + + if (mock) { + setupSecurityGroupRulesMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getSecurityGroupRules(function (err, securityGroupRules) { + should.not.exist(err); + should.exist(securityGroupRules); + + context.securityGroupRules = securityGroupRules; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the getSecurityGroupRule() method should get a security group rule instance', function (done) { + + if (mock) { + setupGetSecurityGroupRuleMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + },context.securityGroupRules[0]); + } + + client.getSecurityGroupRule(context.securityGroupRules[0].id, function (err, securityGroupRule) { + should.not.exist(err); + should.exist(securityGroupRule); + securityGroupRule.should.be.an.instanceOf(SecurityGroupRule); + securityGroupRule.should.have.property('id', context.securityGroupRules[0].id); + context.currentSecurityGroupRule = securityGroupRule; + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + + }); + }); + + it('the createSecurityGroupRule() method should create a security group rule', function (done) { + if (mock) { + setupCreateSecurityGroupRuleMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.createSecurityGroupRule({ + direction: 'ingress' + }, function (err, securityGroupRule) { + should.not.exist(err); + should.exist(securityGroupRule); + securityGroupRule.should.be.an.instanceOf(SecurityGroupRule); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the destroySecurityGroupRule() method should delete a security group rule', function (done) { + if (mock) { + setupDestroySecurityGroupRuleMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSecurityGroupRule); + } + + client.destroySecurityGroupRule(context.currentSecurityGroupRule, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the destroySecurityGroupRule() method should take an id, delete a security group rule', function (done) { + if (mock) { + setupDestroySecurityGroupRuleMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, context.currentSecurityGroupRule); + } + + client.destroySecurityGroupRule(context.currentSecurityGroupRule.id, function (err) { + should.not.exist(err); + done(); + }); + }); + + it('the securityGroupRule.create() method should create a security group rule', function (done) { + if (mock) { + setupSecurityGroupRuleModelCreateMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }); + } + + var securityGroupRule = new SecurityGroupRule(client); + securityGroupRule.direction = 'ingress'; + securityGroupRule.create(function (err, createdSecurityGroupRule) { + should.not.exist(err); + should.exist(createdSecurityGroupRule); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the securityGroupRule.refresh() method should get a security group rule', function (done) { + var securityGroupRule = new SecurityGroupRule(client); + securityGroupRule.id = 'd32019d3-bc6e-4319-9c1d-6722fc136a22'; + + if (mock) { + setupRefreshSecurityGroupRuleMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, securityGroupRule); + } + + securityGroupRule.refresh(function (err, refreshedSecurityGroupRule) { + should.not.exist(err); + should.exist(refreshedSecurityGroupRule); + refreshedSecurityGroupRule.should.have.property('direction', 'ingress'); + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the securityGroupRule.destroy() method should delete a security group rule', function (done) { + var securityGroupRule = new SecurityGroupRule(client); + securityGroupRule.name = 'model deleted securityGroupRule'; + securityGroupRule.id = 'THISISASECURITYGROUPRULEID'; + + if (mock) { + setupModelDestroyedSecurityGroupRuleMock(client, provider, { + authServer: authHockInstance, + server: hockInstance + }, securityGroupRule); + } + + securityGroupRule.destroy(function (err) { + should.not.exist(err); + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + }); +}); + +setupSecurityGroupRulesMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .get('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-group-rules') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroupRules.json'); + } + else if (provider === 'hp') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/hp/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') + .post('/v2.0/tokens', { + auth: { + apiAccessKeyCredentials: { + accessKey: 'MOCK-USERNAME', + secretKey: 'MOCK-API-KEY' + }, + tenantId: '5ACED3DC3AA740ABAA41711243CC6949' + } + }) + .reply(200, helpers.gethpAuthResponse()); + + servers.server + .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-group-rules') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroupRules.json'); + } + else if (provider === 'rackspace') { + servers.authServer + .post('/v2.0/tokens', { + auth: { + 'RAX-KSKEY:apiKeyCredentials': { + username: 'MOCK-USERNAME', + apiKey: 'MOCK-API-KEY' + } + } + }) + .reply(200, helpers.getRackspaceAuthResponse()); + + servers.server + .get('/v2.0/security-group-rules') + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/securityGroupRules.json'); + } +}; + +setupCreateSecurityGroupRuleMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-group-rules', { + security_group_rule: { + direction: 'ingress' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-group-rules', { + security_group_rule: { + direction: 'ingress' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/security-group-rules', { + security_group_rule: { + direction: 'ingress' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/rackspace/securityGroupRule.json'); + } +}; + +setupRefreshSecurityGroupRuleMock = function (client, provider, servers, securityGroupRule) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-group-rules', securityGroupRule.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-group-rules', securityGroupRule.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/security-group-rules', securityGroupRule.id)) + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/securityGroupRule.json'); + } +}; + +setupSecurityGroupRuleModelCreateMock = function (client, provider, servers) { + if (provider === 'openstack') { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-group-rules', { + security_group_rule: { + direction: 'ingress' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'hp') { + servers.server + .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-group-rules', { + security_group_rule: { + direction: 'ingress' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'rackspace') { + servers.server + .post('/v2.0/security-group-rules', { + security_group_rule: { + direction: 'ingress' + } + }) + .replyWithFile(201, __dirname + '/../../fixtures/rackspace/securityGroupRule.json'); + } +}; + +setupGetSecurityGroupRuleMock = function (client, provider, servers, currentSecurityGroupRule) { + if (provider === 'openstack') { + servers.server + .get(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'hp') { + servers.server + .get(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/securityGroupRule.json'); + } + else if (provider === 'rackspace') { + servers.server + .get(urlJoin('/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/securityGroupRule.json'); + } +}; + +setupDestroySecurityGroupRuleMock = function (client, provider, servers, currentSecurityGroupRule){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .reply(204); + } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .reply(204); + } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .reply(204); + } +}; + +setupModelDestroyedSecurityGroupRuleMock = function (client, provider, servers, currentSecurityGroupRule){ + if (provider === 'openstack') { + servers.server + .delete(urlJoin('/v2/72e90ecb69c44d0296072ea39e537041/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .reply(204); + } + else if (provider === 'hp') { + servers.server + .delete(urlJoin('/v2/5ACED3DC3AA740ABAA41711243CC6949/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .reply(204); + } + else if (provider === 'rackspace') { + servers.server + .delete(urlJoin('/v2.0/security-group-rules', currentSecurityGroupRule.id)) + .reply(204); + } +}; + diff --git a/test/fixtures/openstack/securityGroupRule.json b/test/fixtures/openstack/securityGroupRule.json new file mode 100644 index 000000000..080cc2aee --- /dev/null +++ b/test/fixtures/openstack/securityGroupRule.json @@ -0,0 +1,14 @@ +{ + "security_group_rule": { + "direction": "ingress", + "ethertype": "IPv6", + "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + } +} diff --git a/test/fixtures/openstack/securityGroupRules.json b/test/fixtures/openstack/securityGroupRules.json new file mode 100644 index 000000000..fbdeddf05 --- /dev/null +++ b/test/fixtures/openstack/securityGroupRules.json @@ -0,0 +1,52 @@ +{ + "security_group_rules": [ + { + "direction": "egress", + "ethertype": "IPv6", + "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "egress", + "ethertype": "IPv4", + "id": "93aa42e5-80db-4581-9391-3a608bd0e448", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": null, + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "ingress", + "ethertype": "IPv6", + "id": "c0b09f00-1d49-4e64-a0a7-8a186d928138", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + }, + { + "direction": "ingress", + "ethertype": "IPv4", + "id": "f7d45c89-008e-4bab-88ad-d6811724c51c", + "port_range_max": null, + "port_range_min": null, + "protocol": null, + "remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "remote_ip_prefix": null, + "security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550" + } + ] +} diff --git a/test/fixtures/rackspace/securityGroupRule.json b/test/fixtures/rackspace/securityGroupRule.json new file mode 100644 index 000000000..3f21c1ee0 --- /dev/null +++ b/test/fixtures/rackspace/securityGroupRule.json @@ -0,0 +1,14 @@ +{ + "security_group_rule":{ + "direction":"ingress", + "ethertype":"IPv6", + "id":"c0b09f00-1d49-4e64-a0a7-8a186d928138", + "port_range_max":22, + "port_range_min":22, + "protocol":"TCP", + "remote_group_id":null, + "remote_ip_prefix":null, + "security_group_id":"85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id":"5831008" + } +} diff --git a/test/fixtures/rackspace/securityGroupRules.json b/test/fixtures/rackspace/securityGroupRules.json new file mode 100644 index 000000000..e6eb9e05a --- /dev/null +++ b/test/fixtures/rackspace/securityGroupRules.json @@ -0,0 +1,28 @@ +{ + "security_group_rules":[ + { + "direction":"ingress", + "ethertype":"IPv6", + "id":"c0b09f00-1d49-4e64-a0a7-8a186d928138", + "port_range_max":22, + "port_range_min":22, + "protocol":"TCP", + "remote_group_id":null, + "remote_ip_prefix":null, + "security_group_id":"85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id":"5831008" + }, + { + "direction":"ingress", + "ethertype":"IPv4", + "id":"f7d45c89-008e-4bab-88ad-d6811724c51c", + "port_range_max":22, + "port_range_min":22, + "protocol":"TCP", + "remote_group_id":null, + "remote_ip_prefix":null, + "security_group_id":"85cc3048-abc3-43cc-89b3-377341426ac5", + "tenant_id":"5831008" + } + ] +} From c44ef6756e0228d062effa0b98aee3fdc3d7d9d6 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 9 Mar 2015 16:47:13 -0700 Subject: [PATCH 367/460] Adding documentation for security groups and security group rules. --- docs/providers/hp/network.md | 70 ++++++++++++++ docs/providers/openstack/network.md | 140 ++++++++++++++++++++++++++++ docs/providers/rackspace/network.md | 70 ++++++++++++++ 3 files changed, 280 insertions(+) diff --git a/docs/providers/hp/network.md b/docs/providers/hp/network.md index fa68340c0..1d39eec70 100644 --- a/docs/providers/hp/network.md +++ b/docs/providers/hp/network.md @@ -173,3 +173,73 @@ Returns the port in the callback `f(err, port)` Destroys the specified port Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)` + +**Security Groups** + +#### client.getSecurityGroups(callback) +Lists all security groups that are available to use on your Openstack account + +Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` + +#### client.getSecurityGroup(securityGroup, callback) +Gets specified security group + +Takes securityGroup or securityGroupId as an argument and returns the security group in the callback +`f(err, securityGroup)` + +#### client.createSecurityGroup(options, callback) +Creates a security group with the options specified + +Options are as follows: + +```js +{ + name: 'securityGroupName', // required, name of security group + description : 'security group description', // optional, description of security group + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group. Admin-only +} +``` +Returns the created security group in the callback `f(err, securityGroup)` + +#### client.destroySecurityGroup(securityGroup, callback) +Destroys the specified security group + +Takes securityGroup or securityGroupId as an argument and returns the id of the destroyed security group in the callback `f(err, securityGroupId)` + +**Security Group Rules** + +#### client.getSecurityGroupRules(callback) +Lists all security group rules that are available to use on your Openstack account + +Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` + +#### client.getSecurityGroupRule(securityGroupRule, callback) +Gets specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the security group rule in the callback +`f(err, securityGroupRule)` + +#### client.createSecurityGroupRule(options, callback) +Creates a security group rule with the options specified + +Options are as follows: + +```js +{ + securityGroupId: 'securityGroupId', // required, The security group ID to associate with this security group rule. + direction: 'ingress|egress', // required, The direction in which the security group rule is applied. + ethertype: 'IPv4|IPv6', // optional, + portRangeMin: portNumber, // optional, The minimum port number in the range that is matched by the security group rule. + portRangeMax: portNumber, // optional, The maximum port number in the range that is matched by the security group rule. + protocol: 'tcp|udp|icmp', // optional, The protocol that is matched by the security group rule + remoteGroupId: 'remote group id', // optional, The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix. + remoteIpPrefix: 'remote IP prefix', // optional, The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group rule. Admin-only +} +``` +Returns the created security group rule in the callback `f(err, securityGroupRule)` + +#### client.destroySecurityGroupRule(securityGroupRule, callback) +Destroys the specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the id of the destroyed security group rule in the callback `f(err, securityGroupRuleId)` diff --git a/docs/providers/openstack/network.md b/docs/providers/openstack/network.md index 7c1fca117..2716113f9 100644 --- a/docs/providers/openstack/network.md +++ b/docs/providers/openstack/network.md @@ -173,3 +173,143 @@ Returns the port in the callback `f(err, port)` Destroys the specified port Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)` + +**Security Groups** + +#### client.getSecurityGroups(callback) +Lists all security groups that are available to use on your Openstack account + +Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` + +#### client.getSecurityGroup(securityGroup, callback) +Gets specified security group + +Takes securityGroup or securityGroupId as an argument and returns the security group in the callback +`f(err, securityGroup)` + +#### client.createSecurityGroup(options, callback) +Creates a security group with the options specified + +Options are as follows: + +```js +{ + name: 'securityGroupName', // required, name of security group + description : 'security group description', // optional, description of security group + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group. Admin-only +} +``` +Returns the created security group in the callback `f(err, securityGroup)` + +#### client.destroySecurityGroup(securityGroup, callback) +Destroys the specified security group + +Takes securityGroup or securityGroupId as an argument and returns the id of the destroyed security group in the callback `f(err, securityGroupId)` + +**Security Group Rules** + +#### client.getSecurityGroupRules(callback) +Lists all security group rules that are available to use on your Openstack account + +Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` + +#### client.getSecurityGroupRule(securityGroupRule, callback) +Gets specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the security group rule in the callback +`f(err, securityGroupRule)` + +#### client.createSecurityGroupRule(options, callback) +Creates a security group rule with the options specified + +Options are as follows: + +```js +{ + securityGroupId: 'securityGroupId', // required, The security group ID to associate with this security group rule. + direction: 'ingress|egress', // required, The direction in which the security group rule is applied. + ethertype: 'IPv4|IPv6', // optional, + portRangeMin: portNumber, // optional, The minimum port number in the range that is matched by the security group rule. + portRangeMax: portNumber, // optional, The maximum port number in the range that is matched by the security group rule. + protocol: 'tcp|udp|icmp', // optional, The protocol that is matched by the security group rule + remoteGroupId: 'remote group id', // optional, The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix. + remoteIpPrefix: 'remote IP prefix', // optional, The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group rule. Admin-only +} +``` +Returns the created security group rule in the callback `f(err, securityGroupRule)` + +#### client.destroySecurityGroupRule(securityGroupRule, callback) +Destroys the specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the id of the destroyed security group rule in the callback `f(err, securityGroupRuleId)` + +**Security Groups** + +#### client.getSecurityGroups(callback) +Lists all security groups that are available to use on your Openstack account + +Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` + +#### client.getSecurityGroup(securityGroup, callback) +Gets specified security group + +Takes securityGroup or securityGroupId as an argument and returns the security group in the callback +`f(err, securityGroup)` + +#### client.createSecurityGroup(options, callback) +Creates a security group with the options specified + +Options are as follows: + +```js +{ + name: 'securityGroupName', // required, name of security group + description : 'security group description', // optional, description of security group + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group. Admin-only +} +``` +Returns the created security group in the callback `f(err, securityGroup)` + +#### client.destroySecurityGroup(securityGroup, callback) +Destroys the specified security group + +Takes securityGroup or securityGroupId as an argument and returns the id of the destroyed security group in the callback `f(err, securityGroupId)` + +**Security Group Rules** + +#### client.getSecurityGroupRules(callback) +Lists all security group rules that are available to use on your Openstack account + +Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` + +#### client.getSecurityGroupRule(securityGroupRule, callback) +Gets specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the security group rule in the callback +`f(err, securityGroupRule)` + +#### client.createSecurityGroupRule(options, callback) +Creates a security group rule with the options specified + +Options are as follows: + +```js +{ + securityGroupId: 'securityGroupId', // required, The security group ID to associate with this security group rule. + direction: 'ingress|egress', // required, The direction in which the security group rule is applied. + ethertype: 'IPv4|IPv6', // optional, + portRangeMin: portNumber, // optional, The minimum port number in the range that is matched by the security group rule. + portRangeMax: portNumber, // optional, The maximum port number in the range that is matched by the security group rule. + protocol: 'tcp|udp|icmp', // optional, The protocol that is matched by the security group rule + remoteGroupId: 'remote group id', // optional, The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix. + remoteIpPrefix: 'remote IP prefix', // optional, The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group rule. Admin-only +} +``` +Returns the created security group rule in the callback `f(err, securityGroupRule)` + +#### client.destroySecurityGroupRule(securityGroupRule, callback) +Destroys the specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the id of the destroyed security group rule in the callback `f(err, securityGroupRuleId)` diff --git a/docs/providers/rackspace/network.md b/docs/providers/rackspace/network.md index 7c5e64978..7591d620c 100644 --- a/docs/providers/rackspace/network.md +++ b/docs/providers/rackspace/network.md @@ -175,3 +175,73 @@ Returns the port in the callback `f(err, port)` Destroys the specified port Takes port or portId as an argument and returns the id of the destroyed port in the callback `f(err, portId)` + +**Security Groups** + +#### client.getSecurityGroups(callback) +Lists all security groups that are available to use on your Openstack account + +Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` + +#### client.getSecurityGroup(securityGroup, callback) +Gets specified security group + +Takes securityGroup or securityGroupId as an argument and returns the security group in the callback +`f(err, securityGroup)` + +#### client.createSecurityGroup(options, callback) +Creates a security group with the options specified + +Options are as follows: + +```js +{ + name: 'securityGroupName', // required, name of security group + description : 'security group description', // optional, description of security group + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group. Admin-only +} +``` +Returns the created security group in the callback `f(err, securityGroup)` + +#### client.destroySecurityGroup(securityGroup, callback) +Destroys the specified security group + +Takes securityGroup or securityGroupId as an argument and returns the id of the destroyed security group in the callback `f(err, securityGroupId)` + +**Security Group Rules** + +#### client.getSecurityGroupRules(callback) +Lists all security group rules that are available to use on your Openstack account + +Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` + +#### client.getSecurityGroupRule(securityGroupRule, callback) +Gets specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the security group rule in the callback +`f(err, securityGroupRule)` + +#### client.createSecurityGroupRule(options, callback) +Creates a security group rule with the options specified + +Options are as follows: + +```js +{ + securityGroupId: 'securityGroupId', // required, The security group ID to associate with this security group rule. + direction: 'ingress|egress', // required, The direction in which the security group rule is applied. + ethertype: 'IPv4|IPv6', // optional, + portRangeMin: portNumber, // optional, The minimum port number in the range that is matched by the security group rule. + portRangeMax: portNumber, // optional, The maximum port number in the range that is matched by the security group rule. + protocol: 'tcp|udp|icmp', // optional, The protocol that is matched by the security group rule + remoteGroupId: 'remote group id', // optional, The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix. + remoteIpPrefix: 'remote IP prefix', // optional, The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId. + tenantId : 'tenantId' // optional, The ID of the tenant who owns the security group rule. Admin-only +} +``` +Returns the created security group rule in the callback `f(err, securityGroupRule)` + +#### client.destroySecurityGroupRule(securityGroupRule, callback) +Destroys the specified security group rule + +Takes securityGroupRule or securityGroupRuleId as an argument and returns the id of the destroyed security group rule in the callback `f(err, securityGroupRuleId)` From 381644fae0081da268025a6d9e94863ebc673c78 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 10 Mar 2015 10:06:18 -0700 Subject: [PATCH 368/460] Refactoring model.Model to require statement to avoid repitition. --- lib/pkgcloud/core/network/securityGroup.js | 6 +++--- lib/pkgcloud/core/network/securityGroupRule.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/core/network/securityGroup.js b/lib/pkgcloud/core/network/securityGroup.js index 16814c60a..18eeef7fd 100644 --- a/lib/pkgcloud/core/network/securityGroup.js +++ b/lib/pkgcloud/core/network/securityGroup.js @@ -7,13 +7,13 @@ */ var util = require('util'), - model = require('../base/model'); + Model = require('../base/model').Model; var SecurityGroup = exports.SecurityGroup = function (client, details) { - model.Model.call(this, client, details); + Model.call(this, client, details); }; -util.inherits(SecurityGroup, model.Model); +util.inherits(SecurityGroup, Model); SecurityGroup.prototype.create = function (callback) { this.client.createSecurityGroup(this, callback); diff --git a/lib/pkgcloud/core/network/securityGroupRule.js b/lib/pkgcloud/core/network/securityGroupRule.js index 4bce78a3c..abacd2c4b 100644 --- a/lib/pkgcloud/core/network/securityGroupRule.js +++ b/lib/pkgcloud/core/network/securityGroupRule.js @@ -7,13 +7,13 @@ */ var util = require('util'), - model = require('../base/model'); + Model = require('../base/model').Model; var SecurityGroupRule = exports.SecurityGroupRule = function (client, details) { - model.Model.call(this, client, details); + Model.call(this, client, details); }; -util.inherits(SecurityGroupRule, model.Model); +util.inherits(SecurityGroupRule, Model); SecurityGroupRule.prototype.create = function (callback) { this.client.createSecurityGroupRule(this, callback); From 24f47b68eefd74ddf8248f549913e9ba8345cd1f Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 10 Mar 2015 10:14:29 -0700 Subject: [PATCH 369/460] Moving self declaration to top. --- lib/pkgcloud/openstack/network/client/networks.js | 12 ++++++------ lib/pkgcloud/openstack/network/client/ports.js | 12 ++++++------ .../openstack/network/client/securityGroupRules.js | 8 ++++---- .../openstack/network/client/securityGroups.js | 8 ++++---- lib/pkgcloud/openstack/network/client/subnets.js | 12 ++++++------ 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 076c2d897..0028b612c 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -56,8 +56,8 @@ exports.getNetworks = function (options, callback) { * @param callback */ exports.getNetwork = function (network, callback) { - var networkId = network instanceof this.models.Network ? network.id : network, - self = this; + var self = this, + networkId = network instanceof this.models.Network ? network.id : network; self.emit('log::trace', 'Getting details for network', networkId); this._request({ path: urlJoin(networksResourcePath, networkId), @@ -85,8 +85,8 @@ exports.getNetwork = function (network, callback) { * @param callback */ exports.createNetwork = function (options, callback) { - var network = typeof options === 'object' ? options : { 'name' : options}, - self = this; + var self = this, + network = typeof options === 'object' ? options : { 'name' : options}; network = _convertNetworkToWireFormat(network); @@ -141,8 +141,8 @@ exports.updateNetwork = function (network, callback) { * @param callback */ exports.destroyNetwork = function (network, callback) { - var networkId = network instanceof this.models.Network ? network.id : network, - self = this; + var self = this, + networkId = network instanceof this.models.Network ? network.id : network; self.emit('log::trace', 'Deleting network', networkId); this._request({ path: urlJoin(networksResourcePath,networkId), diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index 8193a726b..64125d1fa 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -56,8 +56,8 @@ exports.getPorts = function (options, callback) { * @param callback */ exports.getPort = function (port, callback) { - var portId = port instanceof this.models.Port ? port.id : port, - self = this; + var self = this, + portId = port instanceof this.models.Port ? port.id : port; self.emit('log::trace', 'Getting details for port', portId); this._request({ path: urlJoin(portsResourcePath, portId), @@ -85,8 +85,8 @@ exports.getPort = function (port, callback) { * @param callback */ exports.createPort = function (options, callback) { - var port = typeof options === 'object' ? options : { 'name' : options}, - self = this; + var self = this, + port = typeof options === 'object' ? options : { 'name' : options}; port = _convertPortToWireFormat(port); @@ -141,8 +141,8 @@ exports.updatePort = function (port, callback) { * @param callback */ exports.destroyPort = function (port, callback) { - var portId = port instanceof this.models.Port ? port.id : port, - self = this; + var self = this, + portId = port instanceof this.models.Port ? port.id : port; self.emit('log::trace', 'Deleting port', portId); this._request({ path: urlJoin(portsResourcePath,portId), diff --git a/lib/pkgcloud/openstack/network/client/securityGroupRules.js b/lib/pkgcloud/openstack/network/client/securityGroupRules.js index 75d9d95ce..230cffb14 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroupRules.js +++ b/lib/pkgcloud/openstack/network/client/securityGroupRules.js @@ -57,8 +57,8 @@ exports.getSecurityGroupRules = function (options, callback) { * @param callback */ exports.getSecurityGroupRule = function (securityGroupRule, callback) { - var securityGroupRuleId = securityGroupRule instanceof this.models.SecurityGroupRule ? securityGroupRule.id : securityGroupRule, - self = this; + var self = this, + securityGroupRuleId = securityGroupRule instanceof this.models.SecurityGroupRule ? securityGroupRule.id : securityGroupRule; self.emit('log::trace', 'Getting details for security group rule', securityGroupRuleId); this._request({ path: urlJoin(securityGroupRulesResourcePath, securityGroupRuleId), @@ -121,8 +121,8 @@ exports.createSecurityGroupRule = function (securityGroupRule, callback) { * @param callback */ exports.destroySecurityGroupRule = function (securityGroupRule, callback) { - var securityGroupRuleId = securityGroupRule instanceof this.models.SecurityGroupRule ? securityGroupRule.id : securityGroupRule, - self = this; + var self = this, + securityGroupRuleId = securityGroupRule instanceof this.models.SecurityGroupRule ? securityGroupRule.id : securityGroupRule; self.emit('log::trace', 'Deleting security group rule', securityGroupRuleId); this._request({ path: urlJoin(securityGroupRulesResourcePath,securityGroupRuleId), diff --git a/lib/pkgcloud/openstack/network/client/securityGroups.js b/lib/pkgcloud/openstack/network/client/securityGroups.js index 618cfd2d7..746cd7f4c 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroups.js +++ b/lib/pkgcloud/openstack/network/client/securityGroups.js @@ -57,8 +57,8 @@ exports.getSecurityGroups = function (options, callback) { * @param callback */ exports.getSecurityGroup = function (securityGroup, callback) { - var securityGroupId = securityGroup instanceof this.models.SecurityGroup ? securityGroup.id : securityGroup, - self = this; + var self = this, + securityGroupId = securityGroup instanceof this.models.SecurityGroup ? securityGroup.id : securityGroup; self.emit('log::trace', 'Getting details for security group', securityGroupId); this._request({ path: urlJoin(securityGroupsResourcePath, securityGroupId), @@ -115,8 +115,8 @@ exports.createSecurityGroup = function (securityGroup, callback) { * @param callback */ exports.destroySecurityGroup = function (securityGroup, callback) { - var securityGroupId = securityGroup instanceof this.models.SecurityGroup ? securityGroup.id : securityGroup, - self = this; + var self = this, + securityGroupId = securityGroup instanceof this.models.SecurityGroup ? securityGroup.id : securityGroup; self.emit('log::trace', 'Deleting security group', securityGroupId); this._request({ path: urlJoin(securityGroupsResourcePath,securityGroupId), diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index babae75f0..874abc78b 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -59,8 +59,8 @@ exports.getSubnets = function (options, callback) { * @param callback */ exports.getSubnet = function (subnet, callback) { - var subnetId = subnet instanceof this.models.Subnet ? subnet.id : subnet, - self = this; + var self = this, + subnetId = subnet instanceof this.models.Subnet ? subnet.id : subnet; self.emit('log::trace', 'Getting details for subnet', subnetId); this._request({ path: urlJoin(subnetsResourcePath, subnetId), @@ -88,8 +88,8 @@ exports.getSubnet = function (subnet, callback) { * @param callback */ exports.createSubnet = function (options, callback) { - var subnet = typeof options === 'object' ? options : { 'name' : options}, - self = this; + var self = this, + subnet = typeof options === 'object' ? options : { 'name' : options}; subnet = _convertSubnetToWireFormat(subnet); @@ -144,8 +144,8 @@ exports.updateSubnet = function (subnet, callback) { * @param callback */ exports.destroySubnet = function (subnet, callback) { - var subnetId = subnet instanceof this.models.Subnet ? subnet.id : subnet, - self = this; + var self = this, + subnetId = subnet instanceof this.models.Subnet ? subnet.id : subnet; self.emit('log::trace', 'Deleting subnet', subnetId); this._request({ path: urlJoin(subnetsResourcePath,subnetId), From f2e25fbf6107d6a4d6572803e8584673d1ce1ede Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 10 Mar 2015 10:16:45 -0700 Subject: [PATCH 370/460] Passing err instead of null as first arg to callback in success case. --- lib/pkgcloud/openstack/network/client/networks.js | 10 +++++----- lib/pkgcloud/openstack/network/client/ports.js | 10 +++++----- .../openstack/network/client/securityGroupRules.js | 8 ++++---- .../openstack/network/client/securityGroups.js | 8 ++++---- lib/pkgcloud/openstack/network/client/subnets.js | 10 +++++----- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/networks.js b/lib/pkgcloud/openstack/network/client/networks.js index 0028b612c..a417ec949 100644 --- a/lib/pkgcloud/openstack/network/client/networks.js +++ b/lib/pkgcloud/openstack/network/client/networks.js @@ -41,7 +41,7 @@ exports.getNetworks = function (options, callback) { return new Error('Malformed API Response'); } - return callback(null, body.networks.map(function (network) { + return callback(err, body.networks.map(function (network) { return new self.models.Network(self, network); })); }); @@ -71,7 +71,7 @@ exports.getNetwork = function (network, callback) { return new Error('Malformed API Response'); } - callback(null, new self.models.Network(self, body.network)); + callback(err, new self.models.Network(self, body.network)); }); }; @@ -100,7 +100,7 @@ exports.createNetwork = function (options, callback) { this._request(createNetworkOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.Network(self, body.network)); + : callback(err, new self.models.Network(self, body.network)); }); }; @@ -128,7 +128,7 @@ exports.updateNetwork = function (network, callback) { this._request(updateNetworkOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.Network(self, body.network)); + : callback(err, new self.models.Network(self, body.network)); }); }; @@ -151,7 +151,7 @@ exports.destroyNetwork = function (network, callback) { if (err) { return callback(err); } - callback(null, networkId); + callback(err, networkId); }); }; diff --git a/lib/pkgcloud/openstack/network/client/ports.js b/lib/pkgcloud/openstack/network/client/ports.js index 64125d1fa..2a9242665 100644 --- a/lib/pkgcloud/openstack/network/client/ports.js +++ b/lib/pkgcloud/openstack/network/client/ports.js @@ -41,7 +41,7 @@ exports.getPorts = function (options, callback) { return new Error('Malformed API Response'); } - return callback(null, body.ports.map(function (port) { + return callback(err, body.ports.map(function (port) { return new self.models.Port(self, port); })); }); @@ -71,7 +71,7 @@ exports.getPort = function (port, callback) { return new Error('Malformed API Response'); } - callback(null, new self.models.Port(self, body.port)); + callback(err, new self.models.Port(self, body.port)); }); }; @@ -100,7 +100,7 @@ exports.createPort = function (options, callback) { this._request(createPortOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.Port(self, body.port)); + : callback(err, new self.models.Port(self, body.port)); }); }; @@ -128,7 +128,7 @@ exports.updatePort = function (port, callback) { this._request(updatePortOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.Port(self, body.port)); + : callback(err, new self.models.Port(self, body.port)); }); }; @@ -151,7 +151,7 @@ exports.destroyPort = function (port, callback) { if (err) { return callback(err); } - callback(null, portId); + callback(err, portId); }); }; diff --git a/lib/pkgcloud/openstack/network/client/securityGroupRules.js b/lib/pkgcloud/openstack/network/client/securityGroupRules.js index 230cffb14..58f0e1c34 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroupRules.js +++ b/lib/pkgcloud/openstack/network/client/securityGroupRules.js @@ -42,7 +42,7 @@ exports.getSecurityGroupRules = function (options, callback) { return new Error('Malformed API Response'); } - return callback(null, body.security_group_rules.map(function (securityGroupRule) { + return callback(err, body.security_group_rules.map(function (securityGroupRule) { return new self.models.SecurityGroupRule(self, securityGroupRule); })); }); @@ -72,7 +72,7 @@ exports.getSecurityGroupRule = function (securityGroupRule, callback) { return new Error('Malformed API Response'); } - callback(null, new self.models.SecurityGroupRule(self, body.security_group_rule)); + callback(err, new self.models.SecurityGroupRule(self, body.security_group_rule)); }); }; @@ -108,7 +108,7 @@ exports.createSecurityGroupRule = function (securityGroupRule, callback) { this._request(createSecurityGroupRuleOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.SecurityGroupRule(self, body.securityGroupRule)); + : callback(err, new self.models.SecurityGroupRule(self, body.securityGroupRule)); }); }; @@ -131,7 +131,7 @@ exports.destroySecurityGroupRule = function (securityGroupRule, callback) { if (err) { return callback(err); } - callback(null, securityGroupRuleId); + callback(err, securityGroupRuleId); }); }; diff --git a/lib/pkgcloud/openstack/network/client/securityGroups.js b/lib/pkgcloud/openstack/network/client/securityGroups.js index 746cd7f4c..d87e8a47f 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroups.js +++ b/lib/pkgcloud/openstack/network/client/securityGroups.js @@ -42,7 +42,7 @@ exports.getSecurityGroups = function (options, callback) { return new Error('Malformed API Response'); } - return callback(null, body.security_groups.map(function (securityGroup) { + return callback(err, body.security_groups.map(function (securityGroup) { return new self.models.SecurityGroup(self, securityGroup); })); }); @@ -72,7 +72,7 @@ exports.getSecurityGroup = function (securityGroup, callback) { return new Error('Malformed API Response'); } - callback(null, new self.models.SecurityGroup(self, body.security_group)); + callback(err, new self.models.SecurityGroup(self, body.security_group)); }); }; @@ -102,7 +102,7 @@ exports.createSecurityGroup = function (securityGroup, callback) { this._request(createSecurityGroupOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.SecurityGroup(self, body.securityGroup)); + : callback(err, new self.models.SecurityGroup(self, body.securityGroup)); }); }; @@ -125,7 +125,7 @@ exports.destroySecurityGroup = function (securityGroup, callback) { if (err) { return callback(err); } - callback(null, securityGroupId); + callback(err, securityGroupId); }); }; diff --git a/lib/pkgcloud/openstack/network/client/subnets.js b/lib/pkgcloud/openstack/network/client/subnets.js index 874abc78b..1559aa796 100644 --- a/lib/pkgcloud/openstack/network/client/subnets.js +++ b/lib/pkgcloud/openstack/network/client/subnets.js @@ -44,7 +44,7 @@ exports.getSubnets = function (options, callback) { return new Error('Malformed API Response'); } - return callback(null, body.subnets.map(function (subnet) { + return callback(err, body.subnets.map(function (subnet) { return new self.models.Subnet(self, subnet); })); }); @@ -74,7 +74,7 @@ exports.getSubnet = function (subnet, callback) { return new Error('Malformed API Response'); } - callback(null, new self.models.Subnet(self, body.subnet)); + callback(err, new self.models.Subnet(self, body.subnet)); }); }; @@ -103,7 +103,7 @@ exports.createSubnet = function (options, callback) { this._request(createSubnetOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.Subnet(self, body.subnet)); + : callback(err, new self.models.Subnet(self, body.subnet)); }); }; @@ -131,7 +131,7 @@ exports.updateSubnet = function (subnet, callback) { this._request(updateSubnetOpts, function (err,body) { return err ? callback(err) - : callback(null, new self.models.Subnet(self, body.subnet)); + : callback(err, new self.models.Subnet(self, body.subnet)); }); }; @@ -154,7 +154,7 @@ exports.destroySubnet = function (subnet, callback) { if (err) { return callback(err); } - callback(null, subnetId); + callback(err, subnetId); }); }; From 703582febd12e1dc8add4cbd7ec754c0844bdf86 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 10 Mar 2015 10:17:30 -0700 Subject: [PATCH 371/460] Changing argument type to number from int. --- lib/pkgcloud/openstack/network/client/securityGroupRules.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/securityGroupRules.js b/lib/pkgcloud/openstack/network/client/securityGroupRules.js index 58f0e1c34..576dea14d 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroupRules.js +++ b/lib/pkgcloud/openstack/network/client/securityGroupRules.js @@ -85,8 +85,8 @@ exports.getSecurityGroupRule = function (securityGroupRule, callback) { * @param string securityGroupRule.securityGroupId The security group ID to associate with this security group rule. * @param string securityGroupRule.direction The direction ("ingress" or "egress") in which the security group rule is applied. * @param {string} securityGroupRule.ethertype "IPv4" or "IPv6". - * @param {int} securityGroupRule.portRangeMin The minimum port number in the range that is matched by the security group rule. - * @param {int} securityGroupRule.portRangeMax The maximum port number in the range that is matched by the security group rule. + * @param {number} securityGroupRule.portRangeMin The minimum port number in the range that is matched by the security group rule. + * @param {number} securityGroupRule.portRangeMax The maximum port number in the range that is matched by the security group rule. * @param {string} securityGroupRule.protocol The protocol ("tcp", "udp", or "icmp") that is matched by the security group rule. * @param {string} securityGroupRule.remoteGroupId The remote group ID to be associated with this security group rule. You can specify either this or remoteIpPrefix. * @param {string} securityGroupRule.remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either this or remoteGroupId. From b91dcc513cede26079825094b20fbc6b1e367193 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 10 Mar 2015 10:18:42 -0700 Subject: [PATCH 372/460] Fixing styling of spaces. --- lib/pkgcloud/openstack/network/client/securityGroupRules.js | 2 +- lib/pkgcloud/openstack/network/client/securityGroups.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/network/client/securityGroupRules.js b/lib/pkgcloud/openstack/network/client/securityGroupRules.js index 576dea14d..a7a3dac84 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroupRules.js +++ b/lib/pkgcloud/openstack/network/client/securityGroupRules.js @@ -101,7 +101,7 @@ exports.createSecurityGroupRule = function (securityGroupRule, callback) { var createSecurityGroupRuleOpts = { method: 'POST', path: securityGroupRulesResourcePath, - body: { 'security_group_rule' : securityGroupRule} + body: { 'security_group_rule': securityGroupRule } }; self.emit('log::trace', 'Creating security group rule', securityGroupRule); diff --git a/lib/pkgcloud/openstack/network/client/securityGroups.js b/lib/pkgcloud/openstack/network/client/securityGroups.js index d87e8a47f..5771cf414 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroups.js +++ b/lib/pkgcloud/openstack/network/client/securityGroups.js @@ -95,7 +95,7 @@ exports.createSecurityGroup = function (securityGroup, callback) { var createSecurityGroupOpts = { method: 'POST', path: securityGroupsResourcePath, - body: { 'security_group' : securityGroup} + body: { 'security_group': securityGroup } }; self.emit('log::trace', 'Creating security group', securityGroup); From 310f78a5a554a4dd01f20aba98636a489652bd91 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 11 Mar 2015 14:46:57 -0700 Subject: [PATCH 373/460] Allow passing options to rebuildServer. --- docs/providers/openstack/compute.md | 22 +++ docs/providers/rackspace/compute.md | 22 +++ .../openstack/compute/client/servers.js | 40 ++++- .../compute/client/rebuildServer-test.js | 168 ++++++++++++++++++ 4 files changed, 245 insertions(+), 7 deletions(-) create mode 100644 test/openstack/compute/client/rebuildServer-test.js diff --git a/docs/providers/openstack/compute.md b/docs/providers/openstack/compute.md index 614246ee6..0a69d6281 100644 --- a/docs/providers/openstack/compute.md +++ b/docs/providers/openstack/compute.md @@ -62,6 +62,28 @@ Options include: ``` Returns callback with a confirmation +#### client.rebuildServer(server, options, callback) +Rebuilds the specifed server with options + +Options include: + +```js +{ + image: '45a01744-2bcf-4a23-ae88-63317f768a2f', // required; image ID or instance of pkgcloud.core.compute.Image + flavor: '2', // optional; flavor ID or instance of pkgcloud.core.compute.Flavor + accessIPv4: '123.45.67.89' // optional; IPv4 address of server + accessIPv6: 'f0::09', // optional; IPv6 address of server + adminPass: 'foobar', // optional; administrator password for the server + metadata: { group: 'webservers' }, // optional; metadata key/value pairs + personality: [ { path: '/etc/banner.txt', contents: 'ICAgICAgDQo' } ], // optional; personality files - path and contents + 'OS-DCF:diskConfig': 'AUTO' // optional; disk configuration value ("AUTO" | "MANUAL") +} +``` +Returns callback with a confirmation + +**Note about backwards compatiblity:** +For backwards compatibility, it is also possible to pass an image ID or instance of `pkgcloud.core.compute.Image` as the value of the `options` argument. + #### client.getVersion(callback) Get the current version of the api returned in a callback `f(err, version)` diff --git a/docs/providers/rackspace/compute.md b/docs/providers/rackspace/compute.md index 8637ed016..198f169f4 100644 --- a/docs/providers/rackspace/compute.md +++ b/docs/providers/rackspace/compute.md @@ -64,6 +64,28 @@ Options include: ``` Returns callback with a confirmation +#### client.rebuildServer(server, options, callback) +Rebuilds the specifed server with options + +Options include: + +```js +{ + image: '45a01744-2bcf-4a23-ae88-63317f768a2f', // required; image ID or instance of pkgcloud.core.compute.Image + flavor: '2', // optional; flavor ID or instance of pkgcloud.core.compute.Flavor + accessIPv4: '123.45.67.89' // optional; IPv4 address of server + accessIPv6: 'f0::09', // optional; IPv6 address of server + adminPass: 'foobar', // optional; administrator password for the server + metadata: { group: 'webservers' }, // optional; metadata key/value pairs + personality: [ { path: '/etc/banner.txt', contents: 'ICAgICAgDQo' } ], // optional; personality files - path and contents + 'OS-DCF:diskConfig': 'AUTO' // optional; disk configuration value ("AUTO" | "MANUAL") +} +``` +Returns callback with a confirmation + +**Note about backwards compatiblity:** +For backwards compatibility, it is also possible to pass an image ID or instance of `pkgcloud.core.compute.Image` as the value of the `options` argument. + #### client.getVersion(callback) Get the current version of the api returned in a callback `f(err, version)` diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index 8407eef6d..d1a202192 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -275,18 +275,44 @@ exports.rebootServer = function rebootServer(server, options, callback) { * * @description Rebuild the provider server * - * @param {String|object} server The server or serverId to rebuild - * @param {String|object} image The image or imageId to use in the rebuild + * @param {String|object} server The server or serverId to rebuild + * @param {String|object} options The image or imageId to use in the rebuild (for backwards compatibility) + * @param {String|object} options.image The image or imageId to use in the rebuild + * @param {String|object} options.flavor The flavor or flavorId to use in the rebuild + * @param {String} options.accessIPv4 The IP version 4 address of the server. + * @param {String} options.accessIPv6 The IP version 6 address of the server. + * @param {String} options.adminPass The administrator password for the server. + * @param {object} options.metadata Metadata key/value pairs. + * @param {array} options.personality Personality files - path and contents + * @param {String} options.personality[n].path Personality file path + * @param {String} options.personality[n].contents Personality file contents + * @param {String} options['OS-DCF:diskConfig'] The disk configuration value ("AUTO" | "MANUAL"). * @param {Function} callback * @returns {*} */ -exports.rebuildServer = function rebootServer(server, image, callback) { - var imageId = image instanceof base.Image ? image.id : image; +exports.rebuildServer = function rebootServer(server, options, callback) { + var imageId, flavorId, rebuildBody = {}; + if (options instanceof base.Image) { + // Image object was passed in as options (backwards compatible) + rebuildBody.imageRef = options.id; + } else if (typeof options === 'object') { + // Several options were passed in as options + rebuildBody = _.pick(options, [ + 'accessIPv4', + 'accessIPv6', + 'adminPass', + 'metadata', + 'personality' + ]); + rebuildBody.imageRef = options.image instanceof base.Image ? options.image.id : options.image; + rebuildBody.flavorRef = options.flavor instanceof base.Flavor ? options.flavor.id : options.flavor; + } else { + // Image ID was passed in as options (backwards compatible) + rebuildBody.imageRef = options; + } this._doServerAction.call(this, server, { - rebuild: { - imageRef: imageId - } + rebuild: rebuildBody }, callback); }; diff --git a/test/openstack/compute/client/rebuildServer-test.js b/test/openstack/compute/client/rebuildServer-test.js new file mode 100644 index 000000000..5f91e1506 --- /dev/null +++ b/test/openstack/compute/client/rebuildServer-test.js @@ -0,0 +1,168 @@ +/* + * rebuildServer-test.js: Test for rebuilding servers + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var helpers = require('../../../helpers'); + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + compute = require('../../../../lib/pkgcloud/openstack/compute'), + mock = !!process.env.MOCK; + +var client = helpers.createClient('openstack', 'compute'); + +// Declaring variables for helper functions defined later +var setupRebuildServerWithImageIdMock, setupRebuildServerWithImageObjMock, + setupRebuildServerWithOptionsMock; + +describe('pkgcloud/openstack/compute/server[openstack]', function() { + + var authHockInstance, hockInstance, authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the server.rebuildServer() method with image ID should rebuild a server instance', function (done) { + if (mock) { + setupRebuildServerWithImageIdMock({ + authServer: authHockInstance, + server: hockInstance + }); + } + + client.rebuildServer('a2e90ecb69c44d0296072ea39e53704a', 'd42f821e-c2d1-4796-9f07-af5ed7912d0e', function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the server.rebuildServer() method with image object should rebuild a server instance', function (done) { + if (mock) { + setupRebuildServerWithImageObjMock({ + authServer: authHockInstance, + server: hockInstance + }); + } + + var imageObj = new compute.Image(client, { id: 'd42f821e-c2d1-4796-9f07-af5ed7912d0e' }); + client.rebuildServer('a2e90ecb69c44d0296072ea39e53704a', imageObj, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the server.rebuildServer() method with options should rebuild a server instance', function (done) { + if (mock) { + setupRebuildServerWithOptionsMock({ + authServer: authHockInstance, + server: hockInstance + }); + } + + var options = { + image: 'd42f821e-c2d1-4796-9f07-af5ed7912d0e', + flavor: '2', + adminPass: 'foobar' + }; + client.rebuildServer('a2e90ecb69c44d0296072ea39e53704a', options, function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); +}); + +setupRebuildServerWithImageIdMock = function(servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', + { 'rebuild': { 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e' } }) + .reply(202, ''); +}; + +setupRebuildServerWithImageObjMock = function(servers) { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', + { 'rebuild': { 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e' } }) + .reply(202, ''); +}; + +setupRebuildServerWithOptionsMock = function(servers) { + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', + { 'rebuild': { 'adminPass': 'foobar', 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e', 'flavorRef': '2' } }) + .reply(202, ''); +}; From 4f306b108aeff29466c5c2b8f2d1e04f82afd5ab Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 11 Mar 2015 15:14:33 -0700 Subject: [PATCH 374/460] Removing unused variables. --- lib/pkgcloud/openstack/compute/client/servers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index d1a202192..48419b341 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -291,7 +291,7 @@ exports.rebootServer = function rebootServer(server, options, callback) { * @returns {*} */ exports.rebuildServer = function rebootServer(server, options, callback) { - var imageId, flavorId, rebuildBody = {}; + var rebuildBody = {}; if (options instanceof base.Image) { // Image object was passed in as options (backwards compatible) rebuildBody.imageRef = options.id; From 128bfc6c08304472db881563c63ba5b2098f05e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=98=9F?= Date: Thu, 12 Mar 2015 17:10:23 +0800 Subject: [PATCH 375/460] 1. Add abort on openstack's client.download 2. Add headers on openstack's request --- lib/pkgcloud/openstack/client.js | 12 ++++++++++++ lib/pkgcloud/openstack/storage/client/files.js | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 9bd3da46c..94080917d 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -195,6 +195,10 @@ Client.prototype._request = function (options, callback) { self.emit('log::trace', 'Creating Authenticated Proxy Request'); var apiStream = Client.super_.prototype._request.call(self, options, callback); + proxyStream.on('abort', function () { + apiStream.abort(); + }); + if (options.upload) { // needed for event propagation during proxied auth for streams @@ -209,6 +213,14 @@ Client.prototype._request = function (options, callback) { proxyStream.pipe(apiStream); } else if (options.download) { + apiStream.on('error', function (err) { + proxyStream.emit('error', err); + }); + + apiStream.on('response', function (response) { + proxyStream.emit('response', response); + }); + apiStream.pipe(proxyStream); } diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 57c603b5d..33c018e33 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -202,7 +202,8 @@ exports.download = function (options, callback) { apiStream = this._request({ container: container, path: options.remote, - download: true + download: true, + headers: options.headers }, success); if (inputStream) { From 2035bcbc363f1a30d6af59e54faf9de738f5ea63 Mon Sep 17 00:00:00 2001 From: indexzero Date: Thu, 12 Mar 2015 02:51:43 -0700 Subject: [PATCH 376/460] [dist] Reassign Nodejitsu copyright to the project contributors. --- LICENSE | 4 ++-- lib/pkgcloud.js | 2 +- lib/pkgcloud/amazon/client.js | 2 +- lib/pkgcloud/amazon/compute/client/flavors.js | 2 +- lib/pkgcloud/amazon/compute/client/images.js | 2 +- lib/pkgcloud/amazon/compute/client/index.js | 2 +- lib/pkgcloud/amazon/compute/client/keys.js | 2 +- lib/pkgcloud/amazon/compute/client/servers.js | 4 ++-- lib/pkgcloud/amazon/compute/flavor.js | 2 +- lib/pkgcloud/amazon/compute/image.js | 2 +- lib/pkgcloud/amazon/compute/index.js | 2 +- lib/pkgcloud/amazon/compute/server.js | 2 +- lib/pkgcloud/amazon/index.js | 2 +- .../amazon/storage/client/containers.js | 2 +- lib/pkgcloud/amazon/storage/client/files.js | 2 +- lib/pkgcloud/amazon/storage/client/index.js | 2 +- lib/pkgcloud/amazon/storage/container.js | 2 +- lib/pkgcloud/amazon/storage/file.js | 2 +- lib/pkgcloud/amazon/storage/index.js | 2 +- lib/pkgcloud/common/auth.js | 2 +- lib/pkgcloud/common/azure-signature.js | 2 +- lib/pkgcloud/common/http-signature.js | 2 +- lib/pkgcloud/common/index.js | 2 +- lib/pkgcloud/common/status.js | 2 +- lib/pkgcloud/core/base/client.js | 4 ++-- lib/pkgcloud/core/base/index.js | 2 +- lib/pkgcloud/core/base/model.js | 2 +- lib/pkgcloud/core/compute/flavor.js | 2 +- lib/pkgcloud/core/compute/image.js | 2 +- lib/pkgcloud/core/compute/index.js | 2 +- lib/pkgcloud/core/compute/server.js | 2 +- lib/pkgcloud/core/storage/container.js | 2 +- lib/pkgcloud/core/storage/file.js | 2 +- lib/pkgcloud/core/storage/index.js | 2 +- lib/pkgcloud/digitalocean/client.js | 4 ++-- .../digitalocean/compute/client/flavors.js | 8 ++++---- .../digitalocean/compute/client/images.js | 4 ++-- .../digitalocean/compute/client/index.js | 2 +- .../digitalocean/compute/client/keys.js | 2 +- .../digitalocean/compute/client/servers.js | 2 +- lib/pkgcloud/digitalocean/compute/flavor.js | 4 ++-- lib/pkgcloud/digitalocean/compute/image.js | 2 +- lib/pkgcloud/digitalocean/compute/index.js | 2 +- lib/pkgcloud/digitalocean/compute/server.js | 2 +- lib/pkgcloud/digitalocean/index.js | 2 +- lib/pkgcloud/google/client.js | 2 +- lib/pkgcloud/google/index.js | 2 +- .../google/storage/client/containers.js | 2 +- lib/pkgcloud/google/storage/client/files.js | 2 +- lib/pkgcloud/google/storage/client/index.js | 2 +- lib/pkgcloud/google/storage/container.js | 2 +- lib/pkgcloud/google/storage/file.js | 2 +- lib/pkgcloud/google/storage/index.js | 2 +- .../iriscouch/database/client/index.js | 2 +- lib/pkgcloud/iriscouch/database/index.js | 2 +- lib/pkgcloud/iriscouch/index.js | 2 +- lib/pkgcloud/joyent/client.js | 2 +- lib/pkgcloud/joyent/compute/client/flavors.js | 2 +- lib/pkgcloud/joyent/compute/client/images.js | 2 +- lib/pkgcloud/joyent/compute/client/index.js | 2 +- lib/pkgcloud/joyent/compute/client/keys.js | 2 +- lib/pkgcloud/joyent/compute/client/servers.js | 2 +- lib/pkgcloud/joyent/compute/flavor.js | 2 +- lib/pkgcloud/joyent/compute/image.js | 2 +- lib/pkgcloud/joyent/compute/index.js | 2 +- lib/pkgcloud/joyent/compute/server.js | 2 +- lib/pkgcloud/joyent/index.js | 2 +- .../mongohq/database/client/databases.js | 2 +- lib/pkgcloud/mongohq/database/client/index.js | 2 +- lib/pkgcloud/mongohq/database/index.js | 2 +- lib/pkgcloud/mongohq/index.js | 2 +- .../mongolab/database/client/accounts.js | 2 +- .../mongolab/database/client/databases.js | 2 +- lib/pkgcloud/mongolab/database/client/index.js | 2 +- lib/pkgcloud/mongolab/database/index.js | 2 +- lib/pkgcloud/mongolab/index.js | 2 +- lib/pkgcloud/openstack/client.js | 2 +- .../compute/client/extensions/keys.js | 2 +- .../openstack/compute/client/flavors.js | 2 +- .../openstack/compute/client/images.js | 2 +- lib/pkgcloud/openstack/compute/client/index.js | 2 +- .../openstack/compute/client/servers.js | 2 +- lib/pkgcloud/openstack/compute/flavor.js | 2 +- lib/pkgcloud/openstack/compute/image.js | 2 +- lib/pkgcloud/openstack/compute/index.js | 2 +- lib/pkgcloud/openstack/compute/server.js | 2 +- lib/pkgcloud/openstack/context/index.js | 2 +- lib/pkgcloud/openstack/identity/index.js | 2 +- lib/pkgcloud/openstack/index.js | 2 +- lib/pkgcloud/rackspace/client.js | 2 +- lib/pkgcloud/rackspace/compute/client/index.js | 2 +- lib/pkgcloud/rackspace/compute/index.js | 2 +- .../rackspace/database/client/index.js | 2 +- lib/pkgcloud/rackspace/database/index.js | 2 +- lib/pkgcloud/rackspace/index.js | 2 +- .../rackspace/storage/client/cdn-containers.js | 2 +- lib/pkgcloud/rackspace/storage/client/index.js | 2 +- .../redistogo/database/client/index.js | 2 +- lib/pkgcloud/redistogo/database/index.js | 2 +- lib/pkgcloud/redistogo/index.js | 2 +- lib/pkgcloud/telefonica/compute/client.js | 2 +- lib/pkgcloud/telefonica/compute/index.js | 2 +- lib/pkgcloud/telefonica/index.js | 2 +- package.json | 14 +++++++++----- test/common/base/client-test.js | 2 +- test/common/compute/base-test.js | 2 +- test/common/compute/meta-test.js | 6 +++--- test/common/compute/server-test.js | 2 +- test/common/compute/signature-test.js | 2 +- test/common/storage/base-test.js | 2 +- test/common/storage/upload-test.js | 2 +- test/hp/macros.js | 2 +- .../databases/databases-redis-test.js | 6 +++--- test/iriscouch/databases/databases-test.js | 2 +- test/mongohq/databases/databases-test.js | 2 +- test/mongolab/databases/databases-test.js | 14 +++++++------- test/rackspace/compute/authentication-test.js | 2 +- test/rackspace/compute/image-test.js | 4 ++-- test/rackspace/compute/personality-test.js | 2 +- .../rackspace/databases/authentication-test.js | 2 +- test/rackspace/databases/user-limit-test.js | 2 +- test/rackspace/macros.js | 2 +- test/rackspace/storage/authentication-test.js | 2 +- test/rackspace/storage/container-test.js | 2 +- .../storage/storage-object-large-test.js | 2 +- .../storage/storage-object-metadata-test.js | 2 +- .../storage/storage-object-noauth-test.js | 2 +- test/rackspace/storage/storage-object-test.js | 18 +++++++++--------- test/redistogo/databases/databases-test.js | 2 +- 129 files changed, 165 insertions(+), 161 deletions(-) diff --git a/LICENSE b/LICENSE index 4b467e5d7..58f564e66 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011 Nodejitsu Inc. +Copyright (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index 2c34ef4c7..b70995991 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -1,7 +1,7 @@ /* * pkgcloud.js: Top-level include for the pkgcloud module * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index 2a1985d7a..f8c0060dd 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all AWS clients inherit from * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/compute/client/flavors.js b/lib/pkgcloud/amazon/compute/client/flavors.js index 9975eb7ce..270b25a64 100644 --- a/lib/pkgcloud/amazon/compute/client/flavors.js +++ b/lib/pkgcloud/amazon/compute/client/flavors.js @@ -1,7 +1,7 @@ /* * flavors.js: Implementation of AWS Flavors Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/compute/client/images.js b/lib/pkgcloud/amazon/compute/client/images.js index cc8052fc5..a92dadb66 100644 --- a/lib/pkgcloud/amazon/compute/client/images.js +++ b/lib/pkgcloud/amazon/compute/client/images.js @@ -1,7 +1,7 @@ /* * images.js: Implementation of AWS Images Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var pkgcloud = require('../../../../../lib/pkgcloud'), diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index 82e7d4702..33ec5ce04 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Compute client for AWS CloudAPI * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/compute/client/keys.js b/lib/pkgcloud/amazon/compute/client/keys.js index 8a2420c4b..45dc6d53e 100644 --- a/lib/pkgcloud/amazon/compute/client/keys.js +++ b/lib/pkgcloud/amazon/compute/client/keys.js @@ -1,7 +1,7 @@ /* * keys.js: Implementation of AWS SSH keys Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index 6bec5dbf4..f100651c8 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -1,7 +1,7 @@ /* * servers.js: Instance methods for working with servers from AWS Cloud * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var async = require('async'), @@ -254,7 +254,7 @@ exports.getServer = function getServer(server, callback) { if (err) { return callback(err); } - + callback(null, new compute.Server(self, server)); }); } diff --git a/lib/pkgcloud/amazon/compute/flavor.js b/lib/pkgcloud/amazon/compute/flavor.js index 55e8409a9..fb8c15dcd 100644 --- a/lib/pkgcloud/amazon/compute/flavor.js +++ b/lib/pkgcloud/amazon/compute/flavor.js @@ -1,7 +1,7 @@ /* * flavor.js: AWS Cloud Package * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/compute/image.js b/lib/pkgcloud/amazon/compute/image.js index 2d276257e..69b7fae5a 100644 --- a/lib/pkgcloud/amazon/compute/image.js +++ b/lib/pkgcloud/amazon/compute/image.js @@ -1,7 +1,7 @@ /* * image.js: AWS Cloud * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/compute/index.js b/lib/pkgcloud/amazon/compute/index.js index 1fe951fee..e2d4b17a9 100644 --- a/lib/pkgcloud/amazon/compute/index.js +++ b/lib/pkgcloud/amazon/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the AWS compute module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/compute/server.js b/lib/pkgcloud/amazon/compute/server.js index 99c3d3932..906ff74bc 100644 --- a/lib/pkgcloud/amazon/compute/server.js +++ b/lib/pkgcloud/amazon/compute/server.js @@ -1,7 +1,7 @@ /* * server.js: AWS Server * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/index.js b/lib/pkgcloud/amazon/index.js index b1b009ab8..ed8534b40 100644 --- a/lib/pkgcloud/amazon/index.js +++ b/lib/pkgcloud/amazon/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the AWS module. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index 3b41efe1c..57b71a69d 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -1,7 +1,7 @@ /* * containers.js: Instance methods for working with containers from AWS S3 * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index aca20b70b..d1c1f2e3f 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -1,7 +1,7 @@ /* * files.js: Instance methods for working with files from AWS S3 * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index 162d7c594..16334b834 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Storage client for AWS S3 * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/storage/container.js b/lib/pkgcloud/amazon/storage/container.js index 8942469a6..01817be35 100644 --- a/lib/pkgcloud/amazon/storage/container.js +++ b/lib/pkgcloud/amazon/storage/container.js @@ -1,7 +1,7 @@ /* * container.js: AWS S3 Bucket * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index 370dbe33f..a0effac52 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -1,7 +1,7 @@ /* * container.js: AWS S3 File * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/amazon/storage/index.js b/lib/pkgcloud/amazon/storage/index.js index 82ac8dfcd..a7e4e5193 100644 --- a/lib/pkgcloud/amazon/storage/index.js +++ b/lib/pkgcloud/amazon/storage/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the AWS S3 module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/common/auth.js b/lib/pkgcloud/common/auth.js index 98ddde72e..0a1dfa2f1 100644 --- a/lib/pkgcloud/common/auth.js +++ b/lib/pkgcloud/common/auth.js @@ -1,7 +1,7 @@ /* * auth.js: Utilities for authenticating with multiple cloud providers * - * (C) 2011-2012 Nodejitsu Inc. + * (C) 2011-2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/common/azure-signature.js b/lib/pkgcloud/common/azure-signature.js index cfc7ed376..64f6c83bd 100644 --- a/lib/pkgcloud/common/azure-signature.js +++ b/lib/pkgcloud/common/azure-signature.js @@ -1,7 +1,7 @@ /* * azure-signature.js: Implementation of authentication for Azure APIs. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/common/http-signature.js b/lib/pkgcloud/common/http-signature.js index c5ab23339..10d91ab7f 100644 --- a/lib/pkgcloud/common/http-signature.js +++ b/lib/pkgcloud/common/http-signature.js @@ -4,7 +4,7 @@ * Copyright (C) 2011 Joyent, Inc. All rights reserved. * MIT License * - * Modified by Nodejitsu, under MIT + * Modified under MIT * */ diff --git a/lib/pkgcloud/common/index.js b/lib/pkgcloud/common/index.js index cf5fe070c..b9753790b 100644 --- a/lib/pkgcloud/common/index.js +++ b/lib/pkgcloud/common/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the pkgcloud common module. * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/common/status.js b/lib/pkgcloud/common/status.js index 231afaa75..b4cab0dc8 100644 --- a/lib/pkgcloud/common/status.js +++ b/lib/pkgcloud/common/status.js @@ -1,7 +1,7 @@ /* * status.js: Standardized statuses for different services * - * (C) 2011-2012 Nodejitsu Inc. + * (C) 2011-2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/base/client.js b/lib/pkgcloud/core/base/client.js index 0d6198f29..34a4a5431 100644 --- a/lib/pkgcloud/core/base/client.js +++ b/lib/pkgcloud/core/base/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all pkgcloud clients inherit from * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ @@ -95,7 +95,7 @@ Client.prototype._request = function (options, callback) { requestOptions.signingUrl += '?' + qs.stringify(options.qs); } } - + function sendRequest(opts) { // diff --git a/lib/pkgcloud/core/base/index.js b/lib/pkgcloud/core/base/index.js index b73e15336..2d71cde3f 100644 --- a/lib/pkgcloud/core/base/index.js +++ b/lib/pkgcloud/core/base/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for pkgcloud `base` module from which all pkgcloud objects inherit. * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/base/model.js b/lib/pkgcloud/core/base/model.js index c882d3087..2c00d102d 100644 --- a/lib/pkgcloud/core/base/model.js +++ b/lib/pkgcloud/core/base/model.js @@ -1,7 +1,7 @@ /* * model.js: Base model from which all pkgcloud models inherit from * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/compute/flavor.js b/lib/pkgcloud/core/compute/flavor.js index 70ab650ba..44abcc62b 100644 --- a/lib/pkgcloud/core/compute/flavor.js +++ b/lib/pkgcloud/core/compute/flavor.js @@ -1,7 +1,7 @@ /* * flavor.js: Base flavor from which all pkgcloud flavors inherit from * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/compute/image.js b/lib/pkgcloud/core/compute/image.js index e1992d8cf..f468ad901 100644 --- a/lib/pkgcloud/core/compute/image.js +++ b/lib/pkgcloud/core/compute/image.js @@ -1,7 +1,7 @@ /* * image.js: Base image from which all pkgcloud images inherit from * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/compute/index.js b/lib/pkgcloud/core/compute/index.js index 77cb9be96..d9c09456e 100644 --- a/lib/pkgcloud/core/compute/index.js +++ b/lib/pkgcloud/core/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include from which all pkgcloud compute models inherit. * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/compute/server.js b/lib/pkgcloud/core/compute/server.js index efc111a55..4bef9e01c 100644 --- a/lib/pkgcloud/core/compute/server.js +++ b/lib/pkgcloud/core/compute/server.js @@ -1,7 +1,7 @@ /* * server.js: Base server from which all pkgcloud servers inherit from * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/storage/container.js b/lib/pkgcloud/core/storage/container.js index 70e67dc0d..2c5ab3be0 100644 --- a/lib/pkgcloud/core/storage/container.js +++ b/lib/pkgcloud/core/storage/container.js @@ -1,7 +1,7 @@ /* * container.js: Base container from which all pkgcloud containers inherit from * - * (C) 2010 Nodejitsu Inc. + * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/storage/file.js b/lib/pkgcloud/core/storage/file.js index 517a0f6cb..d98d21d9d 100644 --- a/lib/pkgcloud/core/storage/file.js +++ b/lib/pkgcloud/core/storage/file.js @@ -1,7 +1,7 @@ /* * file.js: Base container from which all pkgcloud files inherit from * - * (C) 2010 Nodejitsu Inc. + * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/core/storage/index.js b/lib/pkgcloud/core/storage/index.js index 8a9cc34f2..09f922080 100644 --- a/lib/pkgcloud/core/storage/index.js +++ b/lib/pkgcloud/core/storage/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include from which all pkgcloud storage models inherit. * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/digitalocean/client.js b/lib/pkgcloud/digitalocean/client.js index c2523c89d..a99c96969 100644 --- a/lib/pkgcloud/digitalocean/client.js +++ b/lib/pkgcloud/digitalocean/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all Joyent clients inherit from * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ @@ -25,7 +25,7 @@ var Client = exports.Client = function (opts) { this.provider = 'digitalocean'; this.protocol = opts.protocol || 'https://'; this.serversUrl = opts.serversUrl; - + if (!this.before) { this.before = []; } diff --git a/lib/pkgcloud/digitalocean/compute/client/flavors.js b/lib/pkgcloud/digitalocean/compute/client/flavors.js index 0a42e4889..8f4232bbd 100644 --- a/lib/pkgcloud/digitalocean/compute/client/flavors.js +++ b/lib/pkgcloud/digitalocean/compute/client/flavors.js @@ -1,7 +1,7 @@ /* * flavors.js: Implementation of DigitalOcean Flavors Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ @@ -24,10 +24,10 @@ exports.getFlavors = function getFlavors(callback) { if (err || !body.sizes) { return callback(err || new Error('No flavors provided.')); } - + callback(null, body.sizes.map(function (result) { return new compute.Flavor(self, result); - }), res); + }), res); }); }; @@ -54,7 +54,7 @@ exports.getFlavor = function getFlavor(flavor, callback) { var flavor = body.sizes.filter(function (flavor) { return flavor.id == flavorId; })[0]; - + return !flavor ? callback(new Error('No flavor found with id: ' + flavorId)) : callback(null, new compute.Flavor(self, flavor)); diff --git a/lib/pkgcloud/digitalocean/compute/client/images.js b/lib/pkgcloud/digitalocean/compute/client/images.js index c123a4a2c..0556a6e6d 100644 --- a/lib/pkgcloud/digitalocean/compute/client/images.js +++ b/lib/pkgcloud/digitalocean/compute/client/images.js @@ -1,7 +1,7 @@ /* * images.js: Implementation of DigitalOcean Images Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var pkgcloud = require('../../../../../lib/pkgcloud'), @@ -41,7 +41,7 @@ exports.getImages = function getImages(callback) { // exports.getImage = function getImage(image, callback) { var imageId = image instanceof base.Image ? image.id : image, - self = this; + self = this; return this._request({ path: '/images/' + imageId diff --git a/lib/pkgcloud/digitalocean/compute/client/index.js b/lib/pkgcloud/digitalocean/compute/client/index.js index 87dfae663..1630aec70 100644 --- a/lib/pkgcloud/digitalocean/compute/client/index.js +++ b/lib/pkgcloud/digitalocean/compute/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Compute client for DigitalOcean API * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/digitalocean/compute/client/keys.js b/lib/pkgcloud/digitalocean/compute/client/keys.js index 798e439d5..88268deef 100644 --- a/lib/pkgcloud/digitalocean/compute/client/keys.js +++ b/lib/pkgcloud/digitalocean/compute/client/keys.js @@ -1,7 +1,7 @@ /* * keys.js: Implementation of DigitalOcean SSH keys Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/digitalocean/compute/client/servers.js b/lib/pkgcloud/digitalocean/compute/client/servers.js index dff9a9de7..30541c77e 100644 --- a/lib/pkgcloud/digitalocean/compute/client/servers.js +++ b/lib/pkgcloud/digitalocean/compute/client/servers.js @@ -1,7 +1,7 @@ /* * servers.js: Instance methods for working with servers from DigitalOcean * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var base = require('../../../core/compute'), diff --git a/lib/pkgcloud/digitalocean/compute/flavor.js b/lib/pkgcloud/digitalocean/compute/flavor.js index c48f90b96..b758b7f06 100644 --- a/lib/pkgcloud/digitalocean/compute/flavor.js +++ b/lib/pkgcloud/digitalocean/compute/flavor.js @@ -1,7 +1,7 @@ /* * flavor.js: DigitalOcean Server "Size" * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ @@ -19,7 +19,7 @@ Flavor.prototype._setProperties = function (details) { this.name = details.name; this.ram = details.memory; this.disk = details.disk; - + // // DigitalOcean specific // diff --git a/lib/pkgcloud/digitalocean/compute/image.js b/lib/pkgcloud/digitalocean/compute/image.js index 1347d4569..8dfde8995 100644 --- a/lib/pkgcloud/digitalocean/compute/image.js +++ b/lib/pkgcloud/digitalocean/compute/image.js @@ -1,7 +1,7 @@ /* * image.js: DigitalOcean Image * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/digitalocean/compute/index.js b/lib/pkgcloud/digitalocean/compute/index.js index 36815810c..7878ea5ea 100644 --- a/lib/pkgcloud/digitalocean/compute/index.js +++ b/lib/pkgcloud/digitalocean/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the DigitalOcean compute module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/digitalocean/compute/server.js b/lib/pkgcloud/digitalocean/compute/server.js index 987020155..1e401eaee 100644 --- a/lib/pkgcloud/digitalocean/compute/server.js +++ b/lib/pkgcloud/digitalocean/compute/server.js @@ -1,7 +1,7 @@ /* * server.js: DigitalOcean Server * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/digitalocean/index.js b/lib/pkgcloud/digitalocean/index.js index a29a0083d..b54da38e5 100644 --- a/lib/pkgcloud/digitalocean/index.js +++ b/lib/pkgcloud/digitalocean/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the DigitalOcean module. * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/client.js b/lib/pkgcloud/google/client.js index f6d28852f..278926fe5 100644 --- a/lib/pkgcloud/google/client.js +++ b/lib/pkgcloud/google/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all Google Cloud Storage clients inherit from * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/index.js b/lib/pkgcloud/google/index.js index 81bc6dca1..c0ab50782 100644 --- a/lib/pkgcloud/google/index.js +++ b/lib/pkgcloud/google/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Google Cloud Storage module. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/storage/client/containers.js b/lib/pkgcloud/google/storage/client/containers.js index 22ed03797..94e3561bc 100644 --- a/lib/pkgcloud/google/storage/client/containers.js +++ b/lib/pkgcloud/google/storage/client/containers.js @@ -1,7 +1,7 @@ /* * containers.js: Instance methods for working with containers from Google Cloud Storage * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index 28312fec9..a8606d844 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -1,7 +1,7 @@ /* * files.js: Instance methods for working with files from Google Cloud Storage * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/storage/client/index.js b/lib/pkgcloud/google/storage/client/index.js index 1e33438d3..f883eff52 100644 --- a/lib/pkgcloud/google/storage/client/index.js +++ b/lib/pkgcloud/google/storage/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Storage client for Google Cloud Storage * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/storage/container.js b/lib/pkgcloud/google/storage/container.js index 749be4ef9..742c52ba6 100644 --- a/lib/pkgcloud/google/storage/container.js +++ b/lib/pkgcloud/google/storage/container.js @@ -1,7 +1,7 @@ /* * container.js: Google Cloud Storage Bucket * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/storage/file.js b/lib/pkgcloud/google/storage/file.js index fd02419ef..157c0afa2 100644 --- a/lib/pkgcloud/google/storage/file.js +++ b/lib/pkgcloud/google/storage/file.js @@ -1,7 +1,7 @@ /* * container.js: Google Cloud Storage File * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/google/storage/index.js b/lib/pkgcloud/google/storage/index.js index 56fe6741d..c87d08a46 100644 --- a/lib/pkgcloud/google/storage/index.js +++ b/lib/pkgcloud/google/storage/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Google Cloud Storage module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/iriscouch/database/client/index.js b/lib/pkgcloud/iriscouch/database/client/index.js index 62fcfb531..5a1c8c6d7 100644 --- a/lib/pkgcloud/iriscouch/database/client/index.js +++ b/lib/pkgcloud/iriscouch/database/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Database client for Iriscouch Cloud Databases * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/iriscouch/database/index.js b/lib/pkgcloud/iriscouch/database/index.js index c34a775e7..21a66c674 100644 --- a/lib/pkgcloud/iriscouch/database/index.js +++ b/lib/pkgcloud/iriscouch/database/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Iriscouch database module * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/iriscouch/index.js b/lib/pkgcloud/iriscouch/index.js index b0c730580..025267972 100644 --- a/lib/pkgcloud/iriscouch/index.js +++ b/lib/pkgcloud/iriscouch/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the iriscouch module. * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/client.js b/lib/pkgcloud/joyent/client.js index 77a5ce136..7e3785d94 100644 --- a/lib/pkgcloud/joyent/client.js +++ b/lib/pkgcloud/joyent/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all Joyent clients inherit from * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/compute/client/flavors.js b/lib/pkgcloud/joyent/compute/client/flavors.js index 31c4be0d1..16031db75 100644 --- a/lib/pkgcloud/joyent/compute/client/flavors.js +++ b/lib/pkgcloud/joyent/compute/client/flavors.js @@ -1,7 +1,7 @@ /* * flavors.js: Implementation of Joyent Flavors Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/compute/client/images.js b/lib/pkgcloud/joyent/compute/client/images.js index bf28da777..2d597b23d 100644 --- a/lib/pkgcloud/joyent/compute/client/images.js +++ b/lib/pkgcloud/joyent/compute/client/images.js @@ -1,7 +1,7 @@ /* * images.js: Implementation of Joyent Images Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var pkgcloud = require('../../../../../lib/pkgcloud'), diff --git a/lib/pkgcloud/joyent/compute/client/index.js b/lib/pkgcloud/joyent/compute/client/index.js index 4524cd411..b7279010a 100644 --- a/lib/pkgcloud/joyent/compute/client/index.js +++ b/lib/pkgcloud/joyent/compute/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Compute client for Joyent CloudAPI * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/compute/client/keys.js b/lib/pkgcloud/joyent/compute/client/keys.js index 71e5d3989..0852ffd30 100644 --- a/lib/pkgcloud/joyent/compute/client/keys.js +++ b/lib/pkgcloud/joyent/compute/client/keys.js @@ -1,7 +1,7 @@ /* * keys.js: Implementation of Joyent SSH keys Client. * - * (C) 2012, Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js index dd29c180c..2410071e8 100644 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ b/lib/pkgcloud/joyent/compute/client/servers.js @@ -1,7 +1,7 @@ /* * servers.js: Instance methods for working with servers from Joyent Cloud * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var base = require('../../../core/compute'), diff --git a/lib/pkgcloud/joyent/compute/flavor.js b/lib/pkgcloud/joyent/compute/flavor.js index 83372eaa7..0bc44f4e8 100644 --- a/lib/pkgcloud/joyent/compute/flavor.js +++ b/lib/pkgcloud/joyent/compute/flavor.js @@ -1,7 +1,7 @@ /* * flavor.js: Joyent Cloud Package * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/compute/image.js b/lib/pkgcloud/joyent/compute/image.js index 04766ebfa..d7a211809 100644 --- a/lib/pkgcloud/joyent/compute/image.js +++ b/lib/pkgcloud/joyent/compute/image.js @@ -1,7 +1,7 @@ /* * image.js: Joyent Cloud DataSet * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/compute/index.js b/lib/pkgcloud/joyent/compute/index.js index 7ad4ff846..e0f98f06e 100644 --- a/lib/pkgcloud/joyent/compute/index.js +++ b/lib/pkgcloud/joyent/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Joyent compute module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/compute/server.js b/lib/pkgcloud/joyent/compute/server.js index 02b132f27..55aa7d0c6 100644 --- a/lib/pkgcloud/joyent/compute/server.js +++ b/lib/pkgcloud/joyent/compute/server.js @@ -1,7 +1,7 @@ /* * server.js: Joyent Cloud Machine * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/joyent/index.js b/lib/pkgcloud/joyent/index.js index a6bed7e82..65303f64a 100644 --- a/lib/pkgcloud/joyent/index.js +++ b/lib/pkgcloud/joyent/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Joyent module. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongohq/database/client/databases.js b/lib/pkgcloud/mongohq/database/client/databases.js index c227130a1..c058d450b 100644 --- a/lib/pkgcloud/mongohq/database/client/databases.js +++ b/lib/pkgcloud/mongohq/database/client/databases.js @@ -1,7 +1,7 @@ /* * database.js: Database methods for working with databases from MongoHQ * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongohq/database/client/index.js b/lib/pkgcloud/mongohq/database/client/index.js index 6cbfed270..e185247ef 100644 --- a/lib/pkgcloud/mongohq/database/client/index.js +++ b/lib/pkgcloud/mongohq/database/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Database client for MongoHQ Cloud Databases * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongohq/database/index.js b/lib/pkgcloud/mongohq/database/index.js index f5d03971d..0ea136bfd 100644 --- a/lib/pkgcloud/mongohq/database/index.js +++ b/lib/pkgcloud/mongohq/database/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the MongoHQ database module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongohq/index.js b/lib/pkgcloud/mongohq/index.js index 63b085d8b..872150b4c 100644 --- a/lib/pkgcloud/mongohq/index.js +++ b/lib/pkgcloud/mongohq/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the mongohq module. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongolab/database/client/accounts.js b/lib/pkgcloud/mongolab/database/client/accounts.js index cb3d819a1..a03ae7692 100644 --- a/lib/pkgcloud/mongolab/database/client/accounts.js +++ b/lib/pkgcloud/mongolab/database/client/accounts.js @@ -1,7 +1,7 @@ /* * accounts.js: Accounts methods for working with databases from MongoLab * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongolab/database/client/databases.js b/lib/pkgcloud/mongolab/database/client/databases.js index 790eca37e..3ec9b8004 100644 --- a/lib/pkgcloud/mongolab/database/client/databases.js +++ b/lib/pkgcloud/mongolab/database/client/databases.js @@ -1,7 +1,7 @@ /* * database.js: Database methods for working with databases from MongoLab * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongolab/database/client/index.js b/lib/pkgcloud/mongolab/database/client/index.js index 648c70ef6..937afe6c3 100644 --- a/lib/pkgcloud/mongolab/database/client/index.js +++ b/lib/pkgcloud/mongolab/database/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Database client for MongoLab databases * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongolab/database/index.js b/lib/pkgcloud/mongolab/database/index.js index 6ef8ab5b8..06eb5768e 100644 --- a/lib/pkgcloud/mongolab/database/index.js +++ b/lib/pkgcloud/mongolab/database/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the MongoLab database module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/mongolab/index.js b/lib/pkgcloud/mongolab/index.js index 1ee6d28cf..644ab6d7b 100644 --- a/lib/pkgcloud/mongolab/index.js +++ b/lib/pkgcloud/mongolab/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the MongoLab module. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 9bd3da46c..ecdc4c415 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all OpenStack clients inherit from * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/compute/client/extensions/keys.js b/lib/pkgcloud/openstack/compute/client/extensions/keys.js index 9bbcf37ce..befaa39fc 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/keys.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/keys.js @@ -1,7 +1,7 @@ /* * keys.js Implementation of OpenStack KeyPair API * - * (C) 2013, Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/compute/client/flavors.js b/lib/pkgcloud/openstack/compute/client/flavors.js index a4f804fdb..7fc133870 100644 --- a/lib/pkgcloud/openstack/compute/client/flavors.js +++ b/lib/pkgcloud/openstack/compute/client/flavors.js @@ -1,7 +1,7 @@ /* * flavors.js: Implementation of OpenStack Flavors Client. * - * (C) 2013, Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var pkgcloud = require('../../../../../lib/pkgcloud'), diff --git a/lib/pkgcloud/openstack/compute/client/images.js b/lib/pkgcloud/openstack/compute/client/images.js index 4492fd1fb..6132c7131 100644 --- a/lib/pkgcloud/openstack/compute/client/images.js +++ b/lib/pkgcloud/openstack/compute/client/images.js @@ -1,7 +1,7 @@ /* * images.js: Implementation of OpenStack Images Client. * - * (C) 2013, Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var pkgcloud = require('../../../../../lib/pkgcloud'), diff --git a/lib/pkgcloud/openstack/compute/client/index.js b/lib/pkgcloud/openstack/compute/client/index.js index 061a23097..3b18fab4e 100644 --- a/lib/pkgcloud/openstack/compute/client/index.js +++ b/lib/pkgcloud/openstack/compute/client/index.js @@ -1,7 +1,7 @@ /* * index.js: Compute client for OpenStack * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index 8407eef6d..da6563b48 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -1,7 +1,7 @@ /* * servers.js: Instance methods for working with servers from OpenStack Cloud * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ var base = require('../../../core/compute'), diff --git a/lib/pkgcloud/openstack/compute/flavor.js b/lib/pkgcloud/openstack/compute/flavor.js index 956cb86a7..f29e39479 100644 --- a/lib/pkgcloud/openstack/compute/flavor.js +++ b/lib/pkgcloud/openstack/compute/flavor.js @@ -1,7 +1,7 @@ /* * flavor.js: OpenStack Cloud flavor * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/compute/image.js b/lib/pkgcloud/openstack/compute/image.js index 257cf484d..0db81aae7 100644 --- a/lib/pkgcloud/openstack/compute/image.js +++ b/lib/pkgcloud/openstack/compute/image.js @@ -1,7 +1,7 @@ /* * image.js: OpenStack Cloud image * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/compute/index.js b/lib/pkgcloud/openstack/compute/index.js index de5f78fb9..05e66dbb5 100644 --- a/lib/pkgcloud/openstack/compute/index.js +++ b/lib/pkgcloud/openstack/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the OpenStack compute module * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/compute/server.js b/lib/pkgcloud/openstack/compute/server.js index 47e9d69e2..28b87f0fb 100644 --- a/lib/pkgcloud/openstack/compute/server.js +++ b/lib/pkgcloud/openstack/compute/server.js @@ -1,7 +1,7 @@ /* * server.js: OpenStack Cloud server * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/context/index.js b/lib/pkgcloud/openstack/context/index.js index a4b7aefac..aa36ee91d 100644 --- a/lib/pkgcloud/openstack/context/index.js +++ b/lib/pkgcloud/openstack/context/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the OpenStack identity module * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/identity/index.js b/lib/pkgcloud/openstack/identity/index.js index 9081e1127..72822bf84 100644 --- a/lib/pkgcloud/openstack/identity/index.js +++ b/lib/pkgcloud/openstack/identity/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the OpenStack identity module * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/openstack/index.js b/lib/pkgcloud/openstack/index.js index 719b099a2..5f46ad2f0 100644 --- a/lib/pkgcloud/openstack/index.js +++ b/lib/pkgcloud/openstack/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the OpenStack module. * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/client.js b/lib/pkgcloud/rackspace/client.js index d5983e844..f3b1da359 100644 --- a/lib/pkgcloud/rackspace/client.js +++ b/lib/pkgcloud/rackspace/client.js @@ -1,7 +1,7 @@ /* * client.js: Base client from which all Rackspace clients inherit from * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/compute/client/index.js b/lib/pkgcloud/rackspace/compute/client/index.js index 352c7c4b9..f15a80ad9 100644 --- a/lib/pkgcloud/rackspace/compute/client/index.js +++ b/lib/pkgcloud/rackspace/compute/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Compute client for Rackspace Cloudservers * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/compute/index.js b/lib/pkgcloud/rackspace/compute/index.js index 0fd03d94d..516538712 100644 --- a/lib/pkgcloud/rackspace/compute/index.js +++ b/lib/pkgcloud/rackspace/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Rackspace compute module * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/database/client/index.js b/lib/pkgcloud/rackspace/database/client/index.js index 4945fe569..51b3c93df 100644 --- a/lib/pkgcloud/rackspace/database/client/index.js +++ b/lib/pkgcloud/rackspace/database/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Database client for Rackspace Cloud Databases * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/database/index.js b/lib/pkgcloud/rackspace/database/index.js index f09c0df3f..df1a07b33 100644 --- a/lib/pkgcloud/rackspace/database/index.js +++ b/lib/pkgcloud/rackspace/database/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Rackspace database module * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/index.js b/lib/pkgcloud/rackspace/index.js index 050f14f40..afd0d2580 100644 --- a/lib/pkgcloud/rackspace/index.js +++ b/lib/pkgcloud/rackspace/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Rackspace module. * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index 600587a40..f2883f3e7 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -1,7 +1,7 @@ /* * cdn-containers.js: Instance methods for working with containers from Rackspace Cloudfiles * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/rackspace/storage/client/index.js b/lib/pkgcloud/rackspace/storage/client/index.js index 8797a9818..8e7e1bd04 100644 --- a/lib/pkgcloud/rackspace/storage/client/index.js +++ b/lib/pkgcloud/rackspace/storage/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Compute client for Rackspace Cloudservers * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/redistogo/database/client/index.js b/lib/pkgcloud/redistogo/database/client/index.js index 73c8ebb48..8855eab9b 100644 --- a/lib/pkgcloud/redistogo/database/client/index.js +++ b/lib/pkgcloud/redistogo/database/client/index.js @@ -1,7 +1,7 @@ /* * client.js: Database client for RedisToGo Cloud Databases * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/redistogo/database/index.js b/lib/pkgcloud/redistogo/database/index.js index 213bca089..5ce4296b4 100644 --- a/lib/pkgcloud/redistogo/database/index.js +++ b/lib/pkgcloud/redistogo/database/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the RedisToGo database module * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/redistogo/index.js b/lib/pkgcloud/redistogo/index.js index 7fbc67c26..c523d9448 100644 --- a/lib/pkgcloud/redistogo/index.js +++ b/lib/pkgcloud/redistogo/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the RedisToGo module. * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/telefonica/compute/client.js b/lib/pkgcloud/telefonica/compute/client.js index c7c84e969..84e182072 100644 --- a/lib/pkgcloud/telefonica/compute/client.js +++ b/lib/pkgcloud/telefonica/compute/client.js @@ -1,7 +1,7 @@ /* * index.js: Compute client for Telefonica InstantServers CloudAPI * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/telefonica/compute/index.js b/lib/pkgcloud/telefonica/compute/index.js index 1e48156f6..fba2e8848 100644 --- a/lib/pkgcloud/telefonica/compute/index.js +++ b/lib/pkgcloud/telefonica/compute/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Telefonica compute module * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/lib/pkgcloud/telefonica/index.js b/lib/pkgcloud/telefonica/index.js index 3c0872103..fb52f1e4d 100644 --- a/lib/pkgcloud/telefonica/index.js +++ b/lib/pkgcloud/telefonica/index.js @@ -1,7 +1,7 @@ /* * index.js: Top-level include for the Telefonica module. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/package.json b/package.json index 446401e85..82a018633 100644 --- a/package.json +++ b/package.json @@ -2,16 +2,16 @@ "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", "version": "1.1.0", - "author": "Nodejitsu Inc ", + "author": "Charlie Robbins ", "contributors": [ - { - "name": "Charlie Robbins", - "email": "charlie@nodejitsu.com" - }, { "name": "Nuno Job", "email": "nuno@nodejitsu.com" }, + { + "name": "Maciej Malecki", + "email": "me@mmalecki.com" + }, { "name": "Daniel Aristizabal", "email": "daniel@nodejitsu.com" @@ -19,6 +19,10 @@ { "name": "Ken Perkins", "email": "ken.perkins@rackspace.com" + }, + { + "name": "Ross Kukulinski", + "email": "ross@getyodlr.com" } ], "repository": { diff --git a/test/common/base/client-test.js b/test/common/base/client-test.js index 372c74bb7..ff362f739 100644 --- a/test/common/base/client-test.js +++ b/test/common/base/client-test.js @@ -1,7 +1,7 @@ /* * client-test.js: Tests for pkgcloud base client * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index ad7a43f2b..c5d5cb847 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -1,7 +1,7 @@ /* * base-test.js: Test that should be common to all providers. * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/common/compute/meta-test.js b/test/common/compute/meta-test.js index 1c08571a9..f0fefc7ca 100644 --- a/test/common/compute/meta-test.js +++ b/test/common/compute/meta-test.js @@ -1,7 +1,7 @@ /* * meta-test.js: Openstack updateImageMeta() function test . * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ @@ -85,9 +85,9 @@ providers.filter(function (provider) { server: hockInstance }); } - + var testMetadata = {os_type: 'windows'}; - + client.updateImageMeta(context.images[0].id, testMetadata, function (err, reply) { should.not.exist(err); should.exist(reply); diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index f84f5eb07..28af428ae 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -1,7 +1,7 @@ /* * server-test.js: Test that should be common to all providers. * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/common/compute/signature-test.js b/test/common/compute/signature-test.js index 2f072b10e..fd1e0c70b 100644 --- a/test/common/compute/signature-test.js +++ b/test/common/compute/signature-test.js @@ -1,7 +1,7 @@ /* * signature-test.js: Test that shared methods meet some expectations for arguments. * - * (C) 2013 Nodejitsu Inc. + * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index bf1c1982e..f1c0a2f7f 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -1,7 +1,7 @@ /* * base-test.js: Test that should be common to all providers. * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index 0b275eb7f..12cede66a 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -1,7 +1,7 @@ /* * base-test.js: Test that should be common to all providers. * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/hp/macros.js b/test/hp/macros.js index 910703197..55499c2f0 100644 --- a/test/hp/macros.js +++ b/test/hp/macros.js @@ -1,7 +1,7 @@ /* * macros.js: Tests macros for Rackspace * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js index efe2a1ab1..93b1adaab 100644 --- a/test/iriscouch/databases/databases-redis-test.js +++ b/test/iriscouch/databases/databases-redis-test.js @@ -1,7 +1,7 @@ /* * databases-redis-test.js: Tests for IrisCouch Redis database service * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ @@ -33,7 +33,7 @@ describe('pkgcloud/iriscouch/databases-redis', function () { it('the create() method with correct options should respond correctly', function(done) { var subdomain = (mock ? 'nodejitsudb43639' : 'nodejitsudb' + Math.floor(Math.random() * 100000)); context.tempPassword = (mock ? 'sTTi:lh9vCF[' : randomPassword(12).replace('\\', '')); - + if (mock) { hockInstance .post('/hosting_public', helpers.loadFixture('iriscouch/database-redis.json')) @@ -42,7 +42,7 @@ describe('pkgcloud/iriscouch/databases-redis', function () { rev: '1-63cf360ebc115cdc8a709a910fdef6d7' }); } - + client.create({ subdomain: subdomain, first_name: 'Marak', diff --git a/test/iriscouch/databases/databases-test.js b/test/iriscouch/databases/databases-test.js index 407221eba..ebf635c73 100644 --- a/test/iriscouch/databases/databases-test.js +++ b/test/iriscouch/databases/databases-test.js @@ -1,7 +1,7 @@ /* * databases-test.js: Tests for IrisCouch database service * - * (C) 2012 Nodejitsu Inc. + * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ diff --git a/test/mongohq/databases/databases-test.js b/test/mongohq/databases/databases-test.js index 4a360439d..7ca4726b5 100644 --- a/test/mongohq/databases/databases-test.js +++ b/test/mongohq/databases/databases-test.js @@ -1,7 +1,7 @@ /* * databases-test.js: Tests for MongoHQ databases service * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js index 528409f42..ffd0fd866 100644 --- a/test/mongolab/databases/databases-test.js +++ b/test/mongolab/databases/databases-test.js @@ -1,7 +1,7 @@ /* * databases-test.js: Tests for MongoLab databases service * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ @@ -117,7 +117,7 @@ describe('pkgcloud/mongolab/databases', function () { }); it('with numbers should respond with success', function(done) { - + if (mock) { hockInstance .post('/api/1/partners/nodejitsu/accounts', { @@ -129,7 +129,7 @@ describe('pkgcloud/mongolab/databases', function () { }) .reply(200, helpers.loadFixture('mongolab/customUser.json')); } - + client.createAccount({ name: 'custompassword', email: 'custom@password.com', @@ -149,7 +149,7 @@ describe('pkgcloud/mongolab/databases', function () { }); it('the getAccounts() method should respond with all accounts', function(done) { - + if (mock) { hockInstance .get('/api/1/partners/nodejitsu/accounts') @@ -170,7 +170,7 @@ describe('pkgcloud/mongolab/databases', function () { done(); }); }); - + it('the getAccount() method should return the matching account', function(done) { if (mock) { @@ -194,7 +194,7 @@ describe('pkgcloud/mongolab/databases', function () { hockInstance && hockInstance.done(); done(); }); - + }); it('the create() method with correct options should respond correctly', function (done) { @@ -266,7 +266,7 @@ describe('pkgcloud/mongolab/databases', function () { databases[0].should.be.a.Object; databases[0].name.should.equal(context.account.username + '_testDatabase'); context.databaseName = databases[0].name; - + hockInstance && hockInstance.done(); done(); }); diff --git a/test/rackspace/compute/authentication-test.js b/test/rackspace/compute/authentication-test.js index df884616f..4262a808a 100644 --- a/test/rackspace/compute/authentication-test.js +++ b/test/rackspace/compute/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud Rackspace compute authentication * -* (C) 2010 Nodejitsu Inc. +* (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/rackspace/compute/image-test.js b/test/rackspace/compute/image-test.js index 549518e6a..6a43da9cb 100644 --- a/test/rackspace/compute/image-test.js +++ b/test/rackspace/compute/image-test.js @@ -1,7 +1,7 @@ /* * image-test.js: Tests for pkgcloud Rackspace compute image requests * -* (C) 2010-2012 Nodejitsu Inc. +* (C) 2010-2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ @@ -94,7 +94,7 @@ describe('pkgcloud/rackspace/compute/images', function () { done(); }); }); - + after(function(done) { if (mock) { diff --git a/test/rackspace/compute/personality-test.js b/test/rackspace/compute/personality-test.js index c44e8369d..98f2dbdc8 100644 --- a/test/rackspace/compute/personality-test.js +++ b/test/rackspace/compute/personality-test.js @@ -2,7 +2,7 @@ * personality-test.js: tests cloudserver's ability to add files * to a server's filesystem during creationg * -* (C) 2010 Nodejitsu Inc. +* (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ diff --git a/test/rackspace/databases/authentication-test.js b/test/rackspace/databases/authentication-test.js index 63aecd34f..8940ca076 100644 --- a/test/rackspace/databases/authentication-test.js +++ b/test/rackspace/databases/authentication-test.js @@ -2,7 +2,7 @@ /* * authentication-test.js: Tests for pkgcloud Rackspace compute authentication * - * (C) 2010 Nodejitsu Inc. + * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js index e6debdded..a92a773d7 100644 --- a/test/rackspace/databases/user-limit-test.js +++ b/test/rackspace/databases/user-limit-test.js @@ -1,7 +1,7 @@ /* * users-limit-test.js: Tests for Cloud Database users within an instace * - * (C) 2010 Nodejitsu Inc. + * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ diff --git a/test/rackspace/macros.js b/test/rackspace/macros.js index 910703197..55499c2f0 100644 --- a/test/rackspace/macros.js +++ b/test/rackspace/macros.js @@ -1,7 +1,7 @@ /* * macros.js: Tests macros for Rackspace * - * (C) 2011 Nodejitsu Inc. + * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/rackspace/storage/authentication-test.js b/test/rackspace/storage/authentication-test.js index ce5a23ea4..7271f9102 100644 --- a/test/rackspace/storage/authentication-test.js +++ b/test/rackspace/storage/authentication-test.js @@ -1,7 +1,7 @@ /* * authentication-test.js: Tests for pkgcloud Rackspace storage authentication * -* (C) 2010 Nodejitsu Inc. +* (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * */ diff --git a/test/rackspace/storage/container-test.js b/test/rackspace/storage/container-test.js index d2ba58849..a13c53f67 100755 --- a/test/rackspace/storage/container-test.js +++ b/test/rackspace/storage/container-test.js @@ -1,7 +1,7 @@ /* * container-test.js: Tests for Rackspace Cloudfiles containers * -* (C) 2010 Nodejitsu Inc. +* (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ diff --git a/test/rackspace/storage/storage-object-large-test.js b/test/rackspace/storage/storage-object-large-test.js index 06bf43a21..495f5c367 100755 --- a/test/rackspace/storage/storage-object-large-test.js +++ b/test/rackspace/storage/storage-object-large-test.js @@ -1,7 +1,7 @@ /* * container-test.js: Tests for Rackspace Cloudfiles containers * - * (C) 2010 Nodejitsu Inc. + * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ diff --git a/test/rackspace/storage/storage-object-metadata-test.js b/test/rackspace/storage/storage-object-metadata-test.js index 0eb9decd6..e98f98352 100755 --- a/test/rackspace/storage/storage-object-metadata-test.js +++ b/test/rackspace/storage/storage-object-metadata-test.js @@ -1,7 +1,7 @@ /* * container-test.js: Tests for Rackspace Cloudfiles containers * - * (C) 2010 Nodejitsu Inc. + * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ diff --git a/test/rackspace/storage/storage-object-noauth-test.js b/test/rackspace/storage/storage-object-noauth-test.js index 37e3bbad9..82bb189aa 100644 --- a/test/rackspace/storage/storage-object-noauth-test.js +++ b/test/rackspace/storage/storage-object-noauth-test.js @@ -1,7 +1,7 @@ ///* // * storage-object-test.js: Tests for uploading files to Rackspace Cloudfiles when not authenticated. // * -// * (C) 2010 Nodejitsu Inc. +// * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. // * MIT LICENSE // * // */ diff --git a/test/rackspace/storage/storage-object-test.js b/test/rackspace/storage/storage-object-test.js index be7610e77..2b332e7b8 100755 --- a/test/rackspace/storage/storage-object-test.js +++ b/test/rackspace/storage/storage-object-test.js @@ -1,7 +1,7 @@ /* * storage-object-test.js: Tests for Rackspace Cloudfiles containers * - * (C) 2010 Nodejitsu Inc. + * (C) 2010 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ @@ -249,11 +249,11 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { }); it('extract should ask server to extract the uploaded tar file', function(done) { - + var data = 'H4sIABub81EAA+3TzUrEMBAH8CiIeNKTXvMC1nxuVzx58CiC9uBNam1kQZt1N4X1XXwDX9IJXVi6UDxo6sH/D4akadJOmY7z/owlJkhubTdOulEo040dJpXMTS6tjuuSriTjNnViUbsM5YJztvCPs+atHdxH25wbI6FxOap/9hDqZcjCKqR5RyzwxJjB+iurN/WXiuqvpdGMizTp9P3z+rO94322y9h1WfGbO37P1+IaO6BQFO8U8fqzd/Jo6JGXRXG7nsYTHxSHW1t2NusnlX/Nyvn8pc6KehWumso/zZpnutkGdzq9kNrQv3E+Nb/yudAX+z9t93/f/0LIrf5XNEP/j0H+dQIAAAAAAAAAAAAAAAAAAADwY194ELb5ACgAAA=='; var tmp = './foo.tar.gz'; fs.writeFileSync(tmp, new Buffer(data, 'base64')); - + if (mock) { authHockInstance .post('/v2.0/tokens', { @@ -270,27 +270,27 @@ describe('pkgcloud/rackspace/storage/storage-object', function () { .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00?extract-archive=tar.gz', new Buffer(data, 'base64').toString()) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/extract.json'); } - - - + + + client.extract({ local: tmp }, function(e, ok, resp) { should.not.exist(e); should.exist(resp); hockInstance && hockInstance.done(); - + fs.unlinkSync(tmp); done(); }); - + }); after(function (done) { if (!mock) { return done(); } - + async.parallel([ function (next) { diff --git a/test/redistogo/databases/databases-test.js b/test/redistogo/databases/databases-test.js index 03f85ef14..4459f668b 100644 --- a/test/redistogo/databases/databases-test.js +++ b/test/redistogo/databases/databases-test.js @@ -1,7 +1,7 @@ /* * databases-test.js: Tests for Redistogo databases service * -* (C) 2012 Nodejitsu Inc. +* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. * MIT LICENSE * */ From dc25de04dca2afaa17bb52429ecd2a6cbeff3b98 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 12 Mar 2015 11:19:50 -0700 Subject: [PATCH 377/460] Removing flavor from rebuild API as it is not supported. --- docs/providers/openstack/compute.md | 1 - docs/providers/rackspace/compute.md | 1 - lib/pkgcloud/openstack/compute/client/servers.js | 2 -- test/openstack/compute/client/rebuildServer-test.js | 3 +-- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/providers/openstack/compute.md b/docs/providers/openstack/compute.md index 0a69d6281..d687f9530 100644 --- a/docs/providers/openstack/compute.md +++ b/docs/providers/openstack/compute.md @@ -70,7 +70,6 @@ Options include: ```js { image: '45a01744-2bcf-4a23-ae88-63317f768a2f', // required; image ID or instance of pkgcloud.core.compute.Image - flavor: '2', // optional; flavor ID or instance of pkgcloud.core.compute.Flavor accessIPv4: '123.45.67.89' // optional; IPv4 address of server accessIPv6: 'f0::09', // optional; IPv6 address of server adminPass: 'foobar', // optional; administrator password for the server diff --git a/docs/providers/rackspace/compute.md b/docs/providers/rackspace/compute.md index 198f169f4..2cb5746b5 100644 --- a/docs/providers/rackspace/compute.md +++ b/docs/providers/rackspace/compute.md @@ -72,7 +72,6 @@ Options include: ```js { image: '45a01744-2bcf-4a23-ae88-63317f768a2f', // required; image ID or instance of pkgcloud.core.compute.Image - flavor: '2', // optional; flavor ID or instance of pkgcloud.core.compute.Flavor accessIPv4: '123.45.67.89' // optional; IPv4 address of server accessIPv6: 'f0::09', // optional; IPv6 address of server adminPass: 'foobar', // optional; administrator password for the server diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index 48419b341..be8efb054 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -278,7 +278,6 @@ exports.rebootServer = function rebootServer(server, options, callback) { * @param {String|object} server The server or serverId to rebuild * @param {String|object} options The image or imageId to use in the rebuild (for backwards compatibility) * @param {String|object} options.image The image or imageId to use in the rebuild - * @param {String|object} options.flavor The flavor or flavorId to use in the rebuild * @param {String} options.accessIPv4 The IP version 4 address of the server. * @param {String} options.accessIPv6 The IP version 6 address of the server. * @param {String} options.adminPass The administrator password for the server. @@ -305,7 +304,6 @@ exports.rebuildServer = function rebootServer(server, options, callback) { 'personality' ]); rebuildBody.imageRef = options.image instanceof base.Image ? options.image.id : options.image; - rebuildBody.flavorRef = options.flavor instanceof base.Flavor ? options.flavor.id : options.flavor; } else { // Image ID was passed in as options (backwards compatible) rebuildBody.imageRef = options; diff --git a/test/openstack/compute/client/rebuildServer-test.js b/test/openstack/compute/client/rebuildServer-test.js index 5f91e1506..4b276782d 100644 --- a/test/openstack/compute/client/rebuildServer-test.js +++ b/test/openstack/compute/client/rebuildServer-test.js @@ -94,7 +94,6 @@ describe('pkgcloud/openstack/compute/server[openstack]', function() { var options = { image: 'd42f821e-c2d1-4796-9f07-af5ed7912d0e', - flavor: '2', adminPass: 'foobar' }; client.rebuildServer('a2e90ecb69c44d0296072ea39e53704a', options, function (err) { @@ -163,6 +162,6 @@ setupRebuildServerWithImageObjMock = function(servers) { setupRebuildServerWithOptionsMock = function(servers) { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', - { 'rebuild': { 'adminPass': 'foobar', 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e', 'flavorRef': '2' } }) + { 'rebuild': { 'adminPass': 'foobar', 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e' } }) .reply(202, ''); }; From 623b7212e996a4ede9a59d0ae8810b464516d235 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 12 Mar 2015 11:23:00 -0700 Subject: [PATCH 378/460] Un-tabifying. --- .../compute/client/rebuildServer-test.js | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test/openstack/compute/client/rebuildServer-test.js b/test/openstack/compute/client/rebuildServer-test.js index 4b276782d..51a677f8a 100644 --- a/test/openstack/compute/client/rebuildServer-test.js +++ b/test/openstack/compute/client/rebuildServer-test.js @@ -63,7 +63,7 @@ describe('pkgcloud/openstack/compute/server[openstack]', function() { done(); }); - }); + }); it('the server.rebuildServer() method with image object should rebuild a server instance', function (done) { if (mock) { @@ -82,7 +82,7 @@ describe('pkgcloud/openstack/compute/server[openstack]', function() { done(); }); - }); + }); it('the server.rebuildServer() method with options should rebuild a server instance', function (done) { if (mock) { @@ -104,7 +104,7 @@ describe('pkgcloud/openstack/compute/server[openstack]', function() { done(); }); - }); + }); after(function (done) { if (!mock) { @@ -123,45 +123,45 @@ describe('pkgcloud/openstack/compute/server[openstack]', function() { }); setupRebuildServerWithImageIdMock = function(servers) { - servers.authServer - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - } - } - }) - .replyWithFile(200, __dirname + '/../../../fixtures/openstack/initialToken.json') - .get('/v2.0/tenants') - .replyWithFile(200, __dirname + '/../../../fixtures/openstack/tenantId.json') - .post('/v2.0/tokens', { - auth: { - passwordCredentials: { - username: 'MOCK-USERNAME', - password: 'MOCK-PASSWORD' - }, - tenantId: '72e90ecb69c44d0296072ea39e537041' - } - }) - .reply(200, helpers.getOpenstackAuthResponse()); + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); - servers.server - .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', + servers.server + .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', { 'rebuild': { 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e' } }) - .reply(202, ''); + .reply(202, ''); }; setupRebuildServerWithImageObjMock = function(servers) { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', { 'rebuild': { 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e' } }) - .reply(202, ''); + .reply(202, ''); }; setupRebuildServerWithOptionsMock = function(servers) { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/servers/a2e90ecb69c44d0296072ea39e53704a/action', { 'rebuild': { 'adminPass': 'foobar', 'imageRef': 'd42f821e-c2d1-4796-9f07-af5ed7912d0e' } }) - .reply(202, ''); + .reply(202, ''); }; From cdd43b3e68c1440012c37f514c0a5d612404950c Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 12 Mar 2015 15:10:30 -0700 Subject: [PATCH 379/460] Allow deleteStack to accept stack object or stack name. --- .../openstack/orchestration/client/stacks.js | 37 +++-- .../orchestration/delete-stack-test.js | 141 ++++++++++++++++++ 2 files changed, 165 insertions(+), 13 deletions(-) create mode 100644 test/openstack/orchestration/delete-stack-test.js diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index fc5879a69..f108d28b5 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -294,20 +294,32 @@ exports.updateStack = function (stack, callback) { * @returns {request|*} */ exports.deleteStack = function (stack, callback) { - var path = stack instanceof orchestration.Stack - ? urlJoin(_urlPrefix, stack.name, stack.id) - : urlJoin(_urlPrefix, stack); + var self = this; - return this._request({ - path: path, - method: 'DELETE' - }, function (err) { - if (err) { - return callback(err); - } + var deleteStack = function(stack) { + return self._request({ + path: urlJoin(_urlPrefix, stack.name, stack.id), + method: 'DELETE' + }, function(err) { + if (err) { + return callback(err); + } + callback(err, true); + }); + }; - callback(err, true); - }); + if (typeof stack === 'string') { + self.getStack(stack, function(err, stack) { + if (err) { + return callback(err); + } + return deleteStack(stack); + }); + } else if (stack instanceof orchestration.Stack) { + return deleteStack(stack); + } else { + return callback(new Error('stack must be a string or stack instance')); + } }; /** @@ -355,4 +367,3 @@ exports.abandonStack = function (stack, callback) { abandon(stack); }; - diff --git a/test/openstack/orchestration/delete-stack-test.js b/test/openstack/orchestration/delete-stack-test.js new file mode 100644 index 000000000..a864f6910 --- /dev/null +++ b/test/openstack/orchestration/delete-stack-test.js @@ -0,0 +1,141 @@ +/* + * delete-stack-test.js: Unit tests for deleting OpenStack Orchestration (Heat) stacks + * + * (C) 2015 Rackspace + * Shaunak Kashyap + * MIT LICENSE + */ + +var helpers = require('../../helpers'); + +var should = require('should'), + async = require('async'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK, + Stack = require('../../../lib/pkgcloud/openstack/orchestration/stack').Stack; + +var client = helpers.createClient('openstack', 'orchestration'); + +// Declaring variables for helper functions defined later +var setupDeleteStackWithObjectMock, setupDeleteStackWithNameMock; + +describe('pkgcloud/openstack/orchestration/stacks[deleteStack]', function () { + + var authHockInstance, hockInstance, authServer, server; + + before(function (done) { + + if (!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + it('the deleteStack method with a stack object should delete the stack', function (done) { + if (mock) { + setupDeleteStackWithObjectMock({ + authServer: authHockInstance, + server: hockInstance + }); + } + + var stack = new Stack(client, { id: '87xxxx1-9xx9-4xxe-bxxf', stack_name: 'emptystack' }); + client.deleteStack(stack, function (err, success) { + should.not.exist(err); + success.should.equal(true); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the deleteStack method with a stack name should delete the stack', function (done) { + if (mock) { + setupDeleteStackWithNameMock({ + authServer: authHockInstance, + server: hockInstance + }); + } + + client.deleteStack('emptystack', function (err, success) { + should.not.exist(err); + success.should.equal(true); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); +}); + +setupDeleteStackWithObjectMock = function(servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .delete('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf') + .reply(204); +}; + +setupDeleteStackWithNameMock = function(servers) { + servers.server + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack') + .reply(302, null, { 'Location': '/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf' }) + .get('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf') + .reply(200, { stack: { id: '87xxxx1-9xx9-4xxe-bxxf', stack_name: 'emptystack' } }) + .delete('/v1/72e90ecb69c44d0296072ea39e537041/stacks/emptystack/87xxxx1-9xx9-4xxe-bxxf') + .reply(204); +}; From 89cfc1a1aa5135b66be0b6854356543d3acb84ee Mon Sep 17 00:00:00 2001 From: Meteor Date: Wed, 18 Mar 2015 00:18:02 +0800 Subject: [PATCH 380/460] Add abort function --- lib/pkgcloud/openstack/client.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 070e36e91..758ef84e1 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -199,6 +199,10 @@ Client.prototype._request = function (options, callback) { apiStream.abort(); }); + proxyStream.abort = function () { + apiStream.abort(); + }; + if (options.upload) { // needed for event propagation during proxied auth for streams From 551454fe2f9e9e6aa84ef12dcf303f2913ceb85c Mon Sep 17 00:00:00 2001 From: Kenta Fried Date: Thu, 19 Mar 2015 12:24:21 -0700 Subject: [PATCH 381/460] [dist] upgrade aws-sdk dependency to 2.1.17 to fix "memory usage bug when downloading objects from Amazon S3" --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82a018633..e4d558d1d 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ ], "dependencies": { "async": "0.9.x", - "aws-sdk": "~2.0.17", + "aws-sdk": "^2.1.17", "errs": "0.3.x", "eventemitter2": "0.4.x", "filed": "0.1.x", From f2a76ec3ae375abc33b1f5a3b7402126e1ca3134 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 25 Mar 2015 20:59:50 +0000 Subject: [PATCH 382/460] Typo: s/compute/network/ --- docs/providers/rackspace/network.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/rackspace/network.md b/docs/providers/rackspace/network.md index 7591d620c..e7b7592ad 100644 --- a/docs/providers/rackspace/network.md +++ b/docs/providers/rackspace/network.md @@ -3,7 +3,7 @@ Creating a client is straight-forward: ``` js - var rackspace = pkgcloud.compute.createClient({ + var rackspace = pkgcloud.network.createClient({ provider: 'rackspace', // required username: 'your-user-name', // required apiKey: 'your-api-key', // required From c88791fca287bdc78d560ab9303ee0c14e4bbf4f Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sat, 28 Mar 2015 23:04:20 -0700 Subject: [PATCH 383/460] Flip the keyId and key in Amazon examples Typical AWS examples and even the AWS interfaces that output access keys output the access key id first, then the secret key. This makes the examples confusing and likely someone will insert the wrong value for the wrong key. --- docs/providers/amazon.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/providers/amazon.md b/docs/providers/amazon.md index 44168835a..0790f8810 100644 --- a/docs/providers/amazon.md +++ b/docs/providers/amazon.md @@ -12,8 +12,8 @@ For all of the Amazon services, you create a client with the same options: ```Javascript var client = require('pkgcloud').compute.createClient({ provider: 'amazon', - key: 'your-secret-key-id', // secret key keyId: 'your-access-key-id', // access key id + key: 'your-secret-key-id', // secret key region: 'us-west-2' // region }); ``` @@ -21,8 +21,8 @@ var client = require('pkgcloud').compute.createClient({ ```Javascript var client = require('pkgcloud').storage.createClient({ provider: 'amazon', - key: 'your-secret-key-id', // secret key keyId: 'your-access-key-id', // access key id + key: 'your-secret-key-id', // secret key region: 'us-west-2' // region }); ``` From f2319aeb6d4f090db0cff4fe6e080096af4a1279 Mon Sep 17 00:00:00 2001 From: Tim Cuthbertson Date: Mon, 13 Apr 2015 11:49:28 +1000 Subject: [PATCH 384/460] amazon createServer: use pluralized keys for SecurityGroups/SecurityGroupIds Fixes #432 --- lib/pkgcloud/amazon/compute/client/servers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/amazon/compute/client/servers.js b/lib/pkgcloud/amazon/compute/client/servers.js index f100651c8..d2c070aee 100644 --- a/lib/pkgcloud/amazon/compute/client/servers.js +++ b/lib/pkgcloud/amazon/compute/client/servers.js @@ -154,12 +154,12 @@ exports.createServer = function createServer(options, callback) { securityGroup = this.securityGroup || options['SecurityGroup']; if (securityGroup) { - createOptions['SecurityGroup'] = securityGroup; + createOptions['SecurityGroups'] = [securityGroup]; } securityGroupId = this.securityGroupId || options['SecurityGroupId']; if (securityGroupId) { - createOptions['SecurityGroupId'] = securityGroupId; + createOptions['SecurityGroupIds'] = [securityGroupId]; } createOptions.ImageId = options.image instanceof base.Image From fc489f59a97283ef5db19881d3ef82cb95fa3135 Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 13 Apr 2015 08:15:19 -0700 Subject: [PATCH 385/460] Pinning to jshint 2.7.0 and fixing hinting errors --- lib/pkgcloud/openstack/orchestration/client/stacks.js | 4 ++-- lib/pkgcloud/openstack/storage/client/files.js | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index f108d28b5..eb6536d68 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -259,7 +259,7 @@ exports.adoptStack = function (details, callback) { * @returns {request|*} */ exports.updateStack = function (stack, callback) { - if (!stack instanceof orchestration.Stack) { + if (!(stack instanceof orchestration.Stack)) { callback(new Error('you must provide a stack to update')); return; } @@ -359,7 +359,7 @@ exports.abandonStack = function (stack, callback) { return; } - else if (!stack instanceof orchestration.stack) { + else if (!(stack instanceof orchestration.stack)) { callback(new Error('stack must be a string or stack instance')); return; } diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 33c018e33..dfab0d8c2 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -365,7 +365,7 @@ exports.updateFileMetadata = function (container, file, callback) { var self = this, containerName = container instanceof self.models.Container ? container.name : container; - if (!file instanceof base.File) { + if (!(file instanceof base.File)) { throw new Error('Must update an existing file instance'); } diff --git a/package.json b/package.json index e4d558d1d..2405b5705 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "blanket": "^1.1.6", "coveralls": "^2.11.2", "hock": "1.2.0", - "jshint": "2.x.x", + "jshint": "2.7.0", "mocha": "1.21.x", "mocha-lcov-reporter": "0.0.1", "should": "4.0.x" From 806474bed481b2f20564b9ddcb21f1c57d6fb73f Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Fri, 1 May 2015 11:37:35 -0500 Subject: [PATCH 386/460] auth: only set x-auth-project-id header if truthy This makes all tests pass on iojs. https://github.com/iojs/io.js/commit/979d0ca874df0383311ca06f154f6965074 196ee introduced throwing an error when the header value is undefined. --- lib/pkgcloud/common/auth.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/common/auth.js b/lib/pkgcloud/common/auth.js index 0a1dfa2f1..01a1b808b 100644 --- a/lib/pkgcloud/common/auth.js +++ b/lib/pkgcloud/common/auth.js @@ -24,7 +24,9 @@ auth.basic = function basicAuth(req) { // Add Account number for requests to rackspace API auth.accountId = function (req) { req.headers = req.headers || {}; - req.headers['x-auth-project-id'] = this.config.accountNumber; + if (this.config.accountNumber) { + req.headers['x-auth-project-id'] = this.config.accountNumber; + } }; function signatureGenerator(sign) { From fb9951e8cd260848d824e37ef5969453d9ce29f8 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Sun, 3 May 2015 12:16:00 -0500 Subject: [PATCH 387/460] [database]: use Array.isArray instead of typeof When running the rackspace databases example, it was failing until this was switched to using `Array.isArray`. Tests were also updated to confirm the fix. --- .../openstack/database/client/instances.js | 2 +- test/common/databases/instances-test.js | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/openstack/database/client/instances.js b/lib/pkgcloud/openstack/database/client/instances.js index 1b1a4b122..299184be3 100644 --- a/lib/pkgcloud/openstack/database/client/instances.js +++ b/lib/pkgcloud/openstack/database/client/instances.js @@ -45,7 +45,7 @@ exports.createInstance = function createInstance(options, callback) { // If the 'databases' are specified we create a template for each database name. if (options && options['databases'] && - typeof options['databases'] === 'array' && + Array.isArray(options['databases']) && options['databases'].length > 0) { options['databases'].forEach(function (item, idx) { if (typeof item === 'string') { diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index 82ee78d74..91c194ebe 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -68,7 +68,8 @@ providers.filter(function (provider) { client.createInstance({ name: 'test-instance', - flavor: flavor + flavor: flavor, + databases: ['db1'] }, function(e, i) { err = e; instance = i; @@ -487,7 +488,11 @@ setupCreateInstanceMock = function (hockInstance, provider) { instance: { name: 'test-instance', flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], + databases: [{ + name: 'db1', + character_set: 'utf8', + collate: 'utf8_general_ci' + }], volume: { size:1 } @@ -503,7 +508,11 @@ setupCreateInstanceMock = function (hockInstance, provider) { instance: { name: 'test-instance', flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], + databases: [{ + name: 'db1', + character_set: 'utf8', + collate: 'utf8_general_ci' + }], volume: { size:1 } @@ -519,7 +528,11 @@ setupCreateInstanceMock = function (hockInstance, provider) { instance: { name: 'test-instance', flavorRef: 'https://ord.databases.api.rackspacecloud.com/v1.0/123456/flavors/1', - databases: [], + databases: [{ + name: 'db1', + character_set: 'utf8', + collate: 'utf8_general_ci' + }], volume: { size:1 } From 2009acf74bc3190b29cd76af39f8d406314d84a3 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Sun, 3 May 2015 12:08:42 -0500 Subject: [PATCH 388/460] [database]: Add enableRootUser and listRootStatus Adds enableRootUser and listRootStatus for rackspace cloud databases. --- docs/providers/rackspace/databases.md | 30 ++++++++- .../openstack/database/client/instances.js | 67 +++++++++++++++++++ test/common/databases/instances-test.js | 64 +++++++++++++++++- 3 files changed, 159 insertions(+), 2 deletions(-) diff --git a/docs/providers/rackspace/databases.md b/docs/providers/rackspace/databases.md index 8ccf0a475..345347851 100644 --- a/docs/providers/rackspace/databases.md +++ b/docs/providers/rackspace/databases.md @@ -90,4 +90,32 @@ A user object is defined as follows: ``` **note**: If creating multiple users, the instance provided must be the same for -both. \ No newline at end of file +both. + +#### client.listRootStatus(instance, callback) + +Checks if the root user is enabled for the passed instance. + +```js +client.listRootStatus(instance, function (err, result) { + // handle err + console.log(result); // => { rootEnabled: true } +}); +``` + +#### client.enableRootUser(instance, callback) + +Enables the root user for the passed instance. + +```js +client.enableRootUser(instance, function (err, result) { + // handle err + console.log(result); + // => { + // => user: { + // => name: 'root', + // => password: '' + // => } + // => } +}); +``` diff --git a/lib/pkgcloud/openstack/database/client/instances.js b/lib/pkgcloud/openstack/database/client/instances.js index 1b1a4b122..1910c47a2 100644 --- a/lib/pkgcloud/openstack/database/client/instances.js +++ b/lib/pkgcloud/openstack/database/client/instances.js @@ -320,3 +320,70 @@ exports.setVolumeSize = function setVolumeSize(instance, newSize, callback) { }), callback); }); }; + +// Enable the root user for the given database instance. +// ### @instance {string | Object} The ID of the instance or a instance or Instance class (required) +// ### @callback {Function} Function to continue, the call is cb(error, res) +exports.enableRootUser = function enableRootUser(instance, callback) { + // Check for instance + if (typeof instance === 'function' || typeof instance === 'undefined') { + return errs.handle(errs.create({ + message: 'An instance is required.' + }), Array.prototype.slice.call(arguments).pop()); + } + + var instanceId = instance instanceof Instance ? instance.id : instance; + + var options = { + method: 'POST', + path: 'instances/' + instanceId + '/root' + }; + + this._request(options, function (err, body, response) { + if (err) { + return callback(err); + } + + if (response.statusCode === 200) { + return callback(null, body); + } + + return errs.handle(errs.create({ + message: 'Bad response from enabling root user' + }), callback); + }); +}; + +// List the root status for the database instance. +// `res` will be an object like `{ rootEnabled: true }` +// ### @instance {string | Object} The ID of the instance or a instance or Instance class (required) +// ### @callback {Function} Function to continue, the call is cb(error, res) +exports.listRootStatus = function listRootStatus(instance, callback) { + // Check for instance + if (typeof instance === 'function' || typeof instance === 'undefined') { + return errs.handle(errs.create({ + message: 'An instance is required.' + }), Array.prototype.slice.call(arguments).pop()); + } + + var instanceId = instance instanceof Instance ? instance.id : instance; + + var options = { + method: 'GET', + path: 'instances/' + instanceId + '/root' + }; + + this._request(options, function (err, body, response) { + if (err) { + return callback(err); + } + + if (response.statusCode === 200) { + return callback(null, body); + } + + return errs.handle(errs.create({ + message: 'Bad response from listing root-enabled status' + }), callback); + }); +}; diff --git a/test/common/databases/instances-test.js b/test/common/databases/instances-test.js index 82ee78d74..6aca8ed93 100644 --- a/test/common/databases/instances-test.js +++ b/test/common/databases/instances-test.js @@ -19,7 +19,7 @@ var should = require('should'), var assertLinks, setupCreateInstanceMock, setupGetInstancesMock, setupGetDatabaseInstancesWithLimitMock, setupDestroyInstanceMock, setGetInstanceMock, setGetFlavorsMock, setupSetFlavorMock, setupResizeMock, - setupGetOneFlavorMock, setupRestartInstanceMock; + setupGetOneFlavorMock, setupRestartInstanceMock, setupEnableRootMock; providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; @@ -428,6 +428,38 @@ providers.filter(function (provider) { }); }); + if (provider === 'rackspace' || provider === 'openstack') { + describe('the enableRootUser() method', function() { + it('with no instance should return error', function (done) { + if (mock) { + setupEnableRootMock(hockInstance, provider); + } + client.enableRootUser(testContext.Instance.id, function (err, body) { + if (err) { + return done(err); + } + + should.exist(body); + body.should.have.property('user'); + done(); + }); + }); + + it('with valid instance should work', function (done) { + client.listRootStatus(testContext.Instance.id, function (err, body) { + if (err) { + return done(err); + } + + should.exist(body); + body.should.have.property('rootEnabled'); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + } + describe('the restartInstance() method', function () { it('with no instance should return error', function (done) { client.restartInstance(function (err) { @@ -750,3 +782,33 @@ setupRestartInstanceMock = function (hockInstance, provider) { .reply(202); } }; + +setupEnableRootMock = function (hockInstance, provider) { + if (provider === 'rackspace') { + hockInstance + .post('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + name: 'root', + password: '12345' + } + }) + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + rootEnabled: true + }); + } else if (provider === 'openstack') { + hockInstance + .post('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + user: { + name: 'root', + password: '12345' + } + }) + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/root') + .reply(200, { + rootEnabled: true + }); + } +}; From e3a34fb2a9f917862975c18ef41a18a1f6464f37 Mon Sep 17 00:00:00 2001 From: "Stuart P. Bentley" Date: Sun, 10 May 2015 12:25:03 -0700 Subject: [PATCH 389/460] Fix Openstack link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9596a1df1..eabbca71e 100644 --- a/README.md +++ b/README.md @@ -380,7 +380,7 @@ To get started with a `pkgcloud.blockstorage` client just create one: #### Providers * [Rackspace](docs/providers/rackspace/blockstorage.md) -* [Rackspace](docs/providers/openstack/blockstorage.md) +* [Openstack](docs/providers/openstack/blockstorage.md) Each instance of `pkgcloud.blockstorage.Client` returned from `pkgcloud.blockstorage.createClient` has a set of uniform APIs: From 47ee5f97e43c10f1729e0f34ba55c1da20cd5b3f Mon Sep 17 00:00:00 2001 From: James Howe Date: Thu, 21 May 2015 11:41:31 +0100 Subject: [PATCH 390/460] Fix auth examples Took a lot of trial-and-error to work this out. --- docs/providers/hp/README.md | 66 +++++++++++++++---------------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/docs/providers/hp/README.md b/docs/providers/hp/README.md index 42cb2c04c..b85a12513 100644 --- a/docs/providers/hp/README.md +++ b/docs/providers/hp/README.md @@ -1,7 +1,6 @@ ![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) ## Using the HP Helion Cloud provider in pkgcloud - The HP Helion Cloud provider in pkgcloud supports the following services: * [**Compute**](compute.md) (cloud compute) @@ -10,79 +9,66 @@ The HP Helion Cloud provider in pkgcloud supports the following services: * [**Storage**](storage.md) (object storage) ### Activating your HP Helion Cloud services - If this is your first time using HP Helion Cloud Services, please follow [this](https://community.hpcloud.com/article/hp-public-cloud-quick-start-guide) guide to get started. ### Getting Started with Compute We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. ### Authentication +For all of the HP Cloud services, you create a client with the same options. -For all of the HP Cloud services, you create a client with the same options: +For key-based auth: ```Javascript -var client = require('pkgcloud').compute.createClient({ +createClient({ provider: 'hp', - username: 'your-user-name', - apiKey: 'your-api-key' + tenantId: 'your-tenant-id', + username: 'your-access-key', + apiKey: 'your-secret-key', +}); +``` + +For password auth: + +```Javascript +createClient({ + provider: 'hp', + tenantId: 'your-tenant-id', + username: 'your-username', + password: 'your-password', }); ``` -### Getting your API key +### Getting your API key You can provision API keys in your cloud management console. Please see [here](https://community.hpcloud.com/article/managing-your-access-keys) for more instructions. ### Authentication Endpoints and Regions - All of the HP `createClient` calls have a few options that can be provided: #### authUrl - `authUrl` specifies the authentication endpoint used to create a token for your HP client. See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) If you're targeting an HP Private Cloud instance, please contact your administrator for the authUrl. +#### region +`region` specifies which region of a service to use. HP has services deployed in multiple regions. +See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) +If you're targeting an HP Private Cloud instance, please contact your administrator for region names. + ##### Authenticating against the US-West endpoint ```Javascript -var client = require('pkgcloud').compute.createClient({ - provider: 'hp', - username: 'your-user-name', - apiKey: 'your-api-key', region: 'region-a.geo-1', - authUrl: 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/' -}); + authUrl: 'https://region-a.geo-1.identity.hpcloudsvc.com:35357' ``` ##### Authenticating against the US-East endpoint ```Javascript -var client = require('pkgcloud').compute.createClient({ - provider: 'hp', - username: 'your-user-name', - apiKey: 'your-api-key', region: 'region-b.geo-1', - authUrl: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/' -}); + authUrl: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357' ``` -#### region - -`region` specifies which region of a service to use. HP has services deployed in multiple regions. -See here for more details : [Regions](http://docs.hpcloud.com/api/identity/#2.2RegionsandAvailabilityZones) -If you're targeting an HP Private Cloud instance, please contact your administrator for region names. - -##### Specifying a custom region - -```Javascript -var client = require('pkgcloud').compute.createClient({ - provider: 'hp', - username: 'your-user-name', - apiKey: 'your-api-key', - region: 'region-a.custom.corp' -}); -``` - -#### Tokens and Expiration - +### Tokens and Expiration When you make your first call to a HP provider, your client is authenticated transparent to your API call. HP will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. From 59d3e5b7cda87fcd6e33327464782c7f53e23861 Mon Sep 17 00:00:00 2001 From: Yaw Etse Date: Wed, 27 May 2015 23:40:48 -0400 Subject: [PATCH 391/460] add cache control support to s3 buckets --- lib/pkgcloud/amazon/storage/client/files.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index d1c1f2e3f..b43953fdf 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -52,6 +52,10 @@ exports.upload = function (options) { Key: options.remote instanceof base.File ? options.remote.name : options.remote }; + if (options.cacheControl) { + s3Options.CacheControl = options.cacheControl; + } + if (options.contentType) { s3Options.ContentType = options.contentType; } From ef79def25bf01360ef49baae5c45b2283993e47d Mon Sep 17 00:00:00 2001 From: Josh Guice Date: Wed, 3 Jun 2015 11:22:52 -0700 Subject: [PATCH 392/460] docs(logging): fix missing semicolon in example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9596a1df1..62e29b8fc 100644 --- a/README.md +++ b/README.md @@ -621,7 +621,7 @@ var client = pkgcloud.compute.createClient(options); client.on('log::*', function(message, object) { if (object) { - console.log(this.event.split('::')[1] + ' ' + message) + console.log(this.event.split('::')[1] + ' ' + message); console.dir(object); } else { From db1fdfcf1c50d86756086ac88971a8692e295443 Mon Sep 17 00:00:00 2001 From: Don Schenck Date: Wed, 22 Jul 2015 16:49:23 -0600 Subject: [PATCH 393/460] Added deleteRule Issue #453 described that openstack/compute/client/extensions/security-group-rules.js lacked the deleteRule method. --- .../client/extensions/security-group-rules.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js b/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js index 2ec96d753..f6c4d5099 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js @@ -78,3 +78,24 @@ exports.addRules = function(rules, callback) { callback(null, created); }); }; + +/** + * client.deleteRule + * + * @description Remove a rule from a security group + * + * @param {string} ruleId the id of the rule to be deleted + * @param {Function} callback + * @returns {request|*} + */ +exports.deleteRule = function deleteRule(ruleId, callback) { + + return this._request({ + method: 'DELETE', + path: urlJoin(_extension, ruleId) + }, function (err) { + return err + ? callback(err) + : callback(err, { ok: ruleId}); + }); +}; From 307f7631036a24b66b8cffcffbba7d6b635f887b Mon Sep 17 00:00:00 2001 From: Don Schenck Date: Wed, 22 Jul 2015 17:19:10 -0600 Subject: [PATCH 394/460] Forgot urlJoin forgot to require urlJoin --- .../openstack/compute/client/extensions/security-group-rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js b/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js index f6c4d5099..b879ed6c2 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/security-group-rules.js @@ -6,7 +6,7 @@ */ var async = require('async'); - +var urlJoin = require('url-join'); var _extension = 'os-security-group-rules'; /** From c5980323b2934aa1dad9e35b5f0277e7d45cbc2f Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Thu, 23 Jul 2015 12:03:23 -0600 Subject: [PATCH 395/460] Update README test instructions --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 62e29b8fc..81d29028c 100644 --- a/README.md +++ b/README.md @@ -550,7 +550,12 @@ Each instance of `pkgcloud.orchestration.Client` returned from `pkgcloud.orchest ``` ## Tests -For run the tests you will need `mocha@1.9.x` or higher, please install it and then run: +To run the tests you will need `mocha@1.9.x` or higher. You may install all +the requirements with: +``` bash + $ npm install +``` +Then run the tests: ``` bash $ npm test From 3d8315fd7333e56b16b9aa00fa2e957e1d1ed478 Mon Sep 17 00:00:00 2001 From: Chris Knabe Date: Tue, 11 Aug 2015 11:33:26 -0500 Subject: [PATCH 396/460] OpenStack updated Keystone to V3 and it contains a number of changes that should be addressed via pkgcloud. http://docs.openstack.org/developer/keystone/http-api.html client.js - A goal is to maintain backwards compatibility with v2. - keystoneAuthVersion is used to default to v2 if a version is not specified identity.js - The new path for obtaining the token is v3/auth/tokens instead of v2.0/tokens. - Authentication in v3 now happens against domains - The token is returned in the x-subject-token header service.js - In V3 the format was changed for how endpoints and interfaces are used. On returning endpoints, an object is created for each interface type now. --- lib/pkgcloud/openstack/client.js | 24 ++- lib/pkgcloud/openstack/context/identity.js | 181 ++++++++++++++++----- lib/pkgcloud/openstack/context/service.js | 33 +++- 3 files changed, 190 insertions(+), 48 deletions(-) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 758ef84e1..d4aa682fe 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -2,6 +2,7 @@ * client.js: Base client from which all OpenStack clients inherit from * * (C) 2013 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. + * (C) 2015 IBM Corp. * */ @@ -36,6 +37,7 @@ var Client = exports.Client = function (options) { this.region = options.region; this.tenantId = options.tenantId; this.version = options.version || 'v2.0'; + this.keystoneAuthVersion = options.keystoneAuthVersion || 'v2.0'; if (!/^http[s]?\:\/\//.test(this.authUrl)) { this.authUrl = 'http://' + this.authUrl; @@ -77,25 +79,44 @@ Client.prototype._getIdentityOptions = function() { url: this.authUrl, version: this.version, username: this.config.username, - password: this.config.password + password: this.config.password, + keystoneAuthVersion: this.keystoneAuthVersion }; options.strictSSL = typeof this.config.strictSSL === 'boolean' ? this.config.strictSSL : true; + if (this.config.domainId) { + options.domainId = this.config.domainId; + } else if (this.config.domainName) { + options.domainName = this.config.domainName; + } + + if (this.config.projectDomainName) { + options.projectDomainName = this.config.projectDomainName; + } else if (this.config.projectDomainId) { + options.projectDomainId = this.config.projectDomainId; + } + if (this.config.tenantId) { options.tenantId = this.config.tenantId; } else if (this.config.tenantName) { options.tenantName = this.config.tenantName; } + if (typeof this.config.useServiceCatalog === 'boolean') { options.useServiceCatalog = this.config.useServiceCatalog; } + if (this.config.basePath) { options.basePath = this.config.basePath; } + if (this.config.headers) { + options.token = this.config.headers.authorization; + } + return options; }; @@ -224,7 +245,6 @@ Client.prototype._request = function (options, callback) { apiStream.on('response', function (response) { proxyStream.emit('response', response); }); - apiStream.pipe(proxyStream); } diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index c3abe200a..38776024a 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -2,6 +2,7 @@ * identity.js: Identity for openstack authentication * * (C) 2013 Rackspace, Ken Perkins + * (C) 2015 IBM Corp. * MIT LICENSE * */ @@ -75,7 +76,7 @@ var Identity = exports.Identity = function (options) { self.options = options || {}; self.name = 'OpenstackIdentity'; - self.basePath = options.basePath || '/v2.0/tokens'; + self.basePath = options.basePath || (options.keystoneAuthVersion === 'v3' ? '/v3/auth/tokens' : '/v2.0/tokens'); self.useServiceCatalog = (typeof options.useServiceCatalog === 'boolean') ? options.useServiceCatalog : true; @@ -114,6 +115,13 @@ Identity.prototype.authorize = function (options, callback) { 'Accept': 'application/json' } }; + if (self.options.headers) { + for (var header in self.options.headers) { + if (self.options.headers.hasOwnProperty(header)) { + authenticationOptions.headers[header] = self.options.headers[header]; + } + } + } if (self.options.version === 1 || self.options.version === '/v1.0') { authenticationOptions.uri = urlJoin(options.url || self.options.url, '/auth/v1.0'); @@ -144,7 +152,6 @@ Identity.prototype.authorize = function (options, callback) { // Don't keep a copy of the credentials in memory delete self._authenticationPayload; - request(authenticationOptions, function (err, response, body) { // check for a network error, or a handled error var err2 = getError(err, response, body); @@ -162,27 +169,27 @@ Identity.prototype.authorize = function (options, callback) { // If we've been asked to do v1 auth, check the response headers // otherwise, check the body - if (self.options.version === 1 || self.options.version === '/v1.0') { + try { + if (self.options.version === 1 || self.options.version === '/v1.0') { self._storageUrl = response.headers['x-storage-url']; self.token = { - id: response.headers['x-auth-token'] + id: response.headers['x-auth-token'] }; callback(); - } - // If we don't have a tenantId in the response (meaning no service catalog) - // go ahead and make a 1-off request to get a tenant and then reauthorize - else if (!body.access.token.tenant) { - getTenantId(urlJoin(options.url || self.options.url, '/v2.0/tenants'), body.access.token.id); - } - else { - try { - self._parseIdentityResponse(body); - callback(); } - catch (e) { - callback(e); + // If we don't have a tenantId in the response (meaning no service catalog) + // go ahead and make a 1-off request to get a tenant and then reauthorize + else if (self.options.keystoneAuthVersion !== 'v3' && !body.access.token.tenant) { + getTenantId(urlJoin(options.url || self.options.url, '/v2.0/tenants'), body.access.token.id); + } + else { + self._parseIdentityResponse(body, response.headers); + callback(); } } + catch (e) { + callback(e); + } }); function getTenantId(endpoint, token) { @@ -232,27 +239,101 @@ Identity.prototype._buildAuthenticationPayload = function () { var self = this; self.emit('log::trace', 'Building Openstack Identity Auth Payload'); - - // setup our inputs for authorization - if (self.options.password && self.options.username) { - self._authenticationPayload = { - auth: { - passwordCredentials: { - username: self.options.username, - password: self.options.password + if (self.options.keystoneAuthVersion === 'v3') { + if (self.options.password) { + self._authenticationPayload = { + auth: { + identity : { + methods : ['password'], + password : { + user: { + password: self.options.password + } + } + } } + }; + + //first add user name or id to user field + if (self.options.username) { + self._authenticationPayload.auth.identity.password.user.name = self.options.username; + } else if (self.options.userid) { + self._authenticationPayload.auth.identity.password.user.id = self.options.userid; } - }; - } - // Token and tenant are also valid inputs - else if (self.options.token && (self.options.tenantId || self.options.tenantName)) { - self._authenticationPayload = { - auth: { - token: { - id: self.options.token + //check if authenticating against user domain + if (self.options.domainId) { + self._authenticationPayload.auth.identity.password.user.domain = {id:self.options.domainId}; + } else if (self.options.domainName) { + self._authenticationPayload.auth.identity.password.user.domain = {name:self.options.domainName}; + } + //check if we're getting a scoped token against a project and/or domain + if (self.options.tenantId || self.options.tenantName || self.options.projectDomainName || self.options.projectDomainId) { + self._authenticationPayload.auth.scope = {}; + var scopedProject = true; + if (self.options.tenantId) { + self._authenticationPayload.auth.scope.project = {id:self.options.tenantId}; + } else if (self.options.tenantName) { + self._authenticationPayload.auth.scope.project = {name:self.options.tenantName}; + } else { + scopedProject = false; + } + if (!scopedProject) { + if (self.options.projectDomainId) { + self._authenticationPayload.auth.scope.domain = {id:self.options.projectDomainId}; + } else if (self.options.projectDomainName) { + self._authenticationPayload.auth.scope.domain = {name:self.options.projectDomainName}; + } + } else { + if (self.options.projectDomainId) { + self._authenticationPayload.auth.scope.project.domain = {id:self.options.projectDomainId}; + } else if(self.options.projectDomainName) { + self._authenticationPayload.auth.scope.project.domain = {name:self.options.projectDomainName}; + } } } - }; + } + // Token and tenant are also valid inputs + else if (self.options.token && (self.options.tenantId || self.options.tenantName)) { + self._authenticationPayload = { + auth: { + identity : { + methods : ['token'], + token: { + id: self.options.token + } + } + } + }; + } + } else { + // setup our inputs for authorization + if (self.options.password && self.options.username) { + self._authenticationPayload = { + auth: { + passwordCredentials: { + username: self.options.username, + password: self.options.password + } + } + }; + } + // Token and tenant are also valid inputs + else if (self.options.token && (self.options.tenantId || self.options.tenantName)) { + self._authenticationPayload = { + auth: { + token: { + id: self.options.token + } + } + }; + } + // Are we filtering down by a tenant? + if (self.options.tenantId) { + self._authenticationPayload.auth.tenantId = self.options.tenantId; + } + else if (self.options.tenantName) { + self._authenticationPayload.auth.tenantName = self.options.tenantName; + } } }; @@ -265,25 +346,36 @@ Identity.prototype._buildAuthenticationPayload = function () { * @param {object} data the raw response from the identity call * @private */ -Identity.prototype._parseIdentityResponse = function (data) { +Identity.prototype._parseIdentityResponse = function (data, headers) { var self = this; if (!data) { throw new Error('missing required arguments!'); } + if (self.options.keystoneAuthVersion === 'v3') { + self.token = { + id: headers['x-subject-token'], + expires: new Date(data.token.expires_at), + issued_at: new Date(data.token.issued_at), + tenant: {id: data.token.project.id, name: data.token.project.name} + }; + self.user = data.token.user; + if (self.useServiceCatalog) { + self.serviceCatalog = new ServiceCatalog(data.token.catalog); + } + } else { + if (data.access.token) { + self.token = data.access.token; + self.token.expires = new Date(self.token.expires); + } - if (data.access.token) { - self.token = data.access.token; - self.token.expires = new Date(self.token.expires); - } + if (self.useServiceCatalog && data.access.serviceCatalog) { + self.serviceCatalog = new ServiceCatalog(data.access.serviceCatalog); + } - if (self.useServiceCatalog && data.access.serviceCatalog) { - self.serviceCatalog = new ServiceCatalog(data.access.serviceCatalog); + self.user = data.access.user; } - - self.user = data.access.user; self.raw = data; - }; Identity.prototype.getServiceEndpointUrl = function (options) { @@ -299,3 +391,6 @@ Identity.prototype.getServiceEndpointUrl = function (options) { return this.options.url; } }; + + + diff --git a/lib/pkgcloud/openstack/context/service.js b/lib/pkgcloud/openstack/context/service.js index 37d1f065b..de961eb56 100644 --- a/lib/pkgcloud/openstack/context/service.js +++ b/lib/pkgcloud/openstack/context/service.js @@ -2,6 +2,7 @@ * service.js: Service model * * (C) 2013 Rackspace, Ken Perkins + * (C) 2015 IBM Corp. * MIT LICENSE * */ @@ -67,14 +68,23 @@ Service.prototype.getEndpointUrl = function (options) { if (options.serviceType.toLowerCase() !== this.type.toLowerCase()) { return ''; } + //since we don't know if this is a v2 or v3 catalog, check if the "interface" field is set on an endpoint, if so, we're v3 + if (self.endpoints && self.endpoints.length > 0 && self.endpoints[0]['interface'] !== undefined) { + self.v3 = true; + } if (options.region) { _.each(self.endpoints, function (endpoint) { if (!endpoint.region || !matchRegion(endpoint.region, options.region)) { return; } - - url = getUrl(endpoint); + if (self.v3 === true) { + if (endpointMatchDesiredInterface(endpoint)) { + url = endpoint.url; + } + } else { + url = getUrl(endpoint); + } }); } else { @@ -111,6 +121,23 @@ Service.prototype.getEndpointUrl = function (options) { endpoint.adminURL : endpoint.publicURL); } + /** + * endpointMatchDesiredInterface + * + * @description determine if the endpoint interface matches the desired interface + * @param {object} endpoint + * @returns {Boolean} + */ + function endpointMatchDesiredInterface(endpoint) { + var interfaceToUse = 'public'; + if (options.useInternal === true) { + interfaceToUse = 'internal'; + } else if (options.useAdmin === true) { + interfaceToUse = 'admin'; + } + return endpoint['interface'] === interfaceToUse; + } + if (!url) { throw new Error('Unable to identify endpoint url'); } @@ -118,4 +145,4 @@ Service.prototype.getEndpointUrl = function (options) { return url; }; -exports.Service = Service; +exports.Service = Service; \ No newline at end of file From 18cf2c92425080b1efa0d16eb6aaaf9af165cf36 Mon Sep 17 00:00:00 2001 From: Chris Knabe Date: Wed, 12 Aug 2015 08:27:55 -0500 Subject: [PATCH 397/460] Updated the tenant check to verify an auth payload exists --- lib/pkgcloud/openstack/context/identity.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index 38776024a..bddd3de6e 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -328,10 +328,10 @@ Identity.prototype._buildAuthenticationPayload = function () { }; } // Are we filtering down by a tenant? - if (self.options.tenantId) { + if (self._authenticationPayload && self.options.tenantId) { self._authenticationPayload.auth.tenantId = self.options.tenantId; } - else if (self.options.tenantName) { + else if (self._authenticationPayload && self.options.tenantName) { self._authenticationPayload.auth.tenantName = self.options.tenantName; } } From 60920d932b78b805005a245235f33ae0a378617d Mon Sep 17 00:00:00 2001 From: Than Nguyen Date: Fri, 21 Aug 2015 19:09:47 -0500 Subject: [PATCH 398/460] replace all underscore useage with lodash --- docs/providers/hp/getting-started-compute.md | 4 ++-- docs/providers/openstack/getting-started-compute.md | 4 ++-- docs/providers/rackspace/getting-started-compute.md | 6 +++--- examples/blockstorage/rackspace.js | 2 +- examples/compute/rackspace.js | 2 +- lib/pkgcloud/amazon/compute/client/groups.js | 2 +- lib/pkgcloud/amazon/compute/client/index.js | 2 +- lib/pkgcloud/amazon/compute/flavor.js | 2 +- lib/pkgcloud/amazon/compute/image.js | 2 +- lib/pkgcloud/amazon/compute/server.js | 2 +- lib/pkgcloud/amazon/storage/client/files.js | 2 +- lib/pkgcloud/amazon/storage/client/index.js | 2 +- lib/pkgcloud/amazon/storage/container.js | 2 +- lib/pkgcloud/amazon/storage/file.js | 2 +- lib/pkgcloud/azure/compute/client/index.js | 2 +- lib/pkgcloud/azure/compute/templates/templates.js | 2 +- lib/pkgcloud/azure/database/client/databases.js | 2 +- lib/pkgcloud/azure/database/client/index.js | 2 +- lib/pkgcloud/azure/storage/client/files.js | 2 +- lib/pkgcloud/azure/storage/client/index.js | 2 +- lib/pkgcloud/azure/storage/container.js | 2 +- lib/pkgcloud/azure/storage/file.js | 2 +- lib/pkgcloud/azure/utils/azureApi.js | 2 +- lib/pkgcloud/azure/utils/templates.js | 2 +- lib/pkgcloud/digitalocean/compute/client/index.js | 2 +- lib/pkgcloud/google/storage/client/files.js | 2 +- lib/pkgcloud/google/storage/client/index.js | 2 +- lib/pkgcloud/google/storage/container.js | 2 +- lib/pkgcloud/google/storage/file.js | 2 +- lib/pkgcloud/hp/client.js | 2 +- lib/pkgcloud/hp/compute/client/index.js | 2 +- lib/pkgcloud/hp/database/client/index.js | 2 +- lib/pkgcloud/hp/network/client/index.js | 2 +- lib/pkgcloud/hp/storage/client/index.js | 2 +- lib/pkgcloud/joyent/compute/client/index.js | 2 +- lib/pkgcloud/mongohq/database/client/index.js | 2 +- lib/pkgcloud/mongolab/database/client/index.js | 2 +- lib/pkgcloud/openstack/blockstorage/client/index.js | 2 +- lib/pkgcloud/openstack/blockstorage/snapshot.js | 2 +- lib/pkgcloud/openstack/blockstorage/volume.js | 2 +- lib/pkgcloud/openstack/blockstorage/volumetype.js | 2 +- lib/pkgcloud/openstack/compute/client/extensions/index.js | 2 +- .../openstack/compute/client/extensions/networks-base.js | 2 +- lib/pkgcloud/openstack/compute/client/index.js | 2 +- lib/pkgcloud/openstack/compute/client/servers.js | 2 +- lib/pkgcloud/openstack/compute/flavor.js | 2 +- lib/pkgcloud/openstack/compute/image.js | 2 +- lib/pkgcloud/openstack/compute/server.js | 2 +- lib/pkgcloud/openstack/context/identity.js | 2 +- lib/pkgcloud/openstack/context/service.js | 2 +- lib/pkgcloud/openstack/context/serviceCatalog.js | 2 +- lib/pkgcloud/openstack/database/client/index.js | 2 +- lib/pkgcloud/openstack/network/client/index.js | 2 +- lib/pkgcloud/openstack/network/network.js | 2 +- lib/pkgcloud/openstack/network/port.js | 2 +- lib/pkgcloud/openstack/network/securityGroup.js | 2 +- lib/pkgcloud/openstack/network/securityGroupRule.js | 2 +- lib/pkgcloud/openstack/network/subnet.js | 2 +- lib/pkgcloud/openstack/orchestration/client/index.js | 2 +- lib/pkgcloud/openstack/orchestration/client/resources.js | 2 +- lib/pkgcloud/openstack/orchestration/client/stacks.js | 2 +- lib/pkgcloud/openstack/orchestration/resource.js | 2 +- lib/pkgcloud/openstack/orchestration/stack.js | 2 +- lib/pkgcloud/openstack/storage/client/containers.js | 2 +- lib/pkgcloud/openstack/storage/client/files.js | 2 +- lib/pkgcloud/openstack/storage/client/index.js | 2 +- lib/pkgcloud/openstack/storage/container.js | 2 +- lib/pkgcloud/openstack/storage/file.js | 2 +- lib/pkgcloud/openstack/storage/storageClient.js | 2 +- lib/pkgcloud/rackspace/blockstorage/client/index.js | 2 +- lib/pkgcloud/rackspace/client.js | 2 +- lib/pkgcloud/rackspace/compute/client/index.js | 2 +- lib/pkgcloud/rackspace/database/client/index.js | 2 +- lib/pkgcloud/rackspace/dns/client/index.js | 2 +- lib/pkgcloud/rackspace/dns/client/records.js | 2 +- lib/pkgcloud/rackspace/dns/client/zones.js | 2 +- lib/pkgcloud/rackspace/dns/record.js | 2 +- lib/pkgcloud/rackspace/dns/zone.js | 2 +- lib/pkgcloud/rackspace/loadbalancer/client/index.js | 2 +- lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js | 2 +- lib/pkgcloud/rackspace/loadbalancer/client/nodes.js | 2 +- lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js | 2 +- lib/pkgcloud/rackspace/loadbalancer/node.js | 2 +- lib/pkgcloud/rackspace/network/client/index.js | 2 +- lib/pkgcloud/rackspace/orchestration/client/index.js | 2 +- lib/pkgcloud/rackspace/storage/client/cdn-containers.js | 2 +- lib/pkgcloud/rackspace/storage/client/index.js | 2 +- lib/pkgcloud/rackspace/storage/container.js | 2 +- lib/pkgcloud/rackspace/storage/file.js | 2 +- package.json | 2 +- test/azure/compute/templates/test-linuxConfigSet.js | 2 +- test/common/compute/base-test.js | 2 +- test/common/compute/server-test.js | 2 +- test/common/network/network-test.js | 2 +- test/helpers/azureNock.js | 2 +- test/hp/storage/file-test.js | 2 +- 96 files changed, 100 insertions(+), 100 deletions(-) diff --git a/docs/providers/hp/getting-started-compute.md b/docs/providers/hp/getting-started-compute.md index f42848c0e..d4e77f974 100644 --- a/docs/providers/hp/getting-started-compute.md +++ b/docs/providers/hp/getting-started-compute.md @@ -16,11 +16,11 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). In this example, we're going to create a HP Helion Cloud Compute client, create two servers, and then output their details to the command line. -*Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* +*Note: We're going to use [lodash.js](https://lodash.com) for some convenience functions.* ```Javascript var pkgcloud = require('pkgcloud'), - _ = require('underscore'); + _ = require('lodash'); // create our client with your openstack credentials var client = pkgcloud.compute.createClient({ diff --git a/docs/providers/openstack/getting-started-compute.md b/docs/providers/openstack/getting-started-compute.md index 5aeacc4a7..879a8f94c 100644 --- a/docs/providers/openstack/getting-started-compute.md +++ b/docs/providers/openstack/getting-started-compute.md @@ -16,12 +16,12 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). In this example, we're going to create a Openstack compute client, create two servers, and then output their details to the command line. -*Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* +*Note: We're going to use [lodash.js](https://lodash.com) for some convenience functions.* *Note: For DevStack, change AuthUrl to http://:5000* ```Javascript var pkgcloud = require('pkgcloud'), - _ = require('underscore'); + _ = require('lodash'); // create our client with your openstack credentials var client = pkgcloud.compute.createClient({ diff --git a/docs/providers/rackspace/getting-started-compute.md b/docs/providers/rackspace/getting-started-compute.md index 7ed6d007e..4102d43e6 100644 --- a/docs/providers/rackspace/getting-started-compute.md +++ b/docs/providers/rackspace/getting-started-compute.md @@ -16,11 +16,11 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). In this example, we're going to create a Rackspace compute client, create two servers, and then output their details to the command line. -*Note: We're going to use [underscore.js](http://underscorejs.org) for some convenience functions.* +*Note: We're going to use [lodash.js](https://lodash.com) for some convenience functions.* ```Javascript var pkgcloud = require('pkgcloud'), - _ = require('underscore'); + _ = require('lodash'); // create our client with your rackspace credentials var client = pkgcloud.providers.rackspace.compute.createClient({ @@ -92,4 +92,4 @@ function handleServerResponse(err, server) { ' in order to not accrue billing charges'); }); } -``` \ No newline at end of file +``` diff --git a/examples/blockstorage/rackspace.js b/examples/blockstorage/rackspace.js index 7ba6d4b07..7d8752159 100644 --- a/examples/blockstorage/rackspace.js +++ b/examples/blockstorage/rackspace.js @@ -1,5 +1,5 @@ var pkgcloud = require('pkgcloud'), - _ = require('underscore'); + _ = require('lodash'); (function() { diff --git a/examples/compute/rackspace.js b/examples/compute/rackspace.js index 5695e44db..127c5039e 100644 --- a/examples/compute/rackspace.js +++ b/examples/compute/rackspace.js @@ -1,5 +1,5 @@ var pkgcloud = require('pkgcloud'), - _ = require('underscore'); + _ = require('lodash'); // create our client with your rackspace credentials var client = pkgcloud.providers.rackspace.compute.createClient({ diff --git a/lib/pkgcloud/amazon/compute/client/groups.js b/lib/pkgcloud/amazon/compute/client/groups.js index c513bbae7..091e7f8f3 100644 --- a/lib/pkgcloud/amazon/compute/client/groups.js +++ b/lib/pkgcloud/amazon/compute/client/groups.js @@ -4,7 +4,7 @@ */ var errs = require('errs'), - _ = require('underscore'); + _ = require('lodash'); // // ### function listGroups (options, callback) diff --git a/lib/pkgcloud/amazon/compute/client/index.js b/lib/pkgcloud/amazon/compute/client/index.js index 1087afb9f..6f183ca7b 100644 --- a/lib/pkgcloud/amazon/compute/client/index.js +++ b/lib/pkgcloud/amazon/compute/client/index.js @@ -8,7 +8,7 @@ var AWS = require('aws-sdk'), util = require('util'), amazon = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { amazon.Client.call(this, options); diff --git a/lib/pkgcloud/amazon/compute/flavor.js b/lib/pkgcloud/amazon/compute/flavor.js index fb8c15dcd..50325b37f 100644 --- a/lib/pkgcloud/amazon/compute/flavor.js +++ b/lib/pkgcloud/amazon/compute/flavor.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/compute/flavor'), - _ = require('underscore'); + _ = require('lodash'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); diff --git a/lib/pkgcloud/amazon/compute/image.js b/lib/pkgcloud/amazon/compute/image.js index 69b7fae5a..2af52b309 100644 --- a/lib/pkgcloud/amazon/compute/image.js +++ b/lib/pkgcloud/amazon/compute/image.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/compute/image'), - _ = require('underscore'); + _ = require('lodash'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); diff --git a/lib/pkgcloud/amazon/compute/server.js b/lib/pkgcloud/amazon/compute/server.js index 906ff74bc..e0cd396fc 100644 --- a/lib/pkgcloud/amazon/compute/server.js +++ b/lib/pkgcloud/amazon/compute/server.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/compute/server'), - _ = require('underscore'); + _ = require('lodash'); var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index d1c1f2e3f..13aa48955 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -9,7 +9,7 @@ var base = require('../../../core/storage'), pkgcloud = require('../../../../../lib/pkgcloud'), through = require('through2'), storage = pkgcloud.providers.amazon.storage, - _ = require('underscore'); + _ = require('lodash'); // // ### function removeFile (container, file, callback) diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index b609b9b92..b3d8fd950 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), AWS = require('aws-sdk'), s3Stream = require('s3-upload-stream'), amazon = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { amazon.Client.call(this, options); diff --git a/lib/pkgcloud/amazon/storage/container.js b/lib/pkgcloud/amazon/storage/container.js index 01817be35..1a2524e1a 100644 --- a/lib/pkgcloud/amazon/storage/container.js +++ b/lib/pkgcloud/amazon/storage/container.js @@ -8,7 +8,7 @@ var util = require('util'), storage = require('../storage'), base = require('../../core/storage/container'), - _ = require('underscore'); + _ = require('lodash'); var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); diff --git a/lib/pkgcloud/amazon/storage/file.js b/lib/pkgcloud/amazon/storage/file.js index a0effac52..cf414df4b 100644 --- a/lib/pkgcloud/amazon/storage/file.js +++ b/lib/pkgcloud/amazon/storage/file.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/storage/file'), - _ = require('underscore'); + _ = require('lodash'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); diff --git a/lib/pkgcloud/azure/compute/client/index.js b/lib/pkgcloud/azure/compute/client/index.js index 79e488889..20b9d0ed4 100644 --- a/lib/pkgcloud/azure/compute/client/index.js +++ b/lib/pkgcloud/azure/compute/client/index.js @@ -12,7 +12,7 @@ var util = require('util'), azureApi = require('../../utils/azureApi.js'), xml2JSON = require('../../utils/xml2json.js').xml2JSON, azure = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { azure.Client.call(this, options); diff --git a/lib/pkgcloud/azure/compute/templates/templates.js b/lib/pkgcloud/azure/compute/templates/templates.js index a2401d1fa..e916f879a 100644 --- a/lib/pkgcloud/azure/compute/templates/templates.js +++ b/lib/pkgcloud/azure/compute/templates/templates.js @@ -7,7 +7,7 @@ var fs = require('fs'); var PATH = require('path'); -var _ = require('underscore'); +var _ = require('lodash'); exports.loadSync = function (name) { var path = PATH.join(__dirname, name); diff --git a/lib/pkgcloud/azure/database/client/databases.js b/lib/pkgcloud/azure/database/client/databases.js index fc24f8daa..75a5ca608 100644 --- a/lib/pkgcloud/azure/database/client/databases.js +++ b/lib/pkgcloud/azure/database/client/databases.js @@ -10,7 +10,7 @@ var errs = require('errs'), templates = require('../../utils/templates'), PATH = require('path'), xml2js = require('xml2js'), - _ = require('underscore'); + _ = require('lodash'); // Encode a uri according to Azure Table rules // ### @options {uri} The uri to encode diff --git a/lib/pkgcloud/azure/database/client/index.js b/lib/pkgcloud/azure/database/client/index.js index 689c7e0fa..bb7ff2445 100644 --- a/lib/pkgcloud/azure/database/client/index.js +++ b/lib/pkgcloud/azure/database/client/index.js @@ -11,7 +11,7 @@ var util = require('util'), azureApi = require('../../utils/azureApi.js'), xml2JSON = require('../../utils/xml2json.js').xml2JSON, azure = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { azure.Client.call(this, options); diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 2912124a2..1b7797673 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -13,7 +13,7 @@ var filed = require('filed'), AzureConstants = require('../../utils/constants'), pkgcloud = require('../../../../../lib/pkgcloud'), storage = pkgcloud.providers.azure.storage, - _ = require('underscore'); + _ = require('lodash'); // // ### function removeFile (container, file, callback) diff --git a/lib/pkgcloud/azure/storage/client/index.js b/lib/pkgcloud/azure/storage/client/index.js index a4b4eb37e..4a62384ab 100644 --- a/lib/pkgcloud/azure/storage/client/index.js +++ b/lib/pkgcloud/azure/storage/client/index.js @@ -11,7 +11,7 @@ var util = require('util'), azureApi = require('../../utils/azureApi.js'), xml2JSON = require('../../utils/xml2json.js').xml2JSON, azure = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { this.serversUrl = options.serversUrl || azureApi.STORAGE_ENDPOINT; diff --git a/lib/pkgcloud/azure/storage/container.js b/lib/pkgcloud/azure/storage/container.js index ff8782165..f64fb3b9e 100644 --- a/lib/pkgcloud/azure/storage/container.js +++ b/lib/pkgcloud/azure/storage/container.js @@ -6,7 +6,7 @@ */ var util = require('util'), - _ = require('underscore'), + _ = require('lodash'), base = require('../../core/storage/container'); var Container = exports.Container = function Container(client, details) { diff --git a/lib/pkgcloud/azure/storage/file.js b/lib/pkgcloud/azure/storage/file.js index ce2a70e5b..ffc467f7c 100644 --- a/lib/pkgcloud/azure/storage/file.js +++ b/lib/pkgcloud/azure/storage/file.js @@ -6,7 +6,7 @@ */ var util = require('util'), - _ = require('underscore'), + _ = require('lodash'), base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index f3cd2b9c9..76e53ad23 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -16,7 +16,7 @@ var HeaderConstants = require('./constants').HeaderConstants; var async = require('async'); var templates = require('../compute/templates/templates'); -var _ = require('underscore'); +var _ = require('lodash'); var errs = require('errs'); var URL = require('url'); var cert = require('../utils/cert'); diff --git a/lib/pkgcloud/azure/utils/templates.js b/lib/pkgcloud/azure/utils/templates.js index 697a773b5..714f18e13 100644 --- a/lib/pkgcloud/azure/utils/templates.js +++ b/lib/pkgcloud/azure/utils/templates.js @@ -6,7 +6,7 @@ */ var fs = require('fs'); -var _ = require('underscore'); +var _ = require('lodash'); exports.load = function (path, callback) { fs.readFile(path, 'utf8', function (err, data) { diff --git a/lib/pkgcloud/digitalocean/compute/client/index.js b/lib/pkgcloud/digitalocean/compute/client/index.js index 1630aec70..f74726c6b 100644 --- a/lib/pkgcloud/digitalocean/compute/client/index.js +++ b/lib/pkgcloud/digitalocean/compute/client/index.js @@ -8,7 +8,7 @@ var util = require('util'), urlJoin = require('url-join'), digitalocean = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { digitalocean.Client.call(this, options); diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index a8606d844..ac539fbb4 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -8,7 +8,7 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), through = require('through2'), storage = pkgcloud.providers.google.storage, - _ = require('underscore'); + _ = require('lodash'); /** * Destroy a file in the specified container. diff --git a/lib/pkgcloud/google/storage/client/index.js b/lib/pkgcloud/google/storage/client/index.js index f883eff52..2e954b69e 100644 --- a/lib/pkgcloud/google/storage/client/index.js +++ b/lib/pkgcloud/google/storage/client/index.js @@ -7,7 +7,7 @@ var util = require('util'), google = require('../../client'), - _ = require('underscore'), + _ = require('lodash'), pkgcloud = require('../../../../../lib/pkgcloud'); var Client = exports.Client = function (options) { diff --git a/lib/pkgcloud/google/storage/container.js b/lib/pkgcloud/google/storage/container.js index 742c52ba6..ea609f227 100644 --- a/lib/pkgcloud/google/storage/container.js +++ b/lib/pkgcloud/google/storage/container.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/storage/container'), - _ = require('underscore'); + _ = require('lodash'); var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); diff --git a/lib/pkgcloud/google/storage/file.js b/lib/pkgcloud/google/storage/file.js index 157c0afa2..bbad7f10c 100644 --- a/lib/pkgcloud/google/storage/file.js +++ b/lib/pkgcloud/google/storage/file.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/storage/file'), - _ = require('underscore'); + _ = require('lodash'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); diff --git a/lib/pkgcloud/hp/client.js b/lib/pkgcloud/hp/client.js index 74dc00f8a..88e4fe822 100644 --- a/lib/pkgcloud/hp/client.js +++ b/lib/pkgcloud/hp/client.js @@ -8,7 +8,7 @@ var util = require('util'), identity = require('./identity'), base = require('../openstack/client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { options = options || {}; diff --git a/lib/pkgcloud/hp/compute/client/index.js b/lib/pkgcloud/hp/compute/client/index.js index 9b16e8a87..ad2484097 100644 --- a/lib/pkgcloud/hp/compute/client/index.js +++ b/lib/pkgcloud/hp/compute/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), hp = require('../../client'), ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { hp.Client.call(this, options); diff --git a/lib/pkgcloud/hp/database/client/index.js b/lib/pkgcloud/hp/database/client/index.js index f811f2361..0cefae2a0 100644 --- a/lib/pkgcloud/hp/database/client/index.js +++ b/lib/pkgcloud/hp/database/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), hp = require('../../client'), auth = require('../../../common/auth.js'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { hp.Client.call(this, options); diff --git a/lib/pkgcloud/hp/network/client/index.js b/lib/pkgcloud/hp/network/client/index.js index 5c87155b0..a48370179 100644 --- a/lib/pkgcloud/hp/network/client/index.js +++ b/lib/pkgcloud/hp/network/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), hp = require('../../client'), NetworkClient = require('../../../openstack/network/networkClient').NetworkClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { hp.Client.call(this, options); diff --git a/lib/pkgcloud/hp/storage/client/index.js b/lib/pkgcloud/hp/storage/client/index.js index ef4f69dbb..3826d3975 100644 --- a/lib/pkgcloud/hp/storage/client/index.js +++ b/lib/pkgcloud/hp/storage/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), hp = require('../../client'), StorageClient = require('../../../openstack/storage/storageClient').StorageClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { hp.Client.call(this, options); diff --git a/lib/pkgcloud/joyent/compute/client/index.js b/lib/pkgcloud/joyent/compute/client/index.js index b7279010a..b2e7487eb 100644 --- a/lib/pkgcloud/joyent/compute/client/index.js +++ b/lib/pkgcloud/joyent/compute/client/index.js @@ -8,7 +8,7 @@ var util = require('util'), urlJoin = require('url-join'), joyent = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { joyent.Client.call(this, options); diff --git a/lib/pkgcloud/mongohq/database/client/index.js b/lib/pkgcloud/mongohq/database/client/index.js index e185247ef..673da7abd 100644 --- a/lib/pkgcloud/mongohq/database/client/index.js +++ b/lib/pkgcloud/mongohq/database/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), base = require('../../../core/base'), auth = require('../../../common/auth'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { base.Client.call(this, options); diff --git a/lib/pkgcloud/mongolab/database/client/index.js b/lib/pkgcloud/mongolab/database/client/index.js index 937afe6c3..129012309 100644 --- a/lib/pkgcloud/mongolab/database/client/index.js +++ b/lib/pkgcloud/mongolab/database/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), base = require('../../../core/base'), auth = require('../../../common/auth'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { base.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/blockstorage/client/index.js b/lib/pkgcloud/openstack/blockstorage/client/index.js index 514cfba96..99e5ca205 100644 --- a/lib/pkgcloud/openstack/blockstorage/client/index.js +++ b/lib/pkgcloud/openstack/blockstorage/client/index.js @@ -10,7 +10,7 @@ var util = require('util'), urlJoin = require('url-join'), openstack = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { openstack.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/blockstorage/snapshot.js b/lib/pkgcloud/openstack/blockstorage/snapshot.js index 75b054784..487a076a9 100644 --- a/lib/pkgcloud/openstack/blockstorage/snapshot.js +++ b/lib/pkgcloud/openstack/blockstorage/snapshot.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/base'), - _ = require('underscore'); + _ = require('lodash'); var Snapshot = exports.Snapshot = function Snapshot(client, details) { base.Model.call(this, client, details); diff --git a/lib/pkgcloud/openstack/blockstorage/volume.js b/lib/pkgcloud/openstack/blockstorage/volume.js index 2ccf74d5b..cb42d530a 100644 --- a/lib/pkgcloud/openstack/blockstorage/volume.js +++ b/lib/pkgcloud/openstack/blockstorage/volume.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/base'), - _ = require('underscore'); + _ = require('lodash'); var Volume = exports.Volume = function Volume(client, details) { base.Model.call(this, client, details); diff --git a/lib/pkgcloud/openstack/blockstorage/volumetype.js b/lib/pkgcloud/openstack/blockstorage/volumetype.js index c4b79a243..e0703b07e 100644 --- a/lib/pkgcloud/openstack/blockstorage/volumetype.js +++ b/lib/pkgcloud/openstack/blockstorage/volumetype.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/base'), - _ = require('underscore'); + _ = require('lodash'); var VolumeType = exports.VolumeType = function VolumeType(client, details) { base.Model.call(this, client, details); diff --git a/lib/pkgcloud/openstack/compute/client/extensions/index.js b/lib/pkgcloud/openstack/compute/client/extensions/index.js index 20bbba366..70464d1b6 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/index.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/index.js @@ -8,7 +8,7 @@ * (updated by Alvaro M. Reol) */ -var _ = require('underscore'); +var _ = require('lodash'); var extensions = { getExtensions: function(callback) { diff --git a/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js b/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js index 128766746..4012a65e1 100644 --- a/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js +++ b/lib/pkgcloud/openstack/compute/client/extensions/networks-base.js @@ -9,7 +9,7 @@ */ var urlJoin = require('url-join'), - _ = require('underscore'); + _ = require('lodash'); exports.createNetworkExtension = function(prefix) { return { diff --git a/lib/pkgcloud/openstack/compute/client/index.js b/lib/pkgcloud/openstack/compute/client/index.js index 3b18fab4e..9cc502d77 100644 --- a/lib/pkgcloud/openstack/compute/client/index.js +++ b/lib/pkgcloud/openstack/compute/client/index.js @@ -8,7 +8,7 @@ var util = require('util'), openstack = require('../../client'), ComputeClient = require('../computeClient').ComputeClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { openstack.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index fe7056ae3..3cdcd628c 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -9,7 +9,7 @@ var base = require('../../../core/compute'), errs = require('errs'), urlJoin = require('url-join'), util = require('util'), - _ = require('underscore'), + _ = require('lodash'), Server = require('../server').Server, compute = pkgcloud.providers.openstack.compute; diff --git a/lib/pkgcloud/openstack/compute/flavor.js b/lib/pkgcloud/openstack/compute/flavor.js index f29e39479..c7f9d9f12 100644 --- a/lib/pkgcloud/openstack/compute/flavor.js +++ b/lib/pkgcloud/openstack/compute/flavor.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/compute/flavor'), - _ = require('underscore'); + _ = require('lodash'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Flavor.call(this, client, details); diff --git a/lib/pkgcloud/openstack/compute/image.js b/lib/pkgcloud/openstack/compute/image.js index 0db81aae7..1c0ca0872 100644 --- a/lib/pkgcloud/openstack/compute/image.js +++ b/lib/pkgcloud/openstack/compute/image.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/compute/image'), - _ = require('underscore'); + _ = require('lodash'); var Image = exports.Image = function Image(client, details) { base.Image.call(this, client, details); diff --git a/lib/pkgcloud/openstack/compute/server.js b/lib/pkgcloud/openstack/compute/server.js index 28b87f0fb..9c240186b 100644 --- a/lib/pkgcloud/openstack/compute/server.js +++ b/lib/pkgcloud/openstack/compute/server.js @@ -8,7 +8,7 @@ var util = require('util'), compute = require('../../core/compute'), base = require('../../core/compute/server'), - _ = require('underscore'); + _ = require('lodash'); var Server = exports.Server = function Server(client, details) { base.Server.call(this, client, details); diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index c3abe200a..54f806e87 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -6,7 +6,7 @@ * */ -var _ = require('underscore'), +var _ = require('lodash'), events = require('eventemitter2'), request = require('request'), ServiceCatalog = require('./serviceCatalog').ServiceCatalog, diff --git a/lib/pkgcloud/openstack/context/service.js b/lib/pkgcloud/openstack/context/service.js index 37d1f065b..bf44b7fc0 100644 --- a/lib/pkgcloud/openstack/context/service.js +++ b/lib/pkgcloud/openstack/context/service.js @@ -6,7 +6,7 @@ * */ -var _ = require('underscore'); +var _ = require('lodash'); function matchRegion(a, b) { if (!a && !b) { diff --git a/lib/pkgcloud/openstack/context/serviceCatalog.js b/lib/pkgcloud/openstack/context/serviceCatalog.js index 4f045565d..f435ebdad 100644 --- a/lib/pkgcloud/openstack/context/serviceCatalog.js +++ b/lib/pkgcloud/openstack/context/serviceCatalog.js @@ -7,7 +7,7 @@ */ var Service = require('./service').Service, - _ = require('underscore'); + _ = require('lodash'); /** * ServiceCatalog class diff --git a/lib/pkgcloud/openstack/database/client/index.js b/lib/pkgcloud/openstack/database/client/index.js index f51a0bbd1..2646173e2 100644 --- a/lib/pkgcloud/openstack/database/client/index.js +++ b/lib/pkgcloud/openstack/database/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), rackspace = require('../../client'), auth = require('../../../common/auth.js'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/network/client/index.js b/lib/pkgcloud/openstack/network/client/index.js index 8b0915940..2d00bce1a 100644 --- a/lib/pkgcloud/openstack/network/client/index.js +++ b/lib/pkgcloud/openstack/network/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), openstack = require('../../client'), NetworkClient = require('../networkClient').NetworkClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { openstack.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/network/network.js b/lib/pkgcloud/openstack/network/network.js index 80a3813d7..69aa46a70 100644 --- a/lib/pkgcloud/openstack/network/network.js +++ b/lib/pkgcloud/openstack/network/network.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/network/network'), - _ = require('underscore'); + _ = require('lodash'); var Network = exports.Network = function Network(client, details) { base.Network.call(this, client, details); diff --git a/lib/pkgcloud/openstack/network/port.js b/lib/pkgcloud/openstack/network/port.js index 1b90c44a0..1b5a3bcf8 100644 --- a/lib/pkgcloud/openstack/network/port.js +++ b/lib/pkgcloud/openstack/network/port.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/network/port'), - _ = require('underscore'); + _ = require('lodash'); var Port = exports.Port = function Port(client, details) { base.Port.call(this, client, details); diff --git a/lib/pkgcloud/openstack/network/securityGroup.js b/lib/pkgcloud/openstack/network/securityGroup.js index 02533d25f..cb68fa4dd 100644 --- a/lib/pkgcloud/openstack/network/securityGroup.js +++ b/lib/pkgcloud/openstack/network/securityGroup.js @@ -8,7 +8,7 @@ var util = require('util'), base = require('../../core/network/securityGroup'), - _ = require('underscore'); + _ = require('lodash'); var SecurityGroup = exports.SecurityGroup = function SecurityGroup(client, details) { base.SecurityGroup.call(this, client, details); diff --git a/lib/pkgcloud/openstack/network/securityGroupRule.js b/lib/pkgcloud/openstack/network/securityGroupRule.js index 60dfcaf72..f80580c35 100644 --- a/lib/pkgcloud/openstack/network/securityGroupRule.js +++ b/lib/pkgcloud/openstack/network/securityGroupRule.js @@ -8,7 +8,7 @@ var util = require('util'), base = require('../../core/network/securityGroupRule'), - _ = require('underscore'); + _ = require('lodash'); var SecurityGroupRule = exports.SecurityGroupRule = function SecurityGroupRule(client, details) { base.SecurityGroupRule.call(this, client, details); diff --git a/lib/pkgcloud/openstack/network/subnet.js b/lib/pkgcloud/openstack/network/subnet.js index 708301a2d..0853a234c 100644 --- a/lib/pkgcloud/openstack/network/subnet.js +++ b/lib/pkgcloud/openstack/network/subnet.js @@ -7,7 +7,7 @@ var util = require('util'), base = require('../../core/network/subnet'), - _ = require('underscore'); + _ = require('lodash'); var Subnet = exports.Subnet = function Subnet(client, details) { base.Subnet.call(this, client, details); diff --git a/lib/pkgcloud/openstack/orchestration/client/index.js b/lib/pkgcloud/openstack/orchestration/client/index.js index 770ba32e5..a844fb8ae 100644 --- a/lib/pkgcloud/openstack/orchestration/client/index.js +++ b/lib/pkgcloud/openstack/orchestration/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), openstack = require('../../client'), urlJoin = require('url-join'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { openstack.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/orchestration/client/resources.js b/lib/pkgcloud/openstack/orchestration/client/resources.js index 300eabb89..cb9e9486f 100644 --- a/lib/pkgcloud/openstack/orchestration/client/resources.js +++ b/lib/pkgcloud/openstack/orchestration/client/resources.js @@ -7,7 +7,7 @@ */ var pkgcloud = require('../../../../../lib/pkgcloud'), urlJoin = require('url-join'), - _ = require('underscore'), + _ = require('lodash'), orchestration = pkgcloud.providers.openstack.orchestration; var _urlPrefix = '/resource_types'; diff --git a/lib/pkgcloud/openstack/orchestration/client/stacks.js b/lib/pkgcloud/openstack/orchestration/client/stacks.js index eb6536d68..4023f9a62 100644 --- a/lib/pkgcloud/openstack/orchestration/client/stacks.js +++ b/lib/pkgcloud/openstack/orchestration/client/stacks.js @@ -10,7 +10,7 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), urlJoin = require('url-join'), util = require('util'), - _ = require('underscore'), + _ = require('lodash'), orchestration = pkgcloud.providers.openstack.orchestration; var _urlPrefix = '/stacks'; diff --git a/lib/pkgcloud/openstack/orchestration/resource.js b/lib/pkgcloud/openstack/orchestration/resource.js index 55dd0fa1a..1fc5a7ad9 100644 --- a/lib/pkgcloud/openstack/orchestration/resource.js +++ b/lib/pkgcloud/openstack/orchestration/resource.js @@ -10,7 +10,7 @@ var util = require('util'), base = require('../../core/base'), Stack = require('./stack').Stack, - _ = require('underscore'); + _ = require('lodash'); var Resource = exports.Resource = function Stack(client, details) { base.Model.call(this, client, details); diff --git a/lib/pkgcloud/openstack/orchestration/stack.js b/lib/pkgcloud/openstack/orchestration/stack.js index 1dd9cd87a..f9c9b894a 100644 --- a/lib/pkgcloud/openstack/orchestration/stack.js +++ b/lib/pkgcloud/openstack/orchestration/stack.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/base'), - _ = require('underscore'); + _ = require('lodash'); var Stack = exports.Stack = function Stack(client, details) { base.Model.call(this, client, details); diff --git a/lib/pkgcloud/openstack/storage/client/containers.js b/lib/pkgcloud/openstack/storage/client/containers.js index 82f3852de..646107a13 100644 --- a/lib/pkgcloud/openstack/storage/client/containers.js +++ b/lib/pkgcloud/openstack/storage/client/containers.js @@ -8,7 +8,7 @@ */ var async = require('async'), - _ = require('underscore'); + _ = require('lodash'); /** * client.getContainers diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index dfab0d8c2..9ee35b361 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -10,7 +10,7 @@ var filed = require('filed'), mime = require('mime'), base = require('../../../core/storage'), through = require('through2'), - _ = require('underscore'), + _ = require('lodash'), urlJoin = require('url-join'); /** diff --git a/lib/pkgcloud/openstack/storage/client/index.js b/lib/pkgcloud/openstack/storage/client/index.js index d524280b8..7c37c37c7 100644 --- a/lib/pkgcloud/openstack/storage/client/index.js +++ b/lib/pkgcloud/openstack/storage/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), openstack = require('../../client'), StorageClient = require('../storageClient').StorageClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { // explicitly prevent service catalog usage if using version 1.0 for swift diff --git a/lib/pkgcloud/openstack/storage/container.js b/lib/pkgcloud/openstack/storage/container.js index 4808eae6a..75fc9033a 100644 --- a/lib/pkgcloud/openstack/storage/container.js +++ b/lib/pkgcloud/openstack/storage/container.js @@ -8,7 +8,7 @@ var util = require('util'), base = require('../../core/storage/container'), - _ = require('underscore'); + _ = require('lodash'); var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); diff --git a/lib/pkgcloud/openstack/storage/file.js b/lib/pkgcloud/openstack/storage/file.js index 23189f638..bf5162dc8 100644 --- a/lib/pkgcloud/openstack/storage/file.js +++ b/lib/pkgcloud/openstack/storage/file.js @@ -7,7 +7,7 @@ */ var util = require('util'), - _ = require('underscore'), + _ = require('lodash'), base = require('../../core/storage/file'); var File = exports.File = function File(client, details) { diff --git a/lib/pkgcloud/openstack/storage/storageClient.js b/lib/pkgcloud/openstack/storage/storageClient.js index 469445de7..a52d2c86f 100644 --- a/lib/pkgcloud/openstack/storage/storageClient.js +++ b/lib/pkgcloud/openstack/storage/storageClient.js @@ -9,7 +9,7 @@ */ var urlJoin = require('url-join'), - _ = require('underscore'); + _ = require('lodash'); const CONTAINER_META_PREFIX = 'x-container-meta-'; const CONTAINER_REMOVE_META_PREFIX = 'x-remove-container-meta-'; diff --git a/lib/pkgcloud/rackspace/blockstorage/client/index.js b/lib/pkgcloud/rackspace/blockstorage/client/index.js index 3d8e95848..75e836176 100644 --- a/lib/pkgcloud/rackspace/blockstorage/client/index.js +++ b/lib/pkgcloud/rackspace/blockstorage/client/index.js @@ -10,7 +10,7 @@ var util = require('util'), urlJoin = require('url-join'), rackspace = require('../../client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/client.js b/lib/pkgcloud/rackspace/client.js index f3b1da359..6a5800d5f 100644 --- a/lib/pkgcloud/rackspace/client.js +++ b/lib/pkgcloud/rackspace/client.js @@ -8,7 +8,7 @@ var util = require('util'), identity = require('./identity'), base = require('../openstack/client'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { options = options || {}; diff --git a/lib/pkgcloud/rackspace/compute/client/index.js b/lib/pkgcloud/rackspace/compute/client/index.js index f15a80ad9..67ba4bc92 100644 --- a/lib/pkgcloud/rackspace/compute/client/index.js +++ b/lib/pkgcloud/rackspace/compute/client/index.js @@ -8,7 +8,7 @@ var util = require('util'), rackspace = require('../../client'), ComputeClient = require('../../../openstack/compute/computeClient').ComputeClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/database/client/index.js b/lib/pkgcloud/rackspace/database/client/index.js index 51b3c93df..8dffca1cc 100644 --- a/lib/pkgcloud/rackspace/database/client/index.js +++ b/lib/pkgcloud/rackspace/database/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), urlJoin = require('url-join'), rackspace = require('../../client'), auth = require('../../../common/auth.js'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/dns/client/index.js b/lib/pkgcloud/rackspace/dns/client/index.js index 320096848..b9fcf09fa 100644 --- a/lib/pkgcloud/rackspace/dns/client/index.js +++ b/lib/pkgcloud/rackspace/dns/client/index.js @@ -11,7 +11,7 @@ var util = require('util'), rackspace = require('../../client'), urlJoin = require('url-join'), Status = require('../status').Status, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/dns/client/records.js b/lib/pkgcloud/rackspace/dns/client/records.js index 8ea27b42c..bd421e3c9 100644 --- a/lib/pkgcloud/rackspace/dns/client/records.js +++ b/lib/pkgcloud/rackspace/dns/client/records.js @@ -9,7 +9,7 @@ var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - _ = require('underscore'), + _ = require('lodash'), dns = pkgcloud.providers.rackspace.dns; var _urlPrefix = 'domains', diff --git a/lib/pkgcloud/rackspace/dns/client/zones.js b/lib/pkgcloud/rackspace/dns/client/zones.js index 59f4db5bd..8d0f2cae3 100644 --- a/lib/pkgcloud/rackspace/dns/client/zones.js +++ b/lib/pkgcloud/rackspace/dns/client/zones.js @@ -9,7 +9,7 @@ var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - _ = require('underscore'), + _ = require('lodash'), dns = pkgcloud.providers.rackspace.dns; var _urlPrefix = 'domains'; diff --git a/lib/pkgcloud/rackspace/dns/record.js b/lib/pkgcloud/rackspace/dns/record.js index 01f9094ee..b1921d60a 100644 --- a/lib/pkgcloud/rackspace/dns/record.js +++ b/lib/pkgcloud/rackspace/dns/record.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/dns/record'), - _ = require('underscore'); + _ = require('lodash'); var Record = exports.Record = function Record(zone, details) { base.Record.call(this, zone, details); diff --git a/lib/pkgcloud/rackspace/dns/zone.js b/lib/pkgcloud/rackspace/dns/zone.js index ba2cbb28e..64490fc2e 100644 --- a/lib/pkgcloud/rackspace/dns/zone.js +++ b/lib/pkgcloud/rackspace/dns/zone.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/dns/zone'), - _ = require('underscore'); + _ = require('lodash'); var Zone = exports.Zone = function Zone(client, details) { base.Zone.call(this, client, details); diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/index.js b/lib/pkgcloud/rackspace/loadbalancer/client/index.js index e8d955378..15f3dffb1 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/index.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/index.js @@ -10,7 +10,7 @@ var util = require('util'), rackspace = require('../../client'), urlJoin = require('url-join'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js index e4665343c..b876f9d0e 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/loadbalancers.js @@ -9,7 +9,7 @@ var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - _ = require('underscore'), + _ = require('lodash'), lb = pkgcloud.providers.rackspace.loadbalancer; var _urlPrefix = 'loadbalancers'; diff --git a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js index b3373eb88..9aa6df900 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js +++ b/lib/pkgcloud/rackspace/loadbalancer/client/nodes.js @@ -9,7 +9,7 @@ var urlJoin = require('url-join'), pkgcloud = require('../../../../../lib/pkgcloud'), - _ = require('underscore'), + _ = require('lodash'), lb = pkgcloud.providers.rackspace.loadbalancer; var _urlPrefix = 'loadbalancers'; diff --git a/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js b/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js index 4b370d367..da6c2d3b8 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js +++ b/lib/pkgcloud/rackspace/loadbalancer/loadbalancer.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/loadbalancer/loadbalancer'), - _ = require('underscore'); + _ = require('lodash'); var LoadBalancer = exports.LoadBalancer = function LoadBalancer(client, details) { base.LoadBalancer.call(this, client, details); diff --git a/lib/pkgcloud/rackspace/loadbalancer/node.js b/lib/pkgcloud/rackspace/loadbalancer/node.js index 3ee491906..be19b0757 100644 --- a/lib/pkgcloud/rackspace/loadbalancer/node.js +++ b/lib/pkgcloud/rackspace/loadbalancer/node.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/loadbalancer/node'), - _ = require('underscore'); + _ = require('lodash'); var Node = exports.Node = function Node(client, details) { base.Node.call(this, client, details); diff --git a/lib/pkgcloud/rackspace/network/client/index.js b/lib/pkgcloud/rackspace/network/client/index.js index 1a5e44756..b24d94dcf 100644 --- a/lib/pkgcloud/rackspace/network/client/index.js +++ b/lib/pkgcloud/rackspace/network/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), rackspace = require('../../client'), NetworkClient = require('../../../openstack/network/networkClient').NetworkClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/orchestration/client/index.js b/lib/pkgcloud/rackspace/orchestration/client/index.js index cdd6b92bb..dddf74c50 100644 --- a/lib/pkgcloud/rackspace/orchestration/client/index.js +++ b/lib/pkgcloud/rackspace/orchestration/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), rackspace = require('../../client'), urlJoin = require('url-join'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js index f2883f3e7..c3074d098 100644 --- a/lib/pkgcloud/rackspace/storage/client/cdn-containers.js +++ b/lib/pkgcloud/rackspace/storage/client/cdn-containers.js @@ -7,7 +7,7 @@ var async = require('async'), crypto = require('crypto'), - _ = require('underscore'); + _ = require('lodash'); /** * client.getFiles diff --git a/lib/pkgcloud/rackspace/storage/client/index.js b/lib/pkgcloud/rackspace/storage/client/index.js index 8e7e1bd04..476419eab 100644 --- a/lib/pkgcloud/rackspace/storage/client/index.js +++ b/lib/pkgcloud/rackspace/storage/client/index.js @@ -8,7 +8,7 @@ var util = require('util'), rackspace = require('../../client'), StorageClient = require('../../../openstack/storage/storageClient').StorageClient, - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); diff --git a/lib/pkgcloud/rackspace/storage/container.js b/lib/pkgcloud/rackspace/storage/container.js index 81e3ac3e6..182f3a901 100644 --- a/lib/pkgcloud/rackspace/storage/container.js +++ b/lib/pkgcloud/rackspace/storage/container.js @@ -8,7 +8,7 @@ var util = require('util'), base = require('../../openstack/storage/container'), - _ = require('underscore'); + _ = require('lodash'); var Container = exports.Container = function Container(client, details) { base.Container.call(this, client, details); diff --git a/lib/pkgcloud/rackspace/storage/file.js b/lib/pkgcloud/rackspace/storage/file.js index ce74ef73a..f12ce2c8e 100644 --- a/lib/pkgcloud/rackspace/storage/file.js +++ b/lib/pkgcloud/rackspace/storage/file.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../openstack/storage/file'), - _ = require('underscore'); + _ = require('lodash'); var File = exports.File = function File(client, details) { base.File.call(this, client, details); diff --git a/package.json b/package.json index 2405b5705..e15c8a1cd 100644 --- a/package.json +++ b/package.json @@ -62,12 +62,12 @@ "filed": "0.1.x", "gcloud": "^0.10.0", "ip": "0.3.x", + "lodash": "^3.10.1", "mime": "1.2.x", "qs": "1.2.x", "request": "2.40.x", "s3-upload-stream": "~1.0.0", "through2": "0.6.x", - "underscore": "1.6.x", "url-join": "0.0.x", "xml2js": "0.1.x" }, diff --git a/test/azure/compute/templates/test-linuxConfigSet.js b/test/azure/compute/templates/test-linuxConfigSet.js index 9495bebd4..09499b410 100644 --- a/test/azure/compute/templates/test-linuxConfigSet.js +++ b/test/azure/compute/templates/test-linuxConfigSet.js @@ -1,7 +1,7 @@ //TODO: Make this a vows test var templates = require('../../../../lib/pkgcloud/azure/compute/templates/templates'); -var _ = require('underscore'); +var _ = require('lodash'); var params = { HOSTNAME: 'pkgcloud1', diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index c5d5cb847..42f5691c3 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -12,7 +12,7 @@ var should = require('should'), http = require('http'), helpers = require('../../helpers'), hock = require('hock'), - _ = require('underscore'), + _ = require('lodash'), providers = require('../../configs/providers.json'), versions = require('../../fixtures/versions.json'), Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor, diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 28af428ae..f111db020 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -11,7 +11,7 @@ var qs = require('qs'), helpers = require('../../helpers'), http = require('http'), hock = require('hock'), - _ = require('underscore'), + _ = require('lodash'), providers = require('../../configs/providers.json'), Server = require('../../../lib/pkgcloud/core/compute/server').Server, azureApi = require('../../../lib/pkgcloud/azure/utils/azureApi'), diff --git a/test/common/network/network-test.js b/test/common/network/network-test.js index bc2d41fc4..cf7f643fc 100644 --- a/test/common/network/network-test.js +++ b/test/common/network/network-test.js @@ -10,7 +10,7 @@ var should = require('should'), helpers = require('../../helpers'), http = require('http'), hock = require('hock'), - _ = require('underscore'), + _ = require('lodash'), providers = require('../../configs/providers.json'), Network = require('../../../lib/pkgcloud/core/network/network').Network, mock = !!process.env.MOCK, diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index 8554b255c..c4f7926c0 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -23,7 +23,7 @@ */ var azureApi = require('../../lib/pkgcloud/azure/utils/azureApi'), - _ = require('underscore'), + _ = require('lodash'), requestId = 'b67cc525-ecc5-4661-8fd6-fb3e57d724f5', helpers; diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index b5d181ef5..0ca464949 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -2,7 +2,7 @@ var helpers = require('../../helpers'), async = require('async'), http = require('http'), hock = require('hock'), - _ = require('underscore'); + _ = require('lodash'); var authenticate = function (hockInstance) { hockInstance From b228512eb0fc388ab494c2e35da00a25122c8562 Mon Sep 17 00:00:00 2001 From: Than Nguyen Date: Fri, 21 Aug 2015 21:46:45 -0500 Subject: [PATCH 399/460] fixes lodash template usage --- lib/pkgcloud/azure/compute/templates/templates.js | 8 ++++---- lib/pkgcloud/azure/database/client/databases.js | 3 ++- lib/pkgcloud/azure/utils/azureApi.js | 3 ++- lib/pkgcloud/azure/utils/templates.js | 5 ++--- test/azure/compute/templates/test-linuxConfigSet.js | 3 ++- test/common/compute/server-test.js | 6 +++--- test/helpers/azureNock.js | 6 +++--- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/pkgcloud/azure/compute/templates/templates.js b/lib/pkgcloud/azure/compute/templates/templates.js index e916f879a..60a5336be 100644 --- a/lib/pkgcloud/azure/compute/templates/templates.js +++ b/lib/pkgcloud/azure/compute/templates/templates.js @@ -15,7 +15,8 @@ exports.loadSync = function (name) { }; exports.compileSync = function (template, params) { - return _.template(template, params); + var compiled = _.template(template); + return compiled(params); }; exports.load = function (name, callback) { @@ -28,8 +29,7 @@ exports.load = function (name, callback) { exports.compile = function (name, params, callback) { var path = PATH.join(__dirname, name); fs.readFile(path, 'utf8', function (err, data) { - callback(err, _.template(data, params)); + var compiled = _.template(data); + callback(err, compiled(params)); }); }; - - diff --git a/lib/pkgcloud/azure/database/client/databases.js b/lib/pkgcloud/azure/database/client/databases.js index 75a5ca608..b1c62b377 100644 --- a/lib/pkgcloud/azure/database/client/databases.js +++ b/lib/pkgcloud/azure/database/client/databases.js @@ -59,7 +59,8 @@ exports.create = function (options, callback) { }, function (template, next) { // compile template with params - body = _.template(template, params); + var compiled = _.template(template); + body = compiled(params); headers['content-length'] = body.length; self._request({ method: 'POST', diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index 76e53ad23..8e3eb1adf 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -179,7 +179,8 @@ makeTemplateRequest = function (client, path, templateName, params, callback) { }, function (template, next) { // compile template with params - body = _.template(template, params); + var compiled = _.template(template); + body = compiled(params); headers['content-length'] = body.length; headers['content-type'] = 'application/xml'; headers['accept'] = 'application/xml'; diff --git a/lib/pkgcloud/azure/utils/templates.js b/lib/pkgcloud/azure/utils/templates.js index 714f18e13..3b433a536 100644 --- a/lib/pkgcloud/azure/utils/templates.js +++ b/lib/pkgcloud/azure/utils/templates.js @@ -19,9 +19,8 @@ exports.compile = function (path, params, callback) { if (err) { callback(err); } else { - callback(null, _.template(data, params)); + var compiled = _.template(data); + callback(null, compiled(params)); } }); }; - - diff --git a/test/azure/compute/templates/test-linuxConfigSet.js b/test/azure/compute/templates/test-linuxConfigSet.js index 09499b410..266430e0a 100644 --- a/test/azure/compute/templates/test-linuxConfigSet.js +++ b/test/azure/compute/templates/test-linuxConfigSet.js @@ -15,6 +15,7 @@ templates.load('linuxConfigSet.xml', function (err, template) { console.dir(err); } else { - console.log(_.template(template, params)); + var compiled = _.template(template); + console.log(compiled(params)); } }); diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index f111db020..52725ff33 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -956,8 +956,8 @@ setupRebootMock = function() { serverStatusReply = function (name, status) { var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; + params = {NAME: name, STATUS: status}, + compiled = _.template(template); - var result = _.template(template, params); - return result; + return compiled(params); }; diff --git a/test/helpers/azureNock.js b/test/helpers/azureNock.js index c4f7926c0..ca1730ce6 100644 --- a/test/helpers/azureNock.js +++ b/test/helpers/azureNock.js @@ -194,8 +194,8 @@ exports.serverTest = function (nock, testHelpers) { serverStatusReply = function (name, status) { var template = helpers.loadFixture('azure/server-status-template.xml'), - params = {NAME: name, STATUS: status}; + params = {NAME: name, STATUS: status}, + compiled = _.template(template); - var result = _.template(template, params); - return result; + return compiled(params); }; From 4229b49ce9900af9aa946a32309aa8c87d14cbf4 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Mon, 14 Sep 2015 19:35:19 -0400 Subject: [PATCH 400/460] [compute] Port DigitalOcean provider to APIv2. --- docs/providers/digitalocean.md | 5 +- examples/compute/digitalocean.js | 54 +++++ lib/pkgcloud/digitalocean/client.js | 12 +- .../digitalocean/compute/client/flavors.js | 4 +- .../digitalocean/compute/client/images.js | 27 ++- .../digitalocean/compute/client/keys.js | 29 +-- .../digitalocean/compute/client/servers.js | 84 ++++--- lib/pkgcloud/digitalocean/compute/flavor.js | 10 +- lib/pkgcloud/digitalocean/compute/image.js | 3 + lib/pkgcloud/digitalocean/compute/server.js | 27 ++- test/common/compute/base-test.js | 46 +--- test/common/compute/server-test.js | 44 ++-- test/configs/mock/digitalocean.json | 3 +- test/fixtures/digitalocean/active.json | 95 +++++++- test/fixtures/digitalocean/active2.json | 95 +++++++- test/fixtures/digitalocean/create-server.json | 44 +++- .../fixtures/digitalocean/create-server2.json | 42 +++- .../fixtures/digitalocean/destroy-server.json | 4 - test/fixtures/digitalocean/flavors.json | 118 ++-------- test/fixtures/digitalocean/images.json | 211 +++--------------- test/fixtures/digitalocean/list-servers.json | 91 +++++++- test/fixtures/digitalocean/not-active.json | 95 +++++++- 22 files changed, 683 insertions(+), 460 deletions(-) create mode 100644 examples/compute/digitalocean.js delete mode 100644 test/fixtures/digitalocean/destroy-server.json diff --git a/docs/providers/digitalocean.md b/docs/providers/digitalocean.md index 6e5b913b2..33da938be 100644 --- a/docs/providers/digitalocean.md +++ b/docs/providers/digitalocean.md @@ -5,13 +5,12 @@ ## Using Compute -DigitalOcean requires a client ID and API key. +DigitalOcean requires an API token. ```js var pkgcloud = require('pkgcloud'); var digitalocean = pkgcloud.compute.createClient({ provider: 'digitalocean', - clientId: '', - apiKey: '' + token: '' }); ``` diff --git a/examples/compute/digitalocean.js b/examples/compute/digitalocean.js new file mode 100644 index 000000000..de0209e60 --- /dev/null +++ b/examples/compute/digitalocean.js @@ -0,0 +1,54 @@ +var pkgcloud = require('../../lib/pkgcloud'), + client, + options; + +// +// Create a pkgcloud compute instance +// +options = { + provider: 'digitalocean', + token: 'digitalocean-api-token' +}; +client = pkgcloud.compute.createClient(options); + +// +// List DigitalOcean Droplets. +// +client.getServers(function (err, servers) { + if (err) { + console.error(err); + } + + servers.forEach(function (server) { + console.log(server.name, server.id, server.status); + }); +}); + + +// +// Create a Droplet and wait until finished. +// +options = { + name: 'pkgcloud-test', + flavor: '512mb', + image: 'ubuntu-14-04-x64', + ipv6: true, + private_networking: true, + backups: true +}; + +client.createServer(options, function (err, server) { + if (err) { + console.log(err); + } else { + // Wait for the server to reach the RUNNING state. + console.log('waiting for server RUNNING state...'); + server.setWait({ status: server.STATUS.running }, 10000, function (err, server) { + if (err) { + console.log(err); + } else { + console.dir(server); + } + }); + } +}); \ No newline at end of file diff --git a/lib/pkgcloud/digitalocean/client.js b/lib/pkgcloud/digitalocean/client.js index a99c96969..55ff0cce3 100644 --- a/lib/pkgcloud/digitalocean/client.js +++ b/lib/pkgcloud/digitalocean/client.js @@ -16,8 +16,8 @@ var util = require('util'), // #### @throws {TypeError} On bad input // var Client = exports.Client = function (opts) { - if (!opts || !opts.clientId || !opts.apiKey) { - throw new TypeError('clientId and apiKey are required'); + if (!opts || !opts.token) { + throw new TypeError('token is required'); } base.Client.call(this, opts); @@ -39,10 +39,10 @@ var Client = exports.Client = function (opts) { }); this.before.push(function setAuth(req) { - req.qs = req.qs || {}; - - req.qs.client_id = opts.clientId; - req.qs.api_key = opts.apiKey; + req.headers = req.headers || {}; + req.headers.authorization = [ + 'Bearer', opts.token + ].join(' '); }); }; diff --git a/lib/pkgcloud/digitalocean/compute/client/flavors.js b/lib/pkgcloud/digitalocean/compute/client/flavors.js index 8f4232bbd..d481fac61 100644 --- a/lib/pkgcloud/digitalocean/compute/client/flavors.js +++ b/lib/pkgcloud/digitalocean/compute/client/flavors.js @@ -19,7 +19,7 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), exports.getFlavors = function getFlavors(callback) { var self = this; return this._request({ - path: '/sizes' + path: '/v2/sizes' }, function (err, body, res) { if (err || !body.sizes) { return callback(err || new Error('No flavors provided.')); @@ -45,7 +45,7 @@ exports.getFlavor = function getFlavor(flavor, callback) { self = this; return this._request({ - path: '/sizes' + path: '/v2/sizes' }, function (err, body) { if (err || !body.sizes) { return callback(err || new Error('No flavors found.')); diff --git a/lib/pkgcloud/digitalocean/compute/client/images.js b/lib/pkgcloud/digitalocean/compute/client/images.js index 0556a6e6d..b7618a088 100644 --- a/lib/pkgcloud/digitalocean/compute/client/images.js +++ b/lib/pkgcloud/digitalocean/compute/client/images.js @@ -7,19 +7,35 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), base = require('../../../core/compute'), errs = require('errs'), + urlJoin = require('url-join'), compute = pkgcloud.providers.digitalocean.compute; // // ### function getImages (callback) +// #### @options {Object} Options when getting images +// #### @options.per_page {number} **Optional** Number of images to list +// #### @options.page {number} **Optional** Page number of images to return // #### @callback {function} f(err, images). `images` is an array that // represents the images that are available to your account // // Lists all images available to your account. // -exports.getImages = function getImages(callback) { - var self = this; +exports.getImages = function getImages(options, callback) { + if (!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + var self = this, + per_page = options.per_page || 200, + page = options.page || 1; + return this._request({ - path: '/images' + path: '/v2/images', + qs: { + per_page: per_page, + page: page + } }, function (err, body, res) { if (err || !body.images) { return callback(err || new Error('No images found.')); @@ -44,7 +60,7 @@ exports.getImage = function getImage(image, callback) { self = this; return this._request({ - path: '/images/' + imageId + path: urlJoin('/v2/images/', imageId) }, function (err, body, res) { return err ? callback(err) @@ -81,7 +97,8 @@ exports.destroyImage = function destroyImage(image, callback) { var imageId = image instanceof base.Image ? image.id : image; return this._request({ - path: '/images/' + imageId + '/destroy' + path: urlJoin('/images/', imageId , '/destroy'), + method: 'DELETE' }, function (err, body, res) { return err ? callback(err) diff --git a/lib/pkgcloud/digitalocean/compute/client/keys.js b/lib/pkgcloud/digitalocean/compute/client/keys.js index 88268deef..4bf6d5df5 100644 --- a/lib/pkgcloud/digitalocean/compute/client/keys.js +++ b/lib/pkgcloud/digitalocean/compute/client/keys.js @@ -5,7 +5,8 @@ * */ -var errs = require('errs'); +var errs = require('errs'), + urlJoin = require('url-join'); // // ### function listKeys (callback) @@ -15,7 +16,7 @@ var errs = require('errs'); // exports.listKeys = function (callback) { return this._request({ - path: '/ssh_keys' + path: '/v2/account/keys' }, function (err, body) { return err ? callback(err) @@ -24,15 +25,15 @@ exports.listKeys = function (callback) { }; // -// ### function getKey (name, callback) -// #### @name {string} Name of the DigitalOcean SSH key to get +// ### function getKey (id, callback) +// #### @id {int} Name of the DigitalOcean SSH key to get // #### @callback {function} Continuation to respond to when complete. // -// Gets the details of the DigitalOcean SSH Key with the specified `name`. +// Gets the details of the DigitalOcean SSH Key with the specified `id`. // -exports.getKey = function (name, callback) { +exports.getKey = function (id, callback) { return this._request({ - path: '/ssh_keys/' + name + path: urlJoin('/v2/account/keys', id) }, function (err, body) { return err ? callback(err) @@ -58,8 +59,9 @@ exports.addKey = function (options, callback) { } return this._request({ - path: '/ssh_keys/new', - qs: { + path: '/v2/account/keys', + method: 'POST', + body: { name: options.name, ssh_pub_key: options.key } @@ -72,14 +74,15 @@ exports.addKey = function (options, callback) { // // ### function getKey (name, callback) -// #### @name {string} Name of the DigitalOcean SSH key to destroy +// #### @id {int} Name of the DigitalOcean SSH key to destroy // #### @callback {function} Continuation to respond to when complete. // -// Destroys DigitalOcean SSH Key with the specified `name`. +// Destroys DigitalOcean SSH Key with the specified `id`. // -exports.destroyKey = function (name, callback) { +exports.destroyKey = function (id, callback) { return this._request({ - path: '/ssh_keys/' + name + '/destroy', + path: urlJoin('/v2/account/keys', id), + method: 'DELETE', }, function (err) { return err ? callback(err) diff --git a/lib/pkgcloud/digitalocean/compute/client/servers.js b/lib/pkgcloud/digitalocean/compute/client/servers.js index 30541c77e..e8808db85 100644 --- a/lib/pkgcloud/digitalocean/compute/client/servers.js +++ b/lib/pkgcloud/digitalocean/compute/client/servers.js @@ -7,6 +7,7 @@ var base = require('../../../core/compute'), pkgcloud = require('../../../../../lib/pkgcloud'), errs = require('errs'), + urlJoin = require('url-join'), compute = pkgcloud.providers.digitalocean.compute; // @@ -38,8 +39,8 @@ exports.getLimits = function getLimits(callback) { // // ### function getServers (callback) // #### @options {Object} Options when getting servers -// #### @options.offset {number} Number of servers to skip when listing -// #### @options.limit {number} Number of servers to return +// #### @options.per_page {number} **Optional** Number of servers to skip when listing +// #### @options.page {number} **Optional** Number of servers to return // #### @callback {function} f(err, servers). `servers` is an array that // represents the servers that are available to your account // @@ -48,14 +49,20 @@ exports.getLimits = function getLimits(callback) { exports.getServers = function getServers(options, callback) { if (!callback && typeof options === 'function') { callback = options; - options = null; + options = {}; } - var self = this; + var self = this, + per_page = options.per_page || 200, + page = options.page || 1; + return this._request( { - path: '/droplets', - qs: options + path: '/v2/droplets', + qs: { + per_page: per_page, + page: page + } }, function (err, body, res) { if (err) { @@ -72,11 +79,15 @@ exports.getServers = function getServers(options, callback) { // // ### function createServer (options, callback) // #### @opts {Object} **Optional** options -// #### @name {String} **Optional** a name for your server +// #### @name {String} a name for your server // #### @flavor {String|Flavor} **Optional** flavor to use for this image // #### @image {String|Image} **Optional** the image to use // #### @required {Boolean} **Optional** Validate if flavor, name, // and image are present +// #### @ipv6 {Boolean} **Optional** Enable IPv6 +// #### @private_networking {Boolean} **Optional** Enable private networking +// #### @backups {Boolean} **Optional** Enable backups +// #### @user_data {String} **Optional** Provide cloud-init user-data // #### @* {*} **Optional** Anything platform specific // #### @callback {Function} f(err, server). // @@ -94,8 +105,9 @@ exports.createServer = function createServer(options, callback) { var self = this, createOptions = { - path: '/droplets/new', - qs: {} + method: 'POST', + path: '/v2/droplets', + body: {} }; ['flavor', 'image', 'name'].forEach(function (member) { @@ -107,13 +119,13 @@ exports.createServer = function createServer(options, callback) { } }); - createOptions.qs.name = options.name; - createOptions.qs.region_id = options.region || options.region_id || 1; - createOptions.qs.size_id = options.flavor instanceof base.Flavor + createOptions.body.name = options.name; + createOptions.body.region = options.region || options.region_id || 'nyc3'; + createOptions.body.size = options.flavor instanceof base.Flavor ? options.flavor.id : options.flavor; - createOptions.qs.image_id = options.image instanceof base.Image + createOptions.body.image = options.image instanceof base.Image ? options.image.id : options.image; @@ -122,14 +134,34 @@ exports.createServer = function createServer(options, callback) { // which can be a single string or an Array. // if (options.keyname) { - createOptions.qs.ssh_key_ids = options.keyname; + createOptions.body.ssh_keys = options.keyname; } else if (options.keynames) { - createOptions.qs.ssh_key_ids = Array.isArray(options.keynames) + createOptions.body.ssh_keys = Array.isArray(options.keynames) ? options.keynames.join(',') : options.keynames; } + + // + // DigitalOcean specific options. + // + if (options.ipv6) { + createOptions.body.ipv6 = options.ipv6; + } + + if (options.private_networking) { + createOptions.body.private_networking = options.private_networking; + } + + if (options.backups) { + createOptions.body.backups = options.backups; + } + + if (options.user_data) { + createOptions.body.user_data = options.user_data; + } + return this._request(createOptions, function (err, body, res) { return err ? callback(err) @@ -157,12 +189,8 @@ exports.destroyServer = function destroyServer(server, options, callback) { } this._request({ - path: '/droplets/' + serverId + '/destroy', - qs: { - scrub_data: (typeof options.scrubData === 'boolean') - ? (options.scrubData ? '1' : '0') - : '1' - } + method: 'DELETE', + path: urlJoin('/v2/droplets/', serverId) }, function (err, body, res) { return err ? callback(err) : callback(null, { ok: serverId }, res); }); @@ -180,7 +208,7 @@ exports.getServer = function getServer(server, callback) { self = this; return this._request({ - path: '/droplets/' + serverId + path: urlJoin('/v2/droplets/', serverId) }, function (err, body, res) { return !err ? callback(null, new compute.Server(self, body.droplet), res) @@ -199,7 +227,9 @@ exports.getServer = function getServer(server, callback) { exports.rebootServer = function rebootServer(server, callback) { var serverId = server instanceof base.Server ? server.id : server; return this._request({ - path: '/droplets/' + serverId + '/reboot' + method: 'POST', + path: urlJoin('/v2/droplets/', serverId, '/actions'), + body: { type: 'reboot' }, }, function (err, body, res) { return err ? callback(err) @@ -218,8 +248,12 @@ exports.rebootServer = function rebootServer(server, callback) { exports.renameServer = function renameServer(server, name, callback) { var serverId = server instanceof base.Server ? server.id : server; return this._request({ - path: '/droplets/' + serverId + '/rename', - qs: { name: name } + method: 'POST', + path: urlJoin('/v2/droplets/', serverId, '/actions'), + body: { + type: 'rename', + name: name + }, }, function (err, body, res) { return err ? callback(err) diff --git a/lib/pkgcloud/digitalocean/compute/flavor.js b/lib/pkgcloud/digitalocean/compute/flavor.js index b758b7f06..bce1c5426 100644 --- a/lib/pkgcloud/digitalocean/compute/flavor.js +++ b/lib/pkgcloud/digitalocean/compute/flavor.js @@ -15,16 +15,16 @@ var Flavor = exports.Flavor = function Flavor(client, details) { util.inherits(Flavor, base.Flavor); Flavor.prototype._setProperties = function (details) { - this.id = details.id; - this.name = details.name; + this.id = details.slug; + this.name = details.slug; this.ram = details.memory; this.disk = details.disk; // // DigitalOcean specific // - this.cpu = details.cpu; - this.costPerHour = details.cost_per_hour; - this.costPerMonth = details.cost_per_month; + this.cpu = details.vcpus; + this.costPerHour = details.price_hourly; + this.costPerMonth = details.price_monthly; this.original = this.digitalocean = details; }; \ No newline at end of file diff --git a/lib/pkgcloud/digitalocean/compute/image.js b/lib/pkgcloud/digitalocean/compute/image.js index 8dfde8995..be1b1530f 100644 --- a/lib/pkgcloud/digitalocean/compute/image.js +++ b/lib/pkgcloud/digitalocean/compute/image.js @@ -17,10 +17,13 @@ util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { this.id = details.id; this.name = details.name; + this.created = details.created_at; // // DigitalOcean specific // this.distribution = details.distribution; + this.public = details.public; + this.slug = details.slug; this.original = this.digitalocean = details; }; \ No newline at end of file diff --git a/lib/pkgcloud/digitalocean/compute/server.js b/lib/pkgcloud/digitalocean/compute/server.js index 1e401eaee..0d7c72122 100644 --- a/lib/pkgcloud/digitalocean/compute/server.js +++ b/lib/pkgcloud/digitalocean/compute/server.js @@ -15,19 +15,38 @@ var Server = exports.Server = function Server(client, details) { util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { + var self = this; + + function getAddresses(networks) { + networks.forEach(function (network) { + self.addresses[network.type].push(network.ip_address); + }); + } + this.id = details.id; this.name = details.name; - this.imageId = details.image_id; - this.flavorId = details.size_id; + this.imageId = details.image.id; + this.flavorId = details.size_slug; this.addresses = { - public: [details.ip_address], + public: [], private: [] }; + if (details.networks.v4) { + getAddresses(details.networks.v4); + } + + if (details.networks.v6) { + getAddresses(details.networks.v6); + } + switch (details.status && details.status.toUpperCase()) { case 'ACTIVE': this.status = 'RUNNING'; break; + case 'OFF': + this.status = this.STATUS.stopped; + break; case 'NEW': default: this.status = 'PROVISIONING'; @@ -37,5 +56,7 @@ Server.prototype._setProperties = function (details) { // DigitalOcean specific // this.region = details.region_id; + this.created = details.created_at; this.original = this.digitalocean = details; }; + diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index c5d5cb847..6ff0b16e6 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -6,7 +6,6 @@ */ var should = require('should'), - qs = require('qs'), util = require('util'), async = require('async'), http = require('http'), @@ -321,12 +320,8 @@ setupFlavorMock = function (client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/joyent/flavors.json'); } else if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); servers.server - .get('/sizes?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/sizes') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/flavors.json'); } else if (provider === 'hp') { @@ -370,12 +365,8 @@ setupImagesMock = function (client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/azure/images.xml'); } else if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); servers.server - .get('/images?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/images?per_page=200&page=1') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/images.json'); } else if (provider === 'hp') { @@ -388,27 +379,18 @@ setupImagesMock = function (client, provider, servers) { setupServerMock = function (client, provider, servers) { if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); servers.server - .get('/droplets/new?' + qs.stringify({ + .post('/v2/droplets', { name: 'create-test-setWait', - region_id: 1, - size_id: 66, - image_id: 1601, - client_id: account.clientId, - api_key: account.apiKey - })) + region: 'nyc3', + size: '512mb', + image: 119192817 + }) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/create-server.json') - .get('/droplets/354526?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/droplets/3164494') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/not-active.json') - .get('/droplets/354526?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/droplets/3164494') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/active.json'); } else if (provider === 'rackspace') { @@ -575,14 +557,8 @@ setupDestroyMock = function (client, provider, servers) { .reply(204); } else if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); - servers.server - .get('/droplets/354526/destroy?' + qs.stringify({ - scrub_data: '1', - client_id: account.clientId, - api_key: account.apiKey - })) - .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/destroy-server.json'); + .delete('/v2/droplets/3164494') + .replyWithFile(204); } }; diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 28af428ae..ee0f5cab4 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -5,8 +5,7 @@ * */ -var qs = require('qs'), - should = require('should'), +var should = require('should'), async = require('async'), helpers = require('../../helpers'), http = require('http'), @@ -296,12 +295,8 @@ setupImagesMock = function (client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/azure/images.xml'); } else if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); servers.server - .get('/images?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/images?per_page=200&page=1') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/images.json'); } else if (provider === 'hp') { @@ -351,12 +346,8 @@ setupFlavorMock = function (client, provider, servers) { .replyWithFile(200, __dirname + '/../../fixtures/joyent/flavors.json'); } else if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); servers.server - .get('/sizes?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/sizes') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/flavors.json'); } else if (provider === 'hp') { @@ -368,22 +359,16 @@ setupFlavorMock = function (client, provider, servers) { setupServerMock = function (client, provider, servers) { if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); servers.server - .get('/droplets/new?' + qs.stringify({ + .post('/v2/droplets', { name: 'create-test-ids2', - region_id: 1, - size_id: 66, - image_id: 1601, - client_id: account.clientId, - api_key: account.apiKey - })) + region: 'nyc3', + size: '512mb', + image: 119192817 + }) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/create-server2.json') - .get('/droplets/354526?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/droplets/354526') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/active2.json'); } else if (provider === 'rackspace') { @@ -524,12 +509,8 @@ setupGetServersMock = function (client, provider, servers) { .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } else if (provider === 'digitalocean') { - var account = require(__dirname + '/../../configs/mock/digitalocean'); servers.server - .get('/droplets?' + qs.stringify({ - client_id: account.clientId, - api_key: account.apiKey - })) + .get('/v2/droplets?per_page=200&page=1') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/list-servers.json'); } else if (provider === 'hp') { @@ -572,6 +553,11 @@ setupGetServerMock = function (client, provider, servers) { .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } + else if (provider === 'digitalocean') { + servers.server + .get('/v2/droplets/3164494') + .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/active.json'); + } else if (provider === 'hp') { servers.server .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') diff --git a/test/configs/mock/digitalocean.json b/test/configs/mock/digitalocean.json index e57861477..6297f75e7 100644 --- a/test/configs/mock/digitalocean.json +++ b/test/configs/mock/digitalocean.json @@ -1,6 +1,5 @@ { - "clientId": "MOCK-ACCOUNT", - "apiKey": "mock-api-key", + "token": "mock-api-key", "protocol" : "http://", "serversUrl" : "localhost:12345" } diff --git a/test/fixtures/digitalocean/active.json b/test/fixtures/digitalocean/active.json index d503f2259..d3f1d6579 100644 --- a/test/fixtures/digitalocean/active.json +++ b/test/fixtures/digitalocean/active.json @@ -1,17 +1,90 @@ { - "status": "OK", "droplet": { - "id": 354526, + "id": 3164494, "name": "create-test-setWait", - "image_id": 1601, - "size_id": 66, - "region_id": 1, - "backups_active": false, - "ip_address": "0.0.0.0", - "locked": true, + "memory": 512, + "vcpus": 1, + "disk": 20, + "locked": false, "status": "active", - "created_at": "2013-08-09T21:57:57Z", - "backups": [], - "snapshots": [] + "kernel": { + "id": 2233, + "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic", + "version": "3.13.0-37-generic" + }, + "created_at": "2014-11-14T16:36:31Z", + "features": [ + "ipv6", + "virtio" + ], + "backup_ids": [ + + ], + "snapshot_ids": [ + 7938206 + ], + "image": { + "id": 6918990, + "name": "14.04 x64", + "distribution": "Ubuntu", + "slug": "ubuntu-14-04-x64", + "public": true, + "regions": [ + "nyc1", + "ams1", + "sfo1", + "nyc2", + "ams2", + "sgp1", + "lon1", + "nyc3", + "ams3", + "nyc3" + ], + "created_at": "2014-10-17T20:24:33Z", + "min_disk_size": 20 + }, + "size_slug": "512mb", + "networks": { + "v4": [ + { + "ip_address": "104.131.186.241", + "netmask": "255.255.240.0", + "gateway": "104.131.176.1", + "type": "public" + } + ], + "v6": [ + { + "ip_address": "2604:A880:0800:0010:0000:0000:031D:2001", + "netmask": 64, + "gateway": "2604:A880:0800:0010:0000:0000:0000:0001", + "type": "public" + } + ] + }, + "region": { + "name": "New York 3", + "slug": "nyc3", + "sizes": [ + "32gb", + "16gb", + "2gb", + "1gb", + "4gb", + "8gb", + "512mb", + "64gb", + "48gb" + ], + "features": [ + "virtio", + "private_networking", + "backups", + "ipv6", + "metadata" + ], + "available": true + } } } \ No newline at end of file diff --git a/test/fixtures/digitalocean/active2.json b/test/fixtures/digitalocean/active2.json index 3cbd09964..4c5ab5fbc 100644 --- a/test/fixtures/digitalocean/active2.json +++ b/test/fixtures/digitalocean/active2.json @@ -1,17 +1,90 @@ { - "status": "OK", "droplet": { - "id": 354526, + "id": 12345, "name": "create-test-ids2", - "image_id": 1601, - "size_id": 66, - "region_id": 1, - "backups_active": false, - "ip_address": "0.0.0.0", - "locked": true, + "memory": 512, + "vcpus": 1, + "disk": 20, + "locked": false, "status": "active", - "created_at": "2013-08-09T21:57:57Z", - "backups": [], - "snapshots": [] + "kernel": { + "id": 2233, + "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic", + "version": "3.13.0-37-generic" + }, + "created_at": "2014-11-14T16:36:31Z", + "features": [ + "ipv6", + "virtio" + ], + "backup_ids": [ + + ], + "snapshot_ids": [ + 7938206 + ], + "image": { + "id": 119192817, + "name": "14.04 x64", + "distribution": "Ubuntu", + "slug": "ubuntu-14-04-x64", + "public": true, + "regions": [ + "nyc1", + "ams1", + "sfo1", + "nyc2", + "ams2", + "sgp1", + "lon1", + "nyc3", + "ams3", + "nyc3" + ], + "created_at": "2014-10-17T20:24:33Z", + "min_disk_size": 20 + }, + "size_slug": "512mb", + "networks": { + "v4": [ + { + "ip_address": "104.131.186.241", + "netmask": "255.255.240.0", + "gateway": "104.131.176.1", + "type": "public" + } + ], + "v6": [ + { + "ip_address": "2604:A880:0800:0010:0000:0000:031D:2001", + "netmask": 64, + "gateway": "2604:A880:0800:0010:0000:0000:0000:0001", + "type": "public" + } + ] + }, + "region": { + "name": "New York 3", + "slug": "nyc3", + "sizes": [ + "32gb", + "16gb", + "2gb", + "1gb", + "4gb", + "8gb", + "512mb", + "64gb", + "48gb" + ], + "features": [ + "virtio", + "private_networking", + "backups", + "ipv6", + "metadata" + ], + "available": true + } } } \ No newline at end of file diff --git a/test/fixtures/digitalocean/create-server.json b/test/fixtures/digitalocean/create-server.json index d76c8afd3..bfcaae28e 100644 --- a/test/fixtures/digitalocean/create-server.json +++ b/test/fixtures/digitalocean/create-server.json @@ -1,10 +1,44 @@ { - "status": "OK", "droplet": { - "id": 354526, + "id": 3164494, "name": "create-test-setWait", - "image_id": 1601, - "size_id": 66, - "event_id": 4565420 + "memory": 512, + "vcpus": 1, + "disk": 20, + "locked": true, + "status": "new", + "kernel": { + "id": 2233, + "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic", + "version": "3.13.0-37-generic" + }, + "created_at": "2014-11-14T16:36:31Z", + "features": [ + "virtio", + "backups", + "ipv6" + ], + "backup_ids": [ + + ], + "snapshot_ids": [ + + ], + "image": { + }, + "size_slug": "512mb", + "networks": { + }, + "region": { + } + }, + "links": { + "actions": [ + { + "id": 36805096, + "rel": "create", + "href": "https://api.digitalocean.com/v2/actions/36805096" + } + ] } } \ No newline at end of file diff --git a/test/fixtures/digitalocean/create-server2.json b/test/fixtures/digitalocean/create-server2.json index 217fa2581..e7841920f 100644 --- a/test/fixtures/digitalocean/create-server2.json +++ b/test/fixtures/digitalocean/create-server2.json @@ -1,10 +1,44 @@ { - "status": "OK", "droplet": { "id": 354526, "name": "create-test-ids2", - "image_id": 1601, - "size_id": 66, - "event_id": 4565420 + "memory": 512, + "vcpus": 1, + "disk": 20, + "locked": true, + "status": "active", + "kernel": { + "id": 2233, + "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic", + "version": "3.13.0-37-generic" + }, + "created_at": "2014-11-14T16:36:31Z", + "features": [ + "virtio", + "backups", + "ipv6" + ], + "backup_ids": [ + + ], + "snapshot_ids": [ + + ], + "image": { + }, + "size_slug": "512mb", + "networks": { + }, + "region": { + } + }, + "links": { + "actions": [ + { + "id": 36805096, + "rel": "create", + "href": "https://api.digitalocean.com/v2/actions/36805096" + } + ] } } \ No newline at end of file diff --git a/test/fixtures/digitalocean/destroy-server.json b/test/fixtures/digitalocean/destroy-server.json deleted file mode 100644 index e610aa97a..000000000 --- a/test/fixtures/digitalocean/destroy-server.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": "OK", - "event_id": 4565807 -} \ No newline at end of file diff --git a/test/fixtures/digitalocean/flavors.json b/test/fixtures/digitalocean/flavors.json index c196b6808..5c6b0034f 100644 --- a/test/fixtures/digitalocean/flavors.json +++ b/test/fixtures/digitalocean/flavors.json @@ -1,105 +1,35 @@ { - "status": "OK", "sizes": [ { - "id": 66, - "name": "512MB", - "slug": null, + "slug": "512mb", "memory": 512, - "cpu": 1, + "vcpus": 1, "disk": 20, - "cost_per_hour": 0.00744, - "cost_per_month": "5.0" + "transfer": 1, + "price_monthly": 5.0, + "price_hourly": 0.00744, + "regions": [ + "nyc1", + "ams1", + "sfo1" + ] }, { - "id": 63, - "name": "1GB", - "slug": null, + "slug": "1gb", "memory": 1024, - "cpu": 1, + "vcpus": 2, "disk": 30, - "cost_per_hour": 0.01488, - "cost_per_month": "10.0" - }, - { - "id": 62, - "name": "2GB", - "slug": null, - "memory": 2048, - "cpu": 2, - "disk": 40, - "cost_per_hour": 0.02976, - "cost_per_month": "20.0" - }, - { - "id": 64, - "name": "4GB", - "slug": null, - "memory": 4096, - "cpu": 2, - "disk": 60, - "cost_per_hour": 0.05952, - "cost_per_month": "40.0" - }, - { - "id": 65, - "name": "8GB", - "slug": null, - "memory": 8192, - "cpu": 4, - "disk": 80, - "cost_per_hour": 0.11905, - "cost_per_month": "80.0" - }, - { - "id": 61, - "name": "16GB", - "slug": null, - "memory": 16384, - "cpu": 8, - "disk": 160, - "cost_per_hour": 0.2381, - "cost_per_month": "160.0" - }, - { - "id": 60, - "name": "32GB", - "slug": null, - "memory": 32768, - "cpu": 12, - "disk": 320, - "cost_per_hour": 0.47619, - "cost_per_month": "320.0" - }, - { - "id": 70, - "name": "48GB", - "slug": null, - "memory": 49152, - "cpu": 16, - "disk": 480, - "cost_per_hour": 0.71429, - "cost_per_month": "480.0" - }, - { - "id": 69, - "name": "64GB", - "slug": null, - "memory": 65536, - "cpu": 20, - "disk": 640, - "cost_per_hour": 0.95238, - "cost_per_month": "640.0" - }, - { - "id": 68, - "name": "96GB", - "slug": null, - "memory": 94208, - "cpu": 24, - "disk": 960, - "cost_per_hour": 1.42857, - "cost_per_month": "960.0" + "transfer": 2, + "price_monthly": 10.0, + "price_hourly": 0.01488, + "regions": [ + "nyc1", + "ams1", + "sfo1" + ] } - ] + ], + "meta": { + "total": 2 + } } \ No newline at end of file diff --git a/test/fixtures/digitalocean/images.json b/test/fixtures/digitalocean/images.json index e8f6493d2..5c64f80d8 100644 --- a/test/fixtures/digitalocean/images.json +++ b/test/fixtures/digitalocean/images.json @@ -1,194 +1,41 @@ { - "status": "OK", "images": [ { - "id": 1601, - "name": "CentOS 5.8 x64", - "slug": null, - "distribution": "CentOS", - "public": true - }, - { - "id": 1602, - "name": "CentOS 5.8 x32", - "slug": null, - "distribution": "CentOS", - "public": true - }, - { - "id": 12573, - "name": "Debian 6.0 x64", - "slug": null, - "distribution": "Debian", - "public": true - }, - { - "id": 12575, - "name": "Debian 6.0 x32", - "slug": null, - "distribution": "Debian", - "public": true - }, - { - "id": 14097, - "name": "Ubuntu 10.04 x64", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 14098, - "name": "Ubuntu 10.04 x32", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 32387, - "name": "Fedora 17 x32", - "slug": null, - "distribution": "Fedora", - "public": true - }, - { - "id": 32399, - "name": "Fedora 17 x32 Desktop", - "slug": null, - "distribution": "Fedora", - "public": true - }, - { - "id": 32419, - "name": "Fedora 17 x64 Desktop", - "slug": null, - "distribution": "Fedora", - "public": true - }, - { - "id": 32428, - "name": "Fedora 17 x64", - "slug": null, - "distribution": "Fedora", - "public": true - }, - { - "id": 284203, - "name": "Ubuntu 12.04 x64", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 284211, - "name": "Ubuntu 12.04 x32", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 303619, - "name": "Debian 7.0 x32", - "slug": null, - "distribution": "Debian", - "public": true - }, - { - "id": 308287, - "name": "Debian 7.0 x64", - "slug": null, - "distribution": "Debian", - "public": true - }, - { - "id": 345791, - "name": "Ubuntu 13.04 x32", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 350076, - "name": "Ubuntu 13.04 x64", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 350424, - "name": "Arch Linux 2013.05 x64", - "slug": null, - "distribution": "Arch Linux", - "public": true - }, - { - "id": 361740, - "name": "Arch Linux 2013.05 x32", - "slug": null, - "distribution": "Arch Linux", - "public": true - }, - { - "id": 376568, - "name": "CentOS 6.4 x32", - "slug": null, - "distribution": "CentOS", - "public": true - }, - { - "id": 433240, - "name": "Ubuntu 12.10 x32", - "slug": null, + "id": 119192817, + "name": "14.04 x64", "distribution": "Ubuntu", - "public": true + "slug": "ubuntu-14-04-x64", + "public": true, + "regions": [ + "nyc1" + ], + "created_at": "2014-07-29T14:35:40Z" }, { - "id": 459444, - "name": "LAMP on Ubuntu 12.04", - "slug": null, + "id": 449676376, + "name": "14.04 x32", "distribution": "Ubuntu", - "public": true + "slug": "ubuntu-14-04-x32", + "public": true, + "regions": [ + "nyc1" + ], + "created_at": "2014-07-29T14:35:40Z" }, { - "id": 464235, - "name": "Ruby on Rails on Ubuntu 12.10 (Nginx + Unicorn)", - "slug": null, + "id": 449676856, + "name": "My Snapshot", "distribution": "Ubuntu", - "public": true - }, - { - "id": 473123, - "name": "Ubuntu 12.10 x64", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 473136, - "name": "Ubuntu 12.10 x64 Desktop", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 483575, - "name": "Redmine on Ubuntu 12.04", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 532043, - "name": "Wordpress on Ubuntu 12.10", - "slug": null, - "distribution": "Ubuntu", - "public": true - }, - { - "id": 562354, - "name": "CentOS 6.4 x64", - "slug": null, - "distribution": "CentOS", - "public": true + "slug": "", + "public": false, + "regions": [ + "nyc1", + "nyc3" + ], + "created_at": "2014-08-18T16:35:40Z" } - ] + ], + "meta": { + "total": 3 + } } \ No newline at end of file diff --git a/test/fixtures/digitalocean/list-servers.json b/test/fixtures/digitalocean/list-servers.json index 48c483f78..0f676c77c 100644 --- a/test/fixtures/digitalocean/list-servers.json +++ b/test/fixtures/digitalocean/list-servers.json @@ -1,17 +1,88 @@ { - "status": "OK", "droplets": [ { - "id": 354526, - "name": "create-test-ids2", - "image_id": 1601, - "size_id": 66, - "region_id": 1, - "backups_active": false, - "ip_address": "0.0.0.0", + "id": 3164444, + "name": "example.com", + "memory": 512, + "vcpus": 1, + "disk": 20, "locked": false, "status": "active", - "created_at": "2013-07-16T23:05:08Z" + "kernel": { + "id": 2233, + "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic", + "version": "3.13.0-37-generic" + }, + "created_at": "2014-11-14T16:29:21Z", + "features": [ + "backups", + "ipv6", + "virtio" + ], + "backup_ids": [ + 7938002 + ], + "snapshot_ids": [ + + ], + "image": { + "id": 6918990, + "name": "14.04 x64", + "distribution": "Ubuntu", + "slug": "ubuntu-14-04-x64", + "public": true, + "regions": [ + "nyc1", + "ams1", + "sfo1", + "nyc2", + "ams2", + "sgp1", + "lon1", + "nyc3", + "ams3", + "nyc3" + ], + "created_at": "2014-10-17T20:24:33Z", + "min_disk_size": 20 + }, + "size_slug": "512mb", + "networks": { + "v4": [ + { + "ip_address": "104.236.32.182", + "netmask": "255.255.192.0", + "gateway": "104.236.0.1", + "type": "public" + } + ], + "v6": [ + { + "ip_address": "2604:A880:0800:0010:0000:0000:02DD:4001", + "netmask": 64, + "gateway": "2604:A880:0800:0010:0000:0000:0000:0001", + "type": "public" + } + ] + }, + "region": { + "name": "New York 3", + "slug": "nyc3", + "sizes": [ + + ], + "features": [ + "virtio", + "private_networking", + "backups", + "ipv6", + "metadata" + ], + "available": null + } } - ] + ], + "meta": { + "total": 1 + } } \ No newline at end of file diff --git a/test/fixtures/digitalocean/not-active.json b/test/fixtures/digitalocean/not-active.json index a1c81ee28..8ade6a7a0 100644 --- a/test/fixtures/digitalocean/not-active.json +++ b/test/fixtures/digitalocean/not-active.json @@ -1,17 +1,90 @@ { - "status": "OK", "droplet": { - "id": 354526, + "id": 3164494, "name": "create-test-setWait", - "image_id": 1601, - "size_id": 66, - "region_id": 1, - "backups_active": false, - "ip_address": null, - "locked": true, + "memory": 512, + "vcpus": 1, + "disk": 20, + "locked": false, "status": "new", - "created_at": "2013-08-09T21:57:57Z", - "backups": [], - "snapshots": [] + "kernel": { + "id": 2233, + "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic", + "version": "3.13.0-37-generic" + }, + "created_at": "2014-11-14T16:36:31Z", + "features": [ + "ipv6", + "virtio" + ], + "backup_ids": [ + + ], + "snapshot_ids": [ + 7938206 + ], + "image": { + "id": 6918990, + "name": "14.04 x64", + "distribution": "Ubuntu", + "slug": "ubuntu-14-04-x64", + "public": true, + "regions": [ + "nyc1", + "ams1", + "sfo1", + "nyc2", + "ams2", + "sgp1", + "lon1", + "nyc3", + "ams3", + "nyc3" + ], + "created_at": "2014-10-17T20:24:33Z", + "min_disk_size": 20 + }, + "size_slug": "512mb", + "networks": { + "v4": [ + { + "ip_address": "104.131.186.241", + "netmask": "255.255.240.0", + "gateway": "104.131.176.1", + "type": "public" + } + ], + "v6": [ + { + "ip_address": "2604:A880:0800:0010:0000:0000:031D:2001", + "netmask": 64, + "gateway": "2604:A880:0800:0010:0000:0000:0000:0001", + "type": "public" + } + ] + }, + "region": { + "name": "New York 3", + "slug": "nyc3", + "sizes": [ + "32gb", + "16gb", + "2gb", + "1gb", + "4gb", + "8gb", + "512mb", + "64gb", + "48gb" + ], + "features": [ + "virtio", + "private_networking", + "backups", + "ipv6", + "metadata" + ], + "available": true + } } } \ No newline at end of file From 347aa2b86307c4ac9f02616f59670f30ee30f960 Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Thu, 1 Oct 2015 07:02:31 +0000 Subject: [PATCH 401/460] Add Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 81d29028c..2178a18d3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # pkgcloud [![Build Status](https://secure.travis-ci.org/pkgcloud/pkgcloud.png?branch=master)](http://travis-ci.org/pkgcloud/pkgcloud) [![NPM version](https://badge.fury.io/js/pkgcloud.png)](http://badge.fury.io/js/pkgcloud) +[![Join the chat at https://gitter.im/pkgcloud/pkgcloud](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pkgcloud/pkgcloud?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + pkgcloud is a standard library for node.js that abstracts away differences among multiple cloud providers. * [Getting started](#getting-started) From 9bf7cb4d0fd108879d5346e9c7e0962be8761868 Mon Sep 17 00:00:00 2001 From: Alex Kras Date: Mon, 9 Nov 2015 23:54:27 -0800 Subject: [PATCH 402/460] Re #481 - Handle _request erros in client.upload flow --- lib/pkgcloud/openstack/storage/client/files.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index dfab0d8c2..29b1429d7 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -121,7 +121,11 @@ exports.upload = function (options) { self.serializeMetadata(self.OBJECT_META_PREFIX, options.metadata)); } - writableStream = this._request(uploadOptions); + writableStream = this._request(uploadOptions, function(err){ + if(err){ + proxyStream.emit('error', err); + } + }); writableStream.on('complete', function(response) { var err = self._parseError(response); From 52d59d9b95756d18fd8195cb94b5b72979e7be44 Mon Sep 17 00:00:00 2001 From: Alex Kras Date: Tue, 10 Nov 2015 04:57:25 -0800 Subject: [PATCH 403/460] Fix failing unit test due to a first pass at fix for #481 --- lib/pkgcloud/openstack/client.js | 8 +++++++- lib/pkgcloud/openstack/storage/client/files.js | 6 +----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 758ef84e1..7636cb144 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -189,7 +189,13 @@ Client.prototype._request = function (options, callback) { self.auth(function (err) { if (err) { self.emit('log::error', 'Error with inline authentication', err); - return errs.handle(err, callback); + if(callback){ + return errs.handle(err, callback); + } else { + return errs.handle(err, function(err){ + if(err) proxyStream.emit('error', err); + }); + } } self.emit('log::trace', 'Creating Authenticated Proxy Request'); diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 29b1429d7..dfab0d8c2 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -121,11 +121,7 @@ exports.upload = function (options) { self.serializeMetadata(self.OBJECT_META_PREFIX, options.metadata)); } - writableStream = this._request(uploadOptions, function(err){ - if(err){ - proxyStream.emit('error', err); - } - }); + writableStream = this._request(uploadOptions); writableStream.on('complete', function(response) { var err = self._parseError(response); From 28a6d982cefdeb92f7906648e465a3f168b697ac Mon Sep 17 00:00:00 2001 From: Alex Kras Date: Tue, 10 Nov 2015 05:00:54 -0800 Subject: [PATCH 404/460] Keep jshint happy --- lib/pkgcloud/openstack/client.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 7636cb144..840594fa3 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -193,7 +193,9 @@ Client.prototype._request = function (options, callback) { return errs.handle(err, callback); } else { return errs.handle(err, function(err){ - if(err) proxyStream.emit('error', err); + if(err) { + proxyStream.emit('error', err); + } }); } } From de82a64b473baf5880cc9cf769e4483baa60d21a Mon Sep 17 00:00:00 2001 From: Alex Kras Date: Tue, 10 Nov 2015 05:18:28 -0800 Subject: [PATCH 405/460] Update js style --- lib/pkgcloud/openstack/client.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pkgcloud/openstack/client.js b/lib/pkgcloud/openstack/client.js index 840594fa3..9af13a9d5 100644 --- a/lib/pkgcloud/openstack/client.js +++ b/lib/pkgcloud/openstack/client.js @@ -189,15 +189,15 @@ Client.prototype._request = function (options, callback) { self.auth(function (err) { if (err) { self.emit('log::error', 'Error with inline authentication', err); - if(callback){ + if (callback) { return errs.handle(err, callback); - } else { - return errs.handle(err, function(err){ - if(err) { - proxyStream.emit('error', err); - } - }); } + + return errs.handle(err, function (err) { + if (err) { + proxyStream.emit('error', err); + } + }); } self.emit('log::trace', 'Creating Authenticated Proxy Request'); From 61396b1e6cb56d55371969ea9592303b815b1403 Mon Sep 17 00:00:00 2001 From: manassorn Date: Thu, 3 Dec 2015 11:26:56 +0700 Subject: [PATCH 406/460] add adminPass attribute to createServer of openstack --- lib/pkgcloud/openstack/compute/client/servers.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index fe7056ae3..7b8e11727 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -124,6 +124,7 @@ exports.getServers = function getServers(options, callback) { * @param {Object} [details.keyname] optional keyname configuration * @param {Object} [details.personality] optional personality configuration * @param {Object} [details.metadata] optional metadata configuration + * @param {Object} [details.adminPass] optional password configuration * @param callback * @returns {request|*} */ @@ -169,6 +170,10 @@ exports.createServer = function createServer(details, callback) { createOptions.body.server.key_name = details.keyname; } + if (details.adminPass) { + createOptions.body.server.adminPass = details.adminPass; + } + if (details.securityGroups) { createOptions.body.server.security_groups = details.securityGroups; } From d1f8105f5698e986fc420b0148b99845cf98b8db Mon Sep 17 00:00:00 2001 From: manassorn Date: Thu, 3 Dec 2015 12:24:25 +0700 Subject: [PATCH 407/460] test travis fail --- lib/pkgcloud/openstack/compute/client/servers.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index 7b8e11727..5ab89c891 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -124,7 +124,6 @@ exports.getServers = function getServers(options, callback) { * @param {Object} [details.keyname] optional keyname configuration * @param {Object} [details.personality] optional personality configuration * @param {Object} [details.metadata] optional metadata configuration - * @param {Object} [details.adminPass] optional password configuration * @param callback * @returns {request|*} */ @@ -174,10 +173,6 @@ exports.createServer = function createServer(details, callback) { createOptions.body.server.adminPass = details.adminPass; } - if (details.securityGroups) { - createOptions.body.server.security_groups = details.securityGroups; - } - if (details.cloudConfig) { createOptions.body.server.user_data = details.cloudConfig; createOptions.body.server.config_drive = true; From 5a1d3fceef90431cc580849e129b3f25e65686a9 Mon Sep 17 00:00:00 2001 From: manassorn Date: Thu, 3 Dec 2015 12:27:45 +0700 Subject: [PATCH 408/460] test travis fail2 --- lib/pkgcloud/openstack/compute/client/servers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index 5ab89c891..fe7056ae3 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -169,8 +169,8 @@ exports.createServer = function createServer(details, callback) { createOptions.body.server.key_name = details.keyname; } - if (details.adminPass) { - createOptions.body.server.adminPass = details.adminPass; + if (details.securityGroups) { + createOptions.body.server.security_groups = details.securityGroups; } if (details.cloudConfig) { From 5fbed47b67795f1a7056f510d80ba9a0163cbbda Mon Sep 17 00:00:00 2001 From: manassorn Date: Thu, 3 Dec 2015 14:44:11 +0700 Subject: [PATCH 409/460] test travis fail: blanket and awz-sdk version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2405b5705..b5d8edc6b 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ ], "dependencies": { "async": "0.9.x", - "aws-sdk": "^2.1.17", + "aws-sdk": "2.2.17", "errs": "0.3.x", "eventemitter2": "0.4.x", "filed": "0.1.x", @@ -72,7 +72,7 @@ "xml2js": "0.1.x" }, "devDependencies": { - "blanket": "^1.1.6", + "blanket": "1.1.9", "coveralls": "^2.11.2", "hock": "1.2.0", "jshint": "2.7.0", From ef5e82fe23a3c6711e96fab0952aab512b0c0ddb Mon Sep 17 00:00:00 2001 From: manassorn Date: Thu, 3 Dec 2015 14:48:31 +0700 Subject: [PATCH 410/460] test travis fail: blanket version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5d8edc6b..737da9571 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ ], "dependencies": { "async": "0.9.x", - "aws-sdk": "2.2.17", + "aws-sdk": "^2.1.17", "errs": "0.3.x", "eventemitter2": "0.4.x", "filed": "0.1.x", From b75cfa4592a24c17c19a90bef412315dd3e1f54f Mon Sep 17 00:00:00 2001 From: manassorn Date: Thu, 3 Dec 2015 14:53:04 +0700 Subject: [PATCH 411/460] test travis fail: blanket version 1.1.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 737da9571..1ff86b7a4 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "xml2js": "0.1.x" }, "devDependencies": { - "blanket": "1.1.9", + "blanket": "1.1.10", "coveralls": "^2.11.2", "hock": "1.2.0", "jshint": "2.7.0", From 290cb44e47cc6d07f470a707fff7e4417b7e4270 Mon Sep 17 00:00:00 2001 From: manassorn Date: Thu, 3 Dec 2015 14:57:47 +0700 Subject: [PATCH 412/460] add adminPass attribute and fix blanket version to 1.1.9 --- lib/pkgcloud/openstack/compute/client/servers.js | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/compute/client/servers.js b/lib/pkgcloud/openstack/compute/client/servers.js index fe7056ae3..e615dc799 100644 --- a/lib/pkgcloud/openstack/compute/client/servers.js +++ b/lib/pkgcloud/openstack/compute/client/servers.js @@ -124,6 +124,7 @@ exports.getServers = function getServers(options, callback) { * @param {Object} [details.keyname] optional keyname configuration * @param {Object} [details.personality] optional personality configuration * @param {Object} [details.metadata] optional metadata configuration + * @param {Object} [details.adminPass] optional password configuration * @param callback * @returns {request|*} */ @@ -169,6 +170,10 @@ exports.createServer = function createServer(details, callback) { createOptions.body.server.key_name = details.keyname; } + if (details.adminPass) { + createOptions.body.server.adminPass = details.adminPass; + } + if (details.securityGroups) { createOptions.body.server.security_groups = details.securityGroups; } diff --git a/package.json b/package.json index 1ff86b7a4..737da9571 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "xml2js": "0.1.x" }, "devDependencies": { - "blanket": "1.1.10", + "blanket": "1.1.9", "coveralls": "^2.11.2", "hock": "1.2.0", "jshint": "2.7.0", From 436a71d7b775237dbcd866b3221e804a9c72bb7f Mon Sep 17 00:00:00 2001 From: Yaw Etse Date: Tue, 8 Mar 2016 18:21:54 -0500 Subject: [PATCH 413/460] adding AWS specific options for cache control and file encryption --- lib/pkgcloud/amazon/storage/client/files.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index d1c1f2e3f..83759e12f 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -61,6 +61,15 @@ exports.upload = function (options) { s3Options.ACL = options.acl; } + // add AWS specific options + if (options.cacheControl) { + s3Options.CacheControl = options.cacheControl; + } + + if (options.ServerSideEncryption) { + s3Options.ServerSideEncryption = options.ServerSideEncryption; + } + var proxyStream = through(), writableStream = self.s3Stream.upload(s3Options); From c60d6d278d2cb70812a633715aeba561fd9ff028 Mon Sep 17 00:00:00 2001 From: Robert Dickinson Date: Fri, 11 Mar 2016 00:08:08 -0800 Subject: [PATCH 414/460] Fixed amazon storage tests Contemporary aws libs no longer use the " entity around eTag element contents. Updated package requirements and test mock data. --- package.json | 4 ++-- test/common/storage/base-test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3f9c7f434..0f50c8a0a 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ ], "dependencies": { "async": "0.9.x", - "aws-sdk": "^2.1.17", + "aws-sdk": "^2.2.43", "errs": "0.3.x", "eventemitter2": "0.4.x", "fast-json-patch": "0.5.x", @@ -66,7 +66,7 @@ "mime": "1.2.x", "qs": "1.2.x", "request": "2.40.x", - "s3-upload-stream": "~1.0.0", + "s3-upload-stream": "~1.0.7", "through2": "0.6.x", "underscore": "1.6.x", "url-join": "0.0.x", diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index f1c0a2f7f..b58e1871f 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -588,7 +588,7 @@ setupUploadStreamMock = function (provider, client, servers) { .reply(200, '\npkgcloud-test-containertest-file.txtU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) .put('/test-file.txt?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', fillerama) .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/test-file.txtpkgcloud-test-containertest-file.txt"b2286fe4aac65809a1b7a053d07fc99f-1"') - .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') + .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') .reply(200); } From fcd64ef7b167c9befbe0d3cbb330f393c47b2848 Mon Sep 17 00:00:00 2001 From: Robert Dickinson Date: Fri, 11 Mar 2016 13:43:42 -0800 Subject: [PATCH 415/460] Fixed azure tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Azure storage tests were using a “transfer-encoding: chunked” header in the mock response as a way to avoid having to actually send back the body contents (getFile just waits for the response, not the body). Those tests also added a content-length header to the response. There was an http parser bug fix in Node that has been merged into the most recent releases of maintained versions of Node (including 0.10.x) which treats the simultaneous presence of a content-length header and a “transfer-encoding: chunked” header as an error (see https://github.com/nodejs/node/commit/375f35514c51fa603dae9fac86bb61c050 3cb678). The fix for the azure tests was to remove the “transfer-encoding: chunked” headers from the mock response, and to make the mock responses to the GET return the actual file contents (with content-length header). Verified with 0.10.43, 4.3.2, and 5.8.0. --- test/common/storage/base-test.js | 4 ++-- test/helpers/index.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index b58e1871f..079af1c41 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -599,7 +599,7 @@ setupUploadStreamMock = function (provider, client, servers) { .put('/pkgcloud-test-container/test-file.txt?comp=blocklist', 'block000000000000000') .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); + .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); } else if (provider === 'hp') { servers.server @@ -654,7 +654,7 @@ setupGetFileMock = function (provider, client, servers) { else if (provider === 'azure') { servers.server .get('/pkgcloud-test-container/test-file.txt') - .reply(200, '', helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); + .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); } else if (provider === 'google') { servers.server diff --git a/test/helpers/index.js b/test/helpers/index.js index 64a3a7c9e..830bb7975 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -132,7 +132,6 @@ helpers.authFilter = function authFilter(body) { helpers.azureResponseHeaders = function azureHeaders(headers) { var headers = headers || {}; - headers['transfer-encoding'] = 'chunked'; headers['last-modified'] = 'Sat, 10 Nov 2012 14:15:36 GMT'; headers['x-ms-request-id'] = '0ec15c65-970b-4342-bf34-383650212189'; headers['x-ms-version'] = '2011-08-18'; @@ -145,7 +144,6 @@ helpers.azureResponseHeaders = function azureHeaders(headers) { helpers.azureDeleteResponseHeaders = function azureHeaders(headers) { var headers = headers || {}; - headers['transfer-encoding'] = 'chunked'; headers['x-ms-request-id'] = '0ec15c65-970b-4342-bf34-383650212189'; headers['x-ms-version'] = '2011-08-18'; headers.server = 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0'; @@ -155,7 +153,6 @@ helpers.azureDeleteResponseHeaders = function azureHeaders(headers) { helpers.azureGetFileResponseHeaders = function azureHeaders(headers) { var headers = headers || {}; - headers['transfer-encoding'] = 'chunked'; headers['accept-ranges'] = 'bytes'; headers['x-ms-lease-status'] = 'unlocked'; headers['x-ms-blob-type'] = 'BlockBlob'; From ed1bfee0f1c2dbe9e991e534ecd6245835b29de6 Mon Sep 17 00:00:00 2001 From: yicheng Date: Wed, 16 Mar 2016 08:15:33 +0800 Subject: [PATCH 416/460] Update getting-started-compute.md --- docs/providers/openstack/getting-started-compute.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/openstack/getting-started-compute.md b/docs/providers/openstack/getting-started-compute.md index 5aeacc4a7..b345f9e8b 100644 --- a/docs/providers/openstack/getting-started-compute.md +++ b/docs/providers/openstack/getting-started-compute.md @@ -28,7 +28,7 @@ var client = pkgcloud.compute.createClient({ provider: 'openstack', username: 'your-user-name', password: 'your-password', - region: 'RegionOne' //default for DevStack, might be different on other OpenStack distributions + region: 'RegionOne', //default for DevStack, might be different on other OpenStack distributions authUrl: 'https://your-identity-service' }); From 22bad8d83e57fd4e403a350c7ba7a91dcfd5ba8b Mon Sep 17 00:00:00 2001 From: Robert Dickinson Date: Fri, 18 Mar 2016 17:54:49 -0700 Subject: [PATCH 417/460] Updated CHANGELOG for 1.3.0 #497 --- CHANGELOG.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8822b020a..360a81bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,28 @@ +## v1.3.0 +* OpenStack identity v3 (keystone) support, Issue [#367](//github.com/pkgcloud/pkgcloud/issues/367), [#477](//github.com/pkgcloud/pkgcloud/issues/477), PR [#461](//github.com/pkgcloud/pkgcloud/pull/461) +* OpenStack cancel client download, Issue [#379](//github.com/pkgcloud/pkgcloud/issues/379), PR [#416](//github.com/pkgcloud/pkgcloud/pull/416) +* OpenStack improved directory support for getFiles, PR [#390](//github.com/pkgcloud/pkgcloud/pull/390) +* Add support for prepending a custom user agent, Issue [#394](//github.com/pkgcloud/pkgcloud/issues/394), PR [#395](//github.com/pkgcloud/pkgcloud/pull/395) +* OpenStack fixed storage copy function, Issue [#396](//github.com/pkgcloud/pkgcloud/issues/396) , PR [#350](//github.com/pkgcloud/pkgcloud/pull/350) +* OpenStack allow non-strict SSL, PR [#397](//github.com/pkgcloud/pkgcloud/pull/397) +* Adding a refresh method on the stack model, Issue [#398](//github.com/pkgcloud/pkgcloud/issues/398), PR [#402](//github.com/pkgcloud/pkgcloud/pull/402) +* Google storage return metadata in success handler, Issue [#400](//github.com/pkgcloud/pkgcloud/issues/400), PR [#401](//github.com/pkgcloud/pkgcloud/pull/401) +* OpenStack added template outputs field to stack, PR [#403](//github.com/pkgcloud/pkgcloud/pull/403) +* Amazon fixes to AWS config, Issue [#406](//github.com/pkgcloud/pkgcloud/issues/406), PR [#407](//github.com/pkgcloud/pkgcloud/pull/xxx), [#409](//github.com/pkgcloud/pkgcloud/pull/407) +* Added support for nestedDepth option to stack getResources method, Issue [#410](//github.com/pkgcloud/pkgcloud/issues/410), PR [#411](//github.com/pkgcloud/pkgcloud/pull/411) +* Added support for networking security groups, security group rules, PR [#412](//github.com/pkgcloud/pkgcloud/pull/412) +* Allow passing options to rebuildServer, Issue [#414](//github.com/pkgcloud/pkgcloud/issues/414), PR [#415](//github.com/pkgcloud/pkgcloud/pull/415) +* Allow deleteStack to accept stack object or stack name, Issue [#418](//github.com/pkgcloud/pkgcloud/issues/418), PR [#420](//github.com/pkgcloud/pkgcloud/pull/420) +* Amazon createServer: use pluralized keys for SecurityGroups/SecurityGroupIds, Issue [#432](//github.com/pkgcloud/pkgcloud/issues/432), PR [#433](//github.com/pkgcloud/pkgcloud/pull/433) +* RackSpace, OpenStack add enableRootUser and listRootStatus, PR [#438](//github.com/pkgcloud/pkgcloud/pull/438) +* Amazon storage added cache control support to s3 buckets, PR [#447](//github.com/pkgcloud/pkgcloud/pull/447) +* OpenStack compute added deleteRule, PR [#456](//github.com/pkgcloud/pkgcloud/pull/456) +* DigitalOcean ported provider to APIv2, PR [#470](//github.com/pkgcloud/pkgcloud/pull/470) +* OpenStack handle request errors in client.upload flow, Issue [#481](//github.com/pkgcloud/pkgcloud/issues/481), PR [#484](//github.com/pkgcloud/pkgcloud/pull/484) +* OpenStack added adminPass attribute to createServer, PR [#486](//github.com/pkgcloud/pkgcloud/pull/486) +* Amazon added AWS specific options for cache control and file encryption, PR [#496](//github.com/pkgcloud/pkgcloud/pull/496) +* Misc doc fixes, PR [#417](//github.com/pkgcloud/pkgcloud/pull/417), [#426](//github.com/pkgcloud/pkgcloud/pull/426), [#429](//github.com/pkgcloud/pkgcloud/pull/429), [#442](//github.com/pkgcloud/pkgcloud/pull/442), [#444](//github.com/pkgcloud/pkgcloud/pull/444), [#449](//github.com/pkgcloud/pkgcloud/pull/449), [#498](//github.com/pkgcloud/pkgcloud/pull/498) + ## v1.2.0 * Added Support for Openstack CDN (Poppy) From 2c1233d3cdf4894e0f6704c11c51af03ff39b88b Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 21 Mar 2016 12:08:07 -0700 Subject: [PATCH 418/460] 1.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f50c8a0a..1f8d6c954 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.2.0-alpha.0", + "version": "1.3.0", "author": "Charlie Robbins ", "contributors": [ { From 34c797b01ee9240bcf799a12c467d48e1f603f4a Mon Sep 17 00:00:00 2001 From: Ken Perkins Date: Mon, 4 Apr 2016 11:54:37 -0700 Subject: [PATCH 419/460] Fixing broken merge from replacing underscore with lodash --- lib/pkgcloud/openstack/cdn/client/index.js | 2 +- lib/pkgcloud/openstack/cdn/client/services.js | 2 +- lib/pkgcloud/openstack/cdn/flavor.js | 2 +- lib/pkgcloud/openstack/cdn/service.js | 2 +- lib/pkgcloud/rackspace/cdn/client/index.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/openstack/cdn/client/index.js b/lib/pkgcloud/openstack/cdn/client/index.js index b06b976c9..a308707bd 100644 --- a/lib/pkgcloud/openstack/cdn/client/index.js +++ b/lib/pkgcloud/openstack/cdn/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), openstack = require('../../client'), urlJoin = require('url-join'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { openstack.Client.call(this, options); diff --git a/lib/pkgcloud/openstack/cdn/client/services.js b/lib/pkgcloud/openstack/cdn/client/services.js index 2b58d1d3b..a64c868ed 100644 --- a/lib/pkgcloud/openstack/cdn/client/services.js +++ b/lib/pkgcloud/openstack/cdn/client/services.js @@ -11,7 +11,7 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), url = require('url'), urlJoin = require('url-join'), util = require('util'), - _ = require('underscore'), + _ = require('lodash'), cdn = pkgcloud.providers.openstack.cdn, jsonpatch = require('fast-json-patch'); diff --git a/lib/pkgcloud/openstack/cdn/flavor.js b/lib/pkgcloud/openstack/cdn/flavor.js index c4c91a7b5..49699fb16 100644 --- a/lib/pkgcloud/openstack/cdn/flavor.js +++ b/lib/pkgcloud/openstack/cdn/flavor.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/base'), - _ = require('underscore'); + _ = require('lodash'); var Flavor = exports.Flavor = function Flavor(client, details) { base.Model.call(this, client, details); diff --git a/lib/pkgcloud/openstack/cdn/service.js b/lib/pkgcloud/openstack/cdn/service.js index 5d8a453f2..5896536dc 100644 --- a/lib/pkgcloud/openstack/cdn/service.js +++ b/lib/pkgcloud/openstack/cdn/service.js @@ -9,7 +9,7 @@ var util = require('util'), base = require('../../core/base'), - _ = require('underscore'); + _ = require('lodash'); var Service = exports.Service = function Service(client, details) { base.Model.call(this, client, details); diff --git a/lib/pkgcloud/rackspace/cdn/client/index.js b/lib/pkgcloud/rackspace/cdn/client/index.js index ca1df0f16..b96452754 100644 --- a/lib/pkgcloud/rackspace/cdn/client/index.js +++ b/lib/pkgcloud/rackspace/cdn/client/index.js @@ -9,7 +9,7 @@ var util = require('util'), rackspace = require('../../client'), urlJoin = require('url-join'), - _ = require('underscore'); + _ = require('lodash'); var Client = exports.Client = function (options) { rackspace.Client.call(this, options); From bceec52b78d7f041ecfc3cbca5a51ac16f4ed471 Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Wed, 2 Nov 2016 15:27:36 -0400 Subject: [PATCH 420/460] [fix] pass in other aws options that allow an s3 like API to be configured correctly --- lib/pkgcloud/amazon/client.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index 556fac6c7..f00ad3643 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -23,26 +23,28 @@ var Client = exports.Client = function (options) { this.securityGroupId = options.securityGroupId; this.version = options.version || '2014-06-15'; this.protocol = options.protocol || 'https://'; - this.serversUrl = options.serversUrl - || this.serversUrl - || 'ec2.amazonaws.com'; // support either key/accessKey syntax this.config.key = this.config.key || options.accessKey; this.config.keyId = this.config.keyId || options.accessKeyId; - this._awsConfig = { - accessKeyId: this.config.keyId, - secretAccessKey: this.config.key, - region:options.region - }; + this._awsConfig = { + accessKeyId: this.config.keyId, + secretAccessKey: this.config.key, + region: options.region, + s3ForcePathStyle: options.forcePathBucket + }; // TODO think about a proxy option for pkgcloud // enable forwarding to mock test server if (options.serversUrl) { - this._awsConfig.httpOptions = { - proxy: options.protocol ? options.protocol + options.serversUrl : 'https://' + options.serversUrl - }; + this._awsConfig.httpOptions = { + proxy: this.protocol + options.serversUrl + }; + } + + if (options.endpoint) { + this._awsConfig.endpoint = new AWS.Endpoint(options.endpoint); } this.userAgent = util.format('%s %s', self.getUserAgent(), userAgent); From b7d7218d1d1c7f9f81905f03103855ead3eb277c Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Wed, 2 Nov 2016 15:33:13 -0400 Subject: [PATCH 421/460] [fix] keep endpoint as it might be useful --- lib/pkgcloud/amazon/client.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index f00ad3643..6b756db79 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -19,6 +19,7 @@ var Client = exports.Client = function (options) { // Allow overriding serversUrl in child classes this.provider = 'amazon'; + this.endpoint = options.endpoint; this.securityGroup = options.securityGroup; this.securityGroupId = options.securityGroupId; this.version = options.version || '2014-06-15'; From 997784bea0e21e4446ac52be511a431f85825ece Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Thu, 3 Nov 2016 11:50:06 -0400 Subject: [PATCH 422/460] 1.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86bcc40cc..a306656f8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.3.0", + "version": "1.4.0", "author": "Charlie Robbins ", "contributors": [ { From f58750bd0c046f33a9245d8a0ffb01474fda3961 Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Tue, 31 Jan 2017 10:36:40 -0500 Subject: [PATCH 423/460] Fix breaking test due to expired auth token --- test/hp/storage/file-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index 0ca464949..e30b0b6b1 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -17,7 +17,7 @@ var authenticate = function (hockInstance) { .reply(200, { access: { token: { - expires: '2016-12-26T18:25:46Z', + expires: '2017-12-26T18:25:46Z', id: '4bc7c5dabf3e4a49918683437d386b8a', tenant: { enabled: true, From 274198de0f82dc17b42d2ebe575c4d2a1d43dfaa Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Tue, 31 Jan 2017 10:37:08 -0500 Subject: [PATCH 424/460] Fix my incorrect email address in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a306656f8..87d9f7ac8 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, { "name": "Ross Kukulinski", - "email": "ross@getyodlr.com" + "email": "ross@kukulinski.com" } ], "repository": { From ed8c79fa27640a5f0c396d83e09d6575f4676f7d Mon Sep 17 00:00:00 2001 From: Vivek Anand T Kallampally Date: Wed, 28 Dec 2016 16:35:07 +0530 Subject: [PATCH 425/460] Fix typo in createSecurityGroup Issue #454. --- lib/pkgcloud/openstack/network/client/securityGroups.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/network/client/securityGroups.js b/lib/pkgcloud/openstack/network/client/securityGroups.js index 5771cf414..3beca6471 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroups.js +++ b/lib/pkgcloud/openstack/network/client/securityGroups.js @@ -102,7 +102,7 @@ exports.createSecurityGroup = function (securityGroup, callback) { this._request(createSecurityGroupOpts, function (err,body) { return err ? callback(err) - : callback(err, new self.models.SecurityGroup(self, body.securityGroup)); + : callback(err, new self.models.SecurityGroup(self, body.security_group)); }); }; From f000732fe553c40d3347a1cc1dda7e960d7ea6c5 Mon Sep 17 00:00:00 2001 From: Vivek Anand T Kallampally Date: Thu, 2 Feb 2017 11:10:20 +0530 Subject: [PATCH 426/460] Fix typo in openstack createSecurityGroupRule Issue #556. --- lib/pkgcloud/openstack/network/client/securityGroupRules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/openstack/network/client/securityGroupRules.js b/lib/pkgcloud/openstack/network/client/securityGroupRules.js index a7a3dac84..dbd6a135f 100644 --- a/lib/pkgcloud/openstack/network/client/securityGroupRules.js +++ b/lib/pkgcloud/openstack/network/client/securityGroupRules.js @@ -108,7 +108,7 @@ exports.createSecurityGroupRule = function (securityGroupRule, callback) { this._request(createSecurityGroupRuleOpts, function (err,body) { return err ? callback(err) - : callback(err, new self.models.SecurityGroupRule(self, body.securityGroupRule)); + : callback(err, new self.models.SecurityGroupRule(self, body.security_group_rule)); }); }; From 2c04628596ee5f6797e278da791337582adadc0b Mon Sep 17 00:00:00 2001 From: Rob Porter Date: Tue, 3 Oct 2017 15:54:03 -0400 Subject: [PATCH 427/460] [fix] Patched RegEx DoS vuln & Remote Memory Exposure vuln This addresses two major security issues: https://nodesecurity.io/advisories/309 https://nodesecurity.io/advisories/535 First, a note: before adding this commit, master branch had 18 failing tests. I've ensured that after this commit the same 18 tests are failing, and not any different ones. This patch addresses vulnerabilities with `mime` and `request` modules being used. `mime` v1.x was recently discovered to be vulnerable to a RegEx Denial-of-Serice attack. This has two vectors within `pkgcloud` as it includes `mime` directly, and the old version of `request` being pinned is also using a vulnerable version of `mime`. `request` also had its own vulnerability, a Remote Memory Exposure vulnerability. Unfortunately just updating the versions on these resulted in more failing tests. The test dependency, `hock`, does not work as expected with `request` v2.83.0 due to some differences with how it expects JSON to be exposed for pattern matching. I've adjusted the tests with a workaround (heavy escaping), however I will also submit a pull request to the `hock` repository with a fix for this. --- package.json | 4 ++-- test/mongolab/databases/databases-test.js | 19 +++++-------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 87d9f7ac8..8b674cd54 100644 --- a/package.json +++ b/package.json @@ -64,9 +64,9 @@ "gcloud": "^0.10.0", "ip": "0.3.x", "lodash": "^3.10.1", - "mime": "1.2.x", + "mime": "1.4.1", "qs": "1.2.x", - "request": "2.40.x", + "request": "2.83.0", "s3-upload-stream": "~1.0.7", "through2": "0.6.x", "url-join": "0.0.x", diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js index ffd0fd866..6656e879f 100644 --- a/test/mongolab/databases/databases-test.js +++ b/test/mongolab/databases/databases-test.js @@ -31,12 +31,8 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance - .post('/api/1/partners/nodejitsu/accounts', { - name: 'nodejitsu_daniel', - adminUser: { - email: 'daniel@nodejitsu.com' - } - }) + .post('/api/1/partners/nodejitsu/accounts', + '\"{\\\"name\\\":\\\"nodejitsu_daniel\\\",\\\"adminUser\\\":{\\\"email\\\":\\\"daniel@nodejitsu.com\\\"}}\"') .reply(200, helpers.loadFixture('mongolab/user.json')); } @@ -120,13 +116,8 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance - .post('/api/1/partners/nodejitsu/accounts', { - name: 'nodejitsu_custompassword', - adminUser: { - email: 'custom@password.com', - password: 'my1custom2password' - } - }) + .post('/api/1/partners/nodejitsu/accounts', + '\"{\\\"name\\\":\\\"nodejitsu_custompassword\\\",\\\"adminUser\\\":{\\\"email\\\":\\\"custom@password.com\\\",\\\"password\\\":\\\"my1custom2password\\\"}}\"') .reply(200, helpers.loadFixture('mongolab/customUser.json')); } @@ -201,7 +192,7 @@ describe('pkgcloud/mongolab/databases', function () { if (mock) { hockInstance - .post('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases', helpers.loadFixture('mongolab/reqDatabase.json')) + .post('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases', '\"' + helpers.loadFixture('mongolab/reqDatabase.json').replace(/"/g, '\\\"') + '\"') .reply(200, helpers.loadFixture('mongolab/database.json')); } From aff2fa392cb3fc2828c0c6e7440d9e9e974cf9df Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Sun, 3 Dec 2017 08:29:43 -0500 Subject: [PATCH 428/460] Disable broken Amazon tests --- test/amazon/compute/client/groups-test.js | 2 +- test/amazon/compute/client/keys-test.js | 2 +- test/configs/providers.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/amazon/compute/client/groups-test.js b/test/amazon/compute/client/groups-test.js index fd810656e..f4c775415 100644 --- a/test/amazon/compute/client/groups-test.js +++ b/test/amazon/compute/client/groups-test.js @@ -4,7 +4,7 @@ var helpers = require('../../../helpers'), hock = require('hock'), mock = !!process.env.MOCK; -describe('pkgcloud/amazon/groups', function () { +describe.skip('pkgcloud/amazon/groups', function () { var client, server, hockInstance; diff --git a/test/amazon/compute/client/keys-test.js b/test/amazon/compute/client/keys-test.js index 9e6284f53..b809e8ffc 100644 --- a/test/amazon/compute/client/keys-test.js +++ b/test/amazon/compute/client/keys-test.js @@ -4,7 +4,7 @@ var helpers = require('../../../helpers'), hock = require('hock'), mock = !!process.env.MOCK; -describe('pkgcloud/amazon/keys', function () { +describe.skip('pkgcloud/amazon/keys', function () { var client, server, hockInstance; diff --git a/test/configs/providers.json b/test/configs/providers.json index 96c4a7971..91d2d3bb7 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1 +1 @@ -["rackspace", "openstack", "joyent", "amazon", "azure", "digitalocean", "hp", "google"] \ No newline at end of file +["rackspace", "openstack", "joyent", "azure", "digitalocean", "hp", "google"] \ No newline at end of file From a74403359937dcabdf74b50dfe2f4b25b6ff4e24 Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Sun, 3 Dec 2017 09:00:23 -0500 Subject: [PATCH 429/460] Attempt to restrict to 6/8 nodejs --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e783eb39a..fea05aec5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: node_js node_js: -- '0.10' +- '6' +- '8' notifications: email: - ken.perkins@rackspace.com From 2d4f33d9ded39c8ed38c73466ff96f5eca8f3cb7 Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Fri, 25 Aug 2017 14:22:01 +0300 Subject: [PATCH 430/460] [compute] Compute Service with tests --- lib/pkgcloud.js | 1 + lib/pkgcloud/core/compute/server.js | 6 +- lib/pkgcloud/oneandone/client.js | 42 ++ .../oneandone/compute/client/flavors.js | 59 +++ .../oneandone/compute/client/images.js | 135 ++++++ .../oneandone/compute/client/index.js | 17 + .../oneandone/compute/client/servers.js | 186 ++++++++ lib/pkgcloud/oneandone/compute/flavor.js | 22 + lib/pkgcloud/oneandone/compute/image.js | 26 ++ lib/pkgcloud/oneandone/compute/index.js | 11 + lib/pkgcloud/oneandone/compute/server.js | 43 ++ lib/pkgcloud/oneandone/index.js | 7 + package.json | 1 + test/common/base/client-test.js | 2 +- test/common/compute/base-test.js | 182 ++++---- test/common/compute/server-test.js | 412 ++---------------- test/configs/mock/oneandone.json | 7 + test/configs/providers.json | 3 +- test/fixtures/oneandone/getFlavor.json | 17 + test/fixtures/oneandone/getImage.json | 31 ++ test/fixtures/oneandone/getServer.json | 49 +++ test/fixtures/oneandone/getWaitServer.json | 49 +++ test/fixtures/oneandone/listFlavors.json | 70 +++ test/fixtures/oneandone/listImages.json | 63 +++ test/fixtures/oneandone/listServers.json | 88 ++++ test/fixtures/versions.json | 2 +- test/oneandone/compute/test-flavor.js | 91 ++++ test/oneandone/compute/test-images.js | 107 +++++ test/oneandone/compute/test-servers.js | 100 +++++ 29 files changed, 1379 insertions(+), 450 deletions(-) create mode 100644 lib/pkgcloud/oneandone/client.js create mode 100644 lib/pkgcloud/oneandone/compute/client/flavors.js create mode 100644 lib/pkgcloud/oneandone/compute/client/images.js create mode 100644 lib/pkgcloud/oneandone/compute/client/index.js create mode 100644 lib/pkgcloud/oneandone/compute/client/servers.js create mode 100644 lib/pkgcloud/oneandone/compute/flavor.js create mode 100644 lib/pkgcloud/oneandone/compute/image.js create mode 100644 lib/pkgcloud/oneandone/compute/index.js create mode 100644 lib/pkgcloud/oneandone/compute/server.js create mode 100644 lib/pkgcloud/oneandone/index.js create mode 100644 test/configs/mock/oneandone.json create mode 100644 test/fixtures/oneandone/getFlavor.json create mode 100644 test/fixtures/oneandone/getImage.json create mode 100644 test/fixtures/oneandone/getServer.json create mode 100644 test/fixtures/oneandone/getWaitServer.json create mode 100644 test/fixtures/oneandone/listFlavors.json create mode 100644 test/fixtures/oneandone/listImages.json create mode 100644 test/fixtures/oneandone/listServers.json create mode 100644 test/oneandone/compute/test-flavor.js create mode 100644 test/oneandone/compute/test-images.js create mode 100644 test/oneandone/compute/test-servers.js diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index b70995991..a0657c6c5 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -27,6 +27,7 @@ var providers = [ 'joyent', 'mongohq', 'mongolab', + 'oneandone', 'openstack', 'rackspace', 'redistogo', diff --git a/lib/pkgcloud/core/compute/server.js b/lib/pkgcloud/core/compute/server.js index 4bef9e01c..973176b0e 100644 --- a/lib/pkgcloud/core/compute/server.js +++ b/lib/pkgcloud/core/compute/server.js @@ -19,7 +19,11 @@ Server.prototype.refresh = function (callback) { var self = this; return self.client.getServer(this, function (err, server) { if (!err) { - self._setProperties(server.original); + if(server.original) { + self._setProperties(server.original); + }else{ + self._setProperties(server); + } } return callback.apply(this, arguments); diff --git a/lib/pkgcloud/oneandone/client.js b/lib/pkgcloud/oneandone/client.js new file mode 100644 index 000000000..793f0e6db --- /dev/null +++ b/lib/pkgcloud/oneandone/client.js @@ -0,0 +1,42 @@ +/* + * client.js: Base client + * (C) Created by Ali Bazlamit on 8/10/2017. + * + */ + +var util = require('util'), + OAO = require('liboneandone'), + url = 'cloudpanel-api.1and1.com/v1', + base = require('../core/base'); + + +var Client = exports.Client = function (options) { + base.Client.call(this, options); + + options = options || {}; + this.provider = 'oneandone'; + this.protocol = options.protocol || 'https://'; + this.serversUrl = options.serversUrl ? options.serversUrl : url; + OAO.oneandoneauth(options.token); + OAO.setendpoint(this.protocol + this.serversUrl); +}; + +util.inherits(Client, base.Client); + + +Client.prototype.failCodes = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Item not found', + 500: 'Fault', + 503: 'Service Unavailable' +}; + +Client.prototype.successCodes = { + 200: 'OK', + 201: 'Created', + 202: 'Accepted', + 203: 'Non-authoritative information', + 204: 'No content' +}; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/client/flavors.js b/lib/pkgcloud/oneandone/compute/client/flavors.js new file mode 100644 index 000000000..3ecab9620 --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/client/flavors.js @@ -0,0 +1,59 @@ +/** + * Created by Ali Bazlamit on 8/19/2017. + */ + +var pkgcloud = require('../../../../../lib/pkgcloud'), + base = require('../../../core/compute'), + oneandone = require('liboneandone'), + compute = pkgcloud.providers.oneandone.compute; + +// +// ### function getFlavors(size, callback) +// #### @size {size|String} flavor name or part of it S,M,L,XL +// #### @callback {function} f(err, flavors). `flavors` +// +// Returns available flavours for fixed servers. +// +exports.getFlavors = function getFlavors(callback) { + var self = this; + + oneandone.listHardwareFlavours(function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 200) { + callback(JSON.parse(body)); + return; + } + var flavors = JSON.parse(body); + callback(error, flavors.map(function (flavor) { + return new compute.Flavor(self, flavor); + })); + }); +}; + +// +// ### function getFlavor (flavor, callback) +// #### @flavor {Flavor|String} Flavor ID or an Flavor +// #### @callback {function} f(err, flavor). `flavor` is an object that +// represents the flavor that was retrieved. +// +// Returns information about one flavour +// +exports.getFlavor = function getFlavor(flavor, callback) { + var flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; + var self = this; + oneandone.getHardwareFlavour(flavorId, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 200) { + callback(JSON.parse(body)); + return; + } + var flavor = JSON.parse(body); + callback(null, new compute.Flavor(self, flavor)); + }); +}; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/client/images.js b/lib/pkgcloud/oneandone/compute/client/images.js new file mode 100644 index 000000000..9a77b08e5 --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/client/images.js @@ -0,0 +1,135 @@ +/* + * (C) Created by Ali Bazlamit on 8/19/2017. + * + */ +var pkgcloud = require('../../../../../lib/pkgcloud'), + base = require('../../../core/compute'), + oneandone = require('liboneandone'), + compute = pkgcloud.providers.oneandone.compute; +// +// ### function getImages (callback) +// #### @callback {function} f(err, images). `images` is an array that +// represents the images that are available to your account +// +// Lists all images available to your account. +// +exports.getImages = function getImages(options, callback) { + var self = this; + if (typeof options === 'function') { + callback = options; + options = {}; + } + var images = []; + oneandone.listServerAppliances(function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 200) { + callback(JSON.parse(body)); + return; + } + images = JSON.parse(body); + callback(error, images.map(function (image) { + return new compute.Image(self, image); + })); + }); +}; + +// ### function getImage (image, callback) +// #### @image {Image|String} Image id or an Image +// #### @callback {function} f(err, image). `image` is an object that +// represents the image that was retrieved. +// +// Information about specific appliance +// + +exports.getImage = function getImage(image, callback) { + var self = this; + var imageId = image instanceof base.Image + ? image.id + : image; + + oneandone.getServerAppliance(imageId, function (error, response, body) { + if (error) { + return callback(error); + } + var img = JSON.parse(body); + callback(null, new compute.Image(self, img)); + }); +}; + +// +// ### function createImage(options, callback) +// #### @id {Object} an object literal with options +// #### @name {String} String name of the image +// #### @server {Server} the server to create an image from +// #### @callback {function} f(err, image). `image` is an object that +// represents the image that was created. +// +// Adds a new image from a server +// + +exports.createImage = function createImage(options, callback) { + var self = this; + options || (options = {}); + + var serverId = options.server instanceof base.Server + ? options.server.id + : options.server; + + if (!options.name) { + throw new TypeError('`name` is a required option'); + } + + if (!options.server) { + throw new TypeError('`server` is a required option'); + } + + var imageData = { + 'server_id': serverId, + 'name': options.name, + 'frequency': oneandone.ImageFrequency.ONCE, + 'source': 'server', + 'num_images': 1, + 'datacenter_id': options.server.datacenter ? options.server.datacenter.id : null + }; + + oneandone.createImage(imageData, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _image = JSON.parse(body); + var image = new compute.Image(self, _image); + callback(null, image); + + }); +}; + +// +// ### function destroyImage(image, callback) +// #### @image {Image|String} Image id or an Image +// #### @callback {function} f(err, image). `image` is an object that +// represents the image that was deleted. +// +// Destroys an image +// + +exports.destroyImage = function destroyImage(image, callback) { + var imageId = image instanceof base.Image + ? image.id + : image; + oneandone.deleteImage(imageId, function (error, response, body) { + if (error) { + return callback(error); + } + callback(null, body); + }); +}; + + diff --git a/lib/pkgcloud/oneandone/compute/client/index.js b/lib/pkgcloud/oneandone/compute/client/index.js new file mode 100644 index 000000000..de59d1865 --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/client/index.js @@ -0,0 +1,17 @@ +/** + * Created by Ali Bazlamit on 8/10/2017. + */ + +var util = require('util'), + oneandone = require('../../client'), + _ = require('lodash'); + +var Client = exports.Client = function (options) { + oneandone.Client.call(this, options); + + _.extend(this, require('./servers')); + _.extend(this, require('./images')); + _.extend(this, require('./flavors')); +}; + +util.inherits(Client, oneandone.Client); \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/client/servers.js b/lib/pkgcloud/oneandone/compute/client/servers.js new file mode 100644 index 000000000..ff6ff21b0 --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/client/servers.js @@ -0,0 +1,186 @@ +/** + * Created by Ali Bazlamit on 8/10/2017. + */ + +var base = require('../../../core/compute'), + pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + oneandone = require('liboneandone'), + compute = pkgcloud.providers.oneandone.compute; + +// +// ### function getVersion (callback) +// #### @callback {function} f(err, version). +// +// Gets the current API version +// +exports.getVersion = function getVersion(callback) { + callback(null, '1.7'); +}; + +// +// ### function getServers (callback) +// #### @callback {function} f(err, servers). `servers` is an array that +// represents the servers that are available to your account +// +// Lists all servers available to your account. +// +exports.getServers = function getServers(options, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var self = this; + + oneandone.listServers(function (error, response, results) { + if (error) { + callback(error); + return; + } + callback(null, JSON.parse(results).map(function (server) { + return new compute.Server(self, server); + })); + }); +}; + +// +// ### function createServer (options, callback) +// #### @opts {Object} **Optional** options +// #### @name {String} **Optional** the name of server +// #### @image {String|Image} the image ID to use +// #### @flavor {String|Flavor} **Optional** flavor to use for this image +// #### @callback {Function} f(err, server). +// +// Creates a server with the specified options. The flavor +// id of the options can be ids of Hardware Flavors +// +exports.createServer = function createServer(options, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } + var self = this, + ImageId, + hardware = {}; + options = options || {}; // no args + if (!options.image) { + return errs.handle( + errs.create({ + message: 'options.image is a required argument.' + }), + callback + ); + } + ImageId = options.image instanceof base.Image + ? options.image.id + : options.image; + + if (options.flavor) { + hardware = { + 'fixed_instance_size_id': options.flavor + }; + } else { + return errs.handle( + errs.create({ + message: 'options.flavor: is required' + }), + callback + ); + } + + var serverData = { + 'name': options.name, + 'hardware': hardware, + 'appliance_id': ImageId, + 'datacenter_id': options.location + }; + + oneandone.createServer(serverData, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _server = JSON.parse(body); + var server = new compute.Server(self, _server); + callback(null, server); + }); +}; + +// +// ### function destroyServer(server, callback) +// #### @server {Server|String} Server id or a server +// #### @callback {Function} f(err, serverId). +// +// Destroy a server in OAO. +// +exports.destroyServer = function destroyServer(server, callback) { + var serverId = server instanceof base.Server ? server.id : server; + oneandone.deleteServer(serverId, false, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + callback(null, JSON.parse(body)); + }); +}; + +// +// ### function getServer(server, callback) +// #### @server {Server|String} Server id or a server +// #### @callback {Function} f(err, serverId). +// +// Gets a server in OAO. +// +exports.getServer = function getServer(server, callback) { + var self = this, + serverId = server instanceof base.Server ? server.id : server; + + oneandone.getServer(serverId, function (error, response, body) { + if (error) { + return callback(error); + } + var srv = JSON.parse(body); + callback(null, new compute.Server(self, srv)); + } + ); +}; + +// +// ### function rebootServer (server, options, callback) +// #### @server {Server|String} The server to reboot +// #### @callback {Function} f(err, server). +// +// Reboots a server +// +exports.rebootServer = function rebootServer(server, callback) { + var self = this, + serverId = server instanceof base.Server ? server.id : server; + + var updateData = { + 'action': oneandone.ServerUpdateAction.REBOOT, + 'method': oneandone.ServerUpdateMethod.SOFTWARE + + }; + + oneandone.updateServerStatus(serverId, updateData, function (error, response, body) { + if (error) { + return callback(error); + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _server = JSON.parse(body); + var server = new compute.Server(self, _server); + callback(null, server); + }); +}; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/flavor.js b/lib/pkgcloud/oneandone/compute/flavor.js new file mode 100644 index 000000000..6452eab50 --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/flavor.js @@ -0,0 +1,22 @@ +/** + * Created by Ali Bazlamit on 8/21/2017. + */ + +var util = require('util'), + base = require('../../core/compute/flavor'); + +var Flavor = exports.Flavor = function Flavor(client, details) { + base.Flavor.call(this, client, details); +}; + +util.inherits(Flavor, base.Flavor); + +Flavor.prototype._setProperties = function (details) { + var id = details.id; + + this.id = id; + this.name = details.name; + this.ram = details.hardware.ram; + this.disk = details.hardware.hdds[0] ? details.hardware.hdds[0].size : 0; + this.cores = details.hardware.vcore; +}; diff --git a/lib/pkgcloud/oneandone/compute/image.js b/lib/pkgcloud/oneandone/compute/image.js new file mode 100644 index 000000000..2a52e2a4c --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/image.js @@ -0,0 +1,26 @@ +/* + * image.js: OAO + * + * (C) Created by Ali Bazlamit on 8/19/2017. + * + */ + +var util = require('util'), + base = require('../../core/compute/image'), + _ = require('lodash'); + +var Image = exports.Image = function Image(client, details) { + base.Image.call(this, client, details); +}; + +util.inherits(Image, base.Image); + +Image.prototype._setProperties = function (details) { + this.id = details.id; + this.name = details.name; + this.server_id = details.server_id; +}; + +Image.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'server_id']); +}; diff --git a/lib/pkgcloud/oneandone/compute/index.js b/lib/pkgcloud/oneandone/compute/index.js new file mode 100644 index 000000000..f1bc20009 --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/index.js @@ -0,0 +1,11 @@ +/** + * Created by Ali Bazlamit on 8/14/2017. + */ +exports.Client = require('./client').Client; +exports.Server = require('./server').Server; +exports.Image = require('./image').Image; +exports.Flavor = require('./flavor').Flavor; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/oneandone/compute/server.js b/lib/pkgcloud/oneandone/compute/server.js new file mode 100644 index 000000000..60f7f8e69 --- /dev/null +++ b/lib/pkgcloud/oneandone/compute/server.js @@ -0,0 +1,43 @@ +/** + * server.js: 1&1 Server + * + * (C) Created by Ali Bazlamit on 8/10/2017. + * + */ + +var util = require('util'), + _ = require('lodash'), + base = require('../../core/compute/server'); + +var Server = exports.Server = function Server(client, details) { + base.Server.call(this, client, details); +}; + +util.inherits(Server, base.Server); + +Server.prototype._setProperties = function (details) { + + this.id = details.id; + this.name = details.name; + this.image = details.image; + this.imageId = details.image ? details.image.id : details.imageId; + if (details.datacenter) { + this.datacenter = details.datacenter; + } + + switch (details.status && details.status.state) { + case 'POWERED_ON': + this.status = 'RUNNING'; + break; + case 'POWERED_OFF': + this.status = this.STATUS.stopped; + break; + case 'NEW': + default: + this.status = 'PROVISIONING'; + } +}; + +Server.prototype.toJSON = function () { + return _.pick(this, ['id', 'name', 'image', 'datacenter']); +}; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/index.js b/lib/pkgcloud/oneandone/index.js new file mode 100644 index 000000000..e7d31a0e4 --- /dev/null +++ b/lib/pkgcloud/oneandone/index.js @@ -0,0 +1,7 @@ +/** + * + * (C) Created by Ali Bazlamit on 8/10/2017. + * + */ + +exports.compute = require('./compute'); \ No newline at end of file diff --git a/package.json b/package.json index 8b674cd54..c6b3a25b5 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "dependencies": { "async": "0.9.x", "aws-sdk": "^2.2.43", + "liboneandone": "1.0.0", "errs": "0.3.x", "eventemitter2": "0.4.x", "fast-json-patch": "0.5.x", diff --git a/test/common/base/client-test.js b/test/common/base/client-test.js index ff362f739..29971bf70 100644 --- a/test/common/base/client-test.js +++ b/test/common/base/client-test.js @@ -1,4 +1,4 @@ -/* + /* * client-test.js: Tests for pkgcloud base client * * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 85bb84d0c..ce4c11ab0 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -30,16 +30,16 @@ azureApi._updateMinimumPollInterval(mock ? 10 : azureApi.MINIMUM_POLL_INTERVAL); providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].compute; -}).forEach(function(provider) { +}).forEach(function (provider) { describe('pkgcloud/common/compute/base [' + provider + ']', function () { var client = helpers.createClient(provider, 'compute'), - context = {}, - authServer, server, - authHockInstance, - hockInstance; + context = {}, + authServer, server, + authHockInstance, + hockInstance; - before(function(done) { + before(function (done) { if (!mock) { return done(); @@ -55,7 +55,7 @@ providers.filter(function (provider) { authServer = http.createServer(authHockInstance.handler); async.parallel([ - function(next) { + function (next) { server.listen(12345, next); }, function (next) { @@ -91,7 +91,7 @@ providers.filter(function (provider) { } }); - it('the getFlavors() method should return a list of flavors', function(done) { + it('the getFlavors() method should return a list of flavors', function (done) { if (mock) { setupFlavorMock(client, provider, { authServer: authHockInstance, @@ -200,7 +200,7 @@ providers.filter(function (provider) { }); }); - after(function(done) { + after(function (done) { if (!mock) { return done(); } @@ -234,7 +234,7 @@ setupVersionMock = function (client, provider, servers) { .reply(200, helpers.getRackspaceAuthResponse()); servers.server - .get('/v2/', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/versions.json'); } else if (provider === 'openstack') { @@ -246,9 +246,9 @@ setupVersionMock = function (client, provider, servers) { password: 'MOCK-PASSWORD' } } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/openstack/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2.0/tenants', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') .post('/v2.0/tokens', { auth: { @@ -258,11 +258,11 @@ setupVersionMock = function (client, provider, servers) { }, tenantId: '72e90ecb69c44d0296072ea39e537041' } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(200, helpers.getOpenstackAuthResponse()); servers.server - .get('/v2/', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/versions.json'); } else if (provider === 'hp') { @@ -274,9 +274,9 @@ setupVersionMock = function (client, provider, servers) { secretKey: 'MOCK-API-KEY' } } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(200, helpers._getOpenstackStandardResponse('../fixtures/hp/initialToken.json')) - .get('/v2.0/tenants', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2.0/tenants', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/hp/tenantId.json') .post('/v2.0/tokens', { auth: { @@ -286,17 +286,17 @@ setupVersionMock = function (client, provider, servers) { }, tenantId: '5ACED3DC3AA740ABAA41711243CC6949' } - }, {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + }, { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(200, helpers.gethpAuthResponse()); servers.server - .get('/v2/', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/hp/versions.json'); } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/datacenters', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(200, '', { 'x-api-version': '6.5.0' }); } }; @@ -304,19 +304,19 @@ setupVersionMock = function (client, provider, servers) { setupFlavorMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server - .get('/v2/123456/flavors/detail', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/v2/123456/flavors/detail', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/flavors.json'); } else if (provider === 'openstack') { servers.server .get('/v2/72e90ecb69c44d0296072ea39e537041/flavors/detail', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/packages', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/joyent/flavors.json'); } else if (provider === 'digitalocean') { @@ -327,41 +327,46 @@ setupFlavorMock = function (client, provider, servers) { else if (provider === 'hp') { servers.server .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); } + else if (provider === 'oneandone') { + servers.server + .get('/servers/fixed_instance_sizes') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/listFlavors.json'); + } }; setupImagesMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .get('/v2/123456/images/detail', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/images.json'); } else if (provider === 'openstack') { servers.server .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); } else if (provider === 'joyent') { servers.server .get('/' + client.account + '/datasets', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/joyent/images.json'); } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) .post('/', { Action: 'DescribeImages', 'Owner.1': 'self' }, - {'User-Agent': client.userAgent }) + { 'User-Agent': client.userAgent }) .replyWithFile(200, __dirname + '/../../fixtures/amazon/images.xml'); } else if (provider === 'azure') { servers.server .get('/azure-account-subscription-id/services/images', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/images.xml'); } else if (provider === 'digitalocean') { @@ -372,9 +377,14 @@ setupImagesMock = function (client, provider, servers) { else if (provider === 'hp') { servers.server .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); } + else if (provider === 'oneandone') { + servers.server + .get('/server_appliances') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/listImages.json'); + } }; setupServerMock = function (client, provider, servers) { @@ -396,52 +406,53 @@ setupServerMock = function (client, provider, servers) { else if (provider === 'rackspace') { servers.server .post('/v2/123456/servers', { - server: { - name: 'create-test-setWait', - flavorRef: '2', - imageRef: '9922a7c7-5a42-4a56-bc6a-93f857ae2346' - } - }, - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + server: { + name: 'create-test-setWait', + flavorRef: '2', + imageRef: '9922a7c7-5a42-4a56-bc6a-93f857ae2346' + } + }, + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(202, __dirname + '/../../fixtures/rackspace/setWaitResp1.json') .get('/v2/123456/servers/a0a5f183-b94e-4a41-a854-64cff53375bf', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/rackspace/a0a5f183-b94e-4a41-a854-64cff53375bf.json'); } else if (provider === 'openstack') { servers.server .post('/v2/72e90ecb69c44d0296072ea39e537041/servers', { - server: { - name: 'create-test-setWait', - flavorRef: '1', - imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' - } - }, - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + server: { + name: 'create-test-setWait', + flavorRef: '1', + imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' + } + }, + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(202, __dirname + '/../../fixtures/openstack/creatingServer.json') .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated.json'); } else if (provider === 'joyent') { servers.server .post('/' + client.account + '/machines', - { name: 'create-test-setWait', - 'package': 'Small 1GB', - dataset: 'sdc:sdc:nodejitsu:1.0.0' - }, - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { + name: 'create-test-setWait', + 'package': 'Small 1GB', + dataset: 'sdc:sdc:nodejitsu:1.0.0' + }, + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/joyent/setWait.json') .get('/' + client.account + '/machines/534aa63a-104f-4d6d-a3b1-c0d341a20a53', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/joyent/setWaitResp1.json'); } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) .post('/', { - 'Action':'RunInstances', + 'Action': 'RunInstances', 'ImageId': 'ami-85db1cec', 'InstanceType': 'm1.small', 'MaxCount': '1', @@ -488,72 +499,84 @@ setupServerMock = function (client, provider, servers) { else if (provider === 'azure') { servers.server .get('/azure-account-subscription-id/services/hostedservices/create-test-setWait?embed-detail=true', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(404, __dirname + '/../../fixtures/azure/hosted-service-404.xml') - .post('/azure-account-subscription-id/services/hostedservices', helpers.loadFixture('azure/create-hosted-service.xml'), {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .post('/azure-account-subscription-id/services/hostedservices', helpers.loadFixture('azure/create-hosted-service.xml'), { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(201, '', { location: 'https://management.core.windows.net/subscriptions/azure-account-subscription-id/compute/create-test-setWait', - 'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5'}) + 'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5' + }) .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml') - .get('/azure-account-subscription-id/services/images/CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .get('/azure-account-subscription-id/services/images/CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/image-1.xml') - .post('/azure-account-subscription-id/services/hostedservices/create-test-setWait/deployments', helpers.loadFixture('azure/create-deployment.xml'), {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(202, '', {'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5'}) + .post('/azure-account-subscription-id/services/hostedservices/create-test-setWait/deployments', helpers.loadFixture('azure/create-deployment.xml'), { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) + .reply(202, '', { 'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5' }) .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-inprogress.xml') .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml') // TODO: have to do this twice as setWait() does not check server status before calling server.refresh()? .get('/azure-account-subscription-id/services/hostedservices/create-test-setWait?embed-detail=true', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/running-server.xml') .get('/azure-account-subscription-id/services/hostedservices/create-test-setWait?embed-detail=true', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/running-server.xml') .filteringRequestBodyRegEx(/.*/, '*') .post('/azure-account-subscription-id/services/hostedservices/create-test-setWait/certificates', '*', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) - .reply(202, '', {'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5'}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) + .reply(202, '', { 'x-ms-request-id': 'b67cc525ecc546618fd6fb3e57d724f5' }) .get('/azure-account-subscription-id/operations/b67cc525ecc546618fd6fb3e57d724f5', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/azure/operation-succeeded.xml'); } else if (provider === 'hp') { servers.server .post('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers', { - server: { - name: 'create-test-setWait', - flavorRef: '1', - imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' - } - }, - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + server: { + name: 'create-test-setWait', + flavorRef: '1', + imageRef: '506d077e-66bf-44ff-907a-588c5c79fa66' + } + }, + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(202, __dirname + '/../../fixtures/hp/creatingServer.json') .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/hp/serverCreated.json'); } + else if (provider === 'oneandone') { + servers.server + .post('/servers', { + name: 'create-test-setWait', + hardware: { fixed_instance_size_id: '8C626C1A7005D0D1F527143C413D461E' } + , appliance_id: 'A0FAA4587A7CB6BBAA1EA877C844977E' + }) + .replyWithFile(202, __dirname + '/../../fixtures/oneandone/getWaitServer.json') + .get('/servers/39AA65F5D5B02FA02D58173094EBAF95') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/getWaitServer.json'); + } }; setupDestroyMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server .delete('/v2/123456/servers/a0a5f183-b94e-4a41-a854-64cff53375bf', - {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(204); } else if (provider === 'openstack') { servers.server - .delete('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .delete('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(204); } else if (provider === 'hp') { servers.server - .delete('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', {'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version)}) + .delete('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .reply(204); } else if (provider === 'digitalocean') { @@ -561,4 +584,9 @@ setupDestroyMock = function (client, provider, servers) { .delete('/v2/droplets/3164494') .replyWithFile(204); } + else if (provider === 'oneandone') { + servers.server + .delete('/servers/39AA65F5D5B02FA02D58173094EBAF95?keep_ips=false') + .replyWithFile(202, __dirname + '/../../fixtures/oneandone/getWaitServer.json'); + } }; diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 970a613f5..bee5d174f 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -327,6 +327,11 @@ setupImagesMock = function (client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/images.json'); } + else if (provider === 'oneandone') { + servers.server + .get('/server_appliances') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/listImages.json'); + } }; setupFlavorMock = function (client, provider, servers) { @@ -355,6 +360,11 @@ setupFlavorMock = function (client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/flavors/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/flavors.json'); } + else if (provider === 'oneandone') { + servers.server + .get('/servers/fixed_instance_sizes') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/listFlavors.json'); + } }; setupServerMock = function (client, provider, servers) { @@ -471,6 +481,17 @@ setupServerMock = function (client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } + else if (provider === 'oneandone') { + servers.server + .post('/servers', { + name: 'create-test-ids2', + hardware: {fixed_instance_size_id: '8C626C1A7005D0D1F527143C413D461E'} + , appliance_id: 'A0FAA4587A7CB6BBAA1EA877C844977E' + }) + .replyWithFile(202, __dirname + '/../../fixtures/oneandone/getServer.json') + .get('/servers/39AA65F5D5B02FA02D58173094EBAF95') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/getServer.json'); + } }; setupGetServersMock = function (client, provider, servers) { @@ -518,6 +539,11 @@ setupGetServersMock = function (client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/detail') .replyWithFile(200, __dirname + '/../../fixtures/hp/serverList.json'); } + else if (provider === 'oneandone') { + servers.server + .get('/servers') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/listServers.json'); + } }; setupGetServerMock = function (client, provider, servers) { @@ -563,382 +589,30 @@ setupGetServerMock = function (client, provider, servers) { .get('/v2/5ACED3DC3AA740ABAA41711243CC6949/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } + else if (provider === 'oneandone') { + servers.server + .get('/servers/39AA65F5D5B02FA02D58173094EBAF95') + .replyWithFile(200, __dirname + '/../../fixtures/oneandone/getServer.json'); + } }; setupRebootMock = function() { // TODO }; -// -//function batchThree(providerClient, providerName) { -// var name = providerName || 'rackspace', -// client = providerClient || clients['rackspace'], -// test = {}; -// -// test["The pkgcloud " + name + " compute client"] = { -// "the getServers() method": { -// topic: function () { -// client.getServers(this.callback); -// }, -// "should return the list of servers": function (err, servers) { -// assert.isNull(err); -// testContext.servers = servers; -// servers.forEach(function (server) { -// assert.assertServer(server); -// }); -// } -// }, -// "the getServer() method": { -// topic: function () { -// client.getServer(testContext.servers[0], this.callback); -// }, -// "should return a valid server": function (err, server) { -// client.destroyServer(server); -// assert.isNull(err); -// assert.assertServerDetails(server); -// assert.ok(Array.isArray(server.addresses["public"])); -// assert.ok(Array.isArray(server.addresses["private"])); -// if (name === 'openstack') { -// assert.ok(typeof server.addresses["private"][0] === 'object'); -// assert.ok(typeof server.addresses["public"][0] === 'object'); -// } -// else { -// assert.ok(typeof server.addresses["private"][0] === 'string'); -// assert.ok(typeof server.addresses["public"][0] === 'string'); -// } -// } -// } -// }; -// -// return test; -//} -// -//function batchReboot(providerClient, providerName, nock) { -// var name = providerName || 'rackspace', -// client = providerClient || clients['rackspace'], -// timeout = process.env.MOCK ? 1 : 10000, -// test = {}; -// -// test["The pkgcloud " + name + " compute client"] = { -// "the rebootServer() method": { -// topic: function () { -// var self = this; -// client.createServer(_.extend({ -// name : "test-reboot", -// image : testContext.images[0].id, -// flavor: testContext.flavors[0].id -// }, name === 'azure' ? azureOptions : {}), -// function (err, server, response) { -// if (err) { return self.callback(err); } -// -// function waitForReboot(server) { -// // should have used setWait -// // dont do this in your code -// return setTimeout(function () { -// server.refresh(function (err, srv) { -// if (err) { return self.callback(err); } -// if (srv.status === "RUNNING") { -// return self.callback(null, srv); -// } -// waitForReboot(srv); -// }); -// }, timeout); -// } -// -// function keepTrying() { -// // should have used setWait -// // dont do this in your code -// return setTimeout(function () { -// if (server.status==='RUNNING') { -// server.reboot(function (err, ok) { -// if (err) { return self.callback(err); } -// waitForReboot(server); -// }); -// } else { -// server.refresh(function (err, srv) { -// if (err) { return self.callback(err); } -// server = srv; -// keepTrying(); -// }); -// } -// }, timeout); -// } -// keepTrying(); -// }); -// }, -// "should return a server after reboot": function (err, server) { -// assert.isNull(err); -// assert.assertServer(server); -// } -// } -// }; -// -// return test; -//} -// -//function batchDestroy(providerClient, providerName) { -// var name = providerName || 'rackspace', -// client = providerClient || clients['rackspace'], -// test = {}; -// -// test["The pkgcloud " + name + " compute client"] = { -// "the destroyServer() method": { -// topic: function () { -// client.destroyServer(testContext.servers[0].id, this.callback); -// }, -// "should respond correctly": function (err, response) { -// assert.isNull(err); -// assert.ok(response.ok); -// assert.equal(response.ok, testContext.servers[0].id); -// } -// } -// }; -// -// return test; -//} -// -//JSON.parse(fs.readFileSync(__dirname + '/../../configs/providers.json')) -// .forEach(function (provider) { -// clients[provider] = helpers.createClient(provider, 'compute'); -// -// var client = clients[provider], -// nock = require('nock'); -// -// testData = {}; -// testContext = {}; -// -// if (process.env.MOCK) { -// if (provider === 'joyent') { -// nock('https://' + client.serversUrl) -// .get('/' + client.account + '/machines') -// .reply(200, "[]", {}) -// .get('/' + client.account + '/datasets') -// .reply(200, __dirname + '/../../fixturejoyent/images.json'), {}) -// .get('/' + client.account + '/packages') -// .reply(200, __dirname + '/../../fixturejoyent/flavors.json'), {}) -// -// -// ["delete"]('/' + client.account + -// '/machines/14186c17-0fcd-4bb5-ab42-51b848bda7e9') -// .reply(204, "", {}) -// .get('/' + client.account + '/machines') -// .reply(200, __dirname + '/../../fixturejoyent/servers.json'), {}) -// .post('/' + client.account + '/machines', -// __dirname + '/../../fixturejoyent/rebootServerRequest1.json')) -// .reply(201, -// __dirname + '/../../fixturejoyent/rebootServerResponse1.json'), {}) -// .get('/' + client.account + -// '/machines/fe4d8e28-6154-4281-8f0e-dead21585ed5') -// .reply(200, -// __dirname + '/../../fixturejoyent/fe4d8e28.json'), {}) -// .post('/' + client.account + -// '/machines/fe4d8e28-6154-4281-8f0e-dead21585ed5?action=reboot') -// .reply(202, "", {}) -// .get('/' + client.account + -// '/machines/fe4d8e28-6154-4281-8f0e-dead21585ed5') -// .reply(200, -// __dirname + '/../../fixturejoyent/fe4d8e28.json'), {}) -// -// .get('/' + client.account + -// '/machines/14186c17-0fcd-4bb5-ab42-51b848bda7e9') -// .reply(200, -// __dirname + '/../../fixturejoyent/14186c17.json'), {}) -// .get('/' + client.account + -// '/machines/14186c17-0fcd-4bb5-ab42-51b848bda7e9') -// .reply(200, -// __dirname + '/../../fixturejoyent/14186c17.json'), {}) -// ["delete"]('/' + client.account + -// '/machines/fe4d8e28-6154-4281-8f0e-dead21585ed5') -// .reply(204, "", {}) -// .post('/' + client.account + -// '/machines/14186c17-0fcd-4bb5-ab42-51b848bda7e9', { action: 'stop' }) -// .reply(202, "", {}) -// .get('/' + client.account + -// '/machines/14186c17-0fcd-4bb5-ab42-51b848bda7e9') -// .reply(200, -// __dirname + '/../../fixturejoyent/14186c17.json'), {}) -// ; -// } -// else if (provider === 'rackspace') { -// nock('https://' + client.authUrl) -// .get('/v1.0') -// .reply(204, "", -// JSON.parse(__dirname + '/../../fixturerackspace/auth.json'))); -// nock('https://' + client.serversUrl) -// .get('/v1.0/537645/flavors/detail.json') -// .reply(200, __dirname + '/../../fixturerackspace/serverFlavors.json'), {}) -// .get('/v1.0/537645/images/detail.json') -// .reply(200, __dirname + '/../../fixturerackspace/images.json'), {}) -// .get('/v1.0/537645/images/detail.json') -// .reply(200, __dirname + '/../../fixturerackspace/images.json'), {}) -// -// -// .post('/v1.0/537645/servers', -// __dirname + '/../../fixturerackspace/createServer.json')) -// .reply(202, __dirname + '/../../fixturerackspace/createdServer.json'), -// {}) -// .get('/v1.0/537645/servers/detail.json') -// .reply(204, __dirname + '/../../fixturerackspace/servers.json'), {}) -// ["delete"]('/v1.0/537645/servers/20592449') -// .reply(200, '{"ok": 20592449}', {}) -// .get('/v1.0/537645/servers/20592449') -// .reply(200, __dirname + '/../../fixturerackspace/20592449.json'), {}) -// .post('/v1.0/537645/servers', -// __dirname + '/../../fixturerackspace/createReboot.json')) -// .reply(202, -// __dirname + '/../../fixturerackspace/buildingReboot.json'), {}) -// .get('/v1.0/537645/servers/20596929') -// .reply(200, -// __dirname + '/../../fixturerackspace/activeReboot.json'), {}) -// .post('/v1.0/537645/servers/20596929/action', -// '{"reboot":{"type":"SOFT"}}') -// .reply(202, "", {}) -// .get('/v1.0/537645/servers/20596929') -// .reply(200, -// __dirname + '/../../fixturerackspace/activeReboot.json'), {}) -// ; -// } else if (provider === 'amazon') { -// nock('https://' + client.serversUrl) -// .filteringRequestBody(helpers.authFilter) -// -// -// .post('/?Action=TerminateInstances', { -// 'InstanceId': 'i-1d48637b' -// }) -// .reply(200, 'doesn\'t matter', {}) -// .post('/?Action=RunInstances', { -// 'ImageId': 'ami-85db1cec', -// 'InstanceType': 'm1.small', -// 'MaxCount': '1', -// 'MinCount': '1', -// 'UserData': 'eyJuYW1lIjoidGVzdC1yZWJvb3QifQ==' -// }) -// .reply(200, __dirname + '/../../fixtureamazon/run-instances.xml'), {}) -// .post('/?Action=DescribeInstances', { -// 'Filter.1.Name': 'instance-state-code', -// 'Filter.1.Value.1': '0', -// 'Filter.1.Value.2': '16', -// 'Filter.1.Value.3': '32', -// 'Filter.1.Value.4': '64', -// 'Filter.1.Value.5': '80', -// 'InstanceId.1': 'i-1d48637b' -// }) -// .reply(200, __dirname + '/../../fixtureamazon/pending-server.xml'), {}) -// .post('/?Action=DescribeInstanceAttribute', { -// 'Attribute': 'userData', -// 'InstanceId': 'i-1d48637b' -// }) -// .reply(200, -// __dirname + '/../../fixtureamazon/running-server-attr.xml', {})) -// .post('/?Action=DescribeInstances', { -// 'Filter.1.Name': 'instance-state-code', -// 'Filter.1.Value.1': '0', -// 'Filter.1.Value.2': '16', -// 'Filter.1.Value.3': '32', -// 'Filter.1.Value.4': '64', -// 'Filter.1.Value.5': '80', -// 'InstanceId.1': 'i-1d48637b' -// }) -// .reply(200, __dirname + '/../../fixtureamazon/running-server.xml'), {}) -// .post('/?Action=DescribeInstanceAttribute', { -// 'Attribute': 'userData', -// 'InstanceId': 'i-1d48637b' -// }) -// .reply(200, -// __dirname + '/../../fixtureamazon/running-server-attr.xml', {})) -// .post('/?Action=RebootInstances', { -// 'InstanceId': 'i-1d48637b' -// }) -// .reply(200, __dirname + '/../../fixtureamazon/reboot-server.xml', {})) -// .post('/?Action=DescribeInstances', { -// 'Filter.1.Name': 'instance-state-code', -// 'Filter.1.Value.1': '0', -// 'Filter.1.Value.2': '16', -// 'Filter.1.Value.3': '32', -// 'Filter.1.Value.4': '64', -// 'Filter.1.Value.5': '80', -// 'InstanceId.1': 'i-1d48637b' -// }) -// .reply(200, __dirname + '/../../fixtureamazon/pending-server.xml'), {}) -// .post('/?Action=DescribeInstanceAttribute', { -// 'Attribute': 'userData', -// 'InstanceId': 'i-1d48637b' -// }) -// .reply(200, -// __dirname + '/../../fixtureamazon/running-server-attr.xml', {})) -// .post('/?Action=DescribeInstances', { -// 'Filter.1.Name': 'instance-state-code', -// 'Filter.1.Value.1': '0', -// 'Filter.1.Value.2': '16', -// 'Filter.1.Value.3': '32', -// 'Filter.1.Value.4': '64', -// 'Filter.1.Value.5': '80', -// 'InstanceId.1': 'i-1d48637b' -// }) -// .reply(200, __dirname + '/../../fixtureamazon/running-server.xml'), {}) -// .post('/?Action=DescribeInstanceAttribute', { -// 'Attribute': 'userData', -// 'InstanceId': 'i-1d48637b' -// }) -// .reply(200, __dirname + '/../../fixtureamazon/running-server-attr.xml'), {}) -// } else if (provider === 'azure') { -// azureNock.serverTest(nock, helpers); -// } else if (provider === 'openstack') { -// nock(client.authUrl) -// -// -// nock('http://compute.myownendpoint.org:8774') -// -// -// .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/detail') -// .reply(200, __dirname + '/../../fixtureopenstack/serverList.json')) -// .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') -// .reply(200, __dirname + '/../../fixtureopenstack/serverCreated2.json')) -// ["delete"]('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') -// .reply(204, ""); -// } -// } -// -// var suite = vows.describe('pkgcloud/common/compute/server [' + provider + ']') -// .addBatch(batchOne(client, provider)) -// .addBatch(batchTwo(client, provider)) -// ; -// -// // Delete the server created on step two -// if (provider === 'openstack') { -// suite -// .addBatch(batchDestroy(client, provider)) -// ; -// } -// -// suite -// .addBatch(batchThree(client, provider)) -// ; -// -// // Disable reboot test for openstack :( -// if (provider !== 'openstack') { -// suite -// .addBatch(batchReboot(client, provider, nock)) -// ; -// } -// -// suite -// .export(module) -// ; -// });z /** - * serverStatusReply() - * fills in the nock xml reply from the server with server name and status - * @param name - name of the server - * @param status - status to be returned in reply - * status should be: - * ReadyRole - server is RUNNING - * VMStopped - server is still PROVISIONING - * Provisioning - server is still PROVISIONING - * see lib/pkgcloud/azure/compute/server.js for more status values - * - * @return {String} - the xml reply containing the server name and status - */ + - * serverStatusReply() + - * fills in the nock xml reply from the server with server name and status + - * @param name - name of the server + - * @param status - status to be returned in reply + - * status should be: + - * ReadyRole - server is RUNNING + - * VMStopped - server is still PROVISIONING + - * Provisioning - server is still PROVISIONING + - * see lib/pkgcloud/azure/compute/server.js for more status values + - * + - * @return {String} - the xml reply containing the server name and status + - */ serverStatusReply = function (name, status) { var template = helpers.loadFixture('azure/server-status-template.xml'), diff --git a/test/configs/mock/oneandone.json b/test/configs/mock/oneandone.json new file mode 100644 index 000000000..567061458 --- /dev/null +++ b/test/configs/mock/oneandone.json @@ -0,0 +1,7 @@ +{ + "token": "MOCK", + "serversUrl": "localhost:12345", + "authUrl": "http://localhost:12346", + "databaseUrl": "localhost:12345", + "protocol": "http://" +} \ No newline at end of file diff --git a/test/configs/providers.json b/test/configs/providers.json index 91d2d3bb7..fd63df7b1 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1 +1,2 @@ -["rackspace", "openstack", "joyent", "azure", "digitalocean", "hp", "google"] \ No newline at end of file +["rackspace", "openstack", "joyent", "azure", "digitalocean", "hp", "google", "oneandone"] + diff --git a/test/fixtures/oneandone/getFlavor.json b/test/fixtures/oneandone/getFlavor.json new file mode 100644 index 000000000..57efad307 --- /dev/null +++ b/test/fixtures/oneandone/getFlavor.json @@ -0,0 +1,17 @@ +{ + "name": "M", + "id": "8C626C1A7005D0D1F527143C413D461E", + "hardware": { + "vcore": 1, + "cores_per_processor": 1, + "ram": 1, + "unit": "GB", + "hdds": [ + { + "size": 40, + "unit": "GB", + "is_main": true + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/oneandone/getImage.json b/test/fixtures/oneandone/getImage.json new file mode 100644 index 000000000..db5220a9e --- /dev/null +++ b/test/fixtures/oneandone/getImage.json @@ -0,0 +1,31 @@ +{ + "id": "842F09CAF954298C6A4BCD25E1CA3689", + "name": "My Image 2", + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "os_family": "Linux", + "os": "Centos", + "os_version": "Centos6", + "architecture": 64, + "os_image_type": "Personal", + "type": "MY_IMAGE", + "min_hdd_size": 40, + "licenses": [], + "cloudpanel_id": "ap8962D_248", + "state": "ACTIVE", + "description": null, + "hdds": [ + { + "id": "35AAD7EB668D7ECF58AF9413DB127BD3", + "size": 40, + "is_main": true + } + ], + "server_id": "CB8A023E99CE2026981A110018A00764", + "frequency": "ONCE", + "num_images": 1, + "creation_date": "2015-04-14T07:18:20+00:00" +} \ No newline at end of file diff --git a/test/fixtures/oneandone/getServer.json b/test/fixtures/oneandone/getServer.json new file mode 100644 index 000000000..e3262c2d9 --- /dev/null +++ b/test/fixtures/oneandone/getServer.json @@ -0,0 +1,49 @@ +{ + "id": "39AA65F5D5B02FA02D58173094EBAF95", + "cloudpanel_id": "958FA92", + "name": "create-test-ids2", + "description": "", + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "creation_date": "2015-05-04T06:32:15+00:00", + "first_password": "Fg52K21nz8", + "status": { + "state": "POWERED_ON", + "percent": null + }, + "hardware": { + "fixed_instance_size_id": 0, + "vcore": 1, + "cores_per_processor": 1, + "ram": 2, + "hdds": [ + { + "id": "8C626C1A7005D0D1F527143C413D461E", + "size": 40, + "is_main": true + } + ] + }, + "image": { + "id": "A0FAA4587A7CB6BBAA1EA877C844977E", + "name": "New image name" + }, + "dvd": null, + "snapshot": null, + "ips": [ + { + "id": "8D135204687B9CF9E79E7A93C096E336", + "ip": "10.4.140.213", + "type": "IPV4", + "reverse_dns": null, + "firewall_policy": null, + "load_balancers": [] + } + ], + "alerts": [], + "monitoring_policy": null, + "private_networks": null +} \ No newline at end of file diff --git a/test/fixtures/oneandone/getWaitServer.json b/test/fixtures/oneandone/getWaitServer.json new file mode 100644 index 000000000..7cc27b753 --- /dev/null +++ b/test/fixtures/oneandone/getWaitServer.json @@ -0,0 +1,49 @@ +{ + "id": "39AA65F5D5B02FA02D58173094EBAF95", + "cloudpanel_id": "958FA92", + "name": "create-test-setWait", + "description": "", + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "creation_date": "2015-05-04T06:32:15+00:00", + "first_password": "Fg52K21nz8", + "status": { + "state": "POWERED_ON", + "percent": null + }, + "hardware": { + "fixed_instance_size_id": 0, + "vcore": 1, + "cores_per_processor": 1, + "ram": 2, + "hdds": [ + { + "id": "8C626C1A7005D0D1F527143C413D461E", + "size": 40, + "is_main": true + } + ] + }, + "image": { + "id": "A0FAA4587A7CB6BBAA1EA877C844977E", + "name": "New image name" + }, + "dvd": null, + "snapshot": null, + "ips": [ + { + "id": "8D135204687B9CF9E79E7A93C096E336", + "ip": "10.4.140.213", + "type": "IPV4", + "reverse_dns": null, + "firewall_policy": null, + "load_balancers": [] + } + ], + "alerts": [], + "monitoring_policy": null, + "private_networks": null +} \ No newline at end of file diff --git a/test/fixtures/oneandone/listFlavors.json b/test/fixtures/oneandone/listFlavors.json new file mode 100644 index 000000000..07103de64 --- /dev/null +++ b/test/fixtures/oneandone/listFlavors.json @@ -0,0 +1,70 @@ +[ + { + "name": "M", + "id": "8C626C1A7005D0D1F527143C413D461E", + "hardware": { + "vcore": 1, + "cores_per_processor": 1, + "ram": 1, + "unit": "GB", + "hdds": [ + { + "size": 40, + "unit": "GB", + "is_main": true + } + ] + } + }, + { + "name": "L", + "id": "8C626C1A7005D0D1F527143C413D461F", + "hardware": { + "vcore": 2, + "cores_per_processor": 1, + "ram": 2, + "unit": "GB", + "hdds": [ + { + "size": 80, + "unit": "GiB", + "is_main": true + } + ] + } + }, + { + "name": "XL", + "id": "8C626C1A7005D0D1F527143C413D4620", + "hardware": { + "vcore": 2, + "cores_per_processor": 1, + "ram": 4, + "unit": "GB", + "hdds": [ + { + "size": 120, + "unit": "GB", + "is_main": true + } + ] + } + }, + { + "name": "XXL", + "id": "8C626C1A7005D0D1F527143C413D4621", + "hardware": { + "vcore": 4, + "cores_per_processor": 1, + "ram": 8, + "unit": "GB", + "hdds": [ + { + "size": 160, + "unit": "GiB", + "is_main": true + } + ] + } + } +] \ No newline at end of file diff --git a/test/fixtures/oneandone/listImages.json b/test/fixtures/oneandone/listImages.json new file mode 100644 index 000000000..22414295a --- /dev/null +++ b/test/fixtures/oneandone/listImages.json @@ -0,0 +1,63 @@ +[ + { + "id": "A0FAA4587A7CB6BBAA1EA877C844977E", + "name": "New image name", + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "os_family": "Linux", + "os": "Centos", + "os_version": "Centos7", + "architecture": 64, + "os_image_type": "Personal", + "type": "MY_IMAGE", + "min_hdd_size": 40, + "licenses": [], + "cloudpanel_id": "ap99AA4_1", + "state": "DEPLOYING", + "description": "New image description", + "hdds": [ + { + "id": "200FC47388A30470A376913E73B9C32C", + "size": 40, + "is_main": true + } + ], + "server_id": "E83777750130E1111AA89623B9557CAF", + "frequency": "DAILY", + "num_images": 5, + "creation_date": "2015-04-29T07:46:40+00:00" + }, + { + "id": "A0FAA4587A7CB6BBAA1EA877C844977F", + "name": "New image name 2", + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "name": "United States" + }, + "os_family": "Linux", + "os": "Centos", + "os_version": "Centos7", + "architecture": 64, + "os_image_type": "Personal", + "type": "MY_IMAGE", + "min_hdd_size": 40, + "licenses": [], + "cloudpanel_id": "ap99AA4_1", + "state": "DEPLOYING", + "description": "New image description", + "hdds": [ + { + "id": "200FC47388A30470A376913E73B9C32D", + "size": 40, + "is_main": true + } + ], + "server_id": "E83777750130E1111AA89623B9557CAF", + "frequency": "DAILY", + "num_images": 5, + "creation_date": "2015-04-29T07:46:40+00:00" + } +] \ No newline at end of file diff --git a/test/fixtures/oneandone/listServers.json b/test/fixtures/oneandone/listServers.json new file mode 100644 index 000000000..18d7f88ea --- /dev/null +++ b/test/fixtures/oneandone/listServers.json @@ -0,0 +1,88 @@ +[ + { + "id": "39AA65F5D5B02FA02D58173094EBAF95", + "cloudpanel_id": "958FA92", + "name": "create-test-ids2", + "description": "", + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "creation_date": "2015-05-04T06:32:15+00:00", + "first_password": "Fg52K21nz8", + "status": { + "state": "POWERED_ON", + "percent": null + }, + "hardware": { + "fixed_instance_size_id": 0, + "vcore": 1, + "cores_per_processor": 1, + "ram": 2, + "hdds": [ + { + "id": "8C626C1A7005D0D1F527143C413D461E", + "size": 40, + "is_main": true + } + ] + }, + "image": { + "id": "3C3B80327CBBD7F0023F793F666C24D0", + "name": "w2008r2datacenter64std" + }, + "dvd": null, + "snapshot": null, + "ips": [ + { + "id": "8D135204687B9CF9E79E7A93C096E336", + "ip": "10.4.140.213", + "type": "IPV4", + "reverse_dns": null, + "firewall_policy": null, + "load_balancers": [] + } + ], + "alerts": [], + "monitoring_policy": null, + "private_networks": null + }, + { + "id": "D6F1239315503A1C44607BB04B3BD9C9", + "name": "My Server 2", + "status": { + "state": "POWERED_ON", + "percent": null + }, + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "image": { + "id": "3C3F2FA3DB91318E8DCCB9F405339F76", + "name": "centos7-64std" + }, + "hardware": { + "fixed_instance_size_id": 0, + "vcore": 1, + "cores_per_processor": 1, + "ram": 2, + "hdds": [ + { + "id": "14B3CD8FE65C69F0AF28BE42431182E1", + "size": 40, + "is_main": true + } + ] + }, + "ips": [ + { + "id": "F116AFAAF937A5661601D31463B3A776", + "ip": "10.4.141.154" + } + ], + "alerts": null + } +] \ No newline at end of file diff --git a/test/fixtures/versions.json b/test/fixtures/versions.json index 639772075..de40d4742 100644 --- a/test/fixtures/versions.json +++ b/test/fixtures/versions.json @@ -1 +1 @@ -{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2014-06-15", "azure": "2012-03-01", "openstack": "v2", "hp": "v1"} \ No newline at end of file +{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2014-06-15", "azure": "2012-03-01", "openstack": "v2", "hp": "v1","oneandone":"1.7"} \ No newline at end of file diff --git a/test/oneandone/compute/test-flavor.js b/test/oneandone/compute/test-flavor.js new file mode 100644 index 000000000..c077b3927 --- /dev/null +++ b/test/oneandone/compute/test-flavor.js @@ -0,0 +1,91 @@ +/** + * Created by Ali Bazlamit on 8/21/2017. + */ +var should = require('should'), + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + http = require('http'), + mock = true, + Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor; + +var flavors = [], + client; +var options = { + token: process.env.OAO_TOKEN +}; +describe('Flavor tests', function () { + this.timeout(18000000); + var authHockInstance, hockInstance, authServer, mockServer; + + before(function (done) { + client = helpers.createClient('oneandone', 'compute', options); + if (!mock) { + return done(); + } + hockInstance = hock.createHock({throwOnUnmatched: false}); + authHockInstance = hock.createHock(); + mockServer = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ + function (next) { + mockServer.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); + + after(function (done) { + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + mockServer.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); + + + it('the getFlavors() method should return the list of flavors', function (done) { + if (mock) { + hockInstance + .get('/servers/fixed_instance_sizes') + .reply(200, helpers.loadFixture('oneandone/listFlavors.json')); + } + client.getFlavors(function (err, _flavors) { + should.exist(_flavors); + _flavors.should.be.an.Array; + _flavors.forEach(function (flavor) { + flavor.should.be.instanceOf(Flavor); + }); + flavors = _flavors; + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the getFlavor() method should return a valid flavor', function (done) { + if (mock) { + hockInstance + .get('/servers/fixed_instance_sizes/8C626C1A7005D0D1F527143C413D461E') + .reply(200, helpers.loadFixture('oneandone/getFlavor.json')); + } + client.getFlavor(flavors[0], function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.instanceOf(Flavor); + flavor.id.should.equal(flavors[0].id); + hockInstance && hockInstance.done(); + done(); + }); + }); +}); + + diff --git a/test/oneandone/compute/test-images.js b/test/oneandone/compute/test-images.js new file mode 100644 index 000000000..c35ebb8d5 --- /dev/null +++ b/test/oneandone/compute/test-images.js @@ -0,0 +1,107 @@ +/** + * Created by Ali Bazlamit on 8/19/2017. + */ + + +var image, + server, + client; +var should = require('should'), + helpers = require('../../helpers'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK, + Image = require('../../../lib/pkgcloud/core/compute/image').Image; + +var srvr_options = { + name: 'create-test-oao2', + flavor: 'S', + image: '6631A1589A2CC87FEA9B99AB07399281', + location: 'Germany', +}; +var image_options = { + name: 'pkgcloud image2', + server: '', + token: process.env.OAO_TOKEN +}; + +describe('Images tests', function () { + this.timeout(18000000); + var hockInstance, mockServer; + before(function (done) { + client = helpers.createClient('oneandone', 'compute'); + if (!mock) { + client.createServer(srvr_options, function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + server = srv1; + image_options.server = server; + client.createImage(image_options, function (err, img1) { + should.not.exist(err); + should.exist(img1); + image = img1; + done(); + }); + }); + } + hockInstance = hock.createHock({throwOnUnmatched: false}); + hockInstance.filteringRequestBody(helpers.authFilter); + mockServer = http.createServer(hockInstance.handler); + mockServer.listen(12345, done); + }); + + after(function (done) { + if (hockInstance) { + mockServer.close(function () { + done(); + }); + } + else { + client.destroyServer(server, function (err, response) { + should.not.exist(err); + should.exist(response); + client.destroyImage(image, function (err, deleteResponse) { + should.not.exist(err); + should.exist(deleteResponse); + done(); + }); + }); + done(); + } + }); + + it('the getImages() method should return a list of images', function (done) { + if (mock) { + hockInstance + .get('images/') + .reply(200, helpers.loadFixture('oneandone/listImages.json')); + } + client.getImages(function (err, images) { + should.not.exist(err); + should.exist(images); + + images.should.be.an.Array; + + images.forEach(function (img) { + img.should.be.instanceOf(Image); + }); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the getImage() method should return an image information', function (done) { + if (mock) { + hockInstance + .get('images/842F09CAF954298C6A4BCD25E1CA3689') + .reply(200, helpers.loadFixture('oneandone/getImage.json')); + } + client.getImage(image, function (err, response) { + should.not.exist(err); + should.exist(response); + response.should.be.instanceOf(Image); + hockInstance && hockInstance.done(); + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/oneandone/compute/test-servers.js b/test/oneandone/compute/test-servers.js new file mode 100644 index 000000000..77a55c34e --- /dev/null +++ b/test/oneandone/compute/test-servers.js @@ -0,0 +1,100 @@ +var server; +var should = require('should'), + helpers = require('../../helpers'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK, + Server = require('../../../lib/pkgcloud/core/compute/server').Server; + +var client; +var options = { + name: 'create-test-oao2', + flavor: 'S', + image: '6631A1589A2CC87FEA9B99AB07399281', + location: 'Germany', + token: process.env.OAO_TOKEN +}; + +describe('Server tests', function () { + this.timeout(18000000); + var hockInstance, mockServer; + before(function (done) { + client = helpers.createClient('oneandone', 'compute'); + if (!mock) { + client.createServer(options, function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + server = srv1; + srv1.should.be.instanceOf(Server); + srv1.name.should.equal('create-test-oao2'); + srv1.image.id.should.equal(options.image); + done(); + }); + } + hockInstance = hock.createHock({throwOnUnmatched: false}); + hockInstance.filteringRequestBody(helpers.authFilter); + mockServer = http.createServer(hockInstance.handler); + mockServer.listen(12345, done); + }); + + after(function (done) { + if (hockInstance) { + mockServer.close(function () { + done(); + }); + } else { + client.destroyServer(server, function (err, response) { + should.not.exist(err); + should.exist(response); + done(); + }); + } + }); + + it('the getServers() method should return a list of servers', function (done) { + if (mock) { + hockInstance + .get('/servers') + .reply(200, helpers.loadFixture('oneandone/listServers.json')); + } + client.getServers(function (err, servers) { + should.not.exist(err); + should.exist(servers); + servers.should.be.an.Array; + servers.forEach(function (srv) { + srv.should.be.instanceOf(Server); + }); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the getServer() method should return a server information', function (done) { + if (mock) { + hockInstance + .get('/servers/39AA65F5D5B02FA02D58173094EBAF95') + .reply(200, helpers.loadFixture('oneandone/getServer.json')); + } + client.getServer(server, function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + srv1.should.be.instanceOf(Server); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the rebootServer() method should restart the server', function (done) { + if (mock) { + hockInstance + .get('/servers/39AA65F5D5B02FA02D58173094EBAF95/status/action') + .reply(200, helpers.loadFixture('oneandone/getServer.json')); + } + client.rebootServer(server, function (err, srv1) { + should.not.exist(err); + srv1.should.be.instanceOf(Server); + hockInstance && hockInstance.done(); + done(); + }); + }); +}); \ No newline at end of file From 9b70db74ed1f93ce6ae9f42427e2b50cafa8e724 Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Mon, 28 Aug 2017 18:31:50 +0300 Subject: [PATCH 431/460] 1&1 blockstorage init --- .../oneandone/blockstorage/client/index.js | 15 +++ .../blockstorage/client/snapshots.js | 114 ++++++++++++++++++ lib/pkgcloud/oneandone/blockstorage/index.js | 12 ++ .../oneandone/blockstorage/snapshot.js | 27 +++++ lib/pkgcloud/oneandone/index.js | 3 +- 5 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 lib/pkgcloud/oneandone/blockstorage/client/index.js create mode 100644 lib/pkgcloud/oneandone/blockstorage/client/snapshots.js create mode 100644 lib/pkgcloud/oneandone/blockstorage/index.js create mode 100644 lib/pkgcloud/oneandone/blockstorage/snapshot.js diff --git a/lib/pkgcloud/oneandone/blockstorage/client/index.js b/lib/pkgcloud/oneandone/blockstorage/client/index.js new file mode 100644 index 000000000..be47a99f0 --- /dev/null +++ b/lib/pkgcloud/oneandone/blockstorage/client/index.js @@ -0,0 +1,15 @@ +/** + * Created by Ali Bazlamit on 8/28/2017. + */ + +var util = require('util'), + oneandone = require('../../client'), + _ = require('lodash'); + +var Client = exports.Client = function (options) { + oneandone.Client.call(this, options); + + _.extend(this, require('./snapshots')); +}; + +util.inherits(Client, oneandone.Client); diff --git a/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js b/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js new file mode 100644 index 000000000..b6ed1879b --- /dev/null +++ b/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js @@ -0,0 +1,114 @@ +/** + * Created by Ali Bazlamit on 8/28/2017. + */ + +var Snapshot = require('../snapshot').Snapshot, + Server = require('../../compute/server').Server; +/** + * client.getSnapshots + * + * @description Returns a list of the server's snapshots. + * + * @param {function} callback + * @returns {*} + */ +exports.getSnapshots = function (options, callback) { + var self = this, + serverId = server instanceof Server ? server.id : server; + oneandone.listSnapshots(serverId, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 200) { + callback(JSON.parse(body)); + return; + } + var object = JSON.parse(body); + callback(null, object.volumes.map(function (data) { + return new Volume(self, data); + }), res); + }); +}; + +/** + * client.createSnapshot + * + * @description Creates a new snapshot of the server. + * + * @param {object} options options for the provided create call + * @param {string} options.server Server or Server id to create the snapshot from + * @param {function} callback + * @returns {*} + */ +exports.createSnapshot = function (options, callback) { + var serverId = options.server instanceof Server ? options.server.id : options.server; + + oneandone.createSnapshot(serverId, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var snapshot = JSON.parse(body); + callback(null, snapshot); + }); +}; + +/** + * client.updateSnapshot + * + * @description Restores a snapshot into the server. + * + * @param {string} options.server Server or Server id to restore the snapshot into + * @param {string} options.snapshot snapshot or snapshot id to restore into the server provided + * @param {function} callback + * @returns {*} + */ +exports.updateSnapshot = function (options, callback) { + var serverId = options.server instanceof Server ? options.server.id : options.server, + snapshotId = options.snapshot instanceof Snapshot ? options.snapshot.id : options.snapshot; + + oneandone.restoreSnapshot(serverId, snapshotId, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var snp = JSON.parse(body); + callback(null, new compute.Snapshot(self, snp)); + }); +}; + +/** + * client.deleteSnapshot + * + * @description Removes a snapshot + * @param {string} options.server Server or Server id to restore the snapshot into + * @param {string} options.snapshot snapshot or snapshot id to restore into the server provided + * @param {function} callback + * @returns {*} + */ +exports.deleteSnapshot = function (options, callback) { + var serverId = options.server instanceof Server ? options.server.id : options.server, + snapshotId = options.snapshot instanceof Snapshot ? options.snapshot.id : options.snapshot; + + oneandone.deleteSnapshot(serverId, snapshotId, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var snp = JSON.parse(body); + callback(null, new compute.Snapshot(self, snp)); + }); +}; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/blockstorage/index.js b/lib/pkgcloud/oneandone/blockstorage/index.js new file mode 100644 index 000000000..5758de503 --- /dev/null +++ b/lib/pkgcloud/oneandone/blockstorage/index.js @@ -0,0 +1,12 @@ +/** + * Created by Ali Bazlamit on 8/28/2017. + */ +/** + * Created by Ali Bazlamit on 8/14/2017. + */ +exports.Client = require('./client').Client; +exports.Snapshot = require('./snapshot').Snapshot; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/oneandone/blockstorage/snapshot.js b/lib/pkgcloud/oneandone/blockstorage/snapshot.js new file mode 100644 index 000000000..a6951ab71 --- /dev/null +++ b/lib/pkgcloud/oneandone/blockstorage/snapshot.js @@ -0,0 +1,27 @@ +/** + * Created by Ali Bazlamit on 8/28/2017. + */ + +var util = require('util'), + base = require('../../core/base'), + _ = require('lodash'); + +var Snapshot = exports.Snapshot = function Snapshot(client, details) { + base.Model.call(this, client, details); +}; + +util.inherits(Snapshot, base.Model); + +Snapshot.prototype._setProperties = function (details) { + this.id = details.id; + this.name = details.name; +}; + +Snapshot.prototype.toJSON = function () { + return _.pick(this, ['id', 'name']); +}; + + + + + diff --git a/lib/pkgcloud/oneandone/index.js b/lib/pkgcloud/oneandone/index.js index e7d31a0e4..251aa23be 100644 --- a/lib/pkgcloud/oneandone/index.js +++ b/lib/pkgcloud/oneandone/index.js @@ -4,4 +4,5 @@ * */ -exports.compute = require('./compute'); \ No newline at end of file +exports.compute = require('./compute'); +exports.blockstorage = require('./blockstorage'); \ No newline at end of file From 0a8815b8f5af57568b28777fb9f663f179089d94 Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Thu, 31 Aug 2017 11:13:07 +0300 Subject: [PATCH 432/460] oneandone blockstorage with tests --- .../blockstorage/client/snapshots.js | 31 ++-- .../oneandone/blockstorage/snapshot.js | 1 - test/fixtures/oneandone/createSnapshot.json | 79 ++++++++++ test/fixtures/oneandone/snapshots.json | 7 + test/oneandone/blockstorage/snapshot-test.js | 3 + test/oneandone/blockstorage/test-snapshot.js | 143 ++++++++++++++++++ test/oneandone/compute/test-images.js | 4 +- test/oneandone/compute/test-servers.js | 13 +- 8 files changed, 261 insertions(+), 20 deletions(-) create mode 100644 test/fixtures/oneandone/createSnapshot.json create mode 100644 test/fixtures/oneandone/snapshots.json create mode 100644 test/oneandone/blockstorage/snapshot-test.js create mode 100644 test/oneandone/blockstorage/test-snapshot.js diff --git a/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js b/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js index b6ed1879b..f170fc5a3 100644 --- a/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js +++ b/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js @@ -3,6 +3,7 @@ */ var Snapshot = require('../snapshot').Snapshot, + oneandone = require('liboneandone'), Server = require('../../compute/server').Server; /** * client.getSnapshots @@ -12,7 +13,7 @@ var Snapshot = require('../snapshot').Snapshot, * @param {function} callback * @returns {*} */ -exports.getSnapshots = function (options, callback) { +exports.getSnapshots = function (server, callback) { var self = this, serverId = server instanceof Server ? server.id : server; oneandone.listSnapshots(serverId, function (error, response, body) { @@ -25,9 +26,15 @@ exports.getSnapshots = function (options, callback) { return; } var object = JSON.parse(body); - callback(null, object.volumes.map(function (data) { - return new Volume(self, data); - }), res); + var result = []; + if (object instanceof Array) { + result = object; + } else { + result.push(object); + } + callback(null, result.map(function (data) { + return new Snapshot(self, data); + })); }); }; @@ -41,8 +48,8 @@ exports.getSnapshots = function (options, callback) { * @param {function} callback * @returns {*} */ -exports.createSnapshot = function (options, callback) { - var serverId = options.server instanceof Server ? options.server.id : options.server; +exports.createSnapshot = function (server, callback) { + var serverId = server instanceof Server ? server.id : server; oneandone.createSnapshot(serverId, function (error, response, body) { if (error) { @@ -54,7 +61,7 @@ exports.createSnapshot = function (options, callback) { return; } var snapshot = JSON.parse(body); - callback(null, snapshot); + callback(null, snapshot.snapshot); }); }; @@ -69,8 +76,9 @@ exports.createSnapshot = function (options, callback) { * @returns {*} */ exports.updateSnapshot = function (options, callback) { + var self = this; var serverId = options.server instanceof Server ? options.server.id : options.server, - snapshotId = options.snapshot instanceof Snapshot ? options.snapshot.id : options.snapshot; + snapshotId = options.snapshot instanceof Object ? options.snapshot.id : options.snapshot; oneandone.restoreSnapshot(serverId, snapshotId, function (error, response, body) { if (error) { @@ -82,7 +90,7 @@ exports.updateSnapshot = function (options, callback) { return; } var snp = JSON.parse(body); - callback(null, new compute.Snapshot(self, snp)); + callback(null, new Snapshot(self, snp)); }); }; @@ -96,8 +104,9 @@ exports.updateSnapshot = function (options, callback) { * @returns {*} */ exports.deleteSnapshot = function (options, callback) { + var self = this; var serverId = options.server instanceof Server ? options.server.id : options.server, - snapshotId = options.snapshot instanceof Snapshot ? options.snapshot.id : options.snapshot; + snapshotId = options.snapshot instanceof Object ? options.snapshot.id : options.snapshot; oneandone.deleteSnapshot(serverId, snapshotId, function (error, response, body) { if (error) { @@ -109,6 +118,6 @@ exports.deleteSnapshot = function (options, callback) { return; } var snp = JSON.parse(body); - callback(null, new compute.Snapshot(self, snp)); + callback(null, new Snapshot(self, snp)); }); }; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/blockstorage/snapshot.js b/lib/pkgcloud/oneandone/blockstorage/snapshot.js index a6951ab71..452a6052c 100644 --- a/lib/pkgcloud/oneandone/blockstorage/snapshot.js +++ b/lib/pkgcloud/oneandone/blockstorage/snapshot.js @@ -14,7 +14,6 @@ util.inherits(Snapshot, base.Model); Snapshot.prototype._setProperties = function (details) { this.id = details.id; - this.name = details.name; }; Snapshot.prototype.toJSON = function () { diff --git a/test/fixtures/oneandone/createSnapshot.json b/test/fixtures/oneandone/createSnapshot.json new file mode 100644 index 000000000..b93349483 --- /dev/null +++ b/test/fixtures/oneandone/createSnapshot.json @@ -0,0 +1,79 @@ +{ + "id": "92AA60BEC8333A21EDB9EAAA61852860", + "cloudpanel_id": "5061DE9", + "name": "My server", + "description": null, + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "creation_date": "2015-05-06T11:09:55+00:00", + "first_password": null, + "status": { + "state": "CONFIGURING", + "percent": null + }, + "hardware": { + "fixed_instance_size_id": 0, + "vcore": 1, + "cores_per_processor": 1, + "ram": 1, + "hdds": [ + { + "id": "77F5BC74C9B3532A37D31FEED070BE01", + "size": 40, + "is_main": true + } + ] + }, + "image": { + "id": "07C170D67C8EC776933FCFF1C299C1C5", + "name": "w2012r2datacenter64min" + }, + "dvd": { + "id": "05F2EF8C89A12782B7DBE445256BD7A5", + "name": "centos7-64iso" + }, + "snapshot": { + "id": "D609F69D08EB0C77D8EADE22F70462B4", + "creation_date": "2015-05-07T10:47:23+00:00" + }, + "ips": [ + { + "id": "696469547988D3945B3FE59DFCB93C90", + "ip": "10.4.141.161", + "type": "IPV4", + "reverse_dns": null, + "firewall_policy": { + "id": "5DE607955050915229D602931F942F32", + "name": "Linux" + }, + "load_balancers": [] + } + ], + "alerts": { + "critical": [ + { + "type": "agent", + "description": "MONITORING_AGENT_NOT_INSTALLED", + "date": "2015-05-07 10:47:23" + }, + { + "type": "internal_ping", + "description": "CRITICAL - 10.4.141.161: rta nan, lost 100%", + "date": "2015-05-07 09:59:21" + } + ] + }, + "monitoring_policy": { + "id": "5DF232A92E9635249B8A4EB31C5B14F4", + "name": "My Monitoring Policy 1" + }, + "private_networks": [ + { + "id": "6B7051F17199EF9EA994CD3E4AA450E6", + "name": "New private network 1" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/oneandone/snapshots.json b/test/fixtures/oneandone/snapshots.json new file mode 100644 index 000000000..72fb37129 --- /dev/null +++ b/test/fixtures/oneandone/snapshots.json @@ -0,0 +1,7 @@ +[ +{ + "id": "D609F69D08EB0C77D8EADE22F70462B4", + "creation_date": "2015-04-06T23:48:38Z", + "deletion_date": "2015-04-09T23:48:38Z" +} +] \ No newline at end of file diff --git a/test/oneandone/blockstorage/snapshot-test.js b/test/oneandone/blockstorage/snapshot-test.js new file mode 100644 index 000000000..8416ceea4 --- /dev/null +++ b/test/oneandone/blockstorage/snapshot-test.js @@ -0,0 +1,3 @@ +/** + * Created by Ali Bazlamit on 8/30/2017. + */ diff --git a/test/oneandone/blockstorage/test-snapshot.js b/test/oneandone/blockstorage/test-snapshot.js new file mode 100644 index 000000000..2b4b9626d --- /dev/null +++ b/test/oneandone/blockstorage/test-snapshot.js @@ -0,0 +1,143 @@ +/** + * Created by Ali Bazlamit on 8/30/2017. + */ +var server, + _snapshot, + blockStorage, + client; +var should = require('should'), + helpers = require('../../helpers'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK, + Server = require('../../../lib/pkgcloud/core/compute/server').Server, + Snapshot = require('../../../lib/pkgcloud/oneandone/blockstorage/snapshot').Snapshot; + +var srvr_options = { + name: 'create-test-oao', + flavor: '81504C620D98BCEBAA5202D145203B4B', + image: '6631A1589A2CC87FEA9B99AB07399281', + location: '4EFAD5836CE43ACA502FD5B99BEE44EF', + token: process.env.OAO_TOKEN +}; + +describe('Snapshot tests', function () { + this.timeout(18000000); + var hockInstance, mockServer; + + before(function (done) { + client = helpers.createClient('oneandone', 'compute', srvr_options); + blockStorage = helpers.createClient('oneandone', 'blockstorage', srvr_options); + if (!mock) { + + client.createServer(srvr_options, function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + server = srv1; + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + blockStorage.createSnapshot(server, function (err, snapshot) { + should.not.exist(err); + should.exist(snapshot); + _snapshot = snapshot; + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + } else { + hockInstance = hock.createHock({ throwOnUnmatched: false }); + hockInstance.filteringRequestBody(helpers.authFilter); + mockServer = http.createServer(hockInstance.handler); + mockServer.listen(12345, done); + } + }); + + after(function (done) { + if (hockInstance) { + mockServer.close(function () { + done(); + }); + } + else { + var deleteOps = {}; + deleteOps.server = server; + deleteOps.snapshot = _snapshot; + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + blockStorage.deleteSnapshot(deleteOps, function (err, response) { + should.not.exist(err); + should.exist(response); + server.setWait({ status: server.STATUS.running }, 15000, function (err) { + if (err) { + console.dir(err); + return; + } + client.destroyServer(server, function (err, response) { + should.not.exist(err); + should.exist(response); + done(); + }); + }); + }); + }); + } + }); + + it('the getSnapshots() method should return a list of snapshots', function (done) { + if (mock) { + hockInstance + .get('servers/{server_id}/snapshots') + .reply(200, helpers.loadFixture('oneandone/snapshots.json')); + } + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + blockStorage.getSnapshots(server, function (err, snapshots) { + should.not.exist(err); + should.exist(snapshots); + + snapshots.should.be.an.Array; + + snapshots.forEach(function (snp) { + snp.should.be.instanceOf(Snapshot); + }); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the updateSnapshot() method should restore a snapshot into a server', function (done) { + if (mock) { + hockInstance + .get('/servers/92AA60BEC8333A21EDB9EAAA61852860/snapshots/D609F69D08EB0C77D8EADE22F70462B4') + .reply(202, helpers.loadFixture('oneandone/createSnapshot.json')); + } + var updateops = {}; + updateops.server = server; + updateops.snapshot = _snapshot; + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + blockStorage.updateSnapshot(updateops, function (err, response) { + should.not.exist(err); + should.exist(response); + response.should.be.instanceOf(Snapshot); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); +}); + diff --git a/test/oneandone/compute/test-images.js b/test/oneandone/compute/test-images.js index c35ebb8d5..b969897b7 100644 --- a/test/oneandone/compute/test-images.js +++ b/test/oneandone/compute/test-images.js @@ -15,9 +15,9 @@ var should = require('should'), var srvr_options = { name: 'create-test-oao2', - flavor: 'S', + flavor: '81504C620D98BCEBAA5202D145203B4B', image: '6631A1589A2CC87FEA9B99AB07399281', - location: 'Germany', + location: '4EFAD5836CE43ACA502FD5B99BEE44EF', }; var image_options = { name: 'pkgcloud image2', diff --git a/test/oneandone/compute/test-servers.js b/test/oneandone/compute/test-servers.js index 77a55c34e..a3ed44709 100644 --- a/test/oneandone/compute/test-servers.js +++ b/test/oneandone/compute/test-servers.js @@ -9,9 +9,9 @@ var should = require('should'), var client; var options = { name: 'create-test-oao2', - flavor: 'S', + flavor: '81504C620D98BCEBAA5202D145203B4B', image: '6631A1589A2CC87FEA9B99AB07399281', - location: 'Germany', + location: '4EFAD5836CE43ACA502FD5B99BEE44EF', token: process.env.OAO_TOKEN }; @@ -30,11 +30,12 @@ describe('Server tests', function () { srv1.image.id.should.equal(options.image); done(); }); + }else{ + hockInstance = hock.createHock({throwOnUnmatched: false}); + hockInstance.filteringRequestBody(helpers.authFilter); + mockServer = http.createServer(hockInstance.handler); + mockServer.listen(12345, done); } - hockInstance = hock.createHock({throwOnUnmatched: false}); - hockInstance.filteringRequestBody(helpers.authFilter); - mockServer = http.createServer(hockInstance.handler); - mockServer.listen(12345, done); }); after(function (done) { From 11765e8733770d2d5987c0b013532ba8125838da Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Thu, 31 Aug 2017 11:19:54 +0300 Subject: [PATCH 433/460] minor change --- test/oneandone/blockstorage/snapshot-test.js | 3 --- test/oneandone/blockstorage/test-snapshot.js | 1 - 2 files changed, 4 deletions(-) delete mode 100644 test/oneandone/blockstorage/snapshot-test.js diff --git a/test/oneandone/blockstorage/snapshot-test.js b/test/oneandone/blockstorage/snapshot-test.js deleted file mode 100644 index 8416ceea4..000000000 --- a/test/oneandone/blockstorage/snapshot-test.js +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Created by Ali Bazlamit on 8/30/2017. - */ diff --git a/test/oneandone/blockstorage/test-snapshot.js b/test/oneandone/blockstorage/test-snapshot.js index 2b4b9626d..862424134 100644 --- a/test/oneandone/blockstorage/test-snapshot.js +++ b/test/oneandone/blockstorage/test-snapshot.js @@ -10,7 +10,6 @@ var should = require('should'), hock = require('hock'), http = require('http'), mock = !!process.env.MOCK, - Server = require('../../../lib/pkgcloud/core/compute/server').Server, Snapshot = require('../../../lib/pkgcloud/oneandone/blockstorage/snapshot').Snapshot; var srvr_options = { From 5d96fe3f952a206f014d565632341f27c64df9ed Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Thu, 31 Aug 2017 11:32:42 +0300 Subject: [PATCH 434/460] [blockstorage] Service with tests --- .../oneandone/compute/client/flavors.js | 64 ++--- .../oneandone/compute/client/images.js | 148 ++++++------ .../oneandone/compute/client/index.js | 12 +- .../oneandone/compute/client/servers.js | 224 +++++++++--------- lib/pkgcloud/oneandone/compute/flavor.js | 16 +- lib/pkgcloud/oneandone/compute/image.js | 14 +- lib/pkgcloud/oneandone/compute/index.js | 2 +- lib/pkgcloud/oneandone/compute/server.js | 44 ++-- test/oneandone/compute/test-flavor.js | 142 +++++------ 9 files changed, 333 insertions(+), 333 deletions(-) diff --git a/lib/pkgcloud/oneandone/compute/client/flavors.js b/lib/pkgcloud/oneandone/compute/client/flavors.js index 3ecab9620..944f46730 100644 --- a/lib/pkgcloud/oneandone/compute/client/flavors.js +++ b/lib/pkgcloud/oneandone/compute/client/flavors.js @@ -3,9 +3,9 @@ */ var pkgcloud = require('../../../../../lib/pkgcloud'), - base = require('../../../core/compute'), - oneandone = require('liboneandone'), - compute = pkgcloud.providers.oneandone.compute; + base = require('../../../core/compute'), + oneandone = require('liboneandone'), + compute = pkgcloud.providers.oneandone.compute; // // ### function getFlavors(size, callback) @@ -15,22 +15,22 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), // Returns available flavours for fixed servers. // exports.getFlavors = function getFlavors(callback) { - var self = this; + var self = this; - oneandone.listHardwareFlavours(function (error, response, body) { - if (error) { - callback(error); - return; - } - if (response.statusCode != 200) { - callback(JSON.parse(body)); - return; - } - var flavors = JSON.parse(body); - callback(error, flavors.map(function (flavor) { - return new compute.Flavor(self, flavor); - })); - }); + oneandone.listHardwareFlavours(function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 200) { + callback(JSON.parse(body)); + return; + } + var flavors = JSON.parse(body); + callback(error, flavors.map(function (flavor) { + return new compute.Flavor(self, flavor); + })); + }); }; // @@ -42,18 +42,18 @@ exports.getFlavors = function getFlavors(callback) { // Returns information about one flavour // exports.getFlavor = function getFlavor(flavor, callback) { - var flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; - var self = this; - oneandone.getHardwareFlavour(flavorId, function (error, response, body) { - if (error) { - callback(error); - return; - } - if (response.statusCode != 200) { - callback(JSON.parse(body)); - return; - } - var flavor = JSON.parse(body); - callback(null, new compute.Flavor(self, flavor)); - }); + var flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; + var self = this; + oneandone.getHardwareFlavour(flavorId, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 200) { + callback(JSON.parse(body)); + return; + } + var flavor = JSON.parse(body); + callback(null, new compute.Flavor(self, flavor)); + }); }; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/client/images.js b/lib/pkgcloud/oneandone/compute/client/images.js index 9a77b08e5..284abf0e4 100644 --- a/lib/pkgcloud/oneandone/compute/client/images.js +++ b/lib/pkgcloud/oneandone/compute/client/images.js @@ -3,9 +3,9 @@ * */ var pkgcloud = require('../../../../../lib/pkgcloud'), - base = require('../../../core/compute'), - oneandone = require('liboneandone'), - compute = pkgcloud.providers.oneandone.compute; + base = require('../../../core/compute'), + oneandone = require('liboneandone'), + compute = pkgcloud.providers.oneandone.compute; // // ### function getImages (callback) // #### @callback {function} f(err, images). `images` is an array that @@ -14,26 +14,26 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), // Lists all images available to your account. // exports.getImages = function getImages(options, callback) { - var self = this; - if (typeof options === 'function') { - callback = options; - options = {}; + var self = this; + if (typeof options === 'function') { + callback = options; + options = {}; + } + var images = []; + oneandone.listServerAppliances(function (error, response, body) { + if (error) { + callback(error); + return; } - var images = []; - oneandone.listServerAppliances(function (error, response, body) { - if (error) { - callback(error); - return; - } - if (response.statusCode != 200) { - callback(JSON.parse(body)); - return; - } - images = JSON.parse(body); - callback(error, images.map(function (image) { - return new compute.Image(self, image); - })); - }); + if (response.statusCode != 200) { + callback(JSON.parse(body)); + return; + } + images = JSON.parse(body); + callback(error, images.map(function (image) { + return new compute.Image(self, image); + })); + }); }; // ### function getImage (image, callback) @@ -45,18 +45,18 @@ exports.getImages = function getImages(options, callback) { // exports.getImage = function getImage(image, callback) { - var self = this; - var imageId = image instanceof base.Image - ? image.id - : image; + var self = this; + var imageId = image instanceof base.Image + ? image.id + : image; - oneandone.getServerAppliance(imageId, function (error, response, body) { - if (error) { - return callback(error); - } - var img = JSON.parse(body); - callback(null, new compute.Image(self, img)); - }); + oneandone.getServerAppliance(imageId, function (error, response, body) { + if (error) { + return callback(error); + } + var img = JSON.parse(body); + callback(null, new compute.Image(self, img)); + }); }; // @@ -71,44 +71,44 @@ exports.getImage = function getImage(image, callback) { // exports.createImage = function createImage(options, callback) { - var self = this; - options || (options = {}); + var self = this; + options || (options = {}); - var serverId = options.server instanceof base.Server - ? options.server.id - : options.server; + var serverId = options.server instanceof base.Server + ? options.server.id + : options.server; - if (!options.name) { - throw new TypeError('`name` is a required option'); - } + if (!options.name) { + throw new TypeError('`name` is a required option'); + } - if (!options.server) { - throw new TypeError('`server` is a required option'); - } + if (!options.server) { + throw new TypeError('`server` is a required option'); + } - var imageData = { - 'server_id': serverId, - 'name': options.name, - 'frequency': oneandone.ImageFrequency.ONCE, - 'source': 'server', - 'num_images': 1, - 'datacenter_id': options.server.datacenter ? options.server.datacenter.id : null - }; + var imageData = { + 'server_id': serverId, + 'name': options.name, + 'frequency': oneandone.ImageFrequency.ONCE, + 'source': 'server', + 'num_images': 1, + 'datacenter_id': options.server.datacenter ? options.server.datacenter.id : null + }; - oneandone.createImage(imageData, function (error, response, body) { - if (error) { - callback(error); - return; - } - if (response.statusCode != 202) { - callback(JSON.parse(body)); - return; - } - var _image = JSON.parse(body); - var image = new compute.Image(self, _image); - callback(null, image); + oneandone.createImage(imageData, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _image = JSON.parse(body); + var image = new compute.Image(self, _image); + callback(null, image); - }); + }); }; // @@ -121,15 +121,15 @@ exports.createImage = function createImage(options, callback) { // exports.destroyImage = function destroyImage(image, callback) { - var imageId = image instanceof base.Image - ? image.id - : image; - oneandone.deleteImage(imageId, function (error, response, body) { - if (error) { - return callback(error); - } - callback(null, body); - }); + var imageId = image instanceof base.Image + ? image.id + : image; + oneandone.deleteImage(imageId, function (error, response, body) { + if (error) { + return callback(error); + } + callback(null, body); + }); }; diff --git a/lib/pkgcloud/oneandone/compute/client/index.js b/lib/pkgcloud/oneandone/compute/client/index.js index de59d1865..33d202b33 100644 --- a/lib/pkgcloud/oneandone/compute/client/index.js +++ b/lib/pkgcloud/oneandone/compute/client/index.js @@ -3,15 +3,15 @@ */ var util = require('util'), - oneandone = require('../../client'), - _ = require('lodash'); + oneandone = require('../../client'), + _ = require('lodash'); var Client = exports.Client = function (options) { - oneandone.Client.call(this, options); + oneandone.Client.call(this, options); - _.extend(this, require('./servers')); - _.extend(this, require('./images')); - _.extend(this, require('./flavors')); + _.extend(this, require('./servers')); + _.extend(this, require('./images')); + _.extend(this, require('./flavors')); }; util.inherits(Client, oneandone.Client); \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/client/servers.js b/lib/pkgcloud/oneandone/compute/client/servers.js index ff6ff21b0..9e4f75604 100644 --- a/lib/pkgcloud/oneandone/compute/client/servers.js +++ b/lib/pkgcloud/oneandone/compute/client/servers.js @@ -3,10 +3,10 @@ */ var base = require('../../../core/compute'), - pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), - oneandone = require('liboneandone'), - compute = pkgcloud.providers.oneandone.compute; + pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + oneandone = require('liboneandone'), + compute = pkgcloud.providers.oneandone.compute; // // ### function getVersion (callback) @@ -15,7 +15,7 @@ var base = require('../../../core/compute'), // Gets the current API version // exports.getVersion = function getVersion(callback) { - callback(null, '1.7'); + callback(null, '1.7'); }; // @@ -26,22 +26,22 @@ exports.getVersion = function getVersion(callback) { // Lists all servers available to your account. // exports.getServers = function getServers(options, callback) { - if (typeof options === 'function') { - callback = options; - options = {}; - } + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var self = this; - var self = this; - - oneandone.listServers(function (error, response, results) { - if (error) { - callback(error); - return; - } - callback(null, JSON.parse(results).map(function (server) { - return new compute.Server(self, server); - })); - }); + oneandone.listServers(function (error, response, results) { + if (error) { + callback(error); + return; + } + callback(null, JSON.parse(results).map(function (server) { + return new compute.Server(self, server); + })); + }); }; // @@ -56,59 +56,59 @@ exports.getServers = function getServers(options, callback) { // id of the options can be ids of Hardware Flavors // exports.createServer = function createServer(options, callback) { - if (typeof options === 'function') { - callback = options; - options = {}; - } - var self = this, - ImageId, - hardware = {}; - options = options || {}; // no args - if (!options.image) { - return errs.handle( - errs.create({ - message: 'options.image is a required argument.' - }), - callback - ); + if (typeof options === 'function') { + callback = options; + options = {}; + } + var self = this, + ImageId, + hardware = {}; + options = options || {}; // no args + if (!options.image) { + return errs.handle( + errs.create({ + message: 'options.image is a required argument.' + }), + callback + ); + } + ImageId = options.image instanceof base.Image + ? options.image.id + : options.image; + + if (options.flavor) { + hardware = { + 'fixed_instance_size_id': options.flavor + }; + } else { + return errs.handle( + errs.create({ + message: 'options.flavor: is required' + }), + callback + ); + } + + var serverData = { + 'name': options.name, + 'hardware': hardware, + 'appliance_id': ImageId, + 'datacenter_id': options.location + }; + + oneandone.createServer(serverData, function (error, response, body) { + if (error) { + callback(error); + return; } - ImageId = options.image instanceof base.Image - ? options.image.id - : options.image; - - if (options.flavor) { - hardware = { - 'fixed_instance_size_id': options.flavor - }; - } else { - return errs.handle( - errs.create({ - message: 'options.flavor: is required' - }), - callback - ); + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; } - - var serverData = { - 'name': options.name, - 'hardware': hardware, - 'appliance_id': ImageId, - 'datacenter_id': options.location - }; - - oneandone.createServer(serverData, function (error, response, body) { - if (error) { - callback(error); - return; - } - if (response.statusCode != 202) { - callback(JSON.parse(body)); - return; - } - var _server = JSON.parse(body); - var server = new compute.Server(self, _server); - callback(null, server); - }); + var _server = JSON.parse(body); + var server = new compute.Server(self, _server); + callback(null, server); + }); }; // @@ -119,18 +119,18 @@ exports.createServer = function createServer(options, callback) { // Destroy a server in OAO. // exports.destroyServer = function destroyServer(server, callback) { - var serverId = server instanceof base.Server ? server.id : server; - oneandone.deleteServer(serverId, false, function (error, response, body) { - if (error) { - callback(error); - return; - } - if (response.statusCode != 202) { - callback(JSON.parse(body)); - return; - } - callback(null, JSON.parse(body)); - }); + var serverId = server instanceof base.Server ? server.id : server; + oneandone.deleteServer(serverId, false, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + callback(null, JSON.parse(body)); + }); }; // @@ -141,17 +141,17 @@ exports.destroyServer = function destroyServer(server, callback) { // Gets a server in OAO. // exports.getServer = function getServer(server, callback) { - var self = this, - serverId = server instanceof base.Server ? server.id : server; - - oneandone.getServer(serverId, function (error, response, body) { - if (error) { - return callback(error); - } - var srv = JSON.parse(body); - callback(null, new compute.Server(self, srv)); - } - ); + var self = this, + serverId = server instanceof base.Server ? server.id : server; + + oneandone.getServer(serverId, function (error, response, body) { + if (error) { + return callback(error); + } + var srv = JSON.parse(body); + callback(null, new compute.Server(self, srv)); + } + ); }; // @@ -162,25 +162,25 @@ exports.getServer = function getServer(server, callback) { // Reboots a server // exports.rebootServer = function rebootServer(server, callback) { - var self = this, - serverId = server instanceof base.Server ? server.id : server; + var self = this, + serverId = server instanceof base.Server ? server.id : server; - var updateData = { - 'action': oneandone.ServerUpdateAction.REBOOT, - 'method': oneandone.ServerUpdateMethod.SOFTWARE + var updateData = { + 'action': oneandone.ServerUpdateAction.REBOOT, + 'method': oneandone.ServerUpdateMethod.SOFTWARE - }; + }; - oneandone.updateServerStatus(serverId, updateData, function (error, response, body) { - if (error) { - return callback(error); - } - if (response.statusCode != 202) { - callback(JSON.parse(body)); - return; - } - var _server = JSON.parse(body); - var server = new compute.Server(self, _server); - callback(null, server); - }); + oneandone.updateServerStatus(serverId, updateData, function (error, response, body) { + if (error) { + return callback(error); + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _server = JSON.parse(body); + var server = new compute.Server(self, _server); + callback(null, server); + }); }; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/flavor.js b/lib/pkgcloud/oneandone/compute/flavor.js index 6452eab50..3d7ac2496 100644 --- a/lib/pkgcloud/oneandone/compute/flavor.js +++ b/lib/pkgcloud/oneandone/compute/flavor.js @@ -3,20 +3,20 @@ */ var util = require('util'), - base = require('../../core/compute/flavor'); + base = require('../../core/compute/flavor'); var Flavor = exports.Flavor = function Flavor(client, details) { - base.Flavor.call(this, client, details); + base.Flavor.call(this, client, details); }; util.inherits(Flavor, base.Flavor); Flavor.prototype._setProperties = function (details) { - var id = details.id; + var id = details.id; - this.id = id; - this.name = details.name; - this.ram = details.hardware.ram; - this.disk = details.hardware.hdds[0] ? details.hardware.hdds[0].size : 0; - this.cores = details.hardware.vcore; + this.id = id; + this.name = details.name; + this.ram = details.hardware.ram; + this.disk = details.hardware.hdds[0] ? details.hardware.hdds[0].size : 0; + this.cores = details.hardware.vcore; }; diff --git a/lib/pkgcloud/oneandone/compute/image.js b/lib/pkgcloud/oneandone/compute/image.js index 2a52e2a4c..96b112986 100644 --- a/lib/pkgcloud/oneandone/compute/image.js +++ b/lib/pkgcloud/oneandone/compute/image.js @@ -6,21 +6,21 @@ */ var util = require('util'), - base = require('../../core/compute/image'), - _ = require('lodash'); + base = require('../../core/compute/image'), + _ = require('lodash'); var Image = exports.Image = function Image(client, details) { - base.Image.call(this, client, details); + base.Image.call(this, client, details); }; util.inherits(Image, base.Image); Image.prototype._setProperties = function (details) { - this.id = details.id; - this.name = details.name; - this.server_id = details.server_id; + this.id = details.id; + this.name = details.name; + this.server_id = details.server_id; }; Image.prototype.toJSON = function () { - return _.pick(this, ['id', 'name', 'server_id']); + return _.pick(this, ['id', 'name', 'server_id']); }; diff --git a/lib/pkgcloud/oneandone/compute/index.js b/lib/pkgcloud/oneandone/compute/index.js index f1bc20009..5307e0de8 100644 --- a/lib/pkgcloud/oneandone/compute/index.js +++ b/lib/pkgcloud/oneandone/compute/index.js @@ -7,5 +7,5 @@ exports.Image = require('./image').Image; exports.Flavor = require('./flavor').Flavor; exports.createClient = function (options) { - return new exports.Client(options); + return new exports.Client(options); }; diff --git a/lib/pkgcloud/oneandone/compute/server.js b/lib/pkgcloud/oneandone/compute/server.js index 60f7f8e69..bc6091655 100644 --- a/lib/pkgcloud/oneandone/compute/server.js +++ b/lib/pkgcloud/oneandone/compute/server.js @@ -6,38 +6,38 @@ */ var util = require('util'), - _ = require('lodash'), - base = require('../../core/compute/server'); + _ = require('lodash'), + base = require('../../core/compute/server'); var Server = exports.Server = function Server(client, details) { - base.Server.call(this, client, details); + base.Server.call(this, client, details); }; util.inherits(Server, base.Server); Server.prototype._setProperties = function (details) { - this.id = details.id; - this.name = details.name; - this.image = details.image; - this.imageId = details.image ? details.image.id : details.imageId; - if (details.datacenter) { - this.datacenter = details.datacenter; - } + this.id = details.id; + this.name = details.name; + this.image = details.image; + this.imageId = details.image ? details.image.id : details.imageId; + if (details.datacenter) { + this.datacenter = details.datacenter; + } - switch (details.status && details.status.state) { - case 'POWERED_ON': - this.status = 'RUNNING'; - break; - case 'POWERED_OFF': - this.status = this.STATUS.stopped; - break; - case 'NEW': - default: - this.status = 'PROVISIONING'; - } + switch (details.status && details.status.state) { + case 'POWERED_ON': + this.status = 'RUNNING'; + break; + case 'POWERED_OFF': + this.status = this.STATUS.stopped; + break; + case 'NEW': + default: + this.status = 'PROVISIONING'; + } }; Server.prototype.toJSON = function () { - return _.pick(this, ['id', 'name', 'image', 'datacenter']); + return _.pick(this, ['id', 'name', 'image', 'datacenter']); }; \ No newline at end of file diff --git a/test/oneandone/compute/test-flavor.js b/test/oneandone/compute/test-flavor.js index c077b3927..6fd05a909 100644 --- a/test/oneandone/compute/test-flavor.js +++ b/test/oneandone/compute/test-flavor.js @@ -2,90 +2,90 @@ * Created by Ali Bazlamit on 8/21/2017. */ var should = require('should'), - async = require('async'), - helpers = require('../../helpers'), - hock = require('hock'), - http = require('http'), - mock = true, - Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor; + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + http = require('http'), + mock = true, + Flavor = require('../../../lib/pkgcloud/core/compute/flavor').Flavor; var flavors = [], - client; + client; var options = { - token: process.env.OAO_TOKEN + token: process.env.OAO_TOKEN }; describe('Flavor tests', function () { - this.timeout(18000000); - var authHockInstance, hockInstance, authServer, mockServer; + this.timeout(18000000); + var authHockInstance, hockInstance, authServer, mockServer; - before(function (done) { - client = helpers.createClient('oneandone', 'compute', options); - if (!mock) { - return done(); - } - hockInstance = hock.createHock({throwOnUnmatched: false}); - authHockInstance = hock.createHock(); - mockServer = http.createServer(hockInstance.handler); - authServer = http.createServer(authHockInstance.handler); - async.parallel([ - function (next) { - mockServer.listen(12345, next); - }, - function (next) { - authServer.listen(12346, next); - } - ], done); - }); + before(function (done) { + client = helpers.createClient('oneandone', 'compute', options); + if (!mock) { + return done(); + } + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + mockServer = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + async.parallel([ + function (next) { + mockServer.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + }); - after(function (done) { - if (!mock) { - return done(); - } + after(function (done) { + if (!mock) { + return done(); + } - async.parallel([ - function (next) { - mockServer.close(next); - }, - function (next) { - authServer.close(next); - } - ], done); - }); + async.parallel([ + function (next) { + mockServer.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + }); - it('the getFlavors() method should return the list of flavors', function (done) { - if (mock) { - hockInstance - .get('/servers/fixed_instance_sizes') - .reply(200, helpers.loadFixture('oneandone/listFlavors.json')); - } - client.getFlavors(function (err, _flavors) { - should.exist(_flavors); - _flavors.should.be.an.Array; - _flavors.forEach(function (flavor) { - flavor.should.be.instanceOf(Flavor); - }); - flavors = _flavors; - hockInstance && hockInstance.done(); - done(); - }); + it('the getFlavors() method should return the list of flavors', function (done) { + if (mock) { + hockInstance + .get('/servers/fixed_instance_sizes') + .reply(200, helpers.loadFixture('oneandone/listFlavors.json')); + } + client.getFlavors(function (err, _flavors) { + should.exist(_flavors); + _flavors.should.be.an.Array; + _flavors.forEach(function (flavor) { + flavor.should.be.instanceOf(Flavor); + }); + flavors = _flavors; + hockInstance && hockInstance.done(); + done(); }); + }); - it('the getFlavor() method should return a valid flavor', function (done) { - if (mock) { - hockInstance - .get('/servers/fixed_instance_sizes/8C626C1A7005D0D1F527143C413D461E') - .reply(200, helpers.loadFixture('oneandone/getFlavor.json')); - } - client.getFlavor(flavors[0], function (err, flavor) { - should.not.exist(err); - should.exist(flavor); - flavor.should.be.instanceOf(Flavor); - flavor.id.should.equal(flavors[0].id); - hockInstance && hockInstance.done(); - done(); - }); + it('the getFlavor() method should return a valid flavor', function (done) { + if (mock) { + hockInstance + .get('/servers/fixed_instance_sizes/8C626C1A7005D0D1F527143C413D461E') + .reply(200, helpers.loadFixture('oneandone/getFlavor.json')); + } + client.getFlavor(flavors[0], function (err, flavor) { + should.not.exist(err); + should.exist(flavor); + flavor.should.be.instanceOf(Flavor); + flavor.id.should.equal(flavors[0].id); + hockInstance && hockInstance.done(); + done(); }); + }); }); From 5cbc7f6bd13d9d3cb4e36c44fc3174ccabcd9657 Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Thu, 31 Aug 2017 18:16:24 +0300 Subject: [PATCH 435/460] [loadbalancer] 1&1 with test/mocks --- lib/pkgcloud/oneandone/blockstorage/index.js | 3 - lib/pkgcloud/oneandone/compute/server.js | 1 + lib/pkgcloud/oneandone/index.js | 3 +- .../oneandone/loadbalancer/client/index.js | 17 ++ .../loadbalancer/client/loadbalancers.js | 172 +++++++++++++ .../oneandone/loadbalancer/client/nodes.js | 97 ++++++++ lib/pkgcloud/oneandone/loadbalancer/index.js | 11 + .../oneandone/loadbalancer/loadbalancer.js | 28 +++ lib/pkgcloud/oneandone/loadbalancer/node.js | 20 ++ lib/pkgcloud/oneandone/loadbalancer/rule.js | 20 ++ test/fixtures/oneandone/addNodes.json | 12 + .../oneandone/createLoadBalancer.json | 38 +++ .../loadbalancer/test-loadbalancers.js | 232 ++++++++++++++++++ 13 files changed, 650 insertions(+), 4 deletions(-) create mode 100644 lib/pkgcloud/oneandone/loadbalancer/client/index.js create mode 100644 lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js create mode 100644 lib/pkgcloud/oneandone/loadbalancer/client/nodes.js create mode 100644 lib/pkgcloud/oneandone/loadbalancer/index.js create mode 100644 lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js create mode 100644 lib/pkgcloud/oneandone/loadbalancer/node.js create mode 100644 lib/pkgcloud/oneandone/loadbalancer/rule.js create mode 100644 test/fixtures/oneandone/addNodes.json create mode 100644 test/fixtures/oneandone/createLoadBalancer.json create mode 100644 test/oneandone/loadbalancer/test-loadbalancers.js diff --git a/lib/pkgcloud/oneandone/blockstorage/index.js b/lib/pkgcloud/oneandone/blockstorage/index.js index 5758de503..c149170bd 100644 --- a/lib/pkgcloud/oneandone/blockstorage/index.js +++ b/lib/pkgcloud/oneandone/blockstorage/index.js @@ -1,9 +1,6 @@ /** * Created by Ali Bazlamit on 8/28/2017. */ -/** - * Created by Ali Bazlamit on 8/14/2017. - */ exports.Client = require('./client').Client; exports.Snapshot = require('./snapshot').Snapshot; diff --git a/lib/pkgcloud/oneandone/compute/server.js b/lib/pkgcloud/oneandone/compute/server.js index bc6091655..a05ba224f 100644 --- a/lib/pkgcloud/oneandone/compute/server.js +++ b/lib/pkgcloud/oneandone/compute/server.js @@ -21,6 +21,7 @@ Server.prototype._setProperties = function (details) { this.name = details.name; this.image = details.image; this.imageId = details.image ? details.image.id : details.imageId; + this.ips = details.ips; if (details.datacenter) { this.datacenter = details.datacenter; } diff --git a/lib/pkgcloud/oneandone/index.js b/lib/pkgcloud/oneandone/index.js index 251aa23be..001d01d00 100644 --- a/lib/pkgcloud/oneandone/index.js +++ b/lib/pkgcloud/oneandone/index.js @@ -5,4 +5,5 @@ */ exports.compute = require('./compute'); -exports.blockstorage = require('./blockstorage'); \ No newline at end of file +exports.blockstorage = require('./blockstorage'); +exports.loadbalancer = require('./loadbalancer'); \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/loadbalancer/client/index.js b/lib/pkgcloud/oneandone/loadbalancer/client/index.js new file mode 100644 index 000000000..d1aec485f --- /dev/null +++ b/lib/pkgcloud/oneandone/loadbalancer/client/index.js @@ -0,0 +1,17 @@ +/** + * Created by Ali Bazlamit on 8/31/2017. + */ + +var util = require('util'), + oneandone = require('../../client'), + _ = require('lodash'); + +var Client = exports.Client = function (options) { + oneandone.Client.call(this, options); + + _.extend(this, require('./loadbalancers')); + _.extend(this, require('./nodes')); + +}; + +util.inherits(Client, oneandone.Client); \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js b/lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js new file mode 100644 index 000000000..b1abb89a8 --- /dev/null +++ b/lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js @@ -0,0 +1,172 @@ +/** + * Created by Ali Bazlamit on 8/31/2017. + */ +var pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + oneandone = require('liboneandone'), + LoadBalancer = require('../loadbalancer').LoadBalancer; + +// +// ### function getLoadBalancers (callback) +// #### @callback {function} f(err, loadbalancers). `loadbalancers` is an array that +// represents the loadbalancers that are available to your account +// +// Lists all loadbalancers available to your account. +// +exports.getLoadBalancers = function getLoadBalancers(options, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var self = this; + + oneandone.listLoadBalancers(function (error, response, body) { + if (error) { + callback(error); + return; + } + callback(null, JSON.parse(body).map(function (loadbalancer) { + return new LoadBalancer(self, loadbalancer); + })); + }); +}; + +// +// ### function createLoadbalancer (options, callback) +// #### @opts {Object} options +// #### @name {String} Load balancer name +// #### @healthCheckInterval {int} Health check period in seconds +// #### @healthCheckPath {String} **Optional** flavor to use for this image +// #### @healthCheckParser {String} **Optional** flavor to use for this image +// #### @persistence {boolean} Persistence +// #### @persistenceTime {int} Persistence time in seconds. Required if persistence is enabled. +// #### @method {String} "Balancing procedure","enum": ["ROUND_ROBIN", "LEAST_CONNECTIONS"]. +// #### @datacenterId {String} **Optional** ID of the datacenter where the load balancer will be created +// #### @rules {Array|Rule} **Optional** flavor to use for this image +// #### @callback {Function} f(err, loadbalancer). +// +// Creates a new load balancer. +// +exports.createLoadBalancer = function createLoadBalancer(options, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } + var self = this; + + var balancerData = { + "name": options.name, + "description": options.name, + "health_check_test": oneandone.HealthCheckTestTypes.TCP, + "health_check_interval": options.healthCheckInterval, + "health_check_path": options.healthCheckPath, + "health_check_parser": options.healthCheckParser, + "persistence": options.Persistence, + "persistence_time": options.persistenceTime, + "method": options.method, + "datacenter_id": options.location, + "rules": options.rules + }; + + oneandone.createLoadBalancer(balancerData, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _lb = JSON.parse(body); + var lb = new LoadBalancer(self, _lb); + callback(null, lb); + }); +}; + +// +// ### function deleteLoadBalancer(loadbalancer, callback) +// #### @loadbalancer {LoadBalancer|String} LoadBalancer id or a LoadBalancer +// #### @callback {Function} f(err, lbId). +// +// Destroy a LoadBalancer in OAO. +// +exports.deleteLoadBalancer = function deleteLoadBalancer(loadbalancer, callback) { + var lbId = loadbalancer instanceof LoadBalancer ? loadbalancer.id : loadbalancer; + oneandone.deleteLoadBalancer(lbId, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + callback(null, JSON.parse(body)); + }); +}; + +// +// ### function getLoadBalancer(loadbalancer, callback) +// #### @loadbalancer {LoadBalancer|String} LoadBalancer id or a loadbalancer +// #### @callback {Function} f(err, lbId). +// +// Gets a loadbalancer in OAO. +// +exports.getLoadBalancer = function getLoadBalancer(loadbalancer, callback) { + var self = this, + lbId = loadbalancer instanceof LoadBalancer ? loadbalancer.id : loadbalancer; + + oneandone.getLoadBalancer(lbId, function (error, response, body) { + if (error) { + return callback(error); + } + var _lb = JSON.parse(body); + callback(null, new LoadBalancer(self, _lb)); + } + ); +}; + +/** + * client.updateLoadBalancer + // #### @opts {Object} options + // #### @name {String} Load balancer name + // #### @healthCheckInterval {int} Health check period in seconds + // #### @healthCheckPath {String} **Optional** flavor to use for this image + // #### @healthCheckParser {String} **Optional** flavor to use for this image + // #### @persistence {boolean} Persistence + // #### @persistenceTime {int} Persistence time in seconds. Required if persistence is enabled. + // #### @method {String} "Balancing procedure","enum": ["ROUND_ROBIN", "LEAST_CONNECTIONS"]. + * @param {function} callback + * @returns {*} + */ +exports.updateLoadBalancer = function updateLoadBalancer(options, callback) { + var self = this, + lbId = options.loadbalancer instanceof LoadBalancer ? options.loadbalancer.id : options.loadbalancer; + + var updateData = { + "name": options.name, + "health_check_test": oneandone.HealthCheckTestTypes.TCP, + "health_check_interval": options.healthCheckInterval, + "health_check_path": options.healthCheckPath, + "health_check_parser": options.healthCheckParser, + "persistence": options.Persistence, + "persistence_time": options.persistenceTime, + "method": options.method, + "rules": options.rules + }; + oneandone.updateLoadBalancer(lbId, updateData, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var lb = JSON.parse(body); + callback(null, new LoadBalancer(self, lb)); + }); +}; + + diff --git a/lib/pkgcloud/oneandone/loadbalancer/client/nodes.js b/lib/pkgcloud/oneandone/loadbalancer/client/nodes.js new file mode 100644 index 000000000..da186dec2 --- /dev/null +++ b/lib/pkgcloud/oneandone/loadbalancer/client/nodes.js @@ -0,0 +1,97 @@ +/** + * Created by Ali Bazlamit on 8/31/2017. + */ +var pkgcloud = require('../../../../../lib/pkgcloud'), + errs = require('errs'), + oneandone = require('liboneandone'), + LoadBalancer = require('../loadbalancer').LoadBalancer, + Node = require('../node').Node; + +// +// ### function getNodes (callback) +// #### @callback {function} f(err, nodes). +// Returns a list of the servers/IPs attached to a load balancer. +// +exports.getNodes = function getNodes(loadbalancer, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } + + var self = this, + lbId = loadbalancer instanceof LoadBalancer ? loadbalancer.id : loadbalancer; + + oneandone.listLoadBalancerServerIps(lbId, function (error, response, body) { + if (error) { + callback(error); + return; + } + callback(null, JSON.parse(body).map(function (node) { + return new Node(self, node); + })); + }); +}; + +// +// ### function createNode (serverIps, callback) +// #### @opts {Object} options +// #### @loadbalancer {Loadbalancer} Load balancer name +// #### @serverIps {Array} +// +// #### @callback {Function} f(err, node). +// +// Assigns servers/IPs to a load balancer. +// +exports.addNodes = function addNodes(options, callback) { + if (typeof options === 'function') { + callback = options; + options = {}; + } + var self = this; + var lbId = options.loadbalancer instanceof LoadBalancer ? options.loadbalancer.id : options.loadbalancer; + + var assignData = { + "server_ips": options.serverIps + }; + + oneandone.assignServerIpToLoadBalancer(lbId, assignData, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _lb = JSON.parse(body); + var lb = new LoadBalancer(self, _lb); + callback(null, lb); + }); +}; + +// +// ### function deleteNode(options, callback) +// #### @opts {Object} options +// #### @loadbalancer {Loadbalancer} Load balancer name +// #### @serverIp {String} +// #### @callback {Function} f(err, lbId). +// +// Destroy a Node in OAO. +// +exports.removeNode = function removeNode(options, callback) { + var self = this, + lbId = options.loadbalancer instanceof LoadBalancer ? options.loadbalancer.id : options.loadbalancer; + oneandone.unassignServerIpFromLoadBalancer(lbId, options.serverIp, function (error, response, body) { + if (error) { + callback(error); + return; + } + if (response.statusCode != 202) { + callback(JSON.parse(body)); + return; + } + var _lb = JSON.parse(body); + var lb = new LoadBalancer(self, _lb); + callback(null, lb); + }); +}; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/loadbalancer/index.js b/lib/pkgcloud/oneandone/loadbalancer/index.js new file mode 100644 index 000000000..0e3ae9482 --- /dev/null +++ b/lib/pkgcloud/oneandone/loadbalancer/index.js @@ -0,0 +1,11 @@ +/** + * Created by Ali Bazlamit on 8/31/2017. + */ + +exports.Client = require('./client').Client; +exports.LoadBalancer = require('./loadbalancer').LoadBalancer; +exports.Node = require('./node').Node; + +exports.createClient = function (options) { + return new exports.Client(options); +}; diff --git a/lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js b/lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js new file mode 100644 index 000000000..5425ca69b --- /dev/null +++ b/lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js @@ -0,0 +1,28 @@ +/** + * Created by Ali Bazlamit on 8/31/2017. + */ + +var util = require('util'), + base = require('../../core/loadbalancer/loadbalancer'); + +var LoadBalancer = exports.LoadBalancer = function LoadBalancer(client, details) { + base.LoadBalancer.call(this, client, details); +}; + +util.inherits(LoadBalancer, base.LoadBalancer); + +LoadBalancer.prototype._setProperties = function (details) { + var id = details.id; + + this.id = id; + this.name = details.name; + this.ip = details.ip; + this.healthCheckTest = details.health_check_test; + this.healthCheckInterval = details.health_check_interval; + this.persistence = details.persistence; + this.persistenceTime = details.persistence_time; + this.datacenter = details.datacenter; + this.rules = details.rules; + this.serverIps = details.server_ips; + +}; diff --git a/lib/pkgcloud/oneandone/loadbalancer/node.js b/lib/pkgcloud/oneandone/loadbalancer/node.js new file mode 100644 index 000000000..153ba4e96 --- /dev/null +++ b/lib/pkgcloud/oneandone/loadbalancer/node.js @@ -0,0 +1,20 @@ +/** + * Created by Ali Bazlamit on 8/31/2017. + */ + +var util = require('util'), + base = require('../../core/loadbalancer/node'); + +var Node = exports.Node = function Node(client, details) { + base.Node.call(this, client, details); +}; + +util.inherits(Node, base.Node); + +Node.prototype._setProperties = function (details) { + var self = this; + + self.id = details.id; + self.ip = details.ip; + self.server_name = details.server_name; +}; diff --git a/lib/pkgcloud/oneandone/loadbalancer/rule.js b/lib/pkgcloud/oneandone/loadbalancer/rule.js new file mode 100644 index 000000000..c3aa92c75 --- /dev/null +++ b/lib/pkgcloud/oneandone/loadbalancer/rule.js @@ -0,0 +1,20 @@ +/** + * Created by Ali Bazlamit on 8/31/2017. + */ +var Rule = function (details) { + if (!details) { + throw new Error('Rule must be constructed with at-least basic details.'); + } + + this._setProperties(details); +}; + +LoadBalancer.prototype._setProperties = function (details) { + this.id = details.id; + this.protocol = details.protocol; + this.portBalancer = details.port_balancer; + this.portServer = details.port_server; + this.source = details.source; +}; + +exports.Rule = Rule; diff --git a/test/fixtures/oneandone/addNodes.json b/test/fixtures/oneandone/addNodes.json new file mode 100644 index 000000000..2f861387b --- /dev/null +++ b/test/fixtures/oneandone/addNodes.json @@ -0,0 +1,12 @@ +[ + { + "id": "7C88E50FBC500A3D9D7F94E414255D6B", + "ip": "123.45.79.100", + "server_name": "My server 1" + }, + { + "id": "7C88E50FBC500A3D9D7F94E414255D6B", + "ip": "87.64.31.100", + "server_name": "My server 2" + } +] \ No newline at end of file diff --git a/test/fixtures/oneandone/createLoadBalancer.json b/test/fixtures/oneandone/createLoadBalancer.json new file mode 100644 index 000000000..d75bfc912 --- /dev/null +++ b/test/fixtures/oneandone/createLoadBalancer.json @@ -0,0 +1,38 @@ +{ + "id": "BD8318616581A9C3C53F94402503230F", + "name": "My load balancer", + "state": "CONFIGURING", + "creation_date": "2015-05-04T07:26:24+00:00", + "description": "My load balancer description", + "ip": null, + "health_check_test": "TCP", + "health_check_interval": 40, + "health_check_path": null, + "health_check_path_parser": null, + "persistence": true, + "persistence_time": 1200, + "method": "ROUND_ROBIN", + "datacenter": { + "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36", + "location": "USA", + "country_code": "US" + }, + "rules": [ + { + "id": "BCFAF421227674B2B324F779C1163ECB", + "protocol": "TCP", + "port_balancer": 80, + "port_server": 80, + "source": "0.0.0.0" + }, + { + "id": "7390C04142800E006FF1B0132FFD8F9A", + "protocol": "TCP", + "port_balancer": 9999, + "port_server": 8888, + "source": "0.0.0.0" + } + ], + "server_ips": [], + "cloudpanel_id": "LB99AA4_1" +} \ No newline at end of file diff --git a/test/oneandone/loadbalancer/test-loadbalancers.js b/test/oneandone/loadbalancer/test-loadbalancers.js new file mode 100644 index 000000000..ba95b15da --- /dev/null +++ b/test/oneandone/loadbalancer/test-loadbalancers.js @@ -0,0 +1,232 @@ +/** + * Created by Ali Bazlamit on 8/30/2017. + */ +var server, + _loadBalancer, + lbClint, + client; +var should = require('should'), + helpers = require('../../helpers'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK, + oneandone = require('liboneandone'), + LoadBalancer = require('../../../lib/pkgcloud/oneandone/loadbalancer/loadbalancer').LoadBalancer, + Node = require('../../../lib/pkgcloud/oneandone/loadbalancer/node').Node; + +var srvr_options = { + name: 'create-test-oao', + flavor: '81504C620D98BCEBAA5202D145203B4B', + image: '6631A1589A2CC87FEA9B99AB07399281', + location: '4EFAD5836CE43ACA502FD5B99BEE44EF', + token: process.env.OAO_TOKEN +}; + +describe('LoadBalancer tests', function () { + this.timeout(18000000); + var hockInstance, mockServer; + + before(function (done) { + client = helpers.createClient('oneandone', 'compute', srvr_options); + lbClint = helpers.createClient('oneandone', 'loadbalancer', srvr_options); + if (!mock) { + + client.createServer(srvr_options, function (err, srv1) { + should.not.exist(err); + should.exist(srv1); + server = srv1; + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + var options = { + name: 'lb test', + healthCheckInterval: 40, + Persistence: true, + persistenceTime: 1200, + method: oneandone.LoadBalancerMethod.ROUND_ROBIN, + rules: [ + { + protocol: 'TCP', + port_balancer: 80, + port_server: 80, + source: '0.0.0.0' + } + ], + location: '4EFAD5836CE43ACA502FD5B99BEE44EF' + }; + lbClint.createLoadBalancer(options, function (err, loadbalancer) { + should.not.exist(err); + should.exist(loadbalancer); + _loadBalancer = loadbalancer; + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + } else { + hockInstance = hock.createHock({ throwOnUnmatched: false }); + hockInstance.filteringRequestBody(helpers.authFilter); + mockServer = http.createServer(hockInstance.handler); + mockServer.listen(12345, done); + } + }); + + after(function (done) { + if (hockInstance) { + mockServer.close(function () { + done(); + }); + } + else { + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + lbClint.deleteLoadBalancer(_loadBalancer, function (err, response) { + should.not.exist(err); + should.exist(response); + server.setWait({ status: server.STATUS.running }, 15000, function (err) { + if (err) { + console.dir(err); + return; + } + client.destroyServer(server, function (err, response) { + should.not.exist(err); + should.exist(response); + done(); + }); + }); + }); + }); + } + }); + + it('the getLoadBalancers() method should return a list of loadbalancers', function (done) { + if (mock) { + hockInstance + .get('/load_balancers/{load_balancer_id}') + .reply(200, helpers.loadFixture('oneandone/loadbalancers.json')); + } + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + lbClint.getLoadBalancers(server, function (err, loadbalancers) { + should.not.exist(err); + should.exist(loadbalancers); + + loadbalancers.should.be.an.Array; + + loadbalancers.forEach(function (lb) { + lb.should.be.instanceOf(LoadBalancer); + }); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the updateLoadBalancer() method should update a loadbalancer ', function (done) { + if (mock) { + hockInstance + .get('/load_balancers/{load_balancer_id}') + .reply(202, helpers.loadFixture('oneandone/createLoadBalancer.json')); + } + var updateops = {}; + updateops.name = "update oao"; + updateops.healthCheckInterval = 100; + updateops.healthCheckPath = "path"; + updateops.healthCheckParser = 100; + updateops.Persistence = true; + updateops.persistenceTime = 1000; + updateops.method = oneandone.LoadBalancerMethod.ROUND_ROBIN; + updateops.loadbalancer = _loadBalancer; + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + lbClint.updateLoadBalancer(updateops, function (err, response) { + should.not.exist(err); + should.exist(response); + response.should.be.instanceOf(LoadBalancer); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the addNodes() method should add a server ip to the load balancer ', function (done) { + if (mock) { + hockInstance + .get('/load_balancers/{load_balancer_id}/server_ips') + .reply(202, helpers.loadFixture('oneandone/createLoadBalancer.json')); + } + var updateops = {}; + updateops.serverIps = [server.ips[0].id]; + updateops.loadbalancer = _loadBalancer; + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + lbClint.addNodes(updateops, function (err, response) { + should.not.exist(err); + should.exist(response); + response.should.be.instanceOf(LoadBalancer); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); + + it('the getNodes() method should update a loadbalancer ', function (done) { + if (mock) { + hockInstance + .get('/load_balancers/{load_balancer_id}/server_ips') + .reply(202, helpers.loadFixture('oneandone/addNodes.json')); + } + + lbClint.getNodes(_loadBalancer, function (err, nodes) { + should.not.exist(err); + should.exist(nodes); + + nodes.should.be.an.Array; + + nodes.forEach(function (nd) { + nd.should.be.instanceOf(Node); + }); + hockInstance && hockInstance.done(); + done(); + }); + }); + + it('the removeNode() method should update a loadbalancer ', function (done) { + if (mock) { + hockInstance + .get('/load_balancers/{load_balancer_id}') + .reply(202, helpers.loadFixture('oneandone/createLoadBalancer.json')); + } + var updateops = {}; + updateops.serverIp = server.ips[0].id; + updateops.loadbalancer = _loadBalancer; + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + lbClint.removeNode(updateops, function (err, response) { + should.not.exist(err); + should.exist(response); + response.should.be.instanceOf(LoadBalancer); + hockInstance && hockInstance.done(); + done(); + }); + }); + }); +}); + From fe88ed8359a5911ae55207648ee82c3aec07efb7 Mon Sep 17 00:00:00 2001 From: Ali Bazlamit Date: Thu, 9 Nov 2017 16:42:09 +0100 Subject: [PATCH 436/460] Add 1&1 support --- docs/README.md | 105 +++++----- docs/providers/oneandone.md | 0 docs/providers/oneandone/README.md | 38 ++++ docs/providers/oneandone/blockstorage.md | 59 ++++++ docs/providers/oneandone/compute.md | 102 +++++++++ .../oneandone/getting-started-compute.md | 93 +++++++++ docs/providers/oneandone/loadbalancer.md | 193 ++++++++++++++++++ examples/blockstorage/oneandone.js | 66 ++++++ examples/compute/oneandone.js | 74 +++++++ examples/loadbalancer/oneandone.js | 84 ++++++++ .../blockstorage/client/snapshots.js | 3 +- lib/pkgcloud/oneandone/client.js | 47 +++-- .../oneandone/compute/client/servers.js | 6 +- .../oneandone/loadbalancer/loadbalancer.js | 30 ++- lib/pkgcloud/oneandone/loadbalancer/rule.js | 6 +- 15 files changed, 828 insertions(+), 78 deletions(-) create mode 100644 docs/providers/oneandone.md create mode 100644 docs/providers/oneandone/README.md create mode 100644 docs/providers/oneandone/blockstorage.md create mode 100644 docs/providers/oneandone/compute.md create mode 100644 docs/providers/oneandone/getting-started-compute.md create mode 100644 docs/providers/oneandone/loadbalancer.md create mode 100644 examples/blockstorage/oneandone.js create mode 100644 examples/compute/oneandone.js create mode 100644 examples/loadbalancer/oneandone.js diff --git a/docs/README.md b/docs/README.md index 404d129e3..855f78407 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,51 +1,54 @@ -## pkgcloud documentation - -pkgcloud is a multi-provider cloud provisioning library for node.js that abstracts away differences among multiple cloud providers. - -### Unified Vocabulary - -Due to the differences between the vocabulary for each service provider, **[pkgcloud uses its own unified vocabulary](vocabulary.md).** - -**Note:** Unified vocabularies may not yet be defined for *beta* services. - -### Supported Providers - -Supporting every API for every cloud service provider in Node.js is a huge undertaking, but _that is the long-term goal of `pkgcloud`_. **Special attention has been made to ensure that each service type has enough providers for a critical mass of portability between providers** (i.e. Each service implemented has multiple providers). - -If a service does not have at least two providers, it is considered a *beta* interface; We reserve the right to improve the API as multiple providers will allow generalization to be better determined. - -* **Compute** [*Compute Client Commonality*](providers/compute-commonality.md) - * [Amazon](providers/amazon.md#using-compute) - * [Azure](providers/azure.md#using-compute) - * [DigitalOcean](providers/digitalocean.md#using-compute) - * [HP](providers/hp/compute.md) - * [Joyent](providers/joyent.md#using-compute) - * [Openstack](providers/openstack/compute.md) - * [Rackspace](providers/rackspace/compute.md) -* **Storage** - * [Amazon](providers/amazon.md#using-storage) - * [Azure](providers/azure.md#using-storage) - * [HP](providers/hp/storage.md) - * [Openstack](providers/openstack/storage.md) - * [Rackspace](providers/rackspace/storage.md) -* **Databases** - * [HP](providers/hp/database.md) - * [IrisCouch](providers/iriscouch.md) - * [MongoLab](providers/mongolab.md) - * [Openstack](providers/openstack/database.md) - * [Rackspace](providers/rackspace/database.md) - * [MongoHQ](providers/mongohq.md) - * [RedisToGo](providers/redistogo.md) -* **DNS** *(beta)* - * [Rackspace](providers/rackspace/dns.md) -* **Block Storage** *(beta)* - * [Rackspace](providers/rackspace/blockstorage.md) - * [Openstack](providers/openstack/blockstorage.md) -* **Orchestration** *(beta)* - * [Rackspace](providers/rackspace/orchestration.md) - * [Openstack](providers/openstack/orchestration.md) -* **Load Balancers** *(beta)* - * [Rackspace](providers/rackspace/loadbalancer.md) -* **Networking** *(beta)* - * [Openstack](providers/openstack/network.md) - * [HP](providers/openstack/hp.md) +## pkgcloud documentation + +pkgcloud is a multi-provider cloud provisioning library for node.js that abstracts away differences among multiple cloud providers. + +### Unified Vocabulary + +Due to the differences between the vocabulary for each service provider, **[pkgcloud uses its own unified vocabulary](vocabulary.md).** + +**Note:** Unified vocabularies may not yet be defined for *beta* services. + +### Supported Providers + +Supporting every API for every cloud service provider in Node.js is a huge undertaking, but _that is the long-term goal of `pkgcloud`_. **Special attention has been made to ensure that each service type has enough providers for a critical mass of portability between providers** (i.e. Each service implemented has multiple providers). + +If a service does not have at least two providers, it is considered a *beta* interface; We reserve the right to improve the API as multiple providers will allow generalization to be better determined. + +* **Compute** [*Compute Client Commonality*](providers/compute-commonality.md) + * [Amazon](providers/amazon.md#using-compute) + * [Azure](providers/azure.md#using-compute) + * [DigitalOcean](providers/digitalocean.md#using-compute) + * [HP](providers/hp/compute.md) + * [Joyent](providers/joyent.md#using-compute) + * [Openstack](providers/openstack/compute.md) + * [Rackspace](providers/rackspace/compute.md) + * [1&1 Oneandone](providers/oneandone/compute.md) +* **Storage** + * [Amazon](providers/amazon.md#using-storage) + * [Azure](providers/azure.md#using-storage) + * [HP](providers/hp/storage.md) + * [Openstack](providers/openstack/storage.md) + * [Rackspace](providers/rackspace/storage.md) +* **Databases** + * [HP](providers/hp/database.md) + * [IrisCouch](providers/iriscouch.md) + * [MongoLab](providers/mongolab.md) + * [Openstack](providers/openstack/database.md) + * [Rackspace](providers/rackspace/database.md) + * [MongoHQ](providers/mongohq.md) + * [RedisToGo](providers/redistogo.md) +* **DNS** *(beta)* + * [Rackspace](providers/rackspace/dns.md) +* **Block Storage** *(beta)* + * [Rackspace](providers/rackspace/blockstorage.md) + * [Openstack](providers/openstack/blockstorage.md) + * [1&1 Oneandone](providers/oneandone/blockstorage.md) +* **Orchestration** *(beta)* + * [Rackspace](providers/rackspace/orchestration.md) + * [Openstack](providers/openstack/orchestration.md) +* **Load Balancers** *(beta)* + * [Rackspace](providers/rackspace/loadbalancer.md) + * [1&1 Oneandone](providers/oneandone/loadbalancer.md) +* **Networking** *(beta)* + * [Openstack](providers/openstack/network.md) + * [HP](providers/openstack/hp.md) diff --git a/docs/providers/oneandone.md b/docs/providers/oneandone.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/providers/oneandone/README.md b/docs/providers/oneandone/README.md new file mode 100644 index 000000000..9aab30b30 --- /dev/null +++ b/docs/providers/oneandone/README.md @@ -0,0 +1,38 @@ +## Using the 1&1 provider in pkgcloud + +The 1&1 provider in pkgcloud supports the following services: + +* [**Compute**](compute.md) (Cloud Servers) +* [**Block Storage**](blockstorage.md) (Cloud Block Storage) *(beta)* +* [**Load Balancers**](loadbalancer.md) (Cloud Load Balancers) *(beta)* + +### Getting Started with Compute + +We've provided a [simple compute example](getting-started-compute.md) where it creates a couple of compute instances. + +### Authentication + +For all of the Rackspace services, you create a client with the same options: + +you can store the token in your Environment variables just like below. + +```Javascript +var client = require('pkgcloud').compute.createClient({ + provider: 'oneandone', + token: process.env.OAO_TOKEN +}); +``` + + +### Datacenters + +All of the 1&1 Oneandone `createClient` calls have a few options that can be provided: + +#### location + +`location` specifies which region of a service to use. Different services have different regions enabled. The current list of regions is: + +- `ES` (Spain) +- `US` (United States of America) +- `DE` (Germany) +- `GB` (United Kingdom of Great Britain and Northern Ireland) \ No newline at end of file diff --git a/docs/providers/oneandone/blockstorage.md b/docs/providers/oneandone/blockstorage.md new file mode 100644 index 000000000..cb52fc34e --- /dev/null +++ b/docs/providers/oneandone/blockstorage.md @@ -0,0 +1,59 @@ +## Using the 1&1 Block Storage provider + +#### BETA - This API may change as additional providers for block storage are added to pkgcloud + +Creating a block-storage client is straight-forward: + +``` js + var oneandone = pkgcloud.blockstorage.createClient({ + provider: 'oneandone', // required + token: 'apikey', // required + }); +``` + +[More options for creating clients](README.md) + +* Snapshot + * [Model](#snapshot-model) + * [APIs](#snapshot-apis) + + +### Snapshot Model + +A Snapshot for BlockStorage has the following properties: + +```Javascript +{ + id: '12345678-1111-2222-3333-123456789012', // id of the snapshot +} +``` + +### Snapshot APIs + +#### client.getSnapshots(options, callback) +Returns a list of the server's snapshots. + +Callback returns `f(err, snapshots)` where `snapshots` is an `Array`. `options` is an optional `boolean` which will return the full snapshot details if true. + +#### client.createSnapshot(details, callback) +Creates a snapshot with the details specified + +Options are as follows: + +```js +{ + server: '81504C620D98BCEBAA5202D145203B4B',//Server or Server id to create the snapshot from +} + +``` +Returns the new snapshot in the callback `f(err, snapshot)` + +#### client.deleteSnapshot(snapshot, callback) +Removes a snapshot + +Takes snapshot or snapshotId as an argument and returns an error if unsuccessful `f(err)` + +#### client.updateSnapshot(snapshot, callback) +Restores a snapshot into the server. + +Returns callback with a confirmation \ No newline at end of file diff --git a/docs/providers/oneandone/compute.md b/docs/providers/oneandone/compute.md new file mode 100644 index 000000000..9b1410fe6 --- /dev/null +++ b/docs/providers/oneandone/compute.md @@ -0,0 +1,102 @@ +## Using the 1&1 Compute provider + +As of the `v0.8` release of `pkgcloud`, the Compute provider uses Next Generation Cloud Servers, meaning you'll need to use a version <=0.7.x to use First Generation Cloud Servers. + +Creating a client is straight-forward: + +``` js + var oneandone = pkgcloud.compute.createClient({ + provider: 'oneandone', // required + token: 'your-api-key', // required + }); +``` + +[More options for creating clients](README.md) + +### API Methods + +**Servers** + +#### client.getServers(callback) +Lists all servers available to your account. + +Callback returns `f(err, servers)` where `servers` is an `Array` + +#### client.createServer(options, callback) +Creates a server with the options specified + +Options are as follows: + +```js +{ + name: 'server name', + flavor: 'falvor-id', + image: 'image or imageId', + location: 'datacenter id' +} + +``` +Returns the server in the callback `f(err, server)` + +#### client.destroyServer(server, callback) +Destroys the specified server + +Takes server or serverId as an argument and returns the id of the destroyed server in the callback `f(err, serverId)` + +#### client.getServer(server, callback) +Gets specified server + +Takes server or serverId as an argument and returns the server in the callback +`f(err, server)` + +#### client.rebootServer(server, options, callback) +Reboots the specifed server with options + +Returns callback with a confirmation + +#### client.getVersion(callback) + +Get the current version of the api returned in a callback `f(err, version)` + +**flavors** + +#### client.getFlavors(callback) + +Returns available flavours for fixed servers in the callback `f(err, +flavors)` + +#### client.getFlavor(flavor, callback) +Returns information about one flavour in the callback `f(err, flavor)` + +**images** + +#### client.getImages(callback) +Lists all images available to your account + +`f(err, images)` + +#### client.getImage(image, callback) +Information about specific appliance/image + +`f(err, image)` + +#### client.createImage(options, callback) +Adds a new image from a server + +Options include: + +```js +{ + name: 'image name', + server: 'server or server id' +} +``` + +Returns the newly created image + +`f(err, image)` + +#### client.destroyImage(image, callback) +Destroys the specified image and returns a confirmation + +`f(err, {ok: imageId})` \ No newline at end of file diff --git a/docs/providers/oneandone/getting-started-compute.md b/docs/providers/oneandone/getting-started-compute.md new file mode 100644 index 000000000..bb8afd079 --- /dev/null +++ b/docs/providers/oneandone/getting-started-compute.md @@ -0,0 +1,93 @@ +# Getting started with pkgcloud & Oneandone + +The onandone node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package. + +To install `pkgcloud` from the command line: + +``` +npm install pkgcloud +``` + +Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). + +## Using pkgcloud + +In this example, we're going to create a 1&1 compute client, create two servers, and then output their details to the command line. + +*Note: We're going to use [lodash.js](https://lodash.com) for some convenience functions.* + +```Javascript +var pkgcloud = require('pkgcloud'), + _ = require('lodash'); + +// create our client with your 1&1 token +var client = pkgcloud.providers.oneandone.compute.createClient({ + token: 'api-key' +}); + +// first we're going to get our flavors +client.getFlavors(function (err, flavors) { + if (err) { + console.dir(err); + return; + } + + // then get our base images + client.getImages(function (err, images) { + if (err) { + console.dir(err); + return; + } + + // Pick a 512MB instance flavor + var flavor = _.findWhere(flavors, { name: '512MB Standard Instance' }); + + // Pick an image based on Ubuntu 14.04 + var image = _.findWhere(images, { name: 'Ubuntu 14.04' }); + + // Create our first server + client.createServer({ + name: 'server1', + image: image, + flavor: flavor.id, + location:location.id + }, handleServerResponse); + + // Create our second server + client.createServer({ + name: 'server2', + image: image, + flavor: flavor.id, + location:location.id, + }, handleServerResponse); + }); +}); + +// This function will handle our server creation, +// as well as waiting for the server to come online after we've +// created it. +function handleServerResponse(err, server) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); + + // Wait for status: ACTIVE on our server, and then callback + server.setWait({ status: 'ACTIVE' }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER INFO'); + console.log(server.name); + console.log(server.status); + console.log(server.id); + + console.log('Make sure you DELETE server: ' + server.id + + ' in order to not accrue billing charges'); + }); +} +``` diff --git a/docs/providers/oneandone/loadbalancer.md b/docs/providers/oneandone/loadbalancer.md new file mode 100644 index 000000000..bddfa8c70 --- /dev/null +++ b/docs/providers/oneandone/loadbalancer.md @@ -0,0 +1,193 @@ +## Using the 1&1 Load Balancer provider + +#### BETA - This API may change as additional providers for load balancers are added to pkgcloud + +### Table of Contents + +* LoadBalancer + * [Model](#loadbalancer-model) + * [Managing Load Balancers](#loadbalancer-apis) + * [Nodes](#nodes) +* Node + * [Model](#node-model) + +### Getting Started + +Creating a loadbalancer client is straight-forward: + +``` js + var oneandone = pkgcloud.loadbalancer.createClient({ + provider: 'oneandone', // required + token: 'your-api-key' // required + }); +``` + +*[More options for creating clients](README.md)* + +Once you have a client, creating a load balancer is straight-forward. + +```Javascript +oneandone.createLoadBalancer({ + name: 'lb test', + healthCheckInterval: 40, + Persistence: true, + persistenceTime: 1200, + method: oneandone.LoadBalancerMethod.ROUND_ROBIN, + rules: [ + { + protocol: 'TCP', + port_balancer: 80, + port_server: 80, + source: '0.0.0.0' + } + ], + location: '4EFAD5836CE43ACA502FD5B99BEE44EF' + }, function(err, loadBalancer) { + // use your new loadBalancer here +}); +``` + +### LoadBalancer Model + +A LoadBalancer has following properties: + +```Javascript +{ + "id": "13C3F75BA55AF28B8B2B4E508786F48B", + "name": "My Load Balancer 1", + "ip": "70.35.192.35", + "healthCheckTest": "TCP", + "healthCheckInterval": 15, + "persistence": true, + "persistenceTime": 1200, + "datacenter": { + "id": "908DC2072407C94C8054610AD5A53B8C", + "country_code": "US", + "location": "United States of America" + }, + "rules": [ + { + "id": "E7CC65B301050BA1722F19EE0B08F1DB", + "protocol": "TCP", + "port_balancer": 90, + "port_server": 90, + "source": "0.0.0.0" + } + ], + "nodes": [{ + "id": "8808D9603ED0001D97F70854EDE3C195", + "ip": "212.227.202.122", + "server_name": "create-test-oao" +}] +} +``` + +**Proxy Methods** + +An instance of a `LoadBalancer` has a number of convenience proxy methods. For example: + +```Javascript +client.getNodes(loadBalancer, function(err, nodes) { ... }; + +// is equivalent to + +loadBalancer.getNodes(function(err, nodes) { ... }; +``` + +View the [complete list of LoadBalancer proxy methods](#loadbalancer-proxy-methods). + +### Node Model + +A Node for LoadBalancer has the following properties: + +```Javascript +{ + "id": "8808D9603ED0001D97F70854EDE3C195", + "ip": "212.227.202.122", + "server_name": "create-test-oao" +} +``` + +### LoadBalancer APIs + +#### client.getLoadBalancers(options, callback) +Lists all loadbalancers available to your account. + +Callback returns `f(err, loadbalancers)` where `loadbalancers` is an `Array`. `options` is an optional and unused argument at this time. + +#### client.getLoadBalancer(loadBalancer, callback) +Gets specified LoadBalancer. + +Takes `loadBalancer` or `loadBalancerId` as an argument and returns the `loadBalancer` in the callback +`f(err, loadBalancer)` + +#### client.createLoadBalancer(details, callback) + +The following JS object provides a brief overview of required and optional parameters for the `createLoadBalancer` `details` argument: + +```js +{ + name: 'lb test', + healthCheckInterval: 40, + Persistence: true, + persistenceTime: 1200, + method: oneandone.LoadBalancerMethod.ROUND_ROBIN, + rules: [ + { + protocol: 'TCP', + port_balancer: 80, + port_server: 80, + source: '0.0.0.0' + } + ], + location: '4EFAD5836CE43ACA502FD5B99BEE44EF' +} +``` + +Returns the new LoadBalancer in the callback `f(err, loadBalancer)` + +#### client.updateLoadBalancer(loadBalancer, callback) +Updates the `name`, `healthCheckInterval`, `healthCheckPath`, `Persistence`, `persistenceTime` and `method` properties of the provided `loadBalancer`. + +Returns callback with `f(err)`. + +#### client.deleteLoadBalancer(loadBalancer, callback) +Deletes the specified `loadBalancer`. + +Takes `loadBalancer` or `loadBalancerId` as an argument and returns an error if unsuccessful `f(err)` + +### Nodes + +A `Node` represnets serverIPs added to a load balancer. When you setup load balancers serverIPs are loaded as nodes. + +#### client.getNodes(loadBalancer, callback) + +Returns a list of the servers/IPs attached to a load balancer. + +Callback is `f(err, nodes)`. + +#### client.addNodes(loadBalancer, nodes, callback) + +Assigns servers/IPs to a load balancer. + +##### Node Details +```Javascript +{ + serverIps=[ip1,ip2], + loadbalancer = _loadBalancer +} +``` + +Callback is `f(err, nodes)`. + +#### client.removeNode(loadBalancer, node, callback) + +Remove a `node` from the provided `loadBalancer`. Takes `loadBalancer` or `loadBalancerId` as an argument. `node` should be either the `node` or `nodeId`. + +Callback is `f(err)`. + +### LoadBalancer Proxy Methods + +##### loadBalancer.getNodes(callback) +##### loadBalancer.addNodes(nodes, callback) +##### loadBalancer.removeNode(node, callback) \ No newline at end of file diff --git a/examples/blockstorage/oneandone.js b/examples/blockstorage/oneandone.js new file mode 100644 index 000000000..eb6bd71f3 --- /dev/null +++ b/examples/blockstorage/oneandone.js @@ -0,0 +1,66 @@ +/** + * Created by Ali Bazlamit on 9/6/2017. + */ +var pkgcloud = require('pkgcloud'), + _ = require('lodash'); + +(function() { + + var config = { + token: process.env.OAO_TOKEN, + }; + + // create our client with your 1&1 credentials + var computeClient = pkgcloud.providers.oneandone.compute.createClient(config); + var blockStorageClient = pkgcloud.providers.oneandone.blockstorage.createClient(config); + + // first we're going to get our flavors + computeClient.getFlavors(function (err, flavors) { + if (err) { + console.dir(err); + return; + } + + // then get our base images + computeClient.getImages(function (err, images) { + if (err) { + console.dir(err); + return; + } + + // Pick a medium instance flavor + var flavor = _.findWhere(flavors, { name: 'M' }); + + // Pick an image based on Ubuntu 14.04 + var image = _.findWhere(images, { name: 'centos6-32std' }); + + // Create our first server + computeClient.createServer({ + name: 'server1', + image: image, + flavor: flavor.id + }, function(err, server) { + if (err) { + console.error(err); + return; + } + + // Wait for our server to start up + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + + // create a block storage snapshot + blockStorageClient.createSnapshot(server, function(err, snapshot) { + if (err) { + console.error(err); + return; + } + }); + }); + }); + }); + }); +})(); diff --git a/examples/compute/oneandone.js b/examples/compute/oneandone.js new file mode 100644 index 000000000..1df0ae89d --- /dev/null +++ b/examples/compute/oneandone.js @@ -0,0 +1,74 @@ +/** + * Created by Ali Bazlamit on 9/6/2017. + */ +var pkgcloud = require('pkgcloud'), + _ = require('lodash'); + +// create our client with your 1&1 token +var client = pkgcloud.providers.oneandone.compute.createClient({ + token: process.env.OAO_TOKEN, +}); + +// This function will handle our server creation, +// as well as waiting for the server to come online after we've +// created it. +function handleServerResponse(err, server) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER CREATED: ' + server.name + ', waiting for active status'); + + // Wait for status: ACTIVE on our server, and then callback + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + + console.log('SERVER INFO'); + console.log(server.name); + console.log(server.status); + console.log(server.id); + + console.log('Make sure you DELETE server: ' + server.id + + ' in order to not accrue billing charges'); + }); +} + +// first we're going to get our flavors +client.getFlavors(function (err, flavors) { + if (err) { + console.dir(err); + return; + } + + // then get our base images + client.getImages(function (err, images) { + if (err) { + console.dir(err); + return; + } + + // Pick a medium instance flavor + var flavor = _.findWhere(flavors, { name: 'M' }); + + // Pick an image based on Ubuntu 14.04 + var image = _.findWhere(images, { name: 'centos6-32std' }); + + // Create our first server + client.createServer({ + name: 'server1', + image: image, + flavor: flavor.id + }, handleServerResponse); + + // Create our second server + client.createServer({ + name: 'server2', + image: image, + flavor: flavor.id + }, handleServerResponse); + }); +}); diff --git a/examples/loadbalancer/oneandone.js b/examples/loadbalancer/oneandone.js new file mode 100644 index 000000000..0e62fb4de --- /dev/null +++ b/examples/loadbalancer/oneandone.js @@ -0,0 +1,84 @@ +/** + * Created by Ali Bazlamit on 9/6/2017. + */ +var pkgcloud = require('pkgcloud'), + _ = require('lodash'); + +(function () { + + var config = { + token: process.env.OAO_TOKEN, + }; + + // create our client with your 1&1 credentials + var computeClient = pkgcloud.providers.oneandone.compute.createClient(config); + var loadBalancerClient = pkgcloud.providers.oneandone.loadbalancer.createClient(config); + + // first we're going to get our flavors + computeClient.getFlavors(function (err, flavors) { + if (err) { + console.dir(err); + return; + } + + // then get our base images + computeClient.getImages(function (err, images) { + if (err) { + console.dir(err); + return; + } + + // Pick a 512MB instance flavor + var flavor = _.findWhere(flavors, { name: 'M' }); + + // Pick an image based on Ubuntu 14.04 + var image = _.findWhere(images, { name: 'centos6-32std' }); + + // Create our first server + computeClient.createServer({ + name: 'server11', + image: image, + flavor: flavor.id, + location: '4EFAD5836CE43ACA502FD5B99BEE44EF' + }, function (err, server) { + if (err) { + console.error(err); + return; + } + + // Wait for our server to start up + server.setWait({ status: server.STATUS.running }, 5000, function (err) { + if (err) { + console.dir(err); + return; + } + + // create a block storage snapshot + var options = { + name: 'lb test', + healthCheckInterval: 40, + Persistence: true, + persistenceTime: 1200, + method: "ROUND_ROBIN", + rules: [ + { + protocol: 'TCP', + port_balancer: 80, + port_server: 80, + source: '0.0.0.0' + } + ], + location: '4EFAD5836CE43ACA502FD5B99BEE44EF' + }; + + loadBalancerClient.createLoadBalancer(options, function (err, loadbalancer) { + if (err) { + console.error(err); + return; + } + }); + }); + }); + }); + }); +})(); diff --git a/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js b/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js index f170fc5a3..a365aeeac 100644 --- a/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js +++ b/lib/pkgcloud/oneandone/blockstorage/client/snapshots.js @@ -43,8 +43,7 @@ exports.getSnapshots = function (server, callback) { * * @description Creates a new snapshot of the server. * - * @param {object} options options for the provided create call - * @param {string} options.server Server or Server id to create the snapshot from + * @param {string} server Server or Server id to create the snapshot from * @param {function} callback * @returns {*} */ diff --git a/lib/pkgcloud/oneandone/client.js b/lib/pkgcloud/oneandone/client.js index 793f0e6db..2de22b9a6 100644 --- a/lib/pkgcloud/oneandone/client.js +++ b/lib/pkgcloud/oneandone/client.js @@ -5,38 +5,41 @@ */ var util = require('util'), - OAO = require('liboneandone'), - url = 'cloudpanel-api.1and1.com/v1', - base = require('../core/base'); + OAO = require('liboneandone'), + url = 'cloudpanel-api.1and1.com/v1', + base = require('../core/base'); var Client = exports.Client = function (options) { - base.Client.call(this, options); - - options = options || {}; - this.provider = 'oneandone'; - this.protocol = options.protocol || 'https://'; - this.serversUrl = options.serversUrl ? options.serversUrl : url; - OAO.oneandoneauth(options.token); - OAO.setendpoint(this.protocol + this.serversUrl); + if (!options || !options.token) { + throw new TypeError('token is required'); + } + base.Client.call(this, options); + + options = options || {}; + this.provider = 'oneandone'; + this.protocol = options.protocol || 'https://'; + this.serversUrl = options.serversUrl ? options.serversUrl : url; + OAO.oneandoneauth(options.token); + OAO.setendpoint(this.protocol + this.serversUrl); }; util.inherits(Client, base.Client); Client.prototype.failCodes = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Item not found', - 500: 'Fault', - 503: 'Service Unavailable' + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Item not found', + 500: 'Fault', + 503: 'Service Unavailable' }; Client.prototype.successCodes = { - 200: 'OK', - 201: 'Created', - 202: 'Accepted', - 203: 'Non-authoritative information', - 204: 'No content' + 200: 'OK', + 201: 'Created', + 202: 'Accepted', + 203: 'Non-authoritative information', + 204: 'No content' }; \ No newline at end of file diff --git a/lib/pkgcloud/oneandone/compute/client/servers.js b/lib/pkgcloud/oneandone/compute/client/servers.js index 9e4f75604..47d00e020 100644 --- a/lib/pkgcloud/oneandone/compute/client/servers.js +++ b/lib/pkgcloud/oneandone/compute/client/servers.js @@ -62,6 +62,7 @@ exports.createServer = function createServer(options, callback) { } var self = this, ImageId, + FlavorId, hardware = {}; options = options || {}; // no args if (!options.image) { @@ -77,8 +78,11 @@ exports.createServer = function createServer(options, callback) { : options.image; if (options.flavor) { + FlavorId = options.flavor instanceof base.Flavor + ? options.flavor.id + : options.flavor; hardware = { - 'fixed_instance_size_id': options.flavor + 'fixed_instance_size_id': FlavorId }; } else { return errs.handle( diff --git a/lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js b/lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js index 5425ca69b..0fc4284b3 100644 --- a/lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js +++ b/lib/pkgcloud/oneandone/loadbalancer/loadbalancer.js @@ -23,6 +23,34 @@ LoadBalancer.prototype._setProperties = function (details) { this.persistenceTime = details.persistence_time; this.datacenter = details.datacenter; this.rules = details.rules; - this.serverIps = details.server_ips; + this.nodes = details.server_ips; }; + +/// Nodes + +LoadBalancer.prototype.refresh = function(callback) { + var self = this; + return self.client.getLoadBalancer(this, function (err, server) { + if (err) { + callback(err); + return; + } + + self._setProperties(server); + callback(err, self); + }); +}; + +//NODES +LoadBalancer.prototype.getNodes = function(callback) { + this.client.getNodes(this, callback); +}; + +LoadBalancer.prototype.addNodes = function(nodes, callback) { + this.client.addNodes(this, nodes, callback); +}; + +LoadBalancer.prototype.removeNode = function (node, callback) { + this.client.removeNode(this, node, callback); +}; diff --git a/lib/pkgcloud/oneandone/loadbalancer/rule.js b/lib/pkgcloud/oneandone/loadbalancer/rule.js index c3aa92c75..d314127b4 100644 --- a/lib/pkgcloud/oneandone/loadbalancer/rule.js +++ b/lib/pkgcloud/oneandone/loadbalancer/rule.js @@ -9,7 +9,7 @@ var Rule = function (details) { this._setProperties(details); }; -LoadBalancer.prototype._setProperties = function (details) { +Rule.prototype._setProperties = function (details) { this.id = details.id; this.protocol = details.protocol; this.portBalancer = details.port_balancer; @@ -18,3 +18,7 @@ LoadBalancer.prototype._setProperties = function (details) { }; exports.Rule = Rule; + +Rule.prototype.toJSON = function () { + return _.pick(this, ['id', 'protocol', 'port_balancer', 'port_server','source']); +}; \ No newline at end of file From 49cc8c7a0f97081f4bf79ecb3ab929926e9ff008 Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Sun, 3 Dec 2017 08:57:26 -0500 Subject: [PATCH 437/460] Add oneandone details field to compute --- lib/pkgcloud/core/compute/server.js | 6 +----- lib/pkgcloud/oneandone/compute/server.js | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/pkgcloud/core/compute/server.js b/lib/pkgcloud/core/compute/server.js index 973176b0e..4bef9e01c 100644 --- a/lib/pkgcloud/core/compute/server.js +++ b/lib/pkgcloud/core/compute/server.js @@ -19,11 +19,7 @@ Server.prototype.refresh = function (callback) { var self = this; return self.client.getServer(this, function (err, server) { if (!err) { - if(server.original) { - self._setProperties(server.original); - }else{ - self._setProperties(server); - } + self._setProperties(server.original); } return callback.apply(this, arguments); diff --git a/lib/pkgcloud/oneandone/compute/server.js b/lib/pkgcloud/oneandone/compute/server.js index a05ba224f..e1337f35e 100644 --- a/lib/pkgcloud/oneandone/compute/server.js +++ b/lib/pkgcloud/oneandone/compute/server.js @@ -37,6 +37,7 @@ Server.prototype._setProperties = function (details) { default: this.status = 'PROVISIONING'; } + this.original = this.oneandone = details; }; Server.prototype.toJSON = function () { From 765722f8e54d62bd38f0c0f42b2a57ddd2792354 Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Sun, 3 Dec 2017 09:32:36 -0500 Subject: [PATCH 438/460] Fix lint issues --- examples/blockstorage/oneandone.js | 1 + examples/loadbalancer/oneandone.js | 3 +- .../loadbalancer/client/loadbalancers.js | 48 +++++++++---------- .../oneandone/loadbalancer/client/nodes.js | 11 +---- lib/pkgcloud/oneandone/loadbalancer/rule.js | 1 + .../loadbalancer/test-loadbalancers.js | 4 +- 6 files changed, 31 insertions(+), 37 deletions(-) diff --git a/examples/blockstorage/oneandone.js b/examples/blockstorage/oneandone.js index eb6bd71f3..6952da3bd 100644 --- a/examples/blockstorage/oneandone.js +++ b/examples/blockstorage/oneandone.js @@ -58,6 +58,7 @@ var pkgcloud = require('pkgcloud'), console.error(err); return; } + console.log(snapshot); }); }); }); diff --git a/examples/loadbalancer/oneandone.js b/examples/loadbalancer/oneandone.js index 0e62fb4de..58503652a 100644 --- a/examples/loadbalancer/oneandone.js +++ b/examples/loadbalancer/oneandone.js @@ -59,7 +59,7 @@ var pkgcloud = require('pkgcloud'), healthCheckInterval: 40, Persistence: true, persistenceTime: 1200, - method: "ROUND_ROBIN", + method: 'ROUND_ROBIN', rules: [ { protocol: 'TCP', @@ -76,6 +76,7 @@ var pkgcloud = require('pkgcloud'), console.error(err); return; } + console.log(loadbalancer); }); }); }); diff --git a/lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js b/lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js index b1abb89a8..a129485d3 100644 --- a/lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js +++ b/lib/pkgcloud/oneandone/loadbalancer/client/loadbalancers.js @@ -1,9 +1,7 @@ /** * Created by Ali Bazlamit on 8/31/2017. */ -var pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), - oneandone = require('liboneandone'), +var oneandone = require('liboneandone'), LoadBalancer = require('../loadbalancer').LoadBalancer; // @@ -41,7 +39,7 @@ exports.getLoadBalancers = function getLoadBalancers(options, callback) { // #### @healthCheckParser {String} **Optional** flavor to use for this image // #### @persistence {boolean} Persistence // #### @persistenceTime {int} Persistence time in seconds. Required if persistence is enabled. -// #### @method {String} "Balancing procedure","enum": ["ROUND_ROBIN", "LEAST_CONNECTIONS"]. +// #### @method {String} 'Balancing procedure','enum': ['ROUND_ROBIN', 'LEAST_CONNECTIONS']. // #### @datacenterId {String} **Optional** ID of the datacenter where the load balancer will be created // #### @rules {Array|Rule} **Optional** flavor to use for this image // #### @callback {Function} f(err, loadbalancer). @@ -56,17 +54,17 @@ exports.createLoadBalancer = function createLoadBalancer(options, callback) { var self = this; var balancerData = { - "name": options.name, - "description": options.name, - "health_check_test": oneandone.HealthCheckTestTypes.TCP, - "health_check_interval": options.healthCheckInterval, - "health_check_path": options.healthCheckPath, - "health_check_parser": options.healthCheckParser, - "persistence": options.Persistence, - "persistence_time": options.persistenceTime, - "method": options.method, - "datacenter_id": options.location, - "rules": options.rules + 'name': options.name, + 'description': options.name, + 'health_check_test': oneandone.HealthCheckTestTypes.TCP, + 'health_check_interval': options.healthCheckInterval, + 'health_check_path': options.healthCheckPath, + 'health_check_parser': options.healthCheckParser, + 'persistence': options.Persistence, + 'persistence_time': options.persistenceTime, + 'method': options.method, + 'datacenter_id': options.location, + 'rules': options.rules }; oneandone.createLoadBalancer(balancerData, function (error, response, body) { @@ -136,7 +134,7 @@ exports.getLoadBalancer = function getLoadBalancer(loadbalancer, callback) { // #### @healthCheckParser {String} **Optional** flavor to use for this image // #### @persistence {boolean} Persistence // #### @persistenceTime {int} Persistence time in seconds. Required if persistence is enabled. - // #### @method {String} "Balancing procedure","enum": ["ROUND_ROBIN", "LEAST_CONNECTIONS"]. + // #### @method {String} 'Balancing procedure','enum': ['ROUND_ROBIN', 'LEAST_CONNECTIONS']. * @param {function} callback * @returns {*} */ @@ -145,15 +143,15 @@ exports.updateLoadBalancer = function updateLoadBalancer(options, callback) { lbId = options.loadbalancer instanceof LoadBalancer ? options.loadbalancer.id : options.loadbalancer; var updateData = { - "name": options.name, - "health_check_test": oneandone.HealthCheckTestTypes.TCP, - "health_check_interval": options.healthCheckInterval, - "health_check_path": options.healthCheckPath, - "health_check_parser": options.healthCheckParser, - "persistence": options.Persistence, - "persistence_time": options.persistenceTime, - "method": options.method, - "rules": options.rules + 'name': options.name, + 'health_check_test': oneandone.HealthCheckTestTypes.TCP, + 'health_check_interval': options.healthCheckInterval, + 'health_check_path': options.healthCheckPath, + 'health_check_parser': options.healthCheckParser, + 'persistence': options.Persistence, + 'persistence_time': options.persistenceTime, + 'method': options.method, + 'rules': options.rules }; oneandone.updateLoadBalancer(lbId, updateData, function (error, response, body) { if (error) { diff --git a/lib/pkgcloud/oneandone/loadbalancer/client/nodes.js b/lib/pkgcloud/oneandone/loadbalancer/client/nodes.js index da186dec2..41b27d1ca 100644 --- a/lib/pkgcloud/oneandone/loadbalancer/client/nodes.js +++ b/lib/pkgcloud/oneandone/loadbalancer/client/nodes.js @@ -1,9 +1,7 @@ /** * Created by Ali Bazlamit on 8/31/2017. */ -var pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), - oneandone = require('liboneandone'), +var oneandone = require('liboneandone'), LoadBalancer = require('../loadbalancer').LoadBalancer, Node = require('../node').Node; @@ -13,11 +11,6 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), // Returns a list of the servers/IPs attached to a load balancer. // exports.getNodes = function getNodes(loadbalancer, callback) { - if (typeof options === 'function') { - callback = options; - options = {}; - } - var self = this, lbId = loadbalancer instanceof LoadBalancer ? loadbalancer.id : loadbalancer; @@ -51,7 +44,7 @@ exports.addNodes = function addNodes(options, callback) { var lbId = options.loadbalancer instanceof LoadBalancer ? options.loadbalancer.id : options.loadbalancer; var assignData = { - "server_ips": options.serverIps + 'server_ips': options.serverIps }; oneandone.assignServerIpToLoadBalancer(lbId, assignData, function (error, response, body) { diff --git a/lib/pkgcloud/oneandone/loadbalancer/rule.js b/lib/pkgcloud/oneandone/loadbalancer/rule.js index d314127b4..84459025e 100644 --- a/lib/pkgcloud/oneandone/loadbalancer/rule.js +++ b/lib/pkgcloud/oneandone/loadbalancer/rule.js @@ -1,6 +1,7 @@ /** * Created by Ali Bazlamit on 8/31/2017. */ +var _ = require('lodash'); var Rule = function (details) { if (!details) { throw new Error('Rule must be constructed with at-least basic details.'); diff --git a/test/oneandone/loadbalancer/test-loadbalancers.js b/test/oneandone/loadbalancer/test-loadbalancers.js index ba95b15da..8264ebe18 100644 --- a/test/oneandone/loadbalancer/test-loadbalancers.js +++ b/test/oneandone/loadbalancer/test-loadbalancers.js @@ -137,9 +137,9 @@ describe('LoadBalancer tests', function () { .reply(202, helpers.loadFixture('oneandone/createLoadBalancer.json')); } var updateops = {}; - updateops.name = "update oao"; + updateops.name = 'update oao'; updateops.healthCheckInterval = 100; - updateops.healthCheckPath = "path"; + updateops.healthCheckPath = 'path'; updateops.healthCheckParser = 100; updateops.Persistence = true; updateops.persistenceTime = 1000; From db6ebdbdc16be1eedae4e7d0095828cbf51f4752 Mon Sep 17 00:00:00 2001 From: Aaron Trachtman Date: Mon, 7 Mar 2016 16:30:19 -0500 Subject: [PATCH 439/460] [storage] Add temporary url functionality to openstack storage --- .../openstack/storage/client/account.js | 101 +++++++++ .../openstack/storage/client/index.js | 1 + .../openstack/storage/storageClient.js | 5 +- test/openstack/storage/temp-url-test.js | 195 ++++++++++++++++++ 4 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 lib/pkgcloud/openstack/storage/client/account.js create mode 100644 test/openstack/storage/temp-url-test.js diff --git a/lib/pkgcloud/openstack/storage/client/account.js b/lib/pkgcloud/openstack/storage/client/account.js new file mode 100644 index 000000000..f10f51359 --- /dev/null +++ b/lib/pkgcloud/openstack/storage/client/account.js @@ -0,0 +1,101 @@ +var crypto = require('crypto'); + +/** + * client.getTemporaryUrlKey + * + * @description get the previously set temporaryUrl key on the current account + * + * @param callback + */ +exports.getTemporaryUrlKey = function (callback) { + var self = this; + + this._request({ + method: 'HEAD' + }, function (err, body, res){ + if(err) { + return callback(err); + } + + var temporaryUrlKey = res.headers[self.ACCOUNT_META_PREFIX + 'temp-url-key']; + callback(null, temporaryUrlKey); + }); + +}; + +/** + * client.setTemporaryUrlKey + * + * @description set a temporaryUrl key on the current account + * + * @param {String} key the secret key to be used in hmac signing temporary urls + * @param callback + */ +exports.setTemporaryUrlKey = function (key, callback) { + if(!key){ + return process.nextTick(function(){ + callback(new Error('A temporary URL key must be provided')); + }); + } + + this._request({ + method: 'POST', + headers: { + 'x-account-meta-temp-url-key': key + } + }, function(err){ + callback(err); + }); +}; + +/** + * client.generateTempUrl + * + * @description create a temporary url for GET/PUT to a cloud files container + * + * @param {String|object} container the container or container name for the url + * @param {String|object} file the file or fileName for the url + * @param {String} method either GET or PUT + * @param {Number} time expiry for the url in seconds (from now) + * @param {String} key the secret key to be used for signing the url + * @param callback + */ +exports.generateTempUrl = function(container, file, method, time, key, callback) { + var containerName = container instanceof this.models.Container ? container.name : container, + fileName = file instanceof this.models.File ? file.name : file, + time = typeof time === 'number' ? time : parseInt(time), + self = this, + split = '/v1'; + + function createUrl() { + // construct our hmac signature + var expiry = parseInt(new Date().getTime() / 1000) + time, + url = self._getUrl({ + container: containerName, + path: fileName + }), + hmac_body = method.toUpperCase() + '\n' + expiry + '\n' + split + url.split(split)[1]; + + var hash = crypto.createHmac('sha1', key).update(hmac_body).digest('hex'); + + callback(null, url + '?temp_url_sig=' + hash + '&temp_url_expires=' + expiry); + } + + // We have to be authed to make sure we have the service catalog + // this is required to validate the service url + + if (!this._isAuthorized()) { + this.auth(function(err) { + if (err) { + callback(err); + return; + } + + createUrl(); + }); + + return; + } + + createUrl(); +}; diff --git a/lib/pkgcloud/openstack/storage/client/index.js b/lib/pkgcloud/openstack/storage/client/index.js index 7c37c37c7..b219a23e6 100644 --- a/lib/pkgcloud/openstack/storage/client/index.js +++ b/lib/pkgcloud/openstack/storage/client/index.js @@ -27,6 +27,7 @@ var Client = exports.Client = function (options) { _.extend(this, require('./containers')); _.extend(this, require('./files')); + _.extend(this, require('./account')); this.serviceType = 'object-store'; }; diff --git a/lib/pkgcloud/openstack/storage/storageClient.js b/lib/pkgcloud/openstack/storage/storageClient.js index a52d2c86f..1420910f9 100644 --- a/lib/pkgcloud/openstack/storage/storageClient.js +++ b/lib/pkgcloud/openstack/storage/storageClient.js @@ -15,6 +15,7 @@ const CONTAINER_META_PREFIX = 'x-container-meta-'; const CONTAINER_REMOVE_META_PREFIX = 'x-remove-container-meta-'; const OBJECT_META_PREFIX = 'x-object-meta-'; const OBJECT_REMOVE_META_PREFIX = 'x-object-remove-meta-'; +const ACCOUNT_META_PREFIX = 'x-account-meta-'; var Client = exports.StorageClient = function () { this.serviceType = 'object-store'; @@ -87,9 +88,11 @@ Client.prototype.deserializeMetadata = function (prefix, metadata) { return deserializedMetadata; }; + + Client.prototype.CONTAINER_META_PREFIX = CONTAINER_META_PREFIX; Client.prototype.CONTAINER_REMOVE_META_PREFIX = CONTAINER_REMOVE_META_PREFIX; Client.prototype.OBJECT_META_PREFIX = OBJECT_META_PREFIX; Client.prototype.OBJECT_REMOVE_META_PREFIX = OBJECT_REMOVE_META_PREFIX; - +Client.prototype.ACCOUNT_META_PREFIX = ACCOUNT_META_PREFIX; diff --git a/test/openstack/storage/temp-url-test.js b/test/openstack/storage/temp-url-test.js new file mode 100644 index 000000000..eef6dc0fb --- /dev/null +++ b/test/openstack/storage/temp-url-test.js @@ -0,0 +1,195 @@ +'use strict'; + +var should = require('should'), + async = require('async'), + helpers = require('../../helpers'), + hock = require('hock'), + http = require('http'), + mock = !!process.env.MOCK; + +var setupSetTemporaryUrlKeyMock, setupGetTemporaryUrlKeyMock, setupGenerateTempUrlKeyMock; + +describe('pkgcloud/openstack/storage', function(){ + var client, authHockInstance, hockInstance, + authServer, server; + + beforeEach(function (done) { + client = helpers.createClient('openstack', 'storage'); + + if(!mock) { + return done(); + } + + hockInstance = hock.createHock({ throwOnUnmatched: false }); + authHockInstance = hock.createHock(); + + server = http.createServer(hockInstance.handler); + authServer = http.createServer(authHockInstance.handler); + + async.parallel([ + function (next) { + server.listen(12345, next); + }, + function (next) { + authServer.listen(12346, next); + } + ], done); + + }); + + afterEach(function (done) { + client = null; + if (!mock) { + return done(); + } + + async.parallel([ + function (next) { + server.close(next); + }, + function (next) { + authServer.close(next); + } + ], done); + + }); + + it('the client.getTemporaryUrlKey() method should return the temporary url key', function(done){ + if(mock) { + setupGetTemporaryUrlKeyMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.getTemporaryUrlKey(function (err, temporaryUrlKey) { + should.not.exist(err); + should.exist(temporaryUrlKey); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.setTemporaryUrlKey() method should have the proper header', function(done){ + if(mock) { + setupSetTemporaryUrlKeyMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.setTemporaryUrlKey('54321', function (err) { + should.not.exist(err); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); + + it('the client.generateTempUrl() method should return the temporary url', function(done){ + if(mock) { + setupGenerateTempUrlKeyMock(client, { + authServer: authHockInstance, + server: hockInstance + }); + } + + client.generateTempUrl('container', 'file', 'GET', 60, '12345', function (err, temporaryUrl) { + should.not.exist(err); + should.exist(temporaryUrl); + + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + + done(); + }); + }); +}); + +setupGetTemporaryUrlKeyMock = function (client, servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00') + .reply(200, null, {'x-account-meta-temp-url-key': '12345'}); +}; + +setupSetTemporaryUrlKeyMock = function (client, servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); + + servers.server + .post('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00', null, {'x-account-meta-temp-url-key': '54321'}) + .reply(201); +}; + +setupGenerateTempUrlKeyMock = function (client, servers) { + servers.authServer + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + } + } + }) + .replyWithFile(200, __dirname + '/../../fixtures/openstack/initialToken.json') + .get('/v2.0/tenants') + .replyWithFile(200, __dirname + '/../../fixtures/openstack/tenantId.json') + .post('/v2.0/tokens', { + auth: { + passwordCredentials: { + username: 'MOCK-USERNAME', + password: 'MOCK-PASSWORD' + }, + tenantId: '72e90ecb69c44d0296072ea39e537041' + } + }) + .reply(200, helpers.getOpenstackAuthResponse()); +}; From c2616c53826529e8654cebad3e0b38c9c9d96279 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Tue, 28 Aug 2018 07:56:09 -0700 Subject: [PATCH 440/460] Set Content-Type with google storage (#635) Content-Type will always be text/plain, which causes issues when trying to open the file if it isn't plaintext (such as a pdf). This fixes that by either looking up the mime type, or using the provided contentType. Addresses Issue [634](https://github.com/pkgcloud/pkgcloud/issues/634) --- docs/providers/google.md | 25 ++++++++++++++++++++- lib/pkgcloud/google/storage/client/files.js | 12 ++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/providers/google.md b/docs/providers/google.md index 0da860884..927702540 100644 --- a/docs/providers/google.md +++ b/docs/providers/google.md @@ -21,4 +21,27 @@ var client = require('pkgcloud').storage.createClient({ keyFilename: '/path/to/a/keyfile.json', // path to a JSON key file projectId: 'eco-channel-658' // project id }); -``` \ No newline at end of file +``` + + +## Uploading a file +```Javascript +var readStream = fs.createReadStream(); + +var writeStream = client.upload({ + container: , + remote: , + contentType: 'application/pdf' // optional +}); + +writeStream.on('error', function (err) { + console.error(err); +}); + +writeStream.on('success', function (file) { + console.log("Success!"); +}); + +readStream.pipe(writeStream); +``` + diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index ac539fbb4..8269cc351 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -7,6 +7,7 @@ var pkgcloud = require('../../../../../lib/pkgcloud'), through = require('through2'), + mime = require('mime'), storage = pkgcloud.providers.google.storage, _ = require('lodash'); @@ -39,15 +40,22 @@ exports.removeFile = function (container, file, callback) { exports.upload = function (options) { var self = this, bucket = this._getBucket(options), - file = this._getFile(bucket, options); + file = this._getFile(bucket, options), + uploadOptions = {}; // check for deprecated calling with a callback if (typeof arguments[arguments.length - 1] === 'function') { self.emit('log::warn', 'storage.upload no longer supports calling with a callback'); } + if (options.contentType) { + uploadOptions.contentType = options.contentType; + } else { + uploadOptions.contentType = mime.lookup(options.file || options.remote || options); + } + var proxyStream = through(), - writableStream = file.createWriteStream(); + writableStream = file.createWriteStream(uploadOptions); // we need a proxy stream so we can always return a file model // via the 'success' event From 15c361515dc71da76631b7dda02fd408fe98a5e0 Mon Sep 17 00:00:00 2001 From: Ralic Lo Date: Wed, 31 Oct 2018 22:23:19 +0800 Subject: [PATCH 441/460] Security related package upgrade (#631) --- package-lock.json | 2348 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 25 +- 2 files changed, 2361 insertions(+), 12 deletions(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..b5356ed4c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2348 @@ +{ + "name": "pkgcloud", + "version": "1.4.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "ascli": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/ascli/-/ascli-0.3.0.tgz", + "integrity": "sha1-XmYjDlIZ/j6JUqTvtPIPrllqgTo=", + "requires": { + "colour": "^0.7.1", + "optjs": "^3.2.2" + } + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "requires": { + "lodash": "^4.17.10" + }, + "dependencies": { + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + } + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sdk": { + "version": "2.296.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.296.0.tgz", + "integrity": "sha512-Ko76U9N7cr4B4IDUuBqnnH6r+t2WkzydrN0ja8fge+asvuJYavEj/jVq8jjq+yOXfW2KgZ+1uaUDjoV33FAfMQ==", + "requires": { + "buffer": "4.9.1", + "events": "1.1.1", + "ieee754": "1.1.8", + "jmespath": "0.15.0", + "querystring": "0.2.0", + "sax": "1.2.1", + "url": "0.10.3", + "uuid": "3.1.0", + "xml2js": "0.4.19" + }, + "dependencies": { + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" + } + } + } + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base64-js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + }, + "base64url": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/base64url/-/base64url-1.0.6.tgz", + "integrity": "sha1-1k03XWinxkDZEuI1jRcNylu1RoE=", + "requires": { + "concat-stream": "~1.4.7", + "meow": "~2.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "1.4.11", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.4.11.tgz", + "integrity": "sha512-X3JMh8+4je3U1cQpG87+f9lXHDrqcb2MVLg9L7o8b1UZ0DzhRrUpdn65ttzu10PpJPPI3MQNkis+oha6TSA9Mw==", + "requires": { + "inherits": "~2.0.1", + "readable-stream": "~1.1.9", + "typedarray": "~0.0.5" + } + } + } + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "optional": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "blanket": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/blanket/-/blanket-1.1.9.tgz", + "integrity": "sha1-1lzKKXuAKHoL+fmeiRCV0fdEUcM=", + "dev": true, + "requires": { + "esprima": "~2.4.1", + "falafel": "~0.3.1", + "xtend": "~4.0.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true, + "optional": true + }, + "bufferview": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bufferview/-/bufferview-1.0.1.tgz", + "integrity": "sha1-ev10pF+Tf6QiodM4wIu/3HbNcl0=" + }, + "bytebuffer": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-3.5.5.tgz", + "integrity": "sha1-em+vGhNRSwg/H8+VQcTJv75+f9M=", + "requires": { + "bufferview": "~1", + "long": "~2 >=2.2.3" + } + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=" + }, + "camelcase-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-1.0.0.tgz", + "integrity": "sha1-vRoRv5sxoc5JNJOpMN4aC69K1+w=", + "requires": { + "camelcase": "^1.0.1", + "map-obj": "^1.0.0" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "cli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", + "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "dev": true, + "requires": { + "exit": "0.1.2", + "glob": "^7.1.1" + } + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "colors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", + "dev": true, + "optional": true + }, + "colour": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/colour/-/colour-0.7.1.tgz", + "integrity": "sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g=" + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "optional": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "coveralls": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.2.tgz", + "integrity": "sha512-Tv0LKe/MkBOilH2v7WBiTBdudg2ChfGbdXafc/s330djpF3zKOmuehTeRwjXWc7pzfj9FrDUTA7tEx6Div8NFw==", + "dev": true, + "requires": { + "growl": "~> 1.10.0", + "js-yaml": "^3.11.0", + "lcov-parse": "^0.0.10", + "log-driver": "^1.2.7", + "minimist": "^1.2.0", + "request": "^2.85.0" + } + }, + "cycle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", + "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=", + "dev": true, + "optional": true + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "deep-equal": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.1.tgz", + "integrity": "sha1-+tenkyJMvww8d4b5LveA5PyMyHg=", + "dev": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "dom-serializer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", + "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "dev": true, + "requires": { + "domelementtype": "~1.1.1", + "entities": "~1.1.1" + }, + "dependencies": { + "domelementtype": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", + "dev": true + }, + "entities": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", + "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", + "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true, + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "duplexify": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.0.tgz", + "integrity": "sha512-fO3Di4tBKJpYTFHAxTU00BcfWMY9w24r/x21a6rZRbsD/ToUgGxsMbiGRmB7uVAXeGKXD9MwiLZa5E97EVgIRQ==", + "requires": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "optional": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "ecdsa-sig-formatter": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz", + "integrity": "sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "requires": { + "once": "^1.4.0" + } + }, + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + }, + "errs": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/errs/-/errs-0.3.2.tgz", + "integrity": "sha1-eYCZstvTfKK8dJ5TinwTB9C1BJk=" + }, + "es6-promise": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", + "dev": true, + "optional": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.4.1.tgz", + "integrity": "sha1-gwWcdR6enEHSKKQaqh7vDMzjhLo=", + "dev": true + }, + "eventemitter2": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz", + "integrity": "sha1-YZegldX7a1folC9v1+qtY6CclFI=" + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "extend": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extend/-/extend-1.3.0.tgz", + "integrity": "sha1-0VFvsP9WJNLr+RI+odrFoZlABPg=" + }, + "extract-zip": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", + "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "dev": true, + "optional": true, + "requires": { + "concat-stream": "1.6.2", + "debug": "2.6.9", + "mkdirp": "0.5.1", + "yauzl": "2.4.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true, + "optional": true + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=", + "dev": true, + "optional": true + }, + "falafel": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/falafel/-/falafel-0.3.1.tgz", + "integrity": "sha1-81RnSIFPfQlUPRny+z1gkPE2hT0=", + "dev": true, + "requires": { + "esprima": "*" + }, + "dependencies": { + "esprima": { + "version": "1.1.0-dev", + "bundled": true, + "dev": true + } + } + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-patch": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/fast-json-patch/-/fast-json-patch-0.5.7.tgz", + "integrity": "sha1-taj0nSWWJFlu+YuHLz/aiVtNhmU=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "dev": true, + "optional": true, + "requires": { + "pend": "~1.2.0" + } + }, + "filed": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/filed/-/filed-0.1.0.tgz", + "integrity": "sha1-sPYmRyojZtwRlFN6Tup+eonzxzU=", + "requires": { + "mime": ">= 1.2.6" + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs-extra": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", + "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", + "dev": true, + "optional": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^2.1.0", + "klaw": "^1.0.0" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true, + "optional": true + } + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "gapitoken": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/gapitoken/-/gapitoken-0.1.5.tgz", + "integrity": "sha1-NXf8+1Qmvjp7jrrakmcSKdjMgc4=", + "requires": { + "jws": "~3.0.0", + "request": "^2.54.0" + } + }, + "gcloud": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/gcloud/-/gcloud-0.10.0.tgz", + "integrity": "sha1-hVoms1Mdx7B5FRP/+4n8ZZIfQ+4=", + "requires": { + "duplexify": "^3.1.2", + "extend": "^1.3.0", + "gapitoken": "^0.1.3", + "node-uuid": "^1.4.1", + "protobufjs": "^3.4.0", + "request": "^2.39.0", + "stream-events": "^1.0.1", + "through2": "^0.6.3" + }, + "dependencies": { + "node-uuid": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", + "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=" + } + } + }, + "get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=" + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "grpc": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/grpc/-/grpc-1.14.1.tgz", + "integrity": "sha512-UQA+WSa6CJYKv8rWAHX2RXCKhcxbB/5kyVnkiK3U+dPm4PlfZT4PrEeEdt2uzmvMhp9PB0SVKpVAukng1By+7w==", + "requires": { + "lodash": "^4.17.5", + "nan": "^2.0.0", + "node-pre-gyp": "^0.10.0", + "protobufjs": "^5.0.3" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "ascli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ascli/-/ascli-1.0.1.tgz", + "integrity": "sha1-vPpZdKYvGOgcq660lzKrSoj5Brw=", + "requires": { + "colour": "~0.7.1", + "optjs": "~3.2.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "bytebuffer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz", + "integrity": "sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0=", + "requires": { + "long": "~3" + } + }, + "chownr": { + "version": "1.0.1", + "bundled": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "bundled": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true + }, + "iconv-lite": { + "version": "0.4.23", + "bundled": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "ini": { + "version": "1.3.5", + "bundled": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true + }, + "long": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", + "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=" + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "bundled": true + }, + "minipass": { + "version": "2.3.3", + "bundled": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.1.0", + "bundled": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "bundled": true + } + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "needle": { + "version": "2.2.2", + "bundled": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.10.3", + "bundled": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.3", + "bundled": true + }, + "npm-packlist": { + "version": "1.1.11", + "bundled": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true + }, + "protobufjs": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-5.0.3.tgz", + "integrity": "sha512-55Kcx1MhPZX0zTbVosMQEO5R6/rikNXd9b6RQK4KSPcrSIIwoXTtebIczUrXlwaSrbz4x8XUVThGPob1n8I4QA==", + "requires": { + "ascli": "~1", + "bytebuffer": "~5", + "glob": "^7.0.5", + "yargs": "^3.10.0" + } + }, + "rc": { + "version": "1.2.8", + "bundled": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "requires": { + "glob": "^7.0.5" + } + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true + }, + "sax": { + "version": "1.2.4", + "bundled": true + }, + "semver": { + "version": "5.5.0", + "bundled": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true + }, + "tar": { + "version": "4.4.6", + "bundled": true, + "requires": { + "chownr": "^1.0.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.3", + "minizlib": "^1.1.0", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true + }, + "wide-align": { + "version": "1.1.3", + "bundled": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + }, + "yallist": { + "version": "3.0.2", + "bundled": true + } + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", + "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", + "requires": { + "ajv": "^5.3.0", + "har-schema": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "hasha": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", + "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", + "dev": true, + "optional": true, + "requires": { + "is-stream": "^1.0.1", + "pinkie-promise": "^2.0.0" + } + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "hock": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/hock/-/hock-1.2.0.tgz", + "integrity": "sha1-6GgiKnXzyX56YX1U1/WYB0bcmHc=", + "dev": true, + "requires": { + "deep-equal": "0.2.1" + } + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1", + "domhandler": "2.3", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=" + }, + "indent-string": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-1.2.2.tgz", + "integrity": "sha1-25m8xYPrarux5I3LsZmamGBBy2s=", + "requires": { + "get-stdin": "^4.0.1", + "minimist": "^1.1.0", + "repeating": "^1.1.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true, + "optional": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true, + "optional": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "jade": { + "version": "0.26.3", + "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", + "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", + "requires": { + "commander": "0.6.1", + "mkdirp": "0.3.0" + }, + "dependencies": { + "commander": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", + "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=" + }, + "mkdirp": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", + "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=" + } + } + }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + } + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "jshint": { + "version": "2.9.6", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.6.tgz", + "integrity": "sha512-KO9SIAKTlJQOM4lE64GQUtGBRpTOuvbrRrSZw3AhUxMNG266nX9hK2cKA4SBhXOj0irJGyNyGSLT62HGOVDEOA==", + "dev": true, + "requires": { + "cli": "~1.0.0", + "console-browserify": "1.1.x", + "exit": "0.1.x", + "htmlparser2": "3.8.x", + "lodash": "~4.17.10", + "minimatch": "~3.0.2", + "phantom": "~4.0.1", + "phantomjs-prebuilt": "~2.1.7", + "shelljs": "0.3.x", + "strip-json-comments": "1.0.x", + "unicode-5.2.0": "^0.7.5" + }, + "dependencies": { + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "dev": true + } + } + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonfile": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "dev": true, + "optional": true, + "requires": { + "graceful-fs": "^4.1.6" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true, + "optional": true + } + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "jwa": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.0.2.tgz", + "integrity": "sha1-/Xlgnx53Limdzo3bdtAGWd2DUR8=", + "requires": { + "base64url": "~0.0.4", + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "^1.0.0" + }, + "dependencies": { + "base64url": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/base64url/-/base64url-0.0.6.tgz", + "integrity": "sha1-lZezazMNscQkdzIuqH6oAnSZuCs=" + } + } + }, + "jws": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.0.0.tgz", + "integrity": "sha1-2l8meJfdTpz4E3l52zP8VKPAVBg=", + "requires": { + "base64url": "~1.0.4", + "jwa": "~1.0.0" + } + }, + "kew": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", + "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", + "dev": true, + "optional": true + }, + "klaw": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", + "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", + "dev": true, + "optional": true, + "requires": { + "graceful-fs": "^4.1.9" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true, + "optional": true + } + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "^1.0.0" + } + }, + "lcov-parse": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", + "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", + "dev": true + }, + "liboneandone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/liboneandone/-/liboneandone-1.2.0.tgz", + "integrity": "sha512-EB6Ak9qw+U4HAOnKqPtatxQ9pLclvtsBsggrvOuD4zclJ5xOeEASojsLKEC3O8KJ1Q4obE2JHhOeDuqWXvkoUQ==", + "requires": { + "mocha": "^2.5.3", + "request": "^2.74.0" + }, + "dependencies": { + "commander": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", + "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=" + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "requires": { + "ms": "0.7.1" + } + }, + "diff": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", + "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=" + }, + "escape-string-regexp": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", + "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=" + }, + "glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "requires": { + "inherits": "2", + "minimatch": "0.3" + } + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=" + }, + "minimatch": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "requires": { + "lru-cache": "2", + "sigmund": "~1.0.0" + } + }, + "mocha": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", + "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", + "requires": { + "commander": "2.3.0", + "debug": "2.2.0", + "diff": "1.4.0", + "escape-string-regexp": "1.0.2", + "glob": "3.2.11", + "growl": "1.9.2", + "jade": "0.26.3", + "mkdirp": "0.5.1", + "supports-color": "1.2.0", + "to-iso-string": "0.0.2" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + }, + "supports-color": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", + "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=" + } + } + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + }, + "log-driver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", + "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", + "dev": true + }, + "long": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/long/-/long-2.4.0.tgz", + "integrity": "sha1-n6GAux2VAM3CnEFWdmoZleH0Uk8=" + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" + }, + "map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" + }, + "meow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-2.0.0.tgz", + "integrity": "sha1-j1MKjs9dQNP0tN+Tw0cpAPuiqPE=", + "requires": { + "camelcase-keys": "^1.0.0", + "indent-string": "^1.1.0", + "minimist": "^1.1.0", + "object-assign": "^1.0.0" + } + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.35.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", + "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + }, + "mime-types": { + "version": "2.1.19", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", + "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "requires": { + "mime-db": "~1.35.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + } + } + }, + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + } + }, + "mocha-lcov-reporter": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/mocha-lcov-reporter/-/mocha-lcov-reporter-0.0.1.tgz", + "integrity": "sha1-AmcEkdtX7myx/nOS6BNwD24zaiE=", + "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "nan": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "object-assign": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-1.0.0.tgz", + "integrity": "sha1-5l3Idm07R7S4MHRlyDEdoDCwcKY=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "optjs": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/optjs/-/optjs-3.2.2.tgz", + "integrity": "sha1-aabOicRCpEQDFBrS+bNwvVu29O4=" + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "requires": { + "lcid": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "dev": true, + "optional": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "phantom": { + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/phantom/-/phantom-4.0.12.tgz", + "integrity": "sha512-Tz82XhtPmwCk1FFPmecy7yRGZG2btpzY2KI9fcoPT7zT9det0CcMyfBFPp1S8DqzsnQnm8ZYEfdy528mwVtksA==", + "dev": true, + "optional": true, + "requires": { + "phantomjs-prebuilt": "^2.1.16", + "split": "^1.0.1", + "winston": "^2.4.0" + } + }, + "phantomjs-prebuilt": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz", + "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", + "dev": true, + "optional": true, + "requires": { + "es6-promise": "^4.0.3", + "extract-zip": "^1.6.5", + "fs-extra": "^1.0.0", + "hasha": "^2.2.0", + "kew": "^0.7.0", + "progress": "^1.1.8", + "request": "^2.81.0", + "request-progress": "^2.0.1", + "which": "^1.2.10" + } + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true, + "optional": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "optional": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "progress": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true, + "optional": true + }, + "protobufjs": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-3.8.2.tgz", + "integrity": "sha1-vIJuNMOvRpfo0K96Zp5NYSrtzRc=", + "requires": { + "ascli": "~0.3", + "bytebuffer": "~3 >=3.5" + } + }, + "psl": { + "version": "1.1.29", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", + "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + } + } + }, + "repeating": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz", + "integrity": "sha1-PUEUIYh3U3SU+X93+Xhfq4EPpKw=", + "requires": { + "is-finite": "^1.0.0" + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + } + } + }, + "request-progress": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", + "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", + "dev": true, + "optional": true, + "requires": { + "throttleit": "^1.0.0" + } + }, + "s3-upload-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/s3-upload-stream/-/s3-upload-stream-1.0.7.tgz", + "integrity": "sha1-4/gCUxQcVp8QWmKqUMqbRXYOSB0=" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "should": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/should/-/should-4.0.4.tgz", + "integrity": "sha1-jvqjBPHxSM89LpVYYpkPmrnqYo8=", + "dev": true + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" + }, + "split": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "dev": true, + "optional": true, + "requires": { + "through": "2" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", + "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "dev": true, + "optional": true + }, + "stream-events": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.4.tgz", + "integrity": "sha512-D243NJaYs/xBN2QnoiMDY7IesJFIK7gEhnvAYqJa5JvDdnh2dC4qDBwlCf0ohPpX2QRlA/4gnbnPd3rs3KxVcA==", + "requires": { + "stubs": "^3.0.0" + } + }, + "stream-shift": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "stubs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", + "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=" + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "throttleit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", + "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", + "dev": true, + "optional": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true, + "optional": true + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "requires": { + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + } + } + }, + "to-iso-string": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", + "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=" + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "unicode-5.2.0": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/unicode-5.2.0/-/unicode-5.2.0-0.7.5.tgz", + "integrity": "sha512-KVGLW1Bri30x00yv4HNM8kBxoqFXr0Sbo55735nvrlsx4PYBZol3UtoWgO492fSwmsetzPEZzy73rbU8OGXJcA==", + "dev": true + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "url-join": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-0.0.1.tgz", + "integrity": "sha1-HbSK1CLTQCRpqH99l73r/k+x48g=" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "optional": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "window-size": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", + "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=" + }, + "winston": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/winston/-/winston-2.4.3.tgz", + "integrity": "sha512-GYKuysPz2pxYAVJD2NPsDLP5Z79SDEzPm9/j4tCjkF/n89iBNGBMJcR+dMUqxgPNgoSs6fVygPi+Vl2oxIpBuw==", + "dev": true, + "optional": true, + "requires": { + "async": "~1.0.0", + "colors": "1.0.x", + "cycle": "1.0.x", + "eyes": "0.1.x", + "isstream": "0.1.x", + "stack-trace": "0.0.x" + }, + "dependencies": { + "async": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", + "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=", + "dev": true, + "optional": true + } + } + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xml2js": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.1.14.tgz", + "integrity": "sha1-UnTmf1pkxfkpdM2FE54DMq3GuQw=", + "requires": { + "sax": ">=0.1.1" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + }, + "yargs": { + "version": "3.32.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", + "integrity": "sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU=", + "requires": { + "camelcase": "^2.0.1", + "cliui": "^3.0.3", + "decamelize": "^1.1.1", + "os-locale": "^1.4.0", + "string-width": "^1.0.1", + "window-size": "^0.1.4", + "y18n": "^3.2.0" + }, + "dependencies": { + "camelcase": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", + "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" + } + } + }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "dev": true, + "optional": true, + "requires": { + "fd-slicer": "~1.0.1" + } + } + } +} diff --git a/package.json b/package.json index c6b3a25b5..310ec0622 100644 --- a/package.json +++ b/package.json @@ -55,19 +55,20 @@ "helion" ], "dependencies": { - "async": "0.9.x", + "async": "^2.6.1", "aws-sdk": "^2.2.43", - "liboneandone": "1.0.0", - "errs": "0.3.x", - "eventemitter2": "0.4.x", + "errs": "^0.3.2", + "eventemitter2": "^5.0.1", "fast-json-patch": "0.5.x", - "filed": "0.1.x", + "filed": "^0.1.0", "gcloud": "^0.10.0", - "ip": "0.3.x", - "lodash": "^3.10.1", + "grpc": "^1.14.1", + "ip": "^1.1.5", + "liboneandone": "^1.2.0", + "lodash": "^4.17.10", "mime": "1.4.1", - "qs": "1.2.x", - "request": "2.83.0", + "qs": "^6.5.2", + "request": "^2.88.0", "s3-upload-stream": "~1.0.7", "through2": "0.6.x", "url-join": "0.0.x", @@ -75,10 +76,10 @@ }, "devDependencies": { "blanket": "1.1.9", - "coveralls": "^2.11.2", + "coveralls": "^3.0.2", "hock": "~1.2.0", - "jshint": "~2.7.0", - "mocha": "1.21.x", + "jshint": "^2.9.6", + "mocha": "^5.2.0", "mocha-lcov-reporter": "0.0.1", "should": "4.0.x" }, From c50daf5f60f7c58d4a621b626191efaaf9373d43 Mon Sep 17 00:00:00 2001 From: Clement134 Date: Thu, 22 Nov 2018 21:04:50 +0100 Subject: [PATCH 442/460] Fix build (jshint + unit test) (#642) * fix lint issues (#641) * fix unit test --- .../amazon/storage/client/containers.js | 16 ++--- .../google/storage/client/containers.js | 16 ++--- lib/pkgcloud/openstack/context/identity.js | 68 +++++++++---------- lib/pkgcloud/openstack/context/service.js | 56 +++++++-------- .../openstack/database/client/users.js | 32 ++++----- test/common/base/client-test.js | 23 ++++--- test/common/databases/flavor-test.js | 37 +++++----- test/hp/storage/file-test.js | 1 + 8 files changed, 125 insertions(+), 124 deletions(-) diff --git a/lib/pkgcloud/amazon/storage/client/containers.js b/lib/pkgcloud/amazon/storage/client/containers.js index 57b71a69d..da71aefd2 100644 --- a/lib/pkgcloud/amazon/storage/client/containers.js +++ b/lib/pkgcloud/amazon/storage/client/containers.js @@ -108,6 +108,14 @@ exports.destroyContainer = function (container, callback) { ); } + function destroyFile(file, next) { + file.remove(next); + } + + function deleteFiles(files, next) { + async.forEachLimit(files, 10, destroyFile, next); + } + function handleResponse(err, files, meta) { if (err) { return callback(err); @@ -128,13 +136,5 @@ exports.destroyContainer = function (container, callback) { deleteFiles(files, deleteContainer); } - function deleteFiles(files, next) { - async.forEachLimit(files, 10, destroyFile, next); - } - - function destroyFile(file, next) { - file.remove(next); - } - getPagedFiles(containerName, handleResponse); }; diff --git a/lib/pkgcloud/google/storage/client/containers.js b/lib/pkgcloud/google/storage/client/containers.js index 94e3561bc..67bd4b8ee 100644 --- a/lib/pkgcloud/google/storage/client/containers.js +++ b/lib/pkgcloud/google/storage/client/containers.js @@ -91,6 +91,14 @@ exports.destroyContainer = function (container, callback) { }); } + function destroyFile(file, next) { + file.delete(next); + } + + function deleteFiles(files, next) { + async.forEachLimit(files, 10, destroyFile, next); + } + function handleResponse(err, files, nextQuery) { if (err) { return callback(err); @@ -109,13 +117,5 @@ exports.destroyContainer = function (container, callback) { } } - function deleteFiles(files, next) { - async.forEachLimit(files, 10, destroyFile, next); - } - - function destroyFile(file, next) { - file.delete(next); - } - bucket.getFiles(handleResponse); }; diff --git a/lib/pkgcloud/openstack/context/identity.js b/lib/pkgcloud/openstack/context/identity.js index 8d308642b..489d41266 100644 --- a/lib/pkgcloud/openstack/context/identity.js +++ b/lib/pkgcloud/openstack/context/identity.js @@ -150,6 +150,40 @@ Identity.prototype.authorize = function (options, callback) { self.emit('log::trace', 'Sending client authorization request', authenticationOptions); + function getTenantId(endpoint, token) { + var tenantOptions = { + uri: endpoint, + json: true, + strictSSL: options.strictSSL || self.options.strictSSL, + headers: { + 'X-Auth-Token': token, + 'Content-Type': 'application/json', + 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) + } + }; + + request(tenantOptions, function (err, response, body) { + if (err || !body.tenants || !body.tenants.length) { + return callback(err ? err : new Error('Unable to find tenants')); + } + + var firstActiveTenant; + body.tenants.forEach(function (tenant) { + if (!firstActiveTenant && !!tenant.enabled && tenant.enabled !== 'false') { + firstActiveTenant = tenant; + } + }); + + if (!firstActiveTenant) { + return callback(new Error('Unable to find an active tenant')); + } + + // TODO make this more resiliant (what if multiple active tenants) + self.options.tenantId = firstActiveTenant.id; + self.authorize(options, callback); + }); + } + // Don't keep a copy of the credentials in memory delete self._authenticationPayload; request(authenticationOptions, function (err, response, body) { @@ -191,40 +225,6 @@ Identity.prototype.authorize = function (options, callback) { callback(e); } }); - - function getTenantId(endpoint, token) { - var tenantOptions = { - uri: endpoint, - json: true, - strictSSL: options.strictSSL || self.options.strictSSL, - headers: { - 'X-Auth-Token': token, - 'Content-Type': 'application/json', - 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) - } - }; - - request(tenantOptions, function (err, response, body) { - if (err || !body.tenants || !body.tenants.length) { - return callback(err ? err : new Error('Unable to find tenants')); - } - - var firstActiveTenant; - body.tenants.forEach(function (tenant) { - if (!firstActiveTenant && !!tenant.enabled && tenant.enabled !== 'false') { - firstActiveTenant = tenant; - } - }); - - if (!firstActiveTenant) { - return callback(new Error('Unable to find an active tenant')); - } - - // TODO make this more resiliant (what if multiple active tenants) - self.options.tenantId = firstActiveTenant.id; - self.authorize(options, callback); - }); - } }; /** diff --git a/lib/pkgcloud/openstack/context/service.js b/lib/pkgcloud/openstack/context/service.js index 79d1fcc2d..0c32f2afd 100644 --- a/lib/pkgcloud/openstack/context/service.js +++ b/lib/pkgcloud/openstack/context/service.js @@ -73,34 +73,6 @@ Service.prototype.getEndpointUrl = function (options) { self.v3 = true; } - if (options.region) { - _.each(self.endpoints, function (endpoint) { - if (!endpoint.region || !matchRegion(endpoint.region, options.region)) { - return; - } - if (self.v3 === true) { - if (endpointMatchDesiredInterface(endpoint)) { - url = endpoint.url; - } - } else { - url = getUrl(endpoint); - } - }); - } - else { - _.each(self.endpoints, function(endpoint) { - - if (url) { - return; - } - - // return the first region-less endpoint - if (!endpoint.region) { - url = getUrl(endpoint); - } - }); - } - /** * getUrl * @@ -138,6 +110,34 @@ Service.prototype.getEndpointUrl = function (options) { return endpoint['interface'] === interfaceToUse; } + if (options.region) { + _.each(self.endpoints, function (endpoint) { + if (!endpoint.region || !matchRegion(endpoint.region, options.region)) { + return; + } + if (self.v3 === true) { + if (endpointMatchDesiredInterface(endpoint)) { + url = endpoint.url; + } + } else { + url = getUrl(endpoint); + } + }); + } + else { + _.each(self.endpoints, function(endpoint) { + + if (url) { + return; + } + + // return the first region-less endpoint + if (!endpoint.region) { + url = getUrl(endpoint); + } + }); + } + if (!url) { throw new Error('Unable to identify endpoint url'); } diff --git a/lib/pkgcloud/openstack/database/client/users.js b/lib/pkgcloud/openstack/database/client/users.js index 5e1e26a04..8a5068a53 100644 --- a/lib/pkgcloud/openstack/database/client/users.js +++ b/lib/pkgcloud/openstack/database/client/users.js @@ -27,6 +27,22 @@ exports.createUser = function createUser(options, callback) { instanceId, count = 0; + function makeRequest() { + var createOptions = { + method: 'POST', + path: 'instances/' + instanceId + '/users', + body: { + users: users + } + }; + + self._request(createOptions, function (err, body, response) { + return err + ? callback(err) + : callback(null, response); + }); + } + function assessOptions(opts) { var databases = [], calledBack = false; @@ -142,22 +158,6 @@ exports.createUser = function createUser(options, callback) { else { assessOptions(options); } - - function makeRequest() { - var createOptions = { - method: 'POST', - path: 'instances/' + instanceId + '/users', - body: { - users: users - } - }; - - self._request(createOptions, function (err, body, response) { - return err - ? callback(err) - : callback(null, response); - }); - } }; // Get the list of users for an Instance diff --git a/test/common/base/client-test.js b/test/common/base/client-test.js index 29971bf70..0de1f3b5d 100644 --- a/test/common/base/client-test.js +++ b/test/common/base/client-test.js @@ -31,18 +31,18 @@ describe('pkgcloud/core/base/client', function () { }; cli.failCodes = {}; var stream = cli._request({ path: '/' }); - stream.on('error', function () { - return handleResponse(true); - }); - stream.on('end', function () { - return handleResponse(false); - }); function handleResponse(err) { should.exist(err); done(); } + stream.on('error', function () { + return handleResponse(true); + }); + stream.on('end', function () { + return handleResponse(false); + }); }); it('the before filters throwing an error with a callback should return the error on the cb', function(done) { @@ -72,6 +72,12 @@ describe('pkgcloud/core/base/client', function () { cli._getUrl = function () { return 'badurl'; }; + + function handleResponse(err) { + should.exist(err); + done(); + } + cli.failCodes = {}; var stream = cli._request({ path: '/' }); stream.on('error', function () { @@ -80,11 +86,6 @@ describe('pkgcloud/core/base/client', function () { stream.on('end', function () { handleResponse(false); }); - - function handleResponse(err) { - should.exist(err); - done(); - } }); }); }); diff --git a/test/common/databases/flavor-test.js b/test/common/databases/flavor-test.js index dc5ff4650..d1f57fb37 100644 --- a/test/common/databases/flavor-test.js +++ b/test/common/databases/flavor-test.js @@ -16,6 +16,24 @@ var should = require('should'), // Declaring variables for helper functions defined later var setupGetFlavorMock; +function setupGetFlavorsMock(hockInstance, provider ){ + if (provider === 'rackspace') { + hockInstance + .get('/v1.0/123456/flavors') + .reply(200, helpers.loadFixture('rackspace/databaseFlavors.json')); + } + else if (provider === 'openstack') { + hockInstance + .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') + .reply(200, helpers.loadFixture('openstack/databaseFlavors.json')); + + } + else if (provider === 'hp') { + hockInstance + .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors') + .reply(200, helpers.loadFixture('hp/databaseFlavors.json')); + } +} providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].database && provider !== 'azure'; @@ -122,25 +140,6 @@ providers.filter(function (provider) { }); }); }); - - function setupGetFlavorsMock(hockInstance, provider ){ - if (provider === 'rackspace') { - hockInstance - .get('/v1.0/123456/flavors') - .reply(200, helpers.loadFixture('rackspace/databaseFlavors.json')); - } - else if (provider === 'openstack') { - hockInstance - .get('/v1.0/72e90ecb69c44d0296072ea39e537041/flavors') - .reply(200, helpers.loadFixture('openstack/databaseFlavors.json')); - - } - else if (provider === 'hp') { - hockInstance - .get('/v1.0/5ACED3DC3AA740ABAA41711243CC6949/flavors') - .reply(200, helpers.loadFixture('hp/databaseFlavors.json')); - } - } }); diff --git a/test/hp/storage/file-test.js b/test/hp/storage/file-test.js index e30b0b6b1..451c55acf 100644 --- a/test/hp/storage/file-test.js +++ b/test/hp/storage/file-test.js @@ -14,6 +14,7 @@ var authenticate = function (hockInstance) { } } }) + .many() .reply(200, { access: { token: { From 79a8c669e1b01f5d1b1154d665ce13c99da2afd1 Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Wed, 28 Nov 2018 21:58:36 -0500 Subject: [PATCH 443/460] 1.5.0 --- 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 b5356ed4c..107cac16e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pkgcloud", - "version": "1.4.0", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 310ec0622..35f80dd0d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.4.0", + "version": "1.5.0", "author": "Charlie Robbins ", "contributors": [ { From f9cfcc911554245c0ea5811f772f264a03cb1bb9 Mon Sep 17 00:00:00 2001 From: Ross Kukulinski Date: Wed, 28 Nov 2018 22:00:38 -0500 Subject: [PATCH 444/460] 1.6.0 --- 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 107cac16e..5a2e3a194 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pkgcloud", - "version": "1.5.0", + "version": "1.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 35f80dd0d..5af480cf0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.5.0", + "version": "1.6.0", "author": "Charlie Robbins ", "contributors": [ { From ca892396c8c7865f3717a5ca5e57dea60ad91516 Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Thu, 3 Jan 2019 18:01:56 -0500 Subject: [PATCH 445/460] Native s3 upload (#645) * Amazon storage use native aws-sdk for uploads (#553) * get rid off thirdparty s3-upload-stream package and use native aws-sdk upload method which supports streams * fix tests for amazon storage client.upload method * amazon storage client.upload() expose managedUpload aws object on returned stream, fixbug with the error event being emited twice, fix tests * in progress * fix storage upload/download tests for large files * update changelog, aws-sdk dependency * rollback development unnecessary changes * fix missing var declaration errors * fix lint errors * fix node 0.10 compatibility issues * call done with err * temporarily skip download/upload large file tests for azure (works for node 6.8 but fails for node 0.10) * amazon file upload documentation * [fix] use send API to cleanup assignment * [dist] update aws-sdk * [dist] update changelog --- CHANGELOG.md | 6 + docs/providers/amazon.md | 26 +++ lib/pkgcloud/amazon/storage/client/files.js | 31 ++-- lib/pkgcloud/amazon/storage/client/index.js | 4 - package-lock.json | 15 +- package.json | 3 +- test/common/storage/base-test.js | 168 +++++++++++++++----- test/common/storage/upload-test.js | 2 +- 8 files changed, 188 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 360a81bc3..6e557764c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## FUTURE + +* Amazon use native `aws-sdk` for `s3` uploads instead of `s3-upload-stream` module +* Update the `aws-sdk` to `2.382.0` +* Amazon storage client.upload - expose concurrency - `queueSize` and `partSize` configurability and add ability to abort an upload + ## v1.3.0 * OpenStack identity v3 (keystone) support, Issue [#367](//github.com/pkgcloud/pkgcloud/issues/367), [#477](//github.com/pkgcloud/pkgcloud/issues/477), PR [#461](//github.com/pkgcloud/pkgcloud/pull/461) * OpenStack cancel client download, Issue [#379](//github.com/pkgcloud/pkgcloud/issues/379), PR [#416](//github.com/pkgcloud/pkgcloud/pull/416) diff --git a/docs/providers/amazon.md b/docs/providers/amazon.md index 0790f8810..e758d4e26 100644 --- a/docs/providers/amazon.md +++ b/docs/providers/amazon.md @@ -26,3 +26,29 @@ var client = require('pkgcloud').storage.createClient({ region: 'us-west-2' // region }); ``` +### File upload + +Whether s3 `multipart-upload` or `putObject` API is used depends on the `partSize` option value and the size of file being uploaded. +Single `putObject` request is made if an object being uploaded is not large enough. if the object size exceeds defined `partSize`, it uses `multipart-upload` API + + +```Javascript +var readableStream = fs.createReadStream('./path/to/file'); + +var writableStream = client.upload({ + queueSize: 1, // == default value + partSize: 5 * 1024 * 1024, // == default value of 5MB + container: 'web-static', + remote: 'image.jpg' +}); + +//writableStream.managedUpload === https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3/ManagedUpload.html +// managedUpload object allows you to abort ongoing upload or track file upload progress. + +readableStream.pipe(writableStream) +.on('success', function(file) { + console.log(file); +}).on('error', function(err) { + console.log(err); +}); +``` diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index f43cc52aa..270b07628 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -52,6 +52,11 @@ exports.upload = function (options) { Key: options.remote instanceof base.File ? options.remote.name : options.remote }; + var s3Settings = { + queueSize: options.queueSize || 1, + partSize: options.partSize || 5 * 1024 * 1024 + }; + if (options.cacheControl) { s3Options.CacheControl = options.cacheControl; } @@ -74,21 +79,25 @@ exports.upload = function (options) { s3Options.ServerSideEncryption = options.ServerSideEncryption; } - var proxyStream = through(), - writableStream = self.s3Stream.upload(s3Options); - + // we need a writable stream because aws-sdk listens for an error event on writable + // stream and redirects it to the provided callback - without the writable stream + // the error would be emitted twice on the returned proxyStream + var writableStream = through(); // we need a proxy stream so we can always return a file model // via the 'success' event - writableStream.on('uploaded', function(details) { - proxyStream.emit('success', new storage.File(self, details)); - }); + var proxyStream = through(); - writableStream.on('error', function(err) { - proxyStream.emit('error', err); - }); + s3Options.Body = writableStream; + + var managedUpload = self.s3.upload(s3Options, s3Settings); + + proxyStream.managedUpload = managedUpload; - writableStream.on('data', function (chunk) { - proxyStream.emit('data', chunk); + managedUpload.send(function(err, data) { + if (err) { + return proxyStream.emit('error', err); + } + return proxyStream.emit('success', new storage.File(self, data)); }); proxyStream.pipe(writableStream); diff --git a/lib/pkgcloud/amazon/storage/client/index.js b/lib/pkgcloud/amazon/storage/client/index.js index b3d8fd950..f8d7a6e94 100644 --- a/lib/pkgcloud/amazon/storage/client/index.js +++ b/lib/pkgcloud/amazon/storage/client/index.js @@ -7,7 +7,6 @@ var util = require('util'), AWS = require('aws-sdk'), - s3Stream = require('s3-upload-stream'), amazon = require('../../client'), _ = require('lodash'); @@ -18,9 +17,6 @@ var Client = exports.Client = function (options) { _.extend(this, require('./files')); this.s3 = new AWS.S3(this._awsConfig); - - // configure the s3Stream - this.s3Stream = s3Stream(this.s3); }; util.inherits(Client, amazon.Client); diff --git a/package-lock.json b/package-lock.json index 5a2e3a194..571fe57b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,9 +72,9 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "aws-sdk": { - "version": "2.296.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.296.0.tgz", - "integrity": "sha512-Ko76U9N7cr4B4IDUuBqnnH6r+t2WkzydrN0ja8fge+asvuJYavEj/jVq8jjq+yOXfW2KgZ+1uaUDjoV33FAfMQ==", + "version": "2.382.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.382.0.tgz", + "integrity": "sha512-wGjZLYo2ZxGTlj2cHy/0zOfYJKUVBQYG1vpW4Cnbgo3HTtOu906a6tqkiD8QuN0EyEkn7i+wyjSiUFOCh3T/2g==", "requires": { "buffer": "4.9.1", "events": "1.1.1", @@ -561,7 +561,7 @@ }, "events": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" }, "exit": { @@ -2000,11 +2000,6 @@ "throttleit": "^1.0.0" } }, - "s3-upload-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/s3-upload-stream/-/s3-upload-stream-1.0.7.tgz", - "integrity": "sha1-4/gCUxQcVp8QWmKqUMqbRXYOSB0=" - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -2300,7 +2295,7 @@ }, "xmlbuilder": { "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, "xtend": { diff --git a/package.json b/package.json index 5af480cf0..22e1da34c 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ ], "dependencies": { "async": "^2.6.1", - "aws-sdk": "^2.2.43", + "aws-sdk": "^2.382.0", "errs": "^0.3.2", "eventemitter2": "^5.0.1", "fast-json-patch": "0.5.x", @@ -69,7 +69,6 @@ "mime": "1.4.1", "qs": "^6.5.2", "request": "^2.88.0", - "s3-upload-stream": "~1.0.7", "through2": "0.6.x", "url-join": "0.0.x", "xml2js": "0.1.x" diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 079af1c41..2ac11617b 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -22,12 +22,14 @@ var fs = require('fs'), File = require('../../../lib/pkgcloud/core/storage/file').File, mock = !!process.env.MOCK, pkgcloud = require('../../../lib/pkgcloud'), - fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'); + fillerama = fs.readFileSync(helpers.fixturePath('fillerama.txt'), 'utf8'), + bigFillerama = fs.readFileSync(helpers.fixturePath('bigfile.raw')); // Declaring variables for helper functions defined later var setupCreateContainerMock, setupGetContainersMock, setupUploadStreamMock, - setupDownloadStreamMock, setupGetFileMock, setupGetFilesMock, - setupRemoveFileMock, setupDestroyContainerMock, setupGetContainers2Mock; + setupBigDataUploadStreamMock, setupDownloadStreamMock, setupBigDataDownloadStreamMock, setupGetFileMock, + setupGetFilesMock, setupRemoveFileMock, setupDestroyContainerMock, + setupGetContainers2Mock; providers.filter(function (provider) { return !!helpers.pkgcloud.providers[provider].storage; @@ -289,67 +291,88 @@ providers.filter(function (provider) { it('the upload() method with large file should succeed', function (done) { if (mock) { - return done(); - // TODO mock these out + //TODO make it work for google + //TODO make it work for azure - no idea why it fails on node 0.10 (it passes for node 6.8) + if (['google', 'azure'].indexOf(provider) !== -1) { + return done(); + } + setupBigDataUploadStreamMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); } var stream = client.upload({ container: context.container, - remote: 'bigfile.raw' - }, function (err, ok) { - should.not.exist(err); - should.exist(ok); + remote: 'bigfile.raw', + headers: {'x-amz-acl': 'public-read'} + }); - context.file = { + stream.on('error', function(err) { + done(err); + }); + + stream.on('success', function(file) { + authHockInstance && authHockInstance.done(); + hockInstance && hockInstance.done(); + file.should.be.an.instanceof(File); + + context.bigFile = { name: 'bigfile.raw', - size: fs.readFileSync(helpers.fixturePath('bigfile.raw')).length + size: bigFillerama.length }; done(); }); - var file = fs.createReadStream(helpers.fixturePath('bigfile.raw')); + var file = fs.createReadStream(helpers.fixturePath('bigfile.raw'), {encoding: 'ascii'}); file.pipe(stream); }); it('the download() method with large file should succeed', function (done) { if (mock) { - return done(); - // TODO mock these out + //TODO make it work for google + //TODO make it work for azure - no idea why it fails on node 0.10 (it passes for node 6.8) + if (['google', 'azure'].indexOf(provider) !== -1) { + return done(); + } + setupBigDataDownloadStreamMock(provider, client, { + server: hockInstance, + authServer: authHockInstance + }); } var stream = client.download({ container: context.container, - remote: context.file.name - }, function (err, file) { + remote: context.bigFile.name + }); - should.not.exist(err); - should.exist(file); - file.should.be.instanceOf(File); + context.fileContents = []; + context.fileContentsSize = 0; + stream.on('data', function (data) { + context.fileContents.push(data); + context.fileContentsSize += data.length; + }); - file.name.should.equal(context.file.name); - file.size.should.equal(context.fileContentsSize); + stream.on('error', function(err) { + return done(err); + }); + + stream.on('end', function() { + hockInstance && hockInstance.done(); context.fileContents = Buffer.concat(context.fileContents, - file.size); + context.fileContentsSize).toString('ascii'); - // Compare byte by byte - var original = fs.readFileSync(helpers.fixturePath('bigfile.raw')); - for (var i = 0; i < file.size; i++) { + //Compare byte by byte + var original = bigFillerama.toString('ascii'); + for (var i = 0; i < original.length; i++) { assert.equal(context.fileContents[i], original[i]); } - done(); - }); - - context.fileContents = []; - context.fileContentsSize = 0; - stream.on('data', function (data) { - context.fileContents.push(data); - context.fileContentsSize += data.length; + return done(); }); - stream.end(); }); it('the destroyContainer() method with container should succeed', function (done) { @@ -584,11 +607,7 @@ setupUploadStreamMock = function (provider, client, servers) { } else if (provider === 'amazon') { servers.server - .post('/test-file.txt?uploads') - .reply(200, '\npkgcloud-test-containertest-file.txtU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) - .put('/test-file.txt?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', fillerama) - .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/test-file.txtpkgcloud-test-containertest-file.txt"b2286fe4aac65809a1b7a053d07fc99f-1"') - .post('/test-file.txt?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1') + .put('/test-file.txt', fillerama) .reply(200); } @@ -610,6 +629,47 @@ setupUploadStreamMock = function (provider, client, servers) { } }; +setupBigDataUploadStreamMock = function (provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .put('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/bigfile.raw', bigFillerama.toString('ascii')) + .reply(200) + .head('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/bigfile.raw?format=json') + .reply(200, '', { 'content-length': bigFillerama.length + 2 }); + } + else if (provider === 'amazon') { + servers.server + .post('/bigfile.raw?uploads') + .reply(200, '\npkgcloud-test-containerbigfile.rawU4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', {}) + .put('/bigfile.raw?partNumber=1&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', bigFillerama.slice(0, 5*1024*1024).toString('ascii')) + .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/bigfile.rawpkgcloud-test-containerbigfile.raw"b2286fe4aac65809a1b7a053d07fc99f-1"') + .put('/bigfile.raw?partNumber=2&uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', bigFillerama.slice(5*1024*1024, 10*1024*1024).toString('ascii')) + .reply(200, '\n\nhttps://pkgcloud-test-container.s3.amazonaws.com/bigfile.rawpkgcloud-test-containerbigfile.raw"b2286fe4aac65809a1b7a053d07fc99f-2"') + .post('/bigfile.raw?uploadId=U4vzbMZVEkBOyxMPHMCu7nRSUw.eNLeqK0oYOPA6BeeiDSu6OTjrsMkkTsOFav3qCpgvIJluGWe_Yi.ypTVxEg--', '"b2286fe4aac65809a1b7a053d07fc99f-1"1"b2286fe4aac65809a1b7a053d07fc99f-2"2') + .reply(200); + } + else if (provider === 'azure') { + servers.server + .put('/pkgcloud-test-container/bigfile.raw?comp=block&blockid=block000000000000000', bigFillerama.slice(0, 4*1024*1024).toString('ascii')) + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) + .put('/pkgcloud-test-container/bigfile.raw?comp=block&blockid=block000000000000001', bigFillerama.slice(4*1024*1024, 8*1024*1024).toString('ascii')) + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) + .put('/pkgcloud-test-container/bigfile.raw?comp=block&blockid=block000000000000002', bigFillerama.slice(8*1024*1024).toString('ascii')) + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'mw0KEVFFwT8SgYGK3Cu8vg=='})) + .put('/pkgcloud-test-container/bigfile.raw?comp=blocklist', 'block000000000000000block000000000000001block000000000000002') + .reply(201, '', helpers.azureResponseHeaders({'content-md5': 'VuFw1xub9CF3KoozbZ3kZw=='})) + .get('/pkgcloud-test-container/bigfile.raw') + .reply(200, bigFillerama.toString('ascii'), helpers.azureGetFileResponseHeaders({'content-length': bigFillerama.length + 2, 'content-type': 'text/plain'})); + } + else if (provider === 'hp') { + servers.server + .put('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/bigfile.raw', bigFillerama.toString('ascii')) + .reply(200) + .head('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/bigfile.raw?format=json') + .reply(200, '', { 'content-length': bigFillerama.length + 2 }); + } +}; + setupDownloadStreamMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server @@ -640,6 +700,36 @@ setupDownloadStreamMock = function (provider, client, servers) { } }; +setupBigDataDownloadStreamMock = function (provider, client, servers) { + if (provider === 'rackspace' || provider === 'openstack') { + servers.server + .get('/v1/MossoCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/bigfile.raw') + .reply(200, bigFillerama.toString('ascii')); + } + else if (provider === 'amazon') { + servers.server + .get('/bigfile.raw') + .reply(200, bigFillerama.toString('ascii')); + } + else if (provider === 'azure') { + servers.server + .get('/pkgcloud-test-container/bigfile.raw') + .reply(200, bigFillerama.toString('ascii'), helpers.azureGetFileResponseHeaders({'content-type': 'text/plain'})); + } + else if (provider === 'google') { + servers.server + .get('/storage/v1/b/pkgcloud-test-container/o/bigfile.raw') + .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) + .get('/mediaLink') + .reply(200, bigFillerama.toString('ascii')); + } + else if (provider === 'hp') { + servers.server + .get('/v1/HPCloudFS_00aa00aa-aa00-aa00-aa00-aa00aa00aa00/pkgcloud-test-container/bigfile.raw') + .reply(200, bigFillerama.toString('ascii')); + } +}; + setupGetFileMock = function (provider, client, servers) { if (provider === 'rackspace' || provider === 'openstack') { servers.server diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index 12cede66a..a2107c03f 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -152,7 +152,7 @@ setupUploadStreamError = function (provider, client, servers) { } else if (provider === 'amazon') { servers.server - .post('/test-file.txt?uploads') + .put('/test-file.txt', 'foo') .reply(400); } else if (provider === 'azure') { From 3566bce36c342f315fb10fe3f11c5c546a955e4b Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Fri, 4 Jan 2019 12:24:34 -0500 Subject: [PATCH 446/460] 1.7.0 --- 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 571fe57b8..b276f6664 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pkgcloud", - "version": "1.6.0", + "version": "1.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 22e1da34c..73b1f9bdf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "An infrastructure-as-a-service agnostic cloud library for node.js", - "version": "1.6.0", + "version": "1.7.0", "author": "Charlie Robbins ", "contributors": [ { From 916fa687c2057625189566d2b0524a79918f56ee Mon Sep 17 00:00:00 2001 From: Kamal Gill Date: Tue, 15 Jan 2019 09:29:22 -0800 Subject: [PATCH 447/460] Correct page title markdown formatting (#646) --- docs/providers/rackspace/compute.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/providers/rackspace/compute.md b/docs/providers/rackspace/compute.md index 2cb5746b5..0a3ae0934 100644 --- a/docs/providers/rackspace/compute.md +++ b/docs/providers/rackspace/compute.md @@ -1,4 +1,4 @@ -##Using the Rackspace Compute provider +## Using the Rackspace Compute provider As of the `v0.8` release of `pkgcloud`, the Compute provider uses Next Generation Cloud Servers, meaning you'll need to use a version <=0.7.x to use First Generation Cloud Servers. @@ -163,4 +163,4 @@ Attaches the provided `volume` to the `server`. `volume` may either be the `volu Detaches the provided `attachment` from the server. `attachment` may either be the `attachmentId` or an object with `attachmentId` as a property. If the `volume` is mounted this call will return an err. -`f(err)` \ No newline at end of file +`f(err)` From ce4382f95b13dc115e12a0ff039e5f8a5e807e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Felipe?= Date: Mon, 4 Feb 2019 19:43:42 -0300 Subject: [PATCH 448/460] Issue 526 Fixed * this.protocol from client instance is used as the URL protocol as it should be --- lib/pkgcloud/azure/storage/client/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkgcloud/azure/storage/client/index.js b/lib/pkgcloud/azure/storage/client/index.js index 4a62384ab..b6cf02b98 100644 --- a/lib/pkgcloud/azure/storage/client/index.js +++ b/lib/pkgcloud/azure/storage/client/index.js @@ -58,6 +58,6 @@ Client.prototype._getUrl = function (options) { } - return urlJoin('http://' + this.azureKeys.storageAccount + '.' + this.serversUrl + '/', + return urlJoin(this.protocol + this.azureKeys.storageAccount + '.' + this.serversUrl + '/', fragment); }; From 44e08a0063252829cdb5e9a8b430c2f4c08b91ad Mon Sep 17 00:00:00 2001 From: Kamal Gill Date: Tue, 15 Jan 2019 10:28:14 -0800 Subject: [PATCH 449/460] Documentation fixes * Fix broken links to databases.md * Replace Openstack with OpenStack * Fix page title markdown formatting --- docs/README.md | 6 +++--- docs/providers/compute-commonality.md | 4 ++-- docs/providers/hp/compute.md | 4 ++-- docs/providers/hp/databases.md | 2 +- docs/providers/hp/network.md | 6 +++--- docs/providers/openstack/README.md | 8 ++++---- docs/providers/openstack/blockstorage.md | 8 ++++---- docs/providers/openstack/cdn.md | 2 +- docs/providers/openstack/compute.md | 6 +++--- docs/providers/openstack/databases.md | 4 ++-- .../openstack/getting-started-compute.md | 8 ++++---- docs/providers/openstack/network.md | 16 ++++++++-------- docs/providers/openstack/orchestration.md | 4 ++-- docs/providers/openstack/storage.md | 8 ++++---- docs/providers/rackspace/blockstorage.md | 2 +- docs/providers/rackspace/cdn.md | 2 +- docs/providers/rackspace/databases.md | 2 +- docs/providers/rackspace/loadbalancer.md | 2 +- docs/providers/rackspace/network.md | 4 ++-- docs/providers/rackspace/orchestration.md | 2 +- docs/providers/rackspace/storage.md | 2 +- 21 files changed, 51 insertions(+), 51 deletions(-) diff --git a/docs/README.md b/docs/README.md index 855f78407..2d2a4bfe0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,11 +30,11 @@ If a service does not have at least two providers, it is considered a *beta* int * [Openstack](providers/openstack/storage.md) * [Rackspace](providers/rackspace/storage.md) * **Databases** - * [HP](providers/hp/database.md) + * [HP](providers/hp/databases.md) * [IrisCouch](providers/iriscouch.md) * [MongoLab](providers/mongolab.md) - * [Openstack](providers/openstack/database.md) - * [Rackspace](providers/rackspace/database.md) + * [Openstack](providers/openstack/databases.md) + * [Rackspace](providers/rackspace/databases.md) * [MongoHQ](providers/mongohq.md) * [RedisToGo](providers/redistogo.md) * **DNS** *(beta)* diff --git a/docs/providers/compute-commonality.md b/docs/providers/compute-commonality.md index 08820ff98..73ab5ff78 100644 --- a/docs/providers/compute-commonality.md +++ b/docs/providers/compute-commonality.md @@ -8,7 +8,7 @@ The following table outlines the methods that are available on the different com AWS Azure Joyent -Openstack +OpenStack RAX DigitalOcean @@ -44,4 +44,4 @@ The following table outlines the methods that are available on the different com -*Note: There are a few I haven't listed yet that I know exist on Rackspace/Openstack, but I lack the awareness of the other providers.* +*Note: There are a few I haven't listed yet that I know exist on Rackspace/OpenStack, but I lack the awareness of the other providers.* diff --git a/docs/providers/hp/compute.md b/docs/providers/hp/compute.md index 8b4a32261..18982a3a2 100644 --- a/docs/providers/hp/compute.md +++ b/docs/providers/hp/compute.md @@ -1,6 +1,6 @@ ![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) -##Using the HP Helion Cloud Compute provider +## Using the HP Helion Cloud Compute provider Creating a client is straight-forward: @@ -79,7 +79,7 @@ Returns a list of all possible server flavors available in the callback `f(err, flavors)` #### client.getFlavor(flavor, callback) -Returns the specified HP flavor of Openstack Images by ID or flavor +Returns the specified HP flavor of OpenStack Images by ID or flavor object in the callback `f(err, flavor)` **images** diff --git a/docs/providers/hp/databases.md b/docs/providers/hp/databases.md index 5f3b91353..0779c47cb 100644 --- a/docs/providers/hp/databases.md +++ b/docs/providers/hp/databases.md @@ -1,4 +1,4 @@ -##Using the HP Helion Database provider +## Using the HP Helion Database provider Creating a client is straight-forward: diff --git a/docs/providers/hp/network.md b/docs/providers/hp/network.md index 1d39eec70..664c97bf5 100644 --- a/docs/providers/hp/network.md +++ b/docs/providers/hp/network.md @@ -1,6 +1,6 @@ ![HP Helion icon](http://www8.hp.com/hpnext/sites/default/files/content/documents/HP%20Helion%20Logo_Cloud_Martin%20Fink_New%20Style%20of%20IT_Hewlett-Packard.PNG) -##Using the HP Cloud Network provider +## Using the HP Cloud Network provider Creating a client is straight-forward: @@ -177,7 +177,7 @@ Takes port or portId as an argument and returns the id of the destroyed port in **Security Groups** #### client.getSecurityGroups(callback) -Lists all security groups that are available to use on your Openstack account +Lists all security groups that are available to use on your OpenStack account Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` @@ -209,7 +209,7 @@ Takes securityGroup or securityGroupId as an argument and returns the id of the **Security Group Rules** #### client.getSecurityGroupRules(callback) -Lists all security group rules that are available to use on your Openstack account +Lists all security group rules that are available to use on your OpenStack account Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` diff --git a/docs/providers/openstack/README.md b/docs/providers/openstack/README.md index 13d5629a3..8a21a7ceb 100644 --- a/docs/providers/openstack/README.md +++ b/docs/providers/openstack/README.md @@ -1,4 +1,4 @@ -## Using the Openstack provider in pkgcloud +## Using the OpenStack provider in pkgcloud The OpenStack provider in pkgcloud supports the following services: @@ -16,7 +16,7 @@ We've provided a [simple compute example](getting-started-compute.md) where it c ### Authentication -For all of the Openstack services, you create a client with the same options: +For all of the OpenStack services, you create a client with the same options: ```javascript var openstack = pkgcloud.storage.createClient({ @@ -32,7 +32,7 @@ For all of the Openstack services, you create a client with the same options: ### Authentication Endpoints and Regions -All of the Openstack `createClient` calls have a few options that can be provided: +All of the OpenStack `createClient` calls have a few options that can be provided: #### region @@ -52,4 +52,4 @@ var client = require('pkgcloud').compute.createClient({ #### Tokens and Expiration -When you make your first call to a Openstack provider, your client is authenticated transparent to your API call. Openstack will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. +When you make your first call to a OpenStack provider, your client is authenticated transparent to your API call. OpenStack will issue you a token, with an expiration. When that token expires, the client will automatically re-authenticate and retrieve a new token. The caller shouldn't have to worry about this happening. diff --git a/docs/providers/openstack/blockstorage.md b/docs/providers/openstack/blockstorage.md index 60073e582..ee1b43966 100644 --- a/docs/providers/openstack/blockstorage.md +++ b/docs/providers/openstack/blockstorage.md @@ -1,4 +1,4 @@ -##Using the Openstack Block Storage provider +## Using the OpenStack Block Storage provider #### BETA - This API may change as additional providers for block storage are added to pkgcloud @@ -77,7 +77,7 @@ A VolumeType for BlockStorage has the following properties: ### Volume APIs #### client.getVolumes(options, callback) -Lists all volumes that are available to use on your Openstack account +Lists all volumes that are available to use on your OpenStack account Callback returns `f(err, volumes)` where `volumes` is an `Array`. `options` is an optional `boolean` which will return the full volume details if true. @@ -116,7 +116,7 @@ Returns callback with a confirmation ### Snapshot APIs #### client.getSnapshots(options, callback) -Lists all snapshots that are available to use on your Openstack account +Lists all snapshots that are available to use on your OpenStack account Callback returns `f(err, snapshots)` where `snapshots` is an `Array`. `options` is an optional `boolean` which will return the full snapshot details if true. @@ -156,7 +156,7 @@ Returns callback with a confirmation Volume types are used to define which kind of new volume to create. #### client.getVolumeTypes(callback) -Lists all volumeTypes that are available to use on your Openstack account +Lists all volumeTypes that are available to use on your OpenStack account Callback returns `f(err, volumeTypes)` where `volumeTypes` is an `Array`. diff --git a/docs/providers/openstack/cdn.md b/docs/providers/openstack/cdn.md index 62bf2764d..1c8936c46 100644 --- a/docs/providers/openstack/cdn.md +++ b/docs/providers/openstack/cdn.md @@ -1,4 +1,4 @@ -##Using the Openstack CDN provider +## Using the OpenStack CDN provider Creating a client is straight-forward: diff --git a/docs/providers/openstack/compute.md b/docs/providers/openstack/compute.md index d687f9530..fc428c76d 100644 --- a/docs/providers/openstack/compute.md +++ b/docs/providers/openstack/compute.md @@ -1,4 +1,4 @@ -##Using the Openstack Compute provider +##Using the OpenStack Compute provider Creating a client is straight-forward: @@ -20,7 +20,7 @@ Creating a client is straight-forward: **Servers** #### client.getServers(callback) -Lists all servers that are available to use on your Openstack account +Lists all servers that are available to use on your OpenStack account Callback returns `f(err, servers)` where `servers` is an `Array` @@ -99,7 +99,7 @@ Returns a list of all possible server flavors available in the callback `f(err, flavors)` #### client.getFlavor(flavor, callback) -Returns the specified flavor of Openstack Images by ID or flavor +Returns the specified flavor of OpenStack Images by ID or flavor object in the callback `f(err, flavor)` **images** diff --git a/docs/providers/openstack/databases.md b/docs/providers/openstack/databases.md index 3669ea150..1c5cd768f 100644 --- a/docs/providers/openstack/databases.md +++ b/docs/providers/openstack/databases.md @@ -1,4 +1,4 @@ -##Using the Openstack Database provider +## Using the OpenStack Database provider Creating a client is straight-forward: @@ -15,7 +15,7 @@ Creating a client is straight-forward: ### Creating a MySQL Database -The steps for provision a MySQL database from Openstack cloud databases are: +The steps for provision a MySQL database from OpenStack cloud databases are: 1. Choose a flavor (memory RAM size) 2. Create an instance of a database server. diff --git a/docs/providers/openstack/getting-started-compute.md b/docs/providers/openstack/getting-started-compute.md index fea7f9ddd..bad2400f1 100644 --- a/docs/providers/openstack/getting-started-compute.md +++ b/docs/providers/openstack/getting-started-compute.md @@ -1,8 +1,8 @@ -# Getting started with pkgcloud & Openstack +# Getting started with pkgcloud & OpenStack -The Openstack node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package +The OpenStack node.js SDK is available as part of `pkgcloud`, a multi-provider cloud provisioning package -Pkgcloud currently supports Openstack Nova (compute) and Openstack Swift (storage). +Pkgcloud currently supports OpenStack Nova (compute) and OpenStack Swift (storage). To install `pkgcloud` from the command line: @@ -14,7 +14,7 @@ Don't have `npm` or `node` yet? [Get it now](http://nodejs.org/download). ## Using pkgcloud -In this example, we're going to create a Openstack compute client, create two servers, and then output their details to the command line. +In this example, we're going to create a OpenStack compute client, create two servers, and then output their details to the command line. *Note: We're going to use [lodash.js](https://lodash.com) for some convenience functions.* *Note: For DevStack, change AuthUrl to http://:5000* diff --git a/docs/providers/openstack/network.md b/docs/providers/openstack/network.md index 2716113f9..3df2a0b58 100644 --- a/docs/providers/openstack/network.md +++ b/docs/providers/openstack/network.md @@ -1,4 +1,4 @@ -##Using the Openstack Network provider +##Using the OpenStack Network provider Creating a client is straight-forward: @@ -18,7 +18,7 @@ Creating a client is straight-forward: **Networks** #### client.getNetworks(callback) -Lists all networks that are available to use on your Openstack account +Lists all networks that are available to use on your OpenStack account Callback returns `f(err, networks)` where `networks` is an `Array` @@ -67,7 +67,7 @@ Takes network or networkId as an argument and returns the id of the destroyed n **Subnets** #### client.getSubnets(callback) -Lists all subnets that are available to use on your Openstack account +Lists all subnets that are available to use on your OpenStack account Callback returns `f(err, subnets)` where `subnets` is an `Array` @@ -120,7 +120,7 @@ Takes subnet or subnetId as an argument and returns the id of the destroyed sub **Ports** #### client.getPorts(callback) -Lists all ports that are available to use on your Openstack account +Lists all ports that are available to use on your OpenStack account Callback returns `f(err, ports)` where `ports` is an `Array` @@ -177,7 +177,7 @@ Takes port or portId as an argument and returns the id of the destroyed port in **Security Groups** #### client.getSecurityGroups(callback) -Lists all security groups that are available to use on your Openstack account +Lists all security groups that are available to use on your OpenStack account Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` @@ -209,7 +209,7 @@ Takes securityGroup or securityGroupId as an argument and returns the id of the **Security Group Rules** #### client.getSecurityGroupRules(callback) -Lists all security group rules that are available to use on your Openstack account +Lists all security group rules that are available to use on your OpenStack account Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` @@ -247,7 +247,7 @@ Takes securityGroupRule or securityGroupRuleId as an argument and returns the i **Security Groups** #### client.getSecurityGroups(callback) -Lists all security groups that are available to use on your Openstack account +Lists all security groups that are available to use on your OpenStack account Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` @@ -279,7 +279,7 @@ Takes securityGroup or securityGroupId as an argument and returns the id of the **Security Group Rules** #### client.getSecurityGroupRules(callback) -Lists all security group rules that are available to use on your Openstack account +Lists all security group rules that are available to use on your OpenStack account Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` diff --git a/docs/providers/openstack/orchestration.md b/docs/providers/openstack/orchestration.md index 36f7118ba..1d3f2de1a 100644 --- a/docs/providers/openstack/orchestration.md +++ b/docs/providers/openstack/orchestration.md @@ -1,4 +1,4 @@ -##Using the Openstack Orchestration provider +##Using the OpenStack Orchestration provider Creating a client is straight-forward: @@ -20,7 +20,7 @@ Creating a client is straight-forward: ## Stacks #### client.getStacks([options], callback) -Lists all stacks that are available to use on your Openstack account +Lists all stacks that are available to use on your OpenStack account Callback returns `f(err, stacks)` where `stacks` is an `Array` diff --git a/docs/providers/openstack/storage.md b/docs/providers/openstack/storage.md index 6ff53d136..14c322a6b 100644 --- a/docs/providers/openstack/storage.md +++ b/docs/providers/openstack/storage.md @@ -1,4 +1,4 @@ -## Using the Openstack Storage provider +## Using the OpenStack Storage provider * Container * [Model](#container-model) @@ -20,11 +20,11 @@ Creating a client is straight-forward: **Note:** *Due to variances between OpenStack deployments, you may or may not need a `region` option.* -Learn about [more options for creating clients](README.md) in the Openstack `storage` provider. +Learn about [more options for creating clients](README.md) in the OpenStack `storage` provider. ### Container Model -A Container for Openstack has following properties: +A Container for OpenStack has following properties: ```Javascript { @@ -39,7 +39,7 @@ A Container for Openstack has following properties: ### File Model -A File for Openstack has the following properties: +A File for OpenStack has the following properties: ```Javascript { diff --git a/docs/providers/rackspace/blockstorage.md b/docs/providers/rackspace/blockstorage.md index f1dc0b70c..32ff08808 100644 --- a/docs/providers/rackspace/blockstorage.md +++ b/docs/providers/rackspace/blockstorage.md @@ -1,4 +1,4 @@ -##Using the Rackspace Block Storage provider +## Using the Rackspace Block Storage provider #### BETA - This API may change as additional providers for block storage are added to pkgcloud diff --git a/docs/providers/rackspace/cdn.md b/docs/providers/rackspace/cdn.md index 271cd22d4..9596a4b86 100644 --- a/docs/providers/rackspace/cdn.md +++ b/docs/providers/rackspace/cdn.md @@ -1,4 +1,4 @@ -##Using the Rackspace CDN provider +## Using the Rackspace CDN provider Creating a client is straight-forward: diff --git a/docs/providers/rackspace/databases.md b/docs/providers/rackspace/databases.md index 345347851..abe0c35a2 100644 --- a/docs/providers/rackspace/databases.md +++ b/docs/providers/rackspace/databases.md @@ -1,4 +1,4 @@ -##Using the Rackspace Database provider +## Using the Rackspace Database provider Creating a client is straight-forward: diff --git a/docs/providers/rackspace/loadbalancer.md b/docs/providers/rackspace/loadbalancer.md index 1c045062f..b02a18c1b 100644 --- a/docs/providers/rackspace/loadbalancer.md +++ b/docs/providers/rackspace/loadbalancer.md @@ -1,4 +1,4 @@ -##Using the Rackspace Load Balancer provider +## Using the Rackspace Load Balancer provider #### BETA - This API may change as additional providers for load balancers are added to pkgcloud diff --git a/docs/providers/rackspace/network.md b/docs/providers/rackspace/network.md index e7b7592ad..104d1cb6c 100644 --- a/docs/providers/rackspace/network.md +++ b/docs/providers/rackspace/network.md @@ -179,7 +179,7 @@ Takes port or portId as an argument and returns the id of the destroyed port in **Security Groups** #### client.getSecurityGroups(callback) -Lists all security groups that are available to use on your Openstack account +Lists all security groups that are available to use on your OpenStack account Callback returns `f(err, securityGroups)` where `securityGroups` is an `Array` @@ -211,7 +211,7 @@ Takes securityGroup or securityGroupId as an argument and returns the id of the **Security Group Rules** #### client.getSecurityGroupRules(callback) -Lists all security group rules that are available to use on your Openstack account +Lists all security group rules that are available to use on your OpenStack account Callback returns `f(err, securityGroupRules)` where `securityGroupRules` is an `Array` diff --git a/docs/providers/rackspace/orchestration.md b/docs/providers/rackspace/orchestration.md index 2b43f65f6..9bb9c37b1 100644 --- a/docs/providers/rackspace/orchestration.md +++ b/docs/providers/rackspace/orchestration.md @@ -1,4 +1,4 @@ -##Using the Rackspace Orchestration provider +## Using the Rackspace Orchestration provider Creating a client is straight-forward: diff --git a/docs/providers/rackspace/storage.md b/docs/providers/rackspace/storage.md index 645a948d9..fc5b935c9 100644 --- a/docs/providers/rackspace/storage.md +++ b/docs/providers/rackspace/storage.md @@ -20,7 +20,7 @@ Creating a client is straight-forward: }); ``` -Learn about [more options for creating clients](README.md) in the Openstack `storage` provider. `region` parameter can be any [Rackspace Region](http://www.rackspace.com/about/datacenters/). +Learn about [more options for creating clients](README.md) in the OpenStack `storage` provider. `region` parameter can be any [Rackspace Region](http://www.rackspace.com/about/datacenters/). ### Container Model From e89f0468d83920670c2253044efaed6ded30324f Mon Sep 17 00:00:00 2001 From: Charlie Robbins Date: Fri, 12 Apr 2019 17:11:16 -0400 Subject: [PATCH 450/460] [BREAKING] Drop all legacy providers. (#652) * [breaking] Drop all legacy providers. * [fix refactor] Finish removal of legacy providers. --- README.md | 32 +- docs/README.md | 103 ++-- docs/providers/iriscouch.md | 71 --- docs/providers/joyent.md | 33 -- docs/providers/mongohq.md | 39 -- docs/providers/mongolab.md | 69 --- docs/providers/redistogo.md | 43 -- examples/compute/joyent.js | 45 -- examples/database/iriscouch.js | 47 -- examples/database/mongohq.js | 30 -- examples/database/mongolab.js | 0 examples/database/redistogo.js | 35 -- lib/pkgcloud.js | 6 - .../iriscouch/database/client/index.js | 191 -------- lib/pkgcloud/iriscouch/database/index.js | 12 - lib/pkgcloud/iriscouch/index.js | 8 - lib/pkgcloud/joyent/client.js | 115 ----- lib/pkgcloud/joyent/compute/client/flavors.js | 55 --- lib/pkgcloud/joyent/compute/client/images.js | 86 ---- lib/pkgcloud/joyent/compute/client/index.js | 34 -- lib/pkgcloud/joyent/compute/client/keys.js | 87 ---- lib/pkgcloud/joyent/compute/client/servers.js | 272 ----------- lib/pkgcloud/joyent/compute/flavor.js | 29 -- lib/pkgcloud/joyent/compute/image.js | 34 -- lib/pkgcloud/joyent/compute/index.js | 15 - lib/pkgcloud/joyent/compute/server.js | 67 --- lib/pkgcloud/joyent/index.js | 8 - .../mongohq/database/client/databases.js | 102 ---- lib/pkgcloud/mongohq/database/client/index.js | 58 --- lib/pkgcloud/mongohq/database/index.js | 12 - lib/pkgcloud/mongohq/index.js | 8 - .../mongolab/database/client/accounts.js | 116 ----- .../mongolab/database/client/databases.js | 190 -------- .../mongolab/database/client/index.js | 71 --- lib/pkgcloud/mongolab/database/index.js | 12 - lib/pkgcloud/mongolab/index.js | 8 - .../redistogo/database/client/index.js | 144 ------ lib/pkgcloud/redistogo/database/index.js | 12 - lib/pkgcloud/redistogo/index.js | 8 - lib/pkgcloud/telefonica/compute/client.js | 30 -- lib/pkgcloud/telefonica/compute/index.js | 15 - lib/pkgcloud/telefonica/index.js | 8 - package.json | 6 - test/common/compute/base-test.js | 35 +- test/common/compute/server-test.js | 30 -- test/common/storage/base-test.js | 55 +-- test/common/storage/upload-test.js | 6 - test/configs/mock/iriscouch.json | 6 - test/configs/mock/joyent.json | 6 - test/configs/mock/mongohq.json | 6 - test/configs/mock/mongolab.json | 7 - test/configs/mock/redistogo.json | 5 - test/configs/providers.json | 2 +- test/fixtures/iriscouch/database-redis.json | 1 - test/fixtures/iriscouch/database.json | 1 - test/fixtures/joyent/14186c17.json | 3 - test/fixtures/joyent/createServer.json | 1 - test/fixtures/joyent/createdServer.json | 18 - test/fixtures/joyent/fe4d8e28.json | 1 - test/fixtures/joyent/flavor.json | 7 - test/fixtures/joyent/flavors.json | 72 --- test/fixtures/joyent/image.json | 12 - test/fixtures/joyent/images.json | 350 -------------- .../fixtures/joyent/rebootServerRequest1.json | 1 - .../joyent/rebootServerResponse1.json | 1 - test/fixtures/joyent/servers.json | 20 - test/fixtures/joyent/setWait.json | 1 - test/fixtures/joyent/setWaitResp1.json | 1 - test/fixtures/mongohq/database.json | 1 - test/fixtures/mongolab/customUser.json | 1 - test/fixtures/mongolab/database.json | 1 - test/fixtures/mongolab/reqDatabase.json | 1 - test/fixtures/mongolab/user.json | 1 - test/fixtures/mongolab/userList.json | 1 - test/fixtures/redistogo/database.json | 1 - test/fixtures/versions.json | 2 +- test/helpers/index.js | 33 +- .../databases/databases-redis-test.js | 135 ------ test/iriscouch/databases/databases-test.js | 126 ----- test/mongohq/databases/databases-test.js | 108 ----- test/mongolab/databases/databases-test.js | 445 ------------------ test/redistogo/databases/databases-test.js | 131 ------ 82 files changed, 66 insertions(+), 3935 deletions(-) delete mode 100644 docs/providers/iriscouch.md delete mode 100644 docs/providers/joyent.md delete mode 100644 docs/providers/mongohq.md delete mode 100644 docs/providers/mongolab.md delete mode 100644 docs/providers/redistogo.md delete mode 100644 examples/compute/joyent.js delete mode 100644 examples/database/iriscouch.js delete mode 100644 examples/database/mongohq.js delete mode 100644 examples/database/mongolab.js delete mode 100644 examples/database/redistogo.js delete mode 100644 lib/pkgcloud/iriscouch/database/client/index.js delete mode 100644 lib/pkgcloud/iriscouch/database/index.js delete mode 100644 lib/pkgcloud/iriscouch/index.js delete mode 100644 lib/pkgcloud/joyent/client.js delete mode 100644 lib/pkgcloud/joyent/compute/client/flavors.js delete mode 100644 lib/pkgcloud/joyent/compute/client/images.js delete mode 100644 lib/pkgcloud/joyent/compute/client/index.js delete mode 100644 lib/pkgcloud/joyent/compute/client/keys.js delete mode 100644 lib/pkgcloud/joyent/compute/client/servers.js delete mode 100644 lib/pkgcloud/joyent/compute/flavor.js delete mode 100644 lib/pkgcloud/joyent/compute/image.js delete mode 100644 lib/pkgcloud/joyent/compute/index.js delete mode 100644 lib/pkgcloud/joyent/compute/server.js delete mode 100644 lib/pkgcloud/joyent/index.js delete mode 100644 lib/pkgcloud/mongohq/database/client/databases.js delete mode 100644 lib/pkgcloud/mongohq/database/client/index.js delete mode 100644 lib/pkgcloud/mongohq/database/index.js delete mode 100644 lib/pkgcloud/mongohq/index.js delete mode 100644 lib/pkgcloud/mongolab/database/client/accounts.js delete mode 100644 lib/pkgcloud/mongolab/database/client/databases.js delete mode 100644 lib/pkgcloud/mongolab/database/client/index.js delete mode 100644 lib/pkgcloud/mongolab/database/index.js delete mode 100644 lib/pkgcloud/mongolab/index.js delete mode 100644 lib/pkgcloud/redistogo/database/client/index.js delete mode 100644 lib/pkgcloud/redistogo/database/index.js delete mode 100644 lib/pkgcloud/redistogo/index.js delete mode 100644 lib/pkgcloud/telefonica/compute/client.js delete mode 100644 lib/pkgcloud/telefonica/compute/index.js delete mode 100644 lib/pkgcloud/telefonica/index.js delete mode 100644 test/configs/mock/iriscouch.json delete mode 100644 test/configs/mock/joyent.json delete mode 100644 test/configs/mock/mongohq.json delete mode 100644 test/configs/mock/mongolab.json delete mode 100644 test/configs/mock/redistogo.json delete mode 100644 test/fixtures/iriscouch/database-redis.json delete mode 100644 test/fixtures/iriscouch/database.json delete mode 100644 test/fixtures/joyent/14186c17.json delete mode 100644 test/fixtures/joyent/createServer.json delete mode 100644 test/fixtures/joyent/createdServer.json delete mode 100644 test/fixtures/joyent/fe4d8e28.json delete mode 100644 test/fixtures/joyent/flavor.json delete mode 100644 test/fixtures/joyent/flavors.json delete mode 100644 test/fixtures/joyent/image.json delete mode 100644 test/fixtures/joyent/images.json delete mode 100644 test/fixtures/joyent/rebootServerRequest1.json delete mode 100644 test/fixtures/joyent/rebootServerResponse1.json delete mode 100644 test/fixtures/joyent/servers.json delete mode 100644 test/fixtures/joyent/setWait.json delete mode 100644 test/fixtures/joyent/setWaitResp1.json delete mode 100644 test/fixtures/mongohq/database.json delete mode 100644 test/fixtures/mongolab/customUser.json delete mode 100644 test/fixtures/mongolab/database.json delete mode 100644 test/fixtures/mongolab/reqDatabase.json delete mode 100644 test/fixtures/mongolab/user.json delete mode 100644 test/fixtures/mongolab/userList.json delete mode 100644 test/fixtures/redistogo/database.json delete mode 100644 test/iriscouch/databases/databases-redis-test.js delete mode 100644 test/iriscouch/databases/databases-test.js delete mode 100644 test/mongohq/databases/databases-test.js delete mode 100644 test/mongolab/databases/databases-test.js delete mode 100644 test/redistogo/databases/databases-test.js diff --git a/README.md b/README.md index 26656db30..5f3d0317e 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Services provided by `pkgcloud` are exposed in two ways: ``` js var client = require('pkgcloud').compute.createClient({ // - // The name of the provider (e.g. "joyent") + // The name of the provider (e.g. "openstack") // provider: 'provider-name', @@ -88,7 +88,7 @@ Services provided by `pkgcloud` are exposed in two ways: * **By provider name:** For example, if you knew the name of the provider you wished to communicate with you could do so directly: ``` js - var client = require('pkgcloud').providers.joyent.compute.createClient({ + var client = require('pkgcloud').providers.openstack.compute.createClient({ // // ... Provider specific credentials // @@ -120,7 +120,6 @@ If a service does not have at least two providers, it is considered a *beta* int * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) * [HP](docs/providers/hp/compute.md) - * [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) * **[Storage](#storage)** @@ -131,11 +130,7 @@ If a service does not have at least two providers, it is considered a *beta* int * [Openstack](docs/providers/openstack/storage.md) * [Rackspace](docs/providers/rackspace/storage.md) * **[Database](#databases)** - * [IrisCouch](docs/providers/iriscouch.md) - * [MongoLab](docs/providers/mongolab.md) * [Rackspace](docs/providers/rackspace/database.md) - * [MongoHQ](docs/providers/mongohq.md) - * [RedisToGo](docs/providers/redistogo.md) * **[DNS](#dns----beta)** *(beta)* * [Rackspace](docs/providers/rackspace/dns.md) * **[Block Storage](#block-storage----beta)** *(beta)* @@ -161,7 +156,7 @@ The `pkgcloud.compute` service is designed to make it easy to provision and work ``` js var client = require('pkgcloud').compute.createClient({ // - // The name of the provider (e.g. "joyent") + // The name of the provider (e.g. "openstack") // provider: 'provider-name', @@ -177,7 +172,6 @@ Each compute provider takes different credentials to authenticate; these details * [Azure](docs/providers/azure.md#using-compute) * [DigitalOcean](docs/providers/digitalocean.md#using-compute) * [HP](docs/providers/hp/compute.md) -* [Joyent](docs/providers/joyent.md#using-compute) * [Openstack](docs/providers/openstack/compute.md) * [Rackspace](docs/providers/rackspace/compute.md) @@ -209,7 +203,7 @@ To get started with a `pkgcloud.storage` client just create one: ``` js var client = require('pkgcloud').storage.createClient({ // - // The name of the provider (e.g. "joyent") + // The name of the provider (e.g. "openstack") // provider: 'provider-name', @@ -291,7 +285,7 @@ To get started with a `pkgcloud.storage` client just create one: ``` js var client = require('pkgcloud').database.createClient({ // - // The name of the provider (e.g. "joyent") + // The name of the provider (e.g. "openstack") // provider: 'provider-name', @@ -303,14 +297,6 @@ To get started with a `pkgcloud.storage` client just create one: Each database provider takes different credentials to authenticate; these details about each specific provider can be found below: -* **CouchDB** - * [IrisCouch](docs/providers/iriscouch.md#couchdb) -* **MongoDB** - * [MongoLab](docs/providers/mongolab.md) - * [MongoHQ](docs/providers/mongohq.md) -* **Redis** - * [IrisCouch](docs/providers/iriscouch.md#redis) - * [RedisToGo](docs/providers/redistogo.md) * **MySQL** * [Rackspace](docs/providers/rackspace/databases.md) * **Azure Tables** @@ -658,16 +644,16 @@ Even better, you can run the tests for some specific provider: ``` bash Linux/Mac - Mocha installed globally: - $ MOCK=on mocha -R spec test/iriscouch/*/*-test.js + $ MOCK=on mocha -R spec test/openstack/*/*-test.js Linux/Mac - Mocha installed locally: - $ MOCK=on ./node_modules/.bin/mocha -R spec test/iriscouch/*/*-test.js + $ MOCK=on ./node_modules/.bin/mocha -R spec test/openstack/*/*-test.js Windows - Mocha installed globally: - $ set MOCK=on&mocha -R spec test/iriscouch/*/*-test.js + $ set MOCK=on&mocha -R spec test/openstack/*/*-test.js Windows - Mocha installed locally: - $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/iriscouch/*/*-test.js + $ set MOCK=on&node_modules\.bin\mocha.cmd -R spec test/openstack/*/*-test.js ``` diff --git a/docs/README.md b/docs/README.md index 2d2a4bfe0..092debdfb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,54 +1,49 @@ -## pkgcloud documentation - -pkgcloud is a multi-provider cloud provisioning library for node.js that abstracts away differences among multiple cloud providers. - -### Unified Vocabulary - -Due to the differences between the vocabulary for each service provider, **[pkgcloud uses its own unified vocabulary](vocabulary.md).** - -**Note:** Unified vocabularies may not yet be defined for *beta* services. - -### Supported Providers - -Supporting every API for every cloud service provider in Node.js is a huge undertaking, but _that is the long-term goal of `pkgcloud`_. **Special attention has been made to ensure that each service type has enough providers for a critical mass of portability between providers** (i.e. Each service implemented has multiple providers). - -If a service does not have at least two providers, it is considered a *beta* interface; We reserve the right to improve the API as multiple providers will allow generalization to be better determined. - -* **Compute** [*Compute Client Commonality*](providers/compute-commonality.md) - * [Amazon](providers/amazon.md#using-compute) - * [Azure](providers/azure.md#using-compute) - * [DigitalOcean](providers/digitalocean.md#using-compute) - * [HP](providers/hp/compute.md) - * [Joyent](providers/joyent.md#using-compute) - * [Openstack](providers/openstack/compute.md) - * [Rackspace](providers/rackspace/compute.md) - * [1&1 Oneandone](providers/oneandone/compute.md) -* **Storage** - * [Amazon](providers/amazon.md#using-storage) - * [Azure](providers/azure.md#using-storage) - * [HP](providers/hp/storage.md) - * [Openstack](providers/openstack/storage.md) - * [Rackspace](providers/rackspace/storage.md) -* **Databases** - * [HP](providers/hp/databases.md) - * [IrisCouch](providers/iriscouch.md) - * [MongoLab](providers/mongolab.md) - * [Openstack](providers/openstack/databases.md) - * [Rackspace](providers/rackspace/databases.md) - * [MongoHQ](providers/mongohq.md) - * [RedisToGo](providers/redistogo.md) -* **DNS** *(beta)* - * [Rackspace](providers/rackspace/dns.md) -* **Block Storage** *(beta)* - * [Rackspace](providers/rackspace/blockstorage.md) - * [Openstack](providers/openstack/blockstorage.md) - * [1&1 Oneandone](providers/oneandone/blockstorage.md) -* **Orchestration** *(beta)* - * [Rackspace](providers/rackspace/orchestration.md) - * [Openstack](providers/openstack/orchestration.md) -* **Load Balancers** *(beta)* - * [Rackspace](providers/rackspace/loadbalancer.md) - * [1&1 Oneandone](providers/oneandone/loadbalancer.md) -* **Networking** *(beta)* - * [Openstack](providers/openstack/network.md) - * [HP](providers/openstack/hp.md) +## pkgcloud documentation + +pkgcloud is a multi-provider cloud provisioning library for node.js that abstracts away differences among multiple cloud providers. + +### Unified Vocabulary + +Due to the differences between the vocabulary for each service provider, **[pkgcloud uses its own unified vocabulary](vocabulary.md).** + +**Note:** Unified vocabularies may not yet be defined for *beta* services. + +### Supported Providers + +Supporting every API for every cloud service provider in Node.js is a huge undertaking, but _that is the long-term goal of `pkgcloud`_. **Special attention has been made to ensure that each service type has enough providers for a critical mass of portability between providers** (i.e. Each service implemented has multiple providers). + +If a service does not have at least two providers, it is considered a *beta* interface; We reserve the right to improve the API as multiple providers will allow generalization to be better determined. + +* **Compute** [*Compute Client Commonality*](providers/compute-commonality.md) + * [Amazon](providers/amazon.md#using-compute) + * [Azure](providers/azure.md#using-compute) + * [DigitalOcean](providers/digitalocean.md#using-compute) + * [HP](providers/hp/compute.md) + * [Openstack](providers/openstack/compute.md) + * [Rackspace](providers/rackspace/compute.md) + * [1&1 Oneandone](providers/oneandone/compute.md) +* **Storage** + * [Amazon](providers/amazon.md#using-storage) + * [Azure](providers/azure.md#using-storage) + * [HP](providers/hp/storage.md) + * [Openstack](providers/openstack/storage.md) + * [Rackspace](providers/rackspace/storage.md) +* **Databases** + * [HP](providers/hp/databases.md) + * [Openstack](providers/openstack/databases.md) + * [Rackspace](providers/rackspace/databases.md) +* **DNS** *(beta)* + * [Rackspace](providers/rackspace/dns.md) +* **Block Storage** *(beta)* + * [Rackspace](providers/rackspace/blockstorage.md) + * [Openstack](providers/openstack/blockstorage.md) + * [1&1 Oneandone](providers/oneandone/blockstorage.md) +* **Orchestration** *(beta)* + * [Rackspace](providers/rackspace/orchestration.md) + * [Openstack](providers/openstack/orchestration.md) +* **Load Balancers** *(beta)* + * [Rackspace](providers/rackspace/loadbalancer.md) + * [1&1 Oneandone](providers/oneandone/loadbalancer.md) +* **Networking** *(beta)* + * [Openstack](providers/openstack/network.md) + * [HP](providers/openstack/hp.md) diff --git a/docs/providers/iriscouch.md b/docs/providers/iriscouch.md deleted file mode 100644 index 8bafdec1e..000000000 --- a/docs/providers/iriscouch.md +++ /dev/null @@ -1,71 +0,0 @@ -# Using IrisCouch with `pkgcloud` - -**In order to use IrisCOuch you will need to have created a valid account.** IrisCouch actually exposes two database services: - -* [Using CouchDB](#couchdb) -* [Using Redis](#redis) -* [All API Methods](#all-api-methods) - - -## Using CouchDB - -``` js -var client = pkgcloud.database.createClient({ - provider: 'iriscouch', - username: 'bob', - password: '1234' -}); - -// -// Create a couch -// -client.create({ - subdomain: 'pkgcloud-nodejitsu-test-7', - first_name: 'pkgcloud', - last_name: 'pkgcloud', - email: 'info@nodejitsu.com' -}, function (err, result) { - // - // Check now exists @ http://pkgcloud-nodejitsu-test-7.iriscouch.com - // - console.log(err, result); -}); -``` - - -## Using Redis - -IrisCouch also supports provisioning redis databases. In this case just pass the option `type: 'redis'` to the `create()` method and put a `password` for the access. - -``` js -// -// Crate a redis database -// -client.create({ - subdomain: 'pkgcloud-nodejitsu-test-7', - first_name: 'pkgcloud', - last_name: 'pkgcloud', - email: 'info@nodejitsu.com', - // - // For redis instead of couch just put type to redis - // - type: 'redis', - // - // AND ADD A PASSWORD! (required) - // - password: 'mys3cur3p4ssw0rd' -}, function (err, result) { - // - // Check the connection, use result.host and result.password values - // redis-cli -h $RESULT.HOST -a $RESULT.PASSWORD - // - console.log('HOST to connect:', result.host); - console.log('KEY to use:', result.password); -}); -``` - -## All API methods - -The `client` instance returned by `pkgcloud.database.createClient` has the following methods for IrisCouch: - -* `client.create(options, callback)` \ No newline at end of file diff --git a/docs/providers/joyent.md b/docs/providers/joyent.md deleted file mode 100644 index 6cd855084..000000000 --- a/docs/providers/joyent.md +++ /dev/null @@ -1,33 +0,0 @@ -# Using Joyent with `pkgcloud` - -* [Using Compute](#using-compute) - - -## Using Compute - -Joyent requires a username / password or key / keyId combo. The key / keyId should be registered in Joyent servers; check `test/helpers/index.js` for details on key/keyId works. - -**key / keyId pair** -``` js - var pkgcloud = require('pkgcloud'), - path = require('path'), - fs = require('fs'); - - var joyent = pkgcloud.compute.createClient({ - provider: 'joyent', - account: 'nodejitsu' - keyId: '/nodejitsu1/keys/dscape', - key: fs.readFileSync(path.join(process.env.HOME, '.ssh/id_rsa'), 'ascii') - }); -``` - -**username / password** -``` js - var pkgcloud = require('pkgcloud'); - - var joyent = pkgcloud.compute.createClient({ - provider: 'joyent', - username: 'your-account', - password: 'your-password' - }); -``` \ No newline at end of file diff --git a/docs/providers/mongohq.md b/docs/providers/mongohq.md deleted file mode 100644 index 89a6ca8ed..000000000 --- a/docs/providers/mongohq.md +++ /dev/null @@ -1,39 +0,0 @@ -# Using MongoHQ with `pkgcloud` - -MongoHQ is available in `pkgcloud` as a `pkgcloud.databases` target. Here is an example of how to use it: - -``` js - var client = pkgcloud.database.createClient({ - provider: 'mongohq', - username: "bob", - password: "1234" - }); - - // - // Create a MongoDB - // - client.create({ - name: "mongo-instance", - plan: "free", - }, function (err, result) { - // - // Check the result - // - console.log(err, result); - - // - // Now delete that same MongoDB - // - client.remove(result.id, function (err, result) { - // - // Check the result - // - console.log(err, result); - }); - }); -``` - -The `client` instance returned by `pkgcloud.database.createClient` has the following methods for MongoHQ: - -* `client.create(options, callback)` -* `client.remove(id, callback)` \ No newline at end of file diff --git a/docs/providers/mongolab.md b/docs/providers/mongolab.md deleted file mode 100644 index 82037ffec..000000000 --- a/docs/providers/mongolab.md +++ /dev/null @@ -1,69 +0,0 @@ -# Using MongoLab with `pkgcloud` - -The MongoLab API has a slightly different approach for managing databases: they have implemented accounts, and each account can provision databases. **To create a database with MongoLab you will need first create an account and then use the created account as "owner" of the database.** - -``` js - // - // First lets set up the client - // - var client = pkgcloud.database.createClient({ - provider: 'mongolab', - username: 'bob', - password: '1234' - }); -``` - -``` js - // - // Now lets create an account - // name and email are required fields. - // - client.createAccount({ - name:'daniel', - email:'daniel@nodejitsu.com', - // - // If you want, you can set your own password - // (Password must contain at least one numeric character.) - // if not mongolab will create a password for you. - // - password:'mys3cur3p4ssw0rd' - }, function (err, user) { - // - // Now you can provision databases under this user account - // - console.log(user); - }); -``` - -``` js - // - // Now lets create a database - // name and owner are required fields - // - client.create({ - name:'myDatabase', - // - // You need to put the exact name account returned in the account creation. - // - owner: user.account.username - }, function (err, database) { - // - // That is all - // - console.log(database); - }); -``` - -The `client` instance returned by `pkgcloud.database.createClient` has the following methods for MongoLab: - -## Accounts -* `client.createAccount(options, callback)` -* `client.getAccounts(callback)` -* `client.getAccount(name, callback)` -* `client.deleteAccount(name, callback)` - -## Databases -* `client.create(options, callback)` -* `client.getDatabases(owner, callback)` -* `client.getDatabase(options, callback)` -* `client.remove(options, callback)` \ No newline at end of file diff --git a/docs/providers/redistogo.md b/docs/providers/redistogo.md deleted file mode 100644 index c6e1737a1..000000000 --- a/docs/providers/redistogo.md +++ /dev/null @@ -1,43 +0,0 @@ -# Using RedisToGo with `pkgcloud` - -``` js - var client = pkgcloud.database.createClient({ - provider: 'redistogo', - username: "bob", - password: "1234" - }); - - // - // Create a redis - // - client.create({ - plan: "nano", - }, function (err, result) { - // - // Log the result - // - console.log(err, result); - - // - // Get the same redis we just created - // - client.get(result.id, function (err, result) { - // - // Show the details of the database we just created - // - console.log(err, result); - client.remove(result.id, function (err, result) { - // - // Ensure it was removed correctly. - // - console.log(err, result); - }); - }); - }); -``` - -The `client` instance returned by `pkgcloud.database.createClient` has the following methods for RedisToGo: - -* `client.create(options, callback)` -* `client.remove(id, callback)` -* `client.get(id, callback)` \ No newline at end of file diff --git a/examples/compute/joyent.js b/examples/compute/joyent.js deleted file mode 100644 index 2b06895c5..000000000 --- a/examples/compute/joyent.js +++ /dev/null @@ -1,45 +0,0 @@ -var fs = require('fs'), - path = require('path'), - pkgcloud = require('../../lib/pkgcloud'); - -// -// Joyent requires a username / password or key / keyId combo. -// key/keyId should be registered in Joyent servers. -// check `test/helpers/index.js` for details on key/keyId works. -// -var client = pkgcloud.compute.createClient({ - provider: 'joyent', - account: 'nodejitsu', - keyId: '/nodejitsu1/keys/dscape', - key: fs.readFileSync(path.join(process.env.HOME, '.ssh/id_rsa'), 'ascii') -}); - -client.getServers(function (err, servers) { - if (err) { - console.error(err); - } - - servers.forEach(function (server) { - console.log(server.toJSON()); - }); -}); - -// -// Alternatively create a client with a username / password pair -// -var otherClient = pkgcloud.compute.createClient({ - provider: 'joyent', - username: 'your-account', - password: 'your-password' -}); - -otherClient.getServers(function (err, servers) { - if (err) { - console.error(err); - } - - servers.forEach(function (server) { - console.log(server.toJSON()); - }); -}); - diff --git a/examples/database/iriscouch.js b/examples/database/iriscouch.js deleted file mode 100644 index c13f7533b..000000000 --- a/examples/database/iriscouch.js +++ /dev/null @@ -1,47 +0,0 @@ -var pkgcloud = require('../../lib/pkgcloud'); - -var client = pkgcloud.database.createClient({ - provider: 'iriscouch', - username: 'bob', - password: '1234' -}); - -// -// Create a couch database -// -client.create({ - subdomain: 'pkgcloud-nodejitsu-test-5', - first_name: 'pkgcloud', - last_name: 'pkgcloud', - email: 'info@nodejitsu.com' -}, function (err, result) { - // - // Check now exists @ http://pkgcloud-nodejitsu-test-5.iriscouch.com - // - console.log(err, result); -}); - -// -// Crate a redis database -// -client.create({ - subdomain: 'pkgcloud-nodejitsu-test-6', - first_name: 'pkgcloud', - last_name: 'pkgcloud', - email: 'info@nodejitsu.com', - // - // For redis instead of couch just put type to redis - // - type: 'redis', - // - // AND ADD A PASSWORD! (required) - // - password: 'mys3cur3p4ssw0rd' -}, function (err, result) { - // - // Check the connection, use result.host and result.password values - // redis-cli -h $RESULT.HOST -a $RESULT.PASSWORD - // - console.log('HOST to connect:', result.host); - console.log('KEY to use:', result.password); -}); \ No newline at end of file diff --git a/examples/database/mongohq.js b/examples/database/mongohq.js deleted file mode 100644 index 444500f85..000000000 --- a/examples/database/mongohq.js +++ /dev/null @@ -1,30 +0,0 @@ -var pkgcloud = require('../../lib/pkgcloud'); - -var client = pkgcloud.database.createClient({ - provider: 'mongohq', - username: 'bob', - password: '1234' -}); - -// -// Create a MongoDB -// -client.create({ - name: 'mongo-instance', - plan: 'free', -}, function (err, result) { - // - // Check the result - // - console.log(err, result); - - // - // Now delete that same MongoDB - // - client.remove(result.id, function (err, result) { - // - // Check the result - // - console.log(err, result); - }); -}); \ No newline at end of file diff --git a/examples/database/mongolab.js b/examples/database/mongolab.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/database/redistogo.js b/examples/database/redistogo.js deleted file mode 100644 index c136a34b8..000000000 --- a/examples/database/redistogo.js +++ /dev/null @@ -1,35 +0,0 @@ -var pkgcloud = require('../../lib/pkgcloud'); - -var client = pkgcloud.database.createClient({ - provider: 'redistogo', - username: 'bob', - password: '1234' -}); - -// -// Create a redis -// -client.create({ - plan: 'nano' -}, function (err, result) { - // - // Log the result - // - console.log(err, result); - - // - // Get the same redis we just created - // - client.get(result.id, function (err, result) { - // - // Show the details of the database we just created - // - console.log(err, result); - client.remove(result.id, function (err, result) { - // - // Ensure it was removed correctly. - // - console.log(err, result); - }); - }); -}); \ No newline at end of file diff --git a/lib/pkgcloud.js b/lib/pkgcloud.js index a0657c6c5..ae6152235 100644 --- a/lib/pkgcloud.js +++ b/lib/pkgcloud.js @@ -23,15 +23,9 @@ var providers = [ 'azure', 'digitalocean', 'google', - 'iriscouch', - 'joyent', - 'mongohq', - 'mongolab', 'oneandone', 'openstack', 'rackspace', - 'redistogo', - 'telefonica', 'hp' ]; diff --git a/lib/pkgcloud/iriscouch/database/client/index.js b/lib/pkgcloud/iriscouch/database/client/index.js deleted file mode 100644 index 5a1c8c6d7..000000000 --- a/lib/pkgcloud/iriscouch/database/client/index.js +++ /dev/null @@ -1,191 +0,0 @@ -/* - * client.js: Database client for Iriscouch Cloud Databases - * - * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - request = require('request'), - pkgcloud = require('../../../../pkgcloud'), - errs = require('errs'); - -var Client = exports.Client = function (options) { - this.username = options.username; - this.password = options.password; - - this.protocol = options.protocol || 'https://'; - this.databaseUrl = options.databaseUrl || 'hosting.iriscouch.com/hosting_public'; -}; - -Client.prototype.create = function (attrs, callback) { - // Check for options. - if (!attrs || typeof attrs === 'function') { - return errs.handle(errs.create({ - message: 'Options required for create a database.' - }), Array.prototype.slice.call(arguments).pop()); - } - // Check for obligatory fields - if (!attrs['first_name'] || !attrs['last_name']) { - return errs.handle(errs.create({ - message: 'Options. first_name and last_name are required arguments' - }), Array.prototype.slice.call(arguments).pop()); - } - - if (!attrs['subdomain'] || !attrs['email']) { - return errs.handle(errs.create({ - message: 'Options. subdomain and email are required arguments' - }), Array.prototype.slice.call(arguments).pop()); - } - - // If is a redis provisioning request so we have to define a password - if (attrs['type'] && attrs['type'] === 'redis' && !attrs['password']) { - return errs.handle(errs.create({ - message: 'Options. password for redis is a required argument' - }), Array.prototype.slice.call(arguments).pop()); - } - - var self = this, - couch = { - // The ID needs the prefix of the type of database - _id: ((attrs['type'] && - attrs['type'] === 'redis') ? 'Redis/' : 'Server/') + attrs.subdomain, - partner: this.username, - creation: { - first_name: attrs.first_name, - last_name: attrs.last_name, - email: attrs.email, - subdomain: attrs.subdomain - } - }; - - // When redis so we have to add the password - if (attrs['type'] && attrs['type'] === 'redis') { - couch.creation.password = attrs['password']; - } - - var options = { - uri : this._getUrl(), - method : 'POST', - body : JSON.stringify(couch), - followRedirect: false, - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64'), - 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) - } - }; - - request(options, function (err, response, body) { - if (err) { - return callback(err); - } - - if (typeof body === 'string') { - try { body = JSON.parse(body) } - catch (ex) { } - } - - if (response.statusCode === 201) { - if (body.ok === true) { - // - // For Redis we dont have any polling method yet, so just trust on iriscouch for provisioning correctly - // - if (attrs['type'] && attrs['type'] === 'redis') { - var subdomain = body.id.split('/').pop(); - callback(err, { - id: subdomain, - port: 6379, - host: subdomain + '.redis.irstack.com', - uri: 'redis://' + subdomain + '.redis.irstack.com/', - username: '', - password: subdomain + '.redis.irstack.com:' + attrs['password'] - }); - } else { - // - // Remark: Begin polling iriscouch to determine when the couch database is ready. - // - self._checkCouch(attrs.subdomain, function (err, response) { - response.subdomain = attrs.subdomain; - var database = self.formatResponse(response); - callback(err, database); - }); - } - } - else { - callback('There was an issue creating the couch', { created: false }); - } - } - else if (response.statusCode === 403 || response.statusCode === 401 || response.statusCode === 302) { - callback('incorrect partner name or password.', { created: false }); - } - else if (response.statusCode === 409) { - callback('subdomain is already taken.', { created: false }); - } - else { - callback('unknown error', { created: false }); - } - }); -}; - -Client.prototype.formatResponse = function (response) { - var database = { - id: response.subdomain, - port: 6984, - host: response.subdomain + '.iriscouch.com', - uri: 'https://' + response.subdomain + '.iriscouch.com:6984/', - username: '', - password: '' - }; - return database; -}; - -Client.prototype._getUrl = function () { - return this.protocol + this.databaseUrl; -}; - -Client.prototype._checkCouch = function (couchName, callback) { - // - // Remark: Poll the couch with a GET every interval to determine if couch is up yet - // We perform a poll since there is no real database available notification event from couchone - // - - var interval = 4000, - maxAttempts = 20, - count = 0, - options = { - uri : this._getCouchPollingUrl(couchName), - method : 'GET', - followRedirect: false, - headers: { - 'Content-Type': 'application/json', - 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) - } - }, - - t = function () { - count = count + 1; - if (count > maxAttempts) { - return callback('Max Attempts hit', { created: false }); - } - request(options, function (err, response) { - if (err) { - return callback(err, { created: false }); - } - if (response.statusCode === 200) { - return callback(null, { created: true }); - } - setTimeout(t, interval); - }); - }; - t(); -}; - -Client.prototype.remove = function (id, callback) { - callback('Destroy method not available for iriscouch.'); -}; - -// This function gets overriden in tests to trap the polling request -Client.prototype._getCouchPollingUrl = function(couchName) { - return 'http://' + couchName + '.iriscouch.com/'; -}; diff --git a/lib/pkgcloud/iriscouch/database/index.js b/lib/pkgcloud/iriscouch/database/index.js deleted file mode 100644 index 21a66c674..000000000 --- a/lib/pkgcloud/iriscouch/database/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * index.js: Top-level include for the Iriscouch database module - * - * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.Client = require('./client').Client; - -exports.createClient = function createClient(options) { - return new exports.Client(options); -}; diff --git a/lib/pkgcloud/iriscouch/index.js b/lib/pkgcloud/iriscouch/index.js deleted file mode 100644 index 025267972..000000000 --- a/lib/pkgcloud/iriscouch/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * index.js: Top-level include for the iriscouch module. - * - * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.database = require('./database'); diff --git a/lib/pkgcloud/joyent/client.js b/lib/pkgcloud/joyent/client.js deleted file mode 100644 index 7e3785d94..000000000 --- a/lib/pkgcloud/joyent/client.js +++ /dev/null @@ -1,115 +0,0 @@ -/* - * client.js: Base client from which all Joyent clients inherit from - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - fs = require('fs'), - auth = require('../common/auth'), - base = require('../core/base'); - -// -// ### constructor (options) -// #### @opts {Object} an object literal with options -// #### @serversUrl {String} **Optional** CloudAPI Endpoint -// #### @apiVersion {String} **Optional** CloudAPI API Version -// #### @account {String} **Optional** CloudAPI Account to connect to -// #### @username {String} **Optional** Login name -// #### @password {String} **Optional** Password that goes with username -// #### @keyId {String} **Optional** SSH KeyId to sign in to cloudapi -// #### @key {String} **Optional** SSH key (PEM) that goes -// #### @identity {String} **Optional** File path of the private key -// with `keyId`. -// #### @throws {TypeError} On bad input -// -// Creates a new Joyent CloudAPI Client. Even though all @opts are optional -// you must either provide username/password or keyId/key -// -var Client = exports.Client = function (opts) { - if (!opts) { - throw new TypeError('options required'); - } - - if (opts.identity) { - opts.key = fs.readFileSync(opts.identity, 'ascii'); - } - - if (!(opts.username && opts.password) && - !(opts.keyId && opts.key)) { - throw new TypeError('Either username/password or keyId/key are required'); - } - - // default values - opts.account = opts.account || opts.username || 'my'; - opts.apiVersion = opts.apiVersion || '~6.5'; - - // if a person gives a key id by name that doesn't work in joyent - // keys are fully qualified. so we check for `/` in the keyId, if it's not - // there we need to do something about it - if (opts.keyId && opts.keyId.indexOf('/') === -1) { - // this will fail if account was also not properly set and account is - // set to `my`. - opts.keyId = '/' + opts.account + '/keys/' + opts.keyId; - } - - base.Client.call(this, opts); - - this.provider = 'joyent'; - this.account = opts.account; - this.serversUrl = opts.serversUrl - || process.env.SDC_CLI_URL - || 'us-sw-1.api.joyentcloud.com'; - this.protocol = opts.protocol || 'https://'; - - if (!this.before) { this.before = []; } - - if (opts.key && opts.keyId) { - this.before.push(auth.httpSignature); - } else { - this.before.push(auth.basic); - } - - this.before.push(function setReqHeaders(req) { - req.json = true; - if (typeof req.headers['X-Api-Version'] === 'undefined') { - req.headers['x-api-version'] = opts.apiVersion; - req.headers.Accept = 'application/json'; - req.headers['content-type'] = 'application/json'; - } - }); - - this.before.push(function setContentTypeAndReqJson(req) { - if (typeof req.body !== 'undefined') { - req.json = req.body; - delete req.body; - } - }); -}; - -util.inherits(Client, base.Client); - -Client.prototype.failCodes = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 405: 'Method Not Allowed', - 406: 'Not Acceptable', - 409: 'Conflict', - 413: 'Request Entity Too Large', - 415: 'Unsupported Media Type', - 420: 'Slow Down', - 449: 'Retry With', - 500: 'Internal Error', - 503: 'Service Unavailable' -}; - -Client.prototype.successCodes = { - 200: 'OK', - 201: 'Created', - 202: 'Accepted', - 203: 'Non-authoritative information', - 204: 'No content' -}; diff --git a/lib/pkgcloud/joyent/compute/client/flavors.js b/lib/pkgcloud/joyent/compute/client/flavors.js deleted file mode 100644 index 16031db75..000000000 --- a/lib/pkgcloud/joyent/compute/client/flavors.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * flavors.js: Implementation of Joyent Flavors Client. - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var pkgcloud = require('../../../../../lib/pkgcloud'), - base = require('../../../core/compute'), - compute = pkgcloud.providers.joyent.compute; - -// -// ### function getFlavors (callback) -// #### @callback {function} f(err, flavors). `flavors` is an array that -// represents the flavors that are available to your account -// -// Lists all flavors available to your account. -// -exports.getFlavors = function getFlavors(callback) { - var self = this; - return this._request({ - path: this.account + '/packages' - }, function (err, body, res) { - return err - ? callback(err) - : callback(null, body.map(function (result) { - return new compute.Flavor(self, result); - }), res); - }); -}; - -// -// ### function getFlavor (flavor, callback) -// #### @image {Flavor|String} Flavor ID or an Flavor -// #### @callback {function} f(err, flavor). `flavor` is an object that -// represents the flavor that was retrieved. -// -// Gets a specified flavor of Joyent DataSets using the provided details -// object. -// -exports.getFlavor = function getFlavor(flavor, callback) { - var self = this, - flavorId = flavor instanceof base.Flavor ? flavor.id : flavor; - - // joyent decided to add spaces to their identifiers - flavorId = encodeURIComponent(flavorId); - - return this._request({ - path: this.account + '/packages/' + flavorId - }, function (err, body, res) { - return err - ? callback(err) - : callback(null, new compute.Flavor(self, body), res); - }); -}; \ No newline at end of file diff --git a/lib/pkgcloud/joyent/compute/client/images.js b/lib/pkgcloud/joyent/compute/client/images.js deleted file mode 100644 index 2d597b23d..000000000 --- a/lib/pkgcloud/joyent/compute/client/images.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * images.js: Implementation of Joyent Images Client. - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ -var pkgcloud = require('../../../../../lib/pkgcloud'), - base = require('../../../core/compute'), - errs = require('errs'), - compute = pkgcloud.providers.joyent.compute; - -// -// ### function getImages (callback) -// #### @callback {function} f(err, images). `images` is an array that -// represents the images that are available to your account -// -// Lists all images available to your account. -// -exports.getImages = function getImages(callback) { - var self = this; - return this._request({ - path: this.account + '/datasets' - }, function (err, body, res) { - return err - ? callback(err) - : callback(null, body.map(function (result) { - return new compute.Image(self, result); - }), res); - }); -}; - -// ### function getImage (image, callback) -// #### @image {Image|String} Image id or an Image -// #### @callback {function} f(err, image). `image` is an object that -// represents the image that was retrieved. -// -// Gets a specified image of Joyent DataSets using the provided details -// object. -// -exports.getImage = function getImage(image, callback) { - var self = this, - imageId = image instanceof base.Image ? image.id : image; - - // joyent decided to add spaces to their identifiers - imageId = encodeURIComponent(imageId); - - return this._request({ - path: this.account + '/datasets/' + imageId - }, function (err, body, res) { - return err - ? callback(err) - : callback(null, new compute.Image(self, body), res); - }); -}; - -// -// ### function createImage(options, callback) -// #### @id {Object} an object literal with options -// #### @name {String} String name of the image -// #### @server {Boolean} the server to use -// #### @callback {function} f(err, image). `image` is an object that -// represents the image that was created. -// -// Creates an image in Joyent based on a server -// -exports.createImage = function createImage(options, callback) { - return errs.handle( - errs.create({ message: 'Not supported by joyent' }), - callback - ); -}; - -// -// ### function destroyImage(image, callback) -// #### @image {Image|String} Image id or an Image -// #### @callback {function} f(err, image). `image` is an object that -// represents the image that was deleted. -// -// Destroys an image in Joyent -// -exports.destroyImage = function destroyImage(image, callback) { - return errs.handle( - errs.create({ message: 'Not supported by joyent' }), - callback - ); -}; \ No newline at end of file diff --git a/lib/pkgcloud/joyent/compute/client/index.js b/lib/pkgcloud/joyent/compute/client/index.js deleted file mode 100644 index b2e7487eb..000000000 --- a/lib/pkgcloud/joyent/compute/client/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * index.js: Compute client for Joyent CloudAPI - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - urlJoin = require('url-join'), - joyent = require('../../client'), - _ = require('lodash'); - -var Client = exports.Client = function (options) { - joyent.Client.call(this, options); - - _.extend(this, require('./flavors')); - _.extend(this, require('./images')); - _.extend(this, require('./servers')); - _.extend(this, require('./keys')); -}; - -util.inherits(Client, joyent.Client); - -Client.prototype._getUrl = function (options) { - options = options || {}; - - var root = this.serversUrl - ? this.protocol + this.serversUrl - : this.protocol + 'us-sw-1.api.joyentcloud.com'; - - return urlJoin(root, typeof options === 'string' - ? options - : options.path); -}; diff --git a/lib/pkgcloud/joyent/compute/client/keys.js b/lib/pkgcloud/joyent/compute/client/keys.js deleted file mode 100644 index 0852ffd30..000000000 --- a/lib/pkgcloud/joyent/compute/client/keys.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * keys.js: Implementation of Joyent SSH keys Client. - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var errs = require('errs'); - -// -// ### function listKeys (callback) -// #### @callback {function} Continuation to respond to when complete. -// -// Lists all Joyent SSH Keys matching the specified `options`. -// -exports.listKeys = function (callback) { - return this._request({ - path: this.account + '/keys' - }, function (err, body) { - return err - ? callback(err) - : callback(null, body); - }); -}; - -// -// ### function getKey (name, callback) -// #### @name {string} Name of the Joyent SSH key to get -// #### @callback {function} Continuation to respond to when complete. -// -// Gets the details of the Joyent SSH Key with the specified `name`. -// -exports.getKey = function (name, callback) { - return this._request({ - path: this.account + '/keys/' + name - }, function (err, body) { - return err - ? callback(err) - : callback(null, body); - }); -}; - -// -// ### function addKey (options, callback) -// #### @options {Object} SSH Public Key details -// #### @name {string} String name of the key -// #### @key {string} SSH Public Key -// #### @callback {function} Continuation to respond to when complete. -// -// Adds a Joyent SSH Key with the specified `options`. -// -exports.addKey = function (options, callback) { - if (!options || !options.key || !options.name) { - return errs.handle( - errs.create({ message: '`key` and `name` are required options.' }), - callback - ); - } - - return this._request({ - method: 'POST', - path: this.account + '/keys', - body: options - }, function (err) { - return err - ? callback(err) - : callback(null, true); - }); -}; - -// -// ### function getKey (name, callback) -// #### @name {string} Name of the Joyent SSH key to destroy -// #### @callback {function} Continuation to respond to when complete. -// -// Destroys Joyent SSH Key with the specified `name`. -// -exports.destroyKey = function (name, callback) { - return this._request({ - method: 'DELETE', - path: this.account + '/keys/' + name - }, function (err) { - return err - ? callback(err) - : callback(null, true); - }); -}; diff --git a/lib/pkgcloud/joyent/compute/client/servers.js b/lib/pkgcloud/joyent/compute/client/servers.js deleted file mode 100644 index 2410071e8..000000000 --- a/lib/pkgcloud/joyent/compute/client/servers.js +++ /dev/null @@ -1,272 +0,0 @@ -/* - * servers.js: Instance methods for working with servers from Joyent Cloud - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ -var base = require('../../../core/compute'), - pkgcloud = require('../../../../../lib/pkgcloud'), - errs = require('errs'), - compute = pkgcloud.providers.joyent.compute; - -// -// ### function getVersion (callback) -// #### @callback {function} f(err, version). -// -// Gets the current API version -// -exports.getVersion = function getVersion(callback) { - return this._request({ - path: this.account + '/datacenters' - }, function (err, response, res) { - return err - ? callback(err) - : callback(null, res.headers['x-api-version'], res); - }); -}; - -// -// ### function getLimits (callback) -// #### @callback {function} f(err, version). -// -// Gets the current API limits -// -exports.getLimits = function getLimits(callback) { - return errs.handle( - errs.create({message: 'Joyent\'s API is not rate limited'}), callback); -}; - -// -// ### function getServers (callback) -// #### @options {Object} Options when getting servers -// #### @options.offset {number} Number of servers to skip when listing -// #### @options.limit {number} Number of servers to return -// #### @callback {function} f(err, servers). `servers` is an array that -// represents the servers that are available to your account -// -// Lists all servers available to your account. -// -exports.getServers = function getServers(options, callback) { - if (!callback && typeof options === 'function') { - callback = options; - options = null; - } - - var self = this; - return this._request( - { - path: this.account + '/machines', - qs: options - }, - function (err, body, res) { - return err - ? callback(err) - : callback(null, body.map(function (result) { - return new compute.Server(self, result); - }), res); - } - ); -}; - -// -// ### function createServer (options, callback) -// #### @opts {Object} **Optional** options -// #### @name {String} **Optional** a name for your server -// #### @flavor {String|Favor} **Optional** flavor to use for this image -// #### @image {String|Image} **Optional** the image to use -// #### @required {Boolean} **Optional** Validate if flavor, name, -// and image are present -// #### @* {*} **Optional** Anything platform specific -// #### @callback {Function} f(err, server). -// -// Creates a server with the specified options. The flavor -// properties of the options can be instances of Flavor -// OR ids to those entities in Joyent. -// -exports.createServer = function createServer(options, callback) { - if (typeof options === 'function') { - callback = options; - options = {}; - } - - options = options || {}; // no args - var self = this, - createOptions = { - method: 'POST', - path: this.account + '/machines', - body: options - }; - - ['flavor', 'image', 'name'].forEach(function (member) { - if (options.required) { // marked as required? - if (!options[member]) { - return errs.handle( - errs.create({ message: 'options.' + member + ' is a required argument.' }), - callback - ); - } - } - }); - if (options.flavor) { - createOptions.body['package'] = options.flavor instanceof base.Flavor - ? options.flavor.id - : options.flavor; - - delete options.flavor; - } - - if (options.image) { - createOptions.body.dataset = options.image instanceof base.Image - ? options.image.id - : options.image; - - delete options.image; - } - - return this._request(createOptions, function (err, body, res) { - return err - ? callback(err) - : callback(null, new compute.Server(self, body), res); - }); -}; - -// -// ### function destroyServer(server, callback) -// #### @server {Server|String} Server id or a server -// #### @callback {Function} f(err, serverId). -// -// Destroy a server in Joyent. -// -exports.destroyServer = function destroyServer(server, callback) { - var serverId = server instanceof base.Server ? server.id : server; - var self = this; - - var stopOptions = { - method: 'POST', - path: this.account + '/machines/' + serverId, - body: { - action: 'stop' - } - }; - - return this._request(stopOptions, function (err, body, res) { - if (err) { - return callback && callback(err); - } - - function finish() { - var destroyOptions = { - method: 'DELETE', - path: self.account + '/machines/' + serverId - }; - - self._request(destroyOptions, function (err, body, res) { - return err - ? callback && callback(err) - : callback && callback(err, {ok: serverId}, res); - }); - } - - if (res.statusCode === 202) { - var checks = 10; - var done = false; - // TODO refactor this setWait - function check() { - if (done) { - return; - } - checks--; - if (checks <= 0) { - return; - } - if (checks === 0) { - done = true; - finish(new Error('Machine unresponsive to STOP')); - return; - } - var checkOptions = { - method: 'GET', - path: self.account + '/machines/' + serverId - }; - - self._request(checkOptions, function (err, body) { - if (err) { return callback && callback(err) } - if (body && body.state === 'stopped') { - done = true; - finish(); - return; - } - }); - - setTimeout(check, 5000); - } - - check(); - return; - } - else { - finish(); - } - - }); -}; - -// -// ### function getServer(server, callback) -// #### @server {Server|String} Server id or a server -// #### @callback {Function} f(err, serverId). -// -// Gets a server in Joyent. -// -exports.getServer = function getServer(server, callback) { - var self = this, - serverId = server instanceof base.Server ? server.id : server; - - return this._request({ - path: this.account + '/machines/' + serverId - }, function (err, body, res) { - return err - ? callback(err) - : callback(null, new compute.Server(self, body), res); - }); -}; - - -// -// ### function rebootServer (server, options, callback) -// #### @server {Server|String} The server to reboot -// #### @callback {Function} f(err, server). -// -// Reboots a server -// -exports.rebootServer = function rebootServer(server, callback) { - var serverId = server instanceof base.Server ? server.id : server; - var createOptions = { - method: 'POST', - path: this.account + '/machines/' + serverId, - qs: { - action: 'reboot' - } - }; - - return this._request(createOptions, function (err, body, res) { - return err - ? callback(err) - : callback(null, { ok: serverId }, res); - }); -}; - -// -// ### function renameServer(server, name, callback) -// #### @server {Server|String} Server id or a server -// #### @name {String} New name to apply to the server -// #### @callback {Function} f(err, server). -// -// Renames a server -// -exports.renameServer = function renameServer(server, name, callback) { - return errs.handle( - errs.create({ message: 'Not supported by Joyent.' }), - callback - ); -}; diff --git a/lib/pkgcloud/joyent/compute/flavor.js b/lib/pkgcloud/joyent/compute/flavor.js deleted file mode 100644 index 0bc44f4e8..000000000 --- a/lib/pkgcloud/joyent/compute/flavor.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * flavor.js: Joyent Cloud Package - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - base = require('../../core/compute/flavor'); - -var Flavor = exports.Flavor = function Flavor(client, details) { - base.Flavor.call(this, client, details); -}; - -util.inherits(Flavor, base.Flavor); - -Flavor.prototype._setProperties = function (details) { - this.id = details.name; - this.name = details.name; - this.ram = details.memory; - this.disk = details.disk; - - // - // Joyent specific - // - this.swap = details.swap; - this['default'] = details['default']; - this.original = this.joyent = details; -}; \ No newline at end of file diff --git a/lib/pkgcloud/joyent/compute/image.js b/lib/pkgcloud/joyent/compute/image.js deleted file mode 100644 index d7a211809..000000000 --- a/lib/pkgcloud/joyent/compute/image.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * image.js: Joyent Cloud DataSet - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - base = require('../../core/compute/image'); - -var Image = exports.Image = function Image(client, details) { - base.Image.call(this, client, details); -}; - -util.inherits(Image, base.Image); - -Image.prototype._setProperties = function (details) { - this.id = details.urn; - this.name = details.name; - this.created = details.created; - - // - // Joyent specific - // - this.urn = details.urn; - this.joyentId = details.id; - this.os = details.os; - this.type = details.type; - this.description = details.description; - this['default'] = details['default']; - this.version = details.version; - this.requirements = details.requirements; - this.original = this.rackspace = details; -}; \ No newline at end of file diff --git a/lib/pkgcloud/joyent/compute/index.js b/lib/pkgcloud/joyent/compute/index.js deleted file mode 100644 index e0f98f06e..000000000 --- a/lib/pkgcloud/joyent/compute/index.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * index.js: Top-level include for the Joyent compute module - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.Client = require('./client').Client; -exports.Flavor = require('./flavor').Flavor; -exports.Image = require('./image').Image; -exports.Server = require('./server').Server; - -exports.createClient = function (options) { - return new exports.Client(options); -}; diff --git a/lib/pkgcloud/joyent/compute/server.js b/lib/pkgcloud/joyent/compute/server.js deleted file mode 100644 index 55aa7d0c6..000000000 --- a/lib/pkgcloud/joyent/compute/server.js +++ /dev/null @@ -1,67 +0,0 @@ -/* - * server.js: Joyent Cloud Machine - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - compute = require('../../core/compute'), - base = require('../../core/compute/server'); - -var Server = exports.Server = function Server(client, details) { - base.Server.call(this, client, details); -}; - -util.inherits(Server, base.Server); - -Server.prototype._setProperties = function (details) { - this.id = details.id; - this.name = details.name; - - if (details.state) { - switch (details.state.toUpperCase()) { - case 'PROVISIONING': - this.status = this.STATUS.provisioning; - break; - case 'RUNNING': - this.status = this.STATUS.running; - break; - case 'STOPPING': - case 'STOPPED': - this.status = this.STATUS.stopped; - break; - default: - this.status = this.STATUS.unknown; - break; - } - } - - var addresses = details.ips.reduce(function (all, addr) { - if (compute.isPrivate(addr)) { - all['private'].push(addr); - } - else { - all['public'].push(addr); - } - - return all; - }, { 'private': [], 'public': [] }); - - // - // Joyent specific - // - this.ips = details.ips; - this.imageId = details.dataset; - this.addresses = details.addresses = addresses; - this.created = details.created; - this.updated = details.updated; - this.type = details.type; - this.ram = details.memory; - this.disk = details.disk; - this.metadata = details.metadata; - this.original = this.joyent = details; - this.adminPass = details.metadata && details.metadata.credentials && - details.metadata.credentials.admin; - -}; diff --git a/lib/pkgcloud/joyent/index.js b/lib/pkgcloud/joyent/index.js deleted file mode 100644 index 65303f64a..000000000 --- a/lib/pkgcloud/joyent/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * index.js: Top-level include for the Joyent module. - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.compute = require('./compute'); diff --git a/lib/pkgcloud/mongohq/database/client/databases.js b/lib/pkgcloud/mongohq/database/client/databases.js deleted file mode 100644 index c058d450b..000000000 --- a/lib/pkgcloud/mongohq/database/client/databases.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * database.js: Database methods for working with databases from MongoHQ - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - - var errs = require('errs'), - url = require('url'); - -// Function formatResponse -// This function parse the response from the provider and return an object -// with the correct keys and values. -// ### @response {Object} The body response from the provider api -function formatResponse(response) { - var info, user, dbname, database, auth; - info = url.parse(response.config.MONGOHQ_URL); - auth = encodeURIComponent(info.auth); - user = auth.replace(/%3A/i, ':').split(':'); - dbname = info.pathname.replace('/', ''), - database = { - id: response.id, - port: Number(info.port), - host: info.hostname, - uri: 'mongodb://' + info.auth + '@' + info.host, - username: decodeURIComponent(user[0]), - password: decodeURIComponent(user[1]), - dbname: dbname - }; - return database; -} - -// Create a new Database at mongohq -// Need Name and select a plan. -// ### @options {Object} pair of name an plan values. -// ##### @options['name'] {String} Name of the new database.(required) -// ##### @options['plan'] {String} Name of the plan selected for database.(required) -exports.create = function create(options, callback) { - // Check for options - if (!options || typeof options === 'function') { - return errs.handle(errs.create({ - message: 'Options required for create a database.' - }), Array.prototype.slice.call(arguments).pop()); - } - // Check for name - if (!options['name']) { - return errs.handle(errs.create({ - message: 'options. Name are required arguments' - }), Array.prototype.slice.call(arguments).pop()); - } - - // Check for plan - if (!options['plan']) { - options['plan'] = 'free'; - } - - var createOptions = { - path : 'resources', - method : 'POST', - body : 'app_id=' + options.name + '&plan=' + options.plan - }; - - this._request(createOptions, function (err, b) { - if (err) { - return callback(err); - } - var body; - if (typeof b !== 'object') { - try { - body = JSON.parse(b); - } catch (e) { - return errs.handle(errs.create({ - messages: 'Bad response from server.' - }), callback); - } - } else { body = b; } - return callback(null, formatResponse(body)); - }); -}; - -// -// Removes one mongo instance by id -// ### @id {String} ID of the instance to remove. -exports.remove = function remove(id, callback) { - // Check for id - if (!id || typeof id === 'function') { - return errs.handle(errs.create({ - message: 'ID is a required argument' - }), Array.prototype.slice.call(arguments).pop()); - } - - var deleteOptions = { - path : 'resources/' + id, - method : 'DELETE' - }; - - this._request(deleteOptions, function (err) { - return err - ? callback(err) - : callback(null, 'deleted'); - }); -}; diff --git a/lib/pkgcloud/mongohq/database/client/index.js b/lib/pkgcloud/mongohq/database/client/index.js deleted file mode 100644 index 673da7abd..000000000 --- a/lib/pkgcloud/mongohq/database/client/index.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - * index.js: Database client for MongoHQ Cloud Databases - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - urlJoin = require('url-join'), - base = require('../../../core/base'), - auth = require('../../../common/auth'), - _ = require('lodash'); - -var Client = exports.Client = function (options) { - base.Client.call(this, options); - - if (!this.before) { - this.before = []; - } - - this.protocol = options.protocol || 'https://'; - this.databaseUrl = options.databaseUrl || 'providers.mongohq.com'; - - this.before.push(auth.basic); - - _.extend(this, require('./databases')); -}; - -util.inherits(Client, base.Client); - -Client.prototype._getUrl = function (options) { - options = options || {}; - - return urlJoin([this.protocol + this.databaseUrl, 'provider'].join('/'), - typeof options === 'string' - ? options - : options.path); -}; - -Client.prototype.failCodes = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Resize not allowed', - 404: 'Item or Account not found', - 409: 'Build in progress', - 413: 'Over Limit', - 415: 'Bad Media Type', - 500: 'Fault', - 503: 'Service Unavailable' -}; - -Client.prototype.successCodes = { - 200: 'OK', - 201: 'Created', - 202: 'Accepted', - 203: 'Non-authoritative information', - 204: 'No content' -}; diff --git a/lib/pkgcloud/mongohq/database/index.js b/lib/pkgcloud/mongohq/database/index.js deleted file mode 100644 index 0ea136bfd..000000000 --- a/lib/pkgcloud/mongohq/database/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * index.js: Top-level include for the MongoHQ database module - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.Client = require('./client').Client; - -exports.createClient = function createClient(options) { - return new exports.Client(options); -}; diff --git a/lib/pkgcloud/mongohq/index.js b/lib/pkgcloud/mongohq/index.js deleted file mode 100644 index 872150b4c..000000000 --- a/lib/pkgcloud/mongohq/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * index.js: Top-level include for the mongohq module. - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.database = require('./database'); diff --git a/lib/pkgcloud/mongolab/database/client/accounts.js b/lib/pkgcloud/mongolab/database/client/accounts.js deleted file mode 100644 index a03ae7692..000000000 --- a/lib/pkgcloud/mongolab/database/client/accounts.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * accounts.js: Accounts methods for working with databases from MongoLab - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var errs = require('errs'); - -// Create Account -// ### @options {Object} Set of options can be -// #### options['name'] {string} Name of account (required) -// #### options['email'] {string} Email of the owner of the account (required) -// #### options['password'] {string} Password for the account (Optional), If not specify so mongolab will generate one. -// ### @callback {Function} Continuation to respond to when complete. -exports.createAccount = function createAccount(options, callback) { - // Check for options - if (typeof options === 'function') { - return errs.handle(errs.create({ - message: 'Options required for create an account.' - }), options); - } - - if (!options['name']) { - return errs.handle(errs.create({ - message: 'options. Name is a required argument' - }), callback); - } - - if (!options['email']) { - return errs.handle(errs.create({ - message: 'options. Email is a required argument' - }), callback); - } - - // Add support for the displayName input for mongolab - // https://objectlabs.jira.com/wiki/display/partners/MongoLab+Partner+Integration+API#MongoLabPartnerIntegrationAPI-Createaccount.1 - - var adminUser = { email: options['email'] }; - - if (options['password']) { - if (/[+\d]/g.test(options['password'])) { - adminUser['password'] = options['password']; - } else { - return errs.handle(errs.create({ - message: 'options. Password must contain at least one numeric character.' - }), callback); - } - } - - var createOptions = { - method: 'POST', - path: 'accounts', - body: { - name: [this.config.username, options['name']].join('_'), - adminUser: adminUser - } - }; - - this._request(createOptions, function (err, body) { - return err - ? callback(err) - : callback(null, { account: body.adminUser }); - }); -}; - -// Delete Account -// ### @name {String} Name of the account to be deleted -// ### @callback {Function} Continuation to respond to when complete. -exports.deleteAccount = function deleteAccount(name, callback) { - // Check for options - if (typeof name === 'function') { - return errs.handle(errs.create({ - message: 'Name required for delete an account.' - }), name); - } - - var deleteOptions = { - method: 'DELETE', - path: 'accounts/' + name - }; - - this._request(deleteOptions, function (err) { - return err - ? callback(err) - : callback(null); - }); -}; - -// List all accounts -// ### @callback {Function} Continuation to respond to when complete. -exports.getAccounts = function getAccounts(callback) { - this._request({ path: 'accounts' }, function (err, body) { - return err - ? callback(err) - : callback(null, body.map(function (account) { - return account.adminUser; - })); - }); -}; - -// View an account -exports.getAccount = function getAccount(name, callback) { - // Check for options - if (typeof name === 'function') { - return errs.handle(errs.create({ - message: 'Name required for view an account.' - }), name); - } - - this._request({ path: 'accounts/' + name }, function (err, body) { - return err - ? callback(err) - : callback(null, body.adminUser); - }); -}; diff --git a/lib/pkgcloud/mongolab/database/client/databases.js b/lib/pkgcloud/mongolab/database/client/databases.js deleted file mode 100644 index 3ec9b8004..000000000 --- a/lib/pkgcloud/mongolab/database/client/databases.js +++ /dev/null @@ -1,190 +0,0 @@ -/* - * database.js: Database methods for working with databases from MongoLab - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var errs = require('errs'), - url = require('url'); - - -// Function formatResponse -// This function parse the response from the provider and return an object -// with the correct keys and values. -// ### @response {Object} The body response from the provider api -function formatResponse(response) { - var info, user, dbname, auth; - info = url.parse(response.uri); - auth = encodeURIComponent(info.auth); - user = auth.replace(/%3A/i, ':').split(':'); - dbname = response.name; - - var database = { - id: dbname, - host: info.hostname, - port: Number(info.port), - uri: 'mongodb://' + info.auth + '@' + info.host, - username: decodeURIComponent(user[0]), - password: decodeURIComponent(user[1]), - dbname: dbname - }; - return database; -} - -// Create Database -// ### @options {Object} Set of options can be -// #### options['name'] {String} Name of database (required) -// #### options['owner'] {String} Name of the user owner the database (required) -// #### options['plan'] {String} Name of plan according to the MongoLab plans (Default: 'free') -// ### @callback {Function} Continuation to respond to when complete. -exports.create = function create(options, callback) { - // Check for options - if (typeof options === 'function') { - return errs.handle(errs.create({ - message: 'Options required for create a database.' - }), options); - } - - if (!options['name']) { - return errs.handle(errs.create({ - message: 'options. Name is a required argument' - }), callback); - } - - if (!options['owner']) { - return errs.handle(errs.create({ - message: 'options. Owner is a required argument' - }), callback); - } - - if (!options['plan']) { - options['plan'] = 'free'; - } - - // We have to setup the correct prefix for database name - // for the moment we use the 'owner' field because we expect the correct prefix there. - var databaseName = [options['owner'], options['name']].join('_'); - - // Setup the account name according mongolab API. - // @todo We need a helper function for add the prefix if its necesary - //var account = [this.config.username, options['owner']].join('_'); - // at the moment we need provide the username with the prefix (partner name) - var account = options['owner']; - - var createOptions = { - method: 'POST', - path: 'accounts/' + account + '/databases', - body: { - name: databaseName, - plan: options['plan'], - username: options['owner'], - // In future we will have to change this for support multiples clouds and user-selected cloud. - cloud: this.config.cloud - } - }; - - this._request(createOptions, function (err, body) { - return err - ? callback(err) - : callback(null, formatResponse(body)); - }); -}; - -// Lists all databases by user account -// ### @owner {String} Username for list their databases -// ### @callback {Function} Continuation to respond to when complete. -exports.getDatabases = function getDatabases(owner, callback) { - // Check for options - if (typeof owner === 'function') { - return errs.handle(errs.create({ - message: 'Name required for delete an account.' - }), owner); - } - - this._request({ path: 'accounts/' + owner + '/databases' }, function (err, body) { - return err - ? callback(err) - : callback(null, body); - }); -}; - -// View one database with details -// NOT USE THIS METHOD YET -// The principal idea of this method is for view details like username and -// password and the hostname and port, but for now MongoLab just answer with the name. -// The behavior I describe its according the parters documentation. -// https://objectlabs.jira.com/wiki/display/partners/MongoLab+Partner+Integration+API#MongoLabPartnerIntegrationAPI-Viewdatabase -// ### @options {Object} Set of options can be -// #### options['name'] {String} Name of the database to view (required) -// #### options['owner'] {String} Username of the database owner (required) -// ### @callback {Function} Continuation to respond to when complete. -exports.getDatabase = function getDatabase(options, callback) { - // Check for options - if (typeof options === 'function') { - return errs.handle(errs.create({ - message: 'Options required for view a database.' - }), options); - } - - // Check for name - if (!options['name']) { - return errs.handle(errs.create({ - message: 'options. Name is a required argument.' - }), callback); - } - - // Check for owner - if (!options['owner']) { - return errs.handle(errs.create({ - message: 'options. Username of owner is a required argument.' - }), callback); - } - - var path = ['accounts', options['owner'], 'databases', options['name']].join('/'); - - this._request({ path: path }, function (err, body) { - return err - ? callback(err) - : callback(null, body); - }); -}; - -// Delete a database -// ### @options {Object} Set of options can be -// #### options['name'] {String} Name of the database to view (required) -// #### options['owner'] {String} Username of the database owner (required) -// ### @callback {Function} Continuation to respond to when complete. -exports.remove = function remove(options, callback) { - // Check for options - if (typeof options === 'function') { - return errs.handle(errs.create({ - message: 'Options required for delete a database.' - }), options); - } - - // Check for name - if (!options['name']) { - return errs.handle(errs.create({ - message: 'options. Name is a required argument.' - }), callback); - } - - // Check for owner - if (!options['owner']) { - return errs.handle(errs.create({ - message: 'options. Username of owner is a required argument.' - }), callback); - } - - var deleteOptions = { - method: 'DELETE', - path: ['accounts', options['owner'], 'databases', options['name']].join('/') - }; - - this._request(deleteOptions, function (err) { - return err - ? callback(err) - : callback(null); - }); -}; diff --git a/lib/pkgcloud/mongolab/database/client/index.js b/lib/pkgcloud/mongolab/database/client/index.js deleted file mode 100644 index 129012309..000000000 --- a/lib/pkgcloud/mongolab/database/client/index.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * index.js: Database client for MongoLab databases - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - urlJoin = require('url-join'), - base = require('../../../core/base'), - auth = require('../../../common/auth'), - _ = require('lodash'); - -var Client = exports.Client = function (options) { - base.Client.call(this, options); - - if (!this.before) { - this.before = []; - } - - this.protocol = options.protocol || 'https://'; - this.databaseUrl = options.databaseUrl || 'api.mongolab.com'; - - this.before.push(auth.basic); - - this.before.push(function (req) { - req.json = true; - if (typeof req.body !== 'undefined') { - req.headers['Content-Type'] = 'application/json'; - req.body = JSON.stringify(req.body); - } - }); - - _.extend(this, require('./databases')); - _.extend(this, require('./accounts')); -}; - -util.inherits(Client, base.Client); - -Client.prototype._getUrl = function (options) { - options = options || {}; - - var root = [this.protocol + this.databaseUrl, - 'api', '1', 'partners', (this.config.username) - ? this.config.username - : ''].join('/'); - - return urlJoin(root, typeof options === 'string' - ? options - : options.path); -}; - -Client.prototype.failCodes = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Resize not allowed', - 404: 'Item or Account not found', - 409: 'Build in progress', - 413: 'Over Limit', - 415: 'Bad Media Type', - 500: 'Fault', - 503: 'Service Unavailable' -}; - -Client.prototype.successCodes = { - 200: 'OK', - 201: 'Created', - 202: 'Accepted', - 203: 'Non-authoritative information', - 204: 'No content' -}; \ No newline at end of file diff --git a/lib/pkgcloud/mongolab/database/index.js b/lib/pkgcloud/mongolab/database/index.js deleted file mode 100644 index 06eb5768e..000000000 --- a/lib/pkgcloud/mongolab/database/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * index.js: Top-level include for the MongoLab database module - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.Client = require('./client').Client; - -exports.createClient = function createClient(options) { - return new exports.Client(options); -}; diff --git a/lib/pkgcloud/mongolab/index.js b/lib/pkgcloud/mongolab/index.js deleted file mode 100644 index 644ab6d7b..000000000 --- a/lib/pkgcloud/mongolab/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * index.js: Top-level include for the MongoLab module. - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.database = require('./database'); diff --git a/lib/pkgcloud/redistogo/database/client/index.js b/lib/pkgcloud/redistogo/database/client/index.js deleted file mode 100644 index 8855eab9b..000000000 --- a/lib/pkgcloud/redistogo/database/client/index.js +++ /dev/null @@ -1,144 +0,0 @@ -/* - * client.js: Database client for RedisToGo Cloud Databases - * - * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - request = require('request'), - pkgcloud = require('../../../../pkgcloud'), - errs = require('errs'); - -var Client = exports.Client = function (options) { - this.username = options.username; - this.password = options.password; - this._url = options.url || 'https://redistogo.com'; -}; - -Client.prototype._getUrl = function () { - return this._url; -}; - -// -// Wrapper for all http requests with RedisToGo -// - -Client.prototype._request = function (options, callback) { - var self = this; - - options.headers['User-Agent'] = util.format('nodejs-pkgcloud/%s', pkgcloud.version); - - request(options, function (err, response, body) { - if (err) { - return callback(err); - } - if (response.statusCode == 401 || response.statusCode == 403) { - return callback('Unauthorized'); - } - if (options.method !== 'DELETE') { - var database; - if (typeof body !== 'object') { - try { - database = JSON.parse(body); - } catch (e) { - return callback('Bad response from server.', body); - } - } else { database = body; } - database = self.formatResponse(database); - return callback(null, database); - } else { - return callback(null, 'deleted'); - } - }); -}; - -// Create a new database at redistogo -// Need a correct plan -// ### @attrs {Object} Map of options -// ##### @attrs['plan'] Plan for the database.(required) -Client.prototype.create = function (attrs, callback) { - // Check for options. - if (!attrs || typeof attrs === 'function') { - return errs.handle(errs.create({ - message: 'Options required for create a database.' - }), Array.prototype.slice.call(arguments).pop()); - } - // Check for plan. - if (!attrs['plan']) { - attrs['plan'] = 'nano'; - } - // - // TODO: Add validation for options.plan types - // - var options = { - uri : this._getUrl() + '/instances.json', - method : 'POST', - body : 'instance%5Bplan%5D=' + attrs.plan, - headers: { - 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64') - } - }; - this._request(options, callback); -}; - -// Get information about specific database -// Need the database ID -// ### @id {String} ID of the database.(required) -Client.prototype.get = function (id, callback) { - // Check for id - if (!id || typeof id === 'function') { - return errs.handle(errs.create({ - message: 'ID is a required argument' - }), Array.prototype.slice.call(arguments).pop()); - } - var options, - path = '/instances'; - if (id !== null) { - path = path + '/' + id; - } - options = { - uri : this._getUrl() + path + '.json', - method : 'GET', - headers: { - 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64') - } - }; - this._request(options, callback); -}; - -// Removes one Redis instance by id -// Need the database ID -// ### @id {String} ID of the database.(required) -Client.prototype.remove = function (id, callback) { - // Check for id - if (!id || typeof id === 'function') { - return errs.handle(errs.create({ - message: 'ID is a required argument' - }), Array.prototype.slice.call(arguments).pop()); - } - var options, - path = '/instances/' + id; - options = { - uri : this._getUrl() + path + '.json', - method : 'DELETE', - headers: { - 'Authorization': 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64'), - 'Content-Length': 0 - } - }; - this._request(options, callback); -}; - -Client.prototype.formatResponse = function (response) { - var database = { - id: response.id, - port: response.port, - host: response.label.split('-')[0] + '.redistogo.com', - uri: 'redis://nodejitsu:' + response.password + '@' + response.label.split('-')[0] + '.redistogo.com:' + response.port, - username: 'nodejitsu', - password: response.password, - metadata: response - }; - return database; -}; diff --git a/lib/pkgcloud/redistogo/database/index.js b/lib/pkgcloud/redistogo/database/index.js deleted file mode 100644 index 5ce4296b4..000000000 --- a/lib/pkgcloud/redistogo/database/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * index.js: Top-level include for the RedisToGo database module - * - * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.Client = require('./client').Client; - -exports.createClient = function createClient(options) { - return new exports.Client(options); -}; diff --git a/lib/pkgcloud/redistogo/index.js b/lib/pkgcloud/redistogo/index.js deleted file mode 100644 index c523d9448..000000000 --- a/lib/pkgcloud/redistogo/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * index.js: Top-level include for the RedisToGo module. - * - * (C) 2011 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.database = require('./database'); diff --git a/lib/pkgcloud/telefonica/compute/client.js b/lib/pkgcloud/telefonica/compute/client.js deleted file mode 100644 index 84e182072..000000000 --- a/lib/pkgcloud/telefonica/compute/client.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * index.js: Compute client for Telefonica InstantServers CloudAPI - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -var util = require('util'), - urlJoin = require('url-join'), - joyent = require('../../joyent/compute'); - -var Client = exports.Client = function (options) { - joyent.Client.call(this, options); - - this.serversUrl = options.serversUrl - || process.env.SDC_CLI_URL - || 'api-eu-lon-1.instantservers.telefonica.com'; -}; - -util.inherits(Client, joyent.Client); - -Client.prototype._getUrl = function (options) { - options = options || {}; - - return urlJoin(this.serversUrl - ? 'https://' + this.serversUrl - : 'https://api-eu-lon-1.instantservers.telefonica.com', - (typeof options === 'string' ? - options : options.path)); -}; diff --git a/lib/pkgcloud/telefonica/compute/index.js b/lib/pkgcloud/telefonica/compute/index.js deleted file mode 100644 index fba2e8848..000000000 --- a/lib/pkgcloud/telefonica/compute/index.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * index.js: Top-level include for the Telefonica compute module - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.Client = require('./client').Client; -exports.Flavor = require('../../joyent/compute/flavor').Flavor; -exports.Image = require('../../joyent/compute/image').Image; -exports.Server = require('../../joyent/compute/server').Server; - -exports.createClient = function (options) { - return new exports.Client(options); -}; diff --git a/lib/pkgcloud/telefonica/index.js b/lib/pkgcloud/telefonica/index.js deleted file mode 100644 index fb52f1e4d..000000000 --- a/lib/pkgcloud/telefonica/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * index.js: Top-level include for the Telefonica module. - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * - */ - -exports.compute = require('./compute'); diff --git a/package.json b/package.json index 73b1f9bdf..c27e6e89f 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "cloud computing", "api", "rackspace", - "joyent", "aws", "amazon", "azure", @@ -43,13 +42,8 @@ "servers", "compute", "storage", - "databases", "client", - "mongolab", - "iriscouch", - "mongohq", "openstack", - "redistogo", "hpcloud", "hp", "helion" diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index ce4c11ab0..6448f61c0 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -177,7 +177,7 @@ providers.filter(function (provider) { it('the setWait() method waiting for a server to be operational should return a running server', function (done) { // TODO enable destroy tests for all providers - if (provider === 'joyent' || provider === 'amazon' || provider === 'azure') { + if (provider === 'amazon' || provider === 'azure') { done(); return; } @@ -293,12 +293,6 @@ setupVersionMock = function (client, provider, servers) { .get('/v2/', { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/hp/versions.json'); } - else if (provider === 'joyent') { - servers.server - .get('/' + client.account + '/datacenters', - { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) - .reply(200, '', { 'x-api-version': '6.5.0' }); - } }; setupFlavorMock = function (client, provider, servers) { @@ -313,12 +307,6 @@ setupFlavorMock = function (client, provider, servers) { { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); } - else if (provider === 'joyent') { - servers.server - .get('/' + client.account + '/packages', - { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) - .replyWithFile(200, __dirname + '/../../fixtures/joyent/flavors.json'); - } else if (provider === 'digitalocean') { servers.server .get('/v2/sizes') @@ -350,12 +338,6 @@ setupImagesMock = function (client, provider, servers) { { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); } - else if (provider === 'joyent') { - servers.server - .get('/' + client.account + '/datasets', - { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) - .replyWithFile(200, __dirname + '/../../fixtures/joyent/images.json'); - } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) @@ -433,21 +415,6 @@ setupServerMock = function (client, provider, servers) { { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated.json'); } - else if (provider === 'joyent') { - servers.server - .post('/' + client.account + '/machines', - { - name: 'create-test-setWait', - 'package': 'Small 1GB', - dataset: 'sdc:sdc:nodejitsu:1.0.0' - }, - { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) - .replyWithFile(200, __dirname + '/../../fixtures/joyent/setWait.json') - .get('/' + client.account + - '/machines/534aa63a-104f-4d6d-a3b1-c0d341a20a53', - { 'User-Agent': util.format('nodejs-pkgcloud/%s', pkgcloud.version) }) - .replyWithFile(200, __dirname + '/../../fixtures/joyent/setWaitResp1.json'); - } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index bee5d174f..5c1ad361b 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -275,11 +275,6 @@ setupImagesMock = function (client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/images/detail') .replyWithFile(200, __dirname + '/../../fixtures/openstack/images.json'); } - else if (provider === 'joyent') { - servers.server - .get('/' + client.account + '/datasets') - .replyWithFile(200, __dirname + '/../../fixtures/joyent/images.json'); - } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) @@ -345,11 +340,6 @@ setupFlavorMock = function (client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/flavors/detail') .replyWithFile(200, __dirname + '/../../fixtures/openstack/flavors.json'); } - else if (provider === 'joyent') { - servers.server - .get('/' + client.account + '/packages') - .replyWithFile(200, __dirname + '/../../fixtures/joyent/flavors.json'); - } else if (provider === 'digitalocean') { servers.server .get('/v2/sizes') @@ -402,16 +392,6 @@ setupServerMock = function (client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } - else if (provider === 'joyent') { - servers.server - .post('/' + client.account + '/machines', - require(__dirname + '/../../fixtures/joyent/createServer.json')) - .replyWithFile(201, __dirname + '/../../fixtures/joyent/createdServer.json') - .get('/' + client.account + - '/machines/14186c17-0fcd-4bb5-ab42-51b848bda7e9') - .replyWithFile(200, - __dirname + '/../../fixtures/joyent/14186c17.json'); - } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) @@ -505,11 +485,6 @@ setupGetServersMock = function (client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/detail') .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverList.json'); } - else if (provider === 'joyent') { - servers.server - .get('/' + client.account + '/machines') - .replyWithFile(200, __dirname + '/../../fixtures/joyent/servers.json'); - } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) @@ -557,11 +532,6 @@ setupGetServerMock = function (client, provider, servers) { .get('/v2/72e90ecb69c44d0296072ea39e537041/servers/5a023de8-957b-4822-ad84-8c7a9ef83c07') .replyWithFile(200, __dirname + '/../../fixtures/openstack/serverCreated2.json'); } - else if (provider === 'joyent') { - servers.server - .get('/' + client.account + '/machines/14186c17-0fcd-4bb5-ab42-51b848bda7e9') - .replyWithFile(200, __dirname + '/../../fixtures/joyent/14186c17.json'); - } else if (provider === 'amazon') { servers.server .filteringRequestBody(helpers.authFilter) diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index 2ac11617b..d5241b8ac 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -78,11 +78,6 @@ providers.filter(function (provider) { it('the createContainer() method should return newly created container', function(done) { if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupCreateContainerMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -106,11 +101,6 @@ providers.filter(function (provider) { it('the getContainers() method should return newly created container', function (done) { if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupGetContainersMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -136,11 +126,6 @@ providers.filter(function (provider) { it('the upload() method with container and filename should succeed', function (done) { if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupUploadStreamMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -179,11 +164,6 @@ providers.filter(function (provider) { it('the download() method with container and filename should succeed', function (done) { if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupDownloadStreamMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -211,11 +191,6 @@ providers.filter(function (provider) { it('the getFile() method with container and filename should succeed', function (done) { if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupGetFileMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -237,11 +212,6 @@ providers.filter(function (provider) { it('the getFiles() method with container should succeed', function (done) { if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupGetFilesMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -268,11 +238,6 @@ providers.filter(function (provider) { it('the removeFile() method with container and filename should succeed', function (done) { if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupRemoveFileMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -291,8 +256,8 @@ providers.filter(function (provider) { it('the upload() method with large file should succeed', function (done) { if (mock) { - //TODO make it work for google - //TODO make it work for azure - no idea why it fails on node 0.10 (it passes for node 6.8) + // TODO make it work for google + // TODO make it work for azure - no idea why it fails on node 0.10 (it passes for node 6.8) if (['google', 'azure'].indexOf(provider) !== -1) { return done(); } @@ -332,8 +297,8 @@ providers.filter(function (provider) { it('the download() method with large file should succeed', function (done) { if (mock) { - //TODO make it work for google - //TODO make it work for azure - no idea why it fails on node 0.10 (it passes for node 6.8) + // TODO make it work for google + // TODO make it work for azure - no idea why it fails on node 0.10 (it passes for node 6.8) if (['google', 'azure'].indexOf(provider) !== -1) { return done(); } @@ -376,13 +341,7 @@ providers.filter(function (provider) { }); it('the destroyContainer() method with container should succeed', function (done) { - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupDestroyContainerMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -399,13 +358,7 @@ providers.filter(function (provider) { }); it('the getContainers() method should succeed', function (done) { - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupGetContainers2Mock(provider, client, { server: hockInstance, authServer: authHockInstance diff --git a/test/common/storage/upload-test.js b/test/common/storage/upload-test.js index a2107c03f..0b7bb5875 100644 --- a/test/common/storage/upload-test.js +++ b/test/common/storage/upload-test.js @@ -54,13 +54,7 @@ providers.filter(function (provider) { }); it('the client.upload stream should emit error', function (done) { - if (mock) { - if (provider === 'joyent') { - // TODO figure out why joyent was disabled in vows based tests - return done(); - } - setupUploadStreamError(provider, client, { server: hockInstance, authServer: authHockInstance diff --git a/test/configs/mock/iriscouch.json b/test/configs/mock/iriscouch.json deleted file mode 100644 index 2b0e5502a..000000000 --- a/test/configs/mock/iriscouch.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "username": "nodejitsu", - "password": "MOCK-PASSWORD", - "protocol": "http://", - "databaseUrl": "localhost:12345/hosting_public" -} \ No newline at end of file diff --git a/test/configs/mock/joyent.json b/test/configs/mock/joyent.json deleted file mode 100644 index c3ed6e879..000000000 --- a/test/configs/mock/joyent.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "account" : "MOCK-ACCOUNT", - "serversUrl" : "localhost:12345", - "protocol" : "http://", - "identity" : "./test/fixtures/testkey" -} diff --git a/test/configs/mock/mongohq.json b/test/configs/mock/mongohq.json deleted file mode 100644 index b5c210ffd..000000000 --- a/test/configs/mock/mongohq.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "username": "nodejitsu", - "password": "MOCK-PASSWORD", - "protocol": "http://", - "databaseUrl": "localhost:12345" -} \ No newline at end of file diff --git a/test/configs/mock/mongolab.json b/test/configs/mock/mongolab.json deleted file mode 100644 index 5caeef383..000000000 --- a/test/configs/mock/mongolab.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "username": "nodejitsu", - "password": "MOCK-PASSWORD", - "cloud": "JYC_us-sw-1", - "protocol": "http://", - "databaseUrl": "localhost:12345" -} \ No newline at end of file diff --git a/test/configs/mock/redistogo.json b/test/configs/mock/redistogo.json deleted file mode 100644 index e3559e901..000000000 --- a/test/configs/mock/redistogo.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "username": "nodejitsu", - "password": "MOCK-PASSWORD", - "url": "http://localhost:12345" -} \ No newline at end of file diff --git a/test/configs/providers.json b/test/configs/providers.json index fd63df7b1..0d2a54369 100644 --- a/test/configs/providers.json +++ b/test/configs/providers.json @@ -1,2 +1,2 @@ -["rackspace", "openstack", "joyent", "azure", "digitalocean", "hp", "google", "oneandone"] +["rackspace", "openstack", "azure", "digitalocean", "hp", "google", "oneandone"] diff --git a/test/fixtures/iriscouch/database-redis.json b/test/fixtures/iriscouch/database-redis.json deleted file mode 100644 index fdbb3333d..000000000 --- a/test/fixtures/iriscouch/database-redis.json +++ /dev/null @@ -1 +0,0 @@ -{"_id":"Redis/nodejitsudb43639","partner":"nodejitsu","creation":{"first_name":"Marak","last_name":"Squires","email":"marak.squires@gmail.com","subdomain":"nodejitsudb43639","password":"sTTi:lh9vCF["}} \ No newline at end of file diff --git a/test/fixtures/iriscouch/database.json b/test/fixtures/iriscouch/database.json deleted file mode 100644 index 7ff10691b..000000000 --- a/test/fixtures/iriscouch/database.json +++ /dev/null @@ -1 +0,0 @@ -{"_id":"Server/nodejitsudb908","partner":"nodejitsu","creation":{"first_name":"Marak","last_name":"Squires","email":"marak.squires@gmail.com","subdomain":"nodejitsudb908"}} \ No newline at end of file diff --git a/test/fixtures/joyent/14186c17.json b/test/fixtures/joyent/14186c17.json deleted file mode 100644 index 855894265..000000000 --- a/test/fixtures/joyent/14186c17.json +++ /dev/null @@ -1,3 +0,0 @@ -{"id": "14186c17-0fcd-4bb5-ab42-51b848bda7e9", "name": "create-test-ids2", "type": "virtualmachine", "state": "running", "dataset": "sdc:sdc:nodejitsu:1.0.0", "ips": ["192.168.26.63", "64.30.132.118"], "memory": 1024, "disk": 30720, "metadata": { - "root_authorized_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyiWqkB9aKGiD7Z8KaBqZA67oo1Ysb5MV+47rQ1gydEyL3Y01FL3HIZMGvxvXLr1lqy3eiWJgTyt0SawqFTtQVY7kMHHkvu2A97h+LP8wdyXrm+MBuxjbQUVGaBRXyv5rFJP9GNZpig+KDBPo54AREmvduwtFAcWFdOC0BCgQ7MwVWcL9xhO02+Ra3fQ70dUV2kUDv/BZFkJaD3Gqc/4cir6oWF2wmdDs1vFpXrfKDi5rLG7CKOo8+pQk3NvSaNBQwonpML4/M1N0NlIM2io7soq5VNknpiCrPdyz2yXl8KFt3/kWLOLMtoxfbHnuuhmHDqLoVy3h7/2vx8Fgr6PWB Charlie@Charlie-Robbinss-MacBook-Pro.localnssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZe2jje7DAL11/Py4/7mFU8jZY4lkdJg0Ikbaq95nizHOqd23P1ONTlJ4OaLuunJSyoa9C4yWcznRCjgj0ZSZyhC+ySTN2aqudPENUksmzu15CxM8yEcs26OVQKqITG3qeBcKeDmyCAkuAWoehwzHfirVvCbBbIvDvbtjLiifCILxUjRxVz0kSJ6BARqWgdVBSI8c3GTm4q0vXp4M2P3Cyk08ZGj31oEsoYdFfPHG3lDgbmYtSVnwsrMK/ZByL6oufzO84Hk1B5KMMCOnjfsUknFZc5tn085T/A1ngkGOtxdoG/8OMchUcmjJfsVBTpy3shyuFUrOzNxipCin5oR5X dscape@air-2.localnssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA15sKCPHrYG51vn0lCBVtV4ZJfHxRGoNweb9Rz4KaB8oAEDEGR0pLf63F78Un2d1V/fM3UdYBQbUXiEOfDvWyMtJCdBPdXbpxfDQxDvT9QxM8cPrwItE1rfgfuCZIl/7sh8UX5DU/TFFSwbgT28xGDe1Cfpu5HCBDKwfXEq3x3thBCxCngmBv69KYf45YC3kvmQ4sBym4+/OFS85L1Mltrk811BAoPulYQW1ZeATlOGwB4c52nI7jKeBaIeHqOLLG7ERGXlikCoWL4m5HaomqoHNDk1t1CHPu2izy+1zsw3wWQOoaQzRWTF6ozEEJ6jN2pLj440w4UBnYx4Nzfi0Og/f5T7+LulLE1xfZO7wawTUc9sTCyAs6jCm/QwZmUzks34IjT/l3F0S3ZDkqRV+Bbd/wPXHHW6PrDRnQJEfstHJB+iqPaRxP2vvQMO0dGsX4x/IYiPCTUJQaFXBa0Dy7V5CNYKImtAxcUAB0gJcNzrsyy2v15YXC2iJz1Xwly6sQHxyxu7wMdoTTcSHYca7cIJTqiDWNpn4dFg+nbzr4OP7RlYkvny3jh9sBEGYKXzHB2opQhD8VR65kPwbmIwBuF7t4BYFFvg/TGyJZ4NUfbSvPIp3zgsdHmtY5OVBXve0Bu8lhoFJ3QWSmRTLD1+Tpl6t8MbbaQZ06X+oFMzJ30cE= jwurster@Jasun-Wursters-MacBook-Pro.localn" -}, "created": "2012-02-15T15:32:20+00:00", "updated": "2012-02-15T15:32:29+00:00"} \ No newline at end of file diff --git a/test/fixtures/joyent/createServer.json b/test/fixtures/joyent/createServer.json deleted file mode 100644 index 08b5de638..000000000 --- a/test/fixtures/joyent/createServer.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"create-test-ids2","package":"Small 1GB","dataset":"sdc:sdc:nodejitsu:1.0.0"} \ No newline at end of file diff --git a/test/fixtures/joyent/createdServer.json b/test/fixtures/joyent/createdServer.json deleted file mode 100644 index 34cdabb5e..000000000 --- a/test/fixtures/joyent/createdServer.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id": "14186c17-0fcd-4bb5-ab42-51b848bda7e9", - "name": "create-test-ids2", - "type": "virtualmachine", - "state": "provisioning", - "dataset": "sdc:sdc:nodejitsu:1.0.0", - "ips": [ - "192.168.26.26", - "64.30.132.75" - ], - "memory": 1024, - "disk": 30720, - "metadata": { - "root_authorized_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyiWqkB9aKGiD7Z8KaBqZA67oo1Ysb5MV+47rQ1gydEyL3Y01FL3HIZMGvxvXLr1lqy3eiWJgTyt0SawqFTtQVY7kMHHkvu2A97h+LP8wdyXrm+MBuxjbQUVGaBRXyv5rFJP9GNZpig+KDBPo54AREmvduwtFAcWFdOC0BCgQ7MwVWcL9xhO02+Ra3fQ70dUV2kUDv/BZFkJaD3Gqc/4cir6oWF2wmdDs1vFpXrfKDi5rLG7CKOo8+pQk3NvSaNBQwonpML4/M1N0NlIM2io7soq5VNknpiCrPdyz2yXl8KFt3/kWLOLMtoxfbHnuuhmHDqLoVy3h7/2vx8Fgr6PWB Charlie@Charlie-Robbinss-MacBook-Pro.localnssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZe2jje7DAL11/Py4/7mFU8jZY4lkdJg0Ikbaq95nizHOqd23P1ONTlJ4OaLuunJSyoa9C4yWcznRCjgj0ZSZyhC+ySTN2aqudPENUksmzu15CxM8yEcs26OVQKqITG3qeBcKeDmyCAkuAWoehwzHfirVvCbBbIvDvbtjLiifCILxUjRxVz0kSJ6BARqWgdVBSI8c3GTm4q0vXp4M2P3Cyk08ZGj31oEsoYdFfPHG3lDgbmYtSVnwsrMK/ZByL6oufzO84Hk1B5KMMCOnjfsUknFZc5tn085T/A1ngkGOtxdoG/8OMchUcmjJfsVBTpy3shyuFUrOzNxipCin5oR5X dscape@air-2.localnssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA15sKCPHrYG51vn0lCBVtV4ZJfHxRGoNweb9Rz4KaB8oAEDEGR0pLf63F78Un2d1V/fM3UdYBQbUXiEOfDvWyMtJCdBPdXbpxfDQxDvT9QxM8cPrwItE1rfgfuCZIl/7sh8UX5DU/TFFSwbgT28xGDe1Cfpu5HCBDKwfXEq3x3thBCxCngmBv69KYf45YC3kvmQ4sBym4+/OFS85L1Mltrk811BAoPulYQW1ZeATlOGwB4c52nI7jKeBaIeHqOLLG7ERGXlikCoWL4m5HaomqoHNDk1t1CHPu2izy+1zsw3wWQOoaQzRWTF6ozEEJ6jN2pLj440w4UBnYx4Nzfi0Og/f5T7+LulLE1xfZO7wawTUc9sTCyAs6jCm/QwZmUzks34IjT/l3F0S3ZDkqRV+Bbd/wPXHHW6PrDRnQJEfstHJB+iqPaRxP2vvQMO0dGsX4x/IYiPCTUJQaFXBa0Dy7V5CNYKImtAxcUAB0gJcNzrsyy2v15YXC2iJz1Xwly6sQHxyxu7wMdoTTcSHYca7cIJTqiDWNpn4dFg+nbzr4OP7RlYkvny3jh9sBEGYKXzHB2opQhD8VR65kPwbmIwBuF7t4BYFFvg/TGyJZ4NUfbSvPIp3zgsdHmtY5OVBXve0Bu8lhoFJ3QWSmRTLD1+Tpl6t8MbbaQZ06X+oFMzJ30cE= jwurster@Jasun-Wursters-MacBook-Pro.localn" - }, - "created": "2012-02-14T16:08:38+00:00", - "updated": "2012-02-14T16:08:38+00:00" -} \ No newline at end of file diff --git a/test/fixtures/joyent/fe4d8e28.json b/test/fixtures/joyent/fe4d8e28.json deleted file mode 100644 index 6a81e371c..000000000 --- a/test/fixtures/joyent/fe4d8e28.json +++ /dev/null @@ -1 +0,0 @@ -{"id":"fe4d8e28-6154-4281-8f0e-dead21585ed5","name":"test-reboot","type":"virtualmachine","state":"running","dataset":"sdc:sdc:nodejitsu:1.0.0","ips":["192.168.26.63","64.30.132.118"],"memory":1024,"disk":30720,"metadata":{"root_authorized_keys":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyiWqkB9aKGiD7Z8KaBqZA67oo1Ysb5MV+47rQ1gydEyL3Y01FL3HIZMGvxvXLr1lqy3eiWJgTyt0SawqFTtQVY7kMHHkvu2A97h+LP8wdyXrm+MBuxjbQUVGaBRXyv5rFJP9GNZpig+KDBPo54AREmvduwtFAcWFdOC0BCgQ7MwVWcL9xhO02+Ra3fQ70dUV2kUDv/BZFkJaD3Gqc/4cir6oWF2wmdDs1vFpXrfKDi5rLG7CKOo8+pQk3NvSaNBQwonpML4/M1N0NlIM2io7soq5VNknpiCrPdyz2yXl8KFt3/kWLOLMtoxfbHnuuhmHDqLoVy3h7/2vx8Fgr6PWB Charlie@Charlie-Robbinss-MacBook-Pro.localnssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZe2jje7DAL11/Py4/7mFU8jZY4lkdJg0Ikbaq95nizHOqd23P1ONTlJ4OaLuunJSyoa9C4yWcznRCjgj0ZSZyhC+ySTN2aqudPENUksmzu15CxM8yEcs26OVQKqITG3qeBcKeDmyCAkuAWoehwzHfirVvCbBbIvDvbtjLiifCILxUjRxVz0kSJ6BARqWgdVBSI8c3GTm4q0vXp4M2P3Cyk08ZGj31oEsoYdFfPHG3lDgbmYtSVnwsrMK/ZByL6oufzO84Hk1B5KMMCOnjfsUknFZc5tn085T/A1ngkGOtxdoG/8OMchUcmjJfsVBTpy3shyuFUrOzNxipCin5oR5X dscape@air-2.localnssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA15sKCPHrYG51vn0lCBVtV4ZJfHxRGoNweb9Rz4KaB8oAEDEGR0pLf63F78Un2d1V/fM3UdYBQbUXiEOfDvWyMtJCdBPdXbpxfDQxDvT9QxM8cPrwItE1rfgfuCZIl/7sh8UX5DU/TFFSwbgT28xGDe1Cfpu5HCBDKwfXEq3x3thBCxCngmBv69KYf45YC3kvmQ4sBym4+/OFS85L1Mltrk811BAoPulYQW1ZeATlOGwB4c52nI7jKeBaIeHqOLLG7ERGXlikCoWL4m5HaomqoHNDk1t1CHPu2izy+1zsw3wWQOoaQzRWTF6ozEEJ6jN2pLj440w4UBnYx4Nzfi0Og/f5T7+LulLE1xfZO7wawTUc9sTCyAs6jCm/QwZmUzks34IjT/l3F0S3ZDkqRV+Bbd/wPXHHW6PrDRnQJEfstHJB+iqPaRxP2vvQMO0dGsX4x/IYiPCTUJQaFXBa0Dy7V5CNYKImtAxcUAB0gJcNzrsyy2v15YXC2iJz1Xwly6sQHxyxu7wMdoTTcSHYca7cIJTqiDWNpn4dFg+nbzr4OP7RlYkvny3jh9sBEGYKXzHB2opQhD8VR65kPwbmIwBuF7t4BYFFvg/TGyJZ4NUfbSvPIp3zgsdHmtY5OVBXve0Bu8lhoFJ3QWSmRTLD1+Tpl6t8MbbaQZ06X+oFMzJ30cE= jwurster@Jasun-Wursters-MacBook-Pro.localn"},"created":"2012-02-15T15:32:20+00:00","updated":"2012-02-15T15:32:29+00:00"} \ No newline at end of file diff --git a/test/fixtures/joyent/flavor.json b/test/fixtures/joyent/flavor.json deleted file mode 100644 index 75fc350a3..000000000 --- a/test/fixtures/joyent/flavor.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "Small 1GB", - "memory": 1024, - "disk": 30720, - "swap": 2048, - "default": true -} \ No newline at end of file diff --git a/test/fixtures/joyent/flavors.json b/test/fixtures/joyent/flavors.json deleted file mode 100644 index d99bea1ef..000000000 --- a/test/fixtures/joyent/flavors.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "name": "Small 1GB", - "memory": 1024, - "disk": 30720, - "swap": 2048, - "default": true - }, - { - "name": "Medium 2GB", - "memory": 2048, - "disk": 61440, - "swap": 4096, - "default": false - }, - { - "name": "Medium 4GB", - "memory": 4096, - "disk": 122880, - "swap": 8192, - "default": false - }, - { - "name": "Large 8GB", - "memory": 8192, - "disk": 245760, - "swap": 16384, - "default": false - }, - { - "name": "Large 16GB", - "memory": 16384, - "disk": 491520, - "swap": 32768, - "default": false - }, - { - "name": "XL 32GB", - "memory": 32768, - "disk": 778240, - "swap": 65536, - "default": false - }, - { - "name": "XXL 48GB", - "memory": 49152, - "disk": 1048576, - "swap": 98304, - "default": false - }, - { - "name": "XXXL 64GB ", - "memory": 65536, - "disk": 1572864, - "swap": 131072, - "default": false - }, - { - "name": "XL 8GB High CPU", - "memory": 8192, - "disk": 245760, - "swap": 16384, - "default": false - }, - { - "name": "Medium 1GB High-CPU", - "memory": 1024, - "disk": 61440, - "swap": 2048, - "default": false - } -] \ No newline at end of file diff --git a/test/fixtures/joyent/image.json b/test/fixtures/joyent/image.json deleted file mode 100644 index 796c6efe4..000000000 --- a/test/fixtures/joyent/image.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "880c3250-51ff-11e1-b7aa-837f081ac1a9", - "urn": "sdc:sdc:nodejitsu:1.0.0", - "name": "nodejitsu", - "os": "linux", - "type": "virtualmachine", - "description": "nodejitsu 1.0.0 VM Image", - "default": true, - "requirements": {}, - "version": "1.0.0", - "created": "2012-02-08T18:41:41+00:00" -} \ No newline at end of file diff --git a/test/fixtures/joyent/images.json b/test/fixtures/joyent/images.json deleted file mode 100644 index ac9f17851..000000000 --- a/test/fixtures/joyent/images.json +++ /dev/null @@ -1,350 +0,0 @@ -[ - { - "id": "880c3250-51ff-11e1-b7aa-837f081ac1a9", - "urn": "sdc:sdc:nodejitsu:1.0.0", - "name": "nodejitsu", - "os": "linux", - "type": "virtualmachine", - "description": "nodejitsu 1.0.0 VM Image", - "default": true, - "requirements": {}, - "version": "1.0.0", - "created": "2012-02-08T18:41:41+00:00" - }, - { - "id": "7a4f84be-df6d-11e0-a504-3f6609d83831", - "urn": "sdc:admin:windows2008r2:1.5.0", - "name": "windows2008r2", - "os": "windows", - "type": "virtualmachine", - "description": "windows2008r2 1.5.0 VM image", - "default": false, - "requirements": {}, - "version": "1.5.0", - "created": "2011-09-15T08:45:09+00:00" - }, - { - "id": "988c2f4e-4314-11e1-8dc3-2bc6d58f4be2", - "urn": "sdc:sdc:centos-5.7:1.2.1", - "name": "centos-5.7", - "os": "linux", - "type": "virtualmachine", - "description": "Centos 5.7 VM 1.2.1", - "default": false, - "requirements": {}, - "version": "1.2.1", - "created": "2012-02-10T19:17:40+00:00" - }, - { - "id": "e62c30b4-cdda-11e0-9dd4-af4d032032e3", - "urn": "sdc:sdc:nodejs:1.2.3", - "name": "nodejs", - "os": "smartos", - "type": "smartmachine", - "description": "Node.js git-deploy PaaS dataset", - "default": false, - "requirements": {}, - "version": "1.2.3", - "created": "2011-09-15T08:23:54+00:00" - }, - { - "id": "f953e97e-4991-11e1-9ea4-27c6e7e8afda", - "urn": "sdc:sdc:nodejs:1.3.3", - "name": "nodejs", - "os": "smartos", - "type": "smartmachine", - "description": "Node.js git-deploy PaaS dataset", - "default": false, - "requirements": {}, - "version": "1.3.3", - "created": "2012-01-31T16:18:06+00:00" - }, - { - "id": "3f8a3d02-43e4-11e1-9565-7f82a075e289", - "urn": "sdc:sdc:fedora-14:1.0.1", - "name": "fedora-14", - "os": "linux", - "type": "virtualmachine", - "description": "Fedora 14 VM 1.0.1", - "default": false, - "requirements": {}, - "version": "1.0.1", - "created": "2012-01-27T18:16:24+00:00" - }, - { - "id": "e6ac6784-44b3-11e1-8555-87c3dd87aafe", - "urn": "sdc:sdc:debian-6.03:1.0.0", - "name": "debian-6.03", - "os": "linux", - "type": "virtualmachine", - "description": "Debian 6.03 VM 1.0.0", - "default": false, - "requirements": {}, - "version": "1.0.0", - "created": "2012-01-22T04:49:31+00:00" - }, - { - "id": "71101322-43a5-11e1-8f01-cf2a3031a7f3", - "urn": "sdc:sdc:ubuntu-10.04:1.0.0", - "name": "ubuntu-10.04", - "os": "linux", - "type": "virtualmachine", - "description": "Ubuntu 10.04 VM 1.0.0", - "default": false, - "requirements": {}, - "version": "1.0.0", - "created": "2012-01-27T18:10:51+00:00" - }, - { - "id": "e4cd7b9e-4330-11e1-81cf-3bb50a972bd9", - "urn": "sdc:sdc:centos-6:1.0.0", - "name": "centos-6", - "os": "linux", - "type": "virtualmachine", - "description": "Centos 6 VM 1.0.0", - "default": false, - "requirements": {}, - "version": "1.0.0", - "created": "2012-01-20T06:47:12+00:00" - }, - { - "id": "1796eb3a-48d3-11e1-94db-3ba91709fad9", - "urn": "sdc:sdc:riak:1.5.5", - "name": "riak", - "os": "smartos", - "type": "smartmachine", - "description": "Riak SmartMachine template", - "default": false, - "requirements": {}, - "version": "1.5.5", - "created": "2012-01-30T17:41:29+00:00" - }, - { - "id": "1a9570ec-48e0-11e1-851f-13b84c932a46", - "urn": "local:admin:riakeds:1.5.5", - "name": "riakeds", - "os": "smartos", - "type": "smartmachine", - "description": "Riak EDS SmartMachine template", - "default": false, - "requirements": {}, - "version": "1.5.5", - "created": "2012-01-31T18:03:04+00:00" - }, - { - "id": "8eafbcca-1f8d-11e1-b18b-036f107bbf62", - "urn": "sdc:sdc:mongodb:1.0.6", - "name": "mongodb", - "os": "smartos", - "type": "smartmachine", - "description": "MongoDB SmartMachine", - "default": false, - "requirements": {}, - "version": "1.0.6", - "created": "2011-12-05T23:17:00+00:00" - }, - { - "id": "e05dbcac-1d44-11e1-b8ab-bf1bc04c2d65", - "urn": "sdc:sdc:smartosplus64:3.0.7", - "name": "smartosplus64", - "os": "smartos", - "type": "smartmachine", - "description": "Generic multi-purpose SmartMachine template", - "default": false, - "requirements": {}, - "version": "3.0.7", - "created": "2011-12-05T22:48:35+00:00" - }, - { - "id": "fcc5996a-1d34-11e1-899e-7bd98b87947a", - "urn": "sdc:sdc:smartosplus:3.0.7", - "name": "smartosplus", - "os": "smartos", - "type": "smartmachine", - "description": "Generic multi-purpose SmartMachine template", - "default": false, - "requirements": {}, - "version": "3.0.7", - "created": "2011-12-05T22:45:42+00:00" - }, - { - "id": "e483afce-10b2-11e1-86bc-ff468add832f", - "urn": "sdc:sdc:debian603:0.1.0", - "name": "debian603", - "os": "linux", - "type": "virtualmachine", - "description": "debian603 base install seed image", - "default": false, - "requirements": {}, - "version": "0.1.0", - "created": "2011-11-22T20:49:05+00:00" - }, - { - "id": "5fef6eda-05f2-11e1-90fc-13dac5e4a347", - "urn": "sdc:sdc:percona:1.2.2", - "name": "percona", - "os": "smartos", - "type": "smartmachine", - "description": "Percona SmartMachine", - "default": false, - "requirements": {}, - "version": "1.2.2", - "created": "2011-11-03T20:27:48+00:00" - }, - { - "id": "34359ccc-21d2-2e4e-87e8-69fb36412008", - "urn": "sdc:sdc:windows2008r2standard:1.5.1", - "name": "windows2008r2standard", - "os": "windows", - "type": "virtualmachine", - "description": "windows2008r2standard VM image", - "default": false, - "requirements": {}, - "version": "1.5.1", - "created": "2011-10-11T22:15:41+00:00" - }, - { - "id": "a9380908-ea0e-11e0-aeee-4ba794c83c33", - "urn": "sdc:sdc:percona:1.0.7", - "name": "percona", - "os": "smartos", - "type": "smartmachine", - "description": "Percona SmartMachine", - "default": false, - "requirements": {}, - "version": "1.0.7", - "created": "2011-09-28T22:51:07+00:00" - }, - { - "id": "df3589dc-df9a-11e0-a3a3-07ceee3e7d54", - "urn": "sdc:sdc:smartosplus64:3.0.4", - "name": "smartosplus64", - "os": "smartos", - "type": "smartmachine", - "description": "Generic multi-purpose SmartMachine template", - "default": false, - "requirements": {}, - "version": "3.0.4", - "created": "2011-09-15T13:21:28+00:00" - }, - { - "id": "aded640a-df98-11e0-b050-1f55ff3ddfa7", - "urn": "sdc:sdc:smartosplus:3.0.4", - "name": "smartosplus", - "os": "smartos", - "type": "smartmachine", - "description": "Generic multi-purpose SmartMachine template", - "default": true, - "requirements": {}, - "version": "3.0.4", - "created": "2011-09-15T13:20:11+00:00" - }, - { - "id": "ea9c36aa-c90b-4e0f-8516-72ec78be2470", - "urn": "sdc:sdc:zxtm-standard-1gbps:1.1.1", - "name": "zxtm-standard-1gbps", - "os": "smartos", - "type": "smartmachine", - "description": "Zeus TM Standard 1 Gbps SmartMachine", - "default": false, - "requirements": {}, - "version": "1.1.1", - "created": "2011-09-15T08:37:31+00:00" - }, - { - "id": "3ffa8676-2a5d-4497-b446-656173b2e738", - "urn": "sdc:sdc:zxtm-standard-200mbps:1.1.1", - "name": "zxtm-standard-200mbps", - "os": "smartos", - "type": "smartmachine", - "description": "Zeus TM Standard 200 Mbps SmartMachine", - "default": false, - "requirements": {}, - "version": "1.1.1", - "created": "2011-09-15T08:34:54+00:00" - }, - { - "id": "6f9c6970-9a31-4b64-b0f4-f6b05ab515f4", - "urn": "sdc:sdc:zeus-lb-200mbps:1.1.1", - "name": "zeus-lb-200mbps", - "os": "smartos", - "type": "smartmachine", - "description": "Zeus Load Balancer 200 Mbps SmartMachine", - "default": false, - "requirements": {}, - "version": "1.1.1", - "created": "2011-09-15T08:31:14+00:00" - }, - { - "id": "875798c3-44b6-4ade-b89c-46e71b020a15", - "urn": "sdc:sdc:zxtm-enterprise-1gbps:1.1.1", - "name": "zxtm-enterprise-1gbps", - "os": "smartos", - "type": "smartmachine", - "description": "Zeus TM Enterprise 1 Gbps SmartMachine", - "default": false, - "requirements": {}, - "version": "1.1.1", - "created": "2011-09-15T08:51:59+00:00" - }, - { - "id": "a6e2bccd-6121-4d67-ac76-7ea541a589cf", - "urn": "sdc:sdc:zxtm-enterprise-200mbps:1.1.1", - "name": "zxtm-enterprise-200mbps", - "os": "smartos", - "type": "smartmachine", - "description": "Zeus TM Enterprise 200 Mbps SmartMachine", - "default": false, - "requirements": {}, - "version": "1.1.1", - "created": "2011-09-15T08:51:37+00:00" - }, - { - "id": "33904834-1f01-49d3-bed3-b642e158c375", - "urn": "sdc:sdc:zeus-simple-lb-200mbps:1.1.1", - "name": "zeus-simple-lb-200mbps", - "os": "smartos", - "type": "smartmachine", - "description": "Zeus Simple Load Balancer 200 Mbps SmartMachine", - "default": false, - "requirements": {}, - "version": "1.1.1", - "created": "2011-09-15T08:30:22+00:00" - }, - { - "id": "3fcf35d2-dd79-11e0-bdcd-b3c7ac8aeea6", - "urn": "sdc:sdc:mysql:1.4.1", - "name": "mysql", - "os": "smartos", - "type": "smartmachine", - "description": "MySQL SmartMachine", - "default": false, - "requirements": {}, - "version": "1.4.1", - "created": "2011-09-15T07:18:23+00:00" - }, - { - "id": "141194fa-dd77-11e0-8539-27dd8d8264b8", - "urn": "sdc:sdc:smartos64:1.4.7", - "name": "smartos64", - "os": "smartos", - "type": "smartmachine", - "description": "Base template to build other templates on", - "default": false, - "requirements": {}, - "version": "1.4.7", - "created": "2011-09-15T07:32:37+00:00" - }, - { - "id": "f8ea0bb8-dd75-11e0-87c3-af5352ad3bd6", - "urn": "sdc:sdc:smartos:1.4.7", - "name": "smartos", - "os": "smartos", - "type": "smartmachine", - "description": "Base template to build other templates on", - "default": false, - "requirements": {}, - "version": "1.4.7", - "created": "2011-09-15T07:31:01+00:00" - } -] \ No newline at end of file diff --git a/test/fixtures/joyent/rebootServerRequest1.json b/test/fixtures/joyent/rebootServerRequest1.json deleted file mode 100644 index b553fafd5..000000000 --- a/test/fixtures/joyent/rebootServerRequest1.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"test-reboot","package":"Small 1GB","dataset":"sdc:sdc:nodejitsu:1.0.0"} \ No newline at end of file diff --git a/test/fixtures/joyent/rebootServerResponse1.json b/test/fixtures/joyent/rebootServerResponse1.json deleted file mode 100644 index 3f23de771..000000000 --- a/test/fixtures/joyent/rebootServerResponse1.json +++ /dev/null @@ -1 +0,0 @@ -{"id":"fe4d8e28-6154-4281-8f0e-dead21585ed5","name":"test-reboot","type":"virtualmachine","state":"provisioning","dataset":"sdc:sdc:nodejitsu:1.0.0","ips":["192.168.26.63","64.30.132.118"],"memory":1024,"disk":30720,"metadata":{"root_authorized_keys":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyiWqkB9aKGiD7Z8KaBqZA67oo1Ysb5MV+47rQ1gydEyL3Y01FL3HIZMGvxvXLr1lqy3eiWJgTyt0SawqFTtQVY7kMHHkvu2A97h+LP8wdyXrm+MBuxjbQUVGaBRXyv5rFJP9GNZpig+KDBPo54AREmvduwtFAcWFdOC0BCgQ7MwVWcL9xhO02+Ra3fQ70dUV2kUDv/BZFkJaD3Gqc/4cir6oWF2wmdDs1vFpXrfKDi5rLG7CKOo8+pQk3NvSaNBQwonpML4/M1N0NlIM2io7soq5VNknpiCrPdyz2yXl8KFt3/kWLOLMtoxfbHnuuhmHDqLoVy3h7/2vx8Fgr6PWB Charlie@Charlie-Robbinss-MacBook-Pro.localnssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZe2jje7DAL11/Py4/7mFU8jZY4lkdJg0Ikbaq95nizHOqd23P1ONTlJ4OaLuunJSyoa9C4yWcznRCjgj0ZSZyhC+ySTN2aqudPENUksmzu15CxM8yEcs26OVQKqITG3qeBcKeDmyCAkuAWoehwzHfirVvCbBbIvDvbtjLiifCILxUjRxVz0kSJ6BARqWgdVBSI8c3GTm4q0vXp4M2P3Cyk08ZGj31oEsoYdFfPHG3lDgbmYtSVnwsrMK/ZByL6oufzO84Hk1B5KMMCOnjfsUknFZc5tn085T/A1ngkGOtxdoG/8OMchUcmjJfsVBTpy3shyuFUrOzNxipCin5oR5X dscape@air-2.localnssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA15sKCPHrYG51vn0lCBVtV4ZJfHxRGoNweb9Rz4KaB8oAEDEGR0pLf63F78Un2d1V/fM3UdYBQbUXiEOfDvWyMtJCdBPdXbpxfDQxDvT9QxM8cPrwItE1rfgfuCZIl/7sh8UX5DU/TFFSwbgT28xGDe1Cfpu5HCBDKwfXEq3x3thBCxCngmBv69KYf45YC3kvmQ4sBym4+/OFS85L1Mltrk811BAoPulYQW1ZeATlOGwB4c52nI7jKeBaIeHqOLLG7ERGXlikCoWL4m5HaomqoHNDk1t1CHPu2izy+1zsw3wWQOoaQzRWTF6ozEEJ6jN2pLj440w4UBnYx4Nzfi0Og/f5T7+LulLE1xfZO7wawTUc9sTCyAs6jCm/QwZmUzks34IjT/l3F0S3ZDkqRV+Bbd/wPXHHW6PrDRnQJEfstHJB+iqPaRxP2vvQMO0dGsX4x/IYiPCTUJQaFXBa0Dy7V5CNYKImtAxcUAB0gJcNzrsyy2v15YXC2iJz1Xwly6sQHxyxu7wMdoTTcSHYca7cIJTqiDWNpn4dFg+nbzr4OP7RlYkvny3jh9sBEGYKXzHB2opQhD8VR65kPwbmIwBuF7t4BYFFvg/TGyJZ4NUfbSvPIp3zgsdHmtY5OVBXve0Bu8lhoFJ3QWSmRTLD1+Tpl6t8MbbaQZ06X+oFMzJ30cE= jwurster@Jasun-Wursters-MacBook-Pro.localn"},"created":"2012-02-15T15:32:18+00:00","updated":"2012-02-15T15:32:18+00:00"} \ No newline at end of file diff --git a/test/fixtures/joyent/servers.json b/test/fixtures/joyent/servers.json deleted file mode 100644 index 5f5c2fee9..000000000 --- a/test/fixtures/joyent/servers.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "id": "14186c17-0fcd-4bb5-ab42-51b848bda7e9", - "name": "create-test-ids2", - "type": "virtualmachine", - "state": "provisioning", - "dataset": "sdc:sdc:nodejitsu:1.0.0", - "ips": [ - "192.168.26.26", - "64.30.132.75" - ], - "memory": 1024, - "disk": 30720, - "metadata": { - "root_authorized_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyiWqkB9aKGiD7Z8KaBqZA67oo1Ysb5MV+47rQ1gydEyL3Y01FL3HIZMGvxvXLr1lqy3eiWJgTyt0SawqFTtQVY7kMHHkvu2A97h+LP8wdyXrm+MBuxjbQUVGaBRXyv5rFJP9GNZpig+KDBPo54AREmvduwtFAcWFdOC0BCgQ7MwVWcL9xhO02+Ra3fQ70dUV2kUDv/BZFkJaD3Gqc/4cir6oWF2wmdDs1vFpXrfKDi5rLG7CKOo8+pQk3NvSaNBQwonpML4/M1N0NlIM2io7soq5VNknpiCrPdyz2yXl8KFt3/kWLOLMtoxfbHnuuhmHDqLoVy3h7/2vx8Fgr6PWB Charlie@Charlie-Robbinss-MacBook-Pro.localnssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZe2jje7DAL11/Py4/7mFU8jZY4lkdJg0Ikbaq95nizHOqd23P1ONTlJ4OaLuunJSyoa9C4yWcznRCjgj0ZSZyhC+ySTN2aqudPENUksmzu15CxM8yEcs26OVQKqITG3qeBcKeDmyCAkuAWoehwzHfirVvCbBbIvDvbtjLiifCILxUjRxVz0kSJ6BARqWgdVBSI8c3GTm4q0vXp4M2P3Cyk08ZGj31oEsoYdFfPHG3lDgbmYtSVnwsrMK/ZByL6oufzO84Hk1B5KMMCOnjfsUknFZc5tn085T/A1ngkGOtxdoG/8OMchUcmjJfsVBTpy3shyuFUrOzNxipCin5oR5X dscape@air-2.localnssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA15sKCPHrYG51vn0lCBVtV4ZJfHxRGoNweb9Rz4KaB8oAEDEGR0pLf63F78Un2d1V/fM3UdYBQbUXiEOfDvWyMtJCdBPdXbpxfDQxDvT9QxM8cPrwItE1rfgfuCZIl/7sh8UX5DU/TFFSwbgT28xGDe1Cfpu5HCBDKwfXEq3x3thBCxCngmBv69KYf45YC3kvmQ4sBym4+/OFS85L1Mltrk811BAoPulYQW1ZeATlOGwB4c52nI7jKeBaIeHqOLLG7ERGXlikCoWL4m5HaomqoHNDk1t1CHPu2izy+1zsw3wWQOoaQzRWTF6ozEEJ6jN2pLj440w4UBnYx4Nzfi0Og/f5T7+LulLE1xfZO7wawTUc9sTCyAs6jCm/QwZmUzks34IjT/l3F0S3ZDkqRV+Bbd/wPXHHW6PrDRnQJEfstHJB+iqPaRxP2vvQMO0dGsX4x/IYiPCTUJQaFXBa0Dy7V5CNYKImtAxcUAB0gJcNzrsyy2v15YXC2iJz1Xwly6sQHxyxu7wMdoTTcSHYca7cIJTqiDWNpn4dFg+nbzr4OP7RlYkvny3jh9sBEGYKXzHB2opQhD8VR65kPwbmIwBuF7t4BYFFvg/TGyJZ4NUfbSvPIp3zgsdHmtY5OVBXve0Bu8lhoFJ3QWSmRTLD1+Tpl6t8MbbaQZ06X+oFMzJ30cE= jwurster@Jasun-Wursters-MacBook-Pro.localn" - }, - "created": "2012-02-14T16:08:38+00:00", - "updated": "2012-02-14T16:08:38+00:00" - } -] \ No newline at end of file diff --git a/test/fixtures/joyent/setWait.json b/test/fixtures/joyent/setWait.json deleted file mode 100644 index c8b0d40c0..000000000 --- a/test/fixtures/joyent/setWait.json +++ /dev/null @@ -1 +0,0 @@ -{"id":"534aa63a-104f-4d6d-a3b1-c0d341a20a53","name":"create-test-setWait","type":"virtualmachine","state":"provisioning","dataset":"sdc:sdc:centos-6:1.0.1","ips":["199.192.240.167","192.168.24.83"],"memory":1024,"disk":30720,"metadata":{"root_authorized_keys":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyiWqkB9aKGiD7Z8KaBqZA67oo1Ysb5MV+47rQ1gydEyL3Y01FL3HIZMGvxvXLr1lqy3eiWJgTyt0SawqFTtQVY7kMHHkvu2A97h+LP8wdyXrm+MBuxjbQUVGaBRXyv5rFJP9GNZpig+KDBPo54AREmvduwtFAcWFdOC0BCgQ7MwVWcL9xhO02+Ra3fQ70dUV2kUDv/BZFkJaD3Gqc/4cir6oWF2wmdDs1vFpXrfKDi5rLG7CKOo8+pQk3NvSaNBQwonpML4/M1N0NlIM2io7soq5VNknpiCrPdyz2yXl8KFt3/kWLOLMtoxfbHnuuhmHDqLoVy3h7/2vx8Fgr6PWB Charlie@Charlie-Robbinss-MacBook-Pro.localnssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZe2jje7DAL11/Py4/7mFU8jZY4lkdJg0Ikbaq95nizHOqd23P1ONTlJ4OaLuunJSyoa9C4yWcznRCjgj0ZSZyhC+ySTN2aqudPENUksmzu15CxM8yEcs26OVQKqITG3qeBcKeDmyCAkuAWoehwzHfirVvCbBbIvDvbtjLiifCILxUjRxVz0kSJ6BARqWgdVBSI8c3GTm4q0vXp4M2P3Cyk08ZGj31oEsoYdFfPHG3lDgbmYtSVnwsrMK/ZByL6oufzO84Hk1B5KMMCOnjfsUknFZc5tn085T/A1ngkGOtxdoG/8OMchUcmjJfsVBTpy3shyuFUrOzNxipCin5oR5X dscape@air-2.localnssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA15sKCPHrYG51vn0lCBVtV4ZJfHxRGoNweb9Rz4KaB8oAEDEGR0pLf63F78Un2d1V/fM3UdYBQbUXiEOfDvWyMtJCdBPdXbpxfDQxDvT9QxM8cPrwItE1rfgfuCZIl/7sh8UX5DU/TFFSwbgT28xGDe1Cfpu5HCBDKwfXEq3x3thBCxCngmBv69KYf45YC3kvmQ4sBym4+/OFS85L1Mltrk811BAoPulYQW1ZeATlOGwB4c52nI7jKeBaIeHqOLLG7ERGXlikCoWL4m5HaomqoHNDk1t1CHPu2izy+1zsw3wWQOoaQzRWTF6ozEEJ6jN2pLj440w4UBnYx4Nzfi0Og/f5T7+LulLE1xfZO7wawTUc9sTCyAs6jCm/QwZmUzks34IjT/l3F0S3ZDkqRV+Bbd/wPXHHW6PrDRnQJEfstHJB+iqPaRxP2vvQMO0dGsX4x/IYiPCTUJQaFXBa0Dy7V5CNYKImtAxcUAB0gJcNzrsyy2v15YXC2iJz1Xwly6sQHxyxu7wMdoTTcSHYca7cIJTqiDWNpn4dFg+nbzr4OP7RlYkvny3jh9sBEGYKXzHB2opQhD8VR65kPwbmIwBuF7t4BYFFvg/TGyJZ4NUfbSvPIp3zgsdHmtY5OVBXve0Bu8lhoFJ3QWSmRTLD1+Tpl6t8MbbaQZ06X+oFMzJ30cE= jwurster@Jasun-Wursters-MacBook-Pro.localn"},"created":"2012-02-16T16:39:04+00:00","updated":"2012-02-16T16:39:04+00:00"} \ No newline at end of file diff --git a/test/fixtures/joyent/setWaitResp1.json b/test/fixtures/joyent/setWaitResp1.json deleted file mode 100644 index 051accaae..000000000 --- a/test/fixtures/joyent/setWaitResp1.json +++ /dev/null @@ -1 +0,0 @@ -{"id":"534aa63a-104f-4d6d-a3b1-c0d341a20a53","name":"create-test-setWait","type":"virtualmachine","state":"running","dataset":"sdc:sdc:centos-6:1.0.1","ips":["199.192.240.167","192.168.24.83"],"memory":1024,"disk":30720,"metadata":{"root_authorized_keys":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyiWqkB9aKGiD7Z8KaBqZA67oo1Ysb5MV+47rQ1gydEyL3Y01FL3HIZMGvxvXLr1lqy3eiWJgTyt0SawqFTtQVY7kMHHkvu2A97h+LP8wdyXrm+MBuxjbQUVGaBRXyv5rFJP9GNZpig+KDBPo54AREmvduwtFAcWFdOC0BCgQ7MwVWcL9xhO02+Ra3fQ70dUV2kUDv/BZFkJaD3Gqc/4cir6oWF2wmdDs1vFpXrfKDi5rLG7CKOo8+pQk3NvSaNBQwonpML4/M1N0NlIM2io7soq5VNknpiCrPdyz2yXl8KFt3/kWLOLMtoxfbHnuuhmHDqLoVy3h7/2vx8Fgr6PWB Charlie@Charlie-Robbinss-MacBook-Pro.localnssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZe2jje7DAL11/Py4/7mFU8jZY4lkdJg0Ikbaq95nizHOqd23P1ONTlJ4OaLuunJSyoa9C4yWcznRCjgj0ZSZyhC+ySTN2aqudPENUksmzu15CxM8yEcs26OVQKqITG3qeBcKeDmyCAkuAWoehwzHfirVvCbBbIvDvbtjLiifCILxUjRxVz0kSJ6BARqWgdVBSI8c3GTm4q0vXp4M2P3Cyk08ZGj31oEsoYdFfPHG3lDgbmYtSVnwsrMK/ZByL6oufzO84Hk1B5KMMCOnjfsUknFZc5tn085T/A1ngkGOtxdoG/8OMchUcmjJfsVBTpy3shyuFUrOzNxipCin5oR5X dscape@air-2.localnssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA15sKCPHrYG51vn0lCBVtV4ZJfHxRGoNweb9Rz4KaB8oAEDEGR0pLf63F78Un2d1V/fM3UdYBQbUXiEOfDvWyMtJCdBPdXbpxfDQxDvT9QxM8cPrwItE1rfgfuCZIl/7sh8UX5DU/TFFSwbgT28xGDe1Cfpu5HCBDKwfXEq3x3thBCxCngmBv69KYf45YC3kvmQ4sBym4+/OFS85L1Mltrk811BAoPulYQW1ZeATlOGwB4c52nI7jKeBaIeHqOLLG7ERGXlikCoWL4m5HaomqoHNDk1t1CHPu2izy+1zsw3wWQOoaQzRWTF6ozEEJ6jN2pLj440w4UBnYx4Nzfi0Og/f5T7+LulLE1xfZO7wawTUc9sTCyAs6jCm/QwZmUzks34IjT/l3F0S3ZDkqRV+Bbd/wPXHHW6PrDRnQJEfstHJB+iqPaRxP2vvQMO0dGsX4x/IYiPCTUJQaFXBa0Dy7V5CNYKImtAxcUAB0gJcNzrsyy2v15YXC2iJz1Xwly6sQHxyxu7wMdoTTcSHYca7cIJTqiDWNpn4dFg+nbzr4OP7RlYkvny3jh9sBEGYKXzHB2opQhD8VR65kPwbmIwBuF7t4BYFFvg/TGyJZ4NUfbSvPIp3zgsdHmtY5OVBXve0Bu8lhoFJ3QWSmRTLD1+Tpl6t8MbbaQZ06X+oFMzJ30cE= jwurster@Jasun-Wursters-MacBook-Pro.localn"},"created":"2012-02-16T16:39:09+00:00","updated":"2012-02-16T16:39:20+00:00"} \ No newline at end of file diff --git a/test/fixtures/mongohq/database.json b/test/fixtures/mongohq/database.json deleted file mode 100644 index eb0c2ae66..000000000 --- a/test/fixtures/mongohq/database.json +++ /dev/null @@ -1 +0,0 @@ -{"id":63562,"config":{"MONGOHQ_URL":"mongodb://nodejitsu:484441bf13a1f89bb8f53eec55942193@alex.mongohq.com:10039/testDatabase"}} \ No newline at end of file diff --git a/test/fixtures/mongolab/customUser.json b/test/fixtures/mongolab/customUser.json deleted file mode 100644 index 3321caca9..000000000 --- a/test/fixtures/mongolab/customUser.json +++ /dev/null @@ -1 +0,0 @@ -{ "name" : "nodejitsu_custompassword" , "adminUser" : { "username" : "nodejitsu_custompassword" , "email" : "custom@password.com"}} \ No newline at end of file diff --git a/test/fixtures/mongolab/database.json b/test/fixtures/mongolab/database.json deleted file mode 100644 index f77683b68..000000000 --- a/test/fixtures/mongolab/database.json +++ /dev/null @@ -1 +0,0 @@ -{ "name" : "nodejitsu_daniel_testDatabase" , "uri" : "mongodb://nodejitsu_daniel:ubcv84coc2euiqsghlp0g0h2gm@dbh86-a.mongolab.com:27867/nodejitsu_daniel_testDatabase"} \ No newline at end of file diff --git a/test/fixtures/mongolab/reqDatabase.json b/test/fixtures/mongolab/reqDatabase.json deleted file mode 100644 index e094686cb..000000000 --- a/test/fixtures/mongolab/reqDatabase.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"nodejitsu_daniel_testDatabase","plan":"free","username":"nodejitsu_daniel","cloud":"JYC_us-sw-1"} \ No newline at end of file diff --git a/test/fixtures/mongolab/user.json b/test/fixtures/mongolab/user.json deleted file mode 100644 index 83b913693..000000000 --- a/test/fixtures/mongolab/user.json +++ /dev/null @@ -1 +0,0 @@ -{ "name" : "nodejitsu_daniel" , "adminUser" : { "username" : "nodejitsu_daniel" , "email" : "daniel@nodejitsu.com" , "password" : "tmmrutb4ho11lta6bggjahjsc5"}} \ No newline at end of file diff --git a/test/fixtures/mongolab/userList.json b/test/fixtures/mongolab/userList.json deleted file mode 100644 index 4f4d11b06..000000000 --- a/test/fixtures/mongolab/userList.json +++ /dev/null @@ -1 +0,0 @@ -[ { "name" : "nodejitsu_custompassword" , "adminUser" : { "username" : "nodejitsu_custompassword" , "email" : "custom@password.com"}} , { "name" : "nodejitsu_daniel" , "adminUser" : { "username" : "nodejitsu_daniel" , "email" : "daniel@nodejitsu.com"}} ] \ No newline at end of file diff --git a/test/fixtures/redistogo/database.json b/test/fixtures/redistogo/database.json deleted file mode 100644 index 314d912b9..000000000 --- a/test/fixtures/redistogo/database.json +++ /dev/null @@ -1 +0,0 @@ -{"activerehashing":true,"appendfsync":"everysec","auto_aof_rewrite_min_size":67108864,"auto_aof_rewrite_percentage":100,"config_command":"54b70572f4e2354bb5af0e5d21a22ad4","connections":10,"created_at":"2012-09-21T23:01:31Z","databases":1,"gc_serial_number":null,"hash_max_zipmap_entries":64,"hash_max_zipmap_value":512,"heroku_hash":null,"id":253739,"info_cache":null,"info_cached_on":null,"label":"ray-9441","last_backup_at":null,"last_bgrewriteaof_at":null,"list_max_ziplist_entries":512,"list_max_ziplist_value":64,"log_level":"notice","master_host":null,"master_password":null,"master_port":null,"maxmemory_policy":"volatile-lru","maxmemory_samples":3,"memory":5242880,"memory_limit_notification":false,"no_appendfsync_on_rewrite":"no","password":"26a5f9c140b50f58e6e414f5f62af0bd","persistence":"snapshot","plan":"nano","port":9441,"server_id":36,"set_max_intset_entries":512,"slave":false,"slave_serve_stale_data":true,"slowlog_enabled":false,"slowlog_log_slower_than":50000,"slowlog_max_len":102,"snapshots":["900 1","300 10","60 10000"],"status":"starting","timeout":150,"trial_expires_at":null,"updated_at":"2012-09-21T23:01:31Z","user_id":123,"version":"2.4.11","vm_enabled":false,"vm_max_memory":4718592,"vm_max_threads":4,"vm_page_size":32,"vm_size":0,"zset_max_ziplist_entries":128,"zset_max_ziplist_value":64} \ No newline at end of file diff --git a/test/fixtures/versions.json b/test/fixtures/versions.json index de40d4742..c583c18e3 100644 --- a/test/fixtures/versions.json +++ b/test/fixtures/versions.json @@ -1 +1 @@ -{"joyent": "6.5.0", "rackspace": "v2", "amazon": "2014-06-15", "azure": "2012-03-01", "openstack": "v2", "hp": "v1","oneandone":"1.7"} \ No newline at end of file +{"rackspace": "v2", "amazon": "2014-06-15", "azure": "2012-03-01", "openstack": "v2", "hp": "v1","oneandone":"1.7"} diff --git a/test/helpers/index.js b/test/helpers/index.js index 830bb7975..8a19ee769 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -9,37 +9,6 @@ helpers.createClient = function createClient(provider, service, config) { config = config || helpers.loadConfig(provider); config.provider = provider; - // use your key for testing, so our credentials dont need to go in the repo - if (provider === 'joyent') { - if (!config.username) { - if (!config.account) { - config.account = process.env.SDC_CLI_ACCOUNT; - } - - if (!config.identity) { - if (process.env.SDC_CLI_IDENTITY) { - config.identity = process.env.SDC_CLI_IDENTITY; - } else { - config.identity = process.env.HOME + '/.ssh/id_rsa'; - } - } - - if (!config.keyId) { - if (process.env.SDC_CLI_KEY_ID) { - config.keyId = process.env.SDC_CLI_KEY_ID; - } else { - config.keyId = 'id_rsa'; - } - } - - if (config.account) { - config.keyId = '/' + config.account + '/keys/' + config.keyId; - config.key = fs.readFileSync(config.identity,'ascii'); - } else { - throw new Error('Can\'t test without username and account'); - } - } - } return pkgcloud[service].createClient(config); }; @@ -109,7 +78,7 @@ helpers.selectInstance = function selectInstance(client, callback) { if (err) { throw new Error(err); } - + if (instances.length === 0) { throw new Error({ message:'No instances found.' }); } diff --git a/test/iriscouch/databases/databases-redis-test.js b/test/iriscouch/databases/databases-redis-test.js deleted file mode 100644 index 93b1adaab..000000000 --- a/test/iriscouch/databases/databases-redis-test.js +++ /dev/null @@ -1,135 +0,0 @@ -/* -* databases-redis-test.js: Tests for IrisCouch Redis database service -* -* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. -* MIT LICENSE -* -*/ - -var helpers = require('../../helpers'), - should = require('should'), - hock = require('hock'), - http = require('http'), - mock = !!process.env.MOCK; - -// Declaring variables for helper functions defined later -var randomPassword; - -describe('pkgcloud/iriscouch/databases-redis', function () { - var context = {}, client, hockInstance, server; - - before(function (done) { - client = helpers.createClient('iriscouch', 'database'); - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock(); - server = http.createServer(hockInstance.handler); - server.listen(12345, done); - }); - - it('the create() method with correct options should respond correctly', function(done) { - var subdomain = (mock ? 'nodejitsudb43639' : 'nodejitsudb' + Math.floor(Math.random() * 100000)); - context.tempPassword = (mock ? 'sTTi:lh9vCF[' : randomPassword(12).replace('\\', '')); - - if (mock) { - hockInstance - .post('/hosting_public', helpers.loadFixture('iriscouch/database-redis.json')) - .reply(201, { ok: true, - id: 'Redis/nodejitsudb43639', - rev: '1-63cf360ebc115cdc8a709a910fdef6d7' - }); - } - - client.create({ - subdomain: subdomain, - first_name: 'Marak', - last_name: 'Squires', - email: 'marak.squires@gmail.com', - type: 'redis', // For redis instead of couch just put type to redis - password: context.tempPassword - }, function(err, database) { - should.not.exist(err); - should.exist(database); - should.exist(database.id); - should.exist(database.uri); - context.databaseId = database.id; - database.password.should.equal([database.host, context.tempPassword].join(':')); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - describe('the create() method with invalid options like', function() { - it('no options should respond with errors', function(done) { - client.create(function(err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no invalid options should respond with errors', function (done) { - client.create({ invalid: 'keys' }, function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no email should respond with errors', function (done) { - client.create({ - subdomain: 'testDatabase', - first_name: 'Daniel', - last_name: 'Aristizabal'}, - function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no subdomain should respond with errors', function (done) { - client.create({ - email: 'daniel@nodejitsu.com', - first_name: 'Daniel', - last_name: 'Aristizabal'}, - function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no names should respond with errors', function (done) { - client.create({ email: 'daniel@nodejitsu.com', subdomain: 'testDatabase'}, - function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - server.close(done); - }); - -}); - -// -// Just a quick and lazy random password generator -// -randomPassword = function(length) { - if (length == 1) { - return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48); - } - return String.fromCharCode(Math.floor(Math.random() * (122 - 48 + 1)) + 48) + randomPassword(length - 1); -}; diff --git a/test/iriscouch/databases/databases-test.js b/test/iriscouch/databases/databases-test.js deleted file mode 100644 index ebf635c73..000000000 --- a/test/iriscouch/databases/databases-test.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * databases-test.js: Tests for IrisCouch database service - * - * (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. - * MIT LICENSE - * - */ - -var helpers = require('../../helpers'), - should = require('should'), - hock = require('hock'), - http = require('http'), - mock = !!process.env.MOCK; - -describe('pkgcloud/iriscouch/databases', function () { - var context = {}, client, hockInstance, server; - - before(function (done) { - client = helpers.createClient('iriscouch', 'database'); - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock(); - server = http.createServer(hockInstance.handler); - server.listen(12345, done); - }); - - it('the create() method with correct options should respond correctly', function (done) { - var subdomain = (mock ? 'nodejitsudb908' : 'nodejitsudb' + Math.floor(Math.random() * 100000)); - - if (mock) { - - client._getCouchPollingUrl = function() { - return 'http://localhost:12345'; - }; - - hockInstance - .post('/hosting_public', helpers.loadFixture('iriscouch/database.json')) - .reply(201, { - ok: true, - id: 'Server/nodejitsudb908', - rev: '1-dc91e4ee524420e6f32607b0c24151de' - }) - .get('/') - .reply(200); - } - - client.create({ - subdomain: subdomain, - first_name: 'Marak', - last_name: 'Squires', - email: 'marak.squires@gmail.com' - }, function (err, database) { - should.not.exist(err); - should.exist(database); - should.exist(database.id); - should.exist(database.uri); - context.databaseId = database.id; - - hockInstance && hockInstance.done(); - done(); - }); - }); - - describe('the create() method with invalid options like', function () { - it('no options should respond with errors', function (done) { - client.create(function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no invalid options should respond with errors', function (done) { - client.create({ invalid: 'keys' }, function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no email should respond with errors', function (done) { - client.create({ - subdomain: 'testDatabase', - first_name: 'Daniel', - last_name: 'Aristizabal'}, - function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no subdomain should respond with errors', function (done) { - client.create({ - email: 'daniel@nodejitsu.com', - first_name: 'Daniel', - last_name: 'Aristizabal'}, - function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no names should respond with errors', function (done) { - client.create({ email: 'daniel@nodejitsu.com', subdomain: 'testDatabase'}, - function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - server.close(done); - }); - -}); diff --git a/test/mongohq/databases/databases-test.js b/test/mongohq/databases/databases-test.js deleted file mode 100644 index 7ca4726b5..000000000 --- a/test/mongohq/databases/databases-test.js +++ /dev/null @@ -1,108 +0,0 @@ -/* -* databases-test.js: Tests for MongoHQ databases service -* -* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. -* MIT LICENSE -* -*/ - -var helpers = require('../../helpers'), - should = require('should'), - hock = require('hock'), - http = require('http'), - mock = !!process.env.MOCK; - -describe('pkgcloud/mongohq/databases', function () { - var context = {}, client, hockInstance, server; - - before(function (done) { - client = helpers.createClient('mongohq', 'database'); - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock(); - server = http.createServer(hockInstance.handler); - server.listen(12345, done); - }); - - it('the create() method with correct options should respond correctly', function (done) { - - if (mock) { - hockInstance - .post('/provider/resources', 'app_id=testDatabase&plan=free') - .reply(200, helpers.loadFixture('mongohq/database.json')); - } - - client.create({ - plan: 'free', - name: 'testDatabase' - }, function (err, database) { - should.not.exist(err); - should.exist(database); - should.exist(database.id); - should.exist(database.uri); - should.exist(database.username); - should.exist(database.password); - context.databaseId = database.id; - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the remove() method with correct options should respond correctly', function (done) { - - if (mock) { - hockInstance - .delete('/provider/resources/63562') - .reply(200, 'OK'); - } - - client.remove(context.databaseId, function (err, confirm) { - should.not.exist(err); - should.exist(confirm); - confirm.should.equal('deleted'); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - describe('the create() method with invalid options like', function () { - it('no options should respond with errors', function (done) { - client.create(function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no invalid options should respond with errors', function (done) { - client.create({ invalid: 'keys' }, function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - describe('the remove() method with invalid options like', function () { - it('no options should respond with errors', function (done) { - client.remove(function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - server.close(done); - }); -}); diff --git a/test/mongolab/databases/databases-test.js b/test/mongolab/databases/databases-test.js deleted file mode 100644 index 6656e879f..000000000 --- a/test/mongolab/databases/databases-test.js +++ /dev/null @@ -1,445 +0,0 @@ -/* -* databases-test.js: Tests for MongoLab databases service -* -* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. -* MIT LICENSE -* -*/ - -var helpers = require('../../helpers'), - should = require('should'), - hock = require('hock'), - http = require('http'), - mock = !!process.env.MOCK; - -describe('pkgcloud/mongolab/databases', function () { - var context = {}, client, hockInstance, server; - - before(function (done) { - client = helpers.createClient('mongolab', 'database'); - - if (!mock) { - return done(); - } - - hockInstance = hock.createHock(); - server = http.createServer(hockInstance.handler); - server.listen(12345, done); - }); - - it('the createAccount() method with correct options should respond correctly', function (done) { - - if (mock) { - hockInstance - .post('/api/1/partners/nodejitsu/accounts', - '\"{\\\"name\\\":\\\"nodejitsu_daniel\\\",\\\"adminUser\\\":{\\\"email\\\":\\\"daniel@nodejitsu.com\\\"}}\"') - .reply(200, helpers.loadFixture('mongolab/user.json')); - } - - client.createAccount({ - name: 'daniel', - email: 'daniel@nodejitsu.com' - }, function (err, response) { - should.not.exist(err); - should.exist(response); - should.exist(response.account); - should.exist(response.account.username); - should.exist(response.account.email); - should.exist(response.account.password); - context.account = response.account; - - hockInstance && hockInstance.done(); - done(); - }); - }); - -// it('the remove() method with correct options should respond correctly', function (done) { -// -// if (mock) { -// server -// .delete('/provider/resources/63562') -// .reply(200, 'OK'); -// } -// -// client.remove(context.databaseId, function (err, confirm) { -// should.not.exist(err); -// should.exist(confirm); -// confirm.should.equal('deleted'); -// ; -// -// server && server.done(); -// done(); -// }); -// }); - - describe('the createAccount() method with invalid options like', function () { - it('no options should respond with errors', function (done) { - client.createAccount(function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no invalid options should respond with errors', function (done) { - client.createAccount({ invalid: 'keys' }, function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no email should respond with errors', function (done) { - client.createAccount({ name: 'testDatabase' }, function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - describe('the createAccount() method with custom passwords with', function () { - it('no numbers should respond with errors', function(done) { - client.createAccount({ - name: 'custompassword', - email: 'custom@password.com', - password: 'mycustompassword' - }, function(err, response) { - should.exist(err); - should.not.exist(response); - - done(); - }); - }); - - it('with numbers should respond with success', function(done) { - - if (mock) { - hockInstance - .post('/api/1/partners/nodejitsu/accounts', - '\"{\\\"name\\\":\\\"nodejitsu_custompassword\\\",\\\"adminUser\\\":{\\\"email\\\":\\\"custom@password.com\\\",\\\"password\\\":\\\"my1custom2password\\\"}}\"') - .reply(200, helpers.loadFixture('mongolab/customUser.json')); - } - - client.createAccount({ - name: 'custompassword', - email: 'custom@password.com', - password: 'my1custom2password' - }, function(err, response) { - should.not.exist(err); - should.exist(response); - should.exist(response.account); - should.exist(response.account.username); - should.exist(response.account.email); - context.custompw = response.account; - - hockInstance && hockInstance.done(); - done(); - }); - }); - }); - - it('the getAccounts() method should respond with all accounts', function(done) { - - if (mock) { - hockInstance - .get('/api/1/partners/nodejitsu/accounts') - .reply(200, helpers.loadFixture('mongolab/userList.json')); - } - - client.getAccounts(function(err, accounts) { - should.not.exist(err); - should.exist(accounts); - accounts.should.be.an.Array; - accounts.should.have.length(2); - accounts.forEach(function(account) { - should.exist(account.username); - should.exist(account.email); - }); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('the getAccount() method should return the matching account', function(done) { - - if (mock) { - hockInstance - .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel') - .reply(200, { - name: 'nodejitsu_daniel', - adminUser: { - username: 'nodejitsu_daniel', - email: 'daniel@nodejitsu.com' - } - }); - } - - client.getAccount(context.account.username, function (err, account) { - should.not.exist(err); - should.exist(account); - account.username.should.equal(context.account.username); - account.email.should.equal(context.account.email); - - hockInstance && hockInstance.done(); - done(); - }); - - }); - - it('the create() method with correct options should respond correctly', function (done) { - - if (mock) { - hockInstance - .post('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases', '\"' + helpers.loadFixture('mongolab/reqDatabase.json').replace(/"/g, '\\\"') + '\"') - .reply(200, helpers.loadFixture('mongolab/database.json')); - } - - client.create({ - plan:'free', - name:'testDatabase', - owner: context.account.username - }, function (err, database) { - should.not.exist(err); - should.exist(database); - should.exist(database.id); - should.exist(database.uri); - should.exist(database.username); - should.exist(database.password); - context.databaseId = database.id; - - hockInstance && hockInstance.done(); - done(); - }); - }); - - describe('the create() method with invalid options like', function () { - it('no options should respond with errors', function (done) { - client.create(function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no invalid options should respond with errors', function (done) { - client.create({ invalid: 'keys' }, function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - - it('no plan should respond with errors', function (done) { - client.create({ name: 'testDatabase' }, function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - describe('the getDatabases() method', function() { - it('with valid options should respond correctly', function (done) { - - if (mock) { - hockInstance - .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases') - .reply(200, [ { name : 'nodejitsu_daniel_testDatabase' } ]); - } - - client.getDatabases(context.account.username, function (err, databases) { - should.not.exist(err); - should.exist(databases); - databases.should.be.an.Array; - databases.should.have.length(1); - databases[0].should.be.a.Object; - databases[0].name.should.equal(context.account.username + '_testDatabase'); - context.databaseName = databases[0].name; - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('with invalid options should respond with errors', function(done) { - client.getDatabases(function(err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - }); - - describe('the getDatabase() method', function () { - it('with valid options should respond correctly', function (done) { - - if (mock) { - hockInstance - .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases/nodejitsu_daniel_testDatabase') - .reply(200, { name : 'nodejitsu_daniel_testDatabase' }); - } - - client.getDatabase({ - owner: context.account.username, - name: context.databaseName }, - function (err, database) { - should.not.exist(err); - should.exist(database); - database.should.be.a.Object; - database.name.should.equal(context.account.username + '_testDatabase'); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('with invalid options should respond with errors', function (done) { - client.getDatabase(function (err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - - it('with no owner should respond with errors', function (done) { - client.getDatabase({ name: 'no-owner' }, function (err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - - it('with no name should respond with errors', function (done) { - client.getDatabase({ owner: 'no-name' }, function (err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - }); - - describe('the remove() method', function () { - it('with valid options should respond correctly', function (done) { - - if (mock) { - hockInstance - .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases/nodejitsu_daniel_testDatabase') - .reply(200, ' null '); - } - - client.remove({ - owner: context.account.username, - name: context.databaseName }, - function (err) { - should.not.exist(err); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('and have no databases left after getDatabases()', function (done) { - - if (mock) { - hockInstance - .get('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel/databases') - .reply(200, []); - } - - client.getDatabases(context.account.username, function (err, databases) { - should.not.exist(err); - should.exist(databases); - databases.should.be.an.Array; - databases.should.have.length(0); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('with invalid options should respond with errors', function (done) { - client.remove(function (err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - - it('with no owner should respond with errors', function (done) { - client.remove({ name: 'no-owner' }, function (err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - - it('with no name should respond with errors', function (done) { - client.remove({ owner: 'no-name' }, function (err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - }); - - describe('the deleteAccount() method', function () { - it('with valid options should respond correctly', function (done) { - - if (mock) { - hockInstance - .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_daniel') - .reply(200, ' null '); - } - - client.deleteAccount(context.account.username, - function (err) { - should.not.exist(err); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('and delete the other account', function (done) { - - if (mock) { - hockInstance - .delete('/api/1/partners/nodejitsu/accounts/nodejitsu_custompassword') - .reply(200, ' null '); - } - - client.deleteAccount(context.custompw.username, function (err) { - should.not.exist(err); - - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('with invalid options should respond with errors', function (done) { - client.deleteAccount(function (err, databases) { - should.exist(err); - should.not.exist(databases); - - done(); - }); - }); - }); - - after(function (done) { - if (!mock) { - return done(); - } - - server.close(done); - }); -}); diff --git a/test/redistogo/databases/databases-test.js b/test/redistogo/databases/databases-test.js deleted file mode 100644 index 4459f668b..000000000 --- a/test/redistogo/databases/databases-test.js +++ /dev/null @@ -1,131 +0,0 @@ -/* -* databases-test.js: Tests for Redistogo databases service -* -* (C) 2012 Charlie Robbins, Ken Perkins, Ross Kukulinski & the Contributors. -* MIT LICENSE -* -*/ - -var should = require('should'), - helpers = require('../../helpers'), - hock = require('hock'), - http = require('http'), - mock = !!process.env.MOCK; - -describe('pkgcloud/redistogo/databases', function () { - var testContext = {}, - client = helpers.createClient('redistogo', 'database'), - hockInstance = null, - server; - - before(function(done) { - if (!mock) { - return done(); - } - - hockInstance = hock.createHock(); - server = http.createServer(hockInstance.handler); - server.listen(12345, done); - - }); - - describe('The pkgcloud RedisToGo Database client', function () { - describe('the create method()', function() { - it('with correct options should respond correctly', function(done) { - - if (mock) { - hockInstance - .post('/instances.json', 'instance%5Bplan%5D=nano') - .replyWithFile(201, __dirname + '/../../fixtures/redistogo/database.json'); - } - - client.create({ plan: 'nano' }, function(err, database) { - should.not.exist(err); - should.exist(database); - should.exist(database.id); - should.exist(database.uri); - should.exist(database.username); - should.exist(database.password); - testContext.databaseId = database.id; - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('with no options should respond with errors', function (done) { - client.create(function (err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - describe('the get() method', function() { - it('with correct options should respond correctly', function(done) { - if (mock) { - hockInstance - .get('/instances/253739.json') - .replyWithFile(200, __dirname + '/../../fixtures/redistogo/database.json'); - } - - client.get(testContext.databaseId, function (err, database) { - should.not.exist(err); - should.exist(database); - should.exist(database.id); - should.exist(database.uri); - should.exist(database.username); - should.exist(database.password); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('with options should respond with an error', function(done) { - client.get(function(err, database) { - should.exist(err); - should.not.exist(database); - done(); - }); - }); - }); - - describe('the remove() method', function () { - it('with correct options should respond correctly', function (done) { - if (mock) { - hockInstance - .delete('/instances/253739.json') - .reply(200); - } - - client.remove(testContext.databaseId, function (err, confirm) { - should.not.exist(err); - should.exist(confirm); - confirm.should.equal('deleted'); - hockInstance && hockInstance.done(); - done(); - }); - }); - - it('with options should respond with an error', function (done) { - client.remove(function (err, confirm) { - should.exist(err); - should.not.exist(confirm); - done(); - }); - }); - }); - }); - - after(function(done) { - if (hockInstance) { - server.close(function() { - done(); - }); - } - else { - done(); - } - }); -}); - From 9ac833c393d95561a5202a86f2b35679e77d2c49 Mon Sep 17 00:00:00 2001 From: Charlie Robbins Date: Tue, 16 Apr 2019 00:25:36 -0400 Subject: [PATCH 451/460] Update dependencies (#651) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [dist] Treat package-lock.json as binary in git. * [dist] Bump all non-Google Cloud dependencies. * [refactor breaking wip] Migrate to @google-cloud/storage. * [dist] Bump node version. * [dist] Regenerate package-lock.json * [fix] Remove bad require. * [refactor doc] Migrate to nyc. Update maintainers. * [fix] Test with mocks. * [fix] (Mostly) fix upgrade to mime@2 - blocked by `filed`. * [test] fixes failed tests and uses filed-mimefix instead of filed (#654) * [dist] Treat package-lock.json as binary in git. * [dist] Bump all non-Google Cloud dependencies. * [refactor breaking wip] Migrate to @google-cloud/storage. * [dist] Bump node version. * [dist] Regenerate package-lock.json * [fix] Remove bad require. * [refactor doc] Migrate to nyc. Update maintainers. * [fix] Test with mocks. * [fix] (Mostly) fix upgrade to mime@2 - blocked by `filed`. * [test] fixes failed tests and uses filed-mimefix instead of filed * [fix] moves _getServerId to top --- .gitattributes | 1 + .gitignore | 5 +- .npmignore | 16 +- .travis.yml | 8 +- Makefile | 30 - README.md | 48 +- docs/providers/compute-commonality.md | 1 - docs/vocabulary.md | 1 - lib/pkgcloud/azure/compute/client/images.js | 2 +- .../azure/database/client/databases.js | 12 +- .../azure/storage/client/containers.js | 3 +- lib/pkgcloud/azure/storage/client/files.js | 6 +- lib/pkgcloud/azure/utils/azureApi.js | 21 +- lib/pkgcloud/azure/utils/xml2json.js | 2 +- .../digitalocean/compute/client/servers.js | 8 +- lib/pkgcloud/google/client.js | 3 - lib/pkgcloud/google/storage/client/files.js | 2 +- lib/pkgcloud/google/storage/client/index.js | 11 +- .../openstack/database/client/users.js | 1 - .../openstack/storage/client/files.js | 4 +- .../rackspace/storage/client/archive.js | 2 +- package-lock.json | 5291 ++++++++++++----- package.json | 65 +- test/azure/databases/databases-test.js | 2 +- test/common/compute/base-test.js | 10 +- test/common/compute/server-test.js | 16 +- test/common/storage/base-test.js | 52 +- test/fixtures/digitalocean/active.json | 2 +- test/fixtures/digitalocean/create-server.json | 2 +- .../fixtures/digitalocean/create-server2.json | 2 +- test/fixtures/digitalocean/not-active.json | 2 +- test/helpers/index.js | 2 +- test/hp/common/client-test.js | 8 +- test/hp/macros.js | 2 +- test/openstack/cdn/services-test.js | 12 +- test/rackspace/databases/user-limit-test.js | 18 +- test/rackspace/macros.js | 2 +- 37 files changed, 4041 insertions(+), 1634 deletions(-) create mode 100644 .gitattributes delete mode 100644 Makefile diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..1a6bd4587 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +package-lock.json binary diff --git a/.gitignore b/.gitignore index a307754e3..318fba425 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,7 @@ azure_error coverage.html .coveralls.yml pkgcloud.lcov* -node-jscoverage \ No newline at end of file +node-jscoverage +.nyc_output +*.tgz +*.tar.gz diff --git a/.npmignore b/.npmignore index e19255845..260ffcaef 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,15 @@ -test/* \ No newline at end of file +.DS_Store +*.log +*.notes +.*.sw[op] +.project +.idea +azure_error +coverage.html +.coveralls.yml +pkgcloud.lcov* +node-jscoverage +.nyc_output +test/* +*.tgz +*.tar.gz diff --git a/.travis.yml b/.travis.yml index fea05aec5..9c67e9deb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,10 @@ language: node_js node_js: -- '6' - '8' +- '10' notifications: - email: - - ken.perkins@rackspace.com irc: irc.freenode.org#pkgcloud slack: secure: RjlcoxHiKzep+CdLSC4UcL6Wsrv/4F3mzCwnDhIFsoH53XZ4t5oexLyaQxZFVq6KYes7nv2D/w2jUX7z7LBCZ6N0p8Sf/ao2s5O71ETDYDajtQjdEC1/w8PflC61b1EsVfE1tDbDtkFJtVXWKCBUAfbvrMYZwP0f8Ffhf3Bvg2I= -script: -- npm run travis +script: npm test +after_success: npm run coverage diff --git a/Makefile b/Makefile deleted file mode 100644 index ee21a6c77..000000000 --- a/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -MOCHA_CMD = MOCK=on ./node_modules/.bin/mocha -MOCHA_OPTS = --require blanket -t 4000 test/*/*/*-test.js test/*/*/*/*-test.js -DEFAULT_REPORT_OPTS = --reporter spec -HTML_REPORT_OPTS = --reporter html-cov > coverage.html -COVERALLS_REPORT_OPTS = --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js - -check: test - -test: test-unit - -cov: test-cov-html - -travis: lint test-unit test-cov-coveralls - -test-unit: - @echo "$(MOCHA_CMD) $(MOCHA_OPTS) $(REPORT_OPTS)" - @NODE_ENV=test $(MOCHA_CMD) $(MOCHA_OPTS) $(REPORT_OPTS) - -test-cov-html: - @echo "$(MOCHA_CMD) $(MOCHA_OPTS) $(HTML_REPORT_OPTS)" - @NODE_ENV=test $(MOCHA_CMD) $(MOCHA_OPTS) $(HTML_REPORT_OPTS) - -test-cov-coveralls: - @echo "$(MOCHA_CMD) $(MOCHA_OPTS) $(COVERALLS_REPORT_OPTS)" - @NODE_ENV=test $(MOCHA_CMD) $(MOCHA_OPTS) $(COVERALLS_REPORT_OPTS) - -lint: - ./node_modules/.bin/jshint --exclude-path .gitignore . - -.PHONY: test diff --git a/README.md b/README.md index 5f3d0317e..3c9f961e1 100644 --- a/README.md +++ b/README.md @@ -678,34 +678,21 @@ client.on('log::*', function(message, object) { The valid log events raised are `log::debug`, `log::verbose`, `log::info`, `log::warn`, and `log::error`. There is also a [more detailed logging example using pkgcloud with Winston](docs/logging-with-winston.md). ## Code Coverage -You will need jscoverage installed in order to run code coverage. There seems to be many forks of the jscoverage project, but the recommended one is [node-jscoverage](https://github.com/visionmedia/node-jscoverage), because we use [node-coveralls](https://github.com/cainus/node-coveralls) to report coverage to http://coveralls.io. node-coveralls requires output from [mocha-lcov-reporter](https://github.com/StevenLooman/mocha-lcov-reporter), whose documentation mentions node-jscoverage. - -### Warning - -**Running coverage will mess with your lib folder. It will make a backup lib-bak before running and restore it if the coverage task runs successfully.** - -In order to simplify cleanup if something goes wrong, it is recommended to have all all new files added and all changes committed before running coverage, so you'll be able to restore with these commands if something goes wrong: - -``` bash -git clean -fd -git checkout lib -``` - -### Coverage Pre-requisites - -Please make sure jscoverage has been installed following the instructions at [node-jscoverage](https://github.com/visionmedia/node-jscoverage). - -### Local Coverage - -make test-cov ### Run Coverage locally and send to coveralls.io -Travis takes care of coveralls, so this shouldn't be necessary unless you're troubleshooting a problem with Travis/Coveralls. -You'll need to have access to the coveralls repo_token, which should only be visible to pkgcloud/pkgcloud admins. +Travis takes care of coveralls, so this shouldn't be necessary unless you're +troubleshooting a problem with Travis / Coveralls. You'll need to have access +to the coveralls `repo_token`, which should only be visible to +`pkgcloud/pkgcloud` admins. -1. Create a .coveralls.yml containing the repo_token from https://coveralls.io/r/pkgcloud/pkgcloud -2. Run make test-coveralls +1. Create a `.coveralls.yml` containing the `repo_token` from + https://coveralls.io/r/pkgcloud/pkgcloud +2. Run the following: +``` +npm test +npm run coverage +``` ## Contribute! @@ -713,15 +700,6 @@ We welcome contribution to `pkgcloud` by any and all individuals or organization We are pretty flexible about these guidelines, but the closer you follow them the more likely we are to merge your pull-request. - -## Roadmap - -1. Backport latest fixes from `node-cloudfiles` and `node-cloudservers` -2. Implement more providers for Block Storage, DNS, and Load Balancing -3. Add more services: Monitoring, Queueing, Autoscale. -4. Implement `fs` compatible file API. -5. Support additional service providers. - -#### Author: [Nodejitsu Inc.](http://nodejitsu.com) -#### Contributors: [Charlie Robbins](https://github.com/indexzero), [Nuno Job](https://github.com/dscape), [Daniel Aristizabal](https://github.com/cronopio), [Marak Squires](https://github.com/marak), [Dale Stammen](https://github.com/stammen), [Ken Perkins](https://github.com/kenperkins) +#### Author: [Charlie Robbins](https://github.com/indexzero) +#### Contributors: [Ross Kukulinski](https://github.com/rosskukulinski), [Jarrett Cruger](https://github.com/jcrugzz), [Ken Perkins](https://github.com/kenperkins) #### License: MIT diff --git a/docs/providers/compute-commonality.md b/docs/providers/compute-commonality.md index 73ab5ff78..e0051ee12 100644 --- a/docs/providers/compute-commonality.md +++ b/docs/providers/compute-commonality.md @@ -7,7 +7,6 @@ The following table outlines the methods that are available on the different com API AWS Azure -Joyent OpenStack RAX DigitalOcean diff --git a/docs/vocabulary.md b/docs/vocabulary.md index 053c545a5..286440fba 100644 --- a/docs/vocabulary.md +++ b/docs/vocabulary.md @@ -8,7 +8,6 @@ When considering all IaaS providers as a whole, their vocabulary is somewhat dis pkgcloud OpenStack - Joyent Amazon Azure Rackspace diff --git a/lib/pkgcloud/azure/compute/client/images.js b/lib/pkgcloud/azure/compute/client/images.js index 869b80a9c..b6c37354e 100644 --- a/lib/pkgcloud/azure/compute/client/images.js +++ b/lib/pkgcloud/azure/compute/client/images.js @@ -28,7 +28,7 @@ exports.getImages = function getImages(options, callback) { return this.get(path, function (err, body, res) { return err ? callback(err) - : callback(null, self._toArray(body.OSImage).map(function (image) { + : callback(null, self._toArray(body.Images.OSImage).map(function (image) { return new compute.Image(self, image); }), res); }); diff --git a/lib/pkgcloud/azure/database/client/databases.js b/lib/pkgcloud/azure/database/client/databases.js index b1c62b377..9a974e174 100644 --- a/lib/pkgcloud/azure/database/client/databases.js +++ b/lib/pkgcloud/azure/database/client/databases.js @@ -70,7 +70,7 @@ exports.create = function (options, callback) { }, function (err, body) { if (err) { return next(err); } - var parser = new xml2js.Parser(); + var parser = new xml2js.Parser({explicitArray : false}); parser.parseString(body || '', function (err, data) { return !err ? next(null, data) @@ -80,7 +80,7 @@ exports.create = function (options, callback) { }], function (err, result) { return !err - ? callback(null, self.formatResponse(result)) + ? callback(null, self.formatResponse(result.entry)) : callback(err); } ); @@ -97,13 +97,13 @@ exports.list = function (callback) { path: 'Tables' }, function (err, body) { if (err) { return callback(err); } - if (body && body.entry) { - if (Array.isArray(body.entry)) { - body.entry.forEach(function (table) { + if (body && body.feed && body.feed.entry) { + if (Array.isArray(body.feed.entry)) { + body.feed.entry.forEach(function (table) { tables.push(self.formatResponse(table)); }); } else { - tables.push(self.formatResponse(body.entry)); + tables.push(self.formatResponse(body.feed.entry)); } } callback(null, tables); diff --git a/lib/pkgcloud/azure/storage/client/containers.js b/lib/pkgcloud/azure/storage/client/containers.js index b8d0b30c8..57773727a 100644 --- a/lib/pkgcloud/azure/storage/client/containers.js +++ b/lib/pkgcloud/azure/storage/client/containers.js @@ -19,13 +19,14 @@ exports.getContainers = function (callback) { this._xmlRequest({ method: 'GET', + path: '/', qs: { comp: 'list' } }, function (err, body) { if (err) { return callback(err); } - var containers = self._toArray(body.Containers.Container); + var containers = self._toArray(body.EnumerationResults.Containers.Container); containers = containers.map(function (container) { return new (storage.Container)(self, container); diff --git a/lib/pkgcloud/azure/storage/client/files.js b/lib/pkgcloud/azure/storage/client/files.js index 1b7797673..8a356388c 100644 --- a/lib/pkgcloud/azure/storage/client/files.js +++ b/lib/pkgcloud/azure/storage/client/files.js @@ -5,7 +5,7 @@ * */ -var filed = require('filed'), +var filed = require('filed-mimefix'), through = require('through2'), mime = require('mime'), urlJoin = require('url-join'), @@ -73,7 +73,7 @@ exports.upload = function (options) { uploadOptions.headers['content-type'] = options.contentType; } else { - uploadOptions.headers['content-type'] = mime.lookup(options.remote); + uploadOptions.headers['content-type'] = mime.getType(options.remote); } uploadOptions.headers['content-length'] = options.size; @@ -220,7 +220,7 @@ exports.sendBlockList = function (options, callback) { if (options.contentType) { putOptions.headers['x-ms-blob-content-type'] = options.contentType; } else if (options.remote) { - putOptions.headers['x-ms-blob-content-type'] = mime.lookup(options.remote); + putOptions.headers['x-ms-blob-content-type'] = mime.getType(options.remote); } putOptions.body = ''; diff --git a/lib/pkgcloud/azure/utils/azureApi.js b/lib/pkgcloud/azure/utils/azureApi.js index 8e3eb1adf..435686133 100644 --- a/lib/pkgcloud/azure/utils/azureApi.js +++ b/lib/pkgcloud/azure/utils/azureApi.js @@ -280,14 +280,14 @@ getHostedServices = exports.getHostedServices = function (client, callback) { if (err) { return callback(err); } - if (body.HostedService) { + if (body && body.HostedServices && body.HostedServices.HostedService) { // need to check if azure returned an array or single object - if (Array.isArray(body.HostedService)) { - body.HostedService.forEach(function (service) { + if (Array.isArray(body.HostedServices.HostedService)) { + body.HostedServices.HostedService.forEach(function (service) { services.push(service); }); } else { - services.push(body.HostedService); + services.push(body.HostedServices.HostedService); } } @@ -387,7 +387,6 @@ deleteOSDisk = function (client, server, callback) { // https://management.core.windows.net//services/disks/ path = client.subscriptionId + '/services/disks/' + diskName; - client._request({ method: 'DELETE', path: path @@ -454,9 +453,9 @@ getServersFromService = function (client, serviceName, callback) { return callback(err); } - if (result && result.Deployments && result.Deployments.Deployment) { - if (isVM(result.Deployments.Deployment)) { - servers.push(result.Deployments.Deployment); + if (result && result.HostedService && result.HostedService.Deployments && result.HostedService.Deployments.Deployment) { + if (isVM(result.HostedService.Deployments.Deployment)) { + servers.push(result.HostedService.Deployments.Deployment); } } @@ -508,7 +507,7 @@ pollRequestStatus = function (client, requestId, interval, callback) { if (err) { return callback(err); } - switch (body.Status) { + switch (body.Operation.Status) { case 'InProgress': setTimeout(checkStatus, interval); break; @@ -604,7 +603,7 @@ destroyImage = exports.destroyImage = function (client, imageName, callback) { createVM = function (client, options, vmOptions, callback) { // check OS type of image to determine if we are creating a linux or windows VM - switch (vmOptions.image.OS.toLowerCase()) { + switch (vmOptions.image.OSImage.OS.toLowerCase()) { case 'linux': createLinuxVM(client, options, vmOptions, callback); break; @@ -646,7 +645,7 @@ createLinuxVM = function (client, options, vmOptions, callback) { LOCAL_PORT: options.ssh.localPort || '22', ROLESIZE: options.flavor, ENDPOINTS: createEndpoints(options.ports), - OS_SOURCE_IMAGE_NAME: vmOptions.image.Name, + OS_SOURCE_IMAGE_NAME: vmOptions.image.OSImage.Name, OS_IMAGE_MEDIALINK: mediaLink }; diff --git a/lib/pkgcloud/azure/utils/xml2json.js b/lib/pkgcloud/azure/utils/xml2json.js index 9c28b0068..3d05030f9 100644 --- a/lib/pkgcloud/azure/utils/xml2json.js +++ b/lib/pkgcloud/azure/utils/xml2json.js @@ -25,7 +25,7 @@ exports.xml2JSON = function (xml, callback) { xml = xml.slice(index); } - var parser = new xml2js.Parser({normalize: false, trim: false}); + var parser = new xml2js.Parser({normalize: false, trim: false, explicitArray : false}); parser.parseString(xml, function (err, data) { if (err) { callback(err); diff --git a/lib/pkgcloud/digitalocean/compute/client/servers.js b/lib/pkgcloud/digitalocean/compute/client/servers.js index e8808db85..db4a14ce6 100644 --- a/lib/pkgcloud/digitalocean/compute/client/servers.js +++ b/lib/pkgcloud/digitalocean/compute/client/servers.js @@ -10,6 +10,10 @@ var base = require('../../../core/compute'), urlJoin = require('url-join'), compute = pkgcloud.providers.digitalocean.compute; +function _getServerId(server) { + return (server instanceof base.Server ? server.id : server) + ''; +} + // // ### function getVersion (callback) // #### @callback {function} f(err, version). @@ -181,7 +185,7 @@ exports.createServer = function createServer(options, callback) { // Destroy a server in DigitalOcean. // exports.destroyServer = function destroyServer(server, options, callback) { - var serverId = server instanceof base.Server ? server.id : server; + var serverId = _getServerId(server); if (typeof options === 'function') { callback = options; @@ -204,7 +208,7 @@ exports.destroyServer = function destroyServer(server, options, callback) { // Gets a server in DigitalOcean. // exports.getServer = function getServer(server, callback) { - var serverId = server instanceof base.Server ? server.id : server, + var serverId = _getServerId(server), self = this; return this._request({ diff --git a/lib/pkgcloud/google/client.js b/lib/pkgcloud/google/client.js index 278926fe5..364f5a541 100644 --- a/lib/pkgcloud/google/client.js +++ b/lib/pkgcloud/google/client.js @@ -6,7 +6,6 @@ */ var util = require('util'), - gcloud = require('gcloud'), base = require('../core/base'); var Client = exports.Client = function (options) { @@ -17,8 +16,6 @@ var Client = exports.Client = function (options) { this.provider = 'google'; this.config.keyFilename = this.config.keyFilename || options.keyFilename; this.config.projectId = this.config.projectId || options.projectId; - - this.gcloud = gcloud(this.config); }; util.inherits(Client, base.Client); diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index 8269cc351..e634c9865 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -51,7 +51,7 @@ exports.upload = function (options) { if (options.contentType) { uploadOptions.contentType = options.contentType; } else { - uploadOptions.contentType = mime.lookup(options.file || options.remote || options); + uploadOptions.contentType = mime.getType(options.file || options.remote || options); } var proxyStream = through(), diff --git a/lib/pkgcloud/google/storage/client/index.js b/lib/pkgcloud/google/storage/client/index.js index 2e954b69e..03b36f5af 100644 --- a/lib/pkgcloud/google/storage/client/index.js +++ b/lib/pkgcloud/google/storage/client/index.js @@ -5,10 +5,11 @@ * */ -var util = require('util'), - google = require('../../client'), - _ = require('lodash'), - pkgcloud = require('../../../../../lib/pkgcloud'); +const util = require('util'); +const google = require('../../client'); +const _ = require('lodash'); +const pkgcloud = require('../../../../../lib/pkgcloud'); +const { Storage } = require('@google-cloud/storage'); var Client = exports.Client = function (options) { google.Client.call(this, options); @@ -16,7 +17,7 @@ var Client = exports.Client = function (options) { _.extend(this, require('./containers')); _.extend(this, require('./files')); - this.storage = this.gcloud.storage(options); + this.storage = new Storage(options); }; util.inherits(Client, google.Client); diff --git a/lib/pkgcloud/openstack/database/client/users.js b/lib/pkgcloud/openstack/database/client/users.js index 8a5068a53..536d338cd 100644 --- a/lib/pkgcloud/openstack/database/client/users.js +++ b/lib/pkgcloud/openstack/database/client/users.js @@ -203,7 +203,6 @@ exports.getUsers = function getUsers(options, callback) { } var marker = null; - if (body.links && body.links.length > 0) { marker = qs.parse(body.links[0].href.split('?').pop()).marker; } diff --git a/lib/pkgcloud/openstack/storage/client/files.js b/lib/pkgcloud/openstack/storage/client/files.js index 9ee35b361..c29387137 100644 --- a/lib/pkgcloud/openstack/storage/client/files.js +++ b/lib/pkgcloud/openstack/storage/client/files.js @@ -6,7 +6,7 @@ * */ -var filed = require('filed'), +var filed = require('filed-mimefix'), mime = require('mime'), base = require('../../../core/storage'), through = require('through2'), @@ -113,7 +113,7 @@ exports.upload = function (options) { uploadOptions.headers['content-type'] = options.contentType; } else { - uploadOptions.headers['content-type'] = mime.lookup(options.remote); + uploadOptions.headers['content-type'] = mime.getType(options.remote); } if (options.metadata) { diff --git a/lib/pkgcloud/rackspace/storage/client/archive.js b/lib/pkgcloud/rackspace/storage/client/archive.js index 8db42c4da..2caa9e24a 100644 --- a/lib/pkgcloud/rackspace/storage/client/archive.js +++ b/lib/pkgcloud/rackspace/storage/client/archive.js @@ -7,7 +7,7 @@ */ var fs = require('fs'), - filed = require('filed'); + filed = require('filed-mimefix'); /** * Client.extract diff --git a/package-lock.json b/package-lock.json index b276f6664..bce73f717 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,21 +4,279 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/generator": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.0.tgz", + "integrity": "sha512-/v5I+a1jhGSKLgZDcmAUZ4K/VePi43eRkUs3yePW1HB1iANOD5tqJXwGSG4BZhSksP8J9ejSlwGeTiiOFZOrXQ==", + "dev": true, + "requires": { + "@babel/types": "^7.4.0", + "jsesc": "^2.5.1", + "lodash": "^4.17.11", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/helper-function-name": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", + "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", + "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz", + "integrity": "sha512-7Cuc6JZiYShaZnybDmfwhY4UYHzI6rlqhWjaIqbsJGsIqPimEYy5uh3akSRLMg65LSdSEnJ8a8/bWQN6u2oMGw==", + "dev": true, + "requires": { + "@babel/types": "^7.4.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.3.tgz", + "integrity": "sha512-gxpEUhTS1sGA63EGQGuA+WESPR/6tz6ng7tSHFCmaTJK/cGK8y37cBTspX+U2xCAue2IQVvF6Z0oigmjwD8YGQ==", + "dev": true + }, + "@babel/template": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.0.tgz", + "integrity": "sha512-SOWwxxClTTh5NdbbYZ0BmaBVzxzTh2tO/TeLTbF6MO6EzVhHTnff8CdBXx3mEtazFBoysmEM6GU/wF+SuSx4Fw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.4.0", + "@babel/types": "^7.4.0" + } + }, + "@babel/traverse": { + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.3.tgz", + "integrity": "sha512-HmA01qrtaCwwJWpSKpA948cBvU5BrmviAief/b3AVw936DtcdsTexlbyzNuDnthwhOQ37xshn7hvQaEQk7ISYQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.4.0", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.0", + "@babel/parser": "^7.4.3", + "@babel/types": "^7.4.0", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.11" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "@babel/types": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.0.tgz", + "integrity": "sha512-aPvkXyU2SPOnztlgo8n9cEiXW755mgyvueUPcpStqdzoSPm0fjO0vQBjLkt3JKJW7ufikfcnMTTPsN1xaTsBPA==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.11", + "to-fast-properties": "^2.0.0" + } + }, + "@google-cloud/common": { + "version": "0.31.1", + "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.31.1.tgz", + "integrity": "sha512-MgaF8VmDaoyIqzZUXIbcohTb5sQn+PYlYmcpb0/E8psUpVe+kaBwLq/Z8pcFtACCr6PNT36n+a6s1kG35bAuCA==", + "requires": { + "@google-cloud/projectify": "^0.3.2", + "@google-cloud/promisify": "^0.4.0", + "@types/duplexify": "^3.5.0", + "@types/request": "^2.47.0", + "arrify": "^1.0.1", + "duplexify": "^3.6.0", + "ent": "^2.2.0", + "extend": "^3.0.1", + "google-auth-library": "^3.0.0", + "pify": "^4.0.0", + "retry-request": "^4.0.0" + } + }, + "@google-cloud/paginator": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-0.2.0.tgz", + "integrity": "sha512-2ZSARojHDhkLvQ+CS32K+iUhBsWg3AEw+uxtqblA7xoCABDyhpj99FPp35xy6A+XlzMhOSrHHaxFE+t6ZTQq0w==", + "requires": { + "arrify": "^1.0.1", + "extend": "^3.0.1", + "split-array-stream": "^2.0.0", + "stream-events": "^1.0.4" + } + }, + "@google-cloud/projectify": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-0.3.3.tgz", + "integrity": "sha512-7522YHQ4IhaafgSunsFF15nG0TGVmxgXidy9cITMe+256RgqfcrfWphiMufW+Ou4kqagW/u3yxwbzVEW3dk2Uw==" + }, + "@google-cloud/promisify": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-0.4.0.tgz", + "integrity": "sha512-4yAHDC52TEMCNcMzVC8WlqnKKKq+Ssi2lXoUg9zWWkZ6U6tq9ZBRYLHHCRdfU+EU9YJsVmivwGcKYCjRGjnf4Q==" + }, + "@google-cloud/storage": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-2.4.3.tgz", + "integrity": "sha512-Ol0Ed1zYNYixq+wPPaFNIVjT5+KJldBI6vyRDXnrAu5Yu66PU4iMJvEztUVfckz6vsihwApBMeXxdDUyJzMM2w==", + "requires": { + "@google-cloud/common": "^0.31.0", + "@google-cloud/paginator": "^0.2.0", + "@google-cloud/promisify": "^0.4.0", + "arrify": "^1.0.0", + "async": "^2.0.1", + "compressible": "^2.0.12", + "concat-stream": "^2.0.0", + "duplexify": "^3.5.0", + "extend": "^3.0.0", + "gcs-resumable-upload": "^1.0.0", + "hash-stream-validation": "^0.2.1", + "mime": "^2.2.0", + "mime-types": "^2.0.8", + "once": "^1.3.1", + "pumpify": "^1.5.1", + "snakeize": "^0.1.0", + "stream-events": "^1.0.1", + "teeny-request": "^3.11.3", + "through2": "^3.0.0", + "xdg-basedir": "^3.0.0" + } + }, + "@types/caseless": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz", + "integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==" + }, + "@types/duplexify": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@types/duplexify/-/duplexify-3.6.0.tgz", + "integrity": "sha512-5zOA53RUlzN74bvrSGwjudssD9F3a797sDZQkiYpUOxW+WHaXTCPz4/d5Dgi6FKnOqZ2CpaTo0DhgIfsXAOE/A==", + "requires": { + "@types/node": "*" + } + }, + "@types/form-data": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "11.13.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.0.tgz", + "integrity": "sha512-rx29MMkRdVmzunmiA4lzBYJNnXsW/PhG4kMBy2ATsYaDjGGR75dCFEVVROKpNwlVdcUX3xxlghKQOeDPBJobng==" + }, + "@types/request": { + "version": "2.48.1", + "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.1.tgz", + "integrity": "sha512-ZgEZ1TiD+KGA9LiAAPPJL68Id2UWfeSO62ijSXZjFJArVV+2pKcsVHmrcu+1oiE3q6eDGiFiSolRc4JHoerBBg==", + "requires": { + "@types/caseless": "*", + "@types/form-data": "*", + "@types/node": "*", + "@types/tough-cookie": "*" + } + }, + "@types/tough-cookie": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.5.tgz", + "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==" + }, + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "requires": { + "event-target-shim": "^5.0.0" + } + }, + "agent-base": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "requires": { + "es6-promisify": "^5.0.0" + } + }, "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", + "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true + }, "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } }, "argparse": { "version": "1.0.10", @@ -29,14 +287,34 @@ "sprintf-js": "~1.0.2" } }, - "ascli": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/ascli/-/ascli-0.3.0.tgz", - "integrity": "sha1-XmYjDlIZ/j6JUqTvtPIPrllqgTo=", - "requires": { - "colour": "^0.7.1", - "optjs": "^3.2.2" - } + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" }, "asn1": { "version": "0.2.4", @@ -51,19 +329,18 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, "async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", - "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", "requires": { - "lodash": "^4.17.10" - }, - "dependencies": { - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" - } + "lodash": "^4.17.11" } }, "asynckit": { @@ -71,10 +348,16 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, "aws-sdk": { - "version": "2.382.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.382.0.tgz", - "integrity": "sha512-wGjZLYo2ZxGTlj2cHy/0zOfYJKUVBQYG1vpW4Cnbgo3HTtOu906a6tqkiD8QuN0EyEkn7i+wyjSiUFOCh3T/2g==", + "version": "2.435.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.435.0.tgz", + "integrity": "sha512-cXHe3V7Syv2JT/0xMO2xPO9T0Y1LZ5ccXeb7ZB/q54xzP1JIv0d7KIVIAoRx8gGn8VZTAd/6UV/D+r/dKTo9+g==", "requires": { "buffer": "4.9.1", "events": "1.1.1", @@ -83,19 +366,8 @@ "querystring": "0.2.0", "sax": "1.2.1", "url": "0.10.3", - "uuid": "3.1.0", + "uuid": "3.3.2", "xml2js": "0.4.19" - }, - "dependencies": { - "xml2js": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", - "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~9.0.1" - } - } } }, "aws-sign2": { @@ -114,51 +386,78 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base64-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" - }, - "base64url": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/base64url/-/base64url-1.0.6.tgz", - "integrity": "sha1-1k03XWinxkDZEuI1jRcNylu1RoE=", + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, "requires": { - "concat-stream": "~1.4.7", - "meow": "~2.0.0" + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" }, "dependencies": { - "concat-stream": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.4.11.tgz", - "integrity": "sha512-X3JMh8+4je3U1cQpG87+f9lXHDrqcb2MVLg9L7o8b1UZ0DzhRrUpdn65ttzu10PpJPPI3MQNkis+oha6TSA9Mw==", + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, "requires": { - "inherits": "~2.0.1", - "readable-stream": "~1.1.9", - "typedarray": "~0.0.5" + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } } } }, + "base64-js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "optional": true, "requires": { "tweetnacl": "^0.14.3" } }, - "blanket": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/blanket/-/blanket-1.1.9.tgz", - "integrity": "sha1-1lzKKXuAKHoL+fmeiRCV0fdEUcM=", - "dev": true, - "requires": { - "esprima": "~2.4.1", - "falafel": "~0.3.1", - "xtend": "~4.0.0" - } + "bignumber.js": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", + "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" }, "brace-expansion": { "version": "1.1.11", @@ -170,6 +469,35 @@ "concat-map": "0.0.1" } }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -194,43 +522,87 @@ "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true, - "optional": true + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, - "bufferview": { + "cache-base": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bufferview/-/bufferview-1.0.1.tgz", - "integrity": "sha1-ev10pF+Tf6QiodM4wIu/3HbNcl0=" - }, - "bytebuffer": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-3.5.5.tgz", - "integrity": "sha1-em+vGhNRSwg/H8+VQcTJv75+f9M=", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, "requires": { - "bufferview": "~1", - "long": "~2 >=2.2.3" + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" } }, "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=" - }, - "camelcase-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-1.0.0.tgz", - "integrity": "sha1-vRoRv5sxoc5JNJOpMN4aC69K1+w=", - "requires": { - "camelcase": "^1.0.1", - "map-obj": "^1.0.0" - } + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, "cli": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", @@ -239,54 +611,102 @@ "requires": { "exit": "0.1.2", "glob": "^7.1.1" + }, + "dependencies": { + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } } }, "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", "wrap-ansi": "^2.0.0" } }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true }, - "colors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", - "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, - "optional": true + "requires": { + "color-name": "1.1.3" + } }, - "colour": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/colour/-/colour-0.7.1.tgz", - "integrity": "sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g=" + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true }, "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "requires": { "delayed-stream": "~1.0.0" } }, "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", + "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=" + }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", "dev": true }, + "compressible": { + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.16.tgz", + "integrity": "sha512-JQfEOdnI7dASwCuSPWIeVYwc/zMsu/+tRhoUvEfXz2gxOA2DNjmG5vhtFdBlhWPPGo+RdT9S3tgc/uH5qgDiiA==", + "requires": { + "mime-db": ">= 1.38.0 < 2" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -294,46 +714,41 @@ "dev": true }, "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "optional": true, + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", "requires": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", - "readable-stream": "^2.2.2", + "readable-stream": "^3.0.2", "typedarray": "^0.0.6" }, "dependencies": { "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "optional": true, + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.3.0.tgz", + "integrity": "sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==", "requires": { - "safe-buffer": "~5.1.0" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } } } }, + "configstore": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-4.0.0.tgz", + "integrity": "sha512-CmquAXFBocrzaSM8mtGPMM/HiWmyIpr4CcJl/rgY2uCObZ/S7cKU0silxslqJejl+t/T9HS8E0PUNQD81JGUEQ==", + "requires": { + "dot-prop": "^4.1.0", + "graceful-fs": "^4.1.2", + "make-dir": "^1.0.0", + "unique-string": "^1.0.0", + "write-file-atomic": "^2.0.0", + "xdg-basedir": "^3.0.0" + } + }, "console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", @@ -343,15 +758,21 @@ "date-now": "^0.1.4" } }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "coveralls": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.2.tgz", - "integrity": "sha512-Tv0LKe/MkBOilH2v7WBiTBdudg2ChfGbdXafc/s330djpF3zKOmuehTeRwjXWc7pzfj9FrDUTA7tEx6Div8NFw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.3.tgz", + "integrity": "sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg==", "dev": true, "requires": { "growl": "~> 1.10.0", @@ -359,15 +780,40 @@ "lcov-parse": "^0.0.10", "log-driver": "^1.2.7", "minimist": "^1.2.0", - "request": "^2.85.0" + "request": "^2.86.0" + }, + "dependencies": { + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } } }, - "cycle": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", - "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=", + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "dev": true, - "optional": true + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "crypto-random-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", + "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=" }, "dashdash": { "version": "1.14.1", @@ -384,64 +830,118 @@ "dev": true }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true }, - "deep-equal": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.1.tgz", - "integrity": "sha1-+tenkyJMvww8d4b5LveA5PyMyHg=", + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=" + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "dev": true }, + "diff": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", + "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=" + }, "dom-serializer": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", - "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", "dev": true, "requires": { - "domelementtype": "~1.1.1", - "entities": "~1.1.1" + "domelementtype": "^1.3.0", + "entities": "^1.1.1" }, "dependencies": { - "domelementtype": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", - "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", - "dev": true - }, "entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", "dev": true } } }, "domelementtype": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", - "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", "dev": true }, "domhandler": { @@ -463,55 +963,38 @@ "domelementtype": "1" } }, + "dot-prop": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", + "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", + "requires": { + "is-obj": "^1.0.0" + } + }, "duplexify": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.0.tgz", - "integrity": "sha512-fO3Di4tBKJpYTFHAxTU00BcfWMY9w24r/x21a6rZRbsD/ToUgGxsMbiGRmB7uVAXeGKXD9MwiLZa5E97EVgIRQ==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", + "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", "requires": { "end-of-stream": "^1.0.0", "inherits": "^2.0.1", "readable-stream": "^2.0.0", "stream-shift": "^1.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } } }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "optional": true, "requires": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" } }, "ecdsa-sig-formatter": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz", - "integrity": "sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM=", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", "requires": { "safe-buffer": "^5.0.1" } @@ -524,6 +1007,11 @@ "once": "^1.4.0" } }, + "ent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", + "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=" + }, "entities": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", @@ -535,25 +1023,66 @@ "resolved": "https://registry.npmjs.org/errs/-/errs-0.3.2.tgz", "integrity": "sha1-eYCZstvTfKK8dJ5TinwTB9C1BJk=" }, - "es6-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", "dev": true, - "optional": true + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "es6-promise": { + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", + "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "requires": { + "es6-promise": "^4.0.3" + } }, "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", + "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=" }, "esprima": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.4.1.tgz", - "integrity": "sha1-gwWcdR6enEHSKKQaqh7vDMzjhLo=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, "eventemitter2": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz", @@ -561,31 +1090,43 @@ }, "events": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, - "extend": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extend/-/extend-1.3.0.tgz", - "integrity": "sha1-0VFvsP9WJNLr+RI+odrFoZlABPg=" - }, - "extract-zip": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", - "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, - "optional": true, "requires": { - "concat-stream": "1.6.2", - "debug": "2.6.9", - "mkdirp": "0.5.1", - "yauzl": "2.4.1" + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "debug": { @@ -593,115 +1134,268 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, - "optional": true, "requires": { "ms": "2.0.0" } }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true, - "optional": true + "dev": true } } }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } }, - "eyes": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", - "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=", + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, - "optional": true + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } }, - "falafel": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/falafel/-/falafel-0.3.1.tgz", - "integrity": "sha1-81RnSIFPfQlUPRny+z1gkPE2hT0=", + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { - "esprima": "*" + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { - "esprima": { - "version": "1.1.0-dev", - "bundled": true, - "dev": true + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } } } }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, "fast-json-patch": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/fast-json-patch/-/fast-json-patch-0.5.7.tgz", - "integrity": "sha1-taj0nSWWJFlu+YuHLz/aiVtNhmU=" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-patch/-/fast-json-patch-2.1.0.tgz", + "integrity": "sha512-PipOsAKamRw7+CXtKiieehyjUeDVPJ5J7b2kdJYerEf6TSUQoD2ijpVyZ88KQm5YXziff4h762bz3+vzf56khg==", + "requires": { + "deep-equal": "^1.0.1" + } }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, - "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "fast-text-encoding": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz", + "integrity": "sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ==" + }, + "filed-mimefix": { + "version": "0.1.3", + "resolved": "http://nexus.wdf.sap.corp:8081/nexus/repository/build.milestones.npm/filed-mimefix/-/filed-mimefix-0.1.3.tgz", + "integrity": "sha1-Cwtn0HWmP8dPJv3znH+dQxSWe7U=", + "requires": { + "mime": "^1.4.0" + }, + "dependencies": { + "mime": { + "version": "1.6.0", + "resolved": "http://nexus.wdf.sap.corp:8081/nexus/repository/build.milestones.npm/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, - "optional": true, "requires": { - "pend": "~1.2.0" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } } }, - "filed": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/filed/-/filed-0.1.0.tgz", - "integrity": "sha1-sPYmRyojZtwRlFN6Tup+eonzxzU=", + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "findup-sync": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", + "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^3.1.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, "requires": { - "mime": ">= 1.2.6" + "is-buffer": "~2.0.3" + }, + "dependencies": { + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "dev": true + } } }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" }, "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "requires": { "asynckit": "^0.4.0", - "combined-stream": "1.0.6", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, - "fs-extra": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, - "optional": true, "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true, - "optional": true - } + "map-cache": "^0.2.2" } }, "fs.realpath": { @@ -710,41 +1404,87 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "gapitoken": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/gapitoken/-/gapitoken-0.1.5.tgz", - "integrity": "sha1-NXf8+1Qmvjp7jrrakmcSKdjMgc4=", + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "gaxios": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.8.3.tgz", + "integrity": "sha512-6Lc1P0NjbPNQ2FGgTRurz32P6FktNJbwLqXvrUNhfwzKb9iizcWuAJiHoSG2W186K9ZL0X6ST5xD9gJWhHI1sg==", "requires": { - "jws": "~3.0.0", - "request": "^2.54.0" + "abort-controller": "^3.0.0", + "extend": "^3.0.2", + "https-proxy-agent": "^2.2.1", + "node-fetch": "^2.3.0" } }, - "gcloud": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/gcloud/-/gcloud-0.10.0.tgz", - "integrity": "sha1-hVoms1Mdx7B5FRP/+4n8ZZIfQ+4=", + "gcp-metadata": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-1.0.0.tgz", + "integrity": "sha512-Q6HrgfrCQeEircnNP3rCcEgiDv7eF9+1B+1MMgpE190+/+0mjQR8PxeOaRgxZWmdDAF9EIryHB9g1moPiw1SbQ==", "requires": { - "duplexify": "^3.1.2", - "extend": "^1.3.0", - "gapitoken": "^0.1.3", - "node-uuid": "^1.4.1", - "protobufjs": "^3.4.0", - "request": "^2.39.0", - "stream-events": "^1.0.1", - "through2": "^0.6.3" + "gaxios": "^1.0.2", + "json-bigint": "^0.3.0" + } + }, + "gcs-resumable-upload": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/gcs-resumable-upload/-/gcs-resumable-upload-1.1.0.tgz", + "integrity": "sha512-uBz7uHqp44xjSDzG3kLbOYZDjxxR/UAGbB47A0cC907W6yd2LkcyFDTHg+bjivkHMwiJlKv4guVWcjPCk2zScg==", + "requires": { + "abort-controller": "^2.0.2", + "configstore": "^4.0.0", + "gaxios": "^1.5.0", + "google-auth-library": "^3.0.0", + "pumpify": "^1.5.1", + "stream-events": "^1.0.4" + }, + "dependencies": { + "abort-controller": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-2.0.3.tgz", + "integrity": "sha512-EPSq5wr2aFyAZ1PejJB32IX9Qd4Nwus+adnp7STYFM5/23nLPBazqZ1oor6ZqbH+4otaaGXTlC8RN5hq3C8w9Q==", + "requires": { + "event-target-shim": "^5.0.0" + } + } + } + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" }, "dependencies": { - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=" + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } } } }, - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=" + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true }, "getpass": { "version": "0.1.7", @@ -755,152 +1495,1332 @@ } }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "requires": { + "inherits": "2", + "minimatch": "0.3" + } + }, + "global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "dev": true, + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, + "globals": { + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.11.0.tgz", + "integrity": "sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==", + "dev": true + }, + "google-auth-library": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-3.1.2.tgz", + "integrity": "sha512-cDQMzTotwyWMrg5jRO7q0A4TL/3GWBgO7I7q5xGKNiiFf9SmGY/OJ1YsLMgI2MVHHsEGyrqYnbnmV1AE+Z6DnQ==", + "requires": { + "base64-js": "^1.3.0", + "fast-text-encoding": "^1.0.0", + "gaxios": "^1.2.1", + "gcp-metadata": "^1.0.0", + "gtoken": "^2.3.2", + "https-proxy-agent": "^2.2.1", + "jws": "^3.1.5", + "lru-cache": "^5.0.0", + "semver": "^5.5.0" + } + }, + "google-p12-pem": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-1.0.4.tgz", + "integrity": "sha512-SwLAUJqUfTB2iS+wFfSS/G9p7bt4eWcc2LyfvmUXe7cWp6p3mpxDo6LLI29MXdU6wvPcQ/up298X7GMC5ylAlA==", + "requires": { + "node-forge": "^0.8.0", + "pify": "^4.0.0" + } + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=" + }, + "gtoken": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-2.3.3.tgz", + "integrity": "sha512-EaB49bu/TCoNeQjhCYKI/CurooBKkGxIqFHsWABW0b25fobBYVTMe84A8EBVVZhl8emiUdNypil9huMOTmyAnw==", + "requires": { + "gaxios": "^1.0.4", + "google-p12-pem": "^1.0.0", + "jws": "^3.1.5", + "mime": "^2.2.0", + "pify": "^4.0.0" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "hash-stream-validation": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/hash-stream-validation/-/hash-stream-validation-0.2.1.tgz", + "integrity": "sha1-7Mm5l7IYvluzEphii7gHhptz3NE=", + "requires": { + "through2": "^2.0.0" + }, + "dependencies": { + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } + } + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "hock": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/hock/-/hock-1.3.3.tgz", + "integrity": "sha512-bEX7KH/KSv2Q5zA+o1EdyeH52+gD2cfpYyAsHMEwjb9txXWttityKVf7cG0y3UVA4D8bxKDzH8LVXCQIr9rClg==", + "dev": true, + "requires": { + "deep-equal": "0.2.1", + "url-equal": "0.1.2-1" + }, + "dependencies": { + "deep-equal": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.1.tgz", + "integrity": "sha1-+tenkyJMvww8d4b5LveA5PyMyHg=", + "dev": true + } + } + }, + "homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "dev": true, + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1", + "domhandler": "2.3", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "https-proxy-agent": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", + "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "requires": { + "agent-base": "^4.1.0", + "debug": "^3.1.0" + } + }, + "ieee754": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=" + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "dev": true + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", + "dev": true + }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "^2.1.0" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-stream-ended": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-stream-ended/-/is-stream-ended-0.1.4.tgz", + "integrity": "sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw==" + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "istanbul-lib-coverage": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", + "integrity": "sha512-dKWuzRGCs4G+67VfW9pBFFz2Jpi4vSp/k7zBcJ888ofV5Mi1g5CUML5GvMvV6u9Cjybftu+E8Cgp+k0dI1E5lw==", + "dev": true + }, + "istanbul-lib-instrument": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.1.0.tgz", + "integrity": "sha512-ooVllVGT38HIk8MxDj/OIHXSYvH+1tq/Vb38s8ixt9GoJadXska4WkGY+0wkmtYCZNYtaARniH/DixUGGLZ0uA==", + "dev": true, + "requires": { + "@babel/generator": "^7.0.0", + "@babel/parser": "^7.0.0", + "@babel/template": "^7.0.0", + "@babel/traverse": "^7.0.0", + "@babel/types": "^7.0.0", + "istanbul-lib-coverage": "^2.0.3", + "semver": "^5.5.0" + } + }, + "jade": { + "version": "0.26.3", + "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", + "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", + "requires": { + "commander": "0.6.1", + "mkdirp": "0.3.0" + }, + "dependencies": { + "commander": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", + "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=" + }, + "mkdirp": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", + "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=" + } + } + }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz", + "integrity": "sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "jshint": { + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", + "integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==", + "dev": true, + "requires": { + "cli": "~1.0.0", + "console-browserify": "1.1.x", + "exit": "0.1.x", + "htmlparser2": "3.8.x", + "lodash": "~4.17.11", + "minimatch": "~3.0.2", + "shelljs": "0.3.x", + "strip-json-comments": "1.0.x" + }, + "dependencies": { + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "json-bigint": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.0.tgz", + "integrity": "sha1-DM2RLEuCcNBfBW+9E4FLU9OCWx4=", + "requires": { + "bignumber.js": "^7.0.0" + } + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "requires": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "lcov-parse": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", + "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", + "dev": true + }, + "liboneandone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/liboneandone/-/liboneandone-1.2.0.tgz", + "integrity": "sha512-EB6Ak9qw+U4HAOnKqPtatxQ9pLclvtsBsggrvOuD4zclJ5xOeEASojsLKEC3O8KJ1Q4obE2JHhOeDuqWXvkoUQ==", + "requires": { + "mocha": "^2.5.3", + "request": "^2.74.0" + }, + "dependencies": { + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "requires": { + "ms": "0.7.1" + } + }, + "mocha": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", + "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", + "requires": { + "commander": "2.3.0", + "debug": "2.2.0", + "diff": "1.4.0", + "escape-string-regexp": "1.0.2", + "glob": "3.2.11", + "growl": "1.9.2", + "jade": "0.26.3", + "mkdirp": "0.5.1", + "supports-color": "1.2.0", + "to-iso-string": "0.0.2" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + } + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + }, + "log-driver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", + "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", + "dev": true + }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "requires": { + "chalk": "^2.0.1" + } + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "requires": { + "pify": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + } + } + }, + "map-age-cleaner": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "p-defer": "^1.0.0" } }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true }, - "grpc": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/grpc/-/grpc-1.14.1.tgz", - "integrity": "sha512-UQA+WSa6CJYKv8rWAHX2RXCKhcxbB/5kyVnkiK3U+dPm4PlfZT4PrEeEdt2uzmvMhp9PB0SVKpVAukng1By+7w==", + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "mem": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^2.0.0", + "p-is-promise": "^2.0.0" + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mime": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.1.tgz", + "integrity": "sha512-VRUfmQO0rCd3hKwBymAn3kxYzBHr3I/wdVMywgG3HhXOwrCQgN84ZagpdTm2tZ4TNtwsSmyJWYO88mb5XvzGqQ==" + }, + "mime-db": { + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", + "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + }, + "mime-types": { + "version": "2.1.22", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", + "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "requires": { + "mime-db": "~1.38.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "minimatch": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "requires": { + "lru-cache": "2", + "sigmund": "~1.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" + } + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mixin-deep": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.0.2.tgz", + "integrity": "sha512-RtTJsmmToGyeTznSOMoM6TPEk1A84FQaHIciKrRqARZx+B5ccJ5tXlmJzEKGBxZdqk9UjpRsesZTUkZmR5YnuQ==", + "dev": true, "requires": { - "lodash": "^4.17.5", - "nan": "^2.0.0", - "node-pre-gyp": "^0.10.0", - "protobufjs": "^5.0.3" + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "findup-sync": "2.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.12.0", + "log-symbols": "2.2.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "ms": "2.1.1", + "node-environment-flags": "1.0.4", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "12.0.5", + "yargs-parser": "11.1.1", + "yargs-unparser": "1.5.0" }, "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true }, - "aproba": { - "version": "1.2.0", - "bundled": true + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "node-environment-flags": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.4.tgz", + "integrity": "sha512-M9rwCnWVLW7PX+NUWe3ejEdiLYinRpsEre9hMkU/6NS4h+EEulYaDH1gCEZ2gyXsmw+RXYDaV2JkkTNcsPDJ0Q==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3" + } + }, + "node-fetch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", + "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" + }, + "node-forge": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.2.tgz", + "integrity": "sha512-mXQ9GBq1N3uDCyV1pdSzgIguwgtVpM7f5/5J4ipz12PKWElmPpVWLDuWl8iXmhysr21+WmX/OJ5UKx82wjomgg==" + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "nyc": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-13.3.0.tgz", + "integrity": "sha512-P+FwIuro2aFG6B0Esd9ZDWUd51uZrAEoGutqZxzrVmYl3qSfkLgcQpBPBjtDFsUQLFY1dvTQJPOyeqr8S9GF8w==", + "dev": true, + "requires": { + "archy": "^1.0.0", + "arrify": "^1.0.1", + "caching-transform": "^3.0.1", + "convert-source-map": "^1.6.0", + "find-cache-dir": "^2.0.0", + "find-up": "^3.0.0", + "foreground-child": "^1.5.6", + "glob": "^7.1.3", + "istanbul-lib-coverage": "^2.0.3", + "istanbul-lib-hook": "^2.0.3", + "istanbul-lib-instrument": "^3.1.0", + "istanbul-lib-report": "^2.0.4", + "istanbul-lib-source-maps": "^3.0.2", + "istanbul-reports": "^2.1.1", + "make-dir": "^1.3.0", + "merge-source-map": "^1.1.0", + "resolve-from": "^4.0.0", + "rimraf": "^2.6.3", + "signal-exit": "^3.0.2", + "spawn-wrap": "^1.4.2", + "test-exclude": "^5.1.0", + "uuid": "^3.3.2", + "yargs": "^12.0.5", + "yargs-parser": "^11.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "bundled": true, + "dev": true }, - "are-we-there-yet": { - "version": "1.1.5", + "append-transform": { + "version": "1.0.0", "bundled": true, + "dev": true, "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" + "default-require-extensions": "^2.0.0" } }, - "ascli": { + "archy": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "arrify": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ascli/-/ascli-1.0.1.tgz", - "integrity": "sha1-vPpZdKYvGOgcq660lzKrSoj5Brw=", + "bundled": true, + "dev": true + }, + "async": { + "version": "2.6.2", + "bundled": true, + "dev": true, "requires": { - "colour": "~0.7.1", - "optjs": "~3.2.2" + "lodash": "^4.17.11" } }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "bytebuffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz", - "integrity": "sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0=", + "caching-transform": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "hasha": "^3.0.0", + "make-dir": "^1.3.0", + "package-hash": "^3.0.0", + "write-file-atomic": "^2.3.0" + } + }, + "camelcase": { + "version": "5.0.0", + "bundled": true, + "dev": true + }, + "cliui": { + "version": "4.1.0", + "bundled": true, + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "commander": { + "version": "2.17.1", + "bundled": true, + "dev": true, + "optional": true + }, + "commondir": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "convert-source-map": { + "version": "1.6.0", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "cross-spawn": { + "version": "4.0.2", + "bundled": true, + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "which": "^1.2.9" + } + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "1.2.0", + "bundled": true, + "dev": true + }, + "default-require-extensions": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "requires": { + "strip-bom": "^3.0.0" + } + }, + "end-of-stream": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "bundled": true, + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es6-error": { + "version": "4.1.1", + "bundled": true, + "dev": true + }, + "execa": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "bundled": true, + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + } + } + }, + "find-cache-dir": { + "version": "2.0.0", + "bundled": true, + "dev": true, "requires": { - "long": "~3" + "commondir": "^1.0.1", + "make-dir": "^1.0.0", + "pkg-dir": "^3.0.0" } }, - "chownr": { - "version": "1.0.1", - "bundled": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true - }, - "debug": { - "version": "2.6.9", + "find-up": { + "version": "3.0.0", "bundled": true, + "dev": true, "requires": { - "ms": "2.0.0" + "locate-path": "^3.0.0" } }, - "deep-extend": { - "version": "0.6.0", - "bundled": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true - }, - "fs-minipass": { - "version": "1.2.5", + "foreground-child": { + "version": "1.5.6", "bundled": true, + "dev": true, "requires": { - "minipass": "^2.2.1" + "cross-spawn": "^4", + "signal-exit": "^3.0.0" } }, "fs.realpath": { "version": "1.0.0", - "bundled": true + "bundled": true, + "dev": true + }, + "get-caller-file": { + "version": "1.0.3", + "bundled": true, + "dev": true }, - "gauge": { - "version": "2.7.4", + "get-stream": { + "version": "4.1.0", "bundled": true, + "dev": true, "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" + "pump": "^3.0.0" } }, "glob": { - "version": "7.1.2", + "version": "7.1.3", "bundled": true, + "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -910,27 +2830,56 @@ "path-is-absolute": "^1.0.0" } }, - "has-unicode": { - "version": "2.0.1", - "bundled": true + "graceful-fs": { + "version": "4.1.15", + "bundled": true, + "dev": true }, - "iconv-lite": { - "version": "0.4.23", + "handlebars": { + "version": "4.1.0", "bundled": true, + "dev": true, "requires": { - "safer-buffer": ">= 2.1.2 < 3" + "async": "^2.5.0", + "optimist": "^0.6.1", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "bundled": true, + "dev": true + } } }, - "ignore-walk": { - "version": "3.0.1", + "has-flag": { + "version": "3.0.0", "bundled": true, + "dev": true + }, + "hasha": { + "version": "3.0.0", + "bundled": true, + "dev": true, "requires": { - "minimatch": "^3.0.4" + "is-stream": "^1.0.1" } }, + "hosted-git-info": { + "version": "2.7.1", + "bundled": true, + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "bundled": true, + "dev": true + }, "inflight": { "version": "1.0.6", "bundled": true, + "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -938,958 +2887,931 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "dev": true + }, + "invert-kv": { + "version": "2.0.0", + "bundled": true, + "dev": true }, - "ini": { - "version": "1.3.5", - "bundled": true + "is-arrayish": { + "version": "0.2.1", + "bundled": true, + "dev": true }, "is-fullwidth-code-point": { - "version": "1.0.0", + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "isexe": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "istanbul-lib-coverage": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "istanbul-lib-hook": { + "version": "2.0.3", "bundled": true, + "dev": true, "requires": { - "number-is-nan": "^1.0.0" + "append-transform": "^1.0.0" } }, - "isarray": { - "version": "1.0.0", - "bundled": true + "istanbul-lib-report": { + "version": "2.0.4", + "bundled": true, + "dev": true, + "requires": { + "istanbul-lib-coverage": "^2.0.3", + "make-dir": "^1.3.0", + "supports-color": "^6.0.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "bundled": true, + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "istanbul-lib-source-maps": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^2.0.3", + "make-dir": "^1.3.0", + "rimraf": "^2.6.2", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "bundled": true, + "dev": true + } + } + }, + "istanbul-reports": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "requires": { + "handlebars": "^4.1.0" + } }, - "long": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", - "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=" + "json-parse-better-errors": { + "version": "1.0.2", + "bundled": true, + "dev": true }, - "minimatch": { - "version": "3.0.4", + "lcid": { + "version": "2.0.0", "bundled": true, + "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "invert-kv": "^2.0.0" } }, - "minimist": { - "version": "1.2.0", - "bundled": true + "load-json-file": { + "version": "4.0.0", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "bundled": true, + "dev": true + }, + "lodash.flattendeep": { + "version": "4.4.0", + "bundled": true, + "dev": true + }, + "lru-cache": { + "version": "4.1.5", + "bundled": true, + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-dir": { + "version": "1.3.0", + "bundled": true, + "dev": true, + "requires": { + "pify": "^3.0.0" + } + }, + "map-age-cleaner": { + "version": "0.1.3", + "bundled": true, + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } }, - "minipass": { - "version": "2.3.3", + "mem": { + "version": "4.1.0", "bundled": true, + "dev": true, "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^1.0.0", + "p-is-promise": "^2.0.0" } }, - "minizlib": { + "merge-source-map": { "version": "1.1.0", "bundled": true, + "dev": true, + "requires": { + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "bundled": true, + "dev": true + } + } + }, + "mimic-fn": { + "version": "1.2.0", + "bundled": true, + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, "requires": { - "minipass": "^2.2.1" + "brace-expansion": "^1.1.7" } }, + "minimist": { + "version": "0.0.10", + "bundled": true, + "dev": true + }, "mkdirp": { "version": "0.5.1", "bundled": true, + "dev": true, "requires": { "minimist": "0.0.8" }, "dependencies": { "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "dev": true } } }, "ms": { - "version": "2.0.0", - "bundled": true + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "bundled": true, + "dev": true }, - "needle": { - "version": "2.2.2", + "normalize-package-data": { + "version": "2.5.0", "bundled": true, + "dev": true, "requires": { - "debug": "^2.1.2", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, - "node-pre-gyp": { - "version": "0.10.3", + "npm-run-path": { + "version": "2.0.2", "bundled": true, + "dev": true, "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" + "path-key": "^2.0.0" } }, - "nopt": { - "version": "4.0.1", + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "once": { + "version": "1.4.0", "bundled": true, + "dev": true, "requires": { - "abbrev": "1", - "osenv": "^0.1.4" + "wrappy": "1" } }, - "npm-bundled": { - "version": "1.0.3", - "bundled": true + "optimist": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + } }, - "npm-packlist": { - "version": "1.1.11", + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "os-locale": { + "version": "3.1.0", "bundled": true, + "dev": true, "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" } }, - "npmlog": { - "version": "4.1.2", + "p-defer": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "p-finally": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "p-is-promise": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "p-limit": { + "version": "2.1.0", "bundled": true, + "dev": true, "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" + "p-try": "^2.0.0" } }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true + "p-locate": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } }, - "object-assign": { - "version": "4.1.1", - "bundled": true + "p-try": { + "version": "2.0.0", + "bundled": true, + "dev": true }, - "once": { - "version": "1.4.0", + "package-hash": { + "version": "3.0.0", "bundled": true, + "dev": true, "requires": { - "wrappy": "1" + "graceful-fs": "^4.1.15", + "hasha": "^3.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" } }, - "os-homedir": { - "version": "1.0.2", - "bundled": true + "parse-json": { + "version": "4.0.0", + "bundled": true, + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true + "path-exists": { + "version": "3.0.0", + "bundled": true, + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "path-key": { + "version": "2.0.1", + "bundled": true, + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "bundled": true, + "dev": true + }, + "path-type": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "pify": "^3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "bundled": true, + "dev": true }, - "osenv": { - "version": "0.1.5", + "pkg-dir": { + "version": "3.0.0", "bundled": true, + "dev": true, "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" + "find-up": "^3.0.0" } }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true + "pseudomap": { + "version": "1.0.2", + "bundled": true, + "dev": true }, - "protobufjs": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-5.0.3.tgz", - "integrity": "sha512-55Kcx1MhPZX0zTbVosMQEO5R6/rikNXd9b6RQK4KSPcrSIIwoXTtebIczUrXlwaSrbz4x8XUVThGPob1n8I4QA==", + "pump": { + "version": "3.0.0", + "bundled": true, + "dev": true, "requires": { - "ascli": "~1", - "bytebuffer": "~5", - "glob": "^7.0.5", - "yargs": "^3.10.0" + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } }, - "rc": { - "version": "1.2.8", + "read-pkg": { + "version": "3.0.0", "bundled": true, + "dev": true, "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" } }, - "readable-stream": { - "version": "2.3.6", + "read-pkg-up": { + "version": "4.0.0", "bundled": true, + "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" + "find-up": "^3.0.0", + "read-pkg": "^3.0.0" } }, - "rimraf": { - "version": "2.6.2", + "release-zalgo": { + "version": "1.0.0", "bundled": true, + "dev": true, "requires": { - "glob": "^7.0.5" + "es6-error": "^4.0.1" } }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true - }, - "sax": { - "version": "1.2.4", - "bundled": true - }, - "semver": { - "version": "5.5.0", - "bundled": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true + "require-directory": { + "version": "2.1.1", + "bundled": true, + "dev": true }, - "signal-exit": { - "version": "3.0.2", - "bundled": true + "require-main-filename": { + "version": "1.0.1", + "bundled": true, + "dev": true }, - "string-width": { - "version": "1.0.2", + "resolve": { + "version": "1.10.0", "bundled": true, + "dev": true, "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "path-parse": "^1.0.6" } }, - "string_decoder": { - "version": "1.1.1", + "resolve-from": { + "version": "4.0.0", "bundled": true, - "requires": { - "safe-buffer": "~5.1.0" - } + "dev": true }, - "strip-ansi": { - "version": "3.0.1", + "rimraf": { + "version": "2.6.3", "bundled": true, + "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "glob": "^7.1.3" } }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true }, - "tar": { - "version": "4.4.6", + "semver": { + "version": "5.6.0", "bundled": true, - "requires": { - "chownr": "^1.0.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.3", - "minizlib": "^1.1.0", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } + "dev": true }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true }, - "wide-align": { - "version": "1.1.3", + "shebang-command": { + "version": "1.2.0", "bundled": true, + "dev": true, "requires": { - "string-width": "^1.0.2 || 2" + "shebang-regex": "^1.0.0" } }, - "wrappy": { - "version": "1.0.2", - "bundled": true - }, - "yallist": { - "version": "3.0.2", - "bundled": true - } - } - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", - "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", - "requires": { - "ajv": "^5.3.0", - "har-schema": "^2.0.0" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "hasha": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", - "dev": true, - "optional": true, - "requires": { - "is-stream": "^1.0.1", - "pinkie-promise": "^2.0.0" - } - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "hock": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/hock/-/hock-1.2.0.tgz", - "integrity": "sha1-6GgiKnXzyX56YX1U1/WYB0bcmHc=", - "dev": true, - "requires": { - "deep-equal": "0.2.1" - } - }, - "htmlparser2": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", - "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", - "dev": true, - "requires": { - "domelementtype": "1", - "domhandler": "2.3", - "domutils": "1.5", - "entities": "1.0", - "readable-stream": "1.1" - } - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, - "ieee754": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", - "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=" - }, - "indent-string": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-1.2.2.tgz", - "integrity": "sha1-25m8xYPrarux5I3LsZmamGBBy2s=", - "requires": { - "get-stdin": "^4.0.1", - "minimist": "^1.1.0", - "repeating": "^1.1.0" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" - }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" - }, - "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true, - "optional": true - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true, - "optional": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "jade": { - "version": "0.26.3", - "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", - "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", - "requires": { - "commander": "0.6.1", - "mkdirp": "0.3.0" - }, - "dependencies": { - "commander": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", - "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=" - }, - "mkdirp": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", - "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=" - } - } - }, - "jmespath": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", - "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" - }, - "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "dependencies": { - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - } - } - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "optional": true - }, - "jshint": { - "version": "2.9.6", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.6.tgz", - "integrity": "sha512-KO9SIAKTlJQOM4lE64GQUtGBRpTOuvbrRrSZw3AhUxMNG266nX9hK2cKA4SBhXOj0irJGyNyGSLT62HGOVDEOA==", - "dev": true, - "requires": { - "cli": "~1.0.0", - "console-browserify": "1.1.x", - "exit": "0.1.x", - "htmlparser2": "3.8.x", - "lodash": "~4.17.10", - "minimatch": "~3.0.2", - "phantom": "~4.0.1", - "phantomjs-prebuilt": "~2.1.7", - "shelljs": "0.3.x", - "strip-json-comments": "1.0.x", - "unicode-5.2.0": "^0.7.5" - }, - "dependencies": { - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "shebang-regex": { + "version": "1.0.0", + "bundled": true, "dev": true - } - } - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "dev": true, - "optional": true, - "requires": { - "graceful-fs": "^4.1.6" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true + }, + "spawn-wrap": { + "version": "1.4.2", + "bundled": true, "dev": true, - "optional": true - } - } - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "jwa": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.0.2.tgz", - "integrity": "sha1-/Xlgnx53Limdzo3bdtAGWd2DUR8=", - "requires": { - "base64url": "~0.0.4", - "buffer-equal-constant-time": "^1.0.1", - "ecdsa-sig-formatter": "^1.0.0" - }, - "dependencies": { - "base64url": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/base64url/-/base64url-0.0.6.tgz", - "integrity": "sha1-lZezazMNscQkdzIuqH6oAnSZuCs=" - } - } - }, - "jws": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.0.0.tgz", - "integrity": "sha1-2l8meJfdTpz4E3l52zP8VKPAVBg=", - "requires": { - "base64url": "~1.0.4", - "jwa": "~1.0.0" - } - }, - "kew": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", - "dev": true, - "optional": true - }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "optional": true, - "requires": { - "graceful-fs": "^4.1.9" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "requires": { + "foreground-child": "^1.5.6", + "mkdirp": "^0.5.0", + "os-homedir": "^1.0.1", + "rimraf": "^2.6.2", + "signal-exit": "^3.0.2", + "which": "^1.3.0" + } + }, + "spdx-correct": { + "version": "3.1.0", + "bundled": true, "dev": true, - "optional": true - } - } - }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "requires": { - "invert-kv": "^1.0.0" - } - }, - "lcov-parse": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", - "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", - "dev": true - }, - "liboneandone": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/liboneandone/-/liboneandone-1.2.0.tgz", - "integrity": "sha512-EB6Ak9qw+U4HAOnKqPtatxQ9pLclvtsBsggrvOuD4zclJ5xOeEASojsLKEC3O8KJ1Q4obE2JHhOeDuqWXvkoUQ==", - "requires": { - "mocha": "^2.5.3", - "request": "^2.74.0" - }, - "dependencies": { - "commander": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", - "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=" + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } }, - "debug": { + "spdx-exceptions": { "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "bundled": true, + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "bundled": true, + "dev": true, "requires": { - "ms": "0.7.1" + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" } }, - "diff": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", - "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=" + "spdx-license-ids": { + "version": "3.0.3", + "bundled": true, + "dev": true }, - "escape-string-regexp": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", - "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=" + "string-width": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } }, - "glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "strip-ansi": { + "version": "4.0.0", + "bundled": true, + "dev": true, "requires": { - "inherits": "2", - "minimatch": "0.3" + "ansi-regex": "^3.0.0" } }, - "growl": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", - "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=" + "strip-bom": { + "version": "3.0.0", + "bundled": true, + "dev": true }, - "minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "strip-eof": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "test-exclude": { + "version": "5.1.0", + "bundled": true, + "dev": true, "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" + "arrify": "^1.0.1", + "minimatch": "^3.0.4", + "read-pkg-up": "^4.0.0", + "require-main-filename": "^1.0.1" } }, - "mocha": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", - "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", + "uglify-js": { + "version": "3.4.9", + "bundled": true, + "dev": true, + "optional": true, "requires": { - "commander": "2.3.0", - "debug": "2.2.0", - "diff": "1.4.0", - "escape-string-regexp": "1.0.2", - "glob": "3.2.11", - "growl": "1.9.2", - "jade": "0.26.3", - "mkdirp": "0.5.1", - "supports-color": "1.2.0", - "to-iso-string": "0.0.2" + "commander": "~2.17.1", + "source-map": "~0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "optional": true + } } }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + "uuid": { + "version": "3.3.2", + "bundled": true, + "dev": true }, - "supports-color": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", - "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=" + "validate-npm-package-license": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "bundled": true, + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "wordwrap": { + "version": "0.0.3", + "bundled": true, + "dev": true + }, + "wrap-ansi": { + "version": "2.1.0", + "bundled": true, + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "write-file-atomic": { + "version": "2.4.2", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "y18n": { + "version": "4.0.0", + "bundled": true, + "dev": true + }, + "yallist": { + "version": "2.1.2", + "bundled": true, + "dev": true + }, + "yargs": { + "version": "12.0.5", + "bundled": true, + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "bundled": true, + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } }, - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" - }, - "log-driver": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", - "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", - "dev": true + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, - "long": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/long/-/long-2.4.0.tgz", - "integrity": "sha1-n6GAux2VAM3CnEFWdmoZleH0Uk8=" + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" + "object-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", + "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", + "dev": true }, - "map-obj": { + "object-visit": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" - }, - "meow": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-2.0.0.tgz", - "integrity": "sha1-j1MKjs9dQNP0tN+Tw0cpAPuiqPE=", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, "requires": { - "camelcase-keys": "^1.0.0", - "indent-string": "^1.1.0", - "minimist": "^1.1.0", - "object-assign": "^1.0.0" + "isobject": "^3.0.0" } }, - "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" - }, - "mime-db": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", - "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } }, - "mime-types": { - "version": "2.1.19", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", - "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, "requires": { - "mime-db": "~1.35.0" + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" } }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "isobject": "^3.0.1" } }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - } + "wrappy": "1" } }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "os-locale": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", "dev": true, "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" } }, - "mocha-lcov-reporter": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/mocha-lcov-reporter/-/mocha-lcov-reporter-0.0.1.tgz", - "integrity": "sha1-AmcEkdtX7myx/nOS6BNwD24zaiE=", + "p-defer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", "dev": true }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", "dev": true }, - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, - "object-assign": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-1.0.0.tgz", - "integrity": "sha1-5l3Idm07R7S4MHRlyDEdoDCwcKY=" + "p-is-promise": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.0.0.tgz", + "integrity": "sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg==", + "dev": true }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "dev": true, "requires": { - "wrappy": "1" + "p-try": "^2.0.0" } }, - "optjs": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/optjs/-/optjs-3.2.2.tgz", - "integrity": "sha1-aabOicRCpEQDFBrS+bNwvVu29O4=" - }, - "os-locale": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, "requires": { - "lcid": "^1.0.0" + "p-limit": "^2.0.0" } }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true, - "optional": true + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, - "phantom": { - "version": "4.0.12", - "resolved": "https://registry.npmjs.org/phantom/-/phantom-4.0.12.tgz", - "integrity": "sha512-Tz82XhtPmwCk1FFPmecy7yRGZG2btpzY2KI9fcoPT7zT9det0CcMyfBFPp1S8DqzsnQnm8ZYEfdy528mwVtksA==", - "dev": true, - "optional": true, - "requires": { - "phantomjs-prebuilt": "^2.1.16", - "split": "^1.0.1", - "winston": "^2.4.0" - } - }, - "phantomjs-prebuilt": { - "version": "2.1.16", - "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz", - "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", - "dev": true, - "optional": true, - "requires": { - "es6-promise": "^4.0.3", - "extract-zip": "^1.6.5", - "fs-extra": "^1.0.0", - "hasha": "^2.2.0", - "kew": "^0.7.0", - "progress": "^1.1.8", - "request": "^2.81.0", - "request-progress": "^2.0.1", - "which": "^1.2.10" - } - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true, - "optional": true + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "optional": true, - "requires": { - "pinkie": "^2.0.0" - } + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" }, - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true, - "optional": true + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" }, - "protobufjs": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-3.8.2.tgz", - "integrity": "sha1-vIJuNMOvRpfo0K96Zp5NYSrtzRc=", + "pump": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", "requires": { - "ascli": "~0.3", - "bytebuffer": "~3 >=3.5" + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } }, - "psl": { - "version": "1.1.29", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", - "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + "pumpify": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", + "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", + "requires": { + "duplexify": "^3.6.0", + "inherits": "^2.0.3", + "pump": "^2.0.0" + } }, "punycode": { "version": "1.3.2", @@ -1897,9 +3819,9 @@ "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" }, "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" }, "querystring": { "version": "0.2.0", @@ -1907,31 +3829,41 @@ "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" }, "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - } + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, - "repeating": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz", - "integrity": "sha1-PUEUIYh3U3SU+X93+Xhfq4EPpKw=", + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, "requires": { - "is-finite": "^1.0.0" + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" } }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", @@ -1959,87 +3891,376 @@ "uuid": "^3.3.2" }, "dependencies": { - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + } + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + } + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "retry-request": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.0.0.tgz", + "integrity": "sha512-S4HNLaWcMP6r8E4TMH52Y7/pM8uNayOcTDDQNBwsCccL1uI+Ol2TljxRDPzaNfbhOB30+XWP5NnZkB3LiJxi1w==", + "requires": { + "through2": "^2.0.0" + }, + "dependencies": { + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "set-value": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "should": { + "version": "13.2.3", + "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", + "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", + "dev": true, + "requires": { + "should-equal": "^2.0.0", + "should-format": "^3.0.3", + "should-type": "^1.4.0", + "should-type-adaptors": "^1.0.1", + "should-util": "^1.0.0" + } + }, + "should-equal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", + "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", + "dev": true, + "requires": { + "should-type": "^1.4.0" + } + }, + "should-format": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", + "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-type-adaptors": "^1.0.1" + } + }, + "should-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", + "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", + "dev": true + }, + "should-type-adaptors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", + "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", + "dev": true, + "requires": { + "should-type": "^1.3.0", + "should-util": "^1.0.0" + } + }, + "should-util": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", + "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", + "dev": true + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "snakeize": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/snakeize/-/snakeize-0.1.0.tgz", + "integrity": "sha1-EMCI2LWOsHazIpu1oE4jLOEmQi0=" + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" + "kind-of": "^6.0.0" } }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } } } }, - "request-progress": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, - "optional": true, "requires": { - "throttleit": "^1.0.0" + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } } }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "sax": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", - "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" - }, - "shelljs": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", - "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true }, - "should": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/should/-/should-4.0.4.tgz", - "integrity": "sha1-jvqjBPHxSM89LpVYYpkPmrnqYo8=", + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" + "split-array-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/split-array-stream/-/split-array-stream-2.0.0.tgz", + "integrity": "sha512-hmMswlVY91WvGMxs0k8MRgq8zb2mSen4FmDNc5AFiTWtrBpdZN6nwD6kROVe4vNL+ywrvbCKsWVCnEd4riELIg==", + "requires": { + "is-stream-ended": "^0.1.4" + } }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, - "optional": true, "requires": { - "through": "2" + "extend-shallow": "^3.0.0" } }, "sprintf-js": { @@ -2049,9 +4270,9 @@ "dev": true }, "sshpk": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", - "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", @@ -2064,17 +4285,31 @@ "tweetnacl": "~0.14.0" } }, - "stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, - "optional": true + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } }, "stream-events": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.4.tgz", - "integrity": "sha512-D243NJaYs/xBN2QnoiMDY7IesJFIK7gEhnvAYqJa5JvDdnh2dC4qDBwlCf0ohPpX2QRlA/4gnbnPd3rs3KxVcA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.5.tgz", + "integrity": "sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==", "requires": { "stubs": "^3.0.0" } @@ -2085,28 +4320,38 @@ "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" }, "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" } }, "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } }, "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "^3.0.0" } }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, "strip-json-comments": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", @@ -2119,59 +4364,102 @@ "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=" }, "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", + "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=" + }, + "teeny-request": { + "version": "3.11.3", + "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-3.11.3.tgz", + "integrity": "sha512-CKncqSF7sH6p4rzCgkb/z/Pcos5efl0DmolzvlqRQUNcpRIruOhY9+T1FsIlyEbfWd7MsFpodROOwHYh2BaXzw==", + "requires": { + "https-proxy-agent": "^2.2.1", + "node-fetch": "^2.2.0", + "uuid": "^3.3.2" + } + }, + "through2": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz", + "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==", + "requires": { + "readable-stream": "2 || 3" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "to-iso-string": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", + "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=" + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { - "has-flag": "^3.0.0" + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } } }, - "throttleit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", - "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, - "optional": true + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, - "optional": true + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" + "psl": "^1.1.24", + "punycode": "^1.4.1" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" } } }, - "to-iso-string": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", - "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=" + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "dev": true }, "tunnel-agent": { "version": "0.6.0", @@ -2184,18 +4472,115 @@ "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, - "unicode-5.2.0": { - "version": "0.7.5", - "resolved": "https://registry.npmjs.org/unicode-5.2.0/-/unicode-5.2.0-0.7.5.tgz", - "integrity": "sha512-KVGLW1Bri30x00yv4HNM8kBxoqFXr0Sbo55735nvrlsx4PYBZol3UtoWgO492fSwmsetzPEZzy73rbU8OGXJcA==", + "union-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", + "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "set-value": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", + "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" + } + } + } + }, + "unique-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", + "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", + "requires": { + "crypto-random-string": "^1.0.0" + } + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "^2.1.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + } + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "dev": true }, "url": { @@ -2207,10 +4592,25 @@ "querystring": "0.2.0" } }, + "url-equal": { + "version": "0.1.2-1", + "resolved": "https://registry.npmjs.org/url-equal/-/url-equal-0.1.2-1.tgz", + "integrity": "sha1-IjeVIL/gfSa1kIAEkIruEuhNBf8=", + "dev": true, + "requires": { + "deep-equal": "~1.0.1" + } + }, "url-join": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/url-join/-/url-join-0.0.1.tgz", - "integrity": "sha1-HbSK1CLTQCRpqH99l73r/k+x48g=" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.0.tgz", + "integrity": "sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo=" + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true }, "util-deprecate": { "version": "1.0.2", @@ -2218,9 +4618,9 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, "verror": { "version": "1.10.0", @@ -2237,47 +4637,70 @@ "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, - "optional": true, "requires": { "isexe": "^2.0.0" } }, - "window-size": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", - "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=" + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true }, - "winston": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/winston/-/winston-2.4.3.tgz", - "integrity": "sha512-GYKuysPz2pxYAVJD2NPsDLP5Z79SDEzPm9/j4tCjkF/n89iBNGBMJcR+dMUqxgPNgoSs6fVygPi+Vl2oxIpBuw==", + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", "dev": true, - "optional": true, "requires": { - "async": "~1.0.0", - "colors": "1.0.x", - "cycle": "1.0.x", - "eyes": "0.1.x", - "isstream": "0.1.x", - "stack-trace": "0.0.x" - }, - "dependencies": { - "async": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", - "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=", - "dev": true, - "optional": true - } + "string-width": "^1.0.2 || 2" } }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, "requires": { "string-width": "^1.0.1", "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } } }, "wrappy": { @@ -2285,17 +4708,33 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "write-file-atomic": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.2.tgz", + "integrity": "sha512-s0b6vB3xIVRLWywa6X9TOMA7k9zio0TMOsl9ZnDkliA/cfJlpHXAscj0gbHVJiTdIuAYpIyqS5GW91fqm6gG5g==", + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "xdg-basedir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", + "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=" + }, "xml2js": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.1.14.tgz", - "integrity": "sha1-UnTmf1pkxfkpdM2FE54DMq3GuQw=", + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", "requires": { - "sax": ">=0.1.1" + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" } }, "xmlbuilder": { "version": "9.0.7", - "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, "xtend": { @@ -2304,39 +4743,55 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" }, "yargs": { - "version": "3.32.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", - "integrity": "sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU=", - "requires": { - "camelcase": "^2.0.1", - "cliui": "^3.0.3", - "decamelize": "^1.1.1", - "os-locale": "^1.4.0", - "string-width": "^1.0.1", - "window-size": "^0.1.4", - "y18n": "^3.2.0" - }, - "dependencies": { - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" - } + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" } }, - "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.5.0.tgz", + "integrity": "sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw==", "dev": true, - "optional": true, "requires": { - "fd-slicer": "~1.0.1" + "flat": "^4.1.0", + "lodash": "^4.17.11", + "yargs": "^12.0.5" } } } diff --git a/package.json b/package.json index c27e6e89f..f1aee89c3 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,12 @@ { "name": "pkgcloud", - "description": "An infrastructure-as-a-service agnostic cloud library for node.js", + "description": "A provider agnostic cloud library for Node.js", "version": "1.7.0", "author": "Charlie Robbins ", "contributors": [ - { - "name": "Nuno Job", - "email": "nuno@nodejitsu.com" - }, - { - "name": "Maciej Malecki", - "email": "me@mmalecki.com" - }, - { - "name": "Daniel Aristizabal", - "email": "daniel@nodejitsu.com" - }, - { - "name": "Ken Perkins", - "email": "ken.perkins@rackspace.com" - }, - { - "name": "Ross Kukulinski", - "email": "ross@kukulinski.com" - } + "Ross Kukulinski ", + "Jarrett Cruger ", + "Ken Perkins " ], "repository": { "type": "git", @@ -49,47 +32,39 @@ "helion" ], "dependencies": { + "@google-cloud/storage": "^2.4.3", "async": "^2.6.1", "aws-sdk": "^2.382.0", "errs": "^0.3.2", "eventemitter2": "^5.0.1", - "fast-json-patch": "0.5.x", - "filed": "^0.1.0", - "gcloud": "^0.10.0", - "grpc": "^1.14.1", + "fast-json-patch": "^2.1.0", + "filed-mimefix": "^0.1.3", "ip": "^1.1.5", "liboneandone": "^1.2.0", "lodash": "^4.17.10", - "mime": "1.4.1", + "mime": "^2.4.1", "qs": "^6.5.2", "request": "^2.88.0", - "through2": "0.6.x", - "url-join": "0.0.x", - "xml2js": "0.1.x" + "through2": "^3.0.1", + "url-join": "^4.0.0", + "xml2js": "^0.4.19" }, "devDependencies": { - "blanket": "1.1.9", "coveralls": "^3.0.2", - "hock": "~1.2.0", + "hock": "^1.2.0", "jshint": "^2.9.6", - "mocha": "^5.2.0", - "mocha-lcov-reporter": "0.0.1", - "should": "4.0.x" + "mocha": "^6.0.2", + "nyc": "^13.3.0", + "should": "^13.2.3" }, "main": "./lib/pkgcloud", "scripts": { - "test": "make test", - "cov": "make cov", - "travis": "make travis", - "lint": "make lint" - }, - "config": { - "blanket": { - "pattern": "/lib/", - "data-cover-never": "node_modules" - } + "test": "MOCK=on nyc mocha -t 4000 test/*/*/*-test.js", + "coverage": "nyc report --reporter=text-lcov | coveralls", + "lint": "jshint --exclude-path .gitignore .", + "posttest": "npm run lint" }, "engines": { - "node": ">=0.10.x" + "node": ">= 8.0.0" } } diff --git a/test/azure/databases/databases-test.js b/test/azure/databases/databases-test.js index 71dde426d..3aa768429 100644 --- a/test/azure/databases/databases-test.js +++ b/test/azure/databases/databases-test.js @@ -29,7 +29,7 @@ describe('pkgcloud/azure/databases', function () { return urlJoin('http://localhost:12345/', (typeof options === 'string' ? options - : options.path)); + : options.path || '')); }; hockInstance = hock.createHock(); diff --git a/test/common/compute/base-test.js b/test/common/compute/base-test.js index 6448f61c0..aae0a4de6 100644 --- a/test/common/compute/base-test.js +++ b/test/common/compute/base-test.js @@ -175,7 +175,7 @@ providers.filter(function (provider) { }); }); - it('the setWait() method waiting for a server to be operational should return a running server', function (done) { + it('the destroyServer() method should destroy an existing server', function (done) { // TODO enable destroy tests for all providers if (provider === 'amazon' || provider === 'azure') { done(); @@ -380,9 +380,9 @@ setupServerMock = function (client, provider, servers) { image: 119192817 }) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/create-server.json') - .get('/v2/droplets/3164494') + .get('/v2/droplets/3164444') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/not-active.json') - .get('/v2/droplets/3164494') + .get('/v2/droplets/3164444') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/active.json'); } else if (provider === 'rackspace') { @@ -548,8 +548,8 @@ setupDestroyMock = function (client, provider, servers) { } else if (provider === 'digitalocean') { servers.server - .delete('/v2/droplets/3164494') - .replyWithFile(204); + .delete('/v2/droplets/3164444') + .reply(204); } else if (provider === 'oneandone') { servers.server diff --git a/test/common/compute/server-test.js b/test/common/compute/server-test.js index 5c1ad361b..7928c445c 100644 --- a/test/common/compute/server-test.js +++ b/test/common/compute/server-test.js @@ -154,6 +154,8 @@ providers.filter(function (provider) { srv.should.be.instanceOf(Server); }); + context.servers = servers; + authHockInstance && authHockInstance.done(); hockInstance && hockInstance.done(); done(); @@ -161,7 +163,7 @@ providers.filter(function (provider) { }); }); - it.skip('the getServer() method should get a server instance', function (done) { + it('the getServer() method should get a server instance', function (done) { if (mock) { setupGetServerMock(client, provider, { authServer: authHockInstance, @@ -368,7 +370,7 @@ setupServerMock = function (client, provider, servers) { image: 119192817 }) .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/create-server2.json') - .get('/v2/droplets/354526') + .get('/v2/droplets/12345') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/active2.json'); } else if (provider === 'rackspace') { @@ -524,8 +526,8 @@ setupGetServersMock = function (client, provider, servers) { setupGetServerMock = function (client, provider, servers) { if (provider === 'rackspace') { servers.server - .get('/v1.0/537645/servers/20578901') - .replyWithFile(200, __dirname + '/../../fixtures/rackspace/20578901.json'); + .get('/v2/123456/servers/a0a5f183-b94e-4a41-a854-00aa00aa00aa') + .replyWithFile(200, __dirname + '/../../fixtures/rackspace/a0a5f183-b94e-4a41-a854-00aa00aa00aa.json'); } else if (provider === 'openstack') { servers.server @@ -541,17 +543,15 @@ setupGetServerMock = function (client, provider, servers) { else if (provider === 'azure') { var requestId = 'b67cc525-ecc5-4661-8fd6-fb3e57d724f5'; - + servers.server .defaultReplyHeaders({'x-ms-request-id': requestId, 'Content-Type': 'application/xml'}) - .get('/azure-account-subscription-id/services/hostedservices') - .reply(200, 'https://management.core.windows.net/azure-account-subscription-id/services/hostedservices/create-test-ids2create-test-ids2service created by pkgcloudEast USCreated2012-11-11T18:13:55Z2012-11-11T18:14:37Z') .get('/azure-account-subscription-id/services/hostedservices/create-test-ids2?embed-detail=true') .reply(200, serverStatusReply('create-test-ids2', 'ReadyRole')); } else if (provider === 'digitalocean') { servers.server - .get('/v2/droplets/3164494') + .get('/v2/droplets/3164444') .replyWithFile(200, __dirname + '/../../fixtures/digitalocean/active.json'); } else if (provider === 'hp') { diff --git a/test/common/storage/base-test.js b/test/common/storage/base-test.js index d5241b8ac..dc8e5d5bb 100644 --- a/test/common/storage/base-test.js +++ b/test/common/storage/base-test.js @@ -16,7 +16,6 @@ var fs = require('fs'), http = require('http'), urlJoin = require('url-join'), request = require('request'), - through = require('through2'), providers = require('../../configs/providers.json'), Container = require('../../../lib/pkgcloud/core/storage/container').Container, File = require('../../../lib/pkgcloud/core/storage/file').File, @@ -126,6 +125,16 @@ providers.filter(function (provider) { it('the upload() method with container and filename should succeed', function (done) { if (mock) { + // FIXME: Added 'google' until finding a way to "simulate" upload + if (provider === 'google') { + // TODO: Remove once 'google' upload & download tests are functional + context.file = { + name: 'test-file.txt', + size: Buffer.byteLength(fillerama) + }; + return done(); + } + setupUploadStreamMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -164,6 +173,11 @@ providers.filter(function (provider) { it('the download() method with container and filename should succeed', function (done) { if (mock) { + // FIXME: Added 'google' until finding a way to "simulate" download + if (provider === 'google') { + return done(); + } + setupDownloadStreamMock(provider, client, { server: hockInstance, authServer: authHockInstance @@ -464,32 +478,16 @@ setupCreateContainerMock = function (provider, client, servers) { name: 'pkgcloud-test-container' }) .replyWithFile(200, __dirname + '/../../fixtures/google/create-bucket.json'); - - client.storage.connection_.createAuthorizedReq = function (reqOpts, callback) { + + client.storage.baseUrl = client.storage.baseUrl.replace(/.*\.com/, 'http://localhost:12345'); + client.storage.makeAuthenticatedRequest = function (reqOpts, callback) { reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - callback(null, reqOpts); - }; - - client.storage.connection_.req = function (reqOpts, callback) { - reqOpts.uri = reqOpts.uri.replace(/.*\.com/, 'http://localhost:12345'); - client.storage.connection_.requester(reqOpts, callback); + return request(reqOpts, callback); }; - client.storage.connection_.requester = function (reqOpts, callback) { - if (reqOpts.qs && reqOpts.qs.uploadType === 'multipart') { - var stream = through(); - stream.on('finish', function () { - fs.readFile(__dirname + '/../../fixtures/google/create-file.json', function(err, file) { - if (err) { - return stream.emit('error', err); - } - stream.emit('complete', { body: JSON.parse(file) }); - }); - }); - return stream; - } - - return request(reqOpts, callback); + client.storage.authClient.request = function (reqOpts) { + reqOpts.url = reqOpts.url.replace(/.*\.com/, 'http://localhost:12345'); + return request(reqOpts); }; } else if (provider === 'hp') { @@ -643,6 +641,8 @@ setupDownloadStreamMock = function (provider, client, servers) { servers.server .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) + .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt?alt=media') + .reply(200, { mediaLink: 'http://localhost:12345/mediaLink' }) .get('/mediaLink') .reply(200, fillerama); } @@ -700,6 +700,10 @@ setupGetFileMock = function (provider, client, servers) { .reply(200, fillerama, helpers.azureGetFileResponseHeaders({'content-length': fillerama.length + 2, 'content-type': 'text/plain'})); } else if (provider === 'google') { + client.storage.request = function (reqOpts, callback) { + reqOpts.uri = urlJoin('http://localhost:12345/storage/v1', reqOpts.uri); + return request(reqOpts, (err, response, body) => callback(err, body? JSON.parse(body): body)); + }; servers.server .get('/storage/v1/b/pkgcloud-test-container/o/test-file.txt') .replyWithFile(200, __dirname + '/../../fixtures/google/get-file.json'); diff --git a/test/fixtures/digitalocean/active.json b/test/fixtures/digitalocean/active.json index d3f1d6579..41352d764 100644 --- a/test/fixtures/digitalocean/active.json +++ b/test/fixtures/digitalocean/active.json @@ -1,6 +1,6 @@ { "droplet": { - "id": 3164494, + "id": 3164444, "name": "create-test-setWait", "memory": 512, "vcpus": 1, diff --git a/test/fixtures/digitalocean/create-server.json b/test/fixtures/digitalocean/create-server.json index bfcaae28e..c0a33a9a0 100644 --- a/test/fixtures/digitalocean/create-server.json +++ b/test/fixtures/digitalocean/create-server.json @@ -1,6 +1,6 @@ { "droplet": { - "id": 3164494, + "id": 3164444, "name": "create-test-setWait", "memory": 512, "vcpus": 1, diff --git a/test/fixtures/digitalocean/create-server2.json b/test/fixtures/digitalocean/create-server2.json index e7841920f..a46a37316 100644 --- a/test/fixtures/digitalocean/create-server2.json +++ b/test/fixtures/digitalocean/create-server2.json @@ -1,6 +1,6 @@ { "droplet": { - "id": 354526, + "id": 12345, "name": "create-test-ids2", "memory": 512, "vcpus": 1, diff --git a/test/fixtures/digitalocean/not-active.json b/test/fixtures/digitalocean/not-active.json index 8ade6a7a0..8d893fd4f 100644 --- a/test/fixtures/digitalocean/not-active.json +++ b/test/fixtures/digitalocean/not-active.json @@ -1,6 +1,6 @@ { "droplet": { - "id": 3164494, + "id": 3164444, "name": "create-test-setWait", "memory": 512, "vcpus": 1, diff --git a/test/helpers/index.js b/test/helpers/index.js index 8a19ee769..2909d4c48 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -69,7 +69,7 @@ helpers.selectInstance = function selectInstance(client, callback) { return (instance.status == instance.STATUS.running); }); if (ready.length === 0) { - console.log('ERROR: Is necessary have Instances actived for this test.'); + console.log('ERROR: No running instances found.'); } return ready[0]; } diff --git a/test/hp/common/client-test.js b/test/hp/common/client-test.js index d224a0a05..a5b7e12e2 100644 --- a/test/hp/common/client-test.js +++ b/test/hp/common/client-test.js @@ -10,24 +10,24 @@ var pkgcloud = require('../../../lib/pkgcloud'); describe('pkgcloud/hp/client', function () { describe('Region validation', function () { - it('User should specify region: compute client', function() { + it('User should specify authUrl: compute client', function() { (function () { pkgcloud.compute.createClient({ provider: 'hp', username: 'username', password: 'password' }); - }).should.throw(new Error('region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)\');')); + }).should.throw(new Error('authUrl is invalid')); }); - it('User should specify region: storage client', function() { + it('User should specify authUrl: storage client', function() { (function () { pkgcloud.storage.createClient({ provider: 'hp', username: 'username', password: 'password' }); - }).should.throw(new Error('region are not valid. Available regions are region-a.geo-1 (US-West), region-b.geo-1(US-East)\');')); + }).should.throw(new Error('authUrl is invalid')); }); diff --git a/test/hp/macros.js b/test/hp/macros.js index 55499c2f0..78c95fc77 100644 --- a/test/hp/macros.js +++ b/test/hp/macros.js @@ -6,7 +6,7 @@ */ var fs = require('fs'), - filed = require('filed'), + filed = require('filed-mimefix'), assert = require('../helpers/assert'); exports.shouldHaveCreds = function (client) { diff --git a/test/openstack/cdn/services-test.js b/test/openstack/cdn/services-test.js index 038fb4220..120de4bba 100644 --- a/test/openstack/cdn/services-test.js +++ b/test/openstack/cdn/services-test.js @@ -341,7 +341,17 @@ setupUpdateServiceMock = function (client, servers) { op: 'replace', path: '/origins/0/origin', value: 'updated-origin.pkgcloud.com' - } + }, + { op: 'remove', path: '/client' }, + { op: 'remove', path: '/listenerTree' }, + { op: 'remove', path: '/wildcard' }, + { op: 'remove', path: '/_maxListeners' }, + { op: 'remove', path: '/delimiter' }, + { op: 'remove', path: '/_conf' }, + { op: 'remove', path: '/verboseMemoryLeak' }, + { op: 'remove', path: '/_removeListener' }, + { op: 'remove', path: '/_newListener' }, + { op: 'remove', path: '/_events' } ]) .reply(202); }; diff --git a/test/rackspace/databases/user-limit-test.js b/test/rackspace/databases/user-limit-test.js index a92a773d7..c86e94a00 100644 --- a/test/rackspace/databases/user-limit-test.js +++ b/test/rackspace/databases/user-limit-test.js @@ -16,7 +16,7 @@ var should = require('should'), // Declaring variables for helper functions defined later var setupAuthenticationMock, setupGetUsersMock; - describe.skip('pkgcloud/[rackspace]/databases/users/limits', function () { + describe('pkgcloud/[rackspace]/databases/users/limits', function () { var testContext = {}, client, authHockInstance, hockInstance, authServer, server, err, list, offset; @@ -40,16 +40,11 @@ var setupAuthenticationMock, setupGetUsersMock; function (next) { authServer.listen(12346, next); } - ], done); + ]); if (mock) { setupAuthenticationMock(authHockInstance); setupGetUsersMock(hockInstance); - hockInstance - .get('/v1.0/123456/instances') - .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') - .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); } helpers.selectInstance(client, function (instance) { @@ -63,6 +58,11 @@ var setupAuthenticationMock, setupGetUsersMock; }); }); + after(function() { + server.close(); + authServer.close(); + }); + it('with limit should respond with one element', function () { should.not.exist(err); should.exist(list); @@ -133,8 +133,8 @@ setupGetUsersMock = function(hockInstance) { hockInstance .get('/v1.0/123456/instances') .reply(200, helpers.loadFixture('rackspace/databaseInstances.json')) - .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users') - .reply(200, helpers.loadFixture('rackspace/databaseUsers.json')); + .get('/v1.0/123456/instances/51a28a3e-2b7b-4b5a-a1ba-99b871af2c8f/users?limit=1') + .reply(200, helpers.loadFixture('rackspace/databaseUsersLimit.json')); }; setupAuthenticationMock = function(authHockInstance) { diff --git a/test/rackspace/macros.js b/test/rackspace/macros.js index 55499c2f0..78c95fc77 100644 --- a/test/rackspace/macros.js +++ b/test/rackspace/macros.js @@ -6,7 +6,7 @@ */ var fs = require('fs'), - filed = require('filed'), + filed = require('filed-mimefix'), assert = require('../helpers/assert'); exports.shouldHaveCreds = function (client) { From a16c4153012162fcb1b25411241fce582a29925c Mon Sep 17 00:00:00 2001 From: indexzero Date: Fri, 10 May 2019 11:29:46 -0400 Subject: [PATCH 452/460] [dist] Version bump. 2.0.0 --- package-lock.json | 1563 +++++++-------------------------------------- package.json | 2 +- 2 files changed, 246 insertions(+), 1319 deletions(-) diff --git a/package-lock.json b/package-lock.json index bce73f717..6566dfb03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pkgcloud", - "version": "1.7.0", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -14,12 +14,12 @@ } }, "@babel/generator": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.0.tgz", - "integrity": "sha512-/v5I+a1jhGSKLgZDcmAUZ4K/VePi43eRkUs3yePW1HB1iANOD5tqJXwGSG4BZhSksP8J9ejSlwGeTiiOFZOrXQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.4.tgz", + "integrity": "sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==", "dev": true, "requires": { - "@babel/types": "^7.4.0", + "@babel/types": "^7.4.4", "jsesc": "^2.5.1", "lodash": "^4.17.11", "source-map": "^0.5.0", @@ -47,12 +47,12 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz", - "integrity": "sha512-7Cuc6JZiYShaZnybDmfwhY4UYHzI6rlqhWjaIqbsJGsIqPimEYy5uh3akSRLMg65LSdSEnJ8a8/bWQN6u2oMGw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", + "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", "dev": true, "requires": { - "@babel/types": "^7.4.0" + "@babel/types": "^7.4.4" } }, "@babel/highlight": { @@ -67,34 +67,34 @@ } }, "@babel/parser": { - "version": "7.4.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.3.tgz", - "integrity": "sha512-gxpEUhTS1sGA63EGQGuA+WESPR/6tz6ng7tSHFCmaTJK/cGK8y37cBTspX+U2xCAue2IQVvF6Z0oigmjwD8YGQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.4.tgz", + "integrity": "sha512-5pCS4mOsL+ANsFZGdvNLybx4wtqAZJ0MJjMHxvzI3bvIsz6sQvzW8XX92EYIkiPtIvcfG3Aj+Ir5VNyjnZhP7w==", "dev": true }, "@babel/template": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.0.tgz", - "integrity": "sha512-SOWwxxClTTh5NdbbYZ0BmaBVzxzTh2tO/TeLTbF6MO6EzVhHTnff8CdBXx3mEtazFBoysmEM6GU/wF+SuSx4Fw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", + "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/parser": "^7.4.4", + "@babel/types": "^7.4.4" } }, "@babel/traverse": { - "version": "7.4.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.3.tgz", - "integrity": "sha512-HmA01qrtaCwwJWpSKpA948cBvU5BrmviAief/b3AVw936DtcdsTexlbyzNuDnthwhOQ37xshn7hvQaEQk7ISYQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.4.tgz", + "integrity": "sha512-Gw6qqkw/e6AGzlyj9KnkabJX7VcubqPtkUQVAwkc0wUMldr3A/hezNB3Rc5eIvId95iSGkGIOe5hh1kMKf951A==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.0", + "@babel/generator": "^7.4.4", "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.0", - "@babel/parser": "^7.4.3", - "@babel/types": "^7.4.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.4.4", + "@babel/types": "^7.4.4", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.11" @@ -112,9 +112,9 @@ } }, "@babel/types": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.0.tgz", - "integrity": "sha512-aPvkXyU2SPOnztlgo8n9cEiXW755mgyvueUPcpStqdzoSPm0fjO0vQBjLkt3JKJW7ufikfcnMTTPsN1xaTsBPA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz", + "integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -123,21 +123,28 @@ } }, "@google-cloud/common": { - "version": "0.31.1", - "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.31.1.tgz", - "integrity": "sha512-MgaF8VmDaoyIqzZUXIbcohTb5sQn+PYlYmcpb0/E8psUpVe+kaBwLq/Z8pcFtACCr6PNT36n+a6s1kG35bAuCA==", + "version": "0.32.1", + "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.32.1.tgz", + "integrity": "sha512-bLdPzFvvBMtVkwsoBtygE9oUm3yrNmPa71gvOgucYI/GqvNP2tb6RYsDHPq98kvignhcgHGDI5wyNgxaCo8bKQ==", "requires": { - "@google-cloud/projectify": "^0.3.2", + "@google-cloud/projectify": "^0.3.3", "@google-cloud/promisify": "^0.4.0", - "@types/duplexify": "^3.5.0", - "@types/request": "^2.47.0", - "arrify": "^1.0.1", + "@types/request": "^2.48.1", + "arrify": "^2.0.0", "duplexify": "^3.6.0", "ent": "^2.2.0", - "extend": "^3.0.1", - "google-auth-library": "^3.0.0", - "pify": "^4.0.0", - "retry-request": "^4.0.0" + "extend": "^3.0.2", + "google-auth-library": "^3.1.1", + "pify": "^4.0.1", + "retry-request": "^4.0.0", + "teeny-request": "^3.11.3" + }, + "dependencies": { + "arrify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", + "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" + } } }, "@google-cloud/paginator": { @@ -162,24 +169,25 @@ "integrity": "sha512-4yAHDC52TEMCNcMzVC8WlqnKKKq+Ssi2lXoUg9zWWkZ6U6tq9ZBRYLHHCRdfU+EU9YJsVmivwGcKYCjRGjnf4Q==" }, "@google-cloud/storage": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-2.4.3.tgz", - "integrity": "sha512-Ol0Ed1zYNYixq+wPPaFNIVjT5+KJldBI6vyRDXnrAu5Yu66PU4iMJvEztUVfckz6vsihwApBMeXxdDUyJzMM2w==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-2.5.0.tgz", + "integrity": "sha512-q1mwB6RUebIahbA3eriRs8DbG2Ij81Ynb9k8hMqTPkmbd8/S6Z0d6hVvfPmnyvX9Ej13IcmEYIbymuq/RBLghA==", "requires": { - "@google-cloud/common": "^0.31.0", + "@google-cloud/common": "^0.32.0", "@google-cloud/paginator": "^0.2.0", "@google-cloud/promisify": "^0.4.0", "arrify": "^1.0.0", "async": "^2.0.1", "compressible": "^2.0.12", "concat-stream": "^2.0.0", + "date-and-time": "^0.6.3", "duplexify": "^3.5.0", "extend": "^3.0.0", "gcs-resumable-upload": "^1.0.0", "hash-stream-validation": "^0.2.1", "mime": "^2.2.0", "mime-types": "^2.0.8", - "once": "^1.3.1", + "onetime": "^5.1.0", "pumpify": "^1.5.1", "snakeize": "^0.1.0", "stream-events": "^1.0.1", @@ -193,14 +201,6 @@ "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz", "integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==" }, - "@types/duplexify": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@types/duplexify/-/duplexify-3.6.0.tgz", - "integrity": "sha512-5zOA53RUlzN74bvrSGwjudssD9F3a797sDZQkiYpUOxW+WHaXTCPz4/d5Dgi6FKnOqZ2CpaTo0DhgIfsXAOE/A==", - "requires": { - "@types/node": "*" - } - }, "@types/form-data": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", @@ -210,9 +210,9 @@ } }, "@types/node": { - "version": "11.13.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.0.tgz", - "integrity": "sha512-rx29MMkRdVmzunmiA4lzBYJNnXsW/PhG4kMBy2ATsYaDjGGR75dCFEVVROKpNwlVdcUX3xxlghKQOeDPBJobng==" + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", + "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" }, "@types/request": { "version": "2.48.1", @@ -287,30 +287,6 @@ "sprintf-js": "~1.0.2" } }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -329,12 +305,6 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, "async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", @@ -348,16 +318,10 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, - "atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true - }, "aws-sdk": { - "version": "2.435.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.435.0.tgz", - "integrity": "sha512-cXHe3V7Syv2JT/0xMO2xPO9T0Y1LZ5ccXeb7ZB/q54xzP1JIv0d7KIVIAoRx8gGn8VZTAd/6UV/D+r/dKTo9+g==", + "version": "2.452.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.452.0.tgz", + "integrity": "sha512-l6J2NmUg12xpDKG9YdlPje5+Z+nNvqyWMA85ookzPqwx8RcD28D3vg4K1aGi27/oo/3NsngR3XfKUBPSqUpUMA==", "requires": { "buffer": "4.9.1", "events": "1.1.1", @@ -386,61 +350,6 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "base64-js": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", @@ -469,35 +378,6 @@ "concat-map": "0.0.1" } }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -524,23 +404,6 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - } - }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -580,29 +443,6 @@ } } }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, "cli": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", @@ -614,9 +454,9 @@ }, "dependencies": { "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -655,16 +495,6 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -693,18 +523,12 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=" }, - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, "compressible": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.16.tgz", - "integrity": "sha512-JQfEOdnI7dASwCuSPWIeVYwc/zMsu/+tRhoUvEfXz2gxOA2DNjmG5vhtFdBlhWPPGo+RdT9S3tgc/uH5qgDiiA==", + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.17.tgz", + "integrity": "sha512-BGHeLCK1GV7j1bSmQQAi26X+GgWcTjLr/0tzSvMCl3LH1w1IJ4PFSPoV5316b30cneTziC+B1a+3OjoSUcQYmw==", "requires": { - "mime-db": ">= 1.38.0 < 2" + "mime-db": ">= 1.40.0 < 2" } }, "concat-map": { @@ -758,12 +582,6 @@ "date-now": "^0.1.4" } }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -823,6 +641,11 @@ "assert-plus": "^1.0.0" } }, + "date-and-time": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-0.6.3.tgz", + "integrity": "sha512-lcWy3AXDRJOD7MplwZMmNSRM//kZtJaLz4n6D1P5z9wEmZGBKhJRBIr1Xs9KNQJmdXPblvgffynYji4iylUTcA==" + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -843,12 +666,6 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true - }, "deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", @@ -863,58 +680,11 @@ "object-keys": "^1.0.12" } }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, - "detect-file": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true - }, "diff": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", @@ -999,6 +769,12 @@ "safe-buffer": "^5.0.1" } }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", @@ -1114,156 +890,11 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -1294,7 +925,7 @@ }, "filed-mimefix": { "version": "0.1.3", - "resolved": "http://nexus.wdf.sap.corp:8081/nexus/repository/build.milestones.npm/filed-mimefix/-/filed-mimefix-0.1.3.tgz", + "resolved": "https://registry.npmjs.org/filed-mimefix/-/filed-mimefix-0.1.3.tgz", "integrity": "sha1-Cwtn0HWmP8dPJv3znH+dQxSWe7U=", "requires": { "mime": "^1.4.0" @@ -1302,34 +933,11 @@ "dependencies": { "mime": { "version": "1.6.0", - "resolved": "http://nexus.wdf.sap.corp:8081/nexus/repository/build.milestones.npm/mime/-/mime-1.6.0.tgz", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" } } }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -1339,18 +947,6 @@ "locate-path": "^3.0.0" } }, - "findup-sync": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", - "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^3.1.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - } - }, "flat": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", @@ -1358,22 +954,8 @@ "dev": true, "requires": { "is-buffer": "~2.0.3" - }, - "dependencies": { - "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", - "dev": true - } } }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -1389,15 +971,6 @@ "mime-types": "^2.1.12" } }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "requires": { - "map-cache": "^0.2.2" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1411,9 +984,9 @@ "dev": true }, "gaxios": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.8.3.tgz", - "integrity": "sha512-6Lc1P0NjbPNQ2FGgTRurz32P6FktNJbwLqXvrUNhfwzKb9iizcWuAJiHoSG2W186K9ZL0X6ST5xD9gJWhHI1sg==", + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.8.4.tgz", + "integrity": "sha512-BoENMnu1Gav18HcpV9IleMPZ9exM+AvUjrAOV4Mzs/vfz2Lu/ABv451iEXByKiMPn2M140uul1txXCg83sAENw==", "requires": { "abort-controller": "^3.0.0", "extend": "^3.0.2", @@ -1454,9 +1027,9 @@ } }, "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, "get-stream": { @@ -1480,12 +1053,6 @@ } } }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -1503,34 +1070,10 @@ "minimatch": "0.3" } }, - "global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "dev": true, - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, "globals": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.11.0.tgz", - "integrity": "sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==", + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, "google-auth-library": { @@ -1615,42 +1158,10 @@ "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", "dev": true }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "hash-stream-validation": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/hash-stream-validation/-/hash-stream-validation-0.2.1.tgz", - "integrity": "sha1-7Mm5l7IYvluzEphii7gHhptz3NE=", + "hash-stream-validation": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/hash-stream-validation/-/hash-stream-validation-0.2.1.tgz", + "integrity": "sha1-7Mm5l7IYvluzEphii7gHhptz3NE=", "requires": { "through2": "^2.0.0" }, @@ -1690,15 +1201,6 @@ } } }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, - "requires": { - "parse-passwd": "^1.0.0" - } - }, "htmlparser2": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", @@ -1782,12 +1284,6 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true - }, "invert-kv": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", @@ -1799,30 +1295,10 @@ "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", "dev": true }, "is-callable": { @@ -1831,112 +1307,23 @@ "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", "dev": true }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "is-date-object": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", "dev": true }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "is-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -1971,12 +1358,6 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -1988,36 +1369,38 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, "istanbul-lib-coverage": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", - "integrity": "sha512-dKWuzRGCs4G+67VfW9pBFFz2Jpi4vSp/k7zBcJ888ofV5Mi1g5CUML5GvMvV6u9Cjybftu+E8Cgp+k0dI1E5lw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", + "integrity": "sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==", "dev": true }, "istanbul-lib-instrument": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.1.0.tgz", - "integrity": "sha512-ooVllVGT38HIk8MxDj/OIHXSYvH+1tq/Vb38s8ixt9GoJadXska4WkGY+0wkmtYCZNYtaARniH/DixUGGLZ0uA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz", + "integrity": "sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==", "dev": true, "requires": { - "@babel/generator": "^7.0.0", - "@babel/parser": "^7.0.0", - "@babel/template": "^7.0.0", - "@babel/traverse": "^7.0.0", - "@babel/types": "^7.0.0", - "istanbul-lib-coverage": "^2.0.3", - "semver": "^5.5.0" + "@babel/generator": "^7.4.0", + "@babel/parser": "^7.4.3", + "@babel/template": "^7.4.0", + "@babel/traverse": "^7.4.3", + "@babel/types": "^7.4.0", + "istanbul-lib-coverage": "^2.0.5", + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz", + "integrity": "sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==", + "dev": true + } } }, "jade": { @@ -2053,9 +1436,9 @@ "dev": true }, "js-yaml": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz", - "integrity": "sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -2153,12 +1536,6 @@ "safe-buffer": "^5.0.1" } }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, "lcid": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", @@ -2277,21 +1654,6 @@ "p-defer": "^1.0.0" } }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "^1.0.0" - } - }, "mem": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", @@ -2303,50 +1665,28 @@ "p-is-promise": "^2.0.0" } }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, "mime": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.1.tgz", - "integrity": "sha512-VRUfmQO0rCd3hKwBymAn3kxYzBHr3I/wdVMywgG3HhXOwrCQgN84ZagpdTm2tZ4TNtwsSmyJWYO88mb5XvzGqQ==" + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", + "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==" }, "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { - "mime-db": "~1.38.0" + "mime-db": "1.40.0" } }, "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" }, "minimatch": { "version": "0.3.0", @@ -2369,27 +1709,6 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, - "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", - "dev": true, - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", @@ -2399,9 +1718,9 @@ } }, "mocha": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.0.2.tgz", - "integrity": "sha512-RtTJsmmToGyeTznSOMoM6TPEk1A84FQaHIciKrRqARZx+B5ccJ5tXlmJzEKGBxZdqk9UjpRsesZTUkZmR5YnuQ==", + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.1.4.tgz", + "integrity": "sha512-PN8CIy4RXsIoxoFJzS4QNnCH4psUCPWc4/rPrst/ecSJJbLBkubMiyGCP2Kj/9YnWbotFqAoeXyXMucj7gwCFg==", "dev": true, "requires": { "ansi-colors": "3.2.3", @@ -2409,23 +1728,23 @@ "debug": "3.2.6", "diff": "3.5.0", "escape-string-regexp": "1.0.5", - "findup-sync": "2.0.0", + "find-up": "3.0.0", "glob": "7.1.3", "growl": "1.10.5", "he": "1.2.0", - "js-yaml": "3.12.0", + "js-yaml": "3.13.1", "log-symbols": "2.2.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", "ms": "2.1.1", - "node-environment-flags": "1.0.4", + "node-environment-flags": "1.0.5", "object.assign": "4.1.0", "strip-json-comments": "2.0.1", "supports-color": "6.0.0", "which": "1.3.1", "wide-align": "1.1.3", - "yargs": "12.0.5", - "yargs-parser": "11.1.1", + "yargs": "13.2.2", + "yargs-parser": "13.0.0", "yargs-unparser": "1.5.0" }, "dependencies": { @@ -2461,16 +1780,6 @@ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, - "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -2502,25 +1811,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - } - }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -2528,18 +1818,19 @@ "dev": true }, "node-environment-flags": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.4.tgz", - "integrity": "sha512-M9rwCnWVLW7PX+NUWe3ejEdiLYinRpsEre9hMkU/6NS4h+EEulYaDH1gCEZ2gyXsmw+RXYDaV2JkkTNcsPDJ0Q==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", "dev": true, "requires": { - "object.getownpropertydescriptors": "^2.0.3" + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" } }, "node-fetch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", - "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.5.0.tgz", + "integrity": "sha512-YuZKluhWGJwCcUu4RlZstdAxr8bFfOVHakc1mplwHkk8J+tqM1Y5yraYvIUpeX8aY7+crCwiELJq7Vl0o0LWXw==" }, "node-forge": { "version": "0.8.2", @@ -3600,52 +2891,12 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "object-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", - "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "^3.0.0" - } - }, "object.assign": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", @@ -3668,15 +2919,6 @@ "es-abstract": "^1.5.1" } }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -3685,6 +2927,14 @@ "wrappy": "1" } }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, "os-locale": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", @@ -3709,9 +2959,9 @@ "dev": true }, "p-is-promise": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.0.0.tgz", - "integrity": "sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", "dev": true }, "p-limit": { @@ -3738,18 +2988,6 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -3778,12 +3016,6 @@ "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", @@ -3842,28 +3074,6 @@ "util-deprecate": "~1.0.1" } }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - } - }, - "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", @@ -3905,31 +3115,9 @@ "dev": true }, "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", - "dev": true - }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" - } - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, "retry-request": { @@ -3956,15 +3144,6 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "~0.1.10" - } - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -3986,29 +3165,6 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -4099,153 +3255,12 @@ "resolved": "https://registry.npmjs.org/snakeize/-/snakeize-0.1.0.tgz", "integrity": "sha1-EMCI2LWOsHazIpu1oE4jLOEmQi0=" }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "requires": { - "kind-of": "^3.2.0" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "dev": true, - "requires": { - "atob": "^2.1.1", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, "split-array-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/split-array-stream/-/split-array-stream-2.0.0.tgz", @@ -4254,15 +3269,6 @@ "is-stream-ended": "^0.1.4" } }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.0" - } - }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -4285,27 +3291,6 @@ "tweetnacl": "~0.14.0" } }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, "stream-events": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.5.tgz", @@ -4397,48 +3382,6 @@ "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=" }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -4479,41 +3422,6 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, - "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } - } - }, "unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", @@ -4522,46 +3430,6 @@ "crypto-random-string": "^1.0.0" } }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - } - } - }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -4577,12 +3445,6 @@ } } }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, "url": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", @@ -4606,12 +3468,6 @@ "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.0.tgz", "integrity": "sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo=" }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -4754,29 +3610,56 @@ "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" }, "yargs": { - "version": "12.0.5", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", - "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.2.tgz", + "integrity": "sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA==", "dev": true, "requires": { "cliui": "^4.0.0", - "decamelize": "^1.2.0", "find-up": "^3.0.0", - "get-caller-file": "^1.0.1", - "os-locale": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", + "require-main-filename": "^2.0.0", "set-blocking": "^2.0.0", - "string-width": "^2.0.0", + "string-width": "^3.0.0", "which-module": "^2.0.0", - "y18n": "^3.2.1 || ^4.0.0", - "yargs-parser": "^11.1.1" + "y18n": "^4.0.0", + "yargs-parser": "^13.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } } }, "yargs-parser": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", - "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz", + "integrity": "sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw==", "dev": true, "requires": { "camelcase": "^5.0.0", @@ -4792,6 +3675,50 @@ "flat": "^4.1.0", "lodash": "^4.17.11", "yargs": "^12.0.5" + }, + "dependencies": { + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "yargs": { + "version": "12.0.5", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", + "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" + } + }, + "yargs-parser": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", + "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } } } } diff --git a/package.json b/package.json index f1aee89c3..1d120a2b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "A provider agnostic cloud library for Node.js", - "version": "1.7.0", + "version": "2.0.0", "author": "Charlie Robbins ", "contributors": [ "Ross Kukulinski ", From 69b849adf780cd6c68b4682e37d236ab404b3173 Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Mon, 10 Jun 2019 17:42:21 -0400 Subject: [PATCH 453/460] [api] add content encoding option for s3 upload (#661) --- lib/pkgcloud/amazon/storage/client/files.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pkgcloud/amazon/storage/client/files.js b/lib/pkgcloud/amazon/storage/client/files.js index 270b07628..7065e71a0 100644 --- a/lib/pkgcloud/amazon/storage/client/files.js +++ b/lib/pkgcloud/amazon/storage/client/files.js @@ -64,6 +64,10 @@ exports.upload = function (options) { if (options.contentType) { s3Options.ContentType = options.contentType; } + + if (options.contentEncoding) { + s3Options.ContentEncoding = options.contentEncoding; + } // use ACL until a more obvious permission generalization is available if (options.acl) { From 61257e91b33af10b43efa0d08c35672c435b6987 Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Mon, 10 Jun 2019 17:44:17 -0400 Subject: [PATCH 454/460] 2.1.0 --- 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 6566dfb03..33b7446e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pkgcloud", - "version": "2.0.0", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1d120a2b3..ddafad18f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "A provider agnostic cloud library for Node.js", - "version": "2.0.0", + "version": "2.1.0", "author": "Charlie Robbins ", "contributors": [ "Ross Kukulinski ", From c446fb5afb3ff0dd2371ee6e282c249f8ebc8e96 Mon Sep 17 00:00:00 2001 From: Christian Hotz Date: Wed, 26 Jun 2019 21:41:26 +0200 Subject: [PATCH 455/460] Fix GCS upload (#666) * adapt GCS file.upload to googles documentation * do not simultaneously use .on('data' and .pipe on streams * avoid proxy stream --- lib/pkgcloud/google/storage/client/files.js | 33 +++++---------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/lib/pkgcloud/google/storage/client/files.js b/lib/pkgcloud/google/storage/client/files.js index e634c9865..b41567c1e 100644 --- a/lib/pkgcloud/google/storage/client/files.js +++ b/lib/pkgcloud/google/storage/client/files.js @@ -6,8 +6,6 @@ */ var pkgcloud = require('../../../../../lib/pkgcloud'), - through = require('through2'), - mime = require('mime'), storage = pkgcloud.providers.google.storage, _ = require('lodash'); @@ -41,39 +39,22 @@ exports.upload = function (options) { var self = this, bucket = this._getBucket(options), file = this._getFile(bucket, options), - uploadOptions = {}; + metadata = { contentType: options.contentType }; // check for deprecated calling with a callback if (typeof arguments[arguments.length - 1] === 'function') { self.emit('log::warn', 'storage.upload no longer supports calling with a callback'); } - if (options.contentType) { - uploadOptions.contentType = options.contentType; - } else { - uploadOptions.contentType = mime.getType(options.file || options.remote || options); - } - - var proxyStream = through(), - writableStream = file.createWriteStream(uploadOptions); - - // we need a proxy stream so we can always return a file model - // via the 'success' event - writableStream.on('complete', function() { - proxyStream.emit('success', new storage.File(self, file)); - }); + // GCS implicitly detects mime-type if none was implicitly given via options + var writableStream = file.createWriteStream({ metadata }); - writableStream.on('error', function(err) { - proxyStream.emit('error', err); + // return a file model via the 'success' event + writableStream.on('finish', function() { + writableStream.emit('success', new storage.File(self, file)); }); - writableStream.on('data', function(chunk) { - proxyStream.emit('data', chunk); - }); - - proxyStream.pipe(writableStream); - - return proxyStream; + return writableStream; }; /** From 063fe65d3320f4ebdf329b1953f4f231cd24a2e2 Mon Sep 17 00:00:00 2001 From: indexzero Date: Mon, 8 Jul 2019 01:16:30 -0400 Subject: [PATCH 456/460] [dist] Update package-lock.json --- package-lock.json | 192 ++++++++++++++++++++++++---------------------- 1 file changed, 99 insertions(+), 93 deletions(-) diff --git a/package-lock.json b/package-lock.json index 33b7446e8..9e11d4934 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,12 +14,12 @@ } }, "@babel/generator": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.4.tgz", - "integrity": "sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.0.tgz", + "integrity": "sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA==", "dev": true, "requires": { - "@babel/types": "^7.4.4", + "@babel/types": "^7.5.0", "jsesc": "^2.5.1", "lodash": "^4.17.11", "source-map": "^0.5.0", @@ -56,9 +56,9 @@ } }, "@babel/highlight": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", - "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", "dev": true, "requires": { "chalk": "^2.0.0", @@ -67,9 +67,9 @@ } }, "@babel/parser": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.4.tgz", - "integrity": "sha512-5pCS4mOsL+ANsFZGdvNLybx4wtqAZJ0MJjMHxvzI3bvIsz6sQvzW8XX92EYIkiPtIvcfG3Aj+Ir5VNyjnZhP7w==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz", + "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA==", "dev": true }, "@babel/template": { @@ -84,17 +84,17 @@ } }, "@babel/traverse": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.4.tgz", - "integrity": "sha512-Gw6qqkw/e6AGzlyj9KnkabJX7VcubqPtkUQVAwkc0wUMldr3A/hezNB3Rc5eIvId95iSGkGIOe5hh1kMKf951A==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.0.tgz", + "integrity": "sha512-SnA9aLbyOCcnnbQEGwdfBggnc142h/rbqqsXcaATj2hZcegCl903pUD/lfpsNBlBSuWow/YDfRyJuWi2EPR5cg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.4", + "@babel/generator": "^7.5.0", "@babel/helper-function-name": "^7.1.0", "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.4.4", - "@babel/types": "^7.4.4", + "@babel/parser": "^7.5.0", + "@babel/types": "^7.5.0", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.11" @@ -112,9 +112,9 @@ } }, "@babel/types": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz", - "integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", + "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -210,9 +210,9 @@ } }, "@types/node": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.0.tgz", - "integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg==" + "version": "12.0.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.12.tgz", + "integrity": "sha512-Uy0PN4R5vgBUXFoJrKryf5aTk3kJ8Rv3PdlHjl6UaX+Cqp1QE0yPQ68MPXGrZOfG7gZVNDIJZYyot0B9ubXUrQ==" }, "@types/request": { "version": "2.48.1", @@ -239,17 +239,17 @@ } }, "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", "requires": { "es6-promisify": "^5.0.0" } }, "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.1.tgz", + "integrity": "sha512-w1YQaVGNC6t2UCPjEawK/vo/dG8OOrVtUmhBT1uJJYxbl5kU2Tj3v6LGqBcsysN1yhuCStJCCA3GqdvKY8sqXQ==", "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", @@ -319,9 +319,9 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "aws-sdk": { - "version": "2.452.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.452.0.tgz", - "integrity": "sha512-l6J2NmUg12xpDKG9YdlPje5+Z+nNvqyWMA85ookzPqwx8RcD28D3vg4K1aGi27/oo/3NsngR3XfKUBPSqUpUMA==", + "version": "2.488.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.488.0.tgz", + "integrity": "sha512-9AP48tyF1E5+x1CKeiRlj0Sv1YF7KI0BdSW9JP8x3ClhPWNUHjDYNH2OwsALuG1BloeY2ZigYqfI2fB7g3rNHQ==", "requires": { "buffer": "4.9.1", "events": "1.1.1", @@ -511,9 +511,9 @@ "dev": true }, "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "requires": { "delayed-stream": "~1.0.0" } @@ -549,9 +549,9 @@ }, "dependencies": { "readable-stream": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.3.0.tgz", - "integrity": "sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -588,9 +588,9 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "coveralls": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.3.tgz", - "integrity": "sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.4.tgz", + "integrity": "sha512-eyqUWA/7RT0JagiL0tThVhjbIjoiEUyWCjtUJoOPcWoeofP5WK/jb2OJYoBFrR6DvplR+AxOyuBqk4JHkk5ykA==", "dev": true, "requires": { "growl": "~> 1.10.0", @@ -825,9 +825,9 @@ } }, "es6-promise": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", - "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, "es6-promisify": { "version": "5.0.0", @@ -1102,9 +1102,9 @@ } }, "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", + "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==" }, "growl": { "version": "1.9.2", @@ -1251,11 +1251,11 @@ } }, "https-proxy-agent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", + "integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", "requires": { - "agent-base": "^4.1.0", + "agent-base": "^4.3.0", "debug": "^3.1.0" } }, @@ -1280,9 +1280,9 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "invert-kv": { "version": "2.0.0", @@ -1396,9 +1396,9 @@ }, "dependencies": { "semver": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz", - "integrity": "sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", + "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==", "dev": true } } @@ -1666,9 +1666,9 @@ } }, "mime": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", - "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==" + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", + "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==" }, "mime-db": { "version": "1.40.0", @@ -1789,6 +1789,12 @@ "brace-expansion": "^1.1.7" } }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -1807,9 +1813,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nice-try": { "version": "1.0.5", @@ -1828,14 +1834,14 @@ } }, "node-fetch": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.5.0.tgz", - "integrity": "sha512-YuZKluhWGJwCcUu4RlZstdAxr8bFfOVHakc1mplwHkk8J+tqM1Y5yraYvIUpeX8aY7+crCwiELJq7Vl0o0LWXw==" + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, "node-forge": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.2.tgz", - "integrity": "sha512-mXQ9GBq1N3uDCyV1pdSzgIguwgtVpM7f5/5J4ipz12PKWElmPpVWLDuWl8iXmhysr21+WmX/OJ5UKx82wjomgg==" + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.5.tgz", + "integrity": "sha512-vFMQIWt+J/7FLNyKouZ9TazT74PRV3wgv9UT4cRjC8BffxFbKXkgIWR42URCPSnHm/QDz6BOlb2Q0U4+VQT67Q==" }, "npm-run-path": { "version": "2.0.2", @@ -3017,14 +3023,14 @@ "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" }, "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz", + "integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA==" }, "pump": { "version": "2.0.1", @@ -3121,20 +3127,20 @@ "dev": true }, "retry-request": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.0.0.tgz", - "integrity": "sha512-S4HNLaWcMP6r8E4TMH52Y7/pM8uNayOcTDDQNBwsCccL1uI+Ol2TljxRDPzaNfbhOB30+XWP5NnZkB3LiJxi1w==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.1.1.tgz", + "integrity": "sha512-BINDzVtLI2BDukjWmjAIRZ0oglnCAkpP2vQjM3jdLhmT62h0xnQgciPwBRDAvHqpkPT2Wo1XuUyLyn6nbGrZQQ==", "requires": { - "through2": "^2.0.0" + "debug": "^4.1.1", + "through2": "^3.0.1" }, "dependencies": { - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" + "ms": "^2.1.1" } } } @@ -3235,9 +3241,9 @@ } }, "should-util": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", - "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.1.tgz", + "integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==", "dev": true }, "sigmund": { @@ -3464,9 +3470,9 @@ } }, "url-join": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.0.tgz", - "integrity": "sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo=" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", + "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==" }, "util-deprecate": { "version": "1.0.2", @@ -3565,9 +3571,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "write-file-atomic": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.2.tgz", - "integrity": "sha512-s0b6vB3xIVRLWywa6X9TOMA7k9zio0TMOsl9ZnDkliA/cfJlpHXAscj0gbHVJiTdIuAYpIyqS5GW91fqm6gG5g==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", "requires": { "graceful-fs": "^4.1.11", "imurmurhash": "^0.1.4", From f8dfbd00dbbbd861d4f1354dcae8b39a125a3331 Mon Sep 17 00:00:00 2001 From: indexzero Date: Mon, 8 Jul 2019 01:17:21 -0400 Subject: [PATCH 457/460] [doc] Update CHANGELOG.md --- CHANGELOG.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e557764c..274a8e6fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,48 @@ -## FUTURE +## CHANGELOG + +## v2.1.0 + +- Add content encoding option for s3 upload + +## v2.0.0 + +- [BREAKING] Drop all legacy providers. +- Update dependencies. +- Documentation fixes. + - Fix broken links to databases.md + - Replace Openstack with OpenStack + - Fix page title markdown formatting +- `this.protocol` from client instance is used as the URL protocol + as it should be. Fixes [#526]. + +## v1.7.0 * Amazon use native `aws-sdk` for `s3` uploads instead of `s3-upload-stream` module * Update the `aws-sdk` to `2.382.0` * Amazon storage client.upload - expose concurrency - `queueSize` and `partSize` configurability and add ability to abort an upload +## v1.6.0 + +- Equivalent to `v1.5.0`. + +## v1.5.0 + +- Added 1&1 support with tests. +- Set Content-Type with Google storage. Fixes [#635]. +- Attempt to restrict to `node@6` and `node@8`. +- [fix] Patched RegEx DoS vuln & Remote Memory Exposure vuln. + This addresses two major security issues: + - https://nodesecurity.io/advisories/309 + - https://nodesecurity.io/advisories/535 +- Fix typo in OpenStack `createSecurityGroupRule`. Fixes [#556]. +- Fix typo in `createSecurityGroup`. Fixes [#454]. +- Fix breaking test due to expired auth token. + +## v1.4.0 + +- Pass in other aws options that allow an s3 like API to be configured correctly +- Fixing broken merge from replacing underscore with lodash + ## v1.3.0 * OpenStack identity v3 (keystone) support, Issue [#367](//github.com/pkgcloud/pkgcloud/issues/367), [#477](//github.com/pkgcloud/pkgcloud/issues/477), PR [#461](//github.com/pkgcloud/pkgcloud/pull/461) * OpenStack cancel client download, Issue [#379](//github.com/pkgcloud/pkgcloud/issues/379), PR [#416](//github.com/pkgcloud/pkgcloud/pull/416) From a86ac182bbe69088bee03789ecb940372fad4b66 Mon Sep 17 00:00:00 2001 From: indexzero Date: Mon, 8 Jul 2019 01:18:24 -0400 Subject: [PATCH 458/460] [dist] Version bump. 2.1.1 --- CHANGELOG.md | 4 ++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 274a8e6fa..f1bdf7177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## CHANGELOG +## v2.1.1 + +- [#666], [@guischdi] Fix GCS upload. + ## v2.1.0 - Add content encoding option for s3 upload diff --git a/package-lock.json b/package-lock.json index 9e11d4934..bcfb2b49b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pkgcloud", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ddafad18f..1210712e3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "A provider agnostic cloud library for Node.js", - "version": "2.1.0", + "version": "2.1.1", "author": "Charlie Robbins ", "contributors": [ "Ross Kukulinski ", From c2f8db03fbf57b82ce786e902c816a84989e97a0 Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Tue, 22 Oct 2019 14:38:50 -0400 Subject: [PATCH 459/460] [fix] support more auth scenarios for amazon with credentials object and session token (#678) --- lib/pkgcloud/amazon/client.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pkgcloud/amazon/client.js b/lib/pkgcloud/amazon/client.js index 6b756db79..e6786ea8f 100644 --- a/lib/pkgcloud/amazon/client.js +++ b/lib/pkgcloud/amazon/client.js @@ -33,7 +33,9 @@ var Client = exports.Client = function (options) { accessKeyId: this.config.keyId, secretAccessKey: this.config.key, region: options.region, - s3ForcePathStyle: options.forcePathBucket + s3ForcePathStyle: options.forcePathBucket, + sessionToken: options.sessionToken, + credentials: options.credentials }; // TODO think about a proxy option for pkgcloud From b6e5b0d4db8d164f444c780ac96c06e555e0b703 Mon Sep 17 00:00:00 2001 From: Jarrett Cruger Date: Tue, 22 Oct 2019 14:43:34 -0400 Subject: [PATCH 460/460] 2.2.0 --- CHANGELOG.md | 10 +++++++--- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1bdf7177..a47e3ac36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ ## CHANGELOG +## v2.2.0 + +- [#678] [@jcrugzz] support more aws auth scenarios via credentials object or sessionToken. + ## v2.1.1 -- [#666], [@guischdi] Fix GCS upload. +- [#666], [@guischdi] Fix GCS upload. ## v2.1.0 @@ -32,9 +36,9 @@ ## v1.5.0 - Added 1&1 support with tests. -- Set Content-Type with Google storage. Fixes [#635]. +- Set Content-Type with Google storage. Fixes [#635]. - Attempt to restrict to `node@6` and `node@8`. -- [fix] Patched RegEx DoS vuln & Remote Memory Exposure vuln. +- [fix] Patched RegEx DoS vuln & Remote Memory Exposure vuln. This addresses two major security issues: - https://nodesecurity.io/advisories/309 - https://nodesecurity.io/advisories/535 diff --git a/package-lock.json b/package-lock.json index bcfb2b49b..e6d06e53f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pkgcloud", - "version": "2.1.1", + "version": "2.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1210712e3..85af72f3f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pkgcloud", "description": "A provider agnostic cloud library for Node.js", - "version": "2.1.1", + "version": "2.2.0", "author": "Charlie Robbins ", "contributors": [ "Ross Kukulinski ",