# Path: libcloud/common/base.py
# class ConnectionUserAndKey(ConnectionKey):
#     """
#     Base connection which accepts a user_id and key
#     """
# 
#     user_id = None
# 
#     def __init__(self, user_id, key, secure=True, host=None, port=None):
#         super(ConnectionUserAndKey, self).__init__(key, secure, host, port)
#         self.user_id = user_id
# 
# Path: libcloud/compute/types.py
# class Provider(object):
# class NodeState(object):
# class DeploymentError(LibcloudError):
#     DUMMY = 0
#     EC2 = 1  # deprecated name
#     EC2_US_EAST = 1
#     EC2_EU = 2 # deprecated name
#     EC2_EU_WEST = 2
#     RACKSPACE = 3
#     SLICEHOST = 4
#     GOGRID = 5
#     VPSNET = 6
#     LINODE = 7
#     VCLOUD = 8
#     RIMUHOSTING = 9
#     EC2_US_WEST = 10
#     VOXEL = 11
#     SOFTLAYER = 12
#     EUCALYPTUS = 13
#     ECP = 14
#     IBM = 15
#     OPENNEBULA = 16
#     DREAMHOST = 17
#     ELASTICHOSTS = 18
#     ELASTICHOSTS_UK1 = 19
#     ELASTICHOSTS_UK2 = 20
#     ELASTICHOSTS_US1 = 21
#     EC2_AP_SOUTHEAST = 22
#     RACKSPACE_UK = 23
#     BRIGHTBOX = 24
#     CLOUDSIGMA = 25
#     EC2_AP_NORTHEAST = 26
#     RUNNING = 0
#     REBOOTING = 1
#     TERMINATED = 2
#     PENDING = 3
#     UNKNOWN = 4
#     def __init__(self, node, original_exception=None):
#     def __str__(self):


import httplib
from urllib2 import urlparse
from libcloud.common.base import ConnectionUserAndKey
from libcloud.compute.types import InvalidCredsError
        self.__host = None
        super(RackspaceBaseConnection, self).__init__(user_id, key, secure=secure)

    def add_default_headers(self, headers):
        headers['X-Auth-Token'] = self.auth_token
        headers['Accept'] = self.accept_format
        return headers

    @property
    def host(self):
        """
        Rackspace uses a separate host for API calls which is only provided
        after an initial authentication request. If we haven't made that
        request yet, do it here. Otherwise, just return the management host.
        """
        if not self.__host:
            # Initial connection used for authentication
            conn = self.conn_classes[self.secure](self.auth_host, self.port[self.secure])
            conn.request(
                method='GET',
                url='/%s' % (AUTH_API_VERSION),
                headers={
                    'X-Auth-User': self.user_id,
                    'X-Auth-Key': self.key
                }
            )

            resp = conn.getresponse()

            if resp.status != httplib.NO_CONTENT:

# Path: libcloud/common/base.py
# class ConnectionUserAndKey(ConnectionKey):
#     """
#     Base connection which accepts a user_id and key
#     """
# 
#     user_id = None
# 
#     def __init__(self, user_id, key, secure=True, host=None, port=None):
#         super(ConnectionUserAndKey, self).__init__(key, secure, host, port)
#         self.user_id = user_id
# 
# Path: libcloud/compute/types.py
# class Provider(object):
# class NodeState(object):
# class DeploymentError(LibcloudError):
#     DUMMY = 0
#     EC2 = 1  # deprecated name
#     EC2_US_EAST = 1
#     EC2_EU = 2 # deprecated name
#     EC2_EU_WEST = 2
#     RACKSPACE = 3
#     SLICEHOST = 4
#     GOGRID = 5
#     VPSNET = 6
#     LINODE = 7
#     VCLOUD = 8
#     RIMUHOSTING = 9
#     EC2_US_WEST = 10
#     VOXEL = 11
#     SOFTLAYER = 12
#     EUCALYPTUS = 13
#     ECP = 14
#     IBM = 15
#     OPENNEBULA = 16
#     DREAMHOST = 17
#     ELASTICHOSTS = 18
#     ELASTICHOSTS_UK1 = 19
#     ELASTICHOSTS_UK2 = 20
#     ELASTICHOSTS_US1 = 21
#     EC2_AP_SOUTHEAST = 22
#     RACKSPACE_UK = 23
#     BRIGHTBOX = 24
#     CLOUDSIGMA = 25
#     EC2_AP_NORTHEAST = 26
#     RUNNING = 0
#     REBOOTING = 1
#     TERMINATED = 2
#     PENDING = 3
#     UNKNOWN = 4
#     def __init__(self, node, original_exception=None):
#     def __str__(self):


# Path: libcloud/common/rackspace.py
import httplib
from urllib2 import urlparse
from libcloud.common.base import ConnectionUserAndKey
from libcloud.compute.types import InvalidCredsError

        self.__host = None
        super(RackspaceBaseConnection, self).__init__(user_id, key, secure=secure)

    def add_default_headers(self, headers):
        headers['X-Auth-Token'] = self.auth_token
        headers['Accept'] = self.accept_format
        return headers

    @property
    def host(self):
        """
        Rackspace uses a separate host for API calls which is only provided
        after an initial authentication request. If we haven't made that
        request yet, do it here. Otherwise, just return the management host.
        """
        if not self.__host:
            # Initial connection used for authentication
            conn = self.conn_classes[self.secure](self.auth_host, self.port[self.secure])
            conn.request(
                method='GET',
                url='/%s' % (AUTH_API_VERSION),
                headers={
                    'X-Auth-User': self.user_id,
                    'X-Auth-Key': self.key
                }
            )

            resp = conn.getresponse()

            if resp.status != httplib.NO_CONTENT:

                raise InvalidCredsError()