use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class ElanServiceTest method checkDmacOfOtherDPN.
@Test
public void checkDmacOfOtherDPN() throws Exception {
// Create Elan instance
createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
awaitForElanTag(ExpectedObjects.ELAN1);
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);
interfaceInfo = ELAN_INTERFACES.get(ELAN1 + ":" + DPN2MAC1).getLeft();
addElanInterface(ExpectedObjects.ELAN1, interfaceInfo, DPN2IP1);
// Read and Compare DMAC flow in DPN1 for MAC1 of DPN2
String flowId = ElanUtils.getKnownDynamicmacFlowRef((short) 51, DPN1_ID, DPN2_ID, interfaceInfo.getMacAddress().toString(), actualElanInstances.getElanTag());
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);
TunnelInterfaceDetails tepDetails = EXTN_INTFS.get(DPN1_ID_STR + ":" + DPN2_ID_STR);
Flow expected = ExpectedObjects.checkDmacOfOtherDPN(flowId, interfaceInfo, tepDetails, actualElanInstances);
AssertDataObjects.assertEqualBeans(getSortedActions(expected), getSortedActions(flowDst));
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class InterfaceHelper method buildInterfaceInfo.
public static InterfaceInfo buildInterfaceInfo(final String interfaceName, final BigInteger dpId, final int portNo, final int lportTag, final String mac, final InterfaceInfo.InterfaceType interfaceType) {
InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
interfaceInfo.setInterfaceName(interfaceName);
interfaceInfo.setDpId(dpId);
interfaceInfo.setPortNo(portNo);
interfaceInfo.setAdminState(InterfaceInfo.InterfaceAdminState.ENABLED);
interfaceInfo.setOpState(InterfaceInfo.InterfaceOpState.UP);
interfaceInfo.setInterfaceTag(lportTag);
interfaceInfo.setInterfaceType(interfaceType);
interfaceInfo.setGroupId(0);
interfaceInfo.setMacAddress(mac);
return interfaceInfo;
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.
the class PolicyServiceUtil method getLogicalTunnelLportTag.
public Optional<Integer> getLogicalTunnelLportTag(BigInteger srcDpId, BigInteger dstDpId) {
Optional<String> logicalTunnelNameOpt = getLogicalTunnelName(srcDpId, dstDpId);
if (!logicalTunnelNameOpt.isPresent()) {
LOG.debug("Failed to get logical tunnel for source DPN {} dst DPN {}", srcDpId, dstDpId);
return Optional.absent();
}
String logicalTunnelName = logicalTunnelNameOpt.get();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(logicalTunnelName);
if (interfaceInfo == null) {
LOG.debug("Failed to get interface info for logical tunnel {}", logicalTunnelName);
return Optional.absent();
}
return Optional.of(interfaceInfo.getInterfaceTag());
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.
the class TestInterfaceManager method addTunnelInterface.
public void addTunnelInterface(TunnelInterfaceDetails tunnelInterfaceDetails) throws TransactionCommitFailedException {
InterfaceInfo interfaceInfo = tunnelInterfaceDetails.getInterfaceInfo();
interfaceInfos.put(interfaceInfo.getInterfaceName(), interfaceInfo);
if (optDataBroker.isPresent()) {
// Can't use ifPresent() here because of checked exception from tx.submit().checkedGet();
DataBroker dataBroker = optDataBroker.get();
Interface iface = InterfaceHelper.buildVxlanTunnelInterfaceFromInfo(tunnelInterfaceDetails);
ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
tx.put(LogicalDatastoreType.CONFIGURATION, InterfaceHelper.buildIId(interfaceInfo.getInterfaceName()), iface);
tx.put(LogicalDatastoreType.OPERATIONAL, InterfaceStateHelper.buildStateInterfaceIid(interfaceInfo.getInterfaceName()), InterfaceStateHelper.buildStateFromInterfaceInfo(interfaceInfo));
tx.submit().checkedGet();
externalInterfaces.put(interfaceInfo.getInterfaceName(), true);
addInterface(iface);
}
}
use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.
the class ItmTunnelAggregationHelper method updateTunnelAggregationGroupBucket.
private void updateTunnelAggregationGroupBucket(Interface ifaceState, IfTunnel ifTunnel, ParentRefs parentRefs, InterfaceParentEntry groupParentEntry, int action, WriteTransaction tx) {
String logicTunnelName = parentRefs.getParentInterface();
List<InterfaceChildEntry> interfaceChildEntries = groupParentEntry.getInterfaceChildEntry();
if (interfaceChildEntries == null) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: empty child list in group {}", groupParentEntry.getParentInterface());
return;
}
String ifaceName = ifaceState.getName();
InterfaceChildEntry childEntry = new InterfaceChildEntryBuilder().setChildInterface(ifaceName).setKey(new InterfaceChildEntryKey(ifaceName)).build();
int bucketId = interfaceChildEntries.indexOf(childEntry);
if (bucketId == -1) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: wrong child id for {} in group {}", ifaceName, groupParentEntry.getParentInterface());
return;
}
InterfaceInfo ifLogicTunnel = interfaceManager.getInterfaceInfoFromOperationalDataStore(logicTunnelName);
long groupId = ifLogicTunnel != null ? interfaceManager.getLogicalTunnelSelectGroupId(ifLogicTunnel.getInterfaceTag()) : INVALID_ID;
if (groupId == INVALID_ID) {
LOG.warn("MULTIPLE_VxLAN_TUNNELS: unknown group id for logic tunnel {}", logicTunnelName);
return;
}
// openflow:dpnid:portnum
String lowerLayerIf = ifaceState.getLowerLayerIf().get(0);
String[] split = lowerLayerIf.split(IfmConstants.OF_URI_SEPARATOR);
BigInteger srcDpnId = new BigInteger(split[1]);
int portNumber = Integer.parseInt(split[2]);
if (action == ADD_TUNNEL) {
if (!mdsalManager.groupExists(srcDpnId, groupId)) {
createLogicalTunnelSelectGroup(srcDpnId, logicTunnelName, ifLogicTunnel.getInterfaceTag());
}
Bucket buckt = createBucket(ifaceName, ifTunnel, bucketId, portNumber);
LOG.debug("MULTIPLE_VxLAN_TUNNELS: add bucketId {} to groupId {}", bucketId, groupId);
mdsalManager.addBucketToTx(srcDpnId, groupId, buckt, tx);
} else {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: remove bucketId {} from groupId {}", bucketId, groupId);
mdsalManager.removeBucketToTx(srcDpnId, groupId, bucketId, tx);
}
}
Aggregations