public static void addToPortCache(Port port) { portMap.put(port.getUuid(), port); }
public static void removeFromPortCache(Port port) { portMap.remove(port.getUuid()); }
public static void addToQosPortsCache(Uuid qosUuid, Port port) { if (qosPortsMap.containsKey(qosUuid)) { if (!qosPortsMap.get(qosUuid).containsKey(port.getUuid())) { qosPortsMap.get(qosUuid).put(port.getUuid(), port); } } else { HashMap<Uuid, Port> portMap = new HashMap<>(); portMap.put(port.getUuid(), port); qosPortsMap.put(qosUuid, portMap); } }
protected static String getVifPortName(Port port) { if (port == null || port.getUuid() == null) { logger.warn("Invalid Neutron port {}", port); return null; } String tapId = port.getUuid().getValue().substring(0, 11); String portNamePrefix = getPortNamePrefix(port); if (portNamePrefix != null) { return new StringBuilder().append(portNamePrefix).append(tapId).toString(); } logger.debug("Failed to get prefix for port {}", port.getUuid()); return null; }
@Override protected void remove(InstanceIdentifier<Port> identifier, Port port) { LOG.debug("remove port notification handler is invoked..."); ifMgr.removePort(port.getUuid()); }
/** * Return the virtual interface ID configured in the specified by the * neutron port. * * @param port A neutron port instance. * @return The virtual interface ID. */ public static String getInterfaceId(Port port) { return convertUUIDToKey(port.getUuid()); }
public static Optional<Port> findPort(Uuid uuid, @Nullable Ports ports) { if (ports == null || ports.getPort() == null) { return Optional.absent(); } for (Port port : ports.getPort()) { if (port.getUuid().equals(uuid)) { return Optional.of(port); } } return Optional.absent(); }
protected static Interface getOfPortInterface(DataBroker broker, Port port) { String name = port.getUuid().getValue(); InstanceIdentifier interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(name); try { Optional<Interface> optionalInf = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier); if (optionalInf.isPresent()) { return optionalInf.get(); } else { logger.error("Interface {} is not present", name); } } catch (Exception e) { logger.error("Failed to get interface {} due to the exception {}", name, e.getMessage()); } return null; }
public static void handleNeutronPortQosUpdate(DataBroker db, OdlInterfaceRpcService odlInterfaceRpcService, Port port, Uuid qosUuid) { if (LOG.isTraceEnabled()) { LOG.trace("Handling Port QoS update: port: {} qos: {}", port.getUuid(), qosUuid); } // handle Bandwidth Limit Rules update QosPolicy qosPolicy = NeutronvpnUtils.qosPolicyMap.get(qosUuid); if (qosPolicy != null && qosPolicy.getBandwidthLimitRules() != null && !qosPolicy.getBandwidthLimitRules().isEmpty()) { setPortBandwidthLimits(db, odlInterfaceRpcService, port, qosPolicy.getBandwidthLimitRules().get(0)); } }
private void deleteOfPortInterface(Port port) { String name = port.getUuid().getValue(); LOG.debug("Removing OFPort Interface {}", name); InstanceIdentifier interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(name); try { Optional<Interface> optionalInf = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier); if (optionalInf.isPresent()) { MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier); } else { LOG.error("Interface {} is not present", name); } } catch (Exception e) { LOG.error("Failed to delete interface {} due to the exception {}", name, e.getMessage()); } }
@Override protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) { LOG.debug("update port notification handler is invoked..."); if (update.getDeviceOwner().equalsIgnoreCase(Ipv6Constants.NETWORK_ROUTER_INTERFACE)) { ifMgr.updateRouterIntf(update.getUuid(), new Uuid(update.getDeviceId()), update.getFixedIps()); } else { ifMgr.updateHostIntf(update.getUuid(), update.getFixedIps()); } }
private String getSubnetIPFromPort(Port port) throws Exception { FixedIps ip = port.getFixedIps().get(0); if (ip == null) { LOG.error("No fixed ip for port " + port.getName()); throw new Exception("No fixed ip for port" + port.getName()); } Uuid subnetId = ip.getSubnetId(); Subnetmap subnetmap = nvManager.updateSubnetmapNodeWithPorts(subnetId, port.getUuid(), null); String subnetIp = subnetmap.getSubnetIp(); return subnetIp; }
private void handleRouterGatewayUpdated(Port routerGwPort) { Uuid routerId = new Uuid(routerGwPort.getDeviceId()); Router router = NeutronvpnUtils.getNeutronRouter(dataBroker, routerId); if (router == null) { LOG.warn("No router found for router GW port {} router id {}", routerGwPort.getUuid(), routerId.getValue()); return; } gwMacResolver.sendArpRequestsToExtGateways(router); }
public static NeutronRouter_Interface convertMDSalInterfaceToNeutronRouterInterface( Port routerInterface) { NeutronRouter_Interface neutronInterface = new NeutronRouter_Interface(); String id = String.valueOf(routerInterface.getUuid().getValue()); neutronInterface.setID(id); if (routerInterface.getTenantId() != null) { neutronInterface.setTenantID(routerInterface.getTenantId().getValue()); } neutronInterface.setSubnetUUID(routerInterface.getFixedIps().get(0).getSubnetId().getValue()); neutronInterface.setPortUUID(routerInterface.getUuid().getValue()); return neutronInterface; }
public static NeutronRouter_Interface convertMDSalInterfaceToNeutronRouterInterface( Port routerInterface) { NeutronRouter_Interface neutronInterface = new NeutronRouter_Interface(); String id = String.valueOf(routerInterface.getUuid().getValue()); neutronInterface.setID(id); if (routerInterface.getTenantId() != null) { neutronInterface.setTenantID(routerInterface.getTenantId().getValue()); } neutronInterface.setSubnetUUID(routerInterface.getFixedIps().get(0).getSubnetId().getValue()); neutronInterface.setPortUUID(routerInterface.getUuid().getValue()); return neutronInterface; }
private void unregisterEndpointAndRemoveMapping(UnregisterEndpointInput baseEpUnreg, Port port, ReadWriteTransaction rwTx) { boolean isUnregisteredBaseEndpoint = epRegistrator.unregisterEndpoint(baseEpUnreg); if (isUnregisteredBaseEndpoint) { UniqueId portId = new UniqueId(port.getUuid().getValue()); PortByBaseEndpointKey portByBaseEndpointKey = new PortByBaseEndpointKey(port.getMacAddress().getValue(), MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN); LOG.trace("Removing Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid().getValue(), port.getDeviceOwner(), portByBaseEndpointKey); removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx); } }
/** * Delete PortMap set for a NeutronPort. * * @param neutronPort * An instance of NeutronPort object. */ public void deletePortMap(@Nonnull Port neutronPort) { LOG.info("Unconfiguring port mapping: neutron-port={}", getUuid(neutronPort.getUuid())); RemovePortMapInput input = new RemovePortMapInputBuilder(). setTenantName(getTenantId(neutronPort)). setBridgeName(getBridgeId(neutronPort)). setInterfaceName(getInterfaceId(neutronPort)). build(); int result = vtnManager.removePortMap(input); if (result != HTTP_OK && result != HTTP_NOT_FOUND) { LOG.error("Failed to unmap physical port: port={}", neutronPort); } }
@Deprecated private void unregisterEndpointAndRemoveMapping( org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregEpInput, Port port, ReadWriteTransaction rwTx) { boolean isUnregisteredEndpoint = epRegistrator.unregisterEndpoint(unregEpInput); if (isUnregisteredEndpoint) { UniqueId portId = new UniqueId(port.getUuid().getValue()); EndpointKey epKey = new EndpointKey(new L2BridgeDomainId(port.getNetworkId().getValue()), new MacAddress( port.getMacAddress().getValue())); LOG.trace("Removing Port-Endpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid() .getValue(), port.getDeviceOwner(), epKey); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.endpointByPortIid(portId), rwTx); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.portByEndpointIid(epKey.getL2Context(), epKey.getMacAddress()), rwTx); } }
private Interface updateInterface(Port original, Port update) { String parentRefName = NeutronvpnUtils.getVifPortName(update); String interfaceName = original.getUuid().getValue(); InterfaceBuilder interfaceBuilder = new InterfaceBuilder(); if(parentRefName != null) { ParentRefsBuilder parentRefsBuilder = new ParentRefsBuilder().setParentInterface(parentRefName); interfaceBuilder.addAugmentation(ParentRefs.class, parentRefsBuilder.build()); } interfaceBuilder.setName(interfaceName); return interfaceBuilder.build(); }