]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove unused raise_http_conflict_for_instance_invalid_state()
authorMark McLoughlin <markmc@redhat.com>
Tue, 17 Jul 2012 03:04:58 +0000 (04:04 +0100)
committerMark McLoughlin <markmc@redhat.com>
Tue, 17 Jul 2012 03:04:58 +0000 (04:04 +0100)
Only used by the compute API in Nova.

Change-Id: I3b2dfa33b4bd1523e13ddb5401bc0397df7466ef

cinder/api/openstack/common.py
cinder/tests/api/openstack/test_common.py

index ce2d2bd934de7489a85f9cd8b245a594f887df17..0fb79d4b940120c111e9cbab409b108e75e8edb4 100644 (file)
@@ -211,21 +211,6 @@ def dict_to_query_str(params):
     return param_str.rstrip('&')
 
 
-def raise_http_conflict_for_instance_invalid_state(exc, action):
-    """Return a webob.exc.HTTPConflict instance containing a message
-    appropriate to return via the API based on the original
-    InstanceInvalidState exception.
-    """
-    attr = exc.kwargs.get('attr')
-    state = exc.kwargs.get('state')
-    if attr and state:
-        msg = _("Cannot '%(action)s' while instance is in %(attr)s %(state)s")
-    else:
-        # At least give some meaningful message
-        msg = _("Instance is in an invalid state for '%(action)s'")
-    raise webob.exc.HTTPConflict(explanation=msg % locals())
-
-
 class MetadataDeserializer(wsgi.MetadataXMLDeserializer):
     def deserialize(self, text):
         dom = minidom.parseString(text)
index 22ccbd77c93f671fb4600c19d2f8c577b27bc98b..162691364764941ba5934e2a54a832bff34d9c3c 100644 (file)
@@ -300,34 +300,6 @@ class MiscFunctionsTest(test.TestCase):
         actual = common.get_version_from_href(fixture)
         self.assertEqual(actual, expected)
 
-    def test_raise_http_conflict_for_instance_invalid_state(self):
-        # Correct args
-        exc = exception.InstanceInvalidState(attr='fake_attr',
-                state='fake_state', method='fake_method')
-        try:
-            common.raise_http_conflict_for_instance_invalid_state(exc,
-                    'meow')
-        except Exception, e:
-            self.assertTrue(isinstance(e, webob.exc.HTTPConflict))
-            msg = str(e)
-            self.assertEqual(msg,
-                "Cannot 'meow' while instance is in fake_attr fake_state")
-        else:
-            self.fail("webob.exc.HTTPConflict was not raised")
-
-        # Incorrect args
-        exc = exception.InstanceInvalidState()
-        try:
-            common.raise_http_conflict_for_instance_invalid_state(exc,
-                    'meow')
-        except Exception, e:
-            self.assertTrue(isinstance(e, webob.exc.HTTPConflict))
-            msg = str(e)
-            self.assertEqual(msg,
-                "Instance is in an invalid state for 'meow'")
-        else:
-            self.fail("webob.exc.HTTPConflict was not raised")
-
 
 class MetadataXMLDeserializationTest(test.TestCase):