private Map<String,NeutronPort> getChangedPorts(Map<InstanceIdentifier<?>, DataObject> changedData) { LOG.trace("getChangedPorts:" + changedData); Map<String,NeutronPort> portMap = new HashMap<>(); for (Map.Entry<InstanceIdentifier<?>, DataObject> changed : changedData.entrySet()) { if (changed.getValue() instanceof Port) { NeutronPort port = fromMd((Port)changed.getValue()); portMap.put(port.getID(), port); } } return portMap; }
private OvsdbTerminationPointAugmentation getInterface(Node node, NeutronPort port) { LOG.trace("getInterface:Node:" + node + " Port:" + port); try { List<OvsdbTerminationPointAugmentation> ovsdbPorts = southbound.getTerminationPointsOfBridge(node); for (OvsdbTerminationPointAugmentation ovsdbPort : ovsdbPorts) { String uuid = southbound.getInterfaceExternalIdsValue(ovsdbPort, Constants.EXTERNAL_ID_INTERFACE_ID); if (null != uuid && uuid.equals(port.getID())) { return ovsdbPort; } } } catch (Exception e) { LOG.error("Exception during handlingNeutron network delete", e); } LOG.info("no interface found for node: " + node + " port:" + port); return null; }
@Override public boolean addPort(NeutronPort input) { if (portExists(input.getID())) { return false; } addMd(input); return true; }
private void updatePort( AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes, Object[] subscribers) { Map<String, NeutronPort> originalPortMap = getChangedPorts(changes.getOriginalData()); for (Entry<InstanceIdentifier<?>, DataObject> updatePort : changes.getUpdatedData().entrySet()) { if (updatePort.getValue() instanceof Port) { NeutronPort port = fromMd((Port)updatePort.getValue()); NeutronPort originalPort = originalPortMap.get(port.getID()); if (originalPort != null) { port.setOriginalPort(originalPort); } else { LOG.warn("Original Port data is missing"); } for (Object entry: subscribers) { INeutronPortAware subscriber = (INeutronPortAware)entry; subscriber.neutronPortUpdated(port); } } } }
private Pair<Long, Uuid> getDpIdOfNeutronPort(String neutronTenantPortUuid) { if(neutronPortToDpIdCache.get(neutronTenantPortUuid) == null) { List<Node> bridges = this.southbound.readOvsdbTopologyBridgeNodes(); LOG.debug("getDpIdOfNeutronPort : {} bridges present in ovsdb topology",bridges.size()); for(Node bridge : bridges) { List<OvsdbTerminationPointAugmentation> interfaces = southbound.extractTerminationPointAugmentations(bridge); if(interfaces != null && !interfaces.isEmpty()) { LOG.debug("getDpIdOfNeutronPort : {} termination point present on bridge {}", interfaces.size(), bridge.getNodeId()); for (OvsdbTerminationPointAugmentation intf : interfaces) { NeutronPort neutronPort = tenantNetworkManager.getTenantPort(intf); if(neutronPort != null && neutronPort.getID().equals(neutronTenantPortUuid)) { Long dpId = getDpidForIntegrationBridge(bridge); Uuid interfaceUuid = intf.getInterfaceUuid(); LOG.debug("getDpIdOfNeutronPort : Found bridge {} and interface {} for the tenant neutron" + " port {}",dpId,interfaceUuid,neutronTenantPortUuid); handleInterfaceEventAdd(neutronPort.getPortUUID(), dpId, interfaceUuid); break; } } } } } return neutronPortToDpIdCache.get(neutronTenantPortUuid); }
if (cachedportUuid.equals(port.getID())) { continue;
private Node getNode(NeutronPort port) { LOG.trace("getNode:Port" + port); List<Node> toplogyNodes = southbound.readOvsdbTopologyNodes(); for (Node topologyNode : toplogyNodes) { try { Node node = southbound.getBridgeNode(topologyNode,Constants.INTEGRATION_BRIDGE); if (node == null) { LOG.error("getNode: br-int interface is not found for node:{}", topologyNode.getNodeId().getValue()); } List<OvsdbTerminationPointAugmentation> ovsdbPorts = southbound.getTerminationPointsOfBridge(node); for (OvsdbTerminationPointAugmentation ovsdbPort : ovsdbPorts) { String uuid = southbound.getInterfaceExternalIdsValue(ovsdbPort, Constants.EXTERNAL_ID_INTERFACE_ID); if (null != uuid && uuid.equals(port.getID())) { return node; } } } catch (Exception e) { LOG.error("Exception during handlingNeutron network delete", e); } } LOG.info("no node found for port:" + port); return null; }
/** * Clean up all created neutron objects. */ public void destroy() { for (PortInfo portInfo : portInfoByName.values()) { neutronUtils.removeNeutronPort(portInfo.neutronPort.getID()); } //TODO: probably more polite to clean up everything else as well... //TODO: for now just assume that the docker image will be recreated //TODO: before each test portInfoByName.clear(); if (neutronSubnet != null) { neutronUtils.removeNeutronSubnet(neutronSubnet.getID()); neutronSubnet = null; } if (neutronNetwork != null) { neutronUtils.removeNeutronNetwork(neutronNetwork.getID()); neutronNetwork = null; } }
if (cachedportUuid.equals(port.getID())) { continue;
private void syncSecurityGroup(NeutronSecurityRule securityRule,NeutronPort port, boolean write) { if (!port.getPortSecurityEnabled()) { LOG.info("Port security not enabled port", port); return; } if (null != securityRule.getSecurityRemoteGroupID()) { List<Neutron_IPs> vmIpList = securityServicesManager .getVmListForSecurityGroup(port.getID(), securityRule.getSecurityRemoteGroupID()); for (Neutron_IPs vmIp :vmIpList ) { securityServicesManager.syncSecurityRule(port, securityRule, vmIp, write); } } else { securityServicesManager.syncSecurityRule(port, securityRule, null, write); } }
private void doNeutronPortDeleted(NeutronPort neutronPort) { LOG.debug("Handling neutron delete port {}", neutronPort); distributedArpService.handlePortEvent(neutronPort, Action.DELETE); neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.DELETE); //TODO: Need to implement getNodes List<Node> nodes = nodeCacheManager.getNodes(); for (Node node : nodes) { OvsdbTerminationPointAugmentation port = findPortOnNode(node, neutronPort); if (port != null) { LOG.trace("neutronPortDeleted: Delete interface {}", port.getName()); southbound.deleteTerminationPoint(node, port.getName()); break; } } LOG.debug(" PORT delete successful for tenant-id - {}, network-id - {}, port-id - {}", neutronPort.getTenantID(), neutronPort.getNetworkUUID(), neutronPort.getID()); }
private void init() { /* * Rebuild the cache in case of a restart. */ List<NeutronPort> portList = neutronPortCache.getAllPorts(); for (NeutronPort port:portList) { List<NeutronSecurityGroup> securityGroupList = port.getSecurityGroups(); if ( null != securityGroupList) { for (NeutronSecurityGroup securityGroup : securityGroupList) { List<NeutronSecurityRule> securityRuleList = getSecurityRulesforGroup(securityGroup); if ( null != securityRuleList) { for (NeutronSecurityRule securityRule : securityRuleList) { if (null != securityRule.getSecurityRemoteGroupID()) { this.addToCache(securityRule.getSecurityRemoteGroupID(), port.getID()); } } } } } } }
private void doNeutronPortCreated(NeutronPort neutronPort) { LOG.debug(" Port-ADD successful for tenant-id - {}, network-id - {}, port-id - {}", neutronPort.getTenantID(), neutronPort.getNetworkUUID(), neutronPort.getID()); //TODO: Need to implement getNodes List<Node> nodes = nodeCacheManager.getNodes(); for (Node node : nodes) { OvsdbTerminationPointAugmentation port = findPortOnNode(node, neutronPort); // if the port already exist on the node it means that the southbound event already arrived // and was not handled because we could not find the tenant network if (port != null) { NeutronNetwork network = tenantNetworkManager.getTenantNetwork(port); if (network != null && !network.getRouterExternal()) { LOG.trace("handleInterfaceUpdate <{}> <{}> network: {}", node, port, network.getNetworkUUID()); if (bridgeConfigurationManager.createLocalNetwork(node, network)) { networkingProviderManager.getProvider(node).handleInterfaceUpdate(network, node, port); } } break; } } distributedArpService.handlePortEvent(neutronPort, Action.ADD); neutronL3Adapter.handleNeutronPortEvent(neutronPort, Action.ADD); }