Add optional "name" parameter in interface configuration.
Interfaces can now be added and deleted by name. Interfaces without names
cannot be updated or deleted.
Change-Id: Icb2188b1c9abf3017724f751a93457920a53ba03
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java b/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
index b9d3ead..e210968 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
@@ -30,11 +30,13 @@
/**
* An Interface maps network configuration information (such as addresses and
- * vlans) to a port in the network. This is considered a L2/L3 network
- * interface.
+ * vlans) to a port in the network.
*/
@Beta
public class Interface {
+ public static final String NO_INTERFACE_NAME = "";
+
+ private final String name;
private final ConnectPoint connectPoint;
private final Set<InterfaceIpAddress> ipAddresses;
private final MacAddress macAddress;
@@ -43,6 +45,25 @@
/**
* Creates new Interface with the provided configuration.
*
+ * @param name name of the interface
+ * @param connectPoint the connect point this interface maps to
+ * @param ipAddresses Set of IP addresses
+ * @param macAddress MAC address
+ * @param vlan VLAN ID
+ */
+ public Interface(String name, ConnectPoint connectPoint,
+ Set<InterfaceIpAddress> ipAddresses,
+ MacAddress macAddress, VlanId vlan) {
+ this.name = name == null ? NO_INTERFACE_NAME : name;
+ this.connectPoint = checkNotNull(connectPoint);
+ this.ipAddresses = ipAddresses == null ? Sets.newHashSet() : ipAddresses;
+ this.macAddress = macAddress == null ? MacAddress.NONE : macAddress;
+ this.vlan = vlan == null ? VlanId.NONE : vlan;
+ }
+
+ /**
+ * Creates new Interface with the provided configuration.
+ *
* @param connectPoint the connect point this interface maps to
* @param ipAddresses Set of IP addresses
* @param macAddress MAC address
@@ -51,10 +72,16 @@
public Interface(ConnectPoint connectPoint,
Set<InterfaceIpAddress> ipAddresses,
MacAddress macAddress, VlanId vlan) {
- this.connectPoint = checkNotNull(connectPoint);
- this.ipAddresses = ipAddresses == null ? Sets.newHashSet() : ipAddresses;
- this.macAddress = macAddress == null ? MacAddress.NONE : macAddress;
- this.vlan = vlan == null ? VlanId.NONE : vlan;
+ this(NO_INTERFACE_NAME, connectPoint, ipAddresses, macAddress, vlan);
+ }
+
+ /**
+ * Retrieves the name of the interface.
+ *
+ * @return name
+ */
+ public String name() {
+ return name;
}
/**
@@ -101,7 +128,8 @@
Interface otherInterface = (Interface) other;
- return Objects.equals(connectPoint, otherInterface.connectPoint) &&
+ return Objects.equals(name, otherInterface.name) &&
+ Objects.equals(connectPoint, otherInterface.connectPoint) &&
Objects.equals(ipAddresses, otherInterface.ipAddresses) &&
Objects.equals(macAddress, otherInterface.macAddress) &&
Objects.equals(vlan, otherInterface.vlan);
@@ -109,12 +137,13 @@
@Override
public int hashCode() {
- return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
+ return Objects.hash(connectPoint, name, ipAddresses, macAddress, vlan);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
+ .add("name", name)
.add("connectPoint", connectPoint)
.add("ipAddresses", ipAddresses)
.add("macAddress", macAddress)
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java
index 56d5aec..32d480d 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceAdminService.java
@@ -16,13 +16,13 @@
package org.onosproject.incubator.net.intf;
-import org.onlab.packet.VlanId;
import org.onosproject.net.ConnectPoint;
/**
* Provides a means to modify the interfaces configuration.
*/
public interface InterfaceAdminService {
+
/**
* Adds a new interface configuration to the system.
*
@@ -34,7 +34,7 @@
* Removes an interface configuration from the system.
*
* @param connectPoint connect point of the interface
- * @param vlanId vlan id
+ * @param name name of the interface
*/
- void remove(ConnectPoint connectPoint, VlanId vlanId);
+ boolean remove(ConnectPoint connectPoint, String name);
}