use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method configureDhcpArpRequestResponseFlow.
public void configureDhcpArpRequestResponseFlow(BigInteger dpnId, String elanInstanceName, boolean addFlow, IpAddress tunnelIp, String dhcpIpAddress, String dhcpMacAddress) {
L2GatewayDevice device = getDeviceFromTunnelIp(tunnelIp);
if (device == null) {
LOG.error("Unable to get L2Device for tunnelIp {} and elanInstanceName {}", tunnelIp, elanInstanceName);
}
jobCoordinator.enqueueJob(getJobKey(elanInstanceName), () -> {
if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
String tunnelInterfaceName = getExternalTunnelInterfaceName(String.valueOf(dpnId), device.getHwvtepNodeId());
int lportTag = interfaceManager.getInterfaceInfo(tunnelInterfaceName).getInterfaceTag();
InstanceIdentifier<ElanInstance> elanIdentifier = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
Optional<ElanInstance> optElan = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, elanIdentifier);
if (optElan.isPresent()) {
LOG.trace("Configuring the SR-IOV Arp request/response flows for LPort {} ElanTag {}.", lportTag, optElan.get().getElanTag());
Uuid nwUuid = new Uuid(elanInstanceName);
String strVni = DhcpServiceUtils.getSegmentationId(nwUuid, broker);
BigInteger vni = strVni != null ? new BigInteger(strVni) : BigInteger.ZERO;
if (!vni.equals(BigInteger.ZERO)) {
if (addFlow) {
LOG.trace("Installing the SR-IOV DHCP Arp flow for DPN {} Port Ip {}, Lport {}.", dpnId, dhcpIpAddress, lportTag);
installDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag, optElan.get().getElanTag());
installDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, elanInstanceName, dhcpIpAddress, dhcpMacAddress);
} else {
LOG.trace("Uninstalling the SR-IOV DHCP Arp flows for DPN {} Port Ip {}, Lport {}.", dpnId, dhcpIpAddress, lportTag);
uninstallDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag);
uninstallDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, dhcpIpAddress);
}
}
}
}
return null;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceChainUtils method updateElanToLportTagMap.
/**
* Stores the relation between ElanLport and scfTag.
*
* @param broker dataBroker service reference
* @param elanInstanceName Name of the ELAN. Typically its UUID
* @param lportTag Dataplane identifier of the ElanPseudoPort
* @param scfTag Dataplane identifier of the SCF
* @param addOrRemove States if flows must be added or removed
*/
public static void updateElanToLportTagMap(final DataBroker broker, final String elanInstanceName, final int lportTag, final long scfTag, final int addOrRemove) {
Long portTag = Long.valueOf(lportTag);
ElanToPseudoPortDataKey key = new ElanToPseudoPortDataKey(portTag, scfTag);
InstanceIdentifier<ElanToPseudoPortData> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).augmentation(ElanServiceChainState.class).child(ElanToPseudoPortData.class, key).build();
if (addOrRemove == NwConstants.ADD_FLOW) {
ElanToPseudoPortData newValue = new ElanToPseudoPortDataBuilder().setKey(key).setElanLportTag(portTag).setScfTag(scfTag).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, path, newValue);
} else {
MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, path);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class CoeUtils method buildElanInstance.
static ElanInstance buildElanInstance(String elanInstanceName, Class<? extends SegmentTypeBase> segmentType, String segmentationId, Boolean isExternal) {
ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName);
if (segmentType != null) {
elanInstanceBuilder.setSegmentType(segmentType);
if (segmentationId != null) {
elanInstanceBuilder.setSegmentationId(Long.valueOf(segmentationId));
}
}
elanInstanceBuilder.setExternal(isExternal);
elanInstanceBuilder.setKey(new ElanInstanceKey(elanInstanceName));
return elanInstanceBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceChainHandler method removeElanPseudoPortFlows.
public void removeElanPseudoPortFlows(String elanName, int elanLportTag) {
Optional<ElanServiceChainState> elanServiceChainState = ElanServiceChainUtils.getElanServiceChainState(broker, elanName);
if (!elanServiceChainState.isPresent()) {
LOG.warn("Could not find ServiceChain state data for Elan {}, elanPseudoLportTag={}", elanName, elanLportTag);
return;
}
Optional<ElanInstance> elanInstance = ElanServiceChainUtils.getElanInstanceByName(broker, elanName);
if (!elanInstance.isPresent()) {
LOG.warn("Could not find ElanInstance for name {}", elanName);
return;
}
Long vni = elanInstance.get().getSegmentationId();
if (vni == null) {
LOG.warn("Elan {} is not related to a VNI. VNI is mandatory for ServiceChaining. Returning", elanName);
return;
}
List<ElanToPseudoPortData> elanToPseudoPortDataList = elanServiceChainState.get().getElanToPseudoPortData();
if (elanToPseudoPortDataList == null || elanToPseudoPortDataList.isEmpty()) {
LOG.info("Could not find elan {} with elanPseudoPort {} participating in any ServiceChain", elanName, elanLportTag);
return;
}
if (elanInstance.get().getElanTag() == null) {
LOG.info("Could not find elanTag for elan {} ", elanName);
return;
}
int elanTag = elanInstance.get().getElanTag().intValue();
List<BigInteger> operativeDPNs = NWUtil.getOperativeDPNs(broker);
for (ElanToPseudoPortData elanToPseudoPortData : elanToPseudoPortDataList) {
Long scfTag = elanToPseudoPortData.getScfTag();
for (BigInteger dpnId : operativeDPNs) {
ElanServiceChainUtils.programLPortDispatcherToScf(mdsalManager, dpnId, elanTag, elanLportTag, NwConstants.SCF_DOWN_SUB_FILTER_TCP_BASED_TABLE, scfTag, NwConstants.DEL_FLOW);
ElanServiceChainUtils.programLPortDispatcherFromScf(mdsalManager, dpnId, elanLportTag, elanTag, NwConstants.DEL_FLOW);
ElanServiceChainUtils.programExternalTunnelTable(mdsalManager, dpnId, elanLportTag, vni, elanTag, NwConstants.DEL_FLOW);
}
}
// Lastly, remove the serviceChain-state for the Elan
InstanceIdentifier<ElanServiceChainState> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanName)).augmentation(ElanServiceChainState.class).build();
MDSALUtil.syncDelete(broker, LogicalDatastoreType.OPERATIONAL, path);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.
the class ElanServiceTest method checkDmacSameDPN.
@Test
public void checkDmacSameDPN() throws Exception {
// Create Elan instance
createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
awaitForElanTag(ExpectedObjects.ELAN1);
// Add Elan interface in DPN1
InterfaceInfo interfaceInfo = ELAN_INTERFACES.get(ELAN1 + ":" + DPN1MAC1).getLeft();
addElanInterface(ExpectedObjects.ELAN1, interfaceInfo, DPN1IP1);
// Read Elan instance
InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
ElanInstance actualElanInstances = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
// Read DMAC Flow in DPN1
String flowId = new StringBuffer().append(NwConstants.ELAN_DMAC_TABLE).append(actualElanInstances.getElanTag()).append(DPN1_ID).append(interfaceInfo.getInterfaceTag()).append(interfaceInfo.getMacAddress()).toString();
InstanceIdentifier<Flow> flowInstanceIidDst = getFlowIid(NwConstants.ELAN_DMAC_TABLE, new FlowId(flowId), DPN1_ID);
awaitForData(LogicalDatastoreType.CONFIGURATION, flowInstanceIidDst);
Flow flowDst = singleTxdataBroker.syncRead(CONFIGURATION, flowInstanceIidDst);
flowDst = getFlowWithoutCookie(flowDst);
Flow expected = ExpectedObjects.checkDmacOfSameDpn(flowId, interfaceInfo, actualElanInstances);
AssertDataObjects.assertEqualBeans(getSortedActions(expected), getSortedActions(flowDst));
}
Aggregations