You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/11/15 01:25:45 UTC

svn commit: r1201975 - in /libcloud/trunk: CHANGES libcloud/compute/drivers/cloudstack.py libcloud/compute/providers.py libcloud/compute/types.py test/compute/test_cloudstack.py

Author: tomaz
Date: Tue Nov 15 00:25:44 2011
New Revision: 1201975

URL: http://svn.apache.org/viewvc?rev=1201975&view=rev
Log:
Expose CLOUDSTACK provider and allow users to instantiate it. This way it can
also be used with an arbitrary CloudStack provider not just with ninefold.com.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/compute/drivers/cloudstack.py
    libcloud/trunk/libcloud/compute/providers.py
    libcloud/trunk/libcloud/compute/types.py
    libcloud/trunk/test/compute/test_cloudstack.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1201975&r1=1201974&r2=1201975&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Tue Nov 15 00:25:44 2011
@@ -37,6 +37,10 @@ Changes with Apache Libcloud in developm
        empty list ([]), not 'unknown'
        [Tomaz Muraus]
 
+     - Expose 'CLOUDSTACK' provider. This driver can be used with an
+       arbitrary CloudStack installation.
+       [Tomaz Muraus]
+
   *) Storage:
 
      - Update Amazon S3 driver to support a new region - US West 2 (Oregon)

Modified: libcloud/trunk/libcloud/compute/drivers/cloudstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/cloudstack.py?rev=1201975&r1=1201974&r2=1201975&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/cloudstack.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/cloudstack.py Tue Nov 15 00:25:44 2011
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from libcloud.compute.providers import Provider
 from libcloud.common.cloudstack import CloudStackConnection, \
                                        CloudStackDriverMixIn
 from libcloud.compute.base import Node, NodeDriver, NodeImage, NodeLocation, \
@@ -83,7 +84,9 @@ class CloudStackNodeDriver(CloudStackDri
                                 job completion.
     @type async_poll_frequency: C{int}"""
 
+    name = 'CloudStack'
     api_name = 'cloudstack'
+    type = Provider.CLOUDSTACK
 
     NODE_STATE_MAP = {
         'Running': NodeState.RUNNING,
@@ -93,6 +96,23 @@ class CloudStackNodeDriver(CloudStackDri
         'Destroyed': NodeState.TERMINATED
     }
 
+    def __init__(self, key, secret=None, secure=True, host=None,
+                 path=None, port=None, *args, **kwargs):
+        host = host if host else self.host
+
+        if path is not None:
+            self.path = path
+
+        if host is not None:
+            self.host = host
+
+        if (self.type == Provider.CLOUDSTACK) and (not host or not path):
+            raise Exception('When instantiating CloudStack driver directly ' +
+                            'you also need to provide host and path argument')
+
+        NodeDriver.__init__(self, key=key, secret=secret, secure=secure,
+                            host=host, port=port)
+
     def list_images(self, location=None):
         args = {
             'templatefilter': 'executable'

Modified: libcloud/trunk/libcloud/compute/providers.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/providers.py?rev=1201975&r1=1201974&r2=1201975&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/providers.py (original)
+++ libcloud/trunk/libcloud/compute/providers.py Tue Nov 15 00:25:44 2011
@@ -94,7 +94,9 @@ DRIVERS = {
     Provider.NINEFOLD:
         ('libcloud.compute.drivers.ninefold', 'NinefoldNodeDriver'),
     Provider.TERREMARK:
-        ('libcloud.compute.drivers.vcloud', 'TerremarkDriver')
+        ('libcloud.compute.drivers.vcloud', 'TerremarkDriver'),
+    Provider.CLOUDSTACK:
+        ('libcloud.compute.drivers.cloudstack', 'CloudStackNodeDriver')
 }
 
 def get_driver(provider):

Modified: libcloud/trunk/libcloud/compute/types.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/types.py?rev=1201975&r1=1201974&r2=1201975&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/types.py (original)
+++ libcloud/trunk/libcloud/compute/types.py Tue Nov 15 00:25:44 2011
@@ -57,6 +57,7 @@ class Provider(object):
     @cvar NINEFOLD: Ninefold
     @cvar TERREMARK: Terremark
     @cvar: EC2_US_WEST_OREGON: Amazon AWS US West 2 (Oregon)
+    @cvar CLOUDSTACK: CloudStack
     """
     DUMMY = 0
     EC2 = 1  # deprecated name
@@ -97,6 +98,7 @@ class Provider(object):
     NINEFOLD = 34
     TERREMARK = 35
     EC2_US_WEST_OREGON = 36
+    CLOUDSTACK = 37
 
 class NodeState(object):
     """

Modified: libcloud/trunk/test/compute/test_cloudstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_cloudstack.py?rev=1201975&r1=1201974&r2=1201975&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_cloudstack.py (original)
+++ libcloud/trunk/test/compute/test_cloudstack.py Tue Nov 15 00:25:44 2011
@@ -25,7 +25,9 @@ class CloudStackNodeDriverTest(unittest.
     def setUp(self):
         CloudStackNodeDriver.connectionCls.conn_classes = \
             (None, CloudStackMockHttp)
-        self.driver = CloudStackNodeDriver('apikey', 'secret')
+        self.driver = CloudStackNodeDriver('apikey', 'secret',
+                                           path='/test/path',
+                                           host='api.dummy.com')
         self.driver.path = '/test/path'
         self.driver.type = -1
         CloudStackMockHttp.fixture_tag = 'default'