The node-cloudservers library is compliant with the Rackspace CloudServers API. Using node-cloudservers is easy for a variety of scenarios: authenticating, getting flavors and images, creating servers, and working with servers.

There are several entities in the Rackspace CloudServer 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:

If you manually create servers yourself via the Rackspace CloudServer management console, you can skip this section. For dynamically load balanced applications like nodejitsu, creating servers on-the-fly is important. To create a server, you will need the id of the image and flavor of the server. You can also pass an instance of a node-cloudservers Flavor or Image.

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:

If you have already created a some Rackspace CloudServer 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:

client.getServers(true, function (err, servers) {
// Inspect the servers that have been returned
util.inspect(servers);
});

Once you're working with servers that are already active there are several operations that you can perform on it:

The 'getAddresses' method takes a callback which has the set of the valid IP addresses for the Server as a parameter. This method takes an optional first parameter with a value of 'public' or 'private', which will force only the public or private IP addresses to be returned respectively.

server.getAddresses(function (addresses) {
// Inspect the addresses that were returned
util.inspect(addresses);
});

All of the node-cloudservers tests are written in vows, 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:

{
"auth": {
"username": "your-username",
"apiKey": "your-apikey"
}
}

Once you have valid Rackspace credentials you can run tests with vows:

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.