@@ -54,6 +54,9 @@ def __call__(self, task, inventory, plugin_data):
5454
5555 for interface in inventory ['interfaces' ]:
5656 if interface ['name' ] not in plugin_data ['all_interfaces' ]:
57+ LOG .debug ("No processed data for interface %s on node %s, "
58+ "skipping physical network processing." ,
59+ interface ['name' ], task .node .uuid )
5760 continue
5861
5962 mac_address = interface ['mac_address' ]
@@ -70,8 +73,7 @@ def __call__(self, task, inventory, plugin_data):
7073 if phys_network is None :
7174 LOG .debug ("Skipping physical network processing for interface "
7275 "%s on node %s - no physical network mapping." ,
73- mac_address ,
74- task .node .uuid )
76+ mac_address , task .node .uuid )
7577 continue
7678
7779 if getattr (port , 'physical_network' , '' ) != phys_network :
@@ -135,18 +137,32 @@ def get_physical_network(self, interface, plugin_data):
135137 :param introspection_data: Introspection data.
136138 :returns: The physical network to set, or None.
137139 """
138- # Check if LLDP data was already processed by lldp_basic plugin
139- # which stores data in 'all_interfaces'
140- iface_name = interface ['name' ]
141- proc_data = plugin_data ['all_interfaces' ][iface_name ]
142- if 'parsed_lldp' not in proc_data :
140+ # Check if LLDP data was already processed
141+ if 'parsed_lldp' not in plugin_data :
142+ LOG .error ("No LLDP data, parse_lldp hook is required. " )
143143 return
144144
145- lldp_proc = proc_data ['parsed_lldp' ]
145+ # check we have data for this interface
146+ iface_name = interface ['name' ]
147+ lldp_proc = plugin_data ['parsed_lldp' ].get (iface_name )
148+ if not lldp_proc :
149+ LOG .debug ("No LLDP data for interface %s" , iface_name )
150+ return
146151
147152 # Switch system name mapping.
148153 switch_sys_name = lldp_proc .get (lldp_parsers .LLDP_SYS_NAME_NM )
149- if switch_sys_name :
150- mapping = self ._get_switch_sys_name_mapping ()
151- if switch_sys_name in mapping :
152- return mapping [switch_sys_name ]
154+ if not switch_sys_name :
155+ LOG .debug ("No switch system name in LLDP data for interface %s" ,
156+ iface_name )
157+ return
158+
159+ mapping = self ._get_switch_sys_name_mapping ()
160+ if switch_sys_name not in mapping :
161+ LOG .debug ("No config set for switch system name %s for "
162+ "interface %s" , switch_sys_name , iface_name )
163+ return
164+
165+ LOG .debug ("Interface %s connected to switch with system name "
166+ "%s, physnet %s" , iface_name , switch_sys_name ,
167+ mapping [switch_sys_name ])
168+ return mapping [switch_sys_name ]
0 commit comments