aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/incubator/api/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/incubator/api/src/main/java')
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java15
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java9
2 files changed, 12 insertions, 12 deletions
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java
index 592336c2..9f2d4105 100644
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/config/basics/InterfaceConfig.java
@@ -39,7 +39,6 @@ public class InterfaceConfig extends Config<ConnectPoint> {
public static final String MAC = "mac";
public static final String VLAN = "vlan";
- public static final String MAC_MISSING_ERROR = "Must have a MAC address for each interface";
public static final String CONFIG_VALUE_ERROR = "Error parsing config value";
/**
@@ -55,15 +54,12 @@ public class InterfaceConfig extends Config<ConnectPoint> {
for (JsonNode intfNode : array) {
Set<InterfaceIpAddress> ips = getIps(intfNode);
- if (intfNode.path(MAC).isMissingNode()) {
- throw new ConfigException(MAC_MISSING_ERROR);
- }
-
- MacAddress mac = MacAddress.valueOf(intfNode.path(MAC).asText());
+ String mac = intfNode.path(MAC).asText();
+ MacAddress macAddr = mac.isEmpty() ? null : MacAddress.valueOf(mac);
VlanId vlan = getVlan(intfNode);
- interfaces.add(new Interface(subject, ips, mac, vlan));
+ interfaces.add(new Interface(subject, ips, macAddr, vlan));
}
} catch (IllegalArgumentException e) {
throw new ConfigException(CONFIG_VALUE_ERROR, e);
@@ -79,7 +75,10 @@ public class InterfaceConfig extends Config<ConnectPoint> {
*/
public void addInterface(Interface intf) {
ObjectNode intfNode = array.addObject();
- intfNode.put(MAC, intf.mac().toString());
+
+ if (intf.mac() != null) {
+ intfNode.put(MAC, intf.mac().toString());
+ }
if (!intf.ipAddresses().isEmpty()) {
intfNode.set(IPS, putIps(intf.ipAddresses()));
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
index 69d14bce..b9d3eadf 100644
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
@@ -30,7 +30,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* An Interface maps network configuration information (such as addresses and
- * vlans) to a port in the network.
+ * vlans) to a port in the network. This is considered a L2/L3 network
+ * interface.
*/
@Beta
public class Interface {
@@ -51,9 +52,9 @@ public class Interface {
Set<InterfaceIpAddress> ipAddresses,
MacAddress macAddress, VlanId vlan) {
this.connectPoint = checkNotNull(connectPoint);
- this.ipAddresses = Sets.newHashSet(checkNotNull(ipAddresses));
- this.macAddress = checkNotNull(macAddress);
- this.vlan = checkNotNull(vlan);
+ this.ipAddresses = ipAddresses == null ? Sets.newHashSet() : ipAddresses;
+ this.macAddress = macAddress == null ? MacAddress.NONE : macAddress;
+ this.vlan = vlan == null ? VlanId.NONE : vlan;
}
/**