use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.Config in project genius by opendaylight.
the class TepCommandHelper method buildTeps.
@SuppressWarnings("checkstyle:IllegalCatch")
public void buildTeps() {
TransportZones transportZonesBuilt = null;
TransportZone transportZone = null;
try {
LOG.debug("no of teps added {}", CHECK);
if (transportZonesHashMap != null && !transportZonesHashMap.isEmpty()) {
transportZoneArrayList = new ArrayList<>();
for (Entry<String, Map<SubnetObject, List<Vteps>>> mapEntry : transportZonesHashMap.entrySet()) {
String tz = mapEntry.getKey();
LOG.debug("transportZonesHashMap {}", tz);
subnetList = new ArrayList<>();
Map<SubnetObject, List<Vteps>> subVtepMapTemp = mapEntry.getValue();
for (Entry<SubnetObject, List<Vteps>> entry : subVtepMapTemp.entrySet()) {
SubnetObject subOb = entry.getKey();
LOG.debug("subnets {}", subOb.get_prefix());
List<Vteps> vtepList = entry.getValue();
Subnets subnet = new SubnetsBuilder().setGatewayIp(subOb.get_gatewayIp()).setKey(subOb.get_key()).setPrefix(subOb.get_prefix()).setVlanId(subOb.get_vlanId()).setVteps(vtepList).build();
subnetList.add(subnet);
LOG.debug("vteps {}", vtepList);
}
InstanceIdentifier<TransportZone> transportZonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tz)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, transportZonePath, dataBroker);
LOG.debug("read container from DS");
if (transportZoneOptional.isPresent()) {
TransportZone tzoneFromDs = transportZoneOptional.get();
LOG.debug("read tzone container {}", tzoneFromDs);
if (tzoneFromDs.getTunnelType() == null || tzoneFromDs.getTunnelType().equals(TunnelTypeVxlan.class)) {
transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList).setZoneName(tz).build();
} else if (tzoneFromDs.getTunnelType().equals(TunnelTypeGre.class)) {
transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeGre.class).setSubnets(subnetList).setZoneName(tz).build();
}
} else {
transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList).setZoneName(tz).build();
}
LOG.debug("tzone object {}", transportZone);
transportZoneArrayList.add(transportZone);
}
transportZonesBuilt = new TransportZonesBuilder().setTransportZone(transportZoneArrayList).build();
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
LOG.debug("InstanceIdentifier {}", path);
ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, transportZonesBuilt, dataBroker, ItmUtils.DEFAULT_CALLBACK);
LOG.debug("wrote to Config DS {}", transportZonesBuilt);
transportZonesHashMap.clear();
transportZoneArrayList.clear();
subnetList.clear();
LOG.debug("Everything cleared");
} else {
LOG.debug("NO vteps were configured");
}
} catch (RuntimeException e) {
LOG.error("Error building TEPs", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.Config in project genius by opendaylight.
the class DpnTepStateCache method removeTepFromDpnTepInterfaceConfigDS.
public void removeTepFromDpnTepInterfaceConfigDS(BigInteger srcDpnId) throws TransactionCommitFailedException {
Collection<DpnsTeps> dpnsTeps = this.getAllPresent();
for (DpnsTeps dpnTep : dpnsTeps) {
if (!dpnTep.getSourceDpnId().equals(srcDpnId)) {
List<RemoteDpns> remoteDpns = dpnTep.getRemoteDpns();
for (RemoteDpns remoteDpn : remoteDpns) {
if (remoteDpn.getDestinationDpnId().equals(srcDpnId)) {
// Remote the SrcDpnId from the remote List. Remove it from COnfig DS. 4
// This will be reflected in cache by the ClusteredDTCN. Not removing it here !
// Caution :- Batching Delete !!
InstanceIdentifier<RemoteDpns> remoteDpnII = buildRemoteDpnsInstanceIdentifier(dpnTep.getSourceDpnId(), remoteDpn.getDestinationDpnId());
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, remoteDpnII);
break;
}
}
} else {
// The source DPn id is the one to be removed
InstanceIdentifier<DpnsTeps> dpnsTepsII = buildDpnsTepsInstanceIdentifier(dpnTep.getSourceDpnId());
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, dpnsTepsII);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.Config in project genius by opendaylight.
the class TepCommandHelper method validateForDuplicates.
/**
* Validate for duplicates.
*
* @param inputVtep
* the input vtep
* @param transportZone
* the transport zone
*/
public void validateForDuplicates(Vteps inputVtep, String transportZone) {
Map<String, TransportZone> allTransportZonesAsMap = getAllTransportZonesAsMap();
boolean isConfiguredTepGreType = isGreTunnelType(transportZone, allTransportZonesAsMap);
// Checking for duplicates in local cache
for (Entry<String, Map<SubnetObject, List<Vteps>>> entry : transportZonesHashMap.entrySet()) {
String tz = entry.getKey();
boolean isGreType = isGreTunnelType(tz, allTransportZonesAsMap);
Map<SubnetObject, List<Vteps>> subVtepMapTemp = entry.getValue();
for (List<Vteps> vtepList : subVtepMapTemp.values()) {
validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
}
}
// Checking for duplicates in config DS
for (TransportZone tz : allTransportZonesAsMap.values()) {
boolean isGreType = false;
if (tz.getTunnelType().equals(TunnelTypeGre.class)) {
isGreType = true;
}
for (Subnets sub : ItmUtils.emptyIfNull(tz.getSubnets())) {
List<Vteps> vtepList = sub.getVteps();
validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.Config in project genius by opendaylight.
the class InterfaceMetaUtils method getBridgeEntryFromConfigDS.
public BridgeEntry getBridgeEntryFromConfigDS(BigInteger dpnId) {
BridgeEntry bridgeEntry = getBridgeEntryFromCache(dpnId);
if (bridgeEntry != null) {
return bridgeEntry;
}
BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier = InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
LOG.debug("Trying to retrieve bridge entry from config for Id: {}", bridgeEntryInstanceIdentifier);
bridgeEntry = readBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier);
if (bridgeEntry != null) {
addBridgeEntryToCache(dpnId, bridgeEntry);
}
return bridgeEntry;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.Config in project controller by opendaylight.
the class DsbenchmarkProvider method startTest.
@Override
public Future<RpcResult<StartTestOutput>> startTest(final StartTestInput input) {
LOG.info("Starting the data store benchmark test, input: {}", input);
// Check if there is a test in progress
if (execStatus.compareAndSet(ExecStatus.Idle, ExecStatus.Executing) == false) {
LOG.info("Test in progress");
return RpcResultBuilder.success(new StartTestOutputBuilder().setStatus(StartTestOutput.Status.TESTINPROGRESS).build()).buildFuture();
}
// Cleanup data that may be left over from a previous test run
cleanupTestStore();
// Get the appropriate writer based on operation type and data format
DatastoreAbstractWriter dsWriter = getDatastoreWriter(input);
// Create listeners on OPERATIONAL and CONFIG test data subtrees
listenerProvider.createAndRegisterListeners(input.getListeners().intValue());
long startTime, endTime, listCreateTime, execTime;
startTime = System.nanoTime();
dsWriter.createList();
endTime = System.nanoTime();
listCreateTime = (endTime - startTime) / 1000;
// Run the test and measure the execution time
try {
startTime = System.nanoTime();
dsWriter.executeList();
endTime = System.nanoTime();
execTime = (endTime - startTime) / 1000;
this.testsCompleted++;
} catch (final Exception e) {
LOG.error("Test error: {}", e.toString());
execStatus.set(ExecStatus.Idle);
return RpcResultBuilder.success(new StartTestOutputBuilder().setStatus(StartTestOutput.Status.FAILED).build()).buildFuture();
}
LOG.info("Test finished");
setTestOperData(ExecStatus.Idle, testsCompleted);
execStatus.set(ExecStatus.Idle);
// Get the number of data change events and cleanup the data change listeners
long numDataChanges = listenerProvider.getDataChangeCount();
long numEvents = listenerProvider.getEventCountAndDestroyListeners();
StartTestOutput output = new StartTestOutputBuilder().setStatus(StartTestOutput.Status.OK).setListBuildTime(listCreateTime).setExecTime(execTime).setTxOk((long) dsWriter.getTxOk()).setNtfOk(numEvents).setDataChangeEventsOk(numDataChanges).setTxError((long) dsWriter.getTxError()).build();
return RpcResultBuilder.success(output).buildFuture();
}
Aggregations