]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Improve error message when flat network already exists
authorBob Kukura <rkukura@redhat.com>
Fri, 7 Sep 2012 01:42:54 +0000 (21:42 -0400)
committerBob Kukura <rkukura@redhat.com>
Fri, 7 Sep 2012 01:42:54 +0000 (21:42 -0400)
Fixes bug 1045601.

When attempting to create a flat network on a physical_network on
which a flat network is already allocated, the openvswitch and
linuxbridge plugins return a FlatNetworkInUse exception rather than a
VlanIdInUse exception referencing VLAN -1.

Change-Id: Id79e917e1376ebbb199efc3f14d9f378c6a04050

quantum/common/exceptions.py
quantum/plugins/linuxbridge/db/l2network_db_v2.py
quantum/plugins/openvswitch/ovs_db_v2.py

index 054bb433ac34953ce01df353129f56129263d7e5..0a117c3a2907ada05ff433bff9cd589723559394 100644 (file)
@@ -127,6 +127,11 @@ class VlanIdInUse(InUse):
                 "%(physical_network)s is in use.")
 
 
+class FlatNetworkInUse(InUse):
+    message = _("Unable to create the flat network. "
+                "Physical network %(physical_network)s is in use.")
+
+
 class TunnelIdInUse(InUse):
     message = _("Unable to create the network. "
                 "The tunnel ID %(tunnel_id)s is in use.")
index 985332c62e2de58263283047b4acb1b23e4f7237..a481c99658654b79698978342b73e9e3e006ef86 100644 (file)
@@ -17,12 +17,12 @@ import logging
 
 from sqlalchemy.orm import exc
 
-from quantum.common import constants
 from quantum.common import exceptions as q_exc
 import quantum.db.api as db
 from quantum.db import models_v2
 from quantum.openstack.common import cfg
 from quantum.plugins.linuxbridge.common import config
+from quantum.plugins.linuxbridge.common import constants
 from quantum.plugins.linuxbridge.db import l2network_models_v2
 
 LOG = logging.getLogger(__name__)
@@ -113,8 +113,12 @@ def reserve_specific_network(session, physical_network, vlan_id):
                                vlan_id=vlan_id).
                      one())
             if state.allocated:
-                raise q_exc.VlanIdInUse(vlan_id=vlan_id,
-                                        physical_network=physical_network)
+                if vlan_id == constants.FLAT_VLAN_ID:
+                    raise q_exc.FlatNetworkInUse(physical_network=
+                                                 physical_network)
+                else:
+                    raise q_exc.VlanIdInUse(vlan_id=vlan_id,
+                                            physical_network=physical_network)
             LOG.debug("reserving specific vlan %s on physical network %s "
                       "from pool" % (vlan_id, physical_network))
             state.allocated = True
index 5957e45825ccd55b802dc2dfa1f3d738c7042082..c1c4ebe236eef1ce40d3d2e3d18adf1d7666fbc9 100644 (file)
@@ -20,11 +20,11 @@ import logging
 
 from sqlalchemy.orm import exc
 
-from quantum.common import constants
 from quantum.common import exceptions as q_exc
 from quantum.db import models_v2
 import quantum.db.api as db
 from quantum.openstack.common import cfg
+from quantum.plugins.openvswitch.common import constants
 from quantum.plugins.openvswitch import ovs_models_v2
 
 LOG = logging.getLogger(__name__)
@@ -132,8 +132,12 @@ def reserve_specific_vlan(session, physical_network, vlan_id):
                                vlan_id=vlan_id).
                      one())
             if alloc.allocated:
-                raise q_exc.VlanIdInUse(vlan_id=vlan_id,
-                                        physical_network=physical_network)
+                if vlan_id == constants.FLAT_VLAN_ID:
+                    raise q_exc.FlatNetworkInUse(physical_network=
+                                                 physical_network)
+                else:
+                    raise q_exc.VlanIdInUse(vlan_id=vlan_id,
+                                            physical_network=physical_network)
             LOG.debug("reserving specific vlan %s on physical network %s "
                       "from pool" % (vlan_id, physical_network))
             alloc.allocated = True