libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1467555 - in /libcloud/trunk: CHANGES libcloud/compute/drivers/vcloud.py libcloud/test/compute/test_vcloud.py
Date Sat, 13 Apr 2013 06:14:37 GMT
Author: tomaz
Date: Sat Apr 13 06:14:37 2013
New Revision: 1467555

URL: http://svn.apache.org/r1467555
Log:
Add support for API version 5.1 to the vCloud driver and accept any value
which is a multiple of four for ex_vm_memory kwarg in create_node method.

Contributed by Trevor Powell part of LIBCLOUD-314.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/compute/drivers/vcloud.py
    libcloud/trunk/libcloud/test/compute/test_vcloud.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1467555&r1=1467554&r2=1467555&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Sat Apr 13 06:14:37 2013
@@ -21,6 +21,11 @@ Changes with Apache Libcloud in developm
       from a file.
       [Rudolf J Streif]
 
+    - Add support for API version 5.1 to the vCloud driver and accept any value
+      which is a multiple of four for ex_vm_memory kwarg in create_node method.
+      (LIBCLOUD-314)
+      [Trevor Powell]
+
 Changes with Apache Libcloud 0.12.3:
 
   *) General

Modified: libcloud/trunk/libcloud/compute/drivers/vcloud.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/vcloud.py?rev=1467555&r1=1467554&r2=1467555&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/vcloud.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/vcloud.py Sat Apr 13 06:14:37 2013
@@ -380,6 +380,8 @@ class VCloudNodeDriver(NodeDriver):
                 cls = VCloudNodeDriver
             elif api_version == '1.5':
                 cls = VCloud_1_5_NodeDriver
+            elif api_version == '5.1':
+                cls = VCloud_1_5_NodeDriver
             else:
                 raise NotImplementedError(
                     "No VCloudNodeDriver found for API version %s" %
@@ -1858,3 +1860,15 @@ class VCloud_1_5_NodeDriver(VCloudNodeDr
                    cpu=cpu,
                    memory=memory,
                    storage=storage)
+
+
+class VCloud_5_1_NodeDriver(VCloud_1_5_NodeDriver):
+
+    @staticmethod
+    def _validate_vm_memory(vm_memory):
+        if vm_memory is None:
+            return None
+        elif (vm_memory % 4) != 0:
+            #The vcd 5.1 virtual machine memory size must be a multiple of 4 MB
+            raise ValueError(
+                '%s is not a valid vApp VM memory value' % (vm_memory))

Modified: libcloud/trunk/libcloud/test/compute/test_vcloud.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/compute/test_vcloud.py?rev=1467555&r1=1467554&r2=1467555&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/compute/test_vcloud.py (original)
+++ libcloud/trunk/libcloud/test/compute/test_vcloud.py Sat Apr 13 06:14:37 2013
@@ -271,6 +271,60 @@ class VCloud_1_5_Tests(unittest.TestCase
         self.driver.ex_set_control_access(node, control_access)
 
 
+class VCloud_5_1_Tests(unittest.TestCase, TestCaseMixin):
+
+    def setUp(self):
+        VCloudNodeDriver.connectionCls.host = 'test'
+        VCloudNodeDriver.connectionCls.conn_classes = (None, VCloud_1_5_MockHttp)
+        VCloud_1_5_MockHttp.type = None
+        self.driver = VCloud_1_5_NodeDriver(*VCLOUD_PARAMS, api_version='5.1')
+
+    def _test_create_node_valid_ex_vm_memory(self):
+        # TODO: Hook up the fixture
+        values = [4, 1024, 4096]
+
+        image = self.driver.list_images()[0]
+        size = self.driver.list_sizes()[0]
+
+        for value in values:
+            self.driver.create_node(
+                name='testerpart2',
+                image=image,
+                size=size,
+                vdc='https://services.vcloudexpress.terremark.com/api/v0.8/vdc/224',
+                network='https://services.vcloudexpress.terremark.com/api/v0.8/network/725',
+                cpus=2,
+                ex_vm_memory=value
+            )
+
+    def test_create_node_invalid_ex_vm_memory(self):
+        values = [1, 3, 7]
+
+        image = self.driver.list_images()[0]
+        size = self.driver.list_sizes()[0]
+
+        for value in values:
+            try:
+                self.driver.create_node(
+                    name='testerpart2',
+                    image=image,
+                    size=size,
+                    vdc='https://services.vcloudexpress.terremark.com/api/v0.8/vdc/224',
+                    network='https://services.vcloudexpress.terremark.com/api/v0.8/network/725',
+                    cpus=2,
+                    ex_vm_memory=value
+                )
+            except ValueError:
+               pass
+            else:
+               self.fail('Exception was not thrown')
+
+
+    def test_list_images(self):
+        ret = self.driver.list_images()
+        self.assertEqual('https://vm-vcloud/api/vAppTemplate/vappTemplate-ac1bc027-bf8c-4050-8643-4971f691c158',
ret[0].id)
+
+
 class TerremarkMockHttp(MockHttp):
 
     fixtures = ComputeFileFixtures('terremark')



Mime
View raw message