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 OvsdbTepAddConfigHelper method addVtepToUnknownVtepsList.
private static Map<UnknownVtepsKey, UnknownVteps> addVtepToUnknownVtepsList(Map<UnknownVtepsKey, UnknownVteps> updatedVtepList, IpAddress tepIpAddress, Uint64 dpid, boolean ofTunnel) {
// create vtep
UnknownVtepsKey vtepkey = new UnknownVtepsKey(dpid);
UnknownVteps vtepObj = new UnknownVtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).withKey(vtepkey).setOfTunnel(ofTunnel).build();
// Add vtep obtained into unknown TZ tep list
updatedVtepList.put(vtepObj.key(), vtepObj);
LOG.trace("Adding TEP (DPID: {}, TEP IP: {}, of-tunnel: {}) into unhosted Transport Zone" + "inside ITM Oper DS.", dpid, tepIpAddress, ofTunnel);
return updatedVtepList;
}
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 OvsdbTepAddConfigHelper method addTepReceivedFromOvsdb.
/**
* Adds the TEP into ITM configuration/operational Datastore in one of the following cases.
* 1) default transport zone
* 2) Configured transport zone
* 3) Unhosted transport zone
*
* @param tepIp TEP-IP address in string
* @param strDpnId bridge datapath ID in string
* @param tzName transport zone name in string
* @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
* @param dataBroker data broker handle to perform operations on config/operational datastore
* @param txRunner ManagedTransactionRunner object
*/
public static List<? extends ListenableFuture<?>> addTepReceivedFromOvsdb(String tepIp, String strDpnId, String tzName, boolean ofTunnel, DataBroker dataBroker, ManagedNewTransactionRunner txRunner) throws Exception {
Uint64 dpnId = Uint64.ZERO;
if (strDpnId != null && !strDpnId.isEmpty()) {
dpnId = MDSALUtil.getDpnId(strDpnId);
}
// Get tep IP
IpAddress tepIpAddress = IpAddressBuilder.getDefaultInstance(tepIp);
TransportZone tzone = null;
// check if TEP received is already present in any other TZ.
TransportZone transportZone = ItmUtils.getTransportZoneOfVtep(dpnId, dataBroker);
if (transportZone != null) {
LOG.trace("Vtep (tep-ip: {} and dpid: {}) is already present in transport-zone: {}", tepIpAddress, dpnId, transportZone.getZoneName());
if (!transportZone.getZoneName().equals(tzName)) {
// remove TEP from TZ because TZ is updated for TEP from southbound in this case
OvsdbTepRemoveWorker ovsdbTepRemoveWorkerObj = new OvsdbTepRemoveWorker(tepIp, strDpnId, transportZone.getZoneName(), dataBroker);
ovsdbTepRemoveWorkerObj.call();
}
}
// Case: TZ name is not given with OVS TEP.
if (tzName == null) {
tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
// add TEP into default-TZ
tzone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (tzone == null) {
// Case: default-TZ is not yet created, then add TEP into "teps-in-not-hosted-transport-zone"
LOG.trace("Adding TEP with default TZ into teps-in-not-hosted-transport-zone.");
return addUnknownTzTepIntoTepsNotHostedAndReturnFutures(tzName, tepIpAddress, dpnId, ofTunnel, dataBroker, txRunner);
}
LOG.trace("Add TEP into default-transport-zone.");
} else {
// Case: Add TEP into corresponding TZ created from Northbound.
tzone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (tzone == null) {
// Case: TZ is not configured from Northbound, then add TEP into "teps-in-not-hosted-transport-zone"
LOG.trace("Adding TEP with unknown TZ into teps-in-not-hosted-transport-zone.");
return addUnknownTzTepIntoTepsNotHostedAndReturnFutures(tzName, tepIpAddress, dpnId, ofTunnel, dataBroker, txRunner);
} else {
LOG.trace("Add TEP into transport-zone already configured by Northbound.");
}
}
List<ListenableFuture<?>> futures = new ArrayList<>();
final Uint64 id = dpnId;
final String name = tzName;
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> addConfig(name, id, tepIpAddress, ofTunnel, tx)));
return futures;
}
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 removeVtepFromTZConfig.
/**
* Removes the TEP from subnet list in the transport zone list
* from ITM configuration Datastore by delete operation with write transaction.
*
* @param dpnId bridge datapath ID
* @param tzName transport zone name in string
* @param tx TypedWriteTransaction object
*/
private static void removeVtepFromTZConfig(String tzName, Uint64 dpnId, TypedWriteTransaction<Datastore.Configuration> tx) {
VtepsKey vtepkey = new VtepsKey(dpnId);
InstanceIdentifier<Vteps> vtepPath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).child(Vteps.class, vtepkey).build();
LOG.trace("Removing TEP from (TZ: {} DPN-ID: {}) inside ITM Config DS.", tzName, dpnId);
// remove vtep
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 OvsdbTepRemoveConfigHelper method removeTepReceivedFromOvsdb.
/**
* Removes the TEP from ITM configuration/operational Datastore in one of the following cases.
* 1) default transport zone
* 2) Configured transport zone
* 3) Unhosted transport zone
* Function checks for above three cases and calls other sub-function to remove the TEP
*
* @param tepIp TEP-IP address in string
* @param strDpnId bridge datapath ID in string
* @param tzName transport zone name in string
* @param dataBroker data broker handle to perform operations on config/operational datastore
* @param txRunner ManagedNewTransactionRunner object
*/
public static List<? extends ListenableFuture<?>> removeTepReceivedFromOvsdb(String tepIp, String strDpnId, String tzName, DataBroker dataBroker, ManagedNewTransactionRunner txRunner) {
List<ListenableFuture<?>> futures = new ArrayList<>();
Uint64 dpnId = Uint64.ZERO;
LOG.trace("Remove TEP: TEP-IP: {}, TZ name: {}, DPID: {}", tepIp, tzName, strDpnId);
if (strDpnId != null && !strDpnId.isEmpty()) {
dpnId = MDSALUtil.getDpnId(strDpnId);
}
// Get tep IP
IpAddress tepIpAddress = IpAddressBuilder.getDefaultInstance(tepIp);
TransportZone transportZone;
// Case: TZ name is not given from OVS's other_config parameters.
if (tzName == null) {
tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
// add TEP into default-TZ
transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (transportZone == null) {
LOG.error("Error: default-transport-zone is not yet created.");
return futures;
}
LOG.trace("Remove TEP from default-transport-zone.");
} else {
// Case: Add TEP into corresponding TZ created from Northbound.
transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
String name = tzName;
Uint64 id = dpnId;
if (transportZone == null) {
// Case: TZ is not configured from Northbound, then add TEP into
// "teps-in-not-hosted-transport-zone"
LOG.trace("Removing TEP from teps-in-not-hosted-transport-zone list.");
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.OPERATIONAL, tx -> removeUnknownTzTepFromTepsNotHosted(name, tepIpAddress, id, dataBroker, tx)));
return futures;
} else {
LOG.trace("Remove TEP from transport-zone already configured by Northbound.");
}
}
// Remove TEP from (default transport-zone) OR (transport-zone already configured by Northbound)
@Nullable Map<VtepsKey, Vteps> vtepList = transportZone.getVteps();
if (vtepList == null || vtepList.isEmpty()) {
// case: vtep list does not exist or it has no elements
LOG.trace("No vtep list in subnet list of transport-zone. Nothing to do.");
} else {
// case: vtep list has elements
boolean vtepFound = false;
Vteps oldVtep = null;
for (Vteps vtep : vtepList.values()) {
if (Objects.equals(vtep.getDpnId(), dpnId)) {
vtepFound = true;
oldVtep = vtep;
break;
}
}
if (vtepFound) {
// vtep is found, update it with tep-ip
LOG.trace("Remove TEP from vtep list in subnet list of transport-zone.");
dpnId = oldVtep.getDpnId();
String name = tzName;
Uint64 id = dpnId;
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> removeVtepFromTZConfig(name, id, tx)));
} else {
LOG.trace("TEP is not found in the vtep list in subnet list of transport-zone. Nothing to do.");
}
}
return futures;
}
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 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 tzName transport zone name in string
* @param tx TypedWriteTransaction object
*/
protected static void addVtepIntoTepsNotHosted(Map<UnknownVtepsKey, UnknownVteps> updatedVtepList, String tzName, TypedWriteTransaction<Datastore.Operational> tx) {
// Create TZ node path
InstanceIdentifier<TepsInNotHostedTransportZone> tepsInNotHostedTransportZoneIid = InstanceIdentifier.builder(NotHostedTransportZones.class).child(TepsInNotHostedTransportZone.class, new TepsInNotHostedTransportZoneKey(tzName)).build();
// create unknown TZ node with updated vtep list
TepsInNotHostedTransportZone updatedTzone = new TepsInNotHostedTransportZoneBuilder().withKey(new TepsInNotHostedTransportZoneKey(tzName)).setZoneName(tzName).setUnknownVteps(updatedVtepList).build();
// Update TZ in Oper DS.
tx.mergeParentStructureMerge(tepsInNotHostedTransportZoneIid, updatedTzone);
}
Aggregations