nodejitsu/pkgcloud — pull request #141 by kenperkins (2013-05-22 04:18:15+00:00)
Title: [Rackspace] Switching Rackspace to derive from Openstack

### Overview

This PR introduces a few key changes to pkgcloud:

* `Rackspace` client is now based on the `Openstack` Client
* `Rackspace` and `Openstack` clients take an authUrl with protocol, i.e. `https://lon.identity.rackspacecloud.com`
* `Rackspace` and `Openstack` clients now take an optional `region` parameter for specifying the region.
* Both the `Rackspace` and `Openstack` clients automatically re-authenticate when the token expires
* Adds a self.emit('log::', ...) in a few key places

### Specifying a custom region

Previously, you were unable to specify a region for a service within the Service Catalog. For example. to use Compute in the `ORD` region:

```Javascript
var client = require('pkgcloud').compute.createClient({
provider: 'rackspace',
username: 'your-user-name',
apiKey: 'your-api-key',
region: 'ORD'
});
```

### Custom logging with your provider:

You can now enable logging with `pkgcloud` if you wire up the `log` event:

```Javascript
var client = require('pkgcloud').compute.createClient({
provider: 'rackspace',
username: 'your-user-name',
apiKey: 'your-api-key',
region: 'ORD'
});

client.on('log::debug', function(message, meta) {
console.log('DEBUG: ' + message);
meta && console.dir(meta);
});
```

Currently, there are only log emits in `core/client.js` and `openstack/client.js`. These should ideally be added to key locations in other providers. It's rather trivial to [wire this up to use winston](https://gist.github.com/kenperkins/5625207) now.

### Next Generation Cloud Servers

The significant major change is that with this PR, `pkgcloud` no longer supports Rackspace First Generation Cloud Servers.

### Other Notes

I have a few code-style changes to add before this should be merged, but I wanted to get the general changes out as soon as possible to start dialog on the changes.