use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project netvirt by opendaylight.
the class PolicyAceFlowProgrammer method getIngressInterfaceFlow.
private Optional<PolicyAceFlowWrapper> getIngressInterfaceFlow(IngressInterface ingressInterface) {
String interfaceName = ingressInterface.getName();
if (interfaceName == null) {
LOG.error("Invalid ingress interface augmentation. missing interface name");
return Optional.empty();
}
String flowName = "INGRESS_INTERFACE_" + interfaceName;
int flowPriority = PolicyServiceConstants.POLICY_ACL_TRUNK_INTERFACE_FLOW_PRIOPITY;
VlanId vlanId = ingressInterface.getVlanId();
if (vlanId != null) {
Optional<String> vlanMemberInterfaceOpt = policyServiceUtil.getVlanMemberInterface(interfaceName, vlanId);
if (!vlanMemberInterfaceOpt.isPresent()) {
LOG.debug("Vlan member {} missing for trunk {}", vlanId.getValue(), interfaceName);
return Optional.of(new PolicyAceFlowWrapper(flowName, PolicyAceFlowWrapper.PARTIAL));
}
interfaceName = vlanMemberInterfaceOpt.get();
flowPriority = PolicyServiceConstants.POLICY_ACL_VLAN_INTERFACE_FLOW_PRIOPITY;
}
List<MatchInfoBase> matches = policyFlowUtil.getIngressInterfaceMatches(interfaceName);
if (matches == null || matches.isEmpty()) {
LOG.debug("Failed to get ingress interface {} matches", interfaceName);
return Optional.of(new PolicyAceFlowWrapper(flowName, PolicyAceFlowWrapper.PARTIAL));
}
BigInteger dpId = interfaceManager.getDpnForInterface(interfaceName);
if (dpId == null) {
dpId = BigInteger.ZERO;
}
return Optional.of(new PolicyAceFlowWrapper(flowName, matches, flowPriority, dpId));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method createSubPortInterface.
private void createSubPortInterface(Trunk trunk, SubPorts subPort) {
if (!NetworkTypeVlan.class.equals(subPort.getSegmentationType())) {
LOG.warn("SegmentationType other than VLAN not supported for Trunk:SubPorts");
return;
}
String portName = subPort.getPortId().getValue();
String parentName = trunk.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
// Should we use parentName?
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
/*
* Build Port-to-Subport details first, irrespective of port being available or not.
*/
PortIdToSubportBuilder portIdToSubportBuilder = new PortIdToSubportBuilder();
Uuid subPortUuid = subPort.getPortId();
portIdToSubportBuilder.withKey(new PortIdToSubportKey(subPortUuid)).setPortId(subPortUuid).setTrunkPortId(trunk.getPortId()).setVlanId(subPort.getSegmentationId());
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.merge(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPortUuid), portIdToSubportBuilder.build());
LOG.trace("Creating PortIdSubportMapping for port{}", portName);
}));
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
if (iface == null) {
/*
* Trunk creation requires NeutronPort to be present, by this time interface
* should've been created. In controller restart use case Interface would already be present.
* Clustering consideration:
* This being same shard as NeutronPort, interface creation will be triggered on the same
* node as this one. Use of DSJC helps ensure the order.
*/
LOG.warn("Interface not present for Trunk SubPort: {}", subPort);
return futures;
}
InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.TrunkMember).setVlanId(new VlanId(subPort.getSegmentationId().intValue())).build();
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentName).build();
SplitHorizon splitHorizon = new SplitHorizonBuilder().setOverrideSplitHorizonProtection(true).build();
interfaceBuilder.setName(portName).setType(L2vlan.class).addAugmentation(ifL2vlan).addAugmentation(parentRefs).addAugmentation(splitHorizon);
Interface newIface = interfaceBuilder.build();
/*
* Interface is already created for parent NeutronPort. We're updating parent refs
* and VLAN Information
*/
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, txn -> txn.merge(interfaceIdentifier, newIface));
LoggingFutures.addErrorLogging(future, LOG, "createSubPortInterface: Failed for portName {}, parentName {}", portName, parentName);
futures.add(future);
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method deleteSubPortInterface.
private void deleteSubPortInterface(SubPorts subPort) {
String portName = subPort.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
List<ListenableFuture<?>> futures = new ArrayList<>();
if (iface == null) {
LOG.warn("Interface not present for SubPort {}", subPort);
return futures;
}
/*
* We'll reset interface back to way it was? Can IFM handle parentRef delete?
*/
InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
// Reset augmentations
interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
interfaceBuilder.addAugmentation(ifL2vlan);
Interface newIface = interfaceBuilder.build();
/*
* There is no means to do an update to remove elements from a node.
* Our solution is to get existing iface, remove parentRef and VlanId,
* and do a put to replace existing entry. This works out better as put
* has better performance than merge.
* Only drawback is any in-flight changes might be lost, but that is a corner case
* and this being subport delete path, don't expect any significant changes to
* corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
*/
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.put(interfaceIdentifier, newIface);
LOG.trace("Resetting trunk member interface {}", newIface);
}));
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.delete(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPort.getPortId()));
LOG.trace("Deleting PortIdSubportMapping for portName {}", portName);
}));
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.
the class ItmManagerRpcServiceTest method setupMocks.
private void setupMocks() {
deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, "abc")).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
deviceVtepsList.add(deviceVteps);
stringList.add(sourceDevice);
dpId1List.add(dpId1);
stringList.add("def");
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(tunnelInterfaceName, String.valueOf(ipAddress1.getValue()), String.valueOf(ipAddress1.getValue()), tunnelType1.getName());
interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1).setIpAddress(ipAddress1).setGwIpAddress(gtwyIp1).setInterfaceName(tunnelInterfaceName).setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest).setKey(new TunnelEndPointsKey(ipAddress1, portName1, tunnelType1, vlanId)).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId1).setKey(new DPNTEPsInfoKey(dpId1)).setUp(true).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
cfgdDpnListVxlan.add(dpntePsInfoVxlan);
dpnEndpoints = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
externalTunnel = new ExternalTunnelBuilder().setSourceDevice(sourceDevice).setDestinationDevice(destinationDevice).setTransportType(tunnelType1).setTunnelInterfaceName(tunnelInterfaceName).setKey(new ExternalTunnelKey(destinationDevice, sourceDevice, tunnelType1)).build();
internalTunnel = new InternalTunnelBuilder().setTunnelInterfaceNames(Collections.singletonList(tunnelInterfaceName)).setDestinationDPN(dpId2).setSourceDPN(dpId1).setTransportType(tunnelType1).setKey(new InternalTunnelKey(dpId2, dpId1, tunnelType1)).build();
getInternalOrExternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ipAddress1).setSourceDpid(dpId1).setTunnelType(tunnelType2).build();
addExternalTunnelEndpointInput = new AddExternalTunnelEndpointInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).build();
addL2GwDeviceInput = new AddL2GwDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
deleteL2GwDeviceInput = new DeleteL2GwDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
addL2GwMlagDeviceInput = new AddL2GwMlagDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(stringList).setTopologyId(destinationDevice).build();
deleteL2GwMlagDeviceInput = new DeleteL2GwMlagDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(stringList).setTopologyId(destinationDevice).build();
buildExternalTunnelFromDpnsInput = new BuildExternalTunnelFromDpnsInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).setDpnId(dpId1List).build();
removeExternalTunnelFromDpnsInput = new RemoveExternalTunnelFromDpnsInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).setDpnId(dpId1List).build();
removeExternalTunnelEndpointInput = new RemoveExternalTunnelEndpointInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).build();
removeTerminatingServiceActionsInput = new RemoveTerminatingServiceActionsInputBuilder().setServiceId(vlanId).setDpnId(dpId1).build();
getTunnelInterfaceNameInput = new GetTunnelInterfaceNameInputBuilder().setTunnelType(tunnelType1).setSourceDpid(dpId1).setDestinationDpid(dpId2).build();
getExternalTunnelInterfaceNameInput = new GetExternalTunnelInterfaceNameInputBuilder().setTunnelType(tunnelType1).setDestinationNode(destinationDevice).setSourceNode(sourceDevice).build();
iface = ItmUtils.buildTunnelInterface(dpId1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunnelType1), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress1, gtwyIp1, tunnelEndPointsVxlan.getVLANID(), false, false, monitorProtocol, null, false, null);
subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).build();
subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.
the class ItmExternalTunnelAddTest method testBuildHwVtepsTunnels.
@Test
public void testBuildHwVtepsTunnels() {
final Interface extTunnelIf1 = ItmUtils.buildTunnelInterface(dpId1, "tun030025bd04f", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress1, gtwyIp1, vlanId, false, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false, null);
final Interface hwTunnelIf2 = ItmUtils.buildHwTunnelInterface("tun9a55a9c38f2", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), hwVtep1.getNodeId(), tunnelType1, ipAddress1, ipAddress3, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final Interface extTunnelIf3 = ItmUtils.buildTunnelInterface(dpId1, "tun17c6e20c283", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress2, gtwyIp1, vlanId, false, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false, null);
final Interface hwTunnelIf4 = ItmUtils.buildHwTunnelInterface("tunaa109b6c8c5", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), destination, tunnelType1, ipAddress2, ipAddress3, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final Interface hwTunnelIf5 = ItmUtils.buildHwTunnelInterface("tund903ed434d5", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), hwVtep1.getNodeId(), tunnelType1, ipAddress1, ipAddress2, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final Interface hwTunnelIf6 = ItmUtils.buildHwTunnelInterface("tunc3315b110a6", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), destination, tunnelType1, ipAddress2, ipAddress1, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final ExternalTunnel externalTunnel1 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(source), tunnelType1, "tun030025bd04f");
final ExternalTunnel externalTunnel2 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(source), getExternalTunnelKey(dpId1.toString()), tunnelType1, "tun9a55a9c38f2");
final ExternalTunnel externalTunnel3 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(destination), tunnelType1, "tun17c6e20c283");
final ExternalTunnel externalTunnel4 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(destination), getExternalTunnelKey(dpId1.toString()), tunnelType1, "tunaa109b6c8c5");
final ExternalTunnel externalTunnel5 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(source), getExternalTunnelKey(destination), tunnelType1, "tund903ed434d5");
final ExternalTunnel externalTunnel6 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(destination), getExternalTunnelKey(source), tunnelType1, "tunc3315b110a6");
InstanceIdentifier<TransportZone> transportZoneIdentifier = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone1)).build();
final InstanceIdentifier<Interface> ifIID1 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun030025bd04f")).build();
final InstanceIdentifier<Interface> ifIID2 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun9a55a9c38f2")).build();
final InstanceIdentifier<Interface> ifIID3 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun17c6e20c283")).build();
final InstanceIdentifier<Interface> ifIID4 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tunaa109b6c8c5")).build();
final InstanceIdentifier<Interface> ifIID5 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tund903ed434d5")).build();
final InstanceIdentifier<Interface> ifIID6 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tunc3315b110a6")).build();
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(source), getExternalTunnelKey(dpId1.toString()), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier2 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(source), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier3 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(destination), getExternalTunnelKey(dpId1.toString()), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier4 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(destination), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier5 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(destination), getExternalTunnelKey(source), tunnelType1));
final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier6 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(source), getExternalTunnelKey(destination), tunnelType1));
Optional<TransportZone> optionalTransportZone = Optional.of(transportZone);
doReturn(Futures.immediateCheckedFuture(optionalTransportZone)).when(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
externalTunnelAddWorker.buildHwVtepsTunnels(cfgdDpnListVxlan, null);
externalTunnelAddWorker.buildHwVtepsTunnels(null, cfgdHwVtepsList);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, ifIID1, extTunnelIf1, true);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier1, externalTunnel1, true);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, ifIID2, hwTunnelIf2, true);
verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier2, externalTunnel2, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID3, extTunnelIf3, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier3, externalTunnel3, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID4, hwTunnelIf4, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier4, externalTunnel4, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID5, hwTunnelIf5, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier5, externalTunnel5, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID6, hwTunnelIf6, true);
verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier6, externalTunnel6, true);
}
Aggregations