]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Deal with 501 errors from NVP correctly
authorarmando-migliaccio <amigliaccio@nicira.com>
Thu, 22 Aug 2013 20:12:15 +0000 (13:12 -0700)
committerarmando-migliaccio <amigliaccio@nicira.com>
Thu, 22 Aug 2013 20:12:15 +0000 (13:12 -0700)
This is done by adding the error code to the exception
handlers dictionary as done for other error codes.

Fixes bug #1215583

Change-Id: Ic876c6bccaf94cae626dfc908c4a34dfbcead406

neutron/plugins/nicira/NvpApiClient.py
neutron/tests/unit/nicira/fake_nvpapiclient.py
neutron/tests/unit/nicira/test_nvplib.py

index b7c32e65e20ce64e8628d4885063e7a67a0f81e9..3dcbc13b02b9760d0a9c0bf56ee3bd267ba0406d 100644 (file)
@@ -202,6 +202,7 @@ class NVPApiHelper(client_eventlet.NvpApiClientEventlet):
                    307: zero,
                    400: zero,
                    500: zero,
+                   501: zero,
                    503: zero}
 
 
index 1aa96ccf9f44d03eb276917f16a728e2a8a2c927..2b73d4dc0adfde188195e6101121ac41cacd1381 100644 (file)
@@ -453,7 +453,7 @@ class FakeClient:
         relations = urlparse.parse_qs(parsedurl.query).get('relations')
         response_file = self.FAKE_GET_RESPONSES.get(res_type)
         if not response_file:
-            raise Exception("resource not found")
+            raise NvpApiClient.NvpApiException()
         if 'lport' in res_type or 'nat' in res_type:
             if len(uuids) > 1:
                 return self._show(res_type, response_file, uuids[0],
index 01383f6bb2396d002175821f053041291be4a3e7..2734feb8dda6f4564a682d93ca378a2096838d40 100644 (file)
@@ -1379,6 +1379,14 @@ class TestNvplibClusterManagement(NvplibTestCase):
             self.assertRaises(nvp_exc.MaintenanceInProgress,
                               nvplib.do_request, cluster=self.fake_cluster)
 
+    def test_cluster_method_not_implemetned(self):
+        self.assertRaises(NvpApiClient.NvpApiException,
+                          nvplib.do_request,
+                          nvplib.HTTP_GET,
+                          nvplib._build_uri_path('MY_FAKE_RESOURCE',
+                                                 resource_id='foo'),
+                          cluster=self.fake_cluster)
+
 
 def _nicira_method(method_name, module_name='nvplib'):
     return '%s.%s.%s' % ('neutron.plugins.nicira', module_name, method_name)