use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.
the class TransportZoneListener method createDPNTepInfo.
private List<DPNTEPsInfo> createDPNTepInfo(TransportZone transportZone) {
Map<BigInteger, List<TunnelEndPoints>> mapDPNToTunnelEndpt = new ConcurrentHashMap<>();
List<DPNTEPsInfo> dpnTepInfo = new ArrayList<>();
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(transportZone.getZoneName());
Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
LOG.trace("Transport Zone_name: {}", transportZone.getZoneName());
List<Subnets> subnetsList = transportZone.getSubnets();
if (subnetsList != null) {
for (Subnets subnet : subnetsList) {
IpPrefix ipPrefix = subnet.getPrefix();
IpAddress gatewayIP = subnet.getGatewayIp();
int vlanID = subnet.getVlanId();
LOG.trace("IpPrefix: {}, gatewayIP: {}, vlanID: {} ", ipPrefix, gatewayIP, vlanID);
List<Vteps> vtepsList = subnet.getVteps();
if (vtepsList != null && !vtepsList.isEmpty()) {
for (Vteps vteps : vtepsList) {
BigInteger dpnID = vteps.getDpnId();
String port = vteps.getPortname();
IpAddress ipAddress = vteps.getIpAddress();
boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOptionOfTunnel());
String tos = vteps.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
LOG.trace("DpnID: {}, port: {}, ipAddress: {}", dpnID, port, ipAddress);
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
List<TunnelEndPoints> tunnelEndPointsList = mapDPNToTunnelEndpt.get(dpnID);
if (tunnelEndPointsList != null) {
LOG.trace("Existing DPN info list in the Map: {} ", dpnID);
tunnelEndPointsList.add(tunnelEndPoints);
} else {
LOG.trace("Adding new DPN info list to the Map: {} ", dpnID);
tunnelEndPointsList = new ArrayList<>();
tunnelEndPointsList.add(tunnelEndPoints);
mapDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
}
}
}
}
}
if (!mapDPNToTunnelEndpt.isEmpty()) {
LOG.trace("List of dpns in the Map: {} ", mapDPNToTunnelEndpt.keySet());
for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapDPNToTunnelEndpt.entrySet()) {
DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
dpnTepInfo.add(newDpnTepsInfo);
}
}
return dpnTepInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.
the class ItmUtils method removeTransportZoneMembership.
public static List<TzMembership> removeTransportZoneMembership(TunnelEndPoints endPts, List<TzMembership> zones) {
LOG.trace(" RemoveTransportZoneMembership TEPs {}, Membership to be removed {} ", endPts, zones);
List<TzMembership> existingTzList = new ArrayList<>(endPts.getTzMembership());
for (TzMembership membership : zones) {
existingTzList.remove(new TzMembershipBuilder().setZoneName(membership.getZoneName()).build());
}
LOG.debug("Modified Membership List {}", existingTzList);
return existingTzList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.
the class ItmExternalTunnelDeleteWorker method tunnelsDeletion.
private static void tunnelsDeletion(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> cfgdhwVteps, TransportZone originalTZone, WriteTransaction writeTransaction, DataBroker dataBroker) {
if (cfgdDpnList != null) {
for (DPNTEPsInfo dpn : cfgdDpnList) {
if (dpn.getTunnelEndPoints() != null) {
for (TunnelEndPoints srcTep : dpn.getTunnelEndPoints()) {
for (TzMembership zone : srcTep.getTzMembership()) {
deleteTunnelsInTransportZone(zone.getZoneName(), dpn, srcTep, cfgdhwVteps, dataBroker, writeTransaction);
}
}
}
}
}
if (cfgdhwVteps != null && !cfgdhwVteps.isEmpty()) {
for (HwVtep hwTep : cfgdhwVteps) {
LOG.trace("processing hwTep from list {}", hwTep);
for (HwVtep hwTepRemote : cfgdhwVteps) {
if (!hwTep.getHwIp().equals(hwTepRemote.getHwIp())) {
deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwTepRemote.getTopoId(), hwTepRemote.getNodeId(), hwTepRemote.getHwIp(), TunnelTypeVxlan.class, writeTransaction);
}
}
// do we need to check tunnel type?
LOG.trace("subnets under tz {} are {}", originalTZone.getZoneName(), originalTZone.getSubnets());
if (originalTZone.getSubnets() != null && !originalTZone.getSubnets().isEmpty()) {
for (Subnets sub : originalTZone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
LOG.trace("hwtepDS exists {}", hwVtepDS);
// for mlag case and non-m-lag case, isnt it enough to just check ipaddress?
if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) {
// dont delete tunnels with self
continue;
}
// TOR-TOR
LOG.trace("deleting tor-tor {} and {}", hwTep, hwVtepDS);
deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), originalTZone.getTunnelType(), writeTransaction);
}
}
if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
for (Vteps vtep : sub.getVteps()) {
// TOR-OVS
LOG.trace("deleting tor-css-tor {} and {}", hwTep, vtep);
String parentIf = ItmUtils.getInterfaceName(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId());
deleteTrunksOvsTor(dataBroker, vtep.getDpnId(), parentIf, vtep.getIpAddress(), hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), originalTZone.getTunnelType(), writeTransaction);
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.
the class ItmTepInstanceRecoveryHandler method extractDPNTepsInfo.
private DPNTEPsInfo extractDPNTepsInfo(String entityId) {
String[] params = entityId.split(":");
if (params.length < 2) {
LOG.error("Not enough arguments..Exiting...");
return null;
} else if (params.length > 2) {
LOG.info("Ignoring extra parameter and proceeding...");
}
// ToDo:- Need to add more validations
this.tzName = params[0];
String ipAddress = params[1];
transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (transportZone == null) {
LOG.error("Transportzone name {} is not valid.", tzName);
return null;
}
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
LOG.error("Transport Zone {} subnet {} has no vteps", transportZone.getZoneName(), sub.getPrefix());
}
for (Vteps vtep : sub.getVteps()) {
if (ipAddress.equals(String.valueOf(vtep.getIpAddress().getValue()))) {
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(tzName);
LOG.trace("Transportzone {} found match for tep {} to be recovered", transportZone.getZoneName(), ipAddress);
// OfTunnels is false byDefault
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(vtep.getDpnId(), IpAddressBuilder.getDefaultInstance(ipAddress), vtep.getPortname(), false, sub.getVlanId(), sub.getPrefix(), sub.getGatewayIp(), zones, transportZone.getTunnelType(), itmConfig.getDefaultTunnelTos());
List<TunnelEndPoints> teps = new ArrayList<>();
teps.add(tunnelEndPoints);
return ItmUtils.createDPNTepInfo(vtep.getDpnId(), teps);
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership in project genius by opendaylight.
the class ItmUtils method createTransportZoneMembership.
public static List<TzMembership> createTransportZoneMembership(String zoneName) {
List<TzMembership> zones = new ArrayList<>();
zones.add(new TzMembershipBuilder().setZoneName(zoneName).build());
return zones;
}
Aggregations