Fixed to not to create gateway group if it is already exists
Also changed some names shorter.
Change-Id: Iaa8aa5ac378fc168e79c9e238090ca817af42261
diff --git a/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNode.java b/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNode.java
index b2f0af0..26371d0 100644
--- a/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNode.java
+++ b/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNode.java
@@ -28,13 +28,12 @@
*/
public final class GatewayNode {
private final DeviceId gatewayDeviceId;
- private final String gatewayExternalInterfaceName;
+ private final String uplinkIntf;
private final Ip4Address dataIpAddress;
- private GatewayNode(DeviceId gatewayDeviceId, String gatewayExternalInterfaceName,
- Ip4Address dataIpAddress) {
+ private GatewayNode(DeviceId gatewayDeviceId, String uplinkIntf, Ip4Address dataIpAddress) {
this.gatewayDeviceId = gatewayDeviceId;
- this.gatewayExternalInterfaceName = gatewayExternalInterfaceName;
+ this.uplinkIntf = uplinkIntf;
this.dataIpAddress = dataIpAddress;
}
@@ -52,8 +51,8 @@
*
* @return The gateway`s interface name
*/
- public String getGatewayExternalInterfaceName() {
- return gatewayExternalInterfaceName;
+ public String getUplinkIntf() {
+ return uplinkIntf;
}
/**
@@ -74,8 +73,7 @@
if (obj instanceof GatewayNode) {
GatewayNode that = (GatewayNode) obj;
if (Objects.equals(gatewayDeviceId, that.gatewayDeviceId) &&
- Objects.equals(gatewayExternalInterfaceName,
- that.gatewayExternalInterfaceName) &&
+ Objects.equals(uplinkIntf, that.uplinkIntf) &&
Objects.equals(dataIpAddress, that.dataIpAddress)) {
return true;
}
@@ -85,17 +83,15 @@
@Override
public int hashCode() {
- return Objects.hash(gatewayDeviceId,
- gatewayExternalInterfaceName,
- dataIpAddress);
+ return Objects.hash(gatewayDeviceId, uplinkIntf, dataIpAddress);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("deviceId", gatewayDeviceId)
- .add("externalPort", gatewayExternalInterfaceName)
- .add("dataIp", dataIpAddress)
+ .add("gatewayDeviceId", gatewayDeviceId)
+ .add("uplinkInterface", uplinkIntf)
+ .add("dataIpAddress", dataIpAddress)
.toString();
}
@@ -114,7 +110,7 @@
public static final class Builder {
private DeviceId gatewayDeviceId;
- private String gatewayExternalInterfaceName;
+ private String uplinkIntf;
private Ip4Address dataIpAddress;
/**
@@ -129,13 +125,13 @@
}
/**
- * Sets the gateway`s interface name.
+ * Sets the gateway`s uplink interface name.
*
* @param name The gateway`s interface name
* @return Builder object
*/
- public Builder gatewayExternalInterfaceName(String name) {
- this.gatewayExternalInterfaceName = name;
+ public Builder uplinkIntf(String name) {
+ this.uplinkIntf = name;
return this;
}
@@ -156,8 +152,8 @@
* @return GatewayNode object
*/
public GatewayNode build() {
- return new GatewayNode(checkNotNull(gatewayDeviceId), checkNotNull(gatewayExternalInterfaceName),
- checkNotNull(dataIpAddress));
+ return new GatewayNode(checkNotNull(gatewayDeviceId), checkNotNull(uplinkIntf),
+ checkNotNull(dataIpAddress));
}
}
}
diff --git a/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNodeConfig.java b/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNodeConfig.java
index 0d4f561..fc047e0 100644
--- a/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNodeConfig.java
+++ b/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/GatewayNodeConfig.java
@@ -41,7 +41,7 @@
public static final String NODES = "nodes";
public static final String BRIDGE_ID = "bridgeId";
public static final String DATAPLANE_IP = "dataPlaneIp";
- public static final String EXTERNAL_INTERFACE_NAME = "gatewayExternalInterfaceName";
+ public static final String UPLINK_INTERFACE_NAME = "uplinkInterface";
/**
* Returns the set of nodes read from network config.
@@ -61,7 +61,7 @@
try {
nodes.add(new GatewayNode.Builder()
.gatewayDeviceId(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()))
- .gatewayExternalInterfaceName(jsonNode.path(EXTERNAL_INTERFACE_NAME).asText())
+ .uplinkIntf(jsonNode.path(UPLINK_INTERFACE_NAME).asText())
.dataIpAddress(Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText())).build());
} catch (IllegalArgumentException | NullPointerException e) {
log.error("Failed to read {}", e.toString());
@@ -86,7 +86,7 @@
ObjectNode objectNode = (ObjectNode) jsonNode;
return isString(objectNode, BRIDGE_ID, MANDATORY)
&& isIpAddress(objectNode, DATAPLANE_IP, MANDATORY)
- && isString(objectNode, EXTERNAL_INTERFACE_NAME, MANDATORY);
+ && isString(objectNode, UPLINK_INTERFACE_NAME, MANDATORY);
}
}
diff --git a/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/ScalableGatewayService.java b/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/ScalableGatewayService.java
index d3d0f86..9611879 100644
--- a/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/ScalableGatewayService.java
+++ b/apps/scalablegateway/src/main/java/org/onosproject/scalablegateway/api/ScalableGatewayService.java
@@ -35,20 +35,21 @@
GatewayNode getGatewayNode(DeviceId deviceId);
/**
- * Returns the gateway`s port number with the given device identifier.
+ * Returns the uplink port number of the gateway with the supplied device ID.
*
- * @param deviceId The gateway node deviceId
- * @return The external interface port number
+ * @param deviceId the gateway node device id
+ * @return the external interface port number
*/
- PortNumber getGatewayExternalPort(DeviceId deviceId);
+ PortNumber getUplinkPort(DeviceId deviceId);
/**
* Returns group id for gateway load balance.
+ * If the group does not exist in the supplied source device, creates one.
*
* @param srcDeviceId source device id
* @return The group id
*/
- GroupId getGroupIdForGatewayLoadBalance(DeviceId srcDeviceId);
+ GroupId getGatewayGroupId(DeviceId srcDeviceId);
/**
* Returns the list of gateway node information with the given device identifier.