use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.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
* @param dataBroker data broker handle to perform operations on operational datastore
* @param tx TypedWriteTransaction object
*/
public static void removeUnknownTzTepFromTepsNotHosted(String tzName, IpAddress tepIpAddress, Uint64 dpnId, DataBroker dataBroker, TypedWriteTransaction<Datastore.Operational> tx) {
Map<UnknownVtepsKey, UnknownVteps> vtepList;
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;
for (UnknownVteps vtep : vtepList.values()) {
if (Objects.equals(vtep.getDpnId(), dpnId)) {
vtepFound = true;
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, tx);
} else {
removeVtepFromTepsNotHosted(tzName, dpnId, tx);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class OvsdbTepRemoveConfigHelper method removeVtepFromTepsNotHosted.
/**
* Removes the TEP from unknown vtep list under the transport zone in the TepsNotHosted list
* from ITM operational Datastore by delete operation with write transaction.
*
* @param tzName transport zone name in string
* @param dpnId bridge datapath ID
* @param tx TypedWriteTransaction object
*/
private static void removeVtepFromTepsNotHosted(String tzName, Uint64 dpnId, TypedWriteTransaction<Datastore.Operational> tx) {
InstanceIdentifier<UnknownVteps> vtepPath = InstanceIdentifier.builder(NotHostedTransportZones.class).child(TepsInNotHostedTransportZone.class, new TepsInNotHostedTransportZoneKey(tzName)).child(UnknownVteps.class, new UnknownVtepsKey(dpnId)).build();
LOG.trace("Removing TEP from unhosted (TZ: {}, DPID: {}) inside ITM Oper DS.", tzName, dpnId);
tx.delete(vtepPath);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepUpdateForTzTest.
@Ignore
public void tepUpdateForTzTest() throws Exception {
// wait for start-up default-TZ creation task to get over
coordinatorEventsWaiter.awaitEventsConsumption();
String tepIp = ItmTestConstants.DEF_TZ_TEP_IP;
// create Network topology 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);
FluentFuture<? extends @NonNull CommitInfo> future = OvsdbTestUtil.createNode(connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE, 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
coordinatorEventsWaiter.awaitEventsConsumption();
// iid for default-TZ
InstanceIdentifier<TransportZone> defTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(defTzonePath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, defTzonePath).get().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(oldVTepPath);
// create Transport-zone TZA
InstanceIdentifier<TransportZone> tzPath = ItmUtils.getTZInstanceIdentifier(ItmTestConstants.TZ_NAME);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, transportZone)).get();
// iid for TZA configured from NB
InstanceIdentifier<TransportZone> tzaTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzaTzonePath);
// update OVSDB node with tzname=TZA in ExternalIds list
String tzName = ItmTestConstants.TZ_NAME;
future = OvsdbTestUtil.updateNode(connInfo, tepIp, tzName, null, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// check old TEP which was in default-TZ is deleted
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
// check TEP is updated and now it is added into TZA transport-zone when tzname is updated
// to TZA from southbound
assertEqualBeans(ExpectedTransportZoneObjects.updatedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzaTzonePath).get().get());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmTepAutoConfigTest method tzReaddWithSameVtepsAndDiffDpnIDTest.
@Test
public void tzReaddWithSameVtepsAndDiffDpnIDTest() throws Exception {
// create TZ
InstanceIdentifier<TransportZone> tzPath = ItmUtils.getTZInstanceIdentifier(ItmTestConstants.TZ_NAME);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, transportZone)).get();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TZ is created
Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get().getZoneName());
// add tep
ListenableFuture<?> futures = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NB_TZ_TEP_IP, ItmTestConstants.DEF_BR_DPID, ItmTestConstants.TZ_NAME, false, dataBroker, txRunner);
futures.get();
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// check TEP is added into TZ that is already created.
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get());
// remove Transport Zone
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(tzPath));
// wait for TransportZoneListener to perform config DS update
// for TEP movement through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// verify delete
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
// check deleted tz moved to notHosted
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath = ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(notHostedPath);
Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get().get().getZoneName());
// create vtepList form unknownVtepList
List<Vteps> vtepsList = new ArrayList<>();
@Nullable Map<UnknownVtepsKey, UnknownVteps> unknownVtepsList = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get().get().getUnknownVteps();
// modifing the dpnid and keeping the ip same.
for (UnknownVteps unknownVtep : unknownVtepsList.values()) {
Vteps vteps = new VtepsBuilder().setDpnId(Uint64.valueOf(10)).setIpAddress(unknownVtep.getIpAddress()).withKey(new VtepsKey(Uint64.valueOf(10))).build();
vtepsList.add(vteps);
}
TransportZone recreatedTransportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setVteps(vtepsList).withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).build();
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, recreatedTransportZone)).get();
// wait for TransportZoneListener to perform config DS update
// for TEP movement through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// verify TZ is moved from notHosted to transport zone and their should be only one vtep in it.
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
assertEqualBeans(1, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get().getVteps().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmTepAutoConfigTest method tzDeletedAndReaddedWithSameVtepsTest.
@Test
@Ignore
public void tzDeletedAndReaddedWithSameVtepsTest() throws Exception {
// create TZ
InstanceIdentifier<TransportZone> tzPath = ItmUtils.getTZInstanceIdentifier(ItmTestConstants.TZ_NAME);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, transportZone)).get();
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TZ is created
Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get().getZoneName());
// add tep
ListenableFuture<?> futures = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NB_TZ_TEP_IP, ItmTestConstants.DEF_BR_DPID, ItmTestConstants.TZ_NAME, false, dataBroker, txRunner);
futures.get();
coordinatorEventsWaiter.awaitEventsConsumption();
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// check TEP is added into TZ that is already created.
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get());
// remove Transport Zone
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(tzPath));
// wait for TransportZoneListener to perform config DS update
// for TEP movement through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// verify delete
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
// check deleted tz moved to notHosted
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath = ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.TZ_NAME);
coordinatorEventsWaiter.awaitEventsConsumption();
Assert.assertNotNull(notHostedPath);
Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get().get().getZoneName());
// create vtepList form unknownVtepList
List<Vteps> vtepsList = new ArrayList<>();
@Nullable Map<UnknownVtepsKey, UnknownVteps> unknownVtepsList = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get().get().getUnknownVteps();
for (UnknownVteps unknownVtep : unknownVtepsList.values()) {
Vteps vteps = new VtepsBuilder().setDpnId(unknownVtep.getDpnId()).setIpAddress(unknownVtep.getIpAddress()).withKey(new VtepsKey(unknownVtep.getDpnId())).build();
vtepsList.add(vteps);
}
TransportZone recreatedTransportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setVteps(vtepsList).withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).build();
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, recreatedTransportZone)).get();
// wait for TransportZoneListener to perform config DS update
// for TEP movement through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// verify TZ is moved from notHosted to transport zone and their should be only one vtep in it.
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
assertEqualBeans(1, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get().getVteps().size());
}
Aggregations