Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[doc dist test] Version bump. 0.2.0

  • Loading branch information...
commit 69866e83afaddfc1a778a4e23da31869c33699e2 1 parent 9d12753
Charlie Robbins indexzero authored
4 .gitignore
View
@@ -1,2 +1,4 @@
/test/files
-/test/files/*
+/test/files/*
+/test/data
+/test/data/*
8 CHANGELOG.md
View
@@ -0,0 +1,8 @@
+## ChangeLog for: node-cloudservers
+
+### Version 0.2.0
+- Improved test coverage
+- Pushed test config out of lib/ to test/data/test-config.json
+
+#### Breaking Changes
+- cloudservers no longer exposes methods on the module itself. Replace cloudservers.* with client.* where var client = cloudservers.createClient(config).
22 LICENSE
View
@@ -0,0 +1,22 @@
+node-cloudservers
+
+Copyright (c) 2010 Nodejitsu Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, 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.
70 README.md
View
@@ -16,43 +16,38 @@ A client implementation for Rackspace CloudServers in node.js
### [Getting Rackspace Account][4]
-
## Usage
[http://blog.nodejitsu.com/nodejs-cloud-server-in-three-minutes][3]
The node-cloudservers library is compliant with the [Rackspace CloudServers API][0]. Using node-cloudservers is easy for a variety of scenarios: authenticating, getting flavors and images, creating servers, and working with servers.
-### Authenticating
-Before we can do anything with cloudservers, we have to authenticate. Authenticating is simple:
+### Getting Started
+Before we can do anything with cloudfiles, we have to create a client with valid credentials. Cloudservers will authenticate for you automatically:
<pre>
var cloudservers = require('cloudservers');
- var example = {
+ var config = {
auth : {
username: 'your-username',
apiKey: 'your-api-key'
}
};
- cloudservers.setAuth(example.auth, function () {
- // Work with Rackspace Cloudservers from here
- });
+ var client = cloudservers.createClient(config);
</pre>
### Getting Flavors and Images
There are several entities in the [Rackspace CloudServer][4] ecosystem: images, flavors, and servers. Both the getFlavors and getImages methods take an optional first parameter which when set to true will return more details for the objects returned. Here's how to get the list of all available flavors and images associated with your Rackspace account:
<pre>
- cloudservers.setAuth(example.auth, function () {
- cloudservers.getFlavors(function (err, flavors) {
- // Dump the flavors we have just received
- util.inspect(flavors);
- example.flavors = flavors;
- });
-
- cloudservers.getImages(function (err, images) {
- // Dump the flavors we have just received
- util.inspect(images);
- example.images = images;
- });
+ client.getFlavors(function (err, flavors) {
+ // Dump the flavors we have just received
+ util.inspect(flavors);
+ example.flavors = flavors;
+ });
+
+ client.getImages(function (err, images) {
+ // Dump the flavors we have just received
+ util.inspect(images);
+ example.images = images;
});
</pre>
@@ -65,17 +60,15 @@ If you manually create servers yourself via the [Rackspace CloudServer][4] manag
image: 49, // Ubuntu Lucid
flavor: 1, // 256 server
};
- cloudservers.setAuth(example.auth, function () {
- cloudservers.createServer(options, function (server) {
- // Your server is now being built and will be ready shortly
- });
+
+ client.createServer(options, function (server) {
+ // Your server is now being built and will be ready shortly
});
</pre>
### Setting a 'personality' for a Server
Rackspace CloudServers exposes an API that allows you to include an arbitrary number of files less than 10kb on a new server. Each file must be Base64 encoded. To use this functionality in node-cloudservers just include the path and contents of each file when creating a server:
<pre>
-
var options = {
name: 'test-server',
image: 49, // Ubuntu Lucid
@@ -85,10 +78,9 @@ Rackspace CloudServers exposes an API that allows you to include an arbitrary nu
contents: new Buffer('hello world').toString('base64')
}]
};
- cloudservers.setAuth(example.auth, function () {
- cloudservers.createServer(options, function (server) {
- // Your server is now being built and will be ready shortly
- });
+
+ client.createServer(options, function (server) {
+ // Your server is now being built and will be ready shortly
});
</pre>
@@ -103,7 +95,7 @@ Once you've created a server, you can't work with it until it has become active.
### Working with Servers
If you have already created a some [Rackspace CloudServer][4] instances it is easy to get them from your account with node-cloudservers with the getServers method. This method takes an optional first parameter that when set to true will return all details for the servers:
<pre>
- cloudservers.getServers(true, function (servers) {
+ client.getServers(true, function (servers) {
// Inspect the servers that have been returned
util.inspect(servers);
});
@@ -174,7 +166,17 @@ The 'updateBackup' method will update the backup schedule of the server on which
3. Get the core 'createImage' operation working.
## Run Tests
-All of the node-cloudservers tests are written in [vows][2], and cover all of the use cases described above. You will need to add your Rackspace API username and API key to lib/cloudservers/config.js before running tests.
+All of the node-cloudservers tests are written in [vows][2], and cover all of the use cases described above. You will need to add your Rackspace API username and API key to test/data/test-config.json before running tests:
+<pre>
+ {
+ "auth": {
+ "username": "your-username",
+ "apiKey": "your-apikey"
+ }
+ }
+</pre>
+
+Once you have valid Rackspace credentials you can run tests with [vows][2]:
<pre>
vows test/*-test.js --spec
</pre>
@@ -183,17 +185,17 @@ All of the node-cloudservers tests are written in [vows][2], and cover all of th
One common usage of the personality features in Rackspace CloudServers is to upload your own SSH keys for communicating with your new server. To run these tests you will need to generate a test key locally.
<pre>
$ cd /path/to/node-cloudservers
- $ mkdir test/files
+ $ mkdir test/data
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
- Enter file in which to save the key (~/.ssh/id_rsa): /path/to/node-cloudservers/test/files/testkey
+ Enter file in which to save the key (~/.ssh/id_rsa): /path/to/node-cloudservers/test/data/testkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
- Your identification has been saved in /path/to/node-cloudservers/test/files/testkey.
+ Your identification has been saved in /path/to/node-cloudservers/test/data/testkey.
</pre>
#### Author: [Charlie Robbins](http://www.charlierobbins.com)
-#### Contributors: [Elijah Insua](http://github.com/tmpvar)
+#### Contributors: [Elijah Insua](http://github.com/tmpvar) [Matthew Bergman](http://github.com/fotoverite)
[0]: http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf
[1]: http://nodejitsu.com
3  lib/cloudservers.js
View
@@ -10,6 +10,9 @@ require.paths.unshift(__dirname);
var cloudservers = exports;
+// Version
+cloudservers.version = [0, 2, 0];
+
cloudservers.createClient = require('cloudservers/core').createClient;
cloudservers.Client = require('cloudservers/core').clients;
3  package.json
View
@@ -13,7 +13,8 @@
},
"keywords": ["cloud computing", "api", "rackspace cloud", "cloudservers"],
"dependencies": {
- "request": ">= 0.10.0"
+ "request": ">= 0.10.0",
+ "vows": ">= 0.5.2"
},
"main": "./lib/cloudservers",
"scripts": { "test": "vows test/*-test.js --spec" },
23 test/helpers.js
View
@@ -25,15 +25,24 @@ helpers.createClient = function () {
};
helpers.loadConfig = function () {
- var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'data', 'test-config.json')).toString());
- if (config.auth.username === 'test-username'
- || config.auth.apiKey === 'test-apiKey') {
- util.puts('Config file test-config.json must be updated with valid data before running tests');
+ try {
+ var configFile = path.join(__dirname, 'data', 'test-config.json'),
+ stats = fs.statSync(configFile),
+ config = JSON.parse(fs.readFileSync(configFile).toString());
+
+ if (config.auth.username === 'test-username'
+ || config.auth.apiKey === 'test-apiKey') {
+ util.puts('Config file test/data/test-config.json must be created with valid data before running tests');
+ process.exit(0);
+ }
+
+ testConfig = config;
+ return config;
+ }
+ catch (ex) {
+ util.puts('Config file test/data/test-config.json must be created with valid data before running tests');
process.exit(0);
}
-
- testConfig = config;
- return config;
};
helpers.assertServer = function (server) {
4 test/personality-test.js
View
@@ -16,7 +16,7 @@ var fs = require('fs'),
cloudservers = require('cloudservers'),
spawn = require('child_process').spawn,
helpers = require('./helpers'),
- keyBuffer = fs.readFileSync(__dirname + "/files/testkey.pub");
+ keyBuffer = fs.readFileSync(__dirname + "/data/testkey.pub");
var testServer, testData = {},
client = helpers.createClient();
@@ -50,7 +50,7 @@ vows.describe('node-cloudservers/personalities').addBatch({
testServer.setWait({ status: 'ACTIVE' }, 5000, function () {
var ssh = spawn('ssh', [
'-i',
- __dirname + '/files/testkey',
+ __dirname + '/data/testkey',
'-q',
'-o',
'StrictHostKeyChecking no',
Please sign in to comment.
Something went wrong with that request. Please try again.