Comparing version 0.6.1 to 0.6.2
@@ -5,3 +5,3 @@ var pkgcloud = require('../../lib/pkgcloud'); | ||
provider: 'azure', | ||
storageAccount: 'test-storage-account', // Name of your storage account | ||
storageAccount: 'test-storage-account', // Name of your storage account | ||
storageAccessKey: 'test-storage-access-key', // Access key for storage account | ||
@@ -11,10 +11,10 @@ managementCertificate: './test/fixtures/azure/cert/management/management.pem', | ||
azure: { | ||
location: 'East US', // Azure location for server | ||
username: 'pkgcloud', // Username for server | ||
password: 'Pkgcloud!!', // Password for server | ||
location: 'East US', // Azure location for server | ||
username: 'pkgcloud', // Username for server | ||
password: 'Pkgcloud!!', // Password for server | ||
// | ||
// SSH settings for linux server | ||
// | ||
ssh: { | ||
port: 22, // default is 22 | ||
ssh: { | ||
port: 22, // default is 22 | ||
pem: "./test/fixtures/azure/cert/ssh/mycert.pem", | ||
@@ -26,6 +26,6 @@ pemPassword: "" | ||
// | ||
rdp: { | ||
rdp: { | ||
port: 3389 | ||
} | ||
} | ||
}); | ||
}); |
@@ -5,3 +5,3 @@ var pkgcloud = require('../../lib/pkgcloud'); | ||
provider: 'azure', | ||
storageAccount: "storage-account-name", // Name of your Azure storage account | ||
storageAccount: "storage-account-name", // Name of your Azure storage account | ||
storageAccessKey: "storage-account-access-key" // Access key for storage account | ||
@@ -8,0 +8,0 @@ }); |
@@ -5,4 +5,4 @@ var pkgcloud = require('../../lib/pkgcloud'); | ||
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 | ||
}); |
@@ -30,3 +30,12 @@ /* | ||
// add the auth keys for request authorization | ||
this.azureKeys = keyfile.readFromFile(this.config.managementCertificate); | ||
if (this.config.key && this.config.cert) { | ||
this.azureKeys = { | ||
key: this.config.key, | ||
cert: this.config.cert | ||
}; | ||
} | ||
else { | ||
this.azureKeys = keyfile.readFromFile(this.config.managementCertificate); | ||
} | ||
this.azureKeys.subscriptionId = this.config.subscriptionId; | ||
@@ -33,0 +42,0 @@ |
@@ -87,3 +87,3 @@ /* | ||
if (body && body.entry) { | ||
if (_.isArray(body.entry)) { | ||
if (Array.isArray(body.entry)) { | ||
body.entry.forEach(function (table) { | ||
@@ -128,2 +128,2 @@ tables.push(self.formatResponse(table)); | ||
.replace(/\*/g, '%2A'); | ||
}; | ||
}; |
@@ -401,3 +401,3 @@ /** | ||
// need to check if azure returned an array or single object | ||
if (_.isArray(body.HostedService)) { | ||
if (Array.isArray(body.HostedService)) { | ||
body.HostedService.forEach(function (service) { | ||
@@ -404,0 +404,0 @@ services.push(service); |
@@ -23,7 +23,7 @@ /* | ||
if (typeof options.key !== 'string') { | ||
if (!options.key) { | ||
throw new TypeError('`key` is a required argument for azure-signature'); | ||
} | ||
if (typeof options.cert!== 'string') { | ||
if (!options.cert) { | ||
throw new TypeError('`cert` is a required argument for azure-signature'); | ||
@@ -30,0 +30,0 @@ } |
@@ -218,3 +218,3 @@ /* | ||
if (!this.authorized && this.provider === 'rackspace') { | ||
if (!this.authorized && (this.provider === 'rackspace' || this.provider == 'openstack')) { | ||
// | ||
@@ -221,0 +221,0 @@ // If this instance is not yet authorized, then return |
@@ -72,3 +72,3 @@ /* | ||
function readKey (key, next) { | ||
var keytype = path.extname(key) === '.pub' || path.extname(key) === '.pem' ? 'public' : 'private'; | ||
var keytype = path.extname(key) === '.pub' ? 'public' : 'private'; | ||
fs.readFile(key, function (err, data) { | ||
@@ -197,12 +197,22 @@ if (err) { | ||
// | ||
// Grace period for IP propagation | ||
// | ||
setTimeout(function () { | ||
self.bootstrapServer(options) | ||
.on('error', onError) | ||
.on('complete', function () { | ||
emitter.emit('complete', server); | ||
}); | ||
}, 60 * 1000); | ||
function waitForLatentBind(err) { | ||
if (err) { | ||
return emitter.emit('error', err); | ||
} | ||
// | ||
// Grace period for IP propagation | ||
// | ||
setTimeout(function () { | ||
self.bootstrapServer(options) | ||
.on('error', onError) | ||
.on('complete', function () { | ||
emitter.emit('complete', server); | ||
}); | ||
}, 60 * 1000); | ||
} | ||
return options.afterCreate | ||
? options.afterCreate(self.compute, server, waitForLatentBind) | ||
: waitForLatentBind(); | ||
}); | ||
@@ -729,7 +739,7 @@ }); | ||
// | ||
// If the target process didn't exit with code = 0 and signal = null | ||
// If the target process didn't exit with code = 0 | ||
// assume something went wrong. | ||
// | ||
if (code !== 0 && signal !== null) { | ||
errs.push(new Error(command + ' exited unexpectedly')); | ||
if (code !== 0) { | ||
errs.push(new Error(command + ' exited unexpectedly with code: ' + code)); | ||
} | ||
@@ -736,0 +746,0 @@ |
@@ -24,9 +24,55 @@ /* | ||
// | ||
// ### function serverIp (server) | ||
// #### @server {Object} Server to extract the IP from. | ||
// | ||
// Attempts to return the `server` IP. | ||
// | ||
exports.serverIp = function (server) { | ||
return (server.ips && server.ips[0]) | ||
|| ( | ||
server.addresses | ||
&& (server.addresses.public || server.addresses.private) | ||
&& (server.addresses.public[0] || server.addresses.private[0]) | ||
); | ||
if (!server && !server.ips && !server.addresses) { | ||
return null; | ||
} | ||
var networks, | ||
interfaces; | ||
if (server.ips) { | ||
// | ||
// Joyent uses the format { ips: ['23.23.23.23', '10.0.0.1'] } | ||
// | ||
return server.ips[0]; | ||
} | ||
else if (server.addresses.public || server.addresses.private) { | ||
// | ||
// Rackspace and most sane providers use: | ||
// | ||
// addresses: { | ||
// public: ['23.23.23.23'], | ||
// private: ['10.0.0.1'] | ||
// } | ||
// | ||
return (server.addresses.public || server.addresses.private)[0]; | ||
} | ||
else if (server.addresses) { | ||
// | ||
// OpenStack uses a non-standard set of names | ||
// | ||
// addresses: { | ||
// vlan01: [ | ||
// { version: 4, addr: '10.0.0.1' } | ||
// { version: 4, addr: '23.23.23.23' } | ||
// ] | ||
// } | ||
// | ||
networks = Object.keys(server.addresses); | ||
if (!networks.length) { | ||
return null; | ||
} | ||
interfaces = server.addresses[networks[0]]; | ||
return (interfaces[1] && interfaces[1].addr) | ||
|| (interfaces[0] && interfaces[0].addr) | ||
|| null; | ||
} | ||
}; |
@@ -104,2 +104,3 @@ /* | ||
449: 'Retry With', | ||
500: 'Internal Error', | ||
503: 'Service Unavailable' | ||
@@ -106,0 +107,0 @@ }; |
@@ -33,3 +33,2 @@ /* | ||
req.headers['Content-Type'] = 'application/json'; | ||
req.body = JSON.stringify(req.body); | ||
} | ||
@@ -146,5 +145,4 @@ }); | ||
} | ||
if (body.access && body.access.token) { | ||
setCatalogList(body.access, cb); | ||
else if (body.access && body.access.token) { | ||
return setCatalogList(body.access, cb); | ||
} | ||
@@ -174,3 +172,3 @@ | ||
getToken(function (err, validToken, validTenant, urls) { | ||
if(err) { | ||
if (err) { | ||
return callback(err); | ||
@@ -186,20 +184,2 @@ } | ||
Client.prototype._ensureAuth = function _ensureAuth (callback) { | ||
var self = this; | ||
if (!this.authorized) { | ||
this.auth(function () { | ||
callback(); | ||
}); | ||
} else { callback(); } | ||
}; | ||
Client.prototype._request = function _request () { | ||
var self = this, | ||
args = arguments; | ||
this._ensureAuth(function() { | ||
self.request.apply(self, args); | ||
}); | ||
}; | ||
Client.prototype.serviceUrl = function serviceUrl (service) { | ||
@@ -206,0 +186,0 @@ var serviceName = service + 'Url', |
@@ -21,3 +21,3 @@ /* | ||
var self = this; | ||
return this._request('flavors/detail', callback, function (body, res) { | ||
return this.request('flavors/detail', callback, function (body, res) { | ||
callback(null, body.flavors.map(function (result) { | ||
@@ -24,0 +24,0 @@ return new compute.Flavor(self, result); |
@@ -21,3 +21,3 @@ /* | ||
return this._request('images/detail', callback, function (body, res) { | ||
return this.request('images/detail', callback, function (body, res) { | ||
callback(null, body.images.map(function (result) { | ||
@@ -24,0 +24,0 @@ return new compute.Image(self, result); |
@@ -33,3 +33,3 @@ /* | ||
this.auth(function () { | ||
self._request({ | ||
self.request({ | ||
url: self.url().replace(self.config.tenantId, '') | ||
@@ -42,1 +42,8 @@ }, callback, function (body, res) { | ||
}; | ||
Client.prototype.getOsFloatingIps = function (callback) { | ||
this.request('os-floating-ips', callback, function (body, res) { | ||
return callback(null, body.floating_ips); | ||
}); | ||
}; | ||
@@ -20,7 +20,7 @@ /* | ||
method: 'POST', | ||
path: ['servers', id, 'action'], | ||
path: ['servers', id, 'action'].join('/'), | ||
body: body | ||
}; | ||
return this._request(actionOptions, callback, function (body, res) { | ||
return this.request(actionOptions, callback, function (body, res) { | ||
callback(null, { ok: id }, res); | ||
@@ -37,3 +37,3 @@ }); | ||
exports.getLimits = function (callback) { | ||
return this._request('limits', callback, function (body, res) { | ||
return this.request('limits', callback, function (body, res) { | ||
callback(null, body.limits, res); | ||
@@ -52,3 +52,3 @@ }); | ||
var self = this; | ||
return this._request('servers/detail', callback, function (body, res) { | ||
return this.request('servers/detail', callback, function (body, res) { | ||
callback(null, body.servers.map(function (result) { | ||
@@ -120,4 +120,7 @@ return new compute.Server(self, result); | ||
createOptions.body.server.personality = options.personality || []; | ||
return this._request(createOptions, callback, function (body, res) { | ||
var serverInfo = JSON.parse(createOptions.body).server; | ||
return this.request(createOptions, callback, function (body, res) { | ||
if (!body.server) { | ||
return new Error('Server not passed back from OpenStack.'); | ||
} | ||
callback(null, new compute.Server(self, { | ||
@@ -127,5 +130,5 @@ id: body.server.id, | ||
adminPass: body.server.adminPass, | ||
flavorId: serverInfo.flavorRef, | ||
imageId: serverInfo.imageRef, | ||
personality: serverInfo.personality | ||
flavorId: body.server.flavorRef, | ||
imageId: body.server.imageRef, | ||
personality: body.server.personality | ||
}), res); | ||
@@ -149,3 +152,3 @@ }); | ||
return this._request(destroyOptions, callback, function (body, res) { | ||
return this.request(destroyOptions, callback, function (body, res) { | ||
callback(null, {ok: serverId}, res); | ||
@@ -166,3 +169,3 @@ }); | ||
return this._request('servers/' + serverId, callback, function (body, res) { | ||
return this.request('servers/' + serverId, callback, function (body, res) { | ||
callback(null, new compute.Server(self, body.server), res); | ||
@@ -193,5 +196,17 @@ }); | ||
// legacy code below | ||
// DEPRECATED | ||
// not officially supported | ||
// | ||
// # Provider specific implementation follows | ||
// **not officially supported** | ||
// | ||
exports.addFloatingIp = function (server, ip, callback) { | ||
var serverId = server instanceof base.Server ? server.id : server; | ||
serverAction.call(this, serverId, { | ||
addFloatingIp: { | ||
address: ip | ||
} | ||
}, callback); | ||
}; | ||
exports.getServerAddresses = function (server, type, callback) { | ||
@@ -206,3 +221,3 @@ if (!callback && typeof type === 'function') { | ||
this._request(['servers', serverId, 'ips', type].join('/'), callback, function (body, res) { | ||
this.request(['servers', serverId, 'ips', type].join('/'), callback, function (body, res) { | ||
var result = body; | ||
@@ -216,3 +231,3 @@ callback(null, result.addresses || result, res); | ||
this._request({ | ||
this.request({ | ||
method: 'PUT', | ||
@@ -250,3 +265,3 @@ path: ['servers', serverId], | ||
this._request(backupOptions, callback, function (body, res) { | ||
this.request(backupOptions, callback, function (body, res) { | ||
callback(null, body.backupSchedule, res); | ||
@@ -266,3 +281,3 @@ }); | ||
this._request(updateOptions, callback, function (body, res) { | ||
this.request(updateOptions, callback, function (body, res) { | ||
callback(null, res); | ||
@@ -276,5 +291,5 @@ }); | ||
this._request('DELETE', disableUrl, callback, function (body, res) { | ||
this.request('DELETE', disableUrl, callback, function (body, res) { | ||
callback(null, res); | ||
}); | ||
}; |
@@ -18,2 +18,3 @@ /* | ||
Server.prototype._setProperties = function (details) { | ||
var self = this; | ||
// Set core properties | ||
@@ -68,4 +69,27 @@ this.id = details.id; | ||
this.hostId = details.hostId || this.hostId; | ||
this.original = this.OpenStack = details; | ||
this.original = this.openstack = details; | ||
if (Object.keys(this.addresses).length && !this.addresses.public | ||
&& !this.addresses.private) { | ||
this.addresses = Object.keys(this.addresses) | ||
.map(function (network) { | ||
return self.addresses[network] | ||
}) | ||
.reduce(function (all, interfaces) { | ||
Object.keys(interfaces).map(function (interface) { | ||
return interfaces[interface].addr | ||
}) | ||
.forEach(function (ip) { | ||
if (/(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^100\.)/.test(ip)) { | ||
all['private'].push(ip); | ||
} | ||
else { | ||
all['public'].push(ip); | ||
} | ||
}); | ||
return all; | ||
}, { public: [], private: [] }); | ||
} | ||
// Try to set the flavorId using a flavor object | ||
@@ -72,0 +96,0 @@ if (typeof this.flavorId === "undefined" && |
{ | ||
"name": "pkgcloud", | ||
"description": "An infrastructure-as-a-service agnostic cloud library for node.js", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"author": "Nodejitsu Inc <info@nodejitsu.com", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11186787
18906