libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1392108 - in /libcloud/trunk/libcloud: compute/drivers/rackspace.py compute/drivers/rackspacenova.py compute/providers.py compute/types.py test/compute/test_deployment.py test/compute/test_rackspace.py test/compute/test_rackspacenova.py
Date Sun, 30 Sep 2012 21:14:05 GMT
Author: tomaz
Date: Sun Sep 30 21:14:04 2012
New Revision: 1392108

URL: http://svn.apache.org/viewvc?rev=1392108&view=rev
Log:
Start working on improving Rackspace drivers and merge 6 classes and constants
into 2.

Modified:
    libcloud/trunk/libcloud/compute/drivers/rackspace.py
    libcloud/trunk/libcloud/compute/drivers/rackspacenova.py
    libcloud/trunk/libcloud/compute/providers.py
    libcloud/trunk/libcloud/compute/types.py
    libcloud/trunk/libcloud/test/compute/test_deployment.py
    libcloud/trunk/libcloud/test/compute/test_rackspace.py
    libcloud/trunk/libcloud/test/compute/test_rackspacenova.py

Modified: libcloud/trunk/libcloud/compute/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/rackspace.py?rev=1392108&r1=1392107&r2=1392108&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/rackspace.py Sun Sep 30 21:14:04 2012
@@ -24,9 +24,9 @@ from libcloud.common.rackspace import (
     AUTH_URL_US, AUTH_URL_UK)
 
 
-class RackspaceConnection(OpenStack_1_0_Connection):
+class RackspaceFirstGenConnection(OpenStack_1_0_Connection):
     """
-    Connection class for the Rackspace driver
+    Connection class for the Rackspace first-gen driver.
     """
 
     responseCls = OpenStack_1_0_Response
@@ -34,7 +34,6 @@ class RackspaceConnection(OpenStack_1_0_
     XML_NAMESPACE = 'http://docs.rackspacecloud.com/servers/api/v1.0'
 
     def get_endpoint(self):
-
         ep = {}
         if '2.0' in self._auth_version:
             ep = self.service_catalog.get_endpoint(service_type='compute',
@@ -48,37 +47,40 @@ class RackspaceConnection(OpenStack_1_0_
         raise LibcloudError('Could not find specified endpoint')
 
 
-class RackspaceNodeDriver(OpenStack_1_0_NodeDriver):
-    name = 'Rackspace'
-    website = 'http://www.rackspace.com/'
-    connectionCls = RackspaceConnection
-    type = Provider.RACKSPACE
+class RackspaceFirstGenNodeDriver(OpenStack_1_0_NodeDriver):
+    name = 'Rackspace Cloud'
+    website = 'http://www.rackspace.com'
+    connectionCls = RackspaceFirstGenConnection
+    type = Provider.RACKSPACE_FIRST_GEN
     api_name = 'rackspace'
 
+    def __init__(self, key, secret=None, secure=True, host=None, port=None,
+                 region='us', **kwargs):
+        if region not in ['us', 'uk']:
+            raise ValueError('Invalid region: %s' % (region))
+
+        if region == 'us':
+            self.connectionCls.auth_url = AUTH_URL_US
+        elif region == 'uk':
+            self.connectionCls.auth_url = AUTH_URL_UK
+
+        self.region = region
+
+        super(RackspaceFirstGenNodeDriver, self).__init__(key=key, secret=secret,
+                       secure=secure, host=host, port=port, **kwargs)
+
     def list_locations(self):
-        """Lists available locations
+        """
+        Lists available locations
 
         Locations cannot be set or retrieved via the API, but currently
         there are two locations, DFW and ORD.
 
         @inherits: L{OpenStack_1_0_NodeDriver.list_locations}
         """
-        return [NodeLocation(0, "Rackspace DFW1/ORD1", 'US', self)]
-
-
-class RackspaceUKConnection(RackspaceConnection):
-    """
-    Connection class for the Rackspace UK driver
-    """
-    auth_url = AUTH_URL_UK
+        if self.region == 'us':
+            locations = [NodeLocation(0, "Rackspace DFW1/ORD1", 'US', self)]
+        elif self.region == 'uk':
+            locations = [NodeLocation(0, 'Rackspace UK London', 'UK', self)]
 
-
-class RackspaceUKNodeDriver(RackspaceNodeDriver):
-    """Driver for Rackspace in the UK (London)
-    """
-
-    name = 'Rackspace (UK)'
-    connectionCls = RackspaceUKConnection
-
-    def list_locations(self):
-        return [NodeLocation(0, 'Rackspace UK London', 'UK', self)]
+        return locations

Modified: libcloud/trunk/libcloud/compute/drivers/rackspacenova.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/rackspacenova.py?rev=1392108&r1=1392107&r2=1392108&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/rackspacenova.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/rackspacenova.py Sun Sep 30 21:14:04 2012
@@ -21,13 +21,35 @@ from libcloud.compute.drivers.openstack 
 from libcloud.common.types import LibcloudError
 
 
-class RackspaceNovaConnection(OpenStack_1_1_Connection):
+ENDPOINT_ARGS_MAP = {
+    'us': {
+        'dfw':  {'service_type': 'compute',
+                  'name': 'cloudServersOpenStack',
+                  'region': 'DFW'},
+        'ord':  {'service_type': 'compute',
+                  'name': 'cloudServersOpenStack',
+                  'region': 'ORD'}
+    },
+    'uk': {
+        'default':  {'service_type': 'compute',
+                     'name': 'cloudServersOpenStack',
+                     'region': 'LON'}
+    },
+    'beta': {
+        'dfw':  {'service_type': 'compute',
+                 'name': 'cloudServersPreprod',
+                 'region': 'DFW'}
+    }
+}
+
+
+class RackspaceConnection(OpenStack_1_1_Connection):
     get_endpoint_args = {}
 
     def get_endpoint(self):
         if not self.get_endpoint_args:
             raise LibcloudError(
-                'RackspaceNovaConnection must have get_endpoint_args set')
+                'RackspaceConnection must have get_endpoint_args set')
 
         # Only support auth 2.0_*
         if '2.0' in self._auth_version:
@@ -44,61 +66,28 @@ class RackspaceNovaConnection(OpenStack_
             raise LibcloudError('Could not find specified endpoint')
 
 
-class RackspaceNovaBetaConnection(RackspaceNovaConnection):
-
-    get_endpoint_args = {'service_type': 'compute',
-                         'name': 'cloudServersPreprod',
-                         'region': 'DFW'}
-
-
-class RackspaceNovaDfwConnection(RackspaceNovaConnection):
-
-    get_endpoint_args = {'service_type': 'compute',
-                         'name': 'cloudServersOpenStack',
-                         'region': 'DFW'}
-
-
-class RackspaceNovaLonConnection(RackspaceNovaConnection):
-
-    get_endpoint_args = {'service_type': 'compute',
-                         'name': 'cloudServersOpenStack',
-                         'region': 'LON'}
-
-
-class RackspaceNovaDfwNodeDriver(OpenStack_1_1_NodeDriver):
-    name = 'RackspaceNovadfw'
-    website = 'http://www.rackspace.com/'
-    connectionCls = RackspaceNovaDfwConnection
-    type = Provider.RACKSPACE_NOVA_DFW
-    api_name = 'rackspacenovaus'
-
-
-class RackspaceNovaOrdConnection(RackspaceNovaConnection):
-
-    get_endpoint_args = {'service_type': 'compute',
-                         'name': 'cloudServersOpenStack',
-                         'region': 'ORD'}
-
-
-class RackspaceNovaOrdNodeDriver(OpenStack_1_1_NodeDriver):
-    name = 'RackspaceNovaord'
-    website = 'http://www.rackspace.com/'
-    connectionCls = RackspaceNovaOrdConnection
-    type = Provider.RACKSPACE_NOVA_ORD
-    api_name = 'rackspacenovaus'
-
+class RackspaceNodeDriver(OpenStack_1_1_NodeDriver):
+    name = 'Rackspace Cloud'
+    website = 'http://www.rackspace.com'
+    connectionCls = RackspaceConnection
+    type = Provider.RACKSPACE
+    api_name = None # todo
+
+    def __init__(self, key, secret=None, secure=True, host=None, port=None,
+                 region='us', datacenter='dfw', **kwargs):
+        if region not in ['us', 'uk']:
+            raise ValueError('Invalid region: %s' % (region))
+
+        if region == 'us' and datacenter not in ['dfw', 'ord']:
+            raise ValueError('Invalid datacenter: %s' % (datacenter))
+        elif region in ['uk']:
+            datacenter = 'default'
 
-class RackspaceNovaLonNodeDriver(OpenStack_1_1_NodeDriver):
-    name = 'RackspaceNovalon'
-    website = 'http://www.rackspace.com/'
-    connectionCls = RackspaceNovaLonConnection
-    type = Provider.RACKSPACE_NOVA_LON
-    api_name = 'rackspacenovauk'
+        self.connectionCls.get_endpoint_args = \
+                ENDPOINT_ARGS_MAP[region][datacenter]
 
+        self.region = region
+        self.datacenter = datacenter
 
-class RackspaceNovaBetaNodeDriver(OpenStack_1_1_NodeDriver):
-    name = 'RackspaceNovaBeta'
-    website = 'http://www.rackspace.com/'
-    connectionCls = RackspaceNovaBetaConnection
-    type = Provider.RACKSPACE_NOVA_BETA
-    api_name = 'rackspacenovabeta'
+        super(RackspaceNodeDriver, self).__init__(key=key, secret=secret,
+                       secure=secure, host=host, port=port, **kwargs)

Modified: libcloud/trunk/libcloud/compute/providers.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/providers.py?rev=1392108&r1=1392107&r2=1392108&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/providers.py (original)
+++ libcloud/trunk/libcloud/compute/providers.py Sun Sep 30 21:14:04 2012
@@ -64,9 +64,9 @@ DRIVERS = {
     Provider.GOGRID:
         ('libcloud.compute.drivers.gogrid', 'GoGridNodeDriver'),
     Provider.RACKSPACE:
-        ('libcloud.compute.drivers.rackspace', 'RackspaceNodeDriver'),
-    Provider.RACKSPACE_UK:
-        ('libcloud.compute.drivers.rackspace', 'RackspaceUKNodeDriver'),
+        ('libcloud.compute.drivers.rackspacenova', 'RackspaceNodeDriver'),
+    Provider.RACKSPACE_FIRST_GEN:
+        ('libcloud.compute.drivers.rackspace', 'RackspaceFirstGenNodeDriver'),
     Provider.SLICEHOST:
         ('libcloud.compute.drivers.slicehost', 'SlicehostNodeDriver'),
     Provider.VPSNET:
@@ -107,14 +107,6 @@ DRIVERS = {
         ('libcloud.compute.drivers.vcloud', 'TerremarkDriver'),
     Provider.CLOUDSTACK:
         ('libcloud.compute.drivers.cloudstack', 'CloudStackNodeDriver'),
-    Provider.RACKSPACE_NOVA_BETA:
-        ('libcloud.compute.drivers.rackspacenova', 'RackspaceNovaBetaNodeDriver'),
-    Provider.RACKSPACE_NOVA_DFW:
-        ('libcloud.compute.drivers.rackspacenova', 'RackspaceNovaDfwNodeDriver'),
-    Provider.RACKSPACE_NOVA_ORD:
-        ('libcloud.compute.drivers.rackspacenova', 'RackspaceNovaOrdNodeDriver'),
-    Provider.RACKSPACE_NOVA_LON:
-        ('libcloud.compute.drivers.rackspacenova', 'RackspaceNovaLonNodeDriver'),
     Provider.LIBVIRT:
         ('libcloud.compute.drivers.libvirt_driver', 'LibvirtNodeDriver'),
     Provider.JOYENT:

Modified: libcloud/trunk/libcloud/compute/types.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/types.py?rev=1392108&r1=1392107&r2=1392108&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/types.py (original)
+++ libcloud/trunk/libcloud/compute/types.py Sun Sep 30 21:14:04 2012
@@ -40,8 +40,8 @@ class Provider(object):
     @cvar EC2_US_EAST: Amazon AWS US N. Virgina
     @cvar EC2_US_WEST: Amazon AWS US N. California
     @cvar EC2_EU_WEST: Amazon AWS EU Ireland
-    @cvar RACKSPACE: Rackspace Cloud Servers
-    @cvar RACKSPACE_UK: Rackspace UK Cloud Servers
+    @cvar RACKSPACE: Rackspace next-gen OpenStack based Cloud Servers
+    @cvar RACKSPACE_FIRST_GEN: Rackspace First Gen Cloud Servers
     @cvar SLICEHOST: Slicehost.com
     @cvar GOGRID: GoGrid
     @cvar VPSNET: VPS.net
@@ -61,10 +61,6 @@ class Provider(object):
     @cvar EC2_US_WEST_OREGON: Amazon AWS US West 2 (Oregon)
     @cvar CLOUDSTACK: CloudStack
     @cvar CLOUDSIGMA_US: CloudSigma US Las Vegas
-    @cvar RACKSPACE_NOVA_BETA: Rackspace Nova Private Beta (ORD)
-    @cvar RACKSPACE_NOVA_DFW: Rackspace Nova Private DFW (DFW)
-    @cvar RACKSPACE_NOVA_ORD: Rackspace Nova Private ORD (ORD)
-    @cvar RACKSPACE_NOVA_LON: Rackspace Nova Private LON (LON)
     @cvar LIBVIRT: Libvirt driver
     @cvar JOYENT: Joyent driver
     @cvar VCL: VCL driver
@@ -96,7 +92,6 @@ class Provider(object):
     ELASTICHOSTS_UK2 = 20
     ELASTICHOSTS_US1 = 21
     EC2_AP_SOUTHEAST = 22
-    RACKSPACE_UK = 23
     BRIGHTBOX = 24
     CLOUDSIGMA = 25
     EC2_AP_NORTHEAST = 26
@@ -113,17 +108,14 @@ class Provider(object):
     CLOUDSTACK = 37
     CLOUDSIGMA_US = 38
     EC2_SA_EAST = 39
-    RACKSPACE_NOVA_BETA = 40
-    RACKSPACE_NOVA_DFW = 41
     LIBVIRT = 42
     ELASTICHOSTS_US2 = 43
     ELASTICHOSTS_CA1 = 44
     JOYENT = 45
     VCL = 46
     KTUCLOUD = 47
-    RACKSPACE_NOVA_LON = 48
     GRIDSPOT = 49
-    RACKSPACE_NOVA_ORD = 50
+    RACKSPACE_FIRST_GEN = 51
 
 
 class NodeState(object):

Modified: libcloud/trunk/libcloud/test/compute/test_deployment.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_deployment.py?rev=1392108&r1=1392107&r2=1392108&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_deployment.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_deployment.py Sun Sep 30 21:14:04 2012
@@ -28,7 +28,7 @@ from libcloud.compute.deployment import 
 from libcloud.compute.base import Node
 from libcloud.compute.types import NodeState, DeploymentError, LibcloudError
 from libcloud.compute.ssh import BaseSSHClient
-from libcloud.compute.drivers.rackspace import RackspaceNodeDriver as Rackspace
+from libcloud.compute.drivers.rackspace import RackspaceFirstGenNodeDriver as Rackspace
 
 from libcloud.test import MockHttp, XML_HEADERS
 from libcloud.test.file_fixtures import ComputeFileFixtures, OpenStackFixtures

Modified: libcloud/trunk/libcloud/test/compute/test_rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_rackspace.py?rev=1392108&r1=1392107&r2=1392108&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_rackspace.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_rackspace.py Sun Sep 30 21:14:04 2012
@@ -15,19 +15,20 @@
 import sys
 import unittest
 
-from libcloud.compute.drivers.rackspace import RackspaceNodeDriver
+from libcloud.compute.drivers.rackspace import RackspaceFirstGenNodeDriver
 from libcloud.test.compute.test_openstack import OpenStack_1_0_Tests
 
 from libcloud.test.secrets import RACKSPACE_PARAMS
 
 
-class RackspaceTests(OpenStack_1_0_Tests):
+class RackspaceusFirstGenUsTests(OpenStack_1_0_Tests):
     should_list_locations = True
     should_have_pricing = True
 
-    driver_klass = RackspaceNodeDriver
-    driver_type = RackspaceNodeDriver
+    driver_klass = RackspaceFirstGenNodeDriver
+    driver_type = RackspaceFirstGenNodeDriver
     driver_args = RACKSPACE_PARAMS
+    driver_kwargs = {'region': 'us'}
 
     def test_list_sizes_pricing(self):
         sizes = self.driver.list_sizes()
@@ -35,5 +36,22 @@ class RackspaceTests(OpenStack_1_0_Tests
         for size in sizes:
             self.assertTrue(size.price > 0)
 
+
+class RackspaceusFirstGenUkTests(OpenStack_1_0_Tests):
+    should_list_locations = True
+    should_have_pricing = True
+
+    driver_klass = RackspaceFirstGenNodeDriver
+    driver_type = RackspaceFirstGenNodeDriver
+    driver_args = RACKSPACE_PARAMS
+    driver_kwargs = {'region': 'uk'}
+
+    def test_list_sizes_pricing(self):
+        sizes = self.driver.list_sizes()
+
+        for size in sizes:
+            self.assertTrue(size.price > 0)
+
+
 if __name__ == '__main__':
     sys.exit(unittest.main())

Modified: libcloud/trunk/libcloud/test/compute/test_rackspacenova.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_rackspacenova.py?rev=1392108&r1=1392107&r2=1392108&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_rackspacenova.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_rackspacenova.py Sun Sep 30 21:14:04 2012
@@ -17,10 +17,7 @@ import unittest
 
 from libcloud.utils.py3 import method_type
 from libcloud.utils.py3 import httplib
-from libcloud.compute.drivers.rackspacenova import RackspaceNovaBetaNodeDriver, \
-                                                   RackspaceNovaDfwNodeDriver, \
-                                                   RackspaceNovaOrdNodeDriver, \
-                                                   RackspaceNovaLonNodeDriver
+from libcloud.compute.drivers.rackspacenova import RackspaceNodeDriver
 from libcloud.test.compute.test_openstack import OpenStack_1_1_Tests, OpenStack_1_1_MockHttp
 from libcloud.pricing import clear_pricing_data
 
@@ -49,12 +46,13 @@ class RackspaceNovaLonMockHttp(Rackspace
         return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
 
 
+"""
 class RackspaceNovaBetaTests(OpenStack_1_1_Tests):
 
-    driver_klass = RackspaceNovaBetaNodeDriver
-    driver_type = RackspaceNovaBetaNodeDriver
-    driver_args = RACKSPACE_NOVA_PARAMS + ('1.1',)
-    driver_kwargs = {'ex_force_auth_version': '2.0'}
+    driver_klass = RackspaceNodeDriver
+    driver_type = RackspaceNodeDriver
+    driver_args = RACKSPACE_NOVA_PARAMS
+    driver_kwargs = {'region': 'beta', 'ex_force_auth_version': '2.0'}
 
     @classmethod
     def create_driver(self):
@@ -71,14 +69,15 @@ class RackspaceNovaBetaTests(OpenStack_1
 
     def test_service_catalog(self):
         self.assertEqual('https://preprod.dfw.servers.api.rackspacecloud.com/v2/1337', self.driver.connection.get_endpoint())
+"""
 
 
 class RackspaceNovaDfwTests(OpenStack_1_1_Tests):
 
-    driver_klass = RackspaceNovaDfwNodeDriver
-    driver_type = RackspaceNovaDfwNodeDriver
-    driver_args = RACKSPACE_NOVA_PARAMS + ('1.1',)
-    driver_kwargs = {'ex_force_auth_version': '2.0'}
+    driver_klass = RackspaceNodeDriver
+    driver_type = RackspaceNodeDriver
+    driver_args = RACKSPACE_NOVA_PARAMS
+    driver_kwargs = {'region': 'us', 'datacenter': 'dfw', 'ex_force_auth_version': '2.0'}
 
     @classmethod
     def create_driver(self):
@@ -99,10 +98,10 @@ class RackspaceNovaDfwTests(OpenStack_1_
 
 class RackspaceNovaOrdTests(OpenStack_1_1_Tests):
 
-    driver_klass = RackspaceNovaOrdNodeDriver
-    driver_type = RackspaceNovaOrdNodeDriver
-    driver_args = RACKSPACE_NOVA_PARAMS + ('1.1',)
-    driver_kwargs = {'ex_force_auth_version': '2.0'}
+    driver_klass = RackspaceNodeDriver
+    driver_type = RackspaceNodeDriver
+    driver_args = RACKSPACE_NOVA_PARAMS
+    driver_kwargs = {'region': 'us', 'datacenter': 'ord', 'ex_force_auth_version': '2.0'}
 
     @classmethod
     def create_driver(self):
@@ -123,10 +122,10 @@ class RackspaceNovaOrdTests(OpenStack_1_
 
 class RackspaceNovaLonTests(OpenStack_1_1_Tests):
 
-    driver_klass = RackspaceNovaLonNodeDriver
-    driver_type = RackspaceNovaLonNodeDriver
-    driver_args = RACKSPACE_NOVA_PARAMS + ('1.1',)
-    driver_kwargs = {'ex_force_auth_version': '2.0'}
+    driver_klass = RackspaceNodeDriver
+    driver_type = RackspaceNodeDriver
+    driver_args = RACKSPACE_NOVA_PARAMS
+    driver_kwargs = {'region': 'uk', 'datacenter': 'ord', 'ex_force_auth_version': '2.0'}
 
     @classmethod
     def create_driver(self):



Mime
View raw message