use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder in project genius by opendaylight.
the class TransportZoneListener method createVtepFromUnKnownVteps.
private Vteps createVtepFromUnKnownVteps(BigInteger dpnID, IpAddress ipAddress, String port) {
VtepsKey vtepkey = new VtepsKey(dpnID, port);
Vteps vtepObj = new VtepsBuilder().setDpnId(dpnID).setIpAddress(ipAddress).setKey(vtepkey).setPortname(port).build();
return vtepObj;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder in project genius by opendaylight.
the class TepCommandHelper method createLocalCache.
@SuppressWarnings("checkstyle:IllegalCatch")
public void createLocalCache(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask, String gatewayIp, String transportZone, CommandSession session) throws TepException {
CHECK.incrementAndGet();
IpAddress ipAddressObj = null;
IpAddress gatewayIpObj = null;
IpPrefix subnetMaskObj = null;
final VtepsKey vtepkey = new VtepsKey(dpnId, portName);
try {
ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
if ((gatewayIp != null) && !gatewayIp.isEmpty() && !("null".equals(gatewayIp)) || ("0.0.0.0".equals(gatewayIp))) {
gatewayIpObj = IpAddressBuilder.getDefaultInstance(gatewayIp);
} else {
LOG.debug("gateway is null");
gatewayIp = null;
}
} catch (RuntimeException e) {
handleError("Invalid IpAddress. Expected: 1.0.0.0 to 254.255.255.255", session);
return;
}
try {
subnetMaskObj = IpPrefixBuilder.getDefaultInstance(subnetMask);
} catch (Exception e) {
handleError("Invalid Subnet Mask. Expected: 0.0.0.0/0 to 255.255.255.255/32", session);
return;
}
if (!validateIPs(ipAddress, subnetMask, gatewayIp)) {
handleError("IpAddress and gateWayIp should belong to the subnet provided", session);
return;
}
if (checkTepPerTzPerDpn(transportZone, dpnId)) {
if (session != null) {
session.getConsole().println("Only one end point per transport Zone per Dpn is allowed");
}
return;
}
Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).setKey(vtepkey).setPortname(portName).build();
validateForDuplicates(vtepCli, transportZone);
SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
if (transportZonesHashMap.containsKey(transportZone)) {
Map<SubnetObject, List<Vteps>> subVtepMapTemp = transportZonesHashMap.get(transportZone);
if (subVtepMapTemp.containsKey(subObCli)) {
// if Subnet exists
List<Vteps> vtepListTemp = subVtepMapTemp.get(subObCli);
if (vtepListTemp.contains(vtepCli)) {
// do nothing
} else {
vtepListTemp.add(vtepCli);
}
} else {
// subnet doesnt exist
if (checkExistingSubnet(subVtepMapTemp, subObCli)) {
if (session != null) {
session.getConsole().println("subnet with subnet mask " + subObCli.get_key() + "already exists");
}
return;
}
List<Vteps> vtepListTemp = new ArrayList<>();
vtepListTemp.add(vtepCli);
subVtepMapTemp.put(subObCli, vtepListTemp);
}
} else {
List<Vteps> vtepListTemp = new ArrayList<>();
vtepListTemp.add(vtepCli);
Map<SubnetObject, List<Vteps>> subVtepMapTemp = new HashMap<>();
subVtepMapTemp.put(subObCli, vtepListTemp);
transportZonesHashMap.put(transportZone, subVtepMapTemp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder in project genius by opendaylight.
the class TepCommandHelper method isInCache.
// deletes from ADD-cache if it exists.
public boolean isInCache(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask, String gatewayIp, String transportZone, CommandSession session) {
boolean exists = false;
final VtepsKey vtepkey = new VtepsKey(dpnId, portName);
IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
IpPrefix subnetMaskObj = IpPrefixBuilder.getDefaultInstance(subnetMask);
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
if (gatewayIp != null) {
gatewayIpObj = IpAddressBuilder.getDefaultInstance(gatewayIp);
} else {
LOG.debug("gateway is null");
}
SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).setKey(vtepkey).setPortname(portName).build();
SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
if (transportZonesHashMap.containsKey(transportZone)) {
Map<SubnetObject, List<Vteps>> subVtepMapTemp = transportZonesHashMap.get(transportZone);
if (subVtepMapTemp.containsKey(subObCli)) {
// if Subnet exists
List<Vteps> vtepListTemp = subVtepMapTemp.get(subObCli);
if (vtepListTemp.contains(vtepCli)) {
// return true if tzones has vtep
exists = true;
vtepListTemp.remove(vtepCli);
if (vtepListTemp.size() == 0) {
subVtepMapTemp.remove(subObCli);
if (subVtepMapTemp.size() == 0) {
transportZonesHashMap.remove(transportZone);
}
}
} else if (session != null) {
session.getConsole().println("Vtep " + "has not been configured");
}
}
}
return exists;
}
Aggregations