From: Mark McLoughlin Date: Tue, 17 Jul 2012 03:04:58 +0000 (+0100) Subject: Remove unused raise_http_conflict_for_instance_invalid_state() X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=03700f12f356a00c67fe3c301cc297c85e92c69e;p=openstack-build%2Fcinder-build.git Remove unused raise_http_conflict_for_instance_invalid_state() Only used by the compute API in Nova. Change-Id: I3b2dfa33b4bd1523e13ddb5401bc0397df7466ef --- diff --git a/cinder/api/openstack/common.py b/cinder/api/openstack/common.py index ce2d2bd93..0fb79d4b9 100644 --- a/cinder/api/openstack/common.py +++ b/cinder/api/openstack/common.py @@ -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) diff --git a/cinder/tests/api/openstack/test_common.py b/cinder/tests/api/openstack/test_common.py index 22ccbd77c..162691364 100644 --- a/cinder/tests/api/openstack/test_common.py +++ b/cinder/tests/api/openstack/test_common.py @@ -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):