Raise a new exception NotImplemented for HTTP501

In _error_checker(), both HTTP500 and 501 are converted to the same
exception ServerFault. In addition, some method which extracts error
message raises a specific exception IdentityError without considering
HTTP code.
This patch adds a new exception NotImplemented and uses it for HTTP501
so that we can know which error response is returned from a server.

Change-Id: Ic8fc216377942619f11a2462b79d0597071ac294
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 576fc26..c25aa8d 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -539,15 +539,17 @@
                             message = resp_body['cloudServersFault']['message']
                         elif 'computeFault' in resp_body:
                             message = resp_body['computeFault']['message']
-                        elif 'error' in resp_body:  # Keystone errors
+                        elif 'error' in resp_body:
                             message = resp_body['error']['message']
-                            raise exceptions.IdentityError(message)
                         elif 'message' in resp_body:
                             message = resp_body['message']
                     else:
                         message = resp_body
 
-            raise exceptions.ServerFault(message)
+            if resp.status == 501:
+                raise exceptions.NotImplemented(message)
+            else:
+                raise exceptions.ServerFault(message)
 
         if resp.status >= 400:
             raise exceptions.UnexpectedResponseCode(str(resp.status))
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 213d5de..9b2b4d4 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -152,6 +152,10 @@
     message = "Got server fault"
 
 
+class NotImplemented(RestClientException):
+    message = "Got NotImplemented error"
+
+
 class ImageFault(TempestException):
     message = "Got image fault"
 
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
index bb463e5..5b2ce7a 100644
--- a/tempest/tests/test_rest_client.py
+++ b/tempest/tests/test_rest_client.py
@@ -351,7 +351,7 @@
                           **self.set_data("500"))
 
     def test_response_501_with_text(self):
-        self.assertRaises(exceptions.ServerFault,
+        self.assertRaises(exceptions.NotImplemented,
                           self.rest_client._error_checker,
                           **self.set_data("501"))
 
@@ -363,7 +363,7 @@
 
     def test_response_501_with_dict(self):
         r_body = '{"resp_body": {"err": "fake_resp_body"}}'
-        self.assertRaises(exceptions.ServerFault,
+        self.assertRaises(exceptions.NotImplemented,
                           self.rest_client._error_checker,
                           **self.set_data("501", r_body=r_body))