use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepMoveFromTepsNotHostedListToTzTest.
@Test
public void tepMoveFromTepsNotHostedListToTzTest() throws Exception {
// add into not hosted list
CheckedFuture<Void, TransactionCommitFailedException> future = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME, false, dataBroker);
future.get();
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath = ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(notHostedPath);
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).checkedGet().get());
// create the same TZ
TransportZone transportZoneNorth = new TransportZoneBuilder().setZoneName(ItmTestConstants.NOT_HOSTED_TZ_NAME).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setKey(new TransportZoneKey(ItmTestConstants.NOT_HOSTED_TZ_NAME)).build();
Assert.assertNotNull(transportZoneNorth);
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.NOT_HOSTED_TZ_NAME), transportZoneNorth, dataBroker);
// wait for TransportZoneListener to perform config DS update
// for TEP movement through transaction
Thread.sleep(1000);
InstanceIdentifier<TransportZone> tzPath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(tzPath);
// check TZ is Moved
assertEqualBeans(String.valueOf(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone().getUnknownVteps().get(0).getIpAddress().getValue()), String.valueOf(dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzPath).checkedGet().get().getSubnets().get(0).getVteps().get(0).getIpAddress().getValue()));
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone().getUnknownVteps().get(0).getDpnId(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzPath).checkedGet().get().getSubnets().get(0).getVteps().get(0).getDpnId());
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone().getZoneName(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzPath).checkedGet().get().getZoneName());
// check TZ is removed
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone 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.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone in project genius by opendaylight.
the class ItmTepAutoConfigTest method tzAddDeleteToNotHostedViaSouthboundTest.
@Test
public void tzAddDeleteToNotHostedViaSouthboundTest() throws Exception {
// create Network topology node
ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, ItmTestConstants.NOT_HOSTED_TZ_NAME, dataBroker);
future.get();
// add bridge into node
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.NOT_HOSTED_DEF_BR_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedtzPath = ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(notHostedtzPath);
// check not hosted
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).checkedGet().get());
future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, null, ItmTestConstants.DEF_BR_NAME, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).get());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone in project genius by opendaylight.
the class OvsdbTepAddConfigHelper method addUnknownTzTepIntoTepsNotHosted.
/**
* Adds the TEP into Vtep list in the subnet list in the transport zone list
* from ITM operational Datastore by merge operation with write transaction.
*
* @param tzName transport zone name in string
* @param tepIpAddress TEP IP address in IpAddress object
* @param dpid bridge datapath ID in BigInteger
* @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
* @param dataBroker data broker handle to perform operations on operational datastore
* @param wrTx WriteTransaction object
*/
protected static void addUnknownTzTepIntoTepsNotHosted(String tzName, IpAddress tepIpAddress, BigInteger dpid, boolean ofTunnel, 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.", tzName);
vtepList = new ArrayList<>();
addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
} else {
vtepList = tepsInNotHostedTransportZone.getUnknownVteps();
if (vtepList == null || vtepList.isEmpty()) {
// case: vtep list does not exist or it has no elements
if (vtepList == null) {
vtepList = new ArrayList<>();
}
LOG.trace("Add TEP into unhosted TZ ({}) when no vtep-list in the TZ.", tzName);
addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
} else {
// case: vtep list has elements
boolean vtepFound = false;
UnknownVteps oldVtep = null;
for (UnknownVteps vtep : vtepList) {
if (vtep.getDpnId().equals(dpid)) {
vtepFound = true;
oldVtep = vtep;
break;
}
}
if (!vtepFound) {
addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
} else {
// vtep is found, update it with tep-ip
vtepList.remove(oldVtep);
addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone in project genius by opendaylight.
the class OvsdbTepAddConfigHelper method addVtepIntoTepsNotHosted.
/**
* Adds the TEP into Unknown Vtep list under the transport zone in the TepsNotHosted list
* from ITM operational Datastore by merge operation with write transaction.
*
* @param updatedVtepList updated UnknownVteps list object which will have new TEP for addition
* into TepsNotHosted
* @param tepIpAddress TEP IP address in IpAddress object
* @param tzName transport zone name in string
* @param dpid bridge datapath ID in BigInteger
* @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
* @param wrTx WriteTransaction object
*/
protected static void addVtepIntoTepsNotHosted(List<UnknownVteps> updatedVtepList, IpAddress tepIpAddress, String tzName, BigInteger dpid, boolean ofTunnel, WriteTransaction wrTx) {
// Create TZ node path
InstanceIdentifier<TepsInNotHostedTransportZone> tepsInNotHostedTransportZoneIid = InstanceIdentifier.builder(NotHostedTransportZones.class).child(TepsInNotHostedTransportZone.class, new TepsInNotHostedTransportZoneKey(tzName)).build();
// create vtep
UnknownVtepsKey vtepkey = new UnknownVtepsKey(dpid);
UnknownVteps vtepObj = new UnknownVtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).setKey(vtepkey).setOfTunnel(ofTunnel).build();
// Add vtep obtained into unknown TZ tep list
updatedVtepList.add(vtepObj);
// create unknown TZ node with updated vtep list
TepsInNotHostedTransportZone updatedTzone = new TepsInNotHostedTransportZoneBuilder().setKey(new TepsInNotHostedTransportZoneKey(tzName)).setZoneName(tzName).setUnknownVteps(updatedVtepList).build();
LOG.trace("Adding TEP (DPID: {}, TEP IP: {}, of-tunnel: {}) into unhosted TZ: {}" + "inside ITM Oper DS.", dpid, tepIpAddress, ofTunnel, tzName);
// Update TZ in Oper DS.
wrTx.merge(LogicalDatastoreType.OPERATIONAL, tepsInNotHostedTransportZoneIid, updatedTzone, true);
}
Aggregations