Browse Source

Merge "Improve logging in bind_port method"

Zuul 7 months ago
parent
commit
c08ac0dbcd
1 changed files with 10 additions and 20 deletions
  1. 10
    20
      networking_ansible/ml2/mech_driver.py

+ 10
- 20
networking_ansible/ml2/mech_driver.py View File

@@ -207,37 +207,27 @@ class AnsibleMechanismDriver(api.MechanismDriver):
207 207
         can use with ports.
208 208
         """
209 209
         port = context.current
210
-        binding_profile = port['binding:profile']
211
-        local_link_info = binding_profile.get('local_link_information')
212 210
         # Validate port and local link info
213
-        if not (self._is_port_supported(port) and local_link_info):
214
-            # TODO(radez) log debug messages here
211
+        if 'local_link_information' not in port['binding:profile']:
212
+            LOG.debug(
213
+                "local_link_information is missing in port binding:profile")
214
+            return
215
+        if not self._is_port_supported(port):
216
+            LOG.debug(
217
+                "Port %s has vnic_type set to %s which is not correct to work "
218
+                "with networking-ansible driver.", port['id'],
219
+                port[portbindings.VNIC_TYPE])
215 220
             return
216 221
 
217
-        switch_name = local_link_info[0].get('switch_info')
218
-        switch_port = local_link_info[0].get('port_id')
219
-
220
-        network = context.network.current
221
-        # If segmentation ID is None, vlan will be set to 1
222
-        segmentation_id = network['provider:segmentation_id'] or '1'
223 222
         segments = context.segments_to_bind
224 223
 
225 224
         provisioning_blocks.add_provisioning_component(
226 225
             context._plugin_context, port['id'], resources.PORT,
227 226
             ANSIBLE_NETWORKING_ENTITY)
228
-        LOG.debug("Putting port {port} on {switch_name} to vlan: "
229
-                  "{segmentation_id}".format(
230
-                      port=switch_port,
231
-                      switch_name=switch_name,
232
-                      segmentation_id=segmentation_id))
227
+
233 228
         # Assign port to network
234 229
         self.ansnet.vlan_access_port('assign', context.current,
235 230
                                      context.network.current)
236
-        LOG.info("Successfully bound port {port_id} in segment "
237
-                 "{segment_id} on host {host}".format(
238
-                     port_id=port['id'],
239
-                     host=switch_name,
240
-                     segment_id=segmentation_id))
241 231
         context.set_binding(segments[0][api.ID],
242 232
                             portbindings.VIF_TYPE_OTHER, {})
243 233
 

Loading…
Cancel
Save