use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepUpdateForBrNameTest.
@Test
public void tepUpdateForBrNameTest() throws Exception {
// create Transport-zone in advance
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, tzonesPath, transportZones, dataBroker);
String tepIp = ItmTestConstants.NB_TZ_TEP_IP;
// prepare OVSDB node with tep-ip set into ExternalIds list
// OvsdbNodeListener would be automatically listen on Node to add TEP
ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, tepIp, ItmTestConstants.TZ_NAME, dataBroker);
future.get();
// add bridge into node
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.DEF_BR_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TEP is added into TZ
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(oldVTepPath);
// add new bridge br2
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.BR2_NAME, ItmTestConstants.BR2_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
// update OVSDB node with br-name=br2 in ExternalIds column
String brName = ItmTestConstants.BR2_NAME;
future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NB_TZ_TEP_IP, ItmTestConstants.TZ_NAME, brName, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
InstanceIdentifier<Vteps> newVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_BR2_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(newVTepPath);
// check old TEP having default-bridge-DPID is deleted
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
// check TEP is updated with dpnId of br2 when br-name is updated to br2 from southbound
Assert.assertEquals(ItmTestConstants.INT_BR2_DPID, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, newVTepPath).checkedGet().get().getDpnId());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.
the class OvsdbTepRemoveConfigHelper method removeUnknownTzTepFromTepsNotHosted.
/**
* Removes the TEP from the not-hosted transport zone in the TepsNotHosted list
* from ITM Operational Datastore.
*
* @param tzName transport zone name in string
* @param tepIpAddress TEP IP address in IpAddress object
* @param dpnId bridge datapath ID in BigInteger
* @param dataBroker data broker handle to perform operations on operational datastore
* @param wrTx WriteTransaction object
*/
public static void removeUnknownTzTepFromTepsNotHosted(String tzName, IpAddress tepIpAddress, BigInteger dpnId, DataBroker dataBroker, WriteTransaction wrTx) {
List<UnknownVteps> vtepList = null;
TepsInNotHostedTransportZone tepsInNotHostedTransportZone = ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
if (tepsInNotHostedTransportZone == null) {
LOG.trace("Unhosted TransportZone ({}) does not exist in OperDS. Nothing to do for TEP removal.", tzName);
return;
} else {
vtepList = tepsInNotHostedTransportZone.getUnknownVteps();
if (vtepList == null || vtepList.isEmpty()) {
// case: vtep list does not exist or it has no elements
LOG.trace("Remove TEP from unhosted TZ ({}) when no vtep-list in the TZ. Nothing to do.", tzName);
} else {
// case: vtep list has elements
boolean vtepFound = false;
UnknownVteps foundVtep = null;
for (UnknownVteps vtep : vtepList) {
if (vtep.getDpnId().equals(dpnId)) {
vtepFound = true;
foundVtep = vtep;
break;
}
}
if (vtepFound) {
// vtep is found, update it with tep-ip
LOG.trace("Remove TEP with IP ({}) from unhosted TZ ({}) inside not-hosted-transport-zones list.", tepIpAddress, tzName);
if (vtepList.size() == 1) {
removeTzFromTepsNotHosted(tzName, wrTx);
} else {
removeVtepFromTepsNotHosted(tzName, dpnId, wrTx);
}
vtepList.remove(foundVtep);
}
}
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.
the class TepCommandHelper method showState.
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void showState(Collection<StateTunnelList> tunnelLists, boolean tunnelMonitorEnabled, CommandSession session) throws TepException {
if (tunnelLists == null || tunnelLists.isEmpty()) {
handleError("No Internal Tunnels Exist", session);
return;
}
if (!tunnelMonitorEnabled) {
if (session != null) {
session.getConsole().println("Tunnel Monitoring is Off");
}
}
String displayFormat = "%-16s %-16s %-16s %-16s %-16s %-10s %-10s";
System.out.println(String.format(displayFormat, "Tunnel Name", "Source-DPN", "Destination-DPN", "Source-IP", "Destination-IP", "Trunk-State", "Transport Type"));
System.out.println("-----------------------------------------------------------------------------------------" + "--------------------------------------------");
for (StateTunnelList tunnelInst : tunnelLists) {
// Display only the internal tunnels
if (tunnelInst.getDstInfo().getTepDeviceType().equals(TepTypeInternal.class)) {
String tunnelInterfaceName = tunnelInst.getTunnelInterfaceName();
LOG.trace("tunnelInterfaceName::: {}", tunnelInterfaceName);
String tunnelState = ITMConstants.TUNNEL_STATE_UNKNOWN;
if (tunnelInst.getOperState() == TunnelOperStatus.Up) {
tunnelState = ITMConstants.TUNNEL_STATE_UP;
} else if (tunnelInst.getOperState() == TunnelOperStatus.Down) {
tunnelState = ITMConstants.TUNNEL_STATE_DOWN;
}
Class<? extends TunnelTypeBase> tunType = tunnelInst.getTransportType();
String tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
if (tunType.equals(TunnelTypeVxlan.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
} else if (tunType.equals(TunnelTypeGre.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_GRE;
} else if (tunType.equals(TunnelTypeMplsOverGre.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_MPLSoGRE;
} else if (tunType.equals(TunnelTypeLogicalGroup.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
}
System.out.println(String.format(displayFormat, tunnelInst.getTunnelInterfaceName(), tunnelInst.getSrcInfo().getTepDeviceId(), tunnelInst.getDstInfo().getTepDeviceId(), new String(tunnelInst.getSrcInfo().getTepIp().getValue()), new String(tunnelInst.getDstInfo().getTepIp().getValue()), tunnelState, tunnelType));
}
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport 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.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project controller by opendaylight.
the class MdsalLowLevelTestProvider method unsubscribeDtcl.
@Override
public Future<RpcResult<UnsubscribeDtclOutput>> unsubscribeDtcl() {
LOG.debug("Received unsubscribe-dtcl");
if (idIntsListener == null || dtclReg == null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Dtcl missing.", "No DataTreeChangeListener registered.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
try {
idIntsListener.tryFinishProcessing().get(120, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "resource-denied-transport", "Unable to finish notification processing in 120 seconds.", "clustering-it", "clustering-it", e);
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
dtclReg.close();
dtclReg = null;
if (!idIntsListener.hasTriggered()) {
final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received" + "any notifications.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
final DOMDataReadOnlyTransaction rTx = domDataBroker.newReadOnlyTransaction();
try {
final Optional<NormalizedNode<?, ?>> readResult = rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID).checkedGet();
if (!readResult.isPresent()) {
final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Final read empty.", "No data read from id-ints list.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
return Futures.immediateFuture(RpcResultBuilder.success(new UnsubscribeDtclOutputBuilder().setCopyMatches(idIntsListener.checkEqual(readResult.get()))).build());
} catch (final ReadFailedException e) {
final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Read failed.", "Final read from id-ints failed.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
}
Aggregations