]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
print error when no match mapping found in check_segment_for_agent
authorYalei Wang <yalei.wang@intel.com>
Mon, 29 Dec 2014 05:17:30 +0000 (13:17 +0800)
committerYalei Wang <yalei.wang@intel.com>
Tue, 6 Jan 2015 02:35:10 +0000 (10:35 +0800)
error print when no match PHYSICAL_NETWORK mapping found in function
check_segment_for_agent for OVS and linuxbridge mechanism driver.

Change-Id: I58c43328f0512de25720871fc51c79f074493cdf
Closes-Bug: #1404962

neutron/plugins/ml2/drivers/mech_linuxbridge.py
neutron/plugins/ml2/drivers/mech_openvswitch.py

index 92cbd6f5dd41447af0c4269b8070527557635f54..2c52c2950b23bb4e02500339580f3301376e60c5 100644 (file)
@@ -15,6 +15,7 @@
 
 from neutron.common import constants
 from neutron.extensions import portbindings
+from neutron.i18n import _LW
 from neutron.openstack.common import log
 from neutron.plugins.ml2 import driver_api as api
 from neutron.plugins.ml2.drivers import mech_agent
@@ -52,6 +53,11 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
         elif network_type in tunnel_types:
             return True
         elif network_type in ['flat', 'vlan']:
-            return segment[api.PHYSICAL_NETWORK] in mappings
+            is_mapping_present = segment[api.PHYSICAL_NETWORK] in mappings
+            if not is_mapping_present:
+                LOG.warn(_LW("Failed to find %(seg)s in mappings %(map)s"),
+                        {'seg': segment[api.PHYSICAL_NETWORK],
+                         'map': mappings})
+            return is_mapping_present
         else:
             return False
index 350816135edcde070198f9489b9f2aaa3501b40c..678e92c18376ee086d630ed9f315ba3866cd12b7 100644 (file)
@@ -16,6 +16,7 @@
 from neutron.agent import securitygroups_rpc
 from neutron.common import constants
 from neutron.extensions import portbindings
+from neutron.i18n import _LW
 from neutron.openstack.common import log
 from neutron.plugins.ml2 import driver_api as api
 from neutron.plugins.ml2.drivers import mech_agent
@@ -56,6 +57,11 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
         elif network_type in tunnel_types:
             return True
         elif network_type in ['flat', 'vlan']:
-            return segment[api.PHYSICAL_NETWORK] in mappings
+            is_mapping_present = segment[api.PHYSICAL_NETWORK] in mappings
+            if not is_mapping_present:
+                LOG.warn(_LW("Failed to find %(seg)s in mappings %(map)s"),
+                        {'seg': segment[api.PHYSICAL_NETWORK],
+                         'map': mappings})
+            return is_mapping_present
         else:
             return False