libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1479042 - in /libcloud/branches/0.12.x: ./ libcloud/compute/drivers/ libcloud/test/compute/ libcloud/test/compute/fixtures/vcloud_1_5/
Date Sat, 04 May 2013 05:56:46 GMT
Author: tomaz
Date: Sat May  4 05:56:45 2013
New Revision: 1479042

URL: http://svn.apache.org/r1479042
Log:
Backport commit from trunk.

Added:
    libcloud/branches/0.12.x/libcloud/test/compute/fixtures/vcloud_1_5/api_vApp_vapp_8c57a5b6_e61b_48ca_8a78_3b70ee65ef6c.xml
      - copied unchanged from r1479041, libcloud/trunk/libcloud/test/compute/fixtures/vcloud_1_5/api_vApp_vapp_8c57a5b6_e61b_48ca_8a78_3b70ee65ef6c.xml
    libcloud/branches/0.12.x/libcloud/test/compute/fixtures/vcloud_1_5/api_vdc_brokenVdc.xml
      - copied unchanged from r1479041, libcloud/trunk/libcloud/test/compute/fixtures/vcloud_1_5/api_vdc_brokenVdc.xml
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/fixtures/vcloud_1_5/api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0.xml
    libcloud/branches/0.12.x/libcloud/test/compute/test_vcloud.py

Propchange: libcloud/branches/0.12.x/
------------------------------------------------------------------------------
  Merged /libcloud/trunk:r1479041

Modified: libcloud/branches/0.12.x/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/CHANGES?rev=1479042&r1=1479041&r2=1479042&view=diff
==============================================================================
--- libcloud/branches/0.12.x/CHANGES (original)
+++ libcloud/branches/0.12.x/CHANGES Sat May  4 05:56:45 2013
@@ -18,6 +18,9 @@ Changes with Apache Libcloud in deveplom
       (LIBCLOUD-318)
       [Michel Samia]
 
+    - Various improvements and bug-fixes in the VCloud driver. (LIBCLOUD-323)
+      [Michel Samia]
+
  *) Load Balancer
 
     - Add ex_list_current_usage method to the Rackspace driver.

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=1479042&r1=1479041&r2=1479042&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/compute/drivers/vcloud.py (original)
+++ libcloud/branches/0.12.x/libcloud/compute/drivers/vcloud.py Sat May  4 05:56:45 2013
@@ -20,7 +20,6 @@ import sys
 import re
 import base64
 import os
-import urllib
 from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlencode
 from libcloud.utils.py3 import urlparse
@@ -56,7 +55,6 @@ DEFAULT_API_VERSION = '0.8'
 Valid vCloud API v1.5 input values.
 """
 VIRTUAL_CPU_VALS_1_5 = [i for i in range(1, 9)]
-VIRTUAL_MEMORY_VALS_1_5 = [2 ** i for i in range(2, 19)]
 FENCE_MODE_VALS_1_5 = ['bridged', 'isolated', 'natRouted']
 IP_MODE_VALS_1_5 = ['POOL', 'DHCP', 'MANUAL', 'NONE']
 
@@ -590,9 +588,10 @@ class VCloudNodeDriver(NodeDriver):
                 except Exception:
                     # The vApp was probably removed since the previous vDC query, ignore
                     e = sys.exc_info()[1]
-                    if not (e.args[0].tag.endswith('Error') and
+                    if not (isinstance(e.args[0], _ElementInterface) and
+                            e.args[0].tag.endswith('Error') and
                             e.args[0].get('minorErrorCode') == 'ACCESS_TO_RESOURCE_IS_FORBIDDEN'):
-                        raise e
+                        raise
 
         return nodes
 
@@ -1573,7 +1572,7 @@ class VCloud_1_5_NodeDriver(VCloudNodeDr
     def _validate_vm_memory(vm_memory):
         if vm_memory is None:
             return
-        elif vm_memory not in VIRTUAL_MEMORY_VALS_1_5:
+        elif vm_memory not in VIRTUAL_MEMORY_VALS:
             raise ValueError(
                 '%s is not a valid vApp VM memory value' % vm_memory)
 
@@ -1859,15 +1858,18 @@ class VCloud_1_5_NodeDriver(VCloudNodeDr
                     public_ips.append(external_ip.text)
                 elif ip is not None:
                     public_ips.append(ip.text)
+            os_type_elem = vm_elem.find('{http://schemas.dmtf.org/ovf/envelope/1}OperatingSystemSection')
+            if os_type_elem:
+                os_type = os_type_elem.get('{http://www.vmware.com/schema/ovf}osType')
+            else:
+                os_type = None
             vm = {
                 'id': vm_elem.get('href'),
                 'name': vm_elem.get('name'),
                 'state': self.NODE_STATE_MAP[vm_elem.get('status')],
                 'public_ips': public_ips,
                 'private_ips': private_ips,
-                'os_type': vm_elem
-                    .find('{http://schemas.dmtf.org/ovf/envelope/1}OperatingSystemSection')
-                    .get('{http://www.vmware.com/schema/ovf}osType')
+                'os_type': os_type
             }
             vms.append(vm)
 

Modified: libcloud/branches/0.12.x/libcloud/test/compute/fixtures/vcloud_1_5/api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0.xml
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/test/compute/fixtures/vcloud_1_5/api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0.xml?rev=1479042&r1=1479041&r2=1479042&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/test/compute/fixtures/vcloud_1_5/api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0.xml
(original)
+++ libcloud/branches/0.12.x/libcloud/test/compute/fixtures/vcloud_1_5/api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0.xml
Sat May  4 05:56:45 2013
@@ -36,6 +36,7 @@
    <ResourceEntities>
       <ResourceEntity type="application/vnd.vmware.vcloud.vApp+xml" name="testNode" href="https://vm-vcloud/api/vApp/vapp-8c57a5b6-e61b-48ca-8a78-3b70ee65ef6a"/>
       <ResourceEntity type="application/vnd.vmware.vcloud.vApp+xml" name="testNode2" href="https://vm-vcloud/api/vApp/vapp-8c57a5b6-e61b-48ca-8a78-3b70ee65ef6b"/>
+      <ResourceEntity type="application/vnd.vmware.vcloud.vApp+xml" name="testNode3" href="https://vm-vcloud/api/vApp/vapp-8c57a5b6-e61b-48ca-8a78-3b70ee65ef6c"/>
       <ResourceEntity type="application/vnd.vmware.vcloud.vApp+xml" name="deleted-test"
href="https://vm-vcloud/api/vApp/vapp-access-to-resource-forbidden"/>
       <ResourceEntity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="VMTemplate_Master"
href="https://vm-vcloud/api/vAppTemplate/vappTemplate-ac1bc027-bf8c-4050-8643-4971f691c158"/>
    </ResourceEntities>
@@ -53,4 +54,4 @@
    <NetworkQuota>1024</NetworkQuota>
    <VmQuota>150</VmQuota>
    <IsEnabled>true</IsEnabled>
-</Vdc>
\ No newline at end of file
+</Vdc>

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=1479042&r1=1479041&r2=1479042&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 May  4 05:56:45 2013
@@ -21,6 +21,7 @@ from libcloud.utils.py3 import httplib, 
 
 from libcloud.compute.drivers.vcloud import TerremarkDriver, VCloudNodeDriver, Subject
 from libcloud.compute.drivers.vcloud import VCloud_1_5_NodeDriver, ControlAccess
+from libcloud.compute.drivers.vcloud import Vdc
 from libcloud.compute.base import Node, NodeImage
 from libcloud.compute.types import NodeState
 
@@ -241,6 +242,13 @@ class VCloud_1_5_Tests(unittest.TestCase
     def test_ex_list_nodes(self):
         self.assertEqual(len(self.driver.ex_list_nodes()), len(self.driver.list_nodes()))
 
+    def test_ex_list_nodes__masked_exception(self):
+        """
+        Test that we don't mask other exceptions.
+        """
+        brokenVdc = Vdc('/api/vdc/brokenVdc', 'brokenVdc', self.driver)
+        self.assertRaises(AnotherError, self.driver.ex_list_nodes, (brokenVdc))
+
     def test_ex_power_off(self):
         node = Node('https://vm-vcloud/api/vApp/vapp-8c57a5b6-e61b-48ca-8a78-3b70ee65ef6b',
'testNode', NodeState.RUNNING, [], [], self.driver)
         self.driver.ex_power_off_node(node)
@@ -395,6 +403,21 @@ class TerremarkMockHttp(MockHttp):
         return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED])
 
 
+class AnotherErrorMember(Exception):
+    """
+    helper class for the synthetic exception
+    """
+
+    def __init__(self):
+        self.tag = 'Error'
+
+    def get(self, foo):
+        return 'ACCESS_TO_RESOURCE_IS_FORBIDDEN'
+
+class AnotherError(Exception):
+    pass
+
+
 class VCloud_1_5_MockHttp(MockHttp, unittest.TestCase):
 
     fixtures = ComputeFileFixtures('vcloud_1_5')
@@ -427,6 +450,14 @@ class VCloud_1_5_MockHttp(MockHttp, unit
         body = self.fixtures.load('api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0.xml')
         return httplib.OK, body, headers, httplib.responses[httplib.OK]
 
+    def _api_vdc_brokenVdc(self, method, url, body, headers):
+        body = self.fixtures.load('api_vdc_brokenVdc.xml')
+        return httplib.OK, body, headers, httplib.responses[httplib.OK]
+
+    def _api_vApp_vapp_errorRaiser(self, method, url, body, headers):
+        m = AnotherErrorMember()
+        raise AnotherError(m)
+
     def _api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0_action_instantiateVAppTemplate(self,
method, url, body, headers):
         body = self.fixtures.load('api_vdc_3d9ae28c_1de9_4307_8107_9356ff8ba6d0_action_instantiateVAppTemplate.xml')
         return httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED]
@@ -457,6 +488,10 @@ class VCloud_1_5_MockHttp(MockHttp, unit
         body = self.fixtures.load('api_vApp_vapp_8c57a5b6_e61b_48ca_8a78_3b70ee65ef6b.xml')
         return httplib.OK, body, headers, httplib.responses[httplib.OK]
 
+    def _api_vApp_vapp_8c57a5b6_e61b_48ca_8a78_3b70ee65ef6c(self, method, url, body, headers):
+        body = self.fixtures.load('api_vApp_vapp_8c57a5b6_e61b_48ca_8a78_3b70ee65ef6c.xml')
+        return httplib.OK, body, headers, httplib.responses[httplib.OK]
+
     def _api_vApp_vm_dd75d1d3_5b7b_48f0_aff3_69622ab7e045(self, method, url, body, headers):
         body = self.fixtures.load('put_api_vApp_vm_dd75d1d3_5b7b_48f0_aff3_69622ab7e045_guestCustomizationSection.xml')
         return httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED]



Mime
View raw message