]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Make the NetAppISCSIDriver._is_clone_done() method able to handle
authorBen Swartzlander <bswartz@netapp.com>
Fri, 21 Dec 2012 05:24:46 +0000 (00:24 -0500)
committerBen Swartzlander <bswartz@netapp.com>
Fri, 21 Dec 2012 05:24:46 +0000 (00:24 -0500)
empty responses. Add unit tests to exercise this case.

bug 1090168

Change-Id: Ia51a73b8ebead7a0f3be9202794ca8549bdf3e5b

cinder/tests/test_netapp.py
cinder/volume/drivers/netapp.py

index 93aba26053a2e0fac464b93227fd847c86e65971..21b39e4f3d6ad46f8b235c499cc4e52a44047dc2 100644 (file)
@@ -822,7 +822,25 @@ class FakeDfmServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             names = body.xpath('na:ApiProxy/na:Request/na:Name',
                                namespaces=nsmap)
             proxy = names[0].text
-            if 'igroup-list-info' == proxy:
+            if 'clone-list-status' == proxy:
+                op_elem = body.xpath('na:ApiProxy/na:Request/na:Args/'
+                                     'clone-id/clone-id-info/clone-op-id',
+                                     namespaces=nsmap)
+                proxy_body = """<status>
+                        <ops-info>
+                            <clone-state>completed</clone-state>
+                        </ops-info>
+                    </status>"""
+                if '0' == op_elem[0].text:
+                    proxy_body = ''
+            elif 'clone-start' == proxy:
+                proxy_body = """<clone-id>
+                        <clone-id-info>
+                            <clone-op-id>1</clone-op-id>
+                            <volume-uuid>xxx</volume-uuid>
+                        </clone-id-info>
+                    </clone-id>"""
+            elif 'igroup-list-info' == proxy:
                 igroup = 'openstack-iqn.1993-08.org.debian:01:23456789'
                 initiator = 'iqn.1993-08.org.debian:01:23456789'
                 proxy_body = """<initiator-groups>
@@ -988,6 +1006,15 @@ class NetAppDriverTestCase(test.TestCase):
         self.driver.terminate_connection(volume, connector)
         self.driver._remove_destroy(self.VOLUME_NAME, self.PROJECT_ID)
 
+    def test_clone(self):
+        self.driver._discover_luns()
+        self.driver._clone_lun(0, '/vol/vol/qtree/src', '/vol/vol/qtree/dst',
+                               False)
+
+    def test_clone_fail(self):
+        self.driver._discover_luns()
+        self.driver._is_clone_done(0, '0', 'xxx')
+
 
 WSDL_HEADER_CMODE = """<?xml version="1.0" encoding="UTF-8"?>
 <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
index 387b2019cf3111250660dbfc864c2433770f0d02..e759e0d42893d52acc2ed79fe094ccc809860bfc 100644 (file)
@@ -836,6 +836,8 @@ class NetAppISCSIDriver(driver.ISCSIDriver):
         response = self.client.service.ApiProxy(Target=host_id,
                                                 Request=request)
         self._check_fail(request, response)
+        if isinstance(response.Results, text.Text):
+            return False
         status = response.Results['status']
         if self._api_elem_is_empty(status):
             return False