import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList;
public interface IITMProvider {
void configureTunnelType(String transportZone, String tunnelType);
+ /**
+ * Adds the vtep config schema.
+ *
+ * @param vtepConfigSchema
+ * the vtep config schema
+ */
+ void addVtepConfigSchema(VtepConfigSchema vtepConfigSchema);
+
+ /**
+ * Gets the vtep config schema.
+ *
+ * @param schemaName
+ * the schema name
+ * @return the vtep config schema
+ */
+ VtepConfigSchema getVtepConfigSchema(String schemaName);
+
+ /**
+ * Gets the all vtep config schemas.
+ *
+ * @return the all vtep config schemas
+ */
+ List<VtepConfigSchema> getAllVtepConfigSchemas();
+
+ /**
+ * Update VTEP schema.
+ *
+ * @param schemaName
+ * the schema name
+ * @param lstDpnsForAdd
+ * the lst dpns for add
+ * @param lstDpnsForDelete
+ * the lst dpns for delete
+ */
+ void updateVtepSchema(String schemaName, List<BigInteger> lstDpnsForAdd, List<BigInteger> lstDpnsForDelete);
+
+ /**
+ * Delete all vtep schemas.
+ */
+ void deleteAllVtepSchemas();
+
void configureTunnelMonitorParams(boolean monitorEnabled, String monitorProtocol);
void configureTunnelMonitorInterval(int interval);
}
}
+ /* Configuration data */
+
+ container vtep-config-schemas {
+ status deprecated;
+ list vtep-config-schema {
+ key schema-name;
+
+ leaf schema-name {
+ type string;
+ mandatory true;
+ description "Schema name";
+ }
+
+ leaf transport-zone-name {
+ type string;
+ mandatory true;
+ description "Transport zone";
+ }
+
+ leaf tunnel-type {
+ type identityref {
+ base odlif:tunnel-type-base;
+ }
+ }
+
+ leaf port-name {
+ type string;
+ mandatory true;
+ description "Port name";
+ }
+
+ leaf vlan-id {
+ type uint16 {
+ range "0..4094";
+ }
+ mandatory true;
+ description "VLAN ID";
+ }
+
+ leaf gateway-ip {
+ type inet:ip-address;
+ description "Gateway IP address";
+ }
+
+ leaf subnet {
+ type inet:ip-prefix;
+ mandatory true;
+ description "Subnet Mask in CIDR-notation string, e.g. 10.0.0.0/24";
+ }
+
+ leaf exclude-ip-filter {
+ type string;
+ description "IP Addresses which needs to be excluded from the specified subnet. IP address range or comma separated IP addresses can to be specified. e.g: 10.0.0.1-10.0.0.20,10.0.0.30,10.0.0.35";
+ }
+
+ list dpn-ids {
+ key "DPN";
+
+ leaf DPN {
+ type uint64;
+ description "DPN ID";
+ }
+ }
+ }
+ }
+
+ /* Ip Address book keeping */
+ container vtep-ip-pools {
+ status deprecated;
+ config true;
+ list vtep-ip-pool {
+ key subnet-cidr;
+ leaf subnet-cidr{
+ type string;
+ }
+ leaf-list available-ipaddress {
+ type inet:ip-address;
+ }
+ leaf-list allocated-ipaddress {
+ type inet:ip-address;
+ }
+ }
+ }
+
/* conf parameters for default-transport-zone */
container itm-config {
config true;
type boolean;
default false;
}
- leaf vlan-id {
- type uint16{
- range "0..4094";
- }
- }
- leaf portname {
- type string;
- }
}
}
/* Minimum 1 port. We may for now support only two ports */
list tunnel-end-points {
ordered-by user;
- key "ip-address tunnel-type"; /* Multiple tunnels on the same physical port but on different VLAN can be supported */
+ key "portname VLAN-ID ip-address tunnel-type"; /* Multiple tunnels on the same physical port but on different VLAN can be supported */
+ leaf portname {
+ status deprecated;
+ type string;
+ }
+ leaf VLAN-ID {
+ status deprecated;
+ type uint16;
+ }
leaf ip-address {
type inet:ip-address;
}
+ leaf subnet-mask {
+ status deprecated;
+ type inet:ip-prefix;
+ }
+ leaf gw-ip-address {
+ status deprecated;
+ type inet:ip-address;
+ }
list tz-membership {
key "zone-name";
leaf zone-name {
container transport-zones {
list transport-zone {
- ordered-by user;
+ ordered-by user;
key zone-name;
leaf zone-name {
type string;
}
mandatory true;
}
- list vteps {
- key "dpn-id";
- leaf dpn-id {
- type uint64;
+
+ list subnets {
+ status deprecated;
+ key "prefix";
+ leaf prefix {
+ type inet:ip-prefix;
}
- leaf ip-address {
+ leaf gateway-ip {
type inet:ip-address;
}
- leaf option-of-tunnel {
- description "Use flow based tunnels for remote-ip";
- type boolean;
- default false;
- }
- leaf option-tunnel-tos {
- description "Value of ToS bits to be set on the encapsulating
- packet. The value of 'inherit' will copy the DSCP value
- from inner IPv4 or IPv6 packets. When ToS is given as
- a numberic value, the least significant two bits will
- be ignored.";
- type string {
- length "1..8";
+ leaf vlan-id {
+ type uint16 {
+ range "0..4094";
}
}
- }
- list device-vteps {
- key "node-id ip-address";
-
- leaf topology-id {
- type string;
- }
- leaf node-id {
- type string;
+ list vteps {
+ key "dpn-id portname";
+ leaf dpn-id {
+ type uint64;
+ }
+ leaf portname {
+ type string;
+ }
+ leaf ip-address {
+ type inet:ip-address;
+ }
+ leaf option-of-tunnel {
+ description "Use flow based tunnels for remote-ip";
+ type boolean;
+ default false;
+ }
+ leaf weight {
+ type uint16;
+ default 1;
+ description "Bucket weight if tunnel belongs to OF select group";
+ }
+ leaf option-tunnel-tos {
+ description "Value of ToS bits to be set on the encapsulating
+ packet. The value of 'inherit' will copy the DSCP value
+ from inner IPv4 or IPv6 packets. When ToS is given as
+ a numberic value, the least significant two bits will
+ be ignored.";
+ type string {
+ length "1..8";
+ }
+ }
}
- leaf ip-address {
- type inet:ip-address;
+ list device-vteps {
+ key "node-id ip-address";
+
+ leaf topology-id {
+ type string;
+ }
+ leaf node-id {
+ type string;
+ }
+ leaf ip-address {
+ type inet:ip-address;
+ }
}
}
- }
+ }
}
container not-hosted-transport-zones {
"Trunk Interface"), true, dpnTepInfo.getTunnelType(),
srcDpnTEPsInfo.get(0).getTunnelEndPoints().get(0).getIpAddress(),
dstDpnTEPsInfo.get(0).getTunnelEndPoints().get(0).getIpAddress(),
+ srcDpnTEPsInfo.get(0).getTunnelEndPoints().get(0).getGwIpAddress(),
+ srcDpnTEPsInfo.get(0).getTunnelEndPoints().get(0).getVLANID(), true,
dpnTepInfo.isMonitoringEnabled(), TunnelMonitoringTypeBfd.class,
monitoringInt, true, null);
}
--- /dev/null
+/*
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.genius.itm.cli;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SubnetObject {
+ private IpAddress gatewayIp;
+ private SubnetsKey key;
+ private IpPrefix prefix;
+ private java.lang.Integer vlanId;
+ private static final Logger LOG = LoggerFactory.getLogger(SubnetObject.class);
+
+ public SubnetObject(IpAddress gwIP, SubnetsKey key, IpPrefix mask, Integer vlanId) {
+ gatewayIp = gwIP;
+ this.key = key;
+ this.prefix = mask;
+ try {
+ if (vlanId != null) {
+ checkVlanIdRange(vlanId);
+ }
+ } catch (IllegalArgumentException e) {
+ LOG.error("Invalid VlanID. expected: 0 to 4095");
+ }
+ this.vlanId = vlanId;
+ }
+
+ public IpAddress get_gatewayIp() {
+ return gatewayIp;
+ }
+
+ public SubnetsKey get_key() {
+ return key;
+ }
+
+ public IpPrefix get_prefix() {
+ return prefix;
+ }
+
+ public java.lang.Integer get_vlanId() {
+ return vlanId;
+ }
+
+ private int hash = 0;
+ private volatile boolean hashValid = false;
+
+ @Override
+ public int hashCode() {
+ if (hashValid) {
+ return hash;
+ }
+
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((gatewayIp == null) ? 0 : gatewayIp.hashCode());
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
+ result = prime * result + ((vlanId == null) ? 0 : vlanId.hashCode());
+ hash = result;
+ hashValid = true;
+ return result;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof SubnetObject)) {
+ return false;
+ }
+ SubnetObject other = (SubnetObject) obj;
+ if (gatewayIp == null) {
+ if (other.get_gatewayIp() != null) {
+ return false;
+ }
+ } else if (!gatewayIp.equals(other.get_gatewayIp())) {
+ return false;
+ }
+ if (key == null) {
+ if (other.get_key() != null) {
+ return false;
+ }
+ } else if (!key.equals(other.get_key())) {
+ return false;
+ }
+ if (prefix == null) {
+ if (other.get_prefix() != null) {
+ return false;
+ }
+ } else if (!prefix.equals(other.get_prefix())) {
+ return false;
+ }
+ if (vlanId == null) {
+ if (other.get_vlanId() != null) {
+ return false;
+ }
+ } else if (!vlanId.equals(other.get_vlanId())) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public java.lang.String toString() {
+ java.lang.StringBuilder builder = new java.lang.StringBuilder("Subnets [");
+ boolean first = true;
+
+ if (gatewayIp != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("gatewayIp=");
+ builder.append(gatewayIp);
+ }
+ if (key != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("key=");
+ builder.append(key);
+ }
+ if (prefix != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("prefix=");
+ builder.append(prefix);
+ }
+ if (vlanId != null) {
+ if (first) {
+ first = false;
+ } else {
+ builder.append(", ");
+ }
+ builder.append("vlanId=");
+ builder.append(vlanId);
+ }
+ return builder.append(']').toString();
+ }
+
+ private static void checkVlanIdRange(final int value) {
+ if (value >= 0 && value <= 4095) {
+ return;
+ }
+ throw new IllegalArgumentException(String.format("Invalid range: %s, expected: [[0?4095]].", value));
+ }
+}
import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
import java.math.BigInteger;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.net.util.SubnetUtils;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.utils.cache.DataStoreCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBfd;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeLldp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.DataObject;
* command is Tep-add else set to false when Tep-delete is called
* tepCommandHelper object is created only once in session initiated
*/
- private final Map<String, List<Vteps>> transportZonesHashMap = new HashMap<>();
+ private final Map<String, Map<SubnetObject, List<Vteps>>> transportZonesHashMap = new HashMap<>();
+ private List<Subnets> subnetList = new ArrayList<>();
private List<TransportZone> transportZoneArrayList = new ArrayList<>();
private final List<Vteps> vtepDelCommitList = new ArrayList<>();
}
@SuppressWarnings("checkstyle:IllegalCatch")
- public void createLocalCache(BigInteger dpnId, String ipAddress,
- String transportZone) throws TepException {
+ public void createLocalCache(BigInteger dpnId, String portName, Integer vlanId, String ipAddress,
+ String subnetMask, String gatewayIp, String transportZone) throws TepException {
CHECK.incrementAndGet();
- IpAddress ipAddressObj;
-
- final VtepsKey vtepkey = new VtepsKey(dpnId);
+ 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");
+ 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");
+ return;
+ }
- ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
+ if (!validateIPs(ipAddress, subnetMask, gatewayIp)) {
+ handleError("IpAddress and gateWayIp should belong to the subnet provided");
+ return;
+ }
if (checkTepPerTzPerDpn(transportZone, dpnId)) {
handleError("Only one end point per transport Zone per Dpn is allowed");
}
Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey)
- .build();
+ .setPortname(portName).build();
+ validateForDuplicates(vtepCli, transportZone);
+ SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
+ SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
if (transportZonesHashMap.containsKey(transportZone)) {
- List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
- if (!vtepListTemp.contains(vtepCli)) {
+ 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)) {
+ handleError("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);
- transportZonesHashMap.put(transportZone, vtepListTemp);
+ Map<SubnetObject, List<Vteps>> subVtepMapTemp = new HashMap<>();
+ subVtepMapTemp.put(subObCli, vtepListTemp);
+ transportZonesHashMap.put(transportZone, subVtepMapTemp);
+ }
+ }
+
+ private boolean validateIPs(String ipAddress, String subnetMask, String gatewayIp) {
+ SubnetUtils utils = new SubnetUtils(subnetMask);
+ if (utils.getInfo().isInRange(ipAddress) && (gatewayIp == null || utils.getInfo().isInRange(gatewayIp))) {
+ return true;
+ } else {
+ LOG.trace("InValid IP");
+ return false;
+ }
+ }
+
+ /**
+ * Validate for duplicates.
+ *
+ * @param inputVtep
+ * the input vtep
+ * @param transportZone
+ * the transport zone
+ */
+ public void validateForDuplicates(Vteps inputVtep, String transportZone) {
+ Map<String, TransportZone> allTransportZonesAsMap = getAllTransportZonesAsMap();
+
+ boolean isConfiguredTepGreType = isGreTunnelType(transportZone, allTransportZonesAsMap);
+ // Checking for duplicates in local cache
+ for (Entry<String, Map<SubnetObject, List<Vteps>>> entry : transportZonesHashMap.entrySet()) {
+ String tz = entry.getKey();
+ boolean isGreType = isGreTunnelType(tz, allTransportZonesAsMap);
+ Map<SubnetObject, List<Vteps>> subVtepMapTemp = entry.getValue();
+ for (List<Vteps> vtepList : subVtepMapTemp.values()) {
+ validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
+ }
+ }
+ // Checking for duplicates in config DS
+ for (TransportZone tz : allTransportZonesAsMap.values()) {
+ boolean isGreType = false;
+ if (TunnelTypeGre.class.equals(tz.getTunnelType())) {
+ isGreType = true;
+ }
+ for (Subnets sub : ItmUtils.emptyIfNull(tz.getSubnets())) {
+ List<Vteps> vtepList = sub.getVteps();
+ validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
+ }
+ }
+ }
+
+ private void validateForDuplicateAndSingleGreTep(Vteps inputVtep, boolean isConfiguredTepGreType, boolean isGreType,
+ List<Vteps> vtepList) {
+ if (ItmUtils.isEmpty(vtepList)) {
+ return;
+ }
+ Preconditions.checkArgument(!vtepList.contains(inputVtep), "VTEP already exists");
+ BigInteger dpnId = inputVtep.getDpnId();
+ if (isConfiguredTepGreType && isGreType) {
+ for (Vteps vtep : vtepList) {
+ Preconditions.checkArgument(!Objects.equals(vtep.getDpnId(), dpnId),
+ "DPN [" + dpnId + "] already configured with GRE TEP."
+ + " Mutiple GRE TEP's on a single DPN are not allowed.");
+ }
}
}
+ /**
+ * Gets all transport zones as map.
+ *
+ * @return all transport zones as map
+ */
+ private Map<String, TransportZone> getAllTransportZonesAsMap() {
+ TransportZones allTransportZones = getAllTransportZones();
+ Map<String, TransportZone> transportZoneMap = new HashMap<>();
+ if (null != allTransportZones) {
+ for (TransportZone tzone : ItmUtils.emptyIfNull(allTransportZones.getTransportZone())) {
+ transportZoneMap.put(tzone.getZoneName(), tzone);
+ }
+ }
+ return transportZoneMap;
+ }
+
+ /**
+ * Checks if is gre tunnel type.
+ *
+ * @param transportZoneName
+ * the zone name
+ * @param trsnsportZoneMap
+ * the zone map
+ * @return true, if is gre tunnel type
+ */
+ private boolean isGreTunnelType(String transportZoneName, Map<String, TransportZone> trsnsportZoneMap) {
+ TransportZone tzone = trsnsportZoneMap.get(transportZoneName);
+ /*
+ * if (tzone != null &&
+ * StringUtils.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_GRE,
+ * tzone.getTunnelType())) { return true; }
+ */
+ return tzone != null && TunnelTypeGre.class.equals(tzone.getTunnelType());
+ }
+
/**
* Gets the transport zone.
*
return ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker).orNull();
}
+ public boolean checkExistingSubnet(Map<SubnetObject, List<Vteps>> subVtepMapTemp, SubnetObject subObCli) {
+ for (SubnetObject subOb : subVtepMapTemp.keySet()) {
+ if (subOb.get_key().equals(subObCli.get_key())) {
+ if (!subOb.get_vlanId().equals(subObCli.get_vlanId())) {
+ return true;
+ }
+ if (!subOb.get_gatewayIp().equals(subObCli.get_gatewayIp())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
public boolean checkTepPerTzPerDpn(String tzone, BigInteger dpnId) {
// check in local cache
if (transportZonesHashMap.containsKey(tzone)) {
- List<Vteps> vtepList = transportZonesHashMap.get(tzone);
- for (Vteps vtep : vtepList) {
- if (Objects.equals(vtep.getDpnId(), dpnId)) {
- return true;
+ Map<SubnetObject, List<Vteps>> subVtepMapTemp = transportZonesHashMap.get(tzone);
+ for (List<Vteps> vtepList : subVtepMapTemp.values()) {
+ for (Vteps vtep : vtepList) {
+ if (Objects.equals(vtep.getDpnId(), dpnId)) {
+ return true;
+ }
}
}
}
ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone tz = transportZoneOptional.get();
- for (Vteps vtep : tz.getVteps()) {
- if (Objects.equals(vtep.getDpnId(), dpnId)) {
- return true;
+ if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
+ return false;
+ }
+ for (Subnets sub : tz.getSubnets()) {
+ if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
+ continue;
+ }
+ for (Vteps vtep : sub.getVteps()) {
+ if (Objects.equals(vtep.getDpnId(), dpnId)) {
+ return true;
+ }
}
}
}
LOG.debug("no of teps added {}", CHECK);
if (transportZonesHashMap != null && !transportZonesHashMap.isEmpty()) {
transportZoneArrayList = new ArrayList<>();
- for (Entry<String, List<Vteps>> mapEntry : transportZonesHashMap.entrySet()) {
+ for (Entry<String, Map<SubnetObject, List<Vteps>>> mapEntry : transportZonesHashMap.entrySet()) {
String tz = mapEntry.getKey();
LOG.debug("transportZonesHashMap {}", tz);
- List<Vteps> vtepListTemp = mapEntry.getValue();
+ subnetList = new ArrayList<>();
+ Map<SubnetObject, List<Vteps>> subVtepMapTemp = mapEntry.getValue();
+ for (Entry<SubnetObject, List<Vteps>> entry : subVtepMapTemp.entrySet()) {
+ SubnetObject subOb = entry.getKey();
+ LOG.debug("subnets {}", subOb.get_prefix());
+ List<Vteps> vtepList = entry.getValue();
+ Subnets subnet = new SubnetsBuilder().setGatewayIp(subOb.get_gatewayIp())
+ .withKey(subOb.get_key()).setPrefix(subOb.get_prefix()).setVlanId(subOb.get_vlanId())
+ .setVteps(vtepList).build();
+ subnetList.add(subnet);
+ LOG.debug("vteps {}", vtepList);
+ }
InstanceIdentifier<TransportZone> transportZonePath =
InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(tz)).build();
|| tzoneFromDs.getTunnelType().equals(TunnelTypeVxlan.class)) {
transportZone =
new TransportZoneBuilder().withKey(new TransportZoneKey(tz))
- .setTunnelType(TunnelTypeVxlan.class)
- .setZoneName(tz).setVteps(vtepListTemp).build();
+ .setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList)
+ .setZoneName(tz).build();
} else if (tzoneFromDs.getTunnelType().equals(TunnelTypeGre.class)) {
transportZone =
new TransportZoneBuilder().withKey(new TransportZoneKey(tz))
- .setTunnelType(TunnelTypeGre.class).setVteps(vtepListTemp)
+ .setTunnelType(TunnelTypeGre.class).setSubnets(subnetList)
.setZoneName(tz).build();
}
} else {
transportZone =
new TransportZoneBuilder().withKey(new TransportZoneKey(tz))
- .setTunnelType(TunnelTypeVxlan.class).setZoneName(tz).setVteps(vtepListTemp)
+ .setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList).setZoneName(tz)
.build();
}
LOG.debug("tzone object {}", transportZone);
transportZoneArrayList.add(transportZone);
}
TransportZones transportZones =
- new TransportZonesBuilder().setTransportZone(transportZoneArrayList).build();
+ new TransportZonesBuilder().setTransportZone(transportZoneArrayList).build();
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
LOG.debug("InstanceIdentifier {}", path);
Futures.addCallback(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> tx.merge(path, transportZones, true)), ItmUtils.DEFAULT_WRITE_CALLBACK,
- MoreExecutors.directExecutor());
+ MoreExecutors.directExecutor());
LOG.debug("wrote to Config DS {}", transportZones);
transportZonesHashMap.clear();
transportZoneArrayList.clear();
+ subnetList.clear();
LOG.debug("Everything cleared");
} else {
LOG.debug("NO vteps were configured");
result.add("---------------------------------------------------------------------------------------------"
+ "---------------------------------");
for (TransportZone tz : transportZones.getTransportZone()) {
- if (tz.getVteps() == null || tz.getVteps().isEmpty()) {
+ if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
continue;
}
- for (Vteps vtep : tz.getVteps()) {
- flag = true;
- String strTunnelType ;
- if (TunnelTypeGre.class.equals(tz.getTunnelType())) {
- strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
- } else {
- strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
+ for (Subnets sub : tz.getSubnets()) {
+ if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
+ continue;
+ }
+ for (Vteps vtep : sub.getVteps()) {
+ flag = true;
+ String strTunnelType ;
+ if (TunnelTypeGre.class.equals(tz.getTunnelType())) {
+ strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
+ } else {
+ strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
+ }
+ result.add(String.format("%-16s %-16s %-16s %-12s %-12s %-12s %-16s %-12s",
+ tz.getZoneName(), strTunnelType, sub.getPrefix().stringValue(),
+ sub.getGatewayIp().stringValue(), sub.getVlanId().toString(),
+ vtep.getDpnId().toString(), vtep.getIpAddress().stringValue(),
+ vtep.getPortname()));
}
- result.add(String.format("%-16s %-16s %-12s %-16s",
- tz.getZoneName(), strTunnelType,
- vtep.getDpnId().toString(), vtep.getIpAddress().stringValue()));
}
}
if (flag) {
}
@SuppressWarnings("checkstyle:IllegalCatch")
- public void deleteVtep(BigInteger dpnId, String ipAddress,
- String transportZone) throws TepException {
-
- final VtepsKey vtepkey = new VtepsKey(dpnId);
+ public void deleteVtep(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask,
+ String gatewayIp, String transportZone) throws TepException {
- IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
+ 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 (!"null".equals(gatewayIp) || "0.0.0.0".equals(gatewayIp) && gatewayIp != null) {
+ 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");
+ 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");
+ return;
+ }
- Vteps vtepCli;
+ if (!validateIPs(ipAddress, subnetMask, gatewayIp)) {
+ handleError("IpAddress and gateWayIp should belong to the subnet provided");
+ return;
+ }
+ SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
+ Vteps vtepCli = null;
+ Subnets subCli = null;
InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class)
- .child(TransportZone.class, new TransportZoneKey(transportZone))
+ .child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey)
.child(Vteps.class, vtepkey).build();
- // check if present in tzones and delete from cache
- boolean existsInCache = isInCache(dpnId, ipAddress, transportZone);
+ // check if present in tzones and delete from cache
+ boolean existsInCache = isInCache(dpnId, portName, vlanId, ipAddress, subnetMask, gatewayIp,
+ transportZone);
if (!existsInCache) {
Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
if (vtepOptional.isPresent()) {
vtepCli = vtepOptional.get();
if (Objects.equals(vtepCli.getIpAddress(), ipAddressObj)) {
- vtepDelCommitList.add(vtepCli);
+ InstanceIdentifier<Subnets> spath =
+ InstanceIdentifier
+ .builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(transportZone))
+ .child(Subnets.class, subnetsKey).build();
+ Optional<Subnets> subOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, spath,
+ dataBroker);
+ if (subOptional.isPresent()) {
+ subCli = subOptional.get();
+ if (Objects.equals(subCli.getGatewayIp(), gatewayIpObj) && Objects.equals(subCli.getVlanId(),
+ vlanId)) {
+ vtepDelCommitList.add(vtepCli);
+ } else {
+ handleError("vtep with this vlan or gateway doesnt exist");
+ }
+ }
+ } else {
+ handleError("Vtep with this ipaddress doesnt exist");
}
} else {
handleError("Vtep Doesnt exist");
public <T extends DataObject> void deleteOnCommit() {
List<InstanceIdentifier<T>> vtepPaths = new ArrayList<>();
List<InstanceIdentifier<T>> subnetPaths = new ArrayList<>();
+ List<Subnets> subDelList = new ArrayList<>();
List<Vteps> vtepDelList = new ArrayList<>();
List<InstanceIdentifier<T>> allPaths = new ArrayList<>();
try {
if (transportZonesOptional.isPresent()) {
List<TransportZone> transportZones = transportZonesOptional.get().nonnullTransportZone();
for (TransportZone tz : transportZones) {
- if (tz.getVteps() == null || tz.getVteps().isEmpty()) {
+ if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
continue;
}
- vtepDelList.addAll(vtepDelCommitList);
- for (Vteps vtep : vtepDelList) {
- InstanceIdentifier<T> vpath =
- (InstanceIdentifier<T>) InstanceIdentifier
- .builder(TransportZones.class)
- .child(TransportZone.class, tz.key())
- .child(Vteps.class, vtep.key()).build();
- vtepPaths.add(vpath);
+ for (Subnets sub : tz.getSubnets()) {
+ vtepDelList.addAll(vtepDelCommitList);
+ for (Vteps vtep : vtepDelList) {
+ InstanceIdentifier<T> vpath =
+ (InstanceIdentifier<T>) InstanceIdentifier
+ .builder(TransportZones.class)
+ .child(TransportZone.class, tz.key())
+ .child(Subnets.class, sub.key())
+ .child(Vteps.class, vtep.key()).build();
+ if (sub.getVteps() != null && sub.getVteps().remove(vtep)) {
+ vtepPaths.add(vpath);
+ if (sub.getVteps().size() == 0 || sub.getVteps() == null) {
+ subDelList.add(sub);
+ }
+
+ }
+ }
+ }
+ }
+
+ for (TransportZone tz : transportZones) {
+ if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
+ continue;
+ }
+ for (Subnets sub : subDelList) {
+ if (tz.getSubnets().remove(sub)) {
+ InstanceIdentifier<T> spath =
+ (InstanceIdentifier<T>) InstanceIdentifier
+ .builder(TransportZones.class)
+ .child(TransportZone.class, tz.key())
+ .child(Subnets.class, sub.key()).build();
+ subnetPaths.add(spath);
+ }
}
}
allPaths.addAll(subnetPaths);
Futures.addCallback(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
tx -> allPaths.forEach(tx::delete)), ItmUtils.DEFAULT_WRITE_CALLBACK,
- MoreExecutors.directExecutor());
+ MoreExecutors.directExecutor());
}
vtepPaths.clear();
subnetPaths.clear();
}
String displayFormat = "%-16s %-16s %-16s %-16s %-16s %-10s %-10s";
System.out.println(String.format(displayFormat, "Tunnel Name", "Source-DPN",
- "Destination-DPN", "Source-IP", "Destination-IP", "Trunk-State", "Transport Type"));
+ "Destination-DPN", "Source-IP", "Destination-IP", "Trunk-State", "Transport Type"));
System.out.println("-----------------------------------------------------------------------------------------"
+ "--------------------------------------------");
for (StateTunnelList tunnelInst : tunnelLists) {
- // Display only the internal tunnels
+ // Display only the internal tunnels
if (TepTypeInternal.class.equals(tunnelInst.getDstInfo().getTepDeviceType())) {
String tunnelInterfaceName = tunnelInst.getTunnelInterfaceName();
LOG.trace("tunnelInterfaceName::: {}", tunnelInterfaceName);
// Show DPN-ID and Bridge mapping
public void showBridges(Map<BigInteger, OvsdbBridgeRef> dpnIdBridgeRefMap) {
System.out.println(String.format("%-16s %-16s %-36s%n", "DPN-ID", "Bridge-Name", "Bridge-UUID")
- + "------------------------------------------------------------------------");
+ + "------------------------------------------------------------------------");
dpnIdBridgeRefMap.forEach((dpnId, ovsdbBridgeRef) -> {
String szBridgeId = ovsdbBridgeRef.getValue().firstKeyOf(Node.class).getNodeId().getValue();
String bridgeUUID = szBridgeId.substring(13, 49);
}
// deletes from ADD-cache if it exists.
- public boolean isInCache(BigInteger dpnId, String ipAddress,
- String transportZone) throws TepException {
+ public boolean isInCache(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask,
+ String gatewayIp, String transportZone) throws TepException {
boolean exists = false;
- final VtepsKey vtepkey = new VtepsKey(dpnId);
+ final VtepsKey vtepkey = new VtepsKey(dpnId, portName);
IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
-
- Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey).build();
+ 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).withKey(vtepkey)
+ .setPortname(portName).build();
+ SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
if (transportZonesHashMap.containsKey(transportZone)) {
- List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
- if (vtepListTemp.contains(vtepCli)) {
- exists = true; // return true if tzones has vtep
- vtepListTemp.remove(vtepCli);
- if (vtepListTemp.size() == 0) {
- transportZonesHashMap.remove(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)) {
+ exists = true; // return true if tzones has vtep
+ vtepListTemp.remove(vtepCli);
+ if (vtepListTemp.size() == 0) {
+ subVtepMapTemp.remove(subObCli);
+ if (subVtepMapTemp.size() == 0) {
+ transportZonesHashMap.remove(transportZone);
+ }
+ }
+ } else {
+ handleError("Vtep has not been configured");
}
- } else {
- handleError("Vtep has not been configured");
}
}
return exists;
TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(transportZoneName, dataBroker);
Class<? extends TunnelTypeBase> tunType;
+ validateTunnelType(transportZoneName, tunnelType, transportZoneFromConfigDS);
if (transportZoneFromConfigDS != null) {
if (!transportZoneName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
LOG.debug("Transport zone {} with tunnel type {} already exists. No action required.",
- transportZoneName, tunnelType);
+ transportZoneName, tunnelType);
return;
} else {
tunnelType = StringUtils.upperCase(tunnelType);
}
+ /**
+ * Validate tunnel type.
+ *
+ * @param transportZoneName
+ * the t zone name
+ * @param tunnelType
+ * the tunnel type
+ */
+ private void validateTunnelType(String transportZoneName, String tunnelType,TransportZone tzoneFromConfigDs) {
+ String strTunnelType = ItmUtils.validateTunnelType(tunnelType);
+ Class<? extends TunnelTypeBase> tunType;
+ if (strTunnelType.equals(ITMConstants.TUNNEL_TYPE_VXLAN)) {
+ tunType = TunnelTypeVxlan.class;
+ } else {
+ tunType = TunnelTypeGre.class;
+ }
+
+ if (tzoneFromConfigDs != null) {
+ if (!Objects.equals(tzoneFromConfigDs.getTunnelType(), tunType) && ItmUtils.isNotEmpty(tzoneFromConfigDs
+ .getSubnets())) {
+ // for default-TZ, such error message is not needed to be thrown.
+ // it needs to be handled in different way, by deleting default-TZ
+ // with old tunnel-type and then add default-TZ with new tunnel-type
+ if (!transportZoneName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
+ throw new IllegalArgumentException(
+ "Changing the tunnel type from " + tzoneFromConfigDs.getTunnelType()
+ + " to " + strTunnelType
+ + " is not allowed for already configured transport zone [" + transportZoneName
+ + "].");
+ } else {
+ // delete already existing default TZ
+ ItmUtils.deleteTransportZoneFromConfigDS(ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
+ }
+ }
+ }
+ }
+
public void configureTunnelMonitorParams(boolean monitorEnabled, String monitorProtocol) {
InstanceIdentifier<TunnelMonitorParams> path = InstanceIdentifier.builder(TunnelMonitorParams.class).build();
Optional<TunnelMonitorParams> storedTunnelMonitor = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
.setMonitorProtocol(monitorType).build();
Futures.addCallback(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> tx.merge(path, tunnelMonitor, true)), ItmUtils.DEFAULT_WRITE_CALLBACK,
- MoreExecutors.directExecutor());
+ MoreExecutors.directExecutor());
}
}
TunnelMonitorInterval tunnelMonitor = new TunnelMonitorIntervalBuilder().setInterval(interval).build();
Futures.addCallback(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> tx.merge(path, tunnelMonitor, true)), ItmUtils.DEFAULT_WRITE_CALLBACK,
- MoreExecutors.directExecutor());
+ MoreExecutors.directExecutor());
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.genius.itm.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.genius.itm.api.IITMProvider;
+import org.opendaylight.genius.itm.globals.ITMConstants;
+import org.opendaylight.genius.itm.impl.ItmUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class which implements karaf command "vtep:schema-add".
+ */
+@Command(scope = "vtep", name = "schema-add", description = "Adding a VTEP schema.")
+public class VtepSchemaAdd extends OsgiCommandSupport {
+
+ private static final String SCHEMA_NAME = "--schema-name";
+ private static final String PORT_NAME = "--port-name";
+ private static final String VLAN_ID = "--vlan-id";
+ private static final String SUBNET_CIDR = "--subnet-cidr";
+ private static final String TRANSPORT_ZONE = "--transport-zone";
+ private static final String DPN_IDS = "--dpn-ids";
+ private static final String GATEWAY_IP = "--gateway-ip";
+ private static final String TUNNEL_TYPE = "--tunnel-type";
+ private static final String EXCLUDE_IP_FILTER = "--exclude-ip-filter";
+
+ /** The schema name. */
+ @Option(name = SCHEMA_NAME, aliases = { "-s" }, description = "Schema name", required = true, multiValued = false)
+ private String schemaName;
+
+ /** The port name. */
+ @Option(name = PORT_NAME, aliases = { "-p" }, description = "Port name", required = true, multiValued = false)
+ private String portName;
+
+ /** The vlan id. */
+ @Option(name = VLAN_ID, aliases = { "-v" }, description = "VLAN ID", required = true, multiValued = false)
+ private Integer vlanId;
+
+ /** The subnet mask. */
+ @Option(name = SUBNET_CIDR, aliases = {
+ "-sc" }, description = "Subnet Mask in CIDR-notation string, e.g. 10.0.0.0/24",
+ required = true, multiValued = false)
+ private String subnetCIDR;
+
+ /** The transport zone. */
+ @Option(name = TRANSPORT_ZONE, aliases = {
+ "-tz" }, description = "Transport zone", required = true, multiValued = false)
+ private String transportZone;
+
+ /** The dpn ids. */
+ @Option(name = DPN_IDS, aliases = {
+ "-d" }, description = "DPN ID's in comma separated values. e.g: 2,3,10",
+ required = false, multiValued = false)
+ private String dpnIds;
+
+ /** The gateway ip. */
+ @Option(name = GATEWAY_IP, aliases = {
+ "-g" }, description = "Gateway IP address", required = false, multiValued = false)
+ private String gatewayIp;
+
+ /** The tunnel type. */
+ @Option(name = TUNNEL_TYPE, aliases = {
+ "-t" }, description = "Tunnel type. Value: VXLAN | GRE. Default: VXLAN",
+ required = false, multiValued = false)
+ private String tunnelType;
+
+ /** The exclude ip filter. */
+ @Option(name = EXCLUDE_IP_FILTER, aliases = {
+ "-ex" }, description = "IP Addresses which needs to be excluded from the specified subnet. "
+ + "IP address range or comma separated IP addresses can to be specified. "
+ + "e.g: 10.0.0.1-10.0.0.20,10.0.0.30,10.0.0.35", required = false, multiValued = false)
+ private String excludeIpFilter;
+
+ /** The Constant logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(VtepSchemaAdd.class);
+
+ /** The itm provider. */
+ private IITMProvider itmProvider;
+
+ /**
+ * Sets the itm provider.
+ *
+ * @param itmProvider
+ * the new itm provider
+ */
+ public void setItmProvider(IITMProvider itmProvider) {
+ this.itmProvider = itmProvider;
+ }
+
+ /**
+ * Command Usage.
+ */
+ private void usage() {
+ session.getConsole().println(String.format(
+ "usage: vtep:schema-add [%s schema-name] [%s port-name] [%s vlan-id] [%s subnet-cidr] "
+ + "[%s transport-zone] [%s dpn-ids] [%s gateway-ip] [%s tunnel-type] [%s exclude-ip-filter]",
+ SCHEMA_NAME, PORT_NAME, VLAN_ID, SUBNET_CIDR, TRANSPORT_ZONE, DPN_IDS, GATEWAY_IP, TUNNEL_TYPE,
+ EXCLUDE_IP_FILTER));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.karaf.shell.console.AbstractAction#doExecute()
+ */
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @Override
+ protected Object doExecute() {
+ try {
+ if (this.schemaName == null || this.portName == null || this.vlanId == null || this.subnetCIDR == null
+ || this.transportZone == null) {
+ usage();
+ return null;
+ }
+ LOG.debug("Executing vtep:schema-add command\t {} \t {} \t {} \t {} \t {} \t {} \t {} \t {} \t {}",
+ schemaName, portName, vlanId, subnetCIDR, gatewayIp, transportZone, tunnelType,
+ dpnIds, excludeIpFilter);
+
+ if (null == tunnelType) {
+ tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN ;
+ }
+ VtepConfigSchema schema = ItmUtils.constructVtepConfigSchema(schemaName, portName, vlanId, subnetCIDR,
+ gatewayIp, transportZone, tunnelType, ItmCliUtils.constructDpnIdList(dpnIds), excludeIpFilter);
+ this.itmProvider.addVtepConfigSchema(schema);
+
+ } catch (Exception e) {
+ LOG.error("Exception occurred during execution of command \"vtep:schema-add\": ", e);
+ throw e;
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.genius.itm.cli;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.genius.itm.api.IITMProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class which implements karaf command "vtep:schema-delete".
+ */
+@Command(scope = "vtep", name = "schema-delete", description = "Delete VTEP schema.")
+public class VtepSchemaDelete extends OsgiCommandSupport {
+
+ private static final String ALL = "all";
+
+ @Argument(index = 0, name = ALL, description = "Delete all VTEP schemas", required = true, multiValued = false)
+ private String deleteAll = null;
+
+ /** The Constant logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(VtepSchemaDelete.class);
+
+ /** The itm provider. */
+ private IITMProvider itmProvider;
+
+ /**
+ * Sets the itm provider.
+ *
+ * @param itmProvider
+ * the new itm provider
+ */
+ public void setItmProvider(IITMProvider itmProvider) {
+ this.itmProvider = itmProvider;
+ }
+
+ private void usage() {
+ session.getConsole().println("usage: vtep:schema-delete all");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.karaf.shell.console.AbstractAction#doExecute()
+ */
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @Override
+ protected Object doExecute() {
+ try {
+ if (this.deleteAll == null || !StringUtils.equalsIgnoreCase(ALL, this.deleteAll)) {
+ usage();
+ return null;
+ }
+ LOG.debug("Executing vtep:schema-delete command\t {} ", this.deleteAll);
+ this.itmProvider.deleteAllVtepSchemas();
+
+ } catch (Exception e) {
+ LOG.error("Exception occurred during execution of command \"vtep:schema-delete all\": ", e);
+ throw e;
+ }
+ return null;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.genius.itm.cli;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.genius.itm.api.IITMProvider;
+import org.opendaylight.genius.itm.globals.ITMConstants;
+import org.opendaylight.genius.itm.impl.ItmUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class which implements karaf command "vtep:schema-show".
+ */
+@Command(scope = "vtep", name = "schema-show", description = "Show all VTEP schemas.")
+public class VtepSchemaShow extends OsgiCommandSupport {
+
+ /** The schema name. */
+ @Argument(index = 0, name = "schemaName", description = "Schema name", required = false, multiValued = false)
+ private String schemaName;
+
+ private static String VTEP_CONFIG_SCHEMA_CLI_FORMAT = "%-14s %-12s %-8s %-16s %-13s %-14s %-11s %-20s %-32s";
+ public static final String HEADER_UNDERLINE = "------------------------------------------------------------------"
+ + "---------------------------------------------------------------------";
+
+ /** The Constant logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(VtepSchemaShow.class);
+
+ /** The itm provider. */
+ private IITMProvider itmProvider;
+
+ /**
+ * Sets the itm provider.
+ *
+ * @param itmProvider
+ * the new itm provider
+ */
+ public void setItmProvider(IITMProvider itmProvider) {
+ this.itmProvider = itmProvider;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.karaf.shell.console.AbstractAction#doExecute()
+ */
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @Override
+ protected Object doExecute() {
+ LOG.debug("Executing command: schema-show {} ", this.schemaName);
+ try {
+ if (this.schemaName != null) {
+ VtepConfigSchema schema = this.itmProvider.getVtepConfigSchema(this.schemaName);
+ if (schema == null) {
+ session.getConsole().println("No VTEP schema present with name: " + this.schemaName);
+ } else {
+ session.getConsole().println(getHeaderOutput());
+ printSchema(schema);
+ }
+ } else {
+ printAllVtepSchemas();
+ }
+ } catch (Exception e) {
+ LOG.error("Exception occurred during execution of command \"vtep:schema-show\": ", e);
+ }
+ return null;
+ }
+
+ /**
+ * Prints all vtep schemas.
+ */
+ private void printAllVtepSchemas() {
+ List<VtepConfigSchema> schemas = this.itmProvider.getAllVtepConfigSchemas();
+ if (schemas == null || schemas.isEmpty()) {
+ session.getConsole().println("No VTEP schemas present.");
+ return;
+ }
+ session.getConsole().println(getHeaderOutput());
+ for (VtepConfigSchema schema : schemas) {
+ printSchema(schema);
+ }
+ }
+
+ /**
+ * Prints the schema.
+ *
+ * @param schema
+ * the schema
+ */
+ private void printSchema(VtepConfigSchema schema) {
+ List<BigInteger> lstDpnIds = (schema.getDpnIds() == null) ? Collections.emptyList()
+ : ItmUtils.getDpnIdList(schema.getDpnIds());
+ List<String> lstIpFilter = getExcludeIpFilterAsList(schema.getExcludeIpFilter());
+
+ Iterator<BigInteger> dpnIterator = lstDpnIds.iterator();
+ Iterator<String> ipFilterIterator = lstIpFilter.iterator();
+
+ String portName = StringUtils.defaultString(schema.getPortName());
+ String vlanId = String.valueOf(schema.getVlanId());
+ String subnetCIDR = (schema.getSubnet() == null) ? StringUtils.EMPTY
+ : schema.getSubnet().stringValue();
+ String gatewayIp = (schema.getGatewayIp() == null) ? StringUtils.EMPTY
+ : schema.getGatewayIp().stringValue();
+ String transportZone = StringUtils.defaultString(schema.getTransportZoneName());
+ String strTunnelType ;
+
+ Class<? extends TunnelTypeBase> tunType = schema.getTunnelType();
+
+ if (TunnelTypeGre.class.equals(tunType)) {
+ strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
+ } else {
+ strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
+ }
+ String dpnId = (dpnIterator.hasNext() ? String.valueOf(dpnIterator.next()) : StringUtils.EMPTY);
+ String excludeIpFilter = (ipFilterIterator.hasNext() ? String.valueOf(ipFilterIterator.next())
+ : StringUtils.EMPTY);
+
+ // Print first row
+ session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, schema.getSchemaName(),
+ portName, vlanId, subnetCIDR, gatewayIp, transportZone, strTunnelType, dpnId, excludeIpFilter));
+ while (dpnIterator.hasNext() || ipFilterIterator.hasNext()) {
+ dpnId = (dpnIterator.hasNext() ? String.valueOf(dpnIterator.next()) : StringUtils.EMPTY);
+ excludeIpFilter = (ipFilterIterator.hasNext() ? String.valueOf(ipFilterIterator.next())
+ : StringUtils.EMPTY);
+ session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, StringUtils.EMPTY,
+ StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY,
+ StringUtils.EMPTY, dpnId, excludeIpFilter));
+ }
+ session.getConsole().println(System.lineSeparator());
+ }
+
+ /**
+ * Gets the exclude ip filter as list.
+ *
+ * @param excludeIpFilter
+ * the exclude ip filter
+ * @return the exclude ip filter as list
+ */
+ private List<String> getExcludeIpFilterAsList(String excludeIpFilter) {
+ if (StringUtils.isBlank(excludeIpFilter)) {
+ return Collections.emptyList();
+ }
+ final String[] arrIpsOrRange = StringUtils.split(excludeIpFilter, ',');
+ return Arrays.asList(arrIpsOrRange);
+ }
+
+ /**
+ * Gets the vtep config schema header output.
+ *
+ * @return the vtep config schema header output
+ */
+ private String getHeaderOutput() {
+ String headerBuilder =
+ String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, "SchemaName", "PortName", "VlanID", "Subnet", "GatewayIP",
+ "TransportZone", "TunnelType", "DPN-IDS", "ExcludeIpFilter") + '\n' + HEADER_UNDERLINE;
+ return headerBuilder;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.genius.itm.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.genius.itm.api.IITMProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class which implements karaf command "vtep:schema-update".
+ */
+@Command(scope = "vtep", name = "schema-update", description = "Update VTEP schema.")
+public class VtepSchemaUpdate extends OsgiCommandSupport {
+
+ private static final String SCHEMA_NAME = "--schema-name";
+ private static final String AD = "--add-dpn-ids";
+ private static final String DD = "--del-dpn-ids";
+
+ /** The schema name. */
+ @Option(name = SCHEMA_NAME, aliases = { "-s" }, description = "Schema name", required = true, multiValued = false)
+ private String schemaName;
+
+ /** The dpn ids for add. */
+ @Option(name = AD, aliases = {
+ "-ad" }, description = "DPN ID's to be added to schema in a comma separated value format. e.g: 2,3,10",
+ required = false, multiValued = false)
+ private String dpnIdsForAdd;
+
+ /** The dpn ids for delete. */
+ @Option(name = DD, aliases = {
+ "-dd" }, description = "DPN ID's to be deleted from schema in a comma separated value format. e.g: 2,3,10",
+ required = false, multiValued = false)
+ private String dpnIdsForDelete;
+
+ /** The Constant logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(VtepSchemaUpdate.class);
+
+ /** The itm provider. */
+ private IITMProvider itmProvider;
+
+ /**
+ * Sets the itm provider.
+ *
+ * @param itmProvider
+ * the new itm provider
+ */
+ public void setItmProvider(IITMProvider itmProvider) {
+ this.itmProvider = itmProvider;
+ }
+
+ /**
+ * Command Usage.
+ */
+ private void usage() {
+ session.getConsole().println(
+ String.format("usage: vtep:schema-update [%s schema-name] [%s dpn-ids-for-add] [%s dpn-ids-for-delete]",
+ SCHEMA_NAME, AD, DD));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.karaf.shell.console.AbstractAction#doExecute()
+ */
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ @Override
+ protected Object doExecute() {
+ try {
+ if (this.dpnIdsForAdd == null && this.dpnIdsForDelete == null) {
+ session.getConsole().println(String.format("Atleast one of the parameters [%s or %s] is mandatory",
+ AD, DD));
+ usage();
+ return null;
+ }
+ LOG.debug("Executing vtep:schema-update command\t {} \t {} \t {} ", this.schemaName, this.dpnIdsForAdd,
+ this.dpnIdsForDelete);
+
+ this.itmProvider.updateVtepSchema(this.schemaName, ItmCliUtils.constructDpnIdList(this.dpnIdsForAdd),
+ ItmCliUtils.constructDpnIdList(this.dpnIdsForDelete));
+
+ } catch (Exception e) {
+ LOG.error("Exception occurred during execution of command \"vtep:schema-update\": ", e);
+ throw e;
+ }
+ return null;
+ }
+}
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
+import org.apache.commons.net.util.SubnetUtils;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
import org.opendaylight.genius.itm.impl.ItmUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
String tunTypeStr = tunType.getName();
String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName,
firstEndPt.getIpAddress().stringValue(), extIp.stringValue(), tunTypeStr);
+ String subnetMaskStr = firstEndPt.getSubnetMask().stringValue();
boolean useOfTunnel = ItmUtils.falseIfNull(firstEndPt.isOptionOfTunnel());
List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(firstEndPt, itmConfig);
+ SubnetUtils utils = new SubnetUtils(subnetMaskStr);
+ String dcGwyIpStr = extIp.stringValue();
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
- IpAddress gwyIpAddress = gatewayIpObj;
+ IpAddress gwyIpAddress =
+ utils.getInfo().isInRange(dcGwyIpStr) ? gatewayIpObj : firstEndPt.getGwIpAddress();
LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {},"
- + " source IP - {}, DC Gateway IP - {} gateway IP - {}", trunkInterfaceName,
- interfaceName, firstEndPt.getIpAddress(), extIp, gwyIpAddress);
+ + " source IP - {}, DC Gateway IP - {} gateway IP - {}", trunkInterfaceName, interfaceName,
+ firstEndPt.getIpAddress(), extIp, gwyIpAddress);
Interface iface = ItmUtils.buildTunnelInterface(teps.getDPNID(), trunkInterfaceName,
- String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"),
- true, tunType, firstEndPt.getIpAddress(), extIp, false,
- ITMConstants.DEFAULT_MONITOR_PROTOCOL, null, useOfTunnel, tunOptions);
+ String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"), true,
+ tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress, firstEndPt.getVLANID(), false, false,
+ ITMConstants.DEFAULT_MONITOR_PROTOCOL, null, useOfTunnel, tunOptions);
LOG.debug(" Trunk Interface builder - {} ", iface);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
.child(ExternalTunnel.class, new ExternalTunnelKey(extIp.stringValue(),
teps.getDPNID().toString(), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(teps.getDPNID().toString(),
- extIp.stringValue(), tunType, trunkInterfaceName);
+ extIp.stringValue(), tunType, trunkInterfaceName);
tx.merge(path, tnl, true);
}
}
Class<? extends TunnelTypeBase> tunType,
TypedWriteTransaction<Configuration> tx) {
Collection<DPNTEPsInfo> cfgDpnList = dpnId == null ? dpnTEPsInfoCache.getAllPresent()
- : ItmUtils.getDpnTepListFromDpnId(dpnTEPsInfoCache, dpnId);
+ : ItmUtils.getDpnTepListFromDpnId(dpnTEPsInfoCache, dpnId);
buildTunnelsToExternalEndPoint(cfgDpnList, extIp, tunType, tx);
}
for (TzMembership zone : tep.nonnullTzMembership()) {
try {
createTunnelsFromOVSinTransportZone(zone.getZoneName(), dpn, tep, tx, monitorInterval,
- monitorProtocol);
+ monitorProtocol);
} catch (ExecutionException | InterruptedException e) {
LOG.error("Tunnel Creation failed for {} due to ", zone.getZoneName(), e);
}
}
private void createTunnelsFromOVSinTransportZone(String zoneName, DPNTEPsInfo dpn, TunnelEndPoints tep,
- TypedReadWriteTransaction<Configuration> tx, Integer monitorInterval,
- Class<? extends TunnelMonitoringTypeBase> monitorProtocol)
- throws ExecutionException, InterruptedException {
+ TypedReadWriteTransaction<Configuration> tx, Integer monitorInterval,
+ Class<? extends TunnelMonitoringTypeBase> monitorProtocol) throws ExecutionException, InterruptedException {
Optional<TransportZone> transportZoneOptional = tx.read(InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(zoneName)).build()).get();
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
//do we need to check tunnel type?
- if (transportZone.getDeviceVteps() != null && !transportZone.getDeviceVteps().isEmpty()) {
- String portName = (itmConfig.getPortname() == null) ? ITMConstants.DUMMY_PORT : itmConfig.getPortname();
- int vlanId = (itmConfig.getVlanId() != null) ? itmConfig.getVlanId() : ITMConstants.DUMMY_VLANID;
- for (DeviceVteps hwVtepDS : transportZone.getDeviceVteps()) {
- //dont mesh if hwVteps and OVS-tep have same ip-address
- if (Objects.equals(hwVtepDS.getIpAddress(), tep.getIpAddress())) {
- continue;
- }
- final String cssID = dpn.getDPNID().toString();
- String nodeId = hwVtepDS.getNodeId();
- boolean useOfTunnel = ItmUtils.falseIfNull(tep.isOptionOfTunnel());
- LOG.trace("wire up {} and {}",tep, hwVtepDS);
- if (!wireUp(dpn.getDPNID(), portName, vlanId, tep.getIpAddress(), useOfTunnel, nodeId,
- hwVtepDS.getIpAddress(), transportZone.getTunnelType(), false,
- monitorInterval, monitorProtocol, tx)) {
- LOG.error("Unable to build tunnel {} -- {}",
- tep.getIpAddress(), hwVtepDS.getIpAddress());
- }
- //TOR-OVS
- LOG.trace("wire up {} and {}", hwVtepDS,tep);
- if (!wireUp(hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(),
- cssID, tep.getIpAddress(),
- transportZone.getTunnelType(), false, monitorInterval,
- monitorProtocol, tx)) {
- LOG.error("Unable to build tunnel {} -- {}",
- hwVtepDS.getIpAddress(), tep.getIpAddress());
- }
+ if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
+ for (Subnets sub : transportZone.getSubnets()) {
+ if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
+ for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
+ //dont mesh if hwVteps and OVS-tep have same ip-address
+ if (Objects.equals(hwVtepDS.getIpAddress(), tep.getIpAddress())) {
+ continue;
+ }
+ final String cssID = dpn.getDPNID().toString();
+ String nodeId = hwVtepDS.getNodeId();
+ boolean useOfTunnel = ItmUtils.falseIfNull(tep.isOptionOfTunnel());
+ LOG.trace("wire up {} and {}",tep, hwVtepDS);
+ if (!wireUp(dpn.getDPNID(), tep.getPortname(), sub.getVlanId(),
+ tep.getIpAddress(), useOfTunnel, nodeId, hwVtepDS.getIpAddress(),
+ tep.getSubnetMask(), sub.getGatewayIp(), sub.getPrefix(),
+ transportZone.getTunnelType(), false, monitorInterval, monitorProtocol, tx)) {
+ LOG.error("Unable to build tunnel {} -- {}",
+ tep.getIpAddress(), hwVtepDS.getIpAddress());
+ }
+ //TOR-OVS
+ LOG.trace("wire up {} and {}", hwVtepDS,tep);
+ if (!wireUp(hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(),
+ cssID, tep.getIpAddress(), sub.getPrefix(), sub.getGatewayIp(),
+ tep.getSubnetMask(), transportZone.getTunnelType(), false, monitorInterval,
+ monitorProtocol, tx)) {
+ LOG.error("Unable to build tunnel {} -- {}",
+ hwVtepDS.getIpAddress(), tep.getIpAddress());
+ }
+ }
+ }
}
}
}
}
- private void tunnelsFromhWVtep(HwVtep hwTep, TypedReadWriteTransaction<Configuration> tx,
- Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol)
- throws ExecutionException, InterruptedException {
+ private void tunnelsFromhWVtep(HwVtep hwTep, TypedReadWriteTransaction<Configuration> tx, Integer monitorInterval,
+ Class<? extends TunnelMonitoringTypeBase> monitorProtocol) throws ExecutionException,
+ InterruptedException {
Optional<TransportZone> transportZoneOptional = tx.read(InstanceIdentifier.builder(TransportZones.class)
- .child(TransportZone.class, new TransportZoneKey(hwTep.getTransportZone())).build()).get();
+ .child(TransportZone.class, new TransportZoneKey(hwTep.getTransportZone())).build()).get();
Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
if (transportZoneOptional.isPresent()) {
TransportZone tzone = transportZoneOptional.get();
- String portName = (itmConfig.getPortname() == null) ? ITMConstants.DUMMY_PORT : itmConfig.getPortname();
- int vlanId = (itmConfig.getVlanId() != null) ? itmConfig.getVlanId() : ITMConstants.DUMMY_VLANID;
//do we need to check tunnel type?
- if (tzone.getDeviceVteps() != null && !tzone.getDeviceVteps().isEmpty()) {
- for (DeviceVteps hwVtepDS : tzone.getDeviceVteps()) {
- if (Objects.equals(hwVtepDS.getIpAddress(), hwTep.getHwIp())) {
- continue;//dont mesh with self
- }
- LOG.trace("wire up {} and {}",hwTep, hwVtepDS);
- if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(),
- hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(),
- tunType, false,
- monitorInterval, monitorProtocol, tx)) {
- LOG.error("Unable to build tunnel {} -- {}",
- hwTep.getHwIp(), hwVtepDS.getIpAddress());
+ if (tzone.getSubnets() != null && !tzone.getSubnets().isEmpty()) {
+ for (Subnets sub : tzone.getSubnets()) {
+ if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
+ for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
+ if (Objects.equals(hwVtepDS.getIpAddress(), hwTep.getHwIp())) {
+ continue;//dont mesh with self
+ }
+ LOG.trace("wire up {} and {}",hwTep, hwVtepDS);
+ if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(),
+ hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getIpPrefix(),
+ hwTep.getGatewayIP(), sub.getPrefix(), tunType, false,
+ monitorInterval, monitorProtocol, tx)) {
+ LOG.error("Unable to build tunnel {} -- {}",
+ hwTep.getHwIp(), hwVtepDS.getIpAddress());
+ }
+ //TOR2-TOR1
+ LOG.trace("wire up {} and {}", hwVtepDS,hwTep);
+ if (!wireUp(hwTep.getTopoId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(),
+ hwTep.getNodeId(), hwTep.getHwIp(), sub.getPrefix(), sub.getGatewayIp(),
+ hwTep.getIpPrefix(), tunType, false, monitorInterval,
+ monitorProtocol, tx)) {
+ LOG.error("Unable to build tunnel {} -- {}",
+ hwVtepDS.getIpAddress(), hwTep.getHwIp());
+ }
+ }
}
- //TOR2-TOR1
- LOG.trace("wire up {} and {}", hwVtepDS,hwTep);
- if (!wireUp(hwTep.getTopoId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(),
- hwTep.getNodeId(), hwTep.getHwIp(),
- tunType, false, monitorInterval,
- monitorProtocol, tx)) {
- LOG.error("Unable to build tunnel {} -- {}",
- hwVtepDS.getIpAddress(), hwTep.getHwIp());
+ if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
+ for (Vteps vtep : sub.getVteps()) {
+ if (Objects.equals(vtep.getIpAddress(), hwTep.getHwIp())) {
+ continue;
+ }
+ //TOR-OVS
+ String cssID = vtep.getDpnId().toString();
+ LOG.trace("wire up {} and {}",hwTep, vtep);
+ if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), cssID,
+ vtep.getIpAddress(), hwTep.getIpPrefix(), hwTep.getGatewayIP(),
+ sub.getPrefix(), tunType,false, monitorInterval, monitorProtocol,
+ tx)) {
+ LOG.error("Unable to build tunnel {} -- {}",
+ hwTep.getHwIp(), vtep.getIpAddress());
+ }
+ //OVS-TOR
+ LOG.trace("wire up {} and {}", vtep,hwTep);
+ boolean useOfTunnel = ItmUtils.falseIfNull(vtep.isOptionOfTunnel());
+ if (!wireUp(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId(), vtep.getIpAddress(),
+ useOfTunnel, hwTep.getNodeId(),hwTep.getHwIp(),sub.getPrefix(),
+ sub.getGatewayIp(),hwTep.getIpPrefix(), tunType, false,
+ monitorInterval, monitorProtocol, tx)) {
+ LOG.debug("wireUp returned false");
+ }
+ }
}
}
}
- for (Vteps vtep : tzone.getVteps()) {
- if (Objects.equals(vtep.getIpAddress(), hwTep.getHwIp())) {
- continue;
- }
- //TOR-OVS
- String cssID = vtep.getDpnId().toString();
- LOG.trace("wire up {} and {}",hwTep, vtep);
- if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), cssID,
- vtep.getIpAddress(),
- tunType,false, monitorInterval, monitorProtocol,
- tx)) {
- LOG.error("Unable to build tunnel {} -- {}",
- hwTep.getHwIp(), vtep.getIpAddress());
- }
- //OVS-TOR
- LOG.trace("wire up {} and {}", vtep,hwTep);
- boolean useOfTunnel = ItmUtils.falseIfNull(vtep.isOptionOfTunnel());
- if (!wireUp(vtep.getDpnId(), portName, vlanId, vtep.getIpAddress(),
- useOfTunnel, hwTep.getNodeId(),hwTep.getHwIp(),
- tunType, false,
- monitorInterval, monitorProtocol, tx)) {
- LOG.debug("wireUp returned false");
- }
- }
}
}
//for tunnels from TOR device
private boolean wireUp(String topoId, String srcNodeid, IpAddress srcIp, String dstNodeId, IpAddress dstIp,
- Class<? extends TunnelTypeBase> tunType,
- Boolean monitorEnabled, Integer monitorInterval,
+ IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet,
+ Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval,
Class<? extends TunnelMonitoringTypeBase> monitorProtocol,
TypedWriteTransaction<Configuration> tx) {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
- IpAddress gwyIpAddress = gatewayIpObj;
+ IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
String parentIf = ItmUtils.getHwParentIf(topoId, srcNodeid);
String tunTypeStr = tunType.getName();
String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf,
srcIp.stringValue(), dstIp.stringValue(), tunTypeStr);
LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, "
- + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp,
+ + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp,
dstIp, gwyIpAddress);
Interface hwTunnelIf = ItmUtils.buildHwTunnelInterface(tunnelIfName,
String.format("%s %s", tunType.getName(), "Trunk Interface"), true, topoId, srcNodeid, tunType, srcIp,
//for tunnels from OVS
private boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, Boolean remoteIpFlow,
- String dstNodeId, IpAddress dstIp,
+ String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet,
Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval,
Class<? extends TunnelMonitoringTypeBase> monitorProtocol,
TypedWriteTransaction<Configuration> tx) {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
- IpAddress gwyIpAddress = gatewayIpObj;
-
+ IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId);
String tunTypeStr = tunType.getName();
String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf,
srcIp.stringValue(), dstIp.stringValue(), tunTypeStr);
LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, "
- + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp,
+ + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp,
dstIp, gwyIpAddress);
Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName,
- String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp,
- monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
+ String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress,
+ vlanId, false,monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class,
new InterfaceKey(tunnelIfName)).build();
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf);
import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
-import org.opendaylight.genius.itm.globals.ITMConstants;
import org.opendaylight.genius.itm.impl.ItmUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
ItmUtils.ITM_CACHE.removeInterface(trunkInterfaceName);
InstanceIdentifier<ExternalTunnel> path =
- InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class,
- ItmUtils.getExternalTunnelKey(extIp.stringValue(), teps.getDPNID().toString(), tunType));
+ InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class,
+ ItmUtils.getExternalTunnelKey(extIp.stringValue(), teps.getDPNID().toString(), tunType));
tx.delete(path);
LOG.debug("Deleting tunnel towards DC gateway, Tunnel interface name {} ", trunkInterfaceName);
ItmUtils.ITM_CACHE.removeExternalTunnel(trunkInterfaceName);
ItmUtils.ITM_CACHE.removeInterface(trunkInterfaceName);
InstanceIdentifier<ExternalTunnel> path =
- InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class,
- ItmUtils.getExternalTunnelKey(extIp.stringValue(), teps.getDPNID().toString(), tunType));
+ InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class,
+ ItmUtils.getExternalTunnelKey(extIp.stringValue(), teps.getDPNID().toString(), tunType));
tx.delete(path);
LOG.debug("Deleting tunnel towards DC gateway, Tunnel interface name {} ", trunkInterfaceName);
ItmUtils.ITM_CACHE.removeExternalTunnel(trunkInterfaceName);
}
public static void deleteHwVtepsTunnels(List<DPNTEPsInfo> delDpnList, List<HwVtep> cfgdHwVteps,
- TransportZone originalTZone, TypedReadWriteTransaction<Configuration> tx,
- ItmConfig itmConfig) throws ExecutionException, InterruptedException {
+ TransportZone originalTZone, TypedReadWriteTransaction<Configuration> tx)
+ throws ExecutionException, InterruptedException {
if (delDpnList != null || cfgdHwVteps != null) {
- tunnelsDeletion(delDpnList, cfgdHwVteps, originalTZone, tx, itmConfig);
+ tunnelsDeletion(delDpnList, cfgdHwVteps, originalTZone, tx);
}
}
private static void tunnelsDeletion(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> cfgdhwVteps,
- TransportZone originalTZone, TypedReadWriteTransaction<Configuration> tx,
- ItmConfig itmConfig) throws ExecutionException, InterruptedException {
+ TransportZone originalTZone, TypedReadWriteTransaction<Configuration> tx)
+ throws ExecutionException, InterruptedException {
if (cfgdDpnList != null) {
for (DPNTEPsInfo dpn : cfgdDpnList) {
if (dpn.getTunnelEndPoints() != null) {
for (HwVtep hwTepRemote : cfgdhwVteps) {
if (!hwTep.getHwIp().equals(hwTepRemote.getHwIp())) {
deleteTrunksTorTor(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(),
- hwTepRemote.getTopoId(), hwTepRemote.getNodeId(), hwTepRemote.getHwIp(),
- TunnelTypeVxlan.class, tx);
+ hwTepRemote.getTopoId(), hwTepRemote.getNodeId(), hwTepRemote.getHwIp(),
+ TunnelTypeVxlan.class, tx);
}
}
// do we need to check tunnel type?
- if (originalTZone.getDeviceVteps() != null) {
- for (DeviceVteps hwVtepDS : originalTZone.getDeviceVteps()) {
- LOG.trace("hwtepDS exists {}", hwVtepDS);
- // do i need to check node-id?
- // for mlag case and non-m-lag case, isnt it enough to just check ipaddress?
- if (Objects.equals(hwVtepDS.getIpAddress(), hwTep.getHwIp())) {
- continue;// dont delete tunnels with self
- }
- // TOR-TOR
- LOG.trace("deleting tor-tor {} and {}", hwTep, hwVtepDS);
- deleteTrunksTorTor(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(),
- hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(),
- originalTZone.getTunnelType(), tx);
- }
- }
- if (originalTZone.getVteps() != null) {
+ LOG.trace("subnets under tz {} are {}", originalTZone.getZoneName(), originalTZone.getSubnets());
+ if (originalTZone.getSubnets() != null && !originalTZone.getSubnets().isEmpty()) {
- String portName = (itmConfig.getPortname() == null) ? ITMConstants.DUMMY_PORT
- : itmConfig.getPortname();
- int vlanId = (itmConfig.getVlanId() != null) ? itmConfig.getVlanId() : ITMConstants.DUMMY_VLANID;
+ for (Subnets sub : originalTZone.getSubnets()) {
+ if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
+ for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
+ LOG.trace("hwtepDS exists {}", hwVtepDS);
+ // do i need to check node-id?
+ // for mlag case and non-m-lag case, isnt it enough to just check ipaddress?
+ if (Objects.equals(hwVtepDS.getIpAddress(), hwTep.getHwIp())) {
+ continue;// dont delete tunnels with self
+ }
+ // TOR-TOR
+ LOG.trace("deleting tor-tor {} and {}", hwTep, hwVtepDS);
+ deleteTrunksTorTor(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(),
+ hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(),
+ originalTZone.getTunnelType(), tx);
- for (Vteps vtep : originalTZone.getVteps()) {
- // TOR-OVS
- LOG.trace("deleting tor-css-tor {} and {}", hwTep, vtep);
- String parentIf = ItmUtils.getInterfaceName(vtep.getDpnId(), portName, vlanId);
- deleteTrunksOvsTor(vtep.getDpnId(), parentIf,
- vtep.getIpAddress(), hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(),
- originalTZone.getTunnelType(), tx);
+ }
+ }
+ 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(vtep.getDpnId(), parentIf, vtep.getIpAddress(), hwTep.getTopoId(),
+ hwTep.getNodeId(), hwTep.getHwIp(), originalTZone.getTunnelType(), tx);
+ }
+ }
}
}
}
}
private static void deleteTunnelsInTransportZone(String zoneName, DPNTEPsInfo dpn, TunnelEndPoints srcTep,
- List<HwVtep> cfgdhwVteps, TypedReadWriteTransaction<Configuration> tx)
+ List<HwVtep> cfgdhwVteps, TypedReadWriteTransaction<Configuration> tx)
throws InterruptedException, ExecutionException {
InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(zoneName)).build();
if (tz.isPresent()) {
TransportZone tzone = tz.get();
// do we need to check tunnel type?
- if (tzone.getDeviceVteps() != null) {
- for (DeviceVteps hwVtepDS : tzone.getDeviceVteps()) {
- // OVS-TOR-OVS
- deleteTrunksOvsTor(dpn.getDPNID(), srcTep.getInterfaceName(),
- srcTep.getIpAddress(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(),
- hwVtepDS.getIpAddress(), tzone.getTunnelType(), tx);
+ if (tzone.getSubnets() != null && !tzone.getSubnets().isEmpty()) {
+ for (Subnets sub : tzone.getSubnets()) {
+ if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
+ for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
+ // OVS-TOR-OVS
+ deleteTrunksOvsTor(dpn.getDPNID(), srcTep.getInterfaceName(),
+ srcTep.getIpAddress(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(),
+ hwVtepDS.getIpAddress(), tzone.getTunnelType(), tx);
+
+ }
+ }
}
}
-
if (cfgdhwVteps != null && !cfgdhwVteps.isEmpty()) {
for (HwVtep hwVtep : cfgdhwVteps) {
deleteTrunksOvsTor(dpn.getDPNID(), srcTep.getInterfaceName(),
srcTep.getIpAddress(), hwVtep.getTopoId(), hwVtep.getNodeId(), hwVtep.getHwIp(),
TunnelTypeVxlan.class, tx);
+
}
}
}
}
private static void deleteTrunksOvsTor(BigInteger dpnid, String interfaceName, IpAddress cssIpAddress,
- String topologyId, String nodeId, IpAddress hwIpAddress, Class<? extends TunnelTypeBase> tunType,
- TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
+ String topologyId, String nodeId, IpAddress hwIpAddress, Class<? extends TunnelTypeBase> tunType,
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
// OVS-TOR
if (trunkExists(dpnid.toString(), nodeId, tunType, tx)) {
LOG.trace("deleting tunnel from {} to {} ", dpnid.toString(), nodeId);
}
private static void deleteTrunksTorTor(String topologyId1, String nodeId1, IpAddress hwIpAddress1,
- String topologyId2, String nodeId2, IpAddress hwIpAddress2, Class<? extends TunnelTypeBase> tunType,
- TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
+ String topologyId2, String nodeId2, IpAddress hwIpAddress2, Class<? extends TunnelTypeBase> tunType,
+ TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
// TOR1-TOR2
if (trunkExists(nodeId1, nodeId2, tunType, tx)) {
LOG.trace("deleting tunnel from {} to {} ", nodeId1, nodeId2);
}
private static boolean trunkExists(String srcDpnOrNode, String dstDpnOrNode,
- Class<? extends TunnelTypeBase> tunType,
- TypedReadWriteTransaction<Configuration> tx)
+ Class<? extends TunnelTypeBase> tunType, TypedReadWriteTransaction<Configuration> tx)
throws ExecutionException, InterruptedException {
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class)
.child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(dstDpnOrNode, srcDpnOrNode, tunType));
Class<? extends TunnelTypeBase> tunType, String trunkInterfaceName, String parentInterfaceName) {
String gateway = srcte.getIpAddress().getIpv4Address() != null ? "0.0.0.0" : "::";
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance(gateway);
- IpAddress gwyIpAddress = gatewayIpObj;
+ IpAddress gwyIpAddress =
+ Objects.equals(srcte.getSubnetMask(), dstte.getSubnetMask()) ? gatewayIpObj : srcte.getGwIpAddress();
LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, "
+ "source IP - {}, destination IP - {} gateway IP - {}",
trunkInterfaceName, srcte.getInterfaceName(), srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress);
Boolean isMonitorEnabled = !tunType.isAssignableFrom(TunnelTypeLogicalGroup.class) && isTunnelMonitoringEnabled;
Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName,
String.format("%s %s",ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"),
- true, tunType, srcte.getIpAddress(), dstte.getIpAddress(),
+ true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress, srcte.getVLANID(), true,
isMonitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, parentInterfaceName, tunOptions);
LOG.debug(" Trunk Interface builder - {} ", iface);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
BigInteger dstDpnId, Class<? extends TunnelTypeBase> tunType, String trunkInterfaceName,
String parentInterfaceName) throws ExecutionException, InterruptedException, OperationFailedException {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
- IpAddress gwyIpAddress = gatewayIpObj;
+ IpAddress gwyIpAddress = Objects.equals(srcte.getSubnetMask(), dstte.getSubnetMask())
+ ? gatewayIpObj : srcte.getGwIpAddress() ;
LOG.debug("Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, source IP - {},"
+ " destination IP - {} gateway IP - {}", trunkInterfaceName, parentInterfaceName,
srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress) ;
Boolean isMonitorEnabled = !tunType.isAssignableFrom(TunnelTypeLogicalGroup.class) && isTunnelMonitoringEnabled;
Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName,
String.format("%s %s",ItmUtils.convertTunnelTypetoString(srcte.getTunnelType()), "Trunk Interface"),
- true, tunType, srcte.getIpAddress(), dstte.getIpAddress(),
- isMonitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, parentInterfaceName, tunOptions);
+ true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress, srcte.getVLANID(),
+ true, isMonitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, parentInterfaceName, tunOptions);
LOG.debug("Trunk Interface builder - {} ", iface);
final DpnTepsStateBuilder dpnTepsStateBuilder = new DpnTepsStateBuilder();
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList;
private final ItmInternalTunnelDeleteWorker itmInternalTunnelDeleteWorker;
private final DPNTEPsInfoCache dpnTEPsInfoCache;
private final ManagedNewTransactionRunner txRunner;
- private final ItmConfig itmConfig;
private Collection<DPNTEPsInfo> meshedDpnList ;
public ItmTepRemoveWorker(List<DPNTEPsInfo> delDpnList, List<HwVtep> delHwList, TransportZone originalTZone,
IMdsalApiManager mdsalManager,
ItmInternalTunnelDeleteWorker itmInternalTunnelDeleteWorker,
- DPNTEPsInfoCache dpnTEPsInfoCache, ManagedNewTransactionRunner txRunner,
- ItmConfig itmConfig) {
+ DPNTEPsInfoCache dpnTEPsInfoCache, ManagedNewTransactionRunner txRunner) {
this.delDpnList = delDpnList;
this.mdsalManager = mdsalManager;
this.cfgdHwVteps = delHwList;
this.itmInternalTunnelDeleteWorker = itmInternalTunnelDeleteWorker;
this.dpnTEPsInfoCache = dpnTEPsInfoCache;
this.txRunner = txRunner;
- this.itmConfig = itmConfig;
LOG.trace("ItmTepRemoveWorker initialized with DpnList {}", delDpnList);
LOG.trace("ItmTepRemoveWorker initialized with cfgdHwTeps {}", delHwList);
}
}
));
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
- tx -> ItmExternalTunnelDeleteWorker.deleteHwVtepsTunnels(delDpnList, cfgdHwVteps, this.originalTZone, tx,
- itmConfig)));
+ tx -> ItmExternalTunnelDeleteWorker.deleteHwVtepsTunnels(delDpnList, cfgdHwVteps, this.originalTZone, tx)));
return futures;
}
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import org.opendaylight.genius.infra.Datastore;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
+import org.opendaylight.genius.itm.globals.ITMConstants;
+import org.opendaylight.genius.itm.impl.ItmUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Move TEP from TepsNotHosted list to NBI configured TZ.
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore
- .CONFIGURATION, tx -> OvsdbTepAddConfigHelper.addVtepInITMConfigDS(
- vtepsList, null /*tepIpAddress*/, tzName, BigInteger.ZERO,
- false, tx)));
+ .CONFIGURATION, tx -> OvsdbTepAddConfigHelper.addVtepInITMConfigDS(new ArrayList<>(),
+ ItmUtils.getDummySubnet(), vtepsList, null /*tepIpAddress*/, tzName, BigInteger.ZERO,
+ ITMConstants.DUMMY_PORT, false, tx)));
}
}
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.NotHostedTransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
public static List<ListenableFuture<Void>> addTepReceivedFromOvsdb(String tepIp, String strDpnId, String tzName,
- boolean ofTunnel, DataBroker dataBroker,
- ManagedNewTransactionRunner txRunner) {
+ boolean ofTunnel, DataBroker dataBroker, ManagedNewTransactionRunner txRunner) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
BigInteger dpnId = BigInteger.valueOf(0);
// 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);
+ dataBroker, txRunner);
}
LOG.trace("Add TEP into default-transport-zone.");
} else {
// 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);
+ dataBroker, txRunner);
} else {
LOG.trace("Add TEP into transport-zone already configured by Northbound.");
}
}
-
+ // Get subnet list of corresponding TZ created from Northbound.
+ final List<Subnets> subnetList = tzone.getSubnets();
final BigInteger id = dpnId;
final String name = tzName;
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
- tx -> addConfig(name, id, tepIpAddress, ofTunnel, tx)));
+ tx -> addConfig(subnetList, name, id, tepIpAddress, ofTunnel, tx)));
return futures;
}
* Adds the TEP into Vtep list in the subnet list in the transport zone list
* from ITM configuration Datastore by merge operation with write transaction.
*
+ * @param subnetList subnets list object
+ * @param subnetMaskObj subnet mask in IpPrefix object
* @param updatedVtepList updated Vteps list object which will have new TEP for addition
* @param tepIpAddress TEP IP address in IpAddress object
* @param tzName transport zone name in string
* @param dpid bridge datapath ID in BigInteger
+ * @param portName port name as a part of VtepsKey
* @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
* @param tx TypedWriteTransaction object
*/
- public static void addVtepInITMConfigDS(List<Vteps> updatedVtepList, IpAddress tepIpAddress, String tzName,
- BigInteger dpid, boolean ofTunnel,
- TypedWriteTransaction<Datastore.Configuration> tx) {
+ public static void addVtepInITMConfigDS(List<Subnets> subnetList, IpPrefix subnetMaskObj,
+ List<Vteps> updatedVtepList, IpAddress tepIpAddress, String tzName, BigInteger dpid,
+ String portName, boolean ofTunnel, TypedWriteTransaction<Datastore.Configuration> tx) {
//Create TZ node path
InstanceIdentifier<TransportZone> tranzportZonePath =
- InstanceIdentifier.builder(TransportZones.class)
- .child(TransportZone.class, new TransportZoneKey(tzName)).build();
+ InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(tzName)).build();
// this check is needed to reuse same function from TransportZoneListener
// when VTEP is moved from TepsNotHosted list to TZ configured from Northbound.
if (dpid.compareTo(BigInteger.ZERO) > 0) {
// create vtep
- VtepsKey vtepkey = new VtepsKey(dpid);
+ VtepsKey vtepkey = new VtepsKey(dpid, portName);
Vteps vtepObj =
- new VtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).withKey(vtepkey)
- .setOptionOfTunnel(ofTunnel).build();
+ new VtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).withKey(vtepkey).setPortname(portName)
+ .setOptionOfTunnel(ofTunnel).build();
// Add vtep obtained from bridge into list
updatedVtepList.add(vtepObj);
- LOG.trace("Adding TEP (TZ: {} TEP IP: {} DPID: {}, of-tunnel: {}) in ITM Config DS.", tzName,
- tepIpAddress, dpid, ofTunnel);
+ LOG.trace("Adding TEP (TZ: {} Subnet: {} TEP IP: {} DPID: {}, of-tunnel: {}) in ITM Config DS.", tzName,
+ subnetMaskObj, tepIpAddress, dpid, ofTunnel);
} else {
// this is case when this function is called while TEPs movement from tepsNotHosted list when
// corresponding TZ is configured from northbound.
for (Vteps vtep: updatedVtepList) {
LOG.trace("Moving TEP (TEP IP: {} DPID: {}, of-tunnel: {})"
- + "from not-hosted-transport-zone {} into ITM Config DS.",
- vtep.getIpAddress(), vtep.getDpnId(), ofTunnel, tzName);
+ + "from not-hosted-transport-zone {} into ITM Config DS.",
+ vtep.getIpAddress(), vtep.getDpnId(), ofTunnel, tzName);
}
}
+ // Create subnet object
+ SubnetsKey subKey = new SubnetsKey(subnetMaskObj);
+ IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
+ int vlanID = ITMConstants.DUMMY_VLANID;
+
+ Subnets subnet =
+ new SubnetsBuilder().setGatewayIp(gatewayIP)
+ .withKey(subKey).setPrefix(subnetMaskObj)
+ .setVlanId(vlanID).setVteps(updatedVtepList).build();
+
+ // add subnet into subnet list
+ subnetList.add(subnet);
+
// create TZ node with updated subnet having new vtep
TransportZone updatedTzone =
- new TransportZoneBuilder().withKey(new TransportZoneKey(tzName)).setVteps(updatedVtepList)
- .setZoneName(tzName).build();
+ new TransportZoneBuilder().withKey(new TransportZoneKey(tzName)).setSubnets(subnetList)
+ .setZoneName(tzName).build();
// Update TZ in Config DS to add vtep in TZ
tx.merge(tranzportZonePath, updatedTzone, true);
* @param tx TypedWriteTransaction object
*/
protected static void addUnknownTzTepIntoTepsNotHosted(String tzName, IpAddress tepIpAddress,
- BigInteger dpid, boolean ofTunnel, DataBroker dataBroker,
- TypedWriteTransaction<Datastore.Operational> tx) {
+ BigInteger dpid, boolean ofTunnel, DataBroker dataBroker, TypedWriteTransaction<Datastore.Operational> tx) {
List<UnknownVteps> vtepList;
TepsInNotHostedTransportZone tepsInNotHostedTransportZone =
- ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
+ ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
if (tepsInNotHostedTransportZone == null) {
LOG.trace("Unhosted TransportZone ({}) does not exist in OperDS.", tzName);
vtepList = new ArrayList<>();
* @param tx TypedWriteTransaction object
*/
protected static void addVtepIntoTepsNotHosted(List<UnknownVteps> updatedVtepList, String tzName,
- TypedWriteTransaction<Datastore.Operational> tx) {
+ TypedWriteTransaction<Datastore.Operational> tx) {
//Create TZ node path
InstanceIdentifier<TepsInNotHostedTransportZone> tepsInNotHostedTransportZoneIid =
- InstanceIdentifier.builder(NotHostedTransportZones.class)
- .child(TepsInNotHostedTransportZone.class,
- new TepsInNotHostedTransportZoneKey(tzName)).build();
+ 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();
+ .withKey(new TepsInNotHostedTransportZoneKey(tzName)).setZoneName(tzName)
+ .setUnknownVteps(updatedVtepList).build();
// Update TZ in Oper DS.
tx.merge(tepsInNotHostedTransportZoneIid, updatedTzone, true);
}
- private static void addConfig(String tzName, BigInteger dpnId, IpAddress ipAdd,
+ private static void addConfig(List<Subnets> subnets, String tzName, BigInteger dpnId, IpAddress ipAdd,
boolean ofTunnel, TypedWriteTransaction<Datastore.Configuration> tx) {
- List<Vteps> vtepList = new ArrayList<>();
+ String portName = ITMConstants.DUMMY_PORT;
+ IpPrefix subnetMask = ItmUtils.getDummySubnet(); // get subnetMaskObject
+
+ if (subnets == null || subnets.isEmpty()) {
+ if (subnets == null) {
+ subnets = new ArrayList<>();
+ }
+ List<Vteps> vtepList = new ArrayList<>();
+ LOG.trace("Add TEP in transport-zone when no subnet-list.");
+ addVtepInITMConfigDS(subnets, subnetMask, vtepList, ipAdd, tzName, dpnId, portName, ofTunnel, tx);
+ } else {
+ List<Vteps> vtepList = null;
+
+ // subnet list already exists case; check for dummy-subnet
+ for (Subnets subnet : subnets) {
+ if (subnet.key().getPrefix().equals(subnetMask)) {
+ LOG.trace("Subnet exists in the subnet list of transport-zone {}.", tzName);
+ // get vtep list of existing subnet
+ vtepList = subnet.getVteps();
+ break;
+ }
+ }
- LOG.trace("Add TEP in transport-zone when no vtep-list for specific subnet.");
- addVtepInITMConfigDS(vtepList, ipAdd, tzName, dpnId, ofTunnel, tx);
+ 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 in transport-zone when no vtep-list for specific subnet.");
+ addVtepInITMConfigDS(subnets, subnetMask, vtepList, ipAdd, tzName, dpnId, portName, ofTunnel, tx);
+ } else {
+ // case: vtep list has elements
+ boolean vtepFound = false;
+ Vteps oldVtep = null;
+
+ for (Vteps vtep : vtepList) {
+ if (Objects.equals(vtep.getDpnId(),dpnId)) {
+ vtepFound = true;
+ oldVtep = vtep;
+ // get portName of existing vtep
+ portName = vtep.getPortname();
+ break;
+ }
+ }
+ if (!vtepFound) {
+ addVtepInITMConfigDS(subnets, subnetMask, vtepList, ipAdd, tzName, dpnId, portName, ofTunnel, tx);
+ } else {
+ // vtep is found, update it with tep-ip
+ vtepList.remove(oldVtep);
+ addVtepInITMConfigDS(subnets, subnetMask, vtepList, ipAdd, tzName, dpnId, portName, ofTunnel, tx);
+ }
+ }
+ }
}
private static List<ListenableFuture<Void>> addUnknownTzTepIntoTepsNotHostedAndReturnFutures(String tzName,
- IpAddress tepIpAddress, BigInteger id, boolean ofTunnel,
- DataBroker dataBroker, ManagedNewTransactionRunner txRunner) {
+ IpAddress tepIpAddress, BigInteger id, boolean ofTunnel, DataBroker dataBroker,
+ ManagedNewTransactionRunner txRunner) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.OPERATIONAL,
tx -> addUnknownTzTepIntoTepsNotHosted(tzName, tepIpAddress, id, ofTunnel, dataBroker, tx)));
}
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.NotHostedTransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Remove TEP from (default transport-zone) OR (transport-zone already configured by Northbound)
- List<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.");
+ // Get subnet list of corresponding TZ created from Northbound.
+ List<Subnets> subnetList = transportZone.getSubnets();
+
+ if (subnetList == null || subnetList.isEmpty()) {
+ LOG.trace("No subnet list in transport-zone. Nothing to do.");
} else {
- // case: vtep list has elements
- boolean vtepFound = false;
- Vteps oldVtep = null;
-
- for (Vteps vtep : vtepList) {
- if (Objects.equals(vtep.getDpnId(), dpnId)) {
- vtepFound = true;
- oldVtep = vtep;
+ IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
+
+ List<Vteps> vtepList = null;
+
+ // subnet list already exists case; check for dummy-subnet
+ for (Subnets subnet : subnetList) {
+ if (subnet.key().getPrefix().equals(subnetMaskObj)) {
+ LOG.trace("Subnet exists in the subnet list of transport-zone {}.", tzName);
+ // get vtep list of existing subnet
+ vtepList = subnet.getVteps();
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;
- BigInteger id = dpnId;
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
- tx -> removeVtepFromTZConfig(name, id, tx)));
+
+ 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 {
- LOG.trace(
+ // case: vtep list has elements
+ boolean vtepFound = false;
+ Vteps oldVtep = null;
+
+ for (Vteps vtep : vtepList) {
+ 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 portName = oldVtep.getPortname();
+ String name = tzName;
+ BigInteger id = dpnId;
+ futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
+ tx -> removeVtepFromTZConfig(subnetMaskObj, name, id, portName, tx)));
+ } else {
+ LOG.trace(
"TEP is not found in the vtep list in subnet list of transport-zone. Nothing to do.");
+ }
}
}
return futures;
* Removes the TEP from subnet list in the transport zone list
* from ITM configuration Datastore by delete operation with write transaction.
*
+ * @param subnetMaskObj subnet mask in IpPrefix object
* @param dpnId bridge datapath ID in BigInteger
* @param tzName transport zone name in string
+ * @param portName port name as a part of VtepsKey
* @param tx TypedWriteTransaction object
*/
- private static void removeVtepFromTZConfig(String tzName, BigInteger dpnId,
- TypedWriteTransaction<Datastore.Configuration> tx) {
-
- VtepsKey vtepkey = new VtepsKey(dpnId);
+ private static void removeVtepFromTZConfig(IpPrefix subnetMaskObj, String tzName, BigInteger dpnId,
+ String portName, TypedWriteTransaction<Datastore.Configuration> tx) {
+ SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
+ VtepsKey vtepkey = new VtepsKey(dpnId, portName);
InstanceIdentifier<Vteps> vtepPath = InstanceIdentifier.builder(TransportZones.class)
- .child(TransportZone.class, new TransportZoneKey(tzName))
- .child(Vteps.class, vtepkey).build();
+ .child(TransportZone.class, new TransportZoneKey(tzName))
+ .child(Subnets.class, subnetsKey).child(Vteps.class, vtepkey).build();
- LOG.trace("Removing TEP from (TZ: {} DPN-ID: {}) inside ITM Config DS.",
- tzName, dpnId);
+ LOG.trace("Removing TEP from (TZ: {} Subnet: {} DPN-ID: {}) inside ITM Config DS.",
+ tzName, subnetMaskObj, dpnId);
// remove vtep
tx.delete(vtepPath);
}
TypedWriteTransaction<Datastore.Operational> tx) {
List<UnknownVteps> vtepList;
TepsInNotHostedTransportZone tepsInNotHostedTransportZone =
- ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
+ ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
if (tepsInNotHostedTransportZone == null) {
LOG.trace("Unhosted TransportZone ({}) does not exist in OperDS. Nothing to do for TEP removal.", tzName);
return;
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);
+ "Remove TEP with IP ({}) from unhosted TZ ({}) inside not-hosted-transport-zones list.",
+ tepIpAddress, tzName);
if (vtepList.size() == 1) {
removeTzFromTepsNotHosted(tzName, tx);
} else {
private static void removeVtepFromTepsNotHosted(String tzName, BigInteger 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();
+ .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);
}
*/
private static void removeTzFromTepsNotHosted(String tzName, TypedWriteTransaction<Datastore.Operational> tx) {
InstanceIdentifier<TepsInNotHostedTransportZone> tepsInNotHostedTransportZoneIid =
- InstanceIdentifier.builder(NotHostedTransportZones.class).child(TepsInNotHostedTransportZone.class,
- new TepsInNotHostedTransportZoneKey(tzName)).build();
+ InstanceIdentifier.builder(NotHostedTransportZones.class).child(TepsInNotHostedTransportZone.class,
+ new TepsInNotHostedTransportZoneKey(tzName)).build();
LOG.trace("Removing TZ ({})from not-hosted-transport-zones list inside ITM Oper DS.", tzName);
tx.delete(tepsInNotHostedTransportZoneIid);
}
package org.opendaylight.genius.itm.impl;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
import java.util.Collection;
import javax.inject.Singleton;
import org.apache.aries.blueprint.annotation.service.Service;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.genius.itm.api.IITMProvider;
import org.opendaylight.genius.itm.listeners.TransportZoneListener;
import org.opendaylight.genius.itm.listeners.TunnelMonitorChangeListener;
import org.opendaylight.genius.itm.listeners.TunnelMonitorIntervalListener;
+import org.opendaylight.genius.itm.listeners.VtepConfigSchemaListener;
import org.opendaylight.genius.itm.monitoring.ItmTunnelEventListener;
import org.opendaylight.genius.itm.rpc.ItmManagerRpcService;
+import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.infrautils.diagstatus.ServiceState;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepConfigSchemas;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInputBuilder;
private final TransportZoneListener tzChangeListener;
private final TunnelMonitorChangeListener tnlToggleListener;
private final TunnelMonitorIntervalListener tnlIntervalListener;
+ private final VtepConfigSchemaListener vtepConfigSchemaListener;
private final InterfaceStateListener ifStateListener;
private final EntityOwnershipService entityOwnershipService;
private final ItmDiagStatusProvider itmStatusProvider;
TunnelMonitorChangeListener tunnelMonitorChangeListener,
TunnelMonitorIntervalListener tunnelMonitorIntervalListener,
TransportZoneListener transportZoneListener,
+ VtepConfigSchemaListener vtepConfigSchemaListener,
OvsdbNodeListener ovsdbNodeListener,
TunnelMonitoringConfig tunnelMonitoringConfig,
EntityOwnershipService entityOwnershipService,
this.tnlToggleListener = tunnelMonitorChangeListener;
this.tnlIntervalListener = tunnelMonitorIntervalListener;
this.tzChangeListener = transportZoneListener;
+ this.vtepConfigSchemaListener = vtepConfigSchemaListener;
this.ovsdbChangeListener = ovsdbNodeListener;
this.tunnelMonitoringConfig = tunnelMonitoringConfig;
this.entityOwnershipService = entityOwnershipService;
String gatewayIp, String transportZone) {
if (tepCommandHelper != null) {
try {
- tepCommandHelper.createLocalCache(dpnId, ipAddress, transportZone);
+ tepCommandHelper.createLocalCache(dpnId, portName, vlanId, ipAddress, subnetMask,
+ gatewayIp, transportZone);
} catch (TepException e) {
LOG.error("Create Local Cache failed", e);
}
public void deleteVtep(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask,
String gatewayIp, String transportZone) {
try {
- tepCommandHelper.deleteVtep(dpnId, ipAddress, transportZone);
+ tepCommandHelper.deleteVtep(dpnId, portName, vlanId, ipAddress,
+ subnetMask, gatewayIp, transportZone);
} catch (TepException e) {
LOG.error("Delete Vteps Failed", e);
}
}
}
+ @Override
+ public void addVtepConfigSchema(VtepConfigSchema vtepConfigSchema) {
+ VtepConfigSchema validatedSchema = ItmUtils.validateForAddVtepConfigSchema(vtepConfigSchema,
+ getAllVtepConfigSchemas());
+
+ String schemaName = validatedSchema.getSchemaName();
+ VtepConfigSchema existingSchema = getVtepConfigSchema(schemaName);
+ Preconditions.checkArgument(existingSchema == null, "VtepConfigSchema [" + schemaName + "] already exists!");
+ MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemaIdentifier(schemaName), validatedSchema);
+ LOG.debug("Vtep config schema {} added to config DS", schemaName);
+ }
+
+ @Override
+ public VtepConfigSchema getVtepConfigSchema(String schemaName) {
+ return ItmUtils.read(LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepConfigSchemaIdentifier(schemaName),
+ this.dataBroker).orNull();
+ }
+
+ @Override
+ public List<VtepConfigSchema> getAllVtepConfigSchemas() {
+ return ItmUtils.read(LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepConfigSchemasIdentifier(),
+ this.dataBroker).toJavaUtil().map(VtepConfigSchemas::getVtepConfigSchema).orElse(null);
+ }
+
+ @Override
+ public void updateVtepSchema(String schemaName, List<BigInteger> lstDpnsForAdd, List<BigInteger> lstDpnsForDelete) {
+ LOG.trace("Updating VTEP schema {} by adding DPN's {} and deleting DPN's {}.", schemaName, lstDpnsForAdd,
+ lstDpnsForDelete);
+
+ VtepConfigSchema schema = ItmUtils.validateForUpdateVtepSchema(schemaName, lstDpnsForAdd, lstDpnsForDelete,
+ this);
+ VtepConfigSchemaBuilder builder = new VtepConfigSchemaBuilder(schema);
+ /* if (ItmUtils.getDpnIdList(schema.getDpnIds()).isEmpty()) {
+ builder.setDpnIds(schema.getDpnIds());
+ } else {*/
+ if (lstDpnsForAdd != null && !lstDpnsForAdd.isEmpty()) {
+ List<BigInteger> originalDpnList = ItmUtils.getDpnIdList(schema.nonnullDpnIds());
+ originalDpnList.addAll(lstDpnsForAdd) ;
+ builder.setDpnIds(ItmUtils.getDpnIdsListFromBigInt(originalDpnList));
+ }
+ if (lstDpnsForDelete != null && !lstDpnsForDelete.isEmpty()) {
+ List<BigInteger> originalDpnList = ItmUtils.getDpnIdList(schema.nonnullDpnIds());
+ originalDpnList.removeAll(lstDpnsForDelete) ;
+ builder.setDpnIds(ItmUtils.getDpnIdsListFromBigInt(originalDpnList));
+ // schema.setDpnIds(ItmUtils.getDpnIdsListFromBigInt(ItmUtils.getDpnIdList(schema.getDpnIds())
+ // .removeAll(lstDpnsForAdd)));
+ }
+ // }
+ schema = builder.build();
+ MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemaIdentifier(schemaName), schema);
+ LOG.debug("Vtep config schema {} updated to config DS with DPN's {}",
+ schemaName, ItmUtils.getDpnIdList(schema.getDpnIds()));
+ }
+
+ @Override
+ public void deleteAllVtepSchemas() {
+ List<VtepConfigSchema> lstSchemas = getAllVtepConfigSchemas();
+ if (lstSchemas != null && !lstSchemas.isEmpty()) {
+ for (VtepConfigSchema schema : lstSchemas) {
+ MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepConfigSchemaIdentifier(schema.getSchemaName()));
+ }
+ }
+ LOG.debug("Deleted all Vtep schemas from config DS");
+ }
+
@Override
public void configureTunnelMonitorParams(boolean monitorEnabled, String monitorProtocol) {
tepCommandHelper.configureTunnelMonitorParams(monitorEnabled, monitorProtocol);
import static java.util.Collections.emptyList;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableMap;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
-import javax.annotation.Nonnull;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.interfacemanager.globals.IfmConstants;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.genius.itm.api.IITMProvider;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
import org.opendaylight.genius.itm.confighelpers.HwVtep;
import org.opendaylight.genius.itm.confighelpers.ItmTunnelAggregationHelper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptionsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepConfigSchemas;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepIpPools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIdsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpointsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeExternal;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
- //ITM cleanup:portname and vlanId are removed, causes change in generated
- //interface name: This has upgrade impact
public static String getInterfaceName(final BigInteger datapathid, final String portName, final Integer vlanId) {
return String.format("%s:%s:%s", datapathid, portName, vlanId);
}
+ public static BigInteger getDpnIdFromInterfaceName(String interfaceName) {
+ String[] dpnStr = interfaceName.split(":");
+ return new BigInteger(dpnStr[0]);
+ }
+
public static String getTrunkInterfaceName(String parentInterfaceName,
String localHostName, String remoteHostName, String tunnelType) {
String tunnelTypeStr;
}
public static TunnelEndPoints createTunnelEndPoints(BigInteger dpnId, IpAddress ipAddress, String portName,
- boolean isOfTunnel, int vlanId, List<TzMembership> zones,
+ boolean isOfTunnel, int vlanId, IpPrefix prefix,
+ IpAddress gwAddress, List<TzMembership> zones,
Class<? extends TunnelTypeBase> tunnelType,
String tos) {
// when Interface Mgr provides support to take in Dpn Id
- return new TunnelEndPointsBuilder().withKey(new TunnelEndPointsKey(ipAddress, tunnelType))
- .setTzMembership(zones)
+ return new TunnelEndPointsBuilder().withKey(new TunnelEndPointsKey(ipAddress, portName,tunnelType, vlanId))
+ .setSubnetMask(prefix).setGwIpAddress(gwAddress).setTzMembership(zones)
.setOptionOfTunnel(isOfTunnel).setInterfaceName(ItmUtils.getInterfaceName(dpnId, portName, vlanId))
.setTunnelType(tunnelType)
.setOptionTunnelTos(tos)
}
public static TunnelEndPoints createDummyTunnelEndPoints(BigInteger dpnID, IpAddress ipAddress, boolean ofTunnel,
- String tos, List<TzMembership> zones,
- Class<? extends TunnelTypeBase> tunnelType,
- String port, int vlanID) {
+ String tos, List<TzMembership> zones,
+ Class<? extends TunnelTypeBase> tunnelType) {
+ String port = ITMConstants.DUMMY_PORT;
+ int vlanID = ITMConstants.DUMMY_VLANID;
+ IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX);
+ IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
- return ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, ofTunnel,vlanID, zones,
- tunnelType, tos);
+ return ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, ofTunnel,vlanID, ipPrefix,
+ gatewayIP, zones, tunnelType, tos);
+ }
+
+ public static DpnEndpoints createDpnEndpoints(List<DPNTEPsInfo> dpnTepInfo) {
+ return new DpnEndpointsBuilder().setDPNTEPsInfo(dpnTepInfo).build();
}
public static InstanceIdentifier<Interface> buildId(String interfaceName) {
public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled,
Class<? extends TunnelTypeBase> tunType, IpAddress localIp,
- IpAddress remoteIp,
- Boolean monitorEnabled,
+ IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId,
+ boolean internal, Boolean monitorEnabled,
Class<? extends TunnelMonitoringTypeBase> monitorProtocol,
Integer monitorInterval, boolean useOfTunnel,
List<TunnelOptions> tunOptions) {
- return buildTunnelInterface(dpn, ifName, desc, enabled, tunType, localIp, remoteIp,
- monitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, null,
- tunOptions);
+ return buildTunnelInterface(dpn, ifName, desc, enabled, tunType, localIp, remoteIp, gatewayIp, vlanId,
+ internal, monitorEnabled, monitorProtocol, monitorInterval, useOfTunnel, null,
+ tunOptions);
}
public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled,
Class<? extends TunnelTypeBase> tunType, IpAddress localIp,
- IpAddress remoteIp,
- Boolean monitorEnabled,
+ IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId,
+ boolean internal, Boolean monitorEnabled,
Class<? extends TunnelMonitoringTypeBase> monitorProtocol,
Integer monitorInterval, boolean useOfTunnel, String parentIfaceName,
List<TunnelOptions> tunnelOptions) {
new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(parentIfaceName).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
Long monitoringInterval = null;
+ if (vlanId > 0) {
+ IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(new VlanId(vlanId)).build();
+ builder.addAugmentation(IfL2vlan.class, l2vlan);
+ }
LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}",
monitorProtocol.getName(),monitorInterval);
monitoringInterval = monitorInterval.longValue();
}
- IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp)
- .setTunnelSource(localIp).setTunnelInterfaceType(tunType)
+ IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp)
+ .setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal)
.setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol)
.setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel)
.setTunnelOptions(tunnelOptions)
@SuppressWarnings("checkstyle:IllegalCatch")
public static void addTerminatingServiceTable(TypedReadWriteTransaction<Configuration> tx,
- BigInteger dpnId, IMdsalApiManager mdsalManager) {
+ BigInteger dpnId, IMdsalApiManager mdsalManager) {
LOG.trace("Installing PUNT to Controller flow in DPN {} ", dpnId);
List<ActionInfo> listActionInfo = new ArrayList<>();
listActionInfo.add(new ActionPuntToController());
mkInstructions.add(new InstructionApplyActions(listActionInfo));
FlowEntity terminatingServiceTableFlowEntity = MDSALUtil
- .buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE,
- getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
- 5, String.format("%s:%d","ITM Flow Entry ", ITMConstants.LLDP_SERVICE_ID), 0, 0,
- ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(ITMConstants.LLDP_SERVICE_ID)),
- mkMatches, mkInstructions);
+ .buildFlowEntity(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE,
+ getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
+ 5, String.format("%s:%d","ITM Flow Entry ", ITMConstants.LLDP_SERVICE_ID), 0, 0,
+ ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(ITMConstants.LLDP_SERVICE_ID)),
+ mkMatches, mkInstructions);
mdsalManager.addFlow(tx, terminatingServiceTableFlowEntity);
} catch (Exception e) {
LOG.error("Error while setting up Table 36 for {}", dpnId, e);
@SuppressWarnings("checkstyle:IllegalCatch")
public static void removeTerminatingServiceTable(TypedReadWriteTransaction<Configuration> tx,
- BigInteger dpnId, IMdsalApiManager mdsalManager) {
+ BigInteger dpnId, IMdsalApiManager mdsalManager) {
LOG.trace("Removing PUNT to Controller flow in DPN {} ", dpnId);
try {
mdsalManager.removeFlow(tx, dpnId,
- getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
- NwConstants.INTERNAL_TUNNEL_TABLE);
+ getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, ITMConstants.LLDP_SERVICE_ID),
+ NwConstants.INTERNAL_TUNNEL_TABLE);
} catch (Exception e) {
LOG.error("Error while setting up Table 36 for {}", dpnId, e);
}
return String.valueOf(termSvcTable) + svcId;
}
+ public static InstanceIdentifier<VtepConfigSchema> getVtepConfigSchemaIdentifier(String schemaName) {
+ return InstanceIdentifier.builder(VtepConfigSchemas.class)
+ .child(VtepConfigSchema.class, new VtepConfigSchemaKey(schemaName)).build();
+ }
+
+ public static InstanceIdentifier<VtepConfigSchema> getVtepConfigSchemaIdentifier() {
+ return InstanceIdentifier.builder(VtepConfigSchemas.class).child(VtepConfigSchema.class).build();
+ }
+
+ public static InstanceIdentifier<VtepConfigSchemas> getVtepConfigSchemasIdentifier() {
+ return InstanceIdentifier.builder(VtepConfigSchemas.class).build();
+ }
+
+ public static InstanceIdentifier<VtepIpPool> getVtepIpPoolIdentifier(String subnetCidr) {
+ return InstanceIdentifier.builder(VtepIpPools.class).child(VtepIpPool.class, new VtepIpPoolKey(subnetCidr))
+ .build();
+ }
+
+ public static VtepConfigSchema validateForAddVtepConfigSchema(VtepConfigSchema schema,
+ List<VtepConfigSchema> existingSchemas) {
+ VtepConfigSchema validSchema = validateVtepConfigSchema(schema);
+ for (VtepConfigSchema existingSchema : emptyIfNull(existingSchemas)) {
+ if (!(!StringUtils.equalsIgnoreCase(schema.getSchemaName(), existingSchema.getSchemaName())
+ && Objects.equals(schema.getSubnet(), existingSchema.getSubnet()))) {
+ String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
+ Preconditions.checkArgument(
+ !(!StringUtils.equalsIgnoreCase(schema.getSchemaName(), existingSchema.getSchemaName())
+ && Objects.equals(schema.getSubnet(), existingSchema.getSubnet())),
+ "VTEP schema with subnet [" + subnetCidr
+ + "] already exists. Multiple VTEP schemas with same subnet is not allowed.");
+ }
+ }
+ if (isNotEmpty(getDpnIdList(validSchema.getDpnIds()))) {
+ String tzone = validSchema.getTransportZoneName();
+ List<BigInteger> lstDpns = getConflictingDpnsAlreadyConfiguredWithTz(validSchema.getSchemaName(), tzone,
+ getDpnIdList(validSchema.getDpnIds()), existingSchemas);
+ Preconditions.checkArgument(lstDpns.isEmpty(),
+ "DPN's " + lstDpns + " already configured for transport zone "
+ + tzone + ". Only one end point per transport Zone per Dpn is allowed.");
+ if (TunnelTypeGre.class.equals(schema.getTunnelType())) {
+ validateForSingleGreTep(validSchema.getSchemaName(), getDpnIdList(validSchema.getDpnIds()),
+ existingSchemas);
+ }
+ }
+ return validSchema;
+ }
+
+ private static void validateForSingleGreTep(String schemaName, List<BigInteger> lstDpnsForAdd,
+ List<VtepConfigSchema> existingSchemas) {
+ for (VtepConfigSchema existingSchema : emptyIfNull(existingSchemas)) {
+ if (TunnelTypeGre.class.equals(existingSchema.getTunnelType())
+ && !StringUtils.equalsIgnoreCase(schemaName, existingSchema.getSchemaName())) {
+ List<BigInteger> lstConflictingDpns = new ArrayList<>(getDpnIdList(existingSchema.getDpnIds()));
+ lstConflictingDpns.retainAll(emptyIfNull(lstDpnsForAdd));
+ Preconditions.checkArgument(lstConflictingDpns.isEmpty(), "DPN's " + lstConflictingDpns
+ + " already configured with GRE TEP. Mutiple GRE TEP's on a single DPN are not allowed.");
+ }
+ }
+ }
+
+ public static VtepConfigSchema validateVtepConfigSchema(VtepConfigSchema schema) {
+ Preconditions.checkNotNull(schema);
+ Preconditions.checkArgument(StringUtils.isNotBlank(schema.getSchemaName()));
+ Preconditions.checkArgument(StringUtils.isNotBlank(schema.getPortName()));
+ Preconditions.checkArgument(schema.getVlanId() >= 0 && schema.getVlanId() < 4095,
+ "Invalid VLAN ID, range (0-4094)");
+ Preconditions.checkArgument(StringUtils.isNotBlank(schema.getTransportZoneName()));
+ Preconditions.checkNotNull(schema.getSubnet());
+ String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
+ SubnetUtils subnetUtils = new SubnetUtils(subnetCidr);
+ IpAddress gatewayIp = schema.getGatewayIp();
+ if (gatewayIp != null) {
+ String strGatewayIp = gatewayIp.stringValue();
+ Preconditions.checkArgument(
+ ITMConstants.DUMMY_IP_ADDRESS.equals(strGatewayIp) || subnetUtils.getInfo().isInRange(strGatewayIp),
+ "Gateway IP address " + strGatewayIp + " is not in subnet range " + subnetCidr);
+ }
+ ItmUtils.getExcludeIpAddresses(schema.getExcludeIpFilter(), subnetUtils.getInfo());
+ return new VtepConfigSchemaBuilder(schema).setTunnelType(schema.getTunnelType()).build();
+ }
+
+ public static String validateTunnelType(String tunnelType) {
+ if (tunnelType == null) {
+ tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
+ } else {
+ tunnelType = StringUtils.upperCase(tunnelType);
+ String error = "Invalid tunnel type. Valid values: "
+ + ITMConstants.TUNNEL_TYPE_VXLAN + " | " + ITMConstants.TUNNEL_TYPE_GRE;
+ Preconditions.checkArgument(ITMConstants.TUNNEL_TYPE_VXLAN.equals(tunnelType)
+ || ITMConstants.TUNNEL_TYPE_GRE.equals(tunnelType), error);
+ }
+ return tunnelType;
+ }
+
+ private static List<BigInteger> getConflictingDpnsAlreadyConfiguredWithTz(String schemaName, String tzone,
+ List<BigInteger> lstDpns,
+ List<VtepConfigSchema> existingSchemas) {
+ List<BigInteger> lstConflictingDpns = new ArrayList<>();
+ for (VtepConfigSchema schema : emptyIfNull(existingSchemas)) {
+ if (!StringUtils.equalsIgnoreCase(schemaName, schema.getSchemaName())
+ && StringUtils.equals(schema.getTransportZoneName(), tzone)) {
+ lstConflictingDpns = new ArrayList<>(getDpnIdList(schema.nonnullDpnIds()));
+ lstConflictingDpns.retainAll(lstDpns);
+ if (!lstConflictingDpns.isEmpty()) {
+ break;
+ }
+ }
+ }
+ return lstConflictingDpns;
+ }
+
+ public static VtepConfigSchema constructVtepConfigSchema(String schemaName, String portName, Integer vlanId,
+ String subnetMask, String gatewayIp, String transportZone,
+ String tunnelType, List<BigInteger> dpnIds,
+ String excludeIpFilter) {
+ IpAddress gatewayIpObj = StringUtils.isBlank(gatewayIp) ? null : IpAddressBuilder.getDefaultInstance(gatewayIp);
+ IpPrefix subnet = StringUtils.isBlank(subnetMask) ? null : IpPrefixBuilder.getDefaultInstance(subnetMask);
+ Class<? extends TunnelTypeBase> tunType ;
+ if (tunnelType.equals(ITMConstants.TUNNEL_TYPE_VXLAN)) {
+ tunType = TunnelTypeVxlan.class ;
+ } else {
+ tunType = TunnelTypeGre.class ;
+ }
+ VtepConfigSchemaBuilder schemaBuilder = new VtepConfigSchemaBuilder().setSchemaName(schemaName)
+ .setPortName(portName).setVlanId(vlanId).setSubnet(subnet).setGatewayIp(gatewayIpObj)
+ .setTransportZoneName(transportZone).setTunnelType(tunType).setDpnIds(getDpnIdsListFromBigInt(dpnIds))
+ .setExcludeIpFilter(excludeIpFilter);
+ return schemaBuilder.build();
+ }
+
+ public static List<IpAddress> getExcludeIpAddresses(String excludeIpFilter, SubnetInfo subnetInfo) {
+ final List<IpAddress> lstIpAddress = new ArrayList<>();
+ if (StringUtils.isBlank(excludeIpFilter)) {
+ return lstIpAddress;
+ }
+ final String[] arrIps = StringUtils.split(excludeIpFilter, ',');
+ for (String ip : arrIps) {
+ if (StringUtils.countMatches(ip, "-") == 1) {
+ final String[] arrIpRange = StringUtils.split(ip, '-');
+ String strStartIp = StringUtils.trim(arrIpRange[0]);
+ String strEndIp = StringUtils.trim(arrIpRange[1]);
+ Preconditions.checkArgument(InetAddresses.isInetAddress(strStartIp),
+ "Invalid exclude IP filter: invalid IP address value " + strStartIp);
+ Preconditions.checkArgument(InetAddresses.isInetAddress(strEndIp),
+ "Invalid exclude IP filter: invalid IP address value " + strEndIp);
+ Preconditions.checkArgument(subnetInfo.isInRange(strStartIp),
+ "Invalid exclude IP filter: IP address [" + strStartIp
+ + "] not in subnet range " + subnetInfo.getCidrSignature());
+ Preconditions.checkArgument(subnetInfo.isInRange(strEndIp),
+ "Invalid exclude IP filter: IP address [" + strEndIp
+ + "] not in subnet range " + subnetInfo.getCidrSignature());
+ int startIp = subnetInfo.asInteger(strStartIp);
+ int endIp = subnetInfo.asInteger(strEndIp);
+
+ Preconditions.checkArgument(startIp < endIp,
+ "Invalid exclude IP filter: Invalid range [" + ip + "] ");
+ for (int iter = startIp; iter <= endIp; iter++) {
+ String ipAddress = ipFormat(toIpArray(iter));
+ validateAndAddIpAddressToList(subnetInfo, lstIpAddress, ipAddress);
+ }
+ } else {
+ validateAndAddIpAddressToList(subnetInfo, lstIpAddress, ip);
+ }
+ }
+ return lstIpAddress;
+ }
+
+ private static void validateAndAddIpAddressToList(SubnetInfo subnetInfo, final List<IpAddress> lstIpAddress,
+ String ipAddress) {
+ String ip = StringUtils.trim(ipAddress);
+ Preconditions.checkArgument(InetAddresses.isInetAddress(ip),
+ "Invalid exclude IP filter: invalid IP address value " + ip);
+ Preconditions.checkArgument(subnetInfo.isInRange(ip),
+ "Invalid exclude IP filter: IP address [" + ip + "] not in subnet range "
+ + subnetInfo.getCidrSignature());
+ lstIpAddress.add(IpAddressBuilder.getDefaultInstance(ip));
+ }
+
+ private static int[] toIpArray(int val) {
+ int[] ret = new int[4];
+ for (int iter = 3; iter >= 0; --iter) {
+ ret[iter] |= val >>> 8 * (3 - iter) & 0xff;
+ }
+ return ret;
+ }
+
+ private static String ipFormat(int[] octets) {
+ StringBuilder str = new StringBuilder();
+ for (int iter = 0; iter < octets.length; ++iter) {
+ str.append(octets[iter]);
+ if (iter != octets.length - 1) {
+ str.append(".");
+ }
+ }
+ return str.toString();
+ }
+
+ public static VtepConfigSchema validateForUpdateVtepSchema(String schemaName, List<BigInteger> lstDpnsForAdd,
+ List<BigInteger> lstDpnsForDelete,
+ IITMProvider itmProvider) {
+ Preconditions.checkArgument(StringUtils.isNotBlank(schemaName));
+ Preconditions.checkArgument(lstDpnsForAdd != null && !lstDpnsForAdd.isEmpty() && lstDpnsForDelete != null
+ && !lstDpnsForDelete.isEmpty(),
+ "DPN ID list for add | delete is null or empty in schema " + schemaName);
+ VtepConfigSchema schema = itmProvider.getVtepConfigSchema(schemaName);
+ Preconditions.checkArgument(schema != null, "Specified VTEP Schema [" + schemaName + "] doesn't exist!");
+ List<BigInteger> existingDpnIds = getDpnIdList(schema.nonnullDpnIds());
+ if (isNotEmpty(lstDpnsForAdd)) {
+ List<BigInteger> lstAlreadyExistingDpns = new ArrayList<>(existingDpnIds);
+ lstAlreadyExistingDpns.retainAll(lstDpnsForAdd);
+ Preconditions.checkArgument(lstAlreadyExistingDpns.isEmpty(),
+ "DPN ID's " + lstAlreadyExistingDpns
+ + " already exists in VTEP schema [" + schemaName + "]");
+ if (TunnelTypeGre.class.equals(schema.getTunnelType())) {
+ validateForSingleGreTep(schema.getSchemaName(), lstDpnsForAdd, itmProvider.getAllVtepConfigSchemas());
+ }
+ }
+ if (isNotEmpty(lstDpnsForDelete)) {
+ Preconditions.checkArgument(!existingDpnIds.isEmpty(), "DPN ID's " + lstDpnsForDelete
+ + " specified for delete from VTEP schema [" + schemaName
+ + "] are not configured in the schema.");
+ if (!existingDpnIds.containsAll(lstDpnsForDelete)) {
+ List<BigInteger> lstConflictingDpns = new ArrayList<>(lstDpnsForDelete);
+ lstConflictingDpns.removeAll(existingDpnIds);
+ throw new IllegalArgumentException("DPN ID's " + lstConflictingDpns
+ + " specified for delete from VTEP schema [" + schemaName
+ + "] are not configured in the schema.");
+ }
+ }
+ return schema;
+ }
+
+ public static String getSubnetCidrAsString(IpPrefix subnet) {
+ return subnet == null ? StringUtils.EMPTY : subnet.stringValue();
+ }
+
+ public static <T> List<T> emptyIfNull(List<T> list) {
+ return list == null ? emptyList() : list;
+ }
+
public static <T> boolean isEmpty(Collection<T> collection) {
return collection == null || collection.isEmpty();
}
- @Nonnull
- public static HwVtep createHwVtepObject(String topoId, String nodeId, IpAddress ipAddress,
+ public static <T> boolean isNotEmpty(Collection<T> collection) {
+ return !isEmpty(collection);
+ }
+
+ @NonNull
+ public static HwVtep createHwVtepObject(String topoId, String nodeId, IpAddress ipAddress, IpPrefix ipPrefix,
+ IpAddress gatewayIP, int vlanID,
Class<? extends TunnelTypeBase> tunneltype, TransportZone transportZone) {
HwVtep hwVtep = new HwVtep();
+ hwVtep.setGatewayIP(gatewayIP);
hwVtep.setHwIp(ipAddress);
+ hwVtep.setIpPrefix(ipPrefix);
hwVtep.setNodeId(nodeId);
hwVtep.setTopoId(topoId);
hwVtep.setTransportZone(transportZone.getZoneName());
hwVtep.setTunnelType(tunneltype);
+ hwVtep.setVlanID(vlanID);
return hwVtep;
}
}
}
+ @NonNull
+ public static List<BigInteger> getDpnIdList(List<DpnIds> dpnIds) {
+ List<BigInteger> dpnList = new ArrayList<>() ;
+ for (DpnIds dpn : dpnIds) {
+ dpnList.add(dpn.getDPN()) ;
+ }
+ return dpnList ;
+ }
+
+ public static List<DpnIds> getDpnIdsListFromBigInt(List<BigInteger> dpnIds) {
+ List<DpnIds> dpnIdList = new ArrayList<>();
+ DpnIdsBuilder builder = new DpnIdsBuilder();
+ for (BigInteger dpnId : dpnIds) {
+ dpnIdList.add(builder.withKey(new DpnIdsKey(dpnId)).setDPN(dpnId).build());
+ }
+ return dpnIdList;
+ }
+
public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
.rev140508.interfaces.state.Interface> buildStateInterfaceId(
String interfaceName) {
return InstanceIdentifier.builder(InterfacesState.class)
.child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
- .state.Interface.class,
- new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
- .rev140508.interfaces.state.InterfaceKey(
- interfaceName)).build();
+ .state.Interface.class,
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
+ .rev140508.interfaces.state.InterfaceKey(
+ interfaceName)).build();
}
@NonNull
return tunnelList;
}
+ public static List<String> getTunnelsofTzone(List<HwVtep> hwVteps, String tzone, DataBroker dataBroker,
+ Boolean hwVtepsExist) {
+ List<String> tunnels = new ArrayList<>();
+ InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(tzone)).build();
+ Optional<TransportZone> transportZoneOptional =
+ ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
+ if (transportZoneOptional.isPresent()) {
+ TransportZone transportZone = transportZoneOptional.get();
+ Class<? extends TunnelTypeBase> tunType = transportZone.getTunnelType();
+ if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
+ for (Subnets sub : transportZone.getSubnets()) {
+ if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
+ for (Vteps vtepLocal : sub.getVteps()) {
+ for (Vteps vtepRemote : sub.getVteps()) {
+ if (!vtepLocal.equals(vtepRemote)) {
+ InternalTunnelKey key = new InternalTunnelKey(vtepRemote.getDpnId(),
+ vtepLocal.getDpnId(), tunType);
+ InstanceIdentifier<InternalTunnel> intIID =
+ InstanceIdentifier.builder(TunnelList.class)
+ .child(InternalTunnel.class, key).build();
+ Optional<InternalTunnel> tunnelsOptional =
+ ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
+ if (tunnelsOptional.isPresent()) {
+ List<String> tunnelInterfaceNames = tunnelsOptional
+ .get().getTunnelInterfaceNames();
+ if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
+ String tunnelInterfaceName = tunnelInterfaceNames.get(0);
+ LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
+ tunnels.add(tunnelInterfaceName);
+ }
+ }
+ }
+ }
+ if (hwVteps != null && !hwVteps.isEmpty()) {
+ for (HwVtep hwVtep : hwVteps) {
+ tunnels.add(getExtTunnel(hwVtep.getNodeId(), vtepLocal.getDpnId().toString(),
+ tunType, dataBroker));
+ tunnels.add(getExtTunnel(vtepLocal.getDpnId().toString(), hwVtep.getNodeId(),
+ tunType, dataBroker));
+ }
+ }
+ }
+ }
+ }
+ }
+ if (hwVtepsExist && hwVteps != null) {
+ for (HwVtep hwVtep : hwVteps) {
+ for (HwVtep hwVtepOther : hwVteps) {
+ if (!hwVtep.getHwIp().equals(hwVtepOther.getHwIp())) {
+ tunnels.add(getExtTunnel(hwVtep.getNodeId(), hwVtepOther.getNodeId(),
+ tunType, dataBroker));
+ tunnels.add(getExtTunnel(hwVtepOther.getNodeId(), hwVtep.getNodeId(),
+ tunType, dataBroker));
+ }
+ }
+ }
+ }
+ }
+ return tunnels;
+ }
+
+ public static List<String> getInternalTunnelsofTzone(String tzone, DataBroker dataBroker) {
+ List<String> tunnels = new ArrayList<>();
+ LOG.trace("Getting internal tunnels of {}",tzone);
+ InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(tzone)).build();
+ Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,
+ path, dataBroker);
+ if (transportZoneOptional.isPresent()) {
+ TransportZone transportZone = transportZoneOptional.get();
+ if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
+ for (Subnets sub : transportZone.getSubnets()) {
+ if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
+ for (Vteps vtepLocal : sub.getVteps()) {
+ for (Vteps vtepRemote : sub.getVteps()) {
+ if (!vtepLocal.equals(vtepRemote)) {
+ InternalTunnelKey key =
+ new InternalTunnelKey(vtepRemote.getDpnId(), vtepLocal.getDpnId(),
+ transportZone.getTunnelType());
+ InstanceIdentifier<InternalTunnel> intIID =
+ InstanceIdentifier.builder(TunnelList.class)
+ .child(InternalTunnel.class, key).build();
+ Optional<InternalTunnel> tunnelsOptional =
+ ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
+ if (tunnelsOptional.isPresent()) {
+ List<String> tunnelInterfaceNames = tunnelsOptional.get()
+ .getTunnelInterfaceNames();
+ if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
+ String tunnelInterfaceName = tunnelInterfaceNames.get(0);
+ LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
+ tunnels.add(tunnelInterfaceName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return tunnels;
+ }
+
+ private static String getExtTunnel(String nodeId, String dpId,Class<? extends TunnelTypeBase> tunType, DataBroker
+ dataBroker) {
+ LOG.trace("getting ext tunnel for {} and dpId {}",nodeId,dpId);
+ ExternalTunnelKey key = getExternalTunnelKey(dpId, nodeId, tunType);
+ InstanceIdentifier<ExternalTunnel> intIID = InstanceIdentifier.builder(ExternalTunnelList.class)
+ .child(ExternalTunnel.class, key).build();
+ Optional<ExternalTunnel> tunnelsOptional =
+ ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
+ if (tunnelsOptional.isPresent()) {
+ String tunnelInterfaceName = tunnelsOptional.get().getTunnelInterfaceName();
+ LOG.trace("ext tunnel returned {} ", tunnelInterfaceName);
+ return tunnelInterfaceName;
+ }
+ return null;
+ }
+
@SuppressFBWarnings("RV_CHECK_FOR_POSITIVE_INDEXOF")
public static ExternalTunnelKey getExternalTunnelKey(String dst , String src,
Class<? extends TunnelTypeBase> tunType) {
* @return the TepsInNotHostedTransportZone object in the TepsNotHosted list in Oper DS
*/
public static TepsInNotHostedTransportZone getUnknownTransportZoneFromITMOperDS(
- String unknownTz, DataBroker dataBroker) {
+ String unknownTz, DataBroker dataBroker) {
InstanceIdentifier<TepsInNotHostedTransportZone> unknownTzPath =
- InstanceIdentifier.builder(NotHostedTransportZones.class)
- .child(TepsInNotHostedTransportZone.class,
- new TepsInNotHostedTransportZoneKey(unknownTz)).build();
+ InstanceIdentifier.builder(NotHostedTransportZones.class)
+ .child(TepsInNotHostedTransportZone.class,
+ new TepsInNotHostedTransportZoneKey(unknownTz)).build();
Optional<TepsInNotHostedTransportZone> unknownTzOptional =
- ItmUtils.read(LogicalDatastoreType.OPERATIONAL, unknownTzPath, dataBroker);
+ ItmUtils.read(LogicalDatastoreType.OPERATIONAL, unknownTzPath, dataBroker);
if (unknownTzOptional.isPresent()) {
return unknownTzOptional.get();
}
NodeId ovsdbNodeId = node.key().getNodeId();
NodeId brNodeId = new NodeId(ovsdbNodeId.getValue()
- + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
+ + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
InstanceIdentifier<Node> bridgeIid =
- InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID))
- .child(Node.class,new NodeKey(brNodeId));
+ InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID))
+ .child(Node.class,new NodeKey(brNodeId));
Optional<Node> opBridgeNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
* @return the Network Topology Node i.e. OVSDB node which is managing the specified bridge
*/
public static Node getOvsdbNode(OvsdbBridgeAugmentation bridgeAugmentation,
- DataBroker dataBroker) {
+ DataBroker dataBroker) {
Node ovsdbNode = null;
Optional<Node> opOvsdbNode = Optional.absent();
if (bridgeAugmentation != null) {
InstanceIdentifier<Node> ovsdbNodeIid =
- (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue();
+ (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue();
opOvsdbNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, ovsdbNodeIid, dataBroker);
}
if (opOvsdbNode.isPresent()) {
String tos = itmConfig.getDefaultTunnelTos();
Class<? extends TunnelTypeBase> tunnelType = TunnelTypeVxlan.class;
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(oldTzName);
-
- String portName = (itmConfig.getPortname() == null) ? ITMConstants.DUMMY_PORT : itmConfig.getPortname();
- int vlanId = (itmConfig.getVlanId() != null) ? itmConfig.getVlanId() : ITMConstants.DUMMY_VLANID;
-
TunnelEndPoints tunnelEndPoints = ItmUtils.createDummyTunnelEndPoints(dpnId, tepIpAddress, newOfTunnel,
- tos, zones, tunnelType, portName, vlanId);
+ tos, zones, tunnelType);
String finalTzName = tzName;
String finalJobKey = jobKey;
String finalLocalIp = newLocalIp;
import org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry;
import org.opendaylight.serviceutils.tools.mdsal.listener.AbstractSyncDataTreeChangeListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final ServiceRecoveryRegistry serviceRecoveryRegistry,
final DataTreeEventCallbackRegistrar eventCallbacks) {
super(dataBroker, LogicalDatastoreType.CONFIGURATION,
- InstanceIdentifier.create(TransportZones.class).child(TransportZone.class));
+ InstanceIdentifier.create(TransportZones.class).child(TransportZone.class));
this.dataBroker = dataBroker;
this.jobCoordinator = jobCoordinator;
this.mdsalManager = mdsalManager;
if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
LOG.trace("Delete: Invoking ItmManager with hwVtep List {} ", hwVtepList);
jobCoordinator.enqueueJob(transportZone.getZoneName(),
- new ItmTepRemoveWorker(opDpnList, hwVtepList, transportZone, mdsalManager,
- itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
-
- if (transportZone.getVteps() != null && !transportZone.getVteps().isEmpty()) {
- List<UnknownVteps> unknownVteps = convertVtepListToUnknownVtepList(transportZone.getVteps());
- LOG.trace("Moving Transport Zone {} to tepsInNotHostedTransportZone Oper Ds.",
- transportZone.getZoneName());
- jobCoordinator.enqueueJob(transportZone.getZoneName(),
- new ItmTepsNotHostedAddWorker(unknownVteps, transportZone.getZoneName(),
- dataBroker, txRunner));
+ new ItmTepRemoveWorker(opDpnList, hwVtepList, transportZone, mdsalManager,
+ itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner));
+
+ //When tz delete event arrives for a particular Transport zone,
+ // teps under TZ will be moved to tepsInNotHostedTransportZone Oper DS.
+ // So that if the same name tz gets re-added from NBI, then these tep's will go back to re-added tz.
+ for (Subnets sub : transportZone.getSubnets()) {
+ if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
+ List<UnknownVteps> unknownVteps = convertVtepListToUnknownVtepList(sub.getVteps());
+ LOG.trace("Moving Transport Zone {} to tepsInNotHostedTransportZone Oper Ds.",
+ transportZone.getZoneName());
+ jobCoordinator.enqueueJob(transportZone.getZoneName(),
+ new ItmTepsNotHostedAddWorker(unknownVteps, transportZone.getZoneName(),
+ dataBroker, txRunner));
+ }
}
}
}
public void update(@NonNull InstanceIdentifier<TransportZone> instanceIdentifier,
@NonNull TransportZone originalTransportZone, @NonNull TransportZone updatedTransportZone) {
LOG.debug("Received Transport Zone Update Event: Old - {}, Updated - {}", originalTransportZone,
- updatedTransportZone);
+ updatedTransportZone);
List<DPNTEPsInfo> oldDpnTepsList = createDPNTepInfo(originalTransportZone);
List<DPNTEPsInfo> newDpnTepsList = createDPNTepInfo(updatedTransportZone);
List<DPNTEPsInfo> oldDpnTepsListcopy = new ArrayList<>();
if (!oldDpnTepsList.isEmpty() && !equalLists) {
LOG.trace("Removing TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
- new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, mdsalManager,
- itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
+ new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, mdsalManager,
+ itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner));
}
List<HwVtep> oldHwList = createhWVteps(originalTransportZone);
List<HwVtep> newHwList = createhWVteps(updatedTransportZone);
if (!oldHwList.isEmpty()) {
LOG.trace("Removing HW TEPs ");
jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(),
- new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, mdsalManager,
- itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner, itmConfig));
+ new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, mdsalManager,
+ itmInternalTunnelDeleteWorker, dpnTEPsInfoCache, txRunner));
}
}
LOG.trace("Add: Invoking ItmManager with DPN List {} ", opDpnList);
LOG.trace("Add: Invoking ItmManager with hwVtep List {} ", hwVtepList);
jobCoordinator.enqueueJob(transportZone.getZoneName(),
- new ItmTepAddWorker(opDpnList, hwVtepList, dataBroker, mdsalManager, itmInternalTunnelAddWorker,
- externalTunnelAddWorker));
+ new ItmTepAddWorker(opDpnList, hwVtepList, dataBroker, mdsalManager, itmInternalTunnelAddWorker,
+ externalTunnelAddWorker));
}
}
if (unVtepsLst != null && !unVtepsLst.isEmpty()) {
for (UnknownVteps vteps : unVtepsLst) {
BigInteger dpnID = vteps.getDpnId();
+ String port = ITMConstants.DUMMY_PORT;
+ int vlanID = ITMConstants.DUMMY_VLANID;
+ IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX);
+ IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
IpAddress ipAddress = vteps.getIpAddress();
- String portName = (itmConfig.getPortname() == null) ? ITMConstants.DUMMY_PORT : itmConfig.getPortname();
- int vlanId = (itmConfig.getVlanId() != null) ? itmConfig.getVlanId() : ITMConstants.DUMMY_VLANID;
boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOfTunnel());
String tos = vteps.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
TunnelEndPoints tunnelEndPoints =
- ItmUtils.createTunnelEndPoints(dpnID, ipAddress, portName, useOfTunnel, vlanId, zones,
- tunnelType, tos);
+ ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel,vlanID, ipPrefix,
+ gatewayIP, zones, tunnelType, tos);
List<TunnelEndPoints> tunnelEndPointsList = mapNotHostedDPNToTunnelEndpt.get(dpnID);
if (tunnelEndPointsList != null) {
tunnelEndPointsList.add(tunnelEndPoints);
tunnelEndPointsList.add(tunnelEndPoints);
mapNotHostedDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
}
- Vteps newVtep = createVtepFromUnKnownVteps(dpnID,ipAddress);
+ Vteps newVtep = createVtepFromUnKnownVteps(dpnID,ipAddress,ITMConstants.DUMMY_PORT);
vtepsList.add(newVtep);
// Enqueue 'remove TEP from TepsNotHosted list' operation
// into DataStoreJobCoordinator
jobCoordinator.enqueueJob(newZoneName,
- new ItmTepsNotHostedRemoveWorker(newZoneName, ipAddress, dpnID, dataBroker, txRunner));
+ new ItmTepsNotHostedRemoveWorker(newZoneName, ipAddress, dpnID, dataBroker, txRunner));
}
}
//avoiding duplicate vteps which are already present in dpn list pushed from NBI
}
- private Vteps createVtepFromUnKnownVteps(BigInteger dpnID, IpAddress ipAddress) {
- VtepsKey vtepkey = new VtepsKey(dpnID);
+ private Vteps createVtepFromUnKnownVteps(BigInteger dpnID, IpAddress ipAddress, String port) {
+ VtepsKey vtepkey = new VtepsKey(dpnID, port);
Vteps vtepObj = new VtepsBuilder().setDpnId(dpnID).setIpAddress(ipAddress).withKey(vtepkey)
- .build();
+ .setPortname(port).build();
return vtepObj;
}
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(transportZone.getZoneName());
Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
LOG.trace("Transport Zone_name: {}", transportZone.getZoneName());
- List<Vteps> vtepsList = transportZone.getVteps();
-
- String portName = (itmConfig.getPortname() == null) ? ITMConstants.DUMMY_PORT : itmConfig.getPortname();
- int vlanId = (itmConfig.getVlanId() != null) ? itmConfig.getVlanId() : ITMConstants.DUMMY_VLANID;
-
- if (vtepsList != null && !vtepsList.isEmpty()) {
- for (Vteps vteps : vtepsList) {
- BigInteger dpnID = vteps.getDpnId();
- IpAddress ipAddress = vteps.getIpAddress();
- boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOptionOfTunnel());
- String tos = vteps.getOptionTunnelTos();
- if (tos == null) {
- tos = itmConfig.getDefaultTunnelTos();
- }
- LOG.trace("DpnID: {}, ipAddress: {}", dpnID, ipAddress);
- TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, portName,
- useOfTunnel, vlanId, 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);
+ 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);
+ }
+ }
}
}
}
String zoneName = transportZone.getZoneName();
Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
LOG.trace("Transport Zone_name: {}", zoneName);
- List<DeviceVteps> deviceVtepsList = transportZone.getDeviceVteps();
- if (deviceVtepsList != null) {
- for (DeviceVteps vteps : deviceVtepsList) {
- String topologyId = vteps.getTopologyId();
- String nodeId = vteps.getNodeId();
- IpAddress ipAddress = vteps.getIpAddress();
- LOG.trace("topo-id: {}, node-id: {}, ipAddress: {}", topologyId, nodeId, ipAddress);
- HwVtep hwVtep = ItmUtils.createHwVtepObject(topologyId, nodeId, ipAddress,
- tunnelType, transportZone);
-
- LOG.trace("Adding new HwVtep {} info ", hwVtep.getHwIp());
- hwVtepsList.add(hwVtep);
+ 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<DeviceVteps> deviceVtepsList = subnet.getDeviceVteps();
+ if (deviceVtepsList != null) {
+ for (DeviceVteps vteps : deviceVtepsList) {
+ String topologyId = vteps.getTopologyId();
+ String nodeId = vteps.getNodeId();
+ IpAddress ipAddress = vteps.getIpAddress();
+ LOG.trace("topo-id: {}, node-id: {}, ipAddress: {}", topologyId, nodeId, ipAddress);
+ HwVtep hwVtep = ItmUtils.createHwVtepObject(topologyId, nodeId, ipAddress, ipPrefix, gatewayIP,
+ vlanID, tunnelType, transportZone);
+
+ LOG.trace("Adding new HwVtep {} info ", hwVtep.getHwIp());
+ hwVtepsList.add(hwVtep);
+ }
+ }
}
}
LOG.trace("returning hwvteplist {}", hwVtepsList);
--- /dev/null
+/*
+ * Copyright (c) 2016, 2018 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.genius.itm.listeners;
+
+import com.google.common.base.Optional;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.ExecutionException;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.itm.cache.UnprocessedTunnelsStateCache;
+import org.opendaylight.genius.itm.cli.TepCommandHelper;
+import org.opendaylight.genius.itm.cli.TepException;
+import org.opendaylight.genius.itm.globals.ITMConstants;
+import org.opendaylight.genius.itm.impl.ItmUtils;
+import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.infrautils.utils.concurrent.Executors;
+import org.opendaylight.serviceutils.tools.mdsal.listener.AbstractAsyncDataTreeChangeListener;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.VtepConfigSchemas;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The listener class interested in processing data change on.
+ * {@code VtepConfigSchema} objects.
+ *
+ * @see VtepConfigSchema
+ */
+@Singleton
+public class VtepConfigSchemaListener extends AbstractAsyncDataTreeChangeListener<VtepConfigSchema> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VtepConfigSchemaListener.class);
+
+ private final DataBroker dataBroker;
+
+ /** Blueprint XML config file handle. */
+ private final ItmConfig itmConfig;
+ private final UnprocessedTunnelsStateCache unprocessedTunnelsStateCache;
+
+ /**
+ * Instantiates a new VTEP config schema listener.
+ *
+ * @param dataBroker
+ * the db
+ * @param itmConfig
+ * ITM config file handle
+ */
+ @Inject
+ public VtepConfigSchemaListener(DataBroker dataBroker, ItmConfig itmConfig,
+ UnprocessedTunnelsStateCache unprocessedTunnelsStateCache) {
+ super(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(VtepConfigSchemas.class).child(VtepConfigSchema.class), Executors
+ .newSingleThreadExecutor("VtepConfigSchemaListener", LOG));
+ this.dataBroker = dataBroker;
+ this.itmConfig = itmConfig;
+ this.unprocessedTunnelsStateCache = unprocessedTunnelsStateCache;
+ }
+
+ @Override
+ public void remove(@NonNull InstanceIdentifier<VtepConfigSchema> instanceIdentifier,
+ @NonNull VtepConfigSchema vtepConfigSchema) {
+ LOG.trace("Received notification for VTEP config schema [{}] deleted.", vtepConfigSchema.getSchemaName());
+ List<BigInteger> lstDpnIds = ItmUtils.getDpnIdList(vtepConfigSchema.nonnullDpnIds());
+ if (!lstDpnIds.isEmpty()) {
+ deleteVteps(vtepConfigSchema, lstDpnIds);
+ }
+ // Delete IP pool corresponding to schema
+ // TODO: Ensure no schema exists with same subnet before deleting
+ String subnetCidr = ItmUtils.getSubnetCidrAsString(vtepConfigSchema.getSubnet());
+ deleteVtepIpPool(subnetCidr);
+ }
+
+ @Override
+ public void update(@NonNull InstanceIdentifier<VtepConfigSchema> instanceIdentifier,
+ @NonNull VtepConfigSchema originalVtepConfigSchema,
+ @NonNull VtepConfigSchema updatedConfigSchema) {
+ LOG.error("Received DCN for updating VTEP Original schema: {}. Updated schema: {}", originalVtepConfigSchema,
+ updatedConfigSchema);
+ VtepConfigSchema originalSchema = ItmUtils.validateVtepConfigSchema(originalVtepConfigSchema);
+ VtepConfigSchema updatedSchema = ItmUtils.validateVtepConfigSchema(updatedConfigSchema);
+
+ if (doesDeleteAndAddSchemaRequired(originalVtepConfigSchema, updatedConfigSchema)) {
+ LOG.error("Failed to handle DCN for updating VTEP schema. Original schema: {}. Updated schema: {}",
+ originalVtepConfigSchema, updatedConfigSchema);
+ // TODO: handle updates
+ return;
+ }
+
+ handleUpdateOfDpnIds(originalSchema, updatedSchema);
+ }
+
+ @Override
+ public void add(@NonNull InstanceIdentifier<VtepConfigSchema> instanceIdentifier,
+ @NonNull VtepConfigSchema vtepConfigSchema) {
+ // Construct the transport zones from the provided schemas and push it to config DS
+ LOG.trace("Add VtepConfigSchema: {}", vtepConfigSchema);
+
+ VtepConfigSchema validatedSchema = ItmUtils
+ .validateForAddVtepConfigSchema(vtepConfigSchema, getAllVtepConfigSchemas());
+
+ VtepIpPool vtepIpPool = processAvailableIps(validatedSchema);
+ try {
+ addVteps(validatedSchema, vtepIpPool);
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.error("Add VtepConfigSchema failed : {}", vtepConfigSchema, e);
+ }
+ }
+
+ /**
+ * Handle update of dpn ids.
+ *
+ * @param original
+ * the original
+ * @param updated
+ * the updated
+ */
+ private void handleUpdateOfDpnIds(VtepConfigSchema original, VtepConfigSchema updated) {
+ // Handling add/delete DPNs from schema
+ List<DpnIds> originalDpnIds = original.getDpnIds() == null ? new ArrayList<>()
+ : original.getDpnIds();
+ List<DpnIds> updatedDpnIds = updated.getDpnIds() == null ? new ArrayList<>()
+ : updated.getDpnIds();
+
+ handleDeletedDpnsFromSchema(original, originalDpnIds, updatedDpnIds);
+ handleNewlyAddedDpnsToSchema(original, originalDpnIds, updatedDpnIds);
+ }
+
+ /**
+ * Does delete and add schema required.
+ *
+ * @param original
+ * the original
+ * @param updated
+ * the updated
+ * @return true, if successful
+ */
+ private boolean doesDeleteAndAddSchemaRequired(VtepConfigSchema original, VtepConfigSchema updated) {
+ boolean delnAddRequired = false;
+ if (!StringUtils.equalsIgnoreCase(original.getPortName(), updated.getPortName())) {
+ delnAddRequired = true;
+ } else if (!Objects.equals(original.getVlanId(), updated.getVlanId())) {
+ delnAddRequired = true;
+ } else if (original.getSubnet() != null && !original.getSubnet().equals(updated.getSubnet())) {
+ delnAddRequired = true;
+ } else if (original.getGatewayIp() != null && !original.getGatewayIp().equals(updated.getGatewayIp())) {
+ delnAddRequired = true;
+ } else if (!StringUtils.equalsIgnoreCase(original.getTransportZoneName(), updated.getTransportZoneName())) {
+ delnAddRequired = true;
+ } else if (!Objects.equals(original.getTunnelType(), updated.getTunnelType())) {
+ delnAddRequired = true;
+ }
+ return delnAddRequired;
+ }
+
+ /**
+ * Handle newly added dpns to schema.
+ *
+ * @param original
+ * the original
+ * @param originalDpnIds
+ * the original dpn ids
+ * @param updatedDpnIds
+ * the updated dpn ids
+ */
+ private void handleNewlyAddedDpnsToSchema(VtepConfigSchema original, List<DpnIds> originalDpnIds,
+ List<DpnIds> updatedDpnIds) {
+ LOG.trace("Handle Addition of DPNs from VTEP Original Dpn: {}. Updated Dpn: {}",
+ originalDpnIds, updatedDpnIds) ;
+ ArrayList<DpnIds> newlyAddedDpns = new ArrayList<>(updatedDpnIds);
+ newlyAddedDpns.removeAll(originalDpnIds);
+ LOG.debug("Newly added DPNs {} to VTEP config schema [{}].", newlyAddedDpns, original.getSchemaName());
+ if (!newlyAddedDpns.isEmpty()) {
+ VtepConfigSchema diffSchema = new VtepConfigSchemaBuilder(original).setDpnIds(newlyAddedDpns).build();
+ String subnetCidr = ItmUtils.getSubnetCidrAsString(original.getSubnet());
+ VtepIpPool vtepIpPool = getVtepIpPool(subnetCidr);
+ LOG.debug("Adding of DPNs in Diff Schema: {}", diffSchema) ;
+ try {
+ addVteps(diffSchema, vtepIpPool);
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.error("Add VtepConfigSchema failed : {}", diffSchema, e);
+ }
+ }
+ }
+
+ /**
+ * Handle deleted dpns from schema.
+ *
+ * @param original
+ * the original
+ * @param originalDpnIds
+ * the original dpn ids
+ * @param updatedDpnIds
+ * the updated dpn ids
+ */
+ private void handleDeletedDpnsFromSchema(VtepConfigSchema original, List<DpnIds> originalDpnIds,
+ List<DpnIds> updatedDpnIds) {
+ ArrayList<DpnIds> deletedDpns = new ArrayList<>(originalDpnIds);
+ deletedDpns.removeAll(updatedDpnIds);
+ LOG.debug("DPNs to be removed DPNs {} from VTEP config schema [{}].", deletedDpns, original.getSchemaName());
+ if (!deletedDpns.isEmpty()) {
+ LOG.debug("Deleting of DPNs from VTEP Schema: {}. To be deleted Dpns: {}", original, deletedDpns) ;
+ deleteVteps(original, ItmUtils.getDpnIdList(deletedDpns));
+ }
+ }
+
+ /**
+ * Gets all vtep config schemas.
+ *
+ * @return the all vtep config schemas
+ */
+ private List<VtepConfigSchema> getAllVtepConfigSchemas() {
+ return ItmUtils.read(LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepConfigSchemasIdentifier(),
+ this.dataBroker).toJavaUtil().map(VtepConfigSchemas::getVtepConfigSchema).orElse(null);
+ }
+
+ /**
+ * Adds the vteps.
+ *
+ * @param schema
+ * the schema
+ * @param vtepIpPool
+ * the vtep ip pool
+ */
+ private void addVteps(VtepConfigSchema schema, VtepIpPool vtepIpPool) throws ExecutionException,
+ InterruptedException {
+ if (schema.getDpnIds() == null || schema.getDpnIds().isEmpty()) {
+ LOG.debug("DPN list is empty, skipping addVteps for schema: {}", schema);
+ return;
+ }
+
+ String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
+ if (vtepIpPool == null) {
+ LOG.error("VTEP config pool not found for subnetCidr {}. Failed to add VTEPs for schema {}", subnetCidr,
+ schema);
+ return;
+ }
+ TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig,
+ unprocessedTunnelsStateCache);
+ // Check this later
+ String tunType ;
+ Class<? extends TunnelTypeBase> tunnelType = schema.getTunnelType() ;
+ if (TunnelTypeVxlan.class.equals(tunnelType)) {
+ tunType = ITMConstants.TUNNEL_TYPE_VXLAN;
+ } else {
+ tunType = ITMConstants.TUNNEL_TYPE_GRE;
+ }
+ tepCommandHelper.configureTunnelType(schema.getTransportZoneName(),
+ StringUtils.upperCase(tunType));
+
+ List<IpAddress> availableIps = vtepIpPool.getAvailableIpaddress();
+ List<IpAddress> newlyAllocatedIps = new ArrayList<>();
+ List<BigInteger> skippedDpnIds = new ArrayList<>();
+
+ String gatewayIp = handleGatewayIp(schema.getGatewayIp());
+ for (BigInteger dpnId : ItmUtils.getDpnIdList(schema.getDpnIds())) {
+ IpAddress ipAddress = getAnAvailableIP(availableIps);
+ if (ipAddress == null) {
+ skippedDpnIds.add(dpnId);
+ continue;
+ }
+ try {
+ tepCommandHelper.createLocalCache(dpnId, schema.getPortName(), schema.getVlanId(),
+ ipAddress.stringValue(), subnetCidr, gatewayIp, schema.getTransportZoneName());
+ } catch (TepException e) {
+ LOG.error("create local cache Failed", e);
+ }
+ newlyAllocatedIps.add(ipAddress);
+ }
+ if (!skippedDpnIds.isEmpty()) {
+ LOG.error("No available IP addresses in the VTEP config pool {}, skipping VTEP configurations for DPN's {}",
+ subnetCidr, skippedDpnIds);
+ }
+
+ if (!newlyAllocatedIps.isEmpty()) {
+ LOG.debug("Delete OnCommit and buildTeps in NewlyAddedDpns");
+ tepCommandHelper.deleteOnCommit();
+ tepCommandHelper.buildTeps();
+ allocateIpAddresses(newlyAllocatedIps, vtepIpPool, subnetCidr);
+ }
+ }
+
+ /**
+ * Handle gateway ip.
+ *
+ * @param gatewayIp
+ * the gateway ip
+ * @return the string
+ */
+ private String handleGatewayIp(IpAddress gatewayIp) {
+ String strGatewayIp = gatewayIp == null ? null : gatewayIp.stringValue();
+ if (StringUtils.isBlank(strGatewayIp) || StringUtils.equals(ITMConstants.DUMMY_IP_ADDRESS, strGatewayIp)) {
+ // To avoid a validation exception in TepCommandHelper
+ strGatewayIp = null;
+ }
+ return strGatewayIp;
+ }
+
+ /**
+ * Delete vteps.
+ *
+ * @param schema
+ * the schema
+ * @param lstDpnIdsToBeDeleted
+ * the dpn ids list to be deleted
+ */
+ private void deleteVteps(VtepConfigSchema schema, List<BigInteger> lstDpnIdsToBeDeleted) {
+ TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig,
+ unprocessedTunnelsStateCache);
+ List<IpAddress> freeIps = new ArrayList<>();
+
+ String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
+ String gatewayIp = handleGatewayIp(schema.getGatewayIp());
+
+ for (BigInteger dpnId : lstDpnIdsToBeDeleted) {
+ VtepsKey vtepkey = new VtepsKey(dpnId, schema.getPortName());
+
+ InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(schema.getTransportZoneName()))
+ .child(Subnets.class, new SubnetsKey(schema.getSubnet())).child(Vteps.class, vtepkey).build();
+
+ Vteps vtep;
+ Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
+ if (vtepOptional.isPresent()) {
+ vtep = vtepOptional.get();
+ } else {
+ LOG.warn("VTEP doesn't exist for DPN [{}] and port [{}].", dpnId, schema.getPortName());
+ continue;
+ }
+
+ IpAddress ipAddress = vtep.getIpAddress();
+ try {
+ tepCommandHelper.deleteVtep(dpnId, vtep.getPortname(), schema.getVlanId(),
+ ipAddress.stringValue(), subnetCidr, gatewayIp, schema.getTransportZoneName());
+ } catch (TepException e) {
+ LOG.error("delete Vtep Failed", e);
+ }
+
+ freeIps.add(ipAddress);
+ }
+ LOG.debug("Delete OnCommit in NewlyAddedDpns");
+ tepCommandHelper.deleteOnCommit();
+ deAllocateIpAddresses(freeIps, subnetCidr);
+ }
+
+ /**
+ * Calculate available IPs from the subnet mask specified in the schema.
+ * Pushes the available and allocated IP address to config DS.
+ *
+ * @param schema
+ * the schema
+ */
+ private VtepIpPool processAvailableIps(final VtepConfigSchema schema) {
+ String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
+ SubnetUtils subnetUtils = new SubnetUtils(subnetCidr);
+
+ List<IpAddress> availableIps = calculateAvailableIps(subnetUtils, schema.getExcludeIpFilter(),
+ schema.getGatewayIp());
+ VtepIpPool vtepIpPool = new VtepIpPoolBuilder().setSubnetCidr(subnetCidr).setAvailableIpaddress(availableIps)
+ .setAllocatedIpaddress(new ArrayList<>()).build();
+
+ MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepIpPoolIdentifier(subnetCidr), vtepIpPool);
+ LOG.info("Vtep IP Pool with key:{} added to config DS", subnetCidr);
+ return vtepIpPool;
+ }
+
+ /**
+ * Gets the vtep ip pool.
+ *
+ * @param subnetCidr
+ * the subnet cidr
+ * @return the vtep ip pool
+ */
+ private VtepIpPool getVtepIpPool(final String subnetCidr) {
+ return ItmUtils.read(LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepIpPoolIdentifier(subnetCidr),
+ this.dataBroker).orNull();
+ }
+
+ /**
+ * Delete vtep ip pool.
+ *
+ * @param subnetCidr
+ * the subnet cidr
+ */
+ private void deleteVtepIpPool(final String subnetCidr) {
+ if (StringUtils.isNotBlank(subnetCidr)) {
+ MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepIpPoolIdentifier(subnetCidr));
+ LOG.debug("Deleted Vtep IP Pool with key:{}", subnetCidr);
+ }
+ }
+
+ /**
+ * Gets the an available ip.
+ *
+ * @param availableIps list of all available IPs
+ *
+ * @return the an available ip
+ */
+ private IpAddress getAnAvailableIP(List<IpAddress> availableIps) {
+ // TODO: Sort IP Addresses, get the least value
+ IpAddress ipAddress = null;
+ if (availableIps != null && !availableIps.isEmpty()) {
+ ipAddress = availableIps.remove(0);
+ }
+ return ipAddress;
+ }
+
+ /**
+ * Allocate ip addresses.
+ *
+ * @param allocatedIps
+ * the allocated ips
+ * @param vtepIpPool
+ * the vtep ip pool
+ * @param subnetCidr
+ * the subnet cidr
+ */
+ private void allocateIpAddresses(List<IpAddress> allocatedIps, VtepIpPool vtepIpPool, String subnetCidr) {
+ if (allocatedIps != null && !allocatedIps.isEmpty() && vtepIpPool != null) {
+ // Remove from the available IP address list and add to allocated IP
+ // address list.
+ VtepIpPoolBuilder builder = new VtepIpPoolBuilder(vtepIpPool);
+ if (builder.getAvailableIpaddress() != null) {
+ builder.getAvailableIpaddress().removeAll(allocatedIps);
+ }
+ if (builder.getAllocatedIpaddress() == null) {
+ builder.setAllocatedIpaddress(allocatedIps);
+ } else {
+ builder.getAllocatedIpaddress().addAll(allocatedIps);
+ }
+
+ MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepIpPoolIdentifier(subnetCidr), builder.build());
+ }
+ }
+
+ /**
+ * De-allocate ip addresses.
+ *
+ * @param freeIps
+ * the free ips
+ * @param subnetCidr
+ * the subnet cidr
+ */
+ private void deAllocateIpAddresses(List<IpAddress> freeIps, String subnetCidr) {
+ VtepIpPool vtepIpPool = getVtepIpPool(subnetCidr);
+ if (freeIps != null && !freeIps.isEmpty() && vtepIpPool != null) {
+ // Remove from the allocated IP address list and add to available IP
+ // address list.
+ VtepIpPoolBuilder builder = new VtepIpPoolBuilder(vtepIpPool);
+ if (builder.getAllocatedIpaddress() != null) {
+ builder.getAllocatedIpaddress().removeAll(freeIps);
+ }
+ if (builder.getAvailableIpaddress() == null) {
+ builder.setAvailableIpaddress(freeIps);
+ } else {
+ builder.getAvailableIpaddress().addAll(freeIps);
+ }
+
+ MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION,
+ ItmUtils.getVtepIpPoolIdentifier(subnetCidr), builder.build());
+ LOG.debug("Vtep IP Pool with key:{} updated to config DS", subnetCidr);
+ }
+ }
+
+ /**
+ * Calculate available ips.
+ *
+ * @param subnetUtils
+ * the subnet cidr
+ * @param excludeIpFilter
+ * the exclude ip filter
+ * @param gatewayIp
+ * the gateway IP
+ * @return the list
+ */
+ private List<IpAddress> calculateAvailableIps(SubnetUtils subnetUtils, String excludeIpFilter,
+ IpAddress gatewayIp) {
+ List<IpAddress> lstAvailableIps = new ArrayList<>();
+ SubnetInfo subnetInfo = subnetUtils.getInfo();
+ String[] arrIpAddresses = subnetInfo.getAllAddresses();
+
+ for (String ipAddress : arrIpAddresses) {
+ lstAvailableIps.add(IpAddressBuilder.getDefaultInstance(ipAddress));
+ }
+ lstAvailableIps.remove(gatewayIp);
+ lstAvailableIps.removeAll(ItmUtils.getExcludeIpAddresses(excludeIpFilter, subnetInfo));
+
+ return lstAvailableIps;
+ }
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.serviceutils.srm.types.rev180626.GeniusItmTep;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
if (oldTz != null) {
LOG.trace("Deleting transportzone {}", tzName);
ItmTepRemoveWorker tepRemoveWorker = new ItmTepRemoveWorker(tepsToRecover, null, oldTz,
- imdsalApiManager, itmInternalTunnelDeleteWorker, dpntePsInfoCache, txRunner, itmConfig);
+ imdsalApiManager, itmInternalTunnelDeleteWorker, dpntePsInfoCache, txRunner);
jobCoordinator.enqueueJob(tzName, tepRemoveWorker);
AtomicInteger eventCallbackCount = new AtomicInteger(0);
AtomicInteger eventRegistrationCount = new AtomicInteger(0);
return null;
}
- String portName = (itmConfig.getPortname() == null) ? ITMConstants.DUMMY_PORT : itmConfig.getPortname();
- int vlanId = (itmConfig.getVlanId() != null) ? itmConfig.getVlanId() : ITMConstants.DUMMY_VLANID;
-
- for (Vteps vtep : transportZone.getVteps()) {
- if (ipAddress.equals(vtep.getIpAddress().stringValue())) {
-
- 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), portName, false,
- vlanId, zones, transportZone.getTunnelType(),
- itmConfig.getDefaultTunnelTos());
-
- List<TunnelEndPoints> teps = new ArrayList<>();
- teps.add(tunnelEndPoints);
- return ItmUtils.createDPNTepInfo(vtep.getDpnId(), teps);
+ for (Subnets sub : transportZone.nonnullSubnets()) {
+ if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
+ LOG.error("Transport Zone {} subnet {} has no vteps", transportZone.getZoneName(), sub.getPrefix());
+ }
+ for (Vteps vtep : sub.nonnullVteps()) {
+ if (ipAddress.equals(vtep.getIpAddress().stringValue())) {
+
+ 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;
}
-}
+}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIpKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInput;
}
if (ItmUtils.isTunnelAggregationUsed(input.getTunnelType())) {
optTunnel = ItmUtils.getInternalTunnelFromDS(sourceDpn, destinationDpn,
- TunnelTypeLogicalGroup.class, dataBroker);
+ TunnelTypeLogicalGroup.class, dataBroker);
LOG.debug("MULTIPLE_VxLAN_TUNNELS: getTunnelInterfaceName {}", optTunnel);
}
if (!optTunnel.isPresent()) {
if (tunnelName == null) {
return Futures.immediateFuture(RpcResultBuilder.<GetEgressActionsForTunnelOutput>failed()
.withError(RpcError.ErrorType.APPLICATION,
- "tunnel name not set for GetEgressActionsForTunnel call").build());
+ "tunnel name not set for GetEgressActionsForTunnel call").build());
}
if (!dpnTepStateCache.isInternal(tunnelName) || !interfaceManager.isItmDirectTunnelsEnabled()) {
// Re-direct the RPC to Interface Manager
.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput>() {
@Override
public void onSuccess(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs
- .rev160406.@NonNull GetEgressActionsForInterfaceOutput result) {
+ .rev160406.@NonNull GetEgressActionsForInterfaceOutput result) {
GetEgressActionsForTunnelOutputBuilder output =
new GetEgressActionsForTunnelOutputBuilder().setAction(result.getAction());
settableFuture.set(RpcResultBuilder.<GetEgressActionsForTunnelOutput>success()
settableFuture.set(RpcResultBuilder.<GetEgressActionsForTunnelOutput>failed()
.withError(RpcError.ErrorType.APPLICATION, errMsg, throwable).build());
}
- } ,MoreExecutors.directExecutor());
+ } ,MoreExecutors.directExecutor());
return settableFuture;
} else {
return fromListenableFuture(LOG, input, () -> getEgressActionsForInternalTunnels(input.getIntfName(),
if (tunnelName == null) {
return Futures.immediateFuture(RpcResultBuilder.<GetTunnelTypeOutput>failed()
.withError(RpcError.ErrorType.APPLICATION,
- "tunnel name not set for getTunnelType call").build());
+ "tunnel name not set for getTunnelType call").build());
}
if (!dpnTepStateCache.isInternal(tunnelName) || !interfaceManager.isItmDirectTunnelsEnabled()) {
.interfacemanager.rpcs.rev160406.GetTunnelTypeOutput>() {
@Override
public void onSuccess(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs
- .rev160406.@NonNull GetTunnelTypeOutput result) {
+ .rev160406.@NonNull GetTunnelTypeOutput result) {
GetTunnelTypeOutputBuilder output = new GetTunnelTypeOutputBuilder()
.setTunnelType(result.getTunnelType());
settableFuture.set(RpcResultBuilder.<GetTunnelTypeOutput>success()
tunnelName);
settableFuture.set(RpcResultBuilder.<GetTunnelTypeOutput>failed()
.withError(RpcError.ErrorType.APPLICATION, errMsg, throwable).build());
+
}
- },MoreExecutors.directExecutor());
+ },MoreExecutors.directExecutor());
return settableFuture;
} else {
LOG.debug("get tunnel type from ITM for interface name {}", input.getIntfName());
Optional<OvsBridgeRefEntry> ovsBridgeRefEntry = ovsBridgeRefEntryCache.get(srcDpnId);
directTunnelUtils.updateBfdConfiguration(srcDpnId, remoteDpn, ovsBridgeRefEntry);
InstanceIdentifier<RemoteDpns> iid = InstanceIdentifier.builder(DpnTepsState.class)
- .child(DpnsTeps.class, new DpnsTepsKey(srcDpnId))
- .child(RemoteDpns.class,
- new RemoteDpnsKey(destDpnId)).build();
+ .child(DpnsTeps.class, new DpnsTepsKey(srcDpnId))
+ .child(RemoteDpns.class,
+ new RemoteDpnsKey(destDpnId)).build();
tx.merge(LogicalDatastoreType.CONFIGURATION, iid, remoteDpn);
}), unused -> new SetBfdParamOnTunnelOutputBuilder().build(), MoreExecutors.directExecutor())).build();
}
FluentFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> {
ItmExternalTunnelDeleteWorker.deleteTunnels(meshedDpnList, input.getDestinationIp(),
- input.getTunnelType(), tx);
+ input.getTunnelType(), tx);
InstanceIdentifier<DcGatewayIp> extPath = InstanceIdentifier.builder(DcGatewayIpList.class)
- .child(DcGatewayIp.class, new DcGatewayIpKey(input.getDestinationIp())).build();
+ .child(DcGatewayIp.class, new DcGatewayIpKey(input.getDestinationIp())).build();
tx.delete(extPath);
}
);
List<DPNTEPsInfo> cfgDpnList = ItmUtils.getDpnTepListFromDpnId(dpnTEPsInfoCache, input.getDpnId());
FluentFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> ItmExternalTunnelDeleteWorker.deleteTunnels(cfgDpnList, input.getDestinationIp(),
- input.getTunnelType(), tx));
+ input.getTunnelType(), tx));
future.addCallback(new FutureCallback<Void>() {
@Override
FluentFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> {
externalTunnelAddWorker.buildTunnelsToExternalEndPoint(meshedDpnList, input.getDestinationIp(),
- input.getTunnelType(), tx);
+ input.getTunnelType(), tx);
tx.put(extPath, dcGatewayIp, true);
}
);
ListenableFuture<Void> removeFlowResult = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
tx -> mdsalManager.removeFlow(tx, input.getDpnId(),
- getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, input.getServiceId()),
- NwConstants.INTERNAL_TUNNEL_TABLE));
+ getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, input.getServiceId()),
+ NwConstants.INTERNAL_TUNNEL_TABLE));
Futures.addCallback(removeFlowResult, new FutureCallback<Void>() {
@Override
if (ItmUtils.isTunnelAggregationUsed(input.getTunnelType())) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(),
- TunnelTypeLogicalGroup.class, dataBroker);
+ TunnelTypeLogicalGroup.class, dataBroker);
LOG.debug("MULTIPLE_VxLAN_TUNNELS: getInternalOrExternalInterfaceName {}", optTunnel);
}
if (!optTunnel.isPresent()) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(),
- input.getTunnelType(), dataBroker);
+ input.getTunnelType(), dataBroker);
}
if (optTunnel.isPresent()) {
InternalTunnel tunnel = optTunnel.get();
}
foundVxlanTzone = true;
String transportZone = tzone.getZoneName();
+ if (tzone.getSubnets() == null || tzone.getSubnets().isEmpty()) {
+ result.set(RpcResultBuilder.<DeleteL2GwDeviceOutput>failed()
+ .withError(RpcError.ErrorType.APPLICATION, "No subnets Configured").build());
+ return result;
+ }
+ SubnetsKey subnetsKey = tzone.getSubnets().get(0).key();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId);
- InstanceIdentifier<DeviceVteps> path = InstanceIdentifier
- .builder(TransportZones.class)
- .child(TransportZone.class,
- new TransportZoneKey(transportZone))
- .child(DeviceVteps.class, deviceVtepKey)
+ InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(transportZone))
+ .child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey)
.build();
FluentFuture<Void> future =
retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(path));
continue;
}
String transportZone = tzone.getZoneName();
+ if (tzone.getSubnets() == null || tzone.getSubnets().isEmpty()) {
+ continue;
+ }
foundVxlanTzone = true;
+ SubnetsKey subnetsKey = tzone.getSubnets().get(0).key();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId);
- InstanceIdentifier<DeviceVteps> path = InstanceIdentifier
- .builder(TransportZones.class)
- .child(TransportZone.class,
- new TransportZoneKey(transportZone))
- .child(DeviceVteps.class, deviceVtepKey)
+ InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(transportZone))
+ .child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey)
.build();
DeviceVteps deviceVtep = new DeviceVtepsBuilder().withKey(deviceVtepKey).setIpAddress(hwIp)
.setNodeId(nodeId).setTopologyId(input.getTopologyId()).build();
//TO DO: add retry if it fails
FluentFuture<Void> future = retryingTxRunner
- .callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(path, deviceVtep,
- true));
+ .callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(path, deviceVtep, true));
future.addCallback(new FutureCallback<Void>() {
return result;
}
String transportZone = transportZones.getTransportZone().get(0).getZoneName();
+ if (transportZones.getTransportZone().get(0).getSubnets() == null
+ || transportZones.getTransportZone().get(0).getSubnets().isEmpty()) {
+ result.set(RpcResultBuilder.<AddL2GwMlagDeviceOutput>failed()
+ .withError(RpcError.ErrorType.APPLICATION, "No subnets Configured").build());
+ return result;
+ }
+ SubnetsKey subnetsKey = transportZones.getTransportZone().get(0).getSubnets().get(0).key();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId.get(0));
InstanceIdentifier<DeviceVteps> path =
InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(transportZone))
- .child(DeviceVteps.class, deviceVtepKey).build();
+ .child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey).build();
DeviceVteps deviceVtep = new DeviceVtepsBuilder().withKey(deviceVtepKey).setIpAddress(hwIp)
.setNodeId(nodeId.get(0)).setTopologyId(input.getTopologyId()).build();
LOG.trace("writing hWvtep{}", deviceVtep);
if (nodeId.size() == 2) {
LOG.trace("second node-id {}", nodeId.get(1));
DeviceVtepsKey deviceVtepKey2 = new DeviceVtepsKey(hwIp, nodeId.get(1));
- InstanceIdentifier<DeviceVteps> path2 = InstanceIdentifier
- .builder(TransportZones.class)
+ InstanceIdentifier<DeviceVteps> path2 = InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(transportZone))
+ .child(Subnets.class, subnetsKey)
.child(DeviceVteps.class, deviceVtepKey2).build();
DeviceVteps deviceVtep2 = new DeviceVtepsBuilder().withKey(deviceVtepKey2)
.setIpAddress(hwIp).setNodeId(nodeId.get(1))
return result;
}
String transportZone = tzones.getTransportZone().get(0).getZoneName();
+ if (tzones.getTransportZone().get(0).getSubnets() == null || tzones.getTransportZone()
+ .get(0).getSubnets().isEmpty()) {
+ result.set(RpcResultBuilder.<DeleteL2GwMlagDeviceOutput>failed()
+ .withError(RpcError.ErrorType.APPLICATION, "No subnets Configured").build());
+ return result;
+ }
+ SubnetsKey subnetsKey = tzones.getTransportZone().get(0).getSubnets().get(0).key();
+
FluentFuture<Void> future =
retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
tx -> {
InstanceIdentifier<DeviceVteps> path =
InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(transportZone))
- .child(DeviceVteps.class,
- deviceVtepKey).build();
+ .child(Subnets.class, subnetsKey).child(DeviceVteps.class,
+ deviceVtepKey).build();
tx.delete(path);
DeviceVtepsKey deviceVtepKey2 = new DeviceVtepsKey(hwIp, nodeId.get(1));
InstanceIdentifier<DeviceVteps> path2 =
InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(transportZone))
- .child(DeviceVteps.class,
- deviceVtepKey2).build();
+ .child(Subnets.class, subnetsKey).child(DeviceVteps.class,
+ deviceVtepKey2).build();
tx.delete(path2);
}
);
String tunIfName = input.getTunnelInterfaceName();
long tunVal = 0;
IsTunnelInternalOrExternalOutputBuilder output = new IsTunnelInternalOrExternalOutputBuilder()
- .setTunnelType(tunVal);
+ .setTunnelType(tunVal);
if (ItmUtils.ITM_CACHE.getInternalTunnel(tunIfName) != null) {
tunVal = 1;
}
Map<BigInteger, ComputesBuilder> result = new HashMap<>();
for (TransportZone transportZone : transportZones.getTransportZone()) {
- for (Vteps vtep : transportZone.getVteps()) {
- if (dpnIds.contains(vtep.getDpnId())) {
- result.putIfAbsent(vtep.getDpnId(),
+ if (transportZone.getSubnets() == null || transportZone.getSubnets().isEmpty()) {
+ LOG.debug("Transport Zone {} has no subnets", transportZone.getZoneName());
+ continue;
+ }
+ for (Subnets sub : transportZone.getSubnets()) {
+ if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
+ LOG.debug("Transport Zone {} subnet {} has no vteps configured",
+ transportZone.getZoneName(), sub.getPrefix());
+ continue;
+ }
+ for (Vteps vtep : sub.getVteps()) {
+ if (dpnIds.contains(vtep.getDpnId())) {
+ result.putIfAbsent(vtep.getDpnId(),
new ComputesBuilder()
- .setZoneName(transportZone.getZoneName())
- .setDpnId(vtep.getDpnId())
- .setNodeId(getNodeId(vtep.getDpnId()))
- .setTepIp(Collections.singletonList(vtep.getIpAddress())));
+ .setZoneName(transportZone.getZoneName())
+ .setPrefix(sub.getPrefix())
+ .setDpnId(vtep.getDpnId())
+ .setPortName(vtep.getPortname())
+ .setNodeId(getNodeId(vtep.getDpnId()))
+ .setTepIp(Collections.singletonList(vtep.getIpAddress())));
+ }
}
}
}
<property name="itmProvider" ref="itmProvider" />
</action>
</command>
+ <command>
+ <action class="org.opendaylight.genius.itm.cli.VtepSchemaAdd">
+ <property name="itmProvider" ref="itmProvider" />
+ </action>
+ </command>
+ <command>
+ <action class="org.opendaylight.genius.itm.cli.VtepSchemaShow">
+ <property name="itmProvider" ref="itmProvider" />
+ </action>
+ </command>
+ <command>
+ <action class="org.opendaylight.genius.itm.cli.VtepSchemaUpdate">
+ <property name="itmProvider" ref="itmProvider" />
+ </action>
+ </command>
+ <command>
+ <action class="org.opendaylight.genius.itm.cli.VtepSchemaDelete">
+ <property name="itmProvider" ref="itmProvider" />
+ </action>
+ </command>
<command>
<action class="org.opendaylight.genius.itm.cli.TepEnableTunnelMonitor">
<property name="itmProvider" ref="itmProvider" />
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Before;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(TepCommandHelper.class);
+ private final int vlanId = 100 ;
private final int interval = 1000;
private final Boolean enabled = false ;
private final Class<? extends TunnelMonitoringTypeBase> monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
private final String tepIp3 = "168.56.102";
private final String tepIp4 = "150.168.56.102";
private final String gwyIp1 = "192.168.56.105";
+ private final String gwyIp2 = "192.168.56.106";
private final String subnetMask = "192.168.56.100/24";
private final String tunnelInterfaceName = "1:phy0:100" ;
private final String sourceDevice = "hwvtep://192.168.101.30:6640/physicalswitch/s3";
private final String destinationDevice = "hwvtep:1";
+ private final String portName1 = "phy0";
private final String transportZone1 = "TZA" ;
private final BigInteger dpId1 = BigInteger.valueOf(1);
private final BigInteger dpId2 = BigInteger.valueOf(2);
+ private final IpAddress gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
private final IpAddress ipAddress1 = IpAddressBuilder.getDefaultInstance(tepIp1);
private final IpAddress ipAddress2 = IpAddressBuilder.getDefaultInstance(tepIp2);
+ private final IpPrefix ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetMask);
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private TransportZone transportZone = null;
private TransportZone transportZoneNew = null;
private TransportZones transportZonesNew = null;
private TunnelMonitorInterval tunnelMonitorInterval = null;
private TunnelMonitorParams tunnelMonitorParams = null;
+ private Subnets subnetsTest = null;
private Vteps vteps = null;
private Vteps vtepsTest = null;
private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state
.Interface interfaceTest = null;
private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface
interfaceTestNew = null;
+ private final List<Subnets> subnetsList = new ArrayList<>() ;
private final List<DeviceVteps> deviceVtepsList = new ArrayList<>();
private final List<Vteps> vtepsList = new ArrayList<>();
private final List<TransportZone> transportZoneList = new ArrayList<>();
InstanceIdentifier.builder(TunnelMonitorParams.class).build();
private final InstanceIdentifier<Vteps> vtepsIdentifier = InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(transportZone1))
- .child(Vteps.class, new VtepsKey(dpId1)).build();
+ .child(Subnets.class, new SubnetsKey(ipPrefixTest))
+ .child(Vteps.class, new VtepsKey(dpId1,portName1)).build();
+ private final InstanceIdentifier<Vteps> vtepsIdentifierNew = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone
+ .class, new TransportZoneKey(transportZone1))
+ .child(Subnets.class, new SubnetsKey(ipPrefixTest))
+ .child(Vteps.class, new VtepsKey(dpId2,portName1)).build();
+ private final InstanceIdentifier<Subnets> subnetsIdentifier = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(transportZone1))
+ .child(Subnets.class, new SubnetsKey(ipPrefixTest)).build();
private final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
.rev140508.interfaces.state.Interface>
interfaceIdentifier = ItmUtils.buildStateInterfaceId(tunnelInterfaceName);
private ReadOnlyTransaction mockReadTx;
@Mock
private WriteTransaction mockWriteTx;
+ @Mock Map<String, Map<SubnetObject, List<Vteps>>> tzones;
private Optional<TransportZones> optionalTransportZones;
Optional<TunnelMonitorInterval> optionalTunnelMonitorInterval = Optional.of(tunnelMonitorInterval);
Optional<TunnelMonitorParams> optionalTunnelMonitorParams = Optional.of(tunnelMonitorParams);
Optional<Vteps> optionalVteps = Optional.of(vteps);
+ Optional<Subnets> optionalSubnets = Optional.of(subnetsTest);
Optional<Interface> ifStateOptional = Optional.of(interfaceTest);
Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
.Interface>
.read(LogicalDatastoreType.CONFIGURATION,tunnelMonitorParamsIdentifier);
doReturn(Futures.immediateCheckedFuture(optionalVteps)).when(mockReadTx)
.read(LogicalDatastoreType.CONFIGURATION,vtepsIdentifier);
+ doReturn(Futures.immediateCheckedFuture(optionalSubnets)).when(mockReadTx)
+ .read(LogicalDatastoreType.CONFIGURATION,subnetsIdentifier);
lenient().doReturn(Futures.immediateCheckedFuture(ifStateOptional)).when(mockReadTx)
.read(LogicalDatastoreType.OPERATIONAL,interfaceIdentifier);
lenient().doReturn(Futures.immediateCheckedFuture(ifStateOptionalNew)).when(mockReadTx)
System.setOut(new PrintStream(outContent));
instanceIdentifierList.add(transportZoneIdentifier);
instanceIdentifierList.add(vtepsIdentifier);
+ instanceIdentifierList.add(subnetsIdentifier);
DeviceVteps deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1)
.withKey(new DeviceVtepsKey(ipAddress1, sourceDevice))
.setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
- vteps = new VtepsBuilder().setDpnId(dpId2)
- .setIpAddress(ipAddress1).withKey(new VtepsKey(dpId2)).build();
+ vteps = new VtepsBuilder().setPortname(portName1).setDpnId(dpId2)
+ .setIpAddress(ipAddress1).withKey(new VtepsKey(dpId2,portName1)).build();
vtepsTest = new VtepsBuilder().build();
deviceVtepsList.add(deviceVteps);
vtepsList.add(vteps);
+ subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).withKey(new SubnetsKey(ipPrefixTest))
+ .setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
+ subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).withKey(new
- TransportZoneKey(transportZone1)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
+ TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).withKey(new
- TransportZoneKey(transportZone1)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
+ TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
transportZonesNew = new TransportZonesBuilder().setTransportZone(transportZoneListNew).build();
.PhysAddress.getDefaultInstance("AA:AA:AA:AA:AA:AA"))
.setIfIndex(100).setLowerLayerIf(lowerLayerIfList).setType(L2vlan.class).build();
interfaceTestNew = ItmUtils.buildTunnelInterface(dpId1, tunnelInterfaceName, destinationDevice, enabled,
- TunnelTypeVxlan.class, ipAddress1, ipAddress2, enabled,monitorProtocol,
+ TunnelTypeVxlan.class, ipAddress1, ipAddress2, gtwyIp1, vlanId, true, enabled,monitorProtocol,
interval, false, null);
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
public void testCreateLocalCacheTzonesEmpty() {
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
@Test
public void testCreateLocalCacheWithoutcheckExistingSubnet() {
- transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2)
- .setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
+ IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
+ IpPrefix subnetMaskObj = ipPrefixTest;
+ SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
+ SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
+ Map<SubnetObject, List<Vteps>> subVtepMapTemp = new HashMap<>();
+ subVtepMapTemp.put(subObCli, vtepsList);
+ transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).build();
doReturn(Futures.immediateCheckedFuture(Optional.of(transportZoneNew))).when(mockReadTx).read(
LogicalDatastoreType.CONFIGURATION,transportZoneIdentifier);
- lenient().doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(LogicalDatastoreType
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(LogicalDatastoreType
.CONFIGURATION,transportZonesIdentifier);
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
- tepCommandHelper.createLocalCache(dpId2,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId2,portName1,vlanId, tepIp1,subnetMask,gwyIp1, transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
@Test
public void testCreateLocalCacheWithcheckExistingSubnet() {
- transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2)
- .setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
+ transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).build();
Optional<TransportZone> optionalTransportZone = Optional.of(transportZoneNew);
doReturn(Futures.immediateCheckedFuture(optionalTransportZone)).when(mockReadTx).read(LogicalDatastoreType
.CONFIGURATION,transportZoneIdentifier);
- lenient().doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(LogicalDatastoreType
+ doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(LogicalDatastoreType
.CONFIGURATION,transportZonesIdentifier);
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
- tepCommandHelper.createLocalCache(dpId2,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId2,portName1,vlanId, tepIp1,subnetMask,gwyIp2, transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
}
@SuppressWarnings("checkstyle:IllegalCatch")
+ @Test
+ public void testCreateLocalCacheInvalidIp() {
+
+ String output = null;
+ try {
+ tepCommandHelper.createLocalCache(dpId1, portName1, vlanId, tepIp3, subnetMask, gwyIp1,
+ transportZone1);
+ } catch (Exception e) {
+ output = e.getMessage();
+ }
+ assertEquals("Invalid IpAddress. Expected: 1.0.0.0 to 254.255.255.255", output);
+ }
+
@Test
public void testCreateLocalCacheGtwyIpNull() {
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,null,transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
LOG.debug("gateway is null");
}
+ @Test
+ public void testCreateLocalCacheInvalidSubnetMask() {
+
+ String output = null;
+ try {
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,tepIp2,gwyIp1,transportZone1);
+ } catch (TepException e) {
+ output = e.getMessage();
+ }
+
+ assertEquals("Invalid Subnet Mask. Expected: 0.0.0.0/0 to 255.255.255.255/32", output);
+
+ }
+
+ @Test
+ public void testCreateLocalCadcheMismatchIpwithSubnet() {
+
+ String output = null;
+ try {
+ tepCommandHelper.createLocalCache(dpId1, portName1, vlanId, tepIp4, subnetMask, gwyIp1,
+ transportZone1);
+ } catch (TepException e) {
+ output = e.getMessage();
+ }
+ assertEquals("IpAddress and gateWayIp should belong to the subnet provided", output);
+ }
+
@Test
public void testConfigureTunnelType() throws ExecutionException, InterruptedException {
doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(LogicalDatastoreType
public void testDeleteVtep() {
try {
- tepCommandHelper.deleteVtep(dpId1, tepIp1, transportZone1);
+ tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp1, subnetMask, gwyIp1, transportZone1);
} catch (Exception e) {
LOG.error(e.getMessage());
}
verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,vtepsIdentifier);
+ verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,subnetsIdentifier);
+
+ }
+
+ @Test
+ public void testDeleteVtepInvalidIp() {
+
+ String output = null;
+ try {
+ tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp3, subnetMask, gwyIp1, transportZone1);
+ } catch (TepException e) {
+ output = e.getMessage();
+ }
+
+ assertEquals("Invalid IpAddress. Expected: 1.0.0.0 to 254.255.255.255", output);
+
+ }
+
+ @Test
+ public void testDeleteVtepInvalidSubnetMask() {
+
+ String output = null;
+ try {
+ tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp1, tepIp1, gwyIp1, transportZone1);
+ } catch (TepException e) {
+ output = e.getMessage();
+ }
+
+ assertEquals("Invalid Subnet Mask. Expected: 0.0.0.0/0 to 255.255.255.255/32", output);
+
}
@SuppressWarnings("checkstyle:IllegalCatch")
public void testDeleteVtepGatewayIpNull() {
try {
- tepCommandHelper.deleteVtep(dpId1, tepIp1, transportZone1);
+ tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp1, subnetMask, null, transportZone1);
} catch (Exception e) {
LOG.error(e.getMessage());
}
}
@SuppressWarnings("checkstyle:IllegalCatch")
+ @Test
+ public void testDeleteVtepIpSubnetMismatch() {
+
+ String output = null;
+ try {
+ tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp4, subnetMask, gwyIp1, transportZone1);
+ } catch (Exception e) {
+ output = e.getMessage();
+ }
+
+ assertEquals("IpAddress and gateWayIp should belong to the subnet provided", output);
+
+ }
+
@Test
public void testBuildTepsTunnelTypeVxlan() {
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(LogicalDatastoreType
.CONFIGURATION,transportZoneIdentifier);
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
tepCommandHelper.buildTeps();
verify(mockReadTx, times(2)).read(LogicalDatastoreType.CONFIGURATION,transportZoneIdentifier);
.CONFIGURATION,transportZonesIdentifier);
try {
- tepCommandHelper.deleteVtep(dpId1, tepIp1, transportZone1);
+ tepCommandHelper.deleteVtep(dpId1, portName1, vlanId, tepIp1, subnetMask, gwyIp1, transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
tepCommandHelper.deleteOnCommit();
verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,vtepsIdentifier);
+ verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,subnetsIdentifier);
+ verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION,vtepsIdentifierNew);
+ verify(mockWriteTx).delete(LogicalDatastoreType.CONFIGURATION,subnetsIdentifier);
}
@Test
public void testIsInCache() {
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
- tepCommandHelper.isInCache(dpId1,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
+ tepCommandHelper.isInCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
+
verify(mockReadTx).read(LogicalDatastoreType.CONFIGURATION,transportZoneIdentifier);
+
+ }
+
+ @Test
+ public void testValidateForDuplicates() {
+
+ try {
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
+ } catch (TepException e) {
+ LOG.error(e.getMessage());
+ }
+ tepCommandHelper.validateForDuplicates(vtepsTest,transportZone1);
+
+ verify(mockReadTx, times(2)).read(LogicalDatastoreType.CONFIGURATION,transportZonesIdentifier);
+
}
@Test
public void testCheckTepPerTzPerDpn() {
try {
- tepCommandHelper.createLocalCache(dpId1,tepIp1,transportZone1);
+ tepCommandHelper.createLocalCache(dpId1,portName1,vlanId,tepIp1,subnetMask,gwyIp1,transportZone1);
} catch (TepException e) {
LOG.error(e.getMessage());
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
AllocateIdInput getIdInput4 = null;
AllocateIdInput getIdInput5 = null;
AllocateIdInput getIdInput6 = null;
+ Subnets subnets = null;
HwVtep hwVtep1 = null;
Vteps vtepsTest = null;
DeviceVteps deviceVteps1 = null;
List<TunnelEndPoints> tunnelEndPointsListVxlan = new ArrayList<>();
List<BigInteger> bigIntegerList = new ArrayList<>();
List<HwVtep> cfgdHwVtepsList = new ArrayList<>();
+ List<Subnets> subnetsList = new ArrayList<>();
List<DeviceVteps> deviceVtepsList = new ArrayList<>();
List<Vteps> vtepsList = new ArrayList<>();
java.lang.Class<? extends TunnelTypeBase> tunnelType1 = TunnelTypeVxlan.class;
gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
- tunnelEndPointsVxlan = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress3).setInterfaceName(parentInterfaceName)
+ tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1)
+ .setIpAddress(ipAddress3).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1))
- .setTunnelType(tunnelType1).build();
+ .setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId1).setUp(true).withKey(new DPNTEPsInfoKey(dpId1))
.setTunnelEndPoints(tunnelEndPointsListVxlan).build();
bigIntegerList.add(dpId1);
deviceVtepsList.add(deviceVteps1);
deviceVtepsList.add(deviceVteps2);
- vtepsTest = new VtepsBuilder().setDpnId(dpId1).setIpAddress(ipAddress3).withKey(new
- VtepsKey(dpId1)).build();
+ vtepsTest = new VtepsBuilder().setDpnId(dpId1).setIpAddress(ipAddress3).setPortname(portName1).withKey(new
+ VtepsKey(dpId1,portName1)).build();
vtepsList.add(vtepsTest);
dpnEndpointsVxlan = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
transportZone = new TransportZoneBuilder().setTunnelType(tunnelType1).setZoneName(transportZone1).withKey(new
- TransportZoneKey(transportZone1)).setVteps(vtepsList).setDeviceVteps(deviceVtepsList).build();
+ TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
idOutputOptional1 = RpcResultBuilder.success(expectedId1).buildFuture();
getIdInput1 = new AllocateIdInputBuilder()
.setPoolName(ITMConstants.ITM_IDPOOL_NAME)
dpId1.toString(), tunnelType1));
iface = ItmUtils.buildTunnelInterface(dpId1,trunkInterfaceName, String.format("%s %s",
ItmUtils.convertTunnelTypetoString(tunnelType1), "Trunk Interface"), true, tunnelType1, ipAddress3,
- ipAddress2, false, monitorProtocol, null, false,
+ ipAddress2, gtwyIp1, tunnelEndPointsVxlan.getVLANID(), false, false, monitorProtocol, null, false,
null);
externalTunnel = ItmUtils.buildExternalTunnel(dpId1.toString(), ipAddress2.stringValue(),
tunnelType1, trunkInterfaceName);
+ subnets = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).withKey(new SubnetsKey(ipPrefixTest))
+ .setVteps(vtepsList).setDeviceVteps(deviceVtepsList).build();
+ subnetsList.add(subnets);
lenient().doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
lenient().doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
lenient().doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
- doReturn("phy0").when(itmConfig).getPortname();
- doReturn(100).when(itmConfig).getVlanId();
+
}
@Test
final Interface extTunnelIf1 = ItmUtils.buildTunnelInterface(dpId1, "tun030025bd04f",
String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1,
tunnelEndPointsVxlan.getIpAddress(), ipAddress1,
- false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false,
+ gtwyIp1, vlanId, false,false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false,
null);
final Interface hwTunnelIf2 = ItmUtils.buildHwTunnelInterface("tun9a55a9c38f2",
String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(),
ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
final Interface extTunnelIf3 = ItmUtils.buildTunnelInterface(dpId1, "tun17c6e20c283",
String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1,
- tunnelEndPointsVxlan.getIpAddress(), ipAddress2, false, monitorProtocol,
+ tunnelEndPointsVxlan.getIpAddress(), ipAddress2, gtwyIp1, vlanId, false,false, monitorProtocol,
ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false, null);
final Interface hwTunnelIf4 = ItmUtils.buildHwTunnelInterface("tunaa109b6c8c5",
String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(),
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
DPNTEPsInfo dpntePsInfoVxlan = null;
TunnelEndPoints tunnelEndPointsVxlan = null;
HwVtep hwVtep1 = null;
+ Subnets subnets = null;
DeviceVteps deviceVteps1 = null;
DeviceVteps deviceVteps2 = null;
Vteps vteps = null;
List<TunnelEndPoints> tunnelEndPointsListVxlan = new ArrayList<>();
List<DPNTEPsInfo> dpnTepsList = new ArrayList<>() ;
List<HwVtep> cfgdHwVtepsList = new ArrayList<>();
+ List<Subnets> subnetsList = new ArrayList<>();
List<DeviceVteps> deviceVtepsList = new ArrayList<>();
List<Vteps> vtepsList = new ArrayList<>();
java.lang.Class<? extends TunnelTypeBase> tunnelType1 = TunnelTypeVxlan.class;
@Mock IdManagerService idManagerService;
@Mock TypedWriteTransaction<Datastore.Configuration> typedWriteTransaction;
@Mock TypedReadWriteTransaction<Datastore.Configuration> typedReadWriteTransaction;
- @Mock ItmConfig itmConfig;
@Before
public void setUp() {
hwVtep1.setTopoId("hwvtep:1");
hwVtep1.setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3");
hwVtep1.setIpPrefix(ipPrefixTest);
- vteps = new VtepsBuilder().setDpnId(dpId2).setIpAddress(ipAddress1).withKey(new
- VtepsKey(dpId2)).build();
+ vteps = new VtepsBuilder().setDpnId(dpId2).setIpAddress(ipAddress1).setPortname(portName1).withKey(new
+ VtepsKey(dpId2,portName1)).build();
vtepsList.add(vteps);
idOutputOptional1 = RpcResultBuilder.success(expectedId1).buildFuture();
getIdInput1 = new AllocateIdInputBuilder()
.setPoolName(ITMConstants.ITM_IDPOOL_NAME)
.setIdKey("1:phy0:100:192.168.56.30:192.168.56.40:VXLAN").build();
lenient().doReturn(idOutputOptional8).when(idManagerService).allocateId(getIdInput8);
- tunnelEndPointsVxlan = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress3).setInterfaceName(parentInterfaceName)
+ tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1)
+ .setIpAddress(ipAddress3).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1)
- .build();
+ .setSubnetMask(ipPrefixTest).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId2).setUp(true).withKey(new DPNTEPsInfoKey(dpId2))
.setTunnelEndPoints(tunnelEndPointsListVxlan).build();
dpnTepsList.add(dpntePsInfoVxlan);
cfgdHwVtepsList.add(hwVtep1);
-
+ subnets = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).withKey(new SubnetsKey(ipPrefixTest))
+ .setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
+ subnetsList.add(subnets);
transportZone = new TransportZoneBuilder().setTunnelType(tunnelType1).setZoneName(transportZone1).withKey(new
- TransportZoneKey(transportZone1)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
+ TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
externalTunnel = new ExternalTunnelBuilder().setTunnelInterfaceName(parentInterfaceName)
.setTransportType(tunnelType1).setDestinationDevice("hwvtep:1").setSourceDevice(dpId2.toString())
.withKey(new ExternalTunnelKey(dpId2.toString() , hwVtep1.getNodeId() , tunnelType1)).build();
lenient().doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
lenient().doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
lenient().doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
- doReturn("phy0").when(itmConfig).getPortname();
- doReturn(100).when(itmConfig).getVlanId();
}
@Test
.read(externalTunnelIdentifier6);
try {
ItmExternalTunnelDeleteWorker
- .deleteHwVtepsTunnels(dpnTepsList, cfgdHwVtepsList, transportZone, typedReadWriteTransaction,
- itmConfig);
+ .deleteHwVtepsTunnels(dpnTepsList, cfgdHwVtepsList, transportZone, typedReadWriteTransaction);
verify(typedReadWriteTransaction).delete(trunkIdentifier);
verify(typedReadWriteTransaction, times(2)).delete(externalTunnelIdentifier1);
verify(typedReadWriteTransaction, times(2)).delete(externalTunnelIdentifier2);
ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
- tunnelEndPointsVxlan = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress1).setInterfaceName(parentInterfaceName)
+ tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1)
+ .setIpAddress(ipAddress1).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1)
- .build();
- tunnelEndPointsVxlanNew = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress2).setInterfaceName(parentInterfaceName)
+ .setSubnetMask(ipPrefixTest).build();
+ tunnelEndPointsVxlanNew = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName2)
+ .setIpAddress(ipAddress2).setGwIpAddress(gtwyIp2).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1)
- .build();
- tunnelEndPointsGre = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress1).setInterfaceName(parentInterfaceName)
+ .setSubnetMask(ipPrefixTest).build();
+ tunnelEndPointsGre = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1)
+ .setIpAddress(ipAddress1).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType2)
- .build();
- tunnelEndPointsGreNew = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress2).setInterfaceName(parentInterfaceName)
+ .setSubnetMask(ipPrefixTest).build();
+ tunnelEndPointsGreNew = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName2)
+ .setIpAddress(ipAddress2).setGwIpAddress(gtwyIp2).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType2)
- .build();
+ .setSubnetMask(ipPrefixTest).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
tunnelEndPointsListVxlanNew.add(tunnelEndPointsVxlanNew);
tunnelEndPointsListGre.add(tunnelEndPointsGre);
ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
- tunnelEndPointsVxlan = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress1).setInterfaceName(parentInterfaceName)
+ tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1)
+ .setIpAddress(ipAddress1).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1))
- .setTunnelType(tunnelType1)
- .withKey(new TunnelEndPointsKey(ipAddress1,tunnelType1)).build();
- tunnelEndPointsVxlanNew = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress2).setInterfaceName(parentInterfaceName)
+ .setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest)
+ .withKey(new TunnelEndPointsKey(ipAddress1,portName1,tunnelType1,vlanId)).build();
+ tunnelEndPointsVxlanNew = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName2)
+ .setIpAddress(ipAddress2).setGwIpAddress(gtwyIp2).setInterfaceName(parentInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1)
- .build();
+ .setSubnetMask(ipPrefixTest).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
tunnelEndPointsListVxlanNew.add(tunnelEndPointsVxlanNew);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId1).withKey(new DPNTEPsInfoKey(dpId1)).setUp(true)
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.interfacemanager.interfaces.InterfaceManagerService;
import org.opendaylight.genius.itm.cache.DPNTEPsInfoCache;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInput;
DPNTEPsInfo dpntePsInfoVxlan = null;
TunnelEndPoints tunnelEndPointsVxlan = null;
Interface iface = null;
+ Subnets subnetsTest = null;
TransportZones transportZones = null;
TransportZone transportZone = null;
DeviceVteps deviceVteps = null;
List<DPNTEPsInfo> cfgdDpnListVxlan = new ArrayList<>() ;
List<TunnelEndPoints> tunnelEndPointsListVxlan = new ArrayList<>();
List<TransportZone> transportZoneList = new ArrayList<>() ;
+ List<Subnets> subnetsList = new ArrayList<>() ;
List<DeviceVteps> deviceVtepsList = new ArrayList<>();
List<String> stringList = new ArrayList<>();
List<BigInteger> dpId1List = new ArrayList<>();
InstanceIdentifier<TransportZones> transportZonesIdentifier = InstanceIdentifier.create(TransportZones.class);
InstanceIdentifier<DeviceVteps> deviceVtepsIdentifier = InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(transportZone1))
- .child(DeviceVteps.class, deviceVtepKey).build();
+ .child(Subnets.class, new SubnetsKey(ipPrefixTest)).child(DeviceVteps.class, deviceVtepKey).build();
@Mock DataBroker dataBroker;
@Mock JobCoordinator jobCoordinator;
@Mock IInterfaceManager interfaceManager;
@Mock InterfaceManagerService interfaceManagerService;
@Mock EntityOwnershipUtils entityOwnershipUtils;
- @Mock TypedReadWriteTransaction mockTypedReadWriteTx;
ItmManagerRpcService itmManagerRpcService ;
DirectTunnelUtils directTunnelUtils;
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(tunnelInterfaceName, ipAddress1.stringValue(),
ipAddress1.stringValue(), tunnelType1.getName());
interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
- tunnelEndPointsVxlan = new TunnelEndPointsBuilder()
- .setIpAddress(ipAddress1).setInterfaceName(tunnelInterfaceName)
+ tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1)
+ .setIpAddress(ipAddress1).setGwIpAddress(gtwyIp1).setInterfaceName(tunnelInterfaceName)
.setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1)
- .withKey(new TunnelEndPointsKey(ipAddress1,tunnelType1)).build();
+ .setSubnetMask(ipPrefixTest)
+ .withKey(new TunnelEndPointsKey(ipAddress1,portName1,tunnelType1,vlanId)).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId1).withKey(new DPNTEPsInfoKey(dpId1)).setUp(true)
.setTunnelEndPoints(tunnelEndPointsListVxlan).build();
.setTunnelType(tunnelType1).setDestinationNode(destinationDevice).setSourceNode(sourceDevice).build();
iface = ItmUtils.buildTunnelInterface(dpId1,trunkInterfaceName, String.format("%s %s",
ItmUtils.convertTunnelTypetoString(tunnelType1), "Trunk Interface"),true,tunnelType1,
- tunnelEndPointsVxlan.getIpAddress(),ipAddress1, false,
+ tunnelEndPointsVxlan.getIpAddress(),ipAddress1,gtwyIp1,tunnelEndPointsVxlan.getVLANID(), false, false,
monitorProtocol,null, false, null);
-
+ subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).withKey(new SubnetsKey(ipPrefixTest))
+ .setDeviceVteps(deviceVtepsList).build();
+ subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(transportZone1)
.setTunnelType(tunnelType1).withKey(new TransportZoneKey(transportZone1))
- .build();
+ .setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointOutput;
DPNTEPsInfo dpntePsInfoVxlan;
TunnelEndPoints tunnelEndPointsVxlan;
Interface iface;
+ Subnets subnetsTest;
TransportZones transportZones;
TransportZone transportZone;
DeviceVteps deviceVteps;
List<DPNTEPsInfo> cfgdDpnListVxlan = new ArrayList<>();
List<TunnelEndPoints> tunnelEndPointsListVxlan = new ArrayList<>();
List<TransportZone> transportZoneList = new ArrayList<>();
+ List<Subnets> subnetsList = new ArrayList<>();
List<DeviceVteps> deviceVtepsList = new ArrayList<>();
List<String> stringList = new ArrayList<>();
List<BigInteger> dpId1List = new ArrayList<>();
InstanceIdentifier<TransportZones> transportZonesIdentifier = InstanceIdentifier.create(TransportZones.class);
InstanceIdentifier<DeviceVteps> deviceVtepsIdentifier = InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(ItmTestConstants.TZ_NAME))
+ .child(Subnets.class, new SubnetsKey(ItmTestConstants.IP_PREFIX_TEST))
.child(DeviceVteps.class, deviceVtepKey).build();
InstanceIdentifier<DeviceVteps> deviceVtepsIdentifier2 = InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(ItmTestConstants.TZ_NAME))
+ .child(Subnets.class, new SubnetsKey(ItmTestConstants.IP_PREFIX_TEST))
.child(DeviceVteps.class, deviceVtep2Key).build();
@Inject DataBroker dataBroker;
ItmTestConstants.IP_ADDRESS_3.stringValue(),
ItmTestConstants.TUNNEL_TYPE_VXLAN.getName());
interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
- tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3)
- .setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME)
+ tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(ItmTestConstants.VLAN_ID)
+ .setPortname(ItmTestConstants.PORT_NAME_1).setIpAddress(ItmTestConstants.IP_ADDRESS_3)
+ .setGwIpAddress(ItmTestConstants.GTWY_IP_1).setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME)
.setTzMembership(ItmUtils.createTransportZoneMembership(ItmTestConstants.TZ_NAME))
- .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN)
- .withKey(new TunnelEndPointsKey(ItmTestConstants.IP_ADDRESS_3,
- ItmTestConstants.TUNNEL_TYPE_VXLAN)).build();
+ .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSubnetMask(ItmTestConstants.IP_PREFIX_TEST)
+ .withKey(new TunnelEndPointsKey(ItmTestConstants.IP_ADDRESS_3,ItmTestConstants.PORT_NAME_1,
+ ItmTestConstants.TUNNEL_TYPE_VXLAN,ItmTestConstants.VLAN_ID)).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(ItmTestConstants.DP_ID_1)
.withKey(new DPNTEPsInfoKey(ItmTestConstants.DP_ID_1)).setUp(true)
iface = ItmUtils.buildTunnelInterface(ItmTestConstants.DP_ID_1,trunkInterfaceName, String.format("%s %s",
ItmUtils.convertTunnelTypetoString(ItmTestConstants.TUNNEL_TYPE_VXLAN), "Trunk Interface"),
true,ItmTestConstants.TUNNEL_TYPE_VXLAN,tunnelEndPointsVxlan.getIpAddress(),
- ItmTestConstants.IP_ADDRESS_3,false, ItmTestConstants.MONITOR_PROTOCOL,null, false, null);
-
+ ItmTestConstants.IP_ADDRESS_3,ItmTestConstants.GTWY_IP_1,
+ tunnelEndPointsVxlan.getVLANID(),false,false, ItmTestConstants.MONITOR_PROTOCOL,null, false, null);
+ subnetsTest = new SubnetsBuilder().setGatewayIp(ItmTestConstants.GTWY_IP_1).setVlanId(ItmTestConstants.VLAN_ID)
+ .withKey(new SubnetsKey(ItmTestConstants.IP_PREFIX_TEST)).setDeviceVteps(deviceVtepsList).build();
+ subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME)
.setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN)
- .withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).build();
+ .withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
import org.opendaylight.infrautils.caches.testutils.CacheModule;
import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.testutils.LogRule;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.ItmConfigBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@Before
public void start() throws InterruptedException {
transportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME)
- .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN)
- .withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME))
- .build();
+ .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME))
+ .build();
this.txRunner = new RetryingManagedNewTransactionRunner(dataBroker);
}
// Common method created for code-reuse
private InstanceIdentifier<TransportZone> processDefTzOnItmConfig(boolean defTzEnabledFlag,
- String defTzTunnelType) throws Exception {
+ String defTzTunnelType) throws Exception {
ItmConfig itmConfigObj = null;
if (defTzTunnelType != null) {
// set def-tz-enabled flag and def-tz-tunnel-type
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(defTzEnabledFlag)
- .setDefTzTunnelType(defTzTunnelType).build();
+ .setDefTzTunnelType(defTzTunnelType).build();
} else {
// set def-tz-enabled flag only
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(defTzEnabledFlag).build();
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ITMConstants.DEFAULT_TRANSPORT_ZONE);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE);
return tzonePath;
}
// read from config DS
boolean defTzEnabled = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(
- dataBroker, LogicalDatastoreType.CONFIGURATION, iid).get().isDefTzEnabled();
+ dataBroker, LogicalDatastoreType.CONFIGURATION, iid).get().isDefTzEnabled();
Assert.assertEquals(defTzEnabled, false);
}
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).build();
// write into config DS
- txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
- tx -> tx.put(iid, itmConfigObj, true)).get();
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(iid, itmConfigObj, true)).get();
// read from config DS
boolean defTzEnabled = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(
- dataBroker, LogicalDatastoreType.CONFIGURATION, iid).get().isDefTzEnabled();
+ dataBroker, LogicalDatastoreType.CONFIGURATION, iid).get().isDefTzEnabled();
Assert.assertEquals(defTzEnabled, true);
}
String defTzTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
InstanceIdentifier<TransportZone> tzonePath = processDefTzOnItmConfig(defTzEnabledFlag,
- defTzTunnelType);
+ defTzTunnelType);
Assert.assertNotNull(tzonePath);
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithVxlanTunnelType(),
- dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
+ dataBroker.newReadOnlyTransaction()
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
}
@Test
String defTzTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
InstanceIdentifier<TransportZone> tzonePath = processDefTzOnItmConfig(defTzEnabledFlag,
- defTzTunnelType);
+ defTzTunnelType);
Assert.assertNotNull(tzonePath);
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithGreTunnelType(),
- dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
+ dataBroker.newReadOnlyTransaction()
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
}
@Test
String defTzTunnelType = null;
InstanceIdentifier<TransportZone> tzonePath = processDefTzOnItmConfig(defTzEnabledFlag,
- defTzTunnelType);
+ defTzTunnelType);
Assert.assertNotNull(tzonePath);
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
}
@Test
String defTzTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
InstanceIdentifier<TransportZone> tzonePath = processDefTzOnItmConfig(defTzEnabledFlag,
- defTzTunnelType);
+ defTzTunnelType);
Assert.assertNotNull(tzonePath);
// check default-TZ is created with VXLAN tunnel type
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithVxlanTunnelType().getTunnelType(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
- .checkedGet().get().getTunnelType());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
+ .checkedGet().get().getTunnelType());
// now, change def-tz-tunnel-type to GRE
defTzTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
// check default-TZ is re-created with GRE tunnel type
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithGreTunnelType().getTunnelType(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
- .checkedGet().get().getTunnelType());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
+ .checkedGet().get().getTunnelType());
}
@Test
// create default-TZ first by setting def-tz-enabled flag to true
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true)
- .setDefTzTunnelType(ITMConstants.TUNNEL_TYPE_GRE).build();
+ .setDefTzTunnelType(ITMConstants.TUNNEL_TYPE_GRE).build();
// creates/deletes default-TZ based on def-tz-enabled flag
itmProvider.createDefaultTransportZone(itmConfigObj);
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ITMConstants.DEFAULT_TRANSPORT_ZONE);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(tzonePath);
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithGreTunnelType(),
- dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
+ dataBroker.newReadOnlyTransaction()
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
// now delete default-TZ first by setting def-tz-enabled flag to false
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(false).build();
coordinatorEventsWaiter.awaitEventsConsumption();
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
}
@Test
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ITMConstants.DEFAULT_TRANSPORT_ZONE);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(tzonePath);
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
// add TEP into default-TZ
ListenableFuture<Void> futures =
- ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.DEF_TZ_TEP_IP,
- ItmTestConstants.DEF_BR_DPID,
- ITMConstants.DEFAULT_TRANSPORT_ZONE, false, dataBroker, txRunner);
+ ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.DEF_TZ_TEP_IP,
+ ItmTestConstants.DEF_BR_DPID,
+ ITMConstants.DEFAULT_TRANSPORT_ZONE, false, dataBroker, txRunner);
futures.get();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj,
- ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID,
- ITMConstants.DUMMY_PORT);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID,
+ ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
// remove tep from default-TZ
futures = ItmTepAutoConfigTestUtil.deleteTep(ItmTestConstants.DEF_TZ_TEP_IP, ItmTestConstants.DEF_BR_DPID,
- ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker, txRunner);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker, txRunner);
futures.get();
// check TEP is deleted from default-TZ
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
+ .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
}
@Test
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ItmTestConstants.TZ_NAME);
+ ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// create TZA
// add tep
ListenableFuture<Void> futures = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NB_TZ_TEP_IP,
- ItmTestConstants.DEF_BR_DPID, ItmTestConstants.TZ_NAME, false, dataBroker, txRunner);
+ 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);
+ 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).checkedGet().get());
+ dataBroker.newReadOnlyTransaction()
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
// remove tep
futures = ItmTepAutoConfigTestUtil.deleteTep(ItmTestConstants.NB_TZ_TEP_IP, ItmTestConstants.DEF_BR_DPID,
- ItmTestConstants.TZ_NAME, dataBroker, txRunner);
+ ItmTestConstants.TZ_NAME, dataBroker, txRunner);
futures.get();
// check TEP is deleted
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
+ .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
// for safe side, check TZ is present
Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get().getZoneName());
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get().getZoneName());
}
@Test
// 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);
+ ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future =
- OvsdbTestUtil.createNode(connInfo,tepIp,ITMConstants.DEFAULT_TRANSPORT_ZONE,dataBroker);
+ OvsdbTestUtil.createNode(connInfo,tepIp,ITMConstants.DEFAULT_TRANSPORT_ZONE,dataBroker);
future.get();
// add bridge into node
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ITMConstants.DEFAULT_TRANSPORT_ZONE);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(tzonePath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
- .checkedGet().get());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
+ .checkedGet().get());
// test TEP delete now,
// pass tep-ip with NULL value, tep-ip paramtere in external_ids will not be set.
tepIp = null;
future = OvsdbTestUtil.updateNode(connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE,
- null, dataBroker);
+ null, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj,
- ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID,
- ITMConstants.DUMMY_PORT);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID,
+ ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// check TEP is deleted from default-TZ when TEP-Ip is removed from southbound
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
+ .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
}
@Test
// 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);
+ ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(
- connInfo, tepIp, ItmTestConstants.TZ_NAME, dataBroker);
+ connInfo, tepIp, ItmTestConstants.TZ_NAME, dataBroker);
future.get();
// create Transport-zone in advance
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ItmTestConstants.TZ_NAME);
+ ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TEP is added into NB configured TZ
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
- .checkedGet().get());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath)
+ .checkedGet().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj,
- ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
+ ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// test TEP delete now,
// check TEP is deleted from default-TZ when TEP-Ip is removed from southbound
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
+ .read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
}
@Test
public void tzAddDeleteToNotHostedViaSouthboundTest() throws Exception {
// create Network topology node
ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT,
- ItmTestConstants.LOCALHOST_IP);
+ ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(
- connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, ItmTestConstants.NOT_HOSTED_TZ_NAME,
- dataBroker);
+ connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, ItmTestConstants.NOT_HOSTED_TZ_NAME,
+ dataBroker);
future.get();
// add bridge into node
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedtzPath = ItmTepAutoConfigTestUtil
- .getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
+ .getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(notHostedtzPath);
// check not hosted
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
- notHostedtzPath).checkedGet().get());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
+ notHostedtzPath).checkedGet().get());
future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, null,
- ItmTestConstants.DEF_BR_NAME, dataBroker);
+ ItmTestConstants.DEF_BR_NAME, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
Assert.assertEquals(Optional.absent(),dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).get());
+ .read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).get());
}
@Test
// 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);
+ ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(
- connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
+ connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
future.get();
// add bridge into node
// iid for default-TZ
InstanceIdentifier<TransportZone> defTzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ITMConstants.DEFAULT_TRANSPORT_ZONE);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(defTzonePath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, defTzonePath)
- .checkedGet().get());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, defTzonePath)
+ .checkedGet().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj,
- ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID,
- ITMConstants.DUMMY_PORT);
+ ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID,
+ ITMConstants.DUMMY_PORT);
Assert.assertNotNull(oldVTepPath);
// create Transport-zone TZA
tzPath, transportZone, WriteTransaction.CREATE_MISSING_PARENTS)).get();
// iid for TZA configured from NB
InstanceIdentifier<TransportZone> tzaTzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ItmTestConstants.TZ_NAME);
+ ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzaTzonePath);
// update OVSDB node with tzname=TZA in ExternalIds list
// check old TEP which was in default-TZ is deleted
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
+ .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)
- .checkedGet().get());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,tzaTzonePath)
+ .checkedGet().get());
}
@Test
// prepare OVSDB 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);
+ ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(
- connInfo, tepIp, ItmTestConstants.TZ_NAME, dataBroker);
+ connInfo, tepIp, ItmTestConstants.TZ_NAME, dataBroker);
future.get();
// create Transport-zone in advance
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(
- ItmTestConstants.TZ_NAME);
+ ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TEP is added into TZ
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj,
- ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
+ ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(oldVTepPath);
// add new bridge br2
// update OVSDB node with br-name=br2 in ExternalIds column
String brName = ItmTestConstants.BR2_NAME;
future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NB_TZ_TEP_IP,
- ItmTestConstants.TZ_NAME, brName, dataBroker);
+ ItmTestConstants.TZ_NAME, brName, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<Vteps> newVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj,
- ItmTestConstants.TZ_NAME, ItmTestConstants.INT_BR2_DPID, ITMConstants.DUMMY_PORT);
+ ItmTestConstants.TZ_NAME, ItmTestConstants.INT_BR2_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(newVTepPath);
// check old TEP having default-bridge-DPID is deleted
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
+ .read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
// check TEP is updated with dpnId of br2 when br-name is updated to br2 from southbound
Assert.assertEquals(ItmTestConstants.INT_BR2_DPID, dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, newVTepPath).checkedGet().get().getDpnId());
+ .read(LogicalDatastoreType.CONFIGURATION, newVTepPath).checkedGet().get().getDpnId());
}
@Test
public void tepAddIntoTepsNotHostedListTest() throws Exception {
// add into not hosted list
ListenableFuture<Void> future = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NOT_HOSTED_TZ_TEP_IP,
- ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME,
- false, dataBroker, txRunner);
+ ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME, false, dataBroker, txRunner);
future.get();
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath =
- ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
+ ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(notHostedPath);
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath)
- .checkedGet().get());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath)
+ .checkedGet().get());
}
@Test
public void tepDeleteFromTepsNotHostedListTest() throws Exception {
// add into not hosted list
ListenableFuture<Void> future = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NOT_HOSTED_TZ_TEP_IP,
- ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME,
- false, dataBroker, txRunner);
+ ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME, false, dataBroker, txRunner);
future.get();
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath =
- ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
+ ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(notHostedPath);
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(),
- dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).checkedGet().get());
+ dataBroker.newReadOnlyTransaction()
+ .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).checkedGet().get());
//delete from not hosted list
future = ItmTepAutoConfigTestUtil.deleteTep(ItmTestConstants.NOT_HOSTED_TZ_TEP_IP,
- ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME, dataBroker, txRunner);
+ ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME, dataBroker, txRunner);
future.get();
Assert.assertEquals(Optional.absent(),
- dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
+ dataBroker.newReadOnlyTransaction()
+ .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
}
@Test
public void tepMoveFromTepsNotHostedListToTzTest() throws Exception {
// add into not hosted list
ListenableFuture<Void> future = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NOT_HOSTED_TZ_TEP_IP,
- ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME,
- false, dataBroker, txRunner);
+ ItmTestConstants.NOT_HOSTED_TZ_TEPDPN_ID, ItmTestConstants.NOT_HOSTED_TZ_NAME, false, dataBroker, txRunner);
future.get();
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath =
- ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
+ ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(notHostedPath);
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(),
- dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).checkedGet().get());
+ 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)
- .withKey(new TransportZoneKey(ItmTestConstants.NOT_HOSTED_TZ_NAME)).build();
+ .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN)
+ .withKey(new TransportZoneKey(ItmTestConstants.NOT_HOSTED_TZ_NAME)).build();
Assert.assertNotNull(transportZoneNorth);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(ItmTepAutoConfigTestUtil
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzPath = ItmTepAutoConfigTestUtil.getTzIid(
- ItmTestConstants.NOT_HOSTED_TZ_NAME);
+ ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(tzPath);
// check TZ is Moved
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects
- .newTepNotHostedTransportZone().getUnknownVteps().get(0).getIpAddress().stringValue(),
- dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzPath)
- .checkedGet().get().getVteps().get(0).getIpAddress().stringValue());
+ .newTepNotHostedTransportZone().getUnknownVteps().get(0).getIpAddress().stringValue(),
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzPath)
+ .checkedGet().get().getSubnets().get(0).getVteps().get(0).getIpAddress().stringValue());
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone().getUnknownVteps()
.get(0).getDpnId(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzPath).checkedGet().get()
+ .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());
+ dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzPath)
+ .checkedGet().get().getZoneName());
// check TZ is removed
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
+ .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
}
@Test
for (UnknownVteps unknownVtep:unknownVtepsList) {
Vteps vteps = new VtepsBuilder().setDpnId(unknownVtep.getDpnId())
- .setIpAddress(unknownVtep.getIpAddress())
- .withKey(new VtepsKey(unknownVtep.getDpnId())).build();
+ .setIpAddress(unknownVtep.getIpAddress()).setPortname("phy0")
+ .withKey(new VtepsKey(unknownVtep.getDpnId(), "phy0")).build();
vtepsList.add(vteps);
}
+ //adding vtepList to subnet
+ List<Subnets> subnetList = new ArrayList<>();
+ Subnets subnet = new SubnetsBuilder().setGatewayIp(IpAddressBuilder.getDefaultInstance("0.0.0.0"))
+ .withKey(new SubnetsKey(subnetMaskObj)).setVlanId(0)
+ .setVteps(vtepsList).build();
+ subnetList.add(subnet);
+
+ //add Subnet to newly created transport zone of same name
TransportZone recreatedTransportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME)
- .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setVteps(vtepsList)
+ .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSubnets(subnetList)
.withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).build();
txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.merge(LogicalDatastoreType.CONFIGURATION,
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.OPERATIONAL, notHostedPath).checkedGet());
assertEqualBeans(1, dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get()
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get().getSubnets().get(0)
.getVteps().size());
}
//modifing the dpnid and keeping the ip same.
for (UnknownVteps unknownVtep:unknownVtepsList) {
Vteps vteps = new VtepsBuilder().setDpnId(new BigInteger("10"))
- .setIpAddress(unknownVtep.getIpAddress())
- .withKey(new VtepsKey(new BigInteger("10"))).build();
+ .setIpAddress(unknownVtep.getIpAddress()).setPortname("phy0")
+ .withKey(new VtepsKey(new BigInteger("10"), "phy0")).build();
vtepsList.add(vteps);
}
+ //adding vtepList to subnet
+ List<Subnets> subnetList = new ArrayList<>();
+ Subnets subnet = new SubnetsBuilder().setGatewayIp(IpAddressBuilder.getDefaultInstance("0.0.0.0"))
+ .withKey(new SubnetsKey(subnetMaskObj)).setVlanId(0)
+ .setVteps(vtepsList).build();
+ subnetList.add(subnet);
+
+ //add Subnet to newly created transport zone of same name
TransportZone recreatedTransportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME)
- .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setVteps(vtepsList)
+ .setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSubnets(subnetList)
.withKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).build();
txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.merge(LogicalDatastoreType.CONFIGURATION,
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction()
.read(LogicalDatastoreType.OPERATIONAL, notHostedPath).checkedGet());
assertEqualBeans(1, dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get()
+ .read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get().getSubnets().get(0)
.getVteps().size());
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public final class ItmTepAutoConfigTestUtil {
/* utility methods */
public static InstanceIdentifier<TransportZone> getTzIid(String tzName) {
InstanceIdentifier<TransportZone> tzoneIid =
- InstanceIdentifier.builder(TransportZones.class)
- .child(TransportZone.class, new TransportZoneKey(tzName))
- .build();
+ InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(tzName))
+ .build();
return tzoneIid;
}
public static InstanceIdentifier<Vteps> getTepIid(IpPrefix subnetMaskObj, String tzName,
BigInteger dpnId, String portName) {
- VtepsKey vtepkey = new VtepsKey(dpnId);
+ SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
+ VtepsKey vtepkey = new VtepsKey(dpnId, portName);
InstanceIdentifier<Vteps> vtepIid = InstanceIdentifier.builder(TransportZones.class)
.child(TransportZone.class, new TransportZoneKey(tzName))
- .child(Vteps.class, vtepkey).build();
+ .child(Subnets.class, subnetsKey).child(Vteps.class, vtepkey).build();
return vtepIid;
}
import org.opendaylight.genius.itm.listeners.TransportZoneListener;
import org.opendaylight.genius.itm.listeners.TunnelMonitorChangeListener;
import org.opendaylight.genius.itm.listeners.TunnelMonitorIntervalListener;
+import org.opendaylight.genius.itm.listeners.VtepConfigSchemaListener;
import org.opendaylight.genius.itm.monitoring.ItmTunnelEventListener;
import org.opendaylight.genius.itm.rpc.ItmManagerRpcService;
import org.opendaylight.genius.lockmanager.impl.LockManagerServiceImpl;
.setDefTzEnabled(true)
.setDefTzTunnelType(ITMConstants.TUNNEL_TYPE_VXLAN)
.setGpeExtensionEnabled(false)
- .setPortname("")
- .setVlanId(0)
.build();
bind(ItmConfig.class).toInstance(itmConfigObj);
IfmConfig interfaceConfig = new IfmConfigBuilder().setItmDirectTunnels(false).build();
bind(TransportZoneListener.class);
bind(OvsdbNodeListener.class);
bind(InterfaceStateListener.class);
+ bind(VtepConfigSchemaListener.class);
bind(TunnelMonitorChangeListener.class);
bind(ItmTunnelEventListener.class);
package org.opendaylight.genius.itm.tests.xtend;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
import org.opendaylight.genius.itm.globals.ITMConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre;
new TransportZoneBuilder >> [
zoneName = ITMConstants.DEFAULT_TRANSPORT_ZONE
tunnelType = TunnelTypeVxlan
- vteps = #[
- new VtepsBuilder >> [
- dpnId = ItmTestConstants.INT_DEF_BR_DPID
- ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.DEF_TZ_TEP_IP)
- optionOfTunnel = false
+
+ subnets = #[
+ new SubnetsBuilder >> [
+ gatewayIp = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP)
+ prefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX)
+ vlanId = ITMConstants.DUMMY_VLANID
+
+ vteps = #[
+ new VtepsBuilder >> [
+ dpnId = ItmTestConstants.INT_DEF_BR_DPID
+ ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.DEF_TZ_TEP_IP)
+ portname = ITMConstants.DUMMY_PORT
+ weight = 1
+ optionOfTunnel = false
+ ]
+ ]
]
]
-
]
}
new TransportZoneBuilder >> [
zoneName = ITMConstants.DEFAULT_TRANSPORT_ZONE
tunnelType = TunnelTypeVxlan
- vteps = #[
- new VtepsBuilder >> [
- dpnId = ItmTestConstants.INT_DEF_BR_DPID
- ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.NB_TZ_TEP_IP)
- optionOfTunnel = false
+ subnets = #[
+ new SubnetsBuilder >> [
+ gatewayIp = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP)
+ prefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX)
+ vlanId = ITMConstants.DUMMY_VLANID
+
+ vteps = #[
+ new VtepsBuilder >> [
+ dpnId = ItmTestConstants.INT_DEF_BR_DPID
+ ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.NB_TZ_TEP_IP)
+ portname = ITMConstants.DUMMY_PORT
+ weight = 1
+ optionOfTunnel = false
+ ]
]
+ ]
]
]
}
package org.opendaylight.genius.itm.tests.xtend;
import org.opendaylight.genius.itm.tests.ItmTestConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder;
import static extension org.opendaylight.mdsal.binding.testutils.XtendBuilderExtensions.operator_doubleGreaterThan
package org.opendaylight.genius.itm.tests.xtend;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder;
new TransportZoneBuilder >> [
zoneName = "TZA"
tunnelType = TunnelTypeVxlan
- vteps = #[
- new VtepsBuilder >> [
- dpnId = ItmTestConstants.INT_DEF_BR_DPID
- ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.NB_TZ_TEP_IP)
- optionOfTunnel = false
+ subnets = #[
+ new SubnetsBuilder >> [
+ gatewayIp = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP)
+ prefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX)
+ vlanId = ITMConstants.DUMMY_VLANID
+
+ vteps = #[
+ new VtepsBuilder >> [
+ dpnId = ItmTestConstants.INT_DEF_BR_DPID
+ ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.NB_TZ_TEP_IP)
+ portname = ITMConstants.DUMMY_PORT
+ weight = 1
+ optionOfTunnel = false
+ ]
+ ]
]
]
]
new TransportZoneBuilder >> [
zoneName = "TZA"
tunnelType = TunnelTypeVxlan
- vteps = #[
- new VtepsBuilder >> [
- dpnId = ItmTestConstants.INT_DEF_BR_DPID
- ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.DEF_TZ_TEP_IP)
- optionOfTunnel = false
+ subnets = #[
+ new SubnetsBuilder >> [
+ gatewayIp = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP)
+ prefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX)
+ vlanId = ITMConstants.DUMMY_VLANID
+
+ vteps = #[
+ new VtepsBuilder >> [
+ dpnId = ItmTestConstants.INT_DEF_BR_DPID
+ ipAddress = IpAddressBuilder.getDefaultInstance(ItmTestConstants.DEF_TZ_TEP_IP)
+ portname = ITMConstants.DUMMY_PORT
+ weight = 1
+ optionOfTunnel = false
+ ]
]
]
+ ]
]
}