libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1467703 - in /libcloud/branches/0.12.x: ./ CHANGES libcloud/compute/drivers/vcloud.py libcloud/test/compute/test_linode.py libcloud/test/compute/test_ssh_client.py libcloud/test/compute/test_vcloud.py
Date Sat, 13 Apr 2013 20:45:23 GMT
Author: tomaz
Date: Sat Apr 13 20:45:23 2013
New Revision: 1467703

URL: http://svn.apache.org/r1467703
Log:
Backport commits from trunk.

Modified:
    libcloud/branches/0.12.x/   (props changed)
    libcloud/branches/0.12.x/CHANGES
    libcloud/branches/0.12.x/libcloud/compute/drivers/vcloud.py
    libcloud/branches/0.12.x/libcloud/test/compute/test_linode.py
    libcloud/branches/0.12.x/libcloud/test/compute/test_ssh_client.py
    libcloud/branches/0.12.x/libcloud/test/compute/test_vcloud.py

Propchange: libcloud/branches/0.12.x/
------------------------------------------------------------------------------
  Merged /libcloud/trunk:r1461703-1462533,1462535-1462560,1462562-1467702

Modified: libcloud/branches/0.12.x/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/CHANGES?rev=1467703&r1=1467702&r2=1467703&view=diff
==============================================================================
--- libcloud/branches/0.12.x/CHANGES (original)
+++ libcloud/branches/0.12.x/CHANGES Sat Apr 13 20:45:23 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/branches/0.12.x/libcloud/compute/drivers/vcloud.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/compute/drivers/vcloud.py?rev=1467703&r1=1467702&r2=1467703&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/compute/drivers/vcloud.py (original)
+++ libcloud/branches/0.12.x/libcloud/compute/drivers/vcloud.py Sat Apr 13 20:45:23 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/branches/0.12.x/libcloud/test/compute/test_linode.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/test/compute/test_linode.py?rev=1467703&r1=1467702&r2=1467703&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/test/compute/test_linode.py (original)
+++ libcloud/branches/0.12.x/libcloud/test/compute/test_linode.py Sat Apr 13 20:45:23 2013
@@ -41,6 +41,7 @@ class LinodeTest(unittest.TestCase, Test
         node = nodes[0]
         self.assertEqual(node.id, "8098")
         self.assertEqual(node.name, 'api-node3')
+        self.assertEqual(node.extra['PLANID'], '1')
         self.assertTrue('75.127.96.245' in node.public_ips)
         self.assertEqual(node.private_ips, [])
 
@@ -97,7 +98,7 @@ class LinodeMockHttp(MockHttp):
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _avail_linodeplans(self, method, url, body, headers):
-        body = '{"ERRORARRAY":[],"ACTION":"avail.linodeplans","DATA":[{"AVAIL":{"2":27,"3":0,"4":0,"6":0},"DISK":16,"PRICE":19.95,"PLANID":1,"LABEL":"Linode
360","RAM":360,"XFER":200},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":24,"PRICE":29.95,"PLANID":2,"LABEL":"Linode
540","RAM":540,"XFER":300},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":32,"PRICE":39.95,"PLANID":3,"LABEL":"Linode
720","RAM":720,"XFER":400},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":48,"PRICE":59.95,"PLANID":4,"LABEL":"Linode
1080","RAM":1080,"XFER":600},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":64,"PRICE":79.95,"PLANID":5,"LABEL":"Linode
1440","RAM":1440,"XFER":800},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":128,"PRICE":159.95,"PLANID":6,"LABEL":"Linode
2880","RAM":2880,"XFER":1600},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":256,"PRICE":319.95,"PLANID":7,"LABEL":"Linode
5760","RAM":5760,"XFER":2000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":384,"PRICE":479.95,"PLANID":8,"LABEL":"Linode
8640","RAM":8640,"XFER":2
 000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":512,"PRICE":639.95,"PLANID":9,"LABEL":"Linode
11520","RAM":11520,"XFER":2000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":640,"PRICE":799.95,"PLANID":10,"LABEL":"Linode
14400","RAM":14400,"XFER":2000}]}'
+        body = '{"ERRORARRAY":[],"ACTION":"avail.linodeplans","DATA":[{"AVAIL":{"2":27,"3":0,"4":0,"6":0},"DISK":16,"PRICE":19.95,"PLANID":1,"LABEL":"Linode
360","RAM":360,"XFER":200},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":24,"PRICE":29.95,"PLANID":2,"LABEL":"Linode
512","RAM":512,"XFER":300},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":32,"PRICE":39.95,"PLANID":3,"LABEL":"Linode
720","RAM":720,"XFER":400},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":48,"PRICE":59.95,"PLANID":4,"LABEL":"Linode
1080","RAM":1080,"XFER":600},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":64,"PRICE":79.95,"PLANID":5,"LABEL":"Linode
1440","RAM":1440,"XFER":800},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":128,"PRICE":159.95,"PLANID":6,"LABEL":"Linode
2880","RAM":2880,"XFER":1600},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":256,"PRICE":319.95,"PLANID":7,"LABEL":"Linode
5760","RAM":5760,"XFER":2000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":384,"PRICE":479.95,"PLANID":8,"LABEL":"Linode
8640","RAM":8640,"XFER":2
 000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":512,"PRICE":639.95,"PLANID":9,"LABEL":"Linode
11520","RAM":11520,"XFER":2000},{"AVAIL":{"2":0,"3":0,"4":0,"6":0},"DISK":640,"PRICE":799.95,"PLANID":10,"LABEL":"Linode
14400","RAM":14400,"XFER":2000}]}'
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _avail_distributions(self, method, url, body, headers):
@@ -141,7 +142,7 @@ class LinodeMockHttp(MockHttp):
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _linode_list(self, method, url, body, headers):
-        body = '{"ACTION": "linode.list", "DATA": [{"ALERT_DISKIO_ENABLED": 1, "BACKUPWEEKLYDAY":
0, "LABEL": "api-node3", "DATACENTERID": 5, "ALERT_BWOUT_ENABLED": 1, "ALERT_CPU_THRESHOLD":
10, "TOTALHD": 100, "ALERT_BWQUOTA_THRESHOLD": 81, "ALERT_BWQUOTA_ENABLED": 1, "TOTALXFER":
200, "STATUS": 2, "ALERT_BWIN_ENABLED": 1, "ALERT_BWIN_THRESHOLD": 5, "ALERT_DISKIO_THRESHOLD":
200, "WATCHDOG": 1, "LINODEID": 8098, "BACKUPWINDOW": 1, "TOTALRAM": 540, "LPM_DISPLAYGROUP":
"", "ALERT_BWOUT_THRESHOLD": 5, "BACKUPSENABLED": 1, "ALERT_CPU_ENABLED": 1}], "ERRORARRAY":
[]}'
+        body = '{"ACTION": "linode.list", "DATA": [{"ALERT_DISKIO_ENABLED": 1, "BACKUPWEEKLYDAY":
0, "LABEL": "api-node3", "DATACENTERID": 5, "ALERT_BWOUT_ENABLED": 1, "ALERT_CPU_THRESHOLD":
10, "TOTALHD": 100, "ALERT_BWQUOTA_THRESHOLD": 81, "ALERT_BWQUOTA_ENABLED": 1, "TOTALXFER":
200, "STATUS": 2, "ALERT_BWIN_ENABLED": 1, "ALERT_BWIN_THRESHOLD": 5, "ALERT_DISKIO_THRESHOLD":
200, "WATCHDOG": 1, "LINODEID": 8098, "BACKUPWINDOW": 1, "TOTALRAM": 512, "LPM_DISPLAYGROUP":
"", "ALERT_BWOUT_THRESHOLD": 5, "BACKUPSENABLED": 1, "ALERT_CPU_ENABLED": 1}], "ERRORARRAY":
[]}'
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
     def _linode_ip_list(self, method, url, body, headers):

Modified: libcloud/branches/0.12.x/libcloud/test/compute/test_ssh_client.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/test/compute/test_ssh_client.py?rev=1467703&r1=1467702&r2=1467703&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/test/compute/test_ssh_client.py (original)
+++ libcloud/branches/0.12.x/libcloud/test/compute/test_ssh_client.py Sat Apr 13 20:45:23
2013
@@ -15,6 +15,7 @@
 # limitations under the License.
 
 from __future__ import absolute_import
+from __future__ import with_statement
 
 import sys
 import unittest

Modified: libcloud/branches/0.12.x/libcloud/test/compute/test_vcloud.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/test/compute/test_vcloud.py?rev=1467703&r1=1467702&r2=1467703&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/test/compute/test_vcloud.py (original)
+++ libcloud/branches/0.12.x/libcloud/test/compute/test_vcloud.py Sat Apr 13 20:45:23 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