Detect DBReferenceError when deleting flavor

The flavor framework currently has a TODO where the logic
to ensure the flavor isn't in use should be. Implementing
this logic will be a bit complicated this late in the cycle
since many different services can depend on the flavor.

For now we can at least catch the DBReferenceError when trying
to delete the flavor and convert it into the FlavorInUse
exception.

This leaves some notes inline about how we might go about
implemented the _ensure_flavor_not_inuse function.

Change-Id: I6bfe61645c6cee002020a507e489c3535d5026ab
Closes-Bug: #1621281
diff --git a/neutron/tests/tempest/api/admin/test_routers_flavors.py b/neutron/tests/tempest/api/admin/test_routers_flavors.py
index 7276a19..3e214e1 100644
--- a/neutron/tests/tempest/api/admin/test_routers_flavors.py
+++ b/neutron/tests/tempest/api/admin/test_routers_flavors.py
@@ -11,7 +11,9 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from tempest.lib import exceptions as lib_exc
 from tempest import test
+import testtools
 
 from neutron.tests.tempest.api import base_routers as base
 
@@ -63,3 +65,9 @@
         # ensure client can create router with flavor
         router = self.create_router('name', flavor_id=flavor['id'])
         self.assertEqual(flavor['id'], router['flavor_id'])
+
+    @test.idempotent_id('30e73858-a0fc-409c-a2e0-e9cd2826f6a2')
+    def test_delete_router_flavor_in_use(self):
+        self.create_router('name', flavor_id=self.flavor['id'])
+        with testtools.ExpectedException(lib_exc.Conflict):
+            self.admin_client.delete_flavor(self.flavor['id'])