def _get_port_infos(self, port, segment, agent_host): if not agent_host: return session = db_api.get_session() agent = l2pop_db.get_agent_by_host(session, agent_host) if not agent: return agent_ip = l2pop_db.get_agent_ip(agent) if not agent_ip: LOG.warning(_LW("Unable to retrieve the agent ip, check the agent " "configuration.")) return if not segment: LOG.warning(_LW("Port %(port)s updated by agent %(agent)s " "isn't bound to any segment"), {'port': port['id'], 'agent': agent}) return network_types = l2pop_db.get_agent_l2pop_network_types(agent) if network_types is None: network_types = l2pop_db.get_agent_tunnel_types(agent) if segment['network_type'] not in network_types: return fdb_entries = [l2pop_rpc.PortInfo(mac_address=port['mac_address'], ip_address=ip['ip_address']) for ip in port['fixed_ips']] return agent_ip, fdb_entries
def _get_portpair_detail_info(self, portpair_id): """Get port detail. @param: portpair_id: uuid @return: (host_id, local_ip, network_type, segment_id, service_insert_type): tuple """ core_plugin = manager.NeutronManager.get_plugin() port_detail = core_plugin.get_port(self.admin_context, portpair_id) host_id, local_ip, network_type, segment_id, mac_address = ( (None, ) * 5) if port_detail: host_id = port_detail['binding:host_id'] network_id = port_detail['network_id'] mac_address = port_detail['mac_address'] network_info = core_plugin.get_network( self.admin_context, network_id) network_type = network_info['provider:network_type'] segment_id = network_info['provider:segmentation_id'] if network_type != np_const.TYPE_VXLAN: LOG.warning(_LW("Currently only support vxlan network")) return ((None, ) * 5) elif not host_id: LOG.warning(_LW("This port has not been binding")) return ((None, ) * 5) else: driver = core_plugin.type_manager.drivers.get(network_type) host_endpoint = driver.obj.get_endpoint_by_host(host_id) local_ip = host_endpoint['ip_address'] return host_id, local_ip, network_type, segment_id, mac_address
def _get_portpair_detail_info(self, portpair_id): """Get port detail. @param: portpair_id: uuid @return: (host_id, local_ip, network_type, segment_id, service_insert_type): tuple """ core_plugin = manager.NeutronManager.get_plugin() port_detail = core_plugin.get_port(self.admin_context, portpair_id) host_id, local_ip, network_type, segment_id, mac_address = ((None, ) * 5) if port_detail: host_id = port_detail['binding:host_id'] network_id = port_detail['network_id'] mac_address = port_detail['mac_address'] network_info = core_plugin.get_network(self.admin_context, network_id) network_type = network_info['provider:network_type'] segment_id = network_info['provider:segmentation_id'] if network_type != np_const.TYPE_VXLAN: LOG.warning(_LW("Currently only support vxlan network")) return ((None, ) * 5) elif not host_id: LOG.warning(_LW("This port has not been binding")) return ((None, ) * 5) else: driver = core_plugin.type_manager.drivers.get(network_type) host_endpoint = driver.obj.get_endpoint_by_host(host_id) local_ip = host_endpoint['ip_address'] return host_id, local_ip, network_type, segment_id, mac_address
def treat_devices_added_or_updated(self, devices, ovs_restarted): skipped_devices = [] need_binding_devices = [] security_disabled_devices = [] devices_details_list = ( self.plugin_rpc.get_devices_details_list_and_failed_devices( self.context, devices, self.agent_id, self.conf.host ) ) failed_devices = set(devices_details_list.get('failed_devices')) devices = devices_details_list.get('devices') vif_by_id = self.int_br.get_vifs_by_ids( [vif['device'] for vif in devices]) for details in devices: device = details['device'] LOG.debug("Processing port: %s", device) port = vif_by_id.get(device) if not port: # The port disappeared and cannot be processed LOG.info(_LI("Port %s was not found on the integration bridge " "and will therefore not be processed"), device) skipped_devices.append(device) continue if 'port_id' in details: LOG.info(_LI("Port %(device)s updated. Details: %(details)s"), {'device': device, 'details': details}) details['vif_port'] = port need_binding = self.treat_vif_port(port, details['port_id'], details['network_id'], details['network_type'], details['physical_network'], details['segmentation_id'], details['admin_state_up'], details['fixed_ips'], details['device_owner'], ovs_restarted) if need_binding: need_binding_devices.append(details) port_security = details['port_security_enabled'] has_sgs = 'security_groups' in details if not port_security or not has_sgs: security_disabled_devices.append(device) self._update_port_network(details['port_id'], details['network_id']) self.ext_manager.handle_port(self.context, details) self.sfc_treat_devices_added_updated(details['port_id']) else: LOG.warning(_LW("Device %s not defined on plugin"), device) if (port and port.ofport != -1): self.port_dead(port) return (skipped_devices, need_binding_devices, security_disabled_devices, failed_devices)
def _get_fcs_by_ids(self, fc_ids): flow_classifiers = [] if not fc_ids: return flow_classifiers # Get the portchain flow classifiers fc_plugin = (manager.NeutronManager.get_service_plugins().get( flowclassifier.FLOW_CLASSIFIER_EXT)) if not fc_plugin: LOG.warning(_LW("Not found the flow classifier service plugin")) return flow_classifiers for fc_id in fc_ids: fc = fc_plugin.get_flow_classifier(self.admin_context, fc_id) flow_classifiers.append(fc) return flow_classifiers
def _get_fcs_by_ids(self, fc_ids): flow_classifiers = [] if not fc_ids: return flow_classifiers # Get the portchain flow classifiers fc_plugin = ( directory.get_plugin(flowclassifier.FLOW_CLASSIFIER_EXT) ) if not fc_plugin: LOG.warning(_LW("Not found the flow classifier service plugin")) return flow_classifiers for fc_id in fc_ids: fc = fc_plugin.get_flow_classifier(self.admin_context, fc_id) flow_classifiers.append(fc) return flow_classifiers