use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.
the class ElanUtils method updateOperationalDataStore.
/**
* Updates the Elan information in the Operational DS. It also updates the
* ElanInstance in the Config DS by setting the adquired elanTag.
*
* @param idManager
* the id manager
* @param elanInstanceAdded
* the elan instance added
* @param elanInterfaces
* the elan interfaces
* @param operTx
* transaction
*
* @return the updated ELAN instance.
*/
public static ElanInstance updateOperationalDataStore(IdManagerService idManager, ElanInstance elanInstanceAdded, List<String> elanInterfaces, TypedWriteTransaction<Configuration> confTx, TypedWriteTransaction<Operational> operTx) {
String elanInstanceName = elanInstanceAdded.getElanInstanceName();
Uint32 elanTag = elanInstanceAdded.getElanTag();
if (elanTag == null || elanTag.longValue() == 0L) {
elanTag = retrieveNewElanTag(idManager, elanInstanceName);
}
if (elanTag.longValue() == 0L) {
LOG.error("ELAN tag creation failed for elan instance {}. Not updating the ELAN DS. " + "Recreate network for recovery", elanInstanceName);
return null;
}
Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces).withKey(new ElanKey(elanInstanceName)).build();
// Add the ElanState in the elan-state operational data-store
operTx.mergeParentStructurePut(getElanInstanceOperationalDataPath(elanInstanceName), elanInfo);
// Add the ElanMacTable in the elan-mac-table operational data-store
MacTable elanMacTable = new MacTableBuilder().withKey(new MacTableKey(elanInstanceName)).build();
operTx.mergeParentStructurePut(getElanMacTableOperationalDataPath(elanInstanceName), elanMacTable);
ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag).withKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
Uint32 etreeLeafTag = Uint32.valueOf(0L);
if (isEtreeInstance(elanInstanceAdded)) {
etreeLeafTag = retrieveNewElanTag(idManager, elanInstanceName + ElanConstants.LEAVES_POSTFIX);
EtreeLeafTagName etreeLeafTagName = new EtreeLeafTagNameBuilder().setEtreeLeafTag(new EtreeLeafTag(etreeLeafTag)).build();
elanTagNameBuilder.addAugmentation(etreeLeafTagName);
addTheLeafTagAsElanTag(elanInstanceName, etreeLeafTag, operTx);
}
ElanTagName elanTagName = elanTagNameBuilder.build();
// Add the ElanTag to ElanName in the elan-tag-name Operational
// data-store
operTx.put(getElanInfoEntriesOperationalDataPath(elanTag), elanTagName);
// Updates the ElanInstance Config DS by setting the just acquired
// elanTag
ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstanceAdded).setElanInstanceName(elanInstanceName).setDescription(elanInstanceAdded.getDescription()).setMacTimeout(elanInstanceAdded.getMacTimeout() == null ? Uint32.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout()).withKey(elanInstanceAdded.key()).setElanTag(elanTag);
if (isEtreeInstance(elanInstanceAdded)) {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag)).build();
elanInstanceBuilder.addAugmentation(etreeInstance);
}
ElanInstance elanInstanceWithTag = elanInstanceBuilder.build();
LOG.trace("Updated elan Operational DS for elan: {} with elanTag: {} and interfaces: {}", elanInstanceName, elanTag, elanInterfaces);
confTx.mergeParentStructureMerge(ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstanceWithTag);
return elanInstanceWithTag;
}
use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.
the class ElanUtils method deleteMacFlows.
public void deleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
String elanInstanceName = elanInfo.getElanInstanceName();
List<DpnInterfaces> remoteFEs = getInvolvedDpnsInElan(elanInstanceName);
Uint64 srcdpId = interfaceInfo.getDpId();
boolean isFlowsRemovedInSrcDpn = false;
for (DpnInterfaces dpnInterface : remoteFEs) {
Uint32 elanTag = elanInfo.getElanTag();
Uint64 dstDpId = dpnInterface.getDpId();
if (executeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId, elanTag, dstDpId, flowTx)) {
isFlowsRemovedInSrcDpn = true;
}
executeEtreeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId, elanTag, dstDpId, flowTx);
}
if (!isFlowsRemovedInSrcDpn) {
deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, flowTx);
}
}
use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.
the class ElanUtils method deleteSmacAndDmacFlows.
private void deleteSmacAndDmacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
String elanInstanceName = elanInfo.getElanInstanceName();
Uint64 srcdpId = interfaceInfo.getDpId();
Uint32 elanTag = elanInfo.getElanTag();
if (deleteSmac) {
LOG.debug("Deleting SMAC flow with id {}", getKnownDynamicmacFlowRef(elanTag, macAddress));
mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
}
mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
LOG.debug("All the required flows deleted for elan:{}, logical Interface port:{} and MAC address:{} on dpn:{}", elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
}
use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.
the class ElanUtils method deleteSmacFlowOnly.
public void deleteSmacFlowOnly(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
Uint64 srcdpId = interfaceInfo.getDpId();
Uint32 elanTag = elanInfo.getElanTag();
LOG.debug("Deleting SMAC flow with id {}", getKnownDynamicmacFlowRef(elanTag, macAddress));
mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
}
use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.
the class BgpManagerTest method testConnectedRoutNullNextHop.
@Test
public void testConnectedRoutNullNextHop() {
String rd = "101";
String prefix = "10.10.10.10/32";
Uint32 label = Uint32.valueOf(1234);
try {
bgpFibWriter.addFibEntryToDS(rd, /*macAddress*/
prefix, null, VrfEntry.EncapType.Mplsgre, label, Uint32.ZERO, /*l3vni*/
null, /*gatewayMacAddress*/
RouteOrigin.CONNECTED);
// The code is not launching NullPointerException
assertEquals(1, 0);
} catch (NullPointerException e) {
// The code must launch NullPointerException
assertEquals(1, 1);
}
}
Aggregations