Add unit test for simple fabric default classes
Change-Id: I47e88a5819833effe92b4e802a7ecaf001e6a6c2
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricNetwork.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricNetwork.java
new file mode 100644
index 0000000..386a345
--- /dev/null
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricNetwork.java
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.onlab.packet.VlanId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.Host;
+import org.onosproject.net.HostId;
+import org.onosproject.net.intf.Interface;
+import org.onosproject.simplefabric.api.FabricNetwork;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR;
+
+
+/**
+ * Class stores a DefaultFabricNetwork information.
+ */
+public final class DefaultFabricNetwork implements FabricNetwork {
+
+ private static final String NOT_NULL_MSG = "FabricNetwork % cannot be null";
+
+ private final String name;
+ private final Set<String> interfaceNames;
+ private final EncapsulationType encapsulation;
+ private boolean forward;
+ private boolean broadcast;
+
+ /* status variables */
+ private final Set<Interface> interfaces;
+ private final Set<HostId> hostIds;
+ private boolean dirty;
+
+ /**
+ * Constructs a DefaultFabricNetwork instance.
+ *
+ * @param name fabric name name
+ * @param interfaceNames a collection of interface names
+ * @param encapsulation encapsulation type
+ * @param forward flag for forward intents to be installed or not
+ * @param broadcast flag for broadcast intents to be installed or not
+ */
+ private DefaultFabricNetwork(String name, Collection<String> interfaceNames,
+ EncapsulationType encapsulation,
+ boolean forward, boolean broadcast) {
+ this.name = name;
+ this.interfaceNames = Sets.newHashSet();
+
+ if (interfaceNames != null) {
+ this.interfaceNames.addAll(interfaceNames);
+ }
+
+ this.encapsulation = encapsulation;
+ this.forward = (ALLOW_ETH_ADDRESS_SELECTOR) && forward;
+ this.broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) && broadcast;
+ this.interfaces = Sets.newHashSet();
+ this.hostIds = Sets.newHashSet();
+ this.dirty = false;
+ }
+
+ /**
+ * Constructs a DefaultFabricNetwork instance.
+ *
+ * @param name fabric network name
+ * @param encapsulation encapsulation type
+ */
+ private DefaultFabricNetwork(String name, EncapsulationType encapsulation) {
+ this.name = name;
+ this.interfaceNames = Sets.newHashSet();
+ this.encapsulation = encapsulation;
+ this.forward = ALLOW_ETH_ADDRESS_SELECTOR;
+ this.broadcast = ALLOW_ETH_ADDRESS_SELECTOR;
+ this.interfaces = Sets.newHashSet();
+ this.hostIds = Sets.newHashSet();
+ this.dirty = false;
+ }
+
+ /**
+ * Creates a DefaultFabricNetwork data by given name.
+ * The encapsulation type of the DefaultFabricNetwork will be NONE.
+ *
+ * @param name fabric network name
+ * @return DefaultFabricNetwork instance
+ */
+ public static FabricNetwork of(String name) {
+ Objects.requireNonNull(name);
+ return new DefaultFabricNetwork(name, EncapsulationType.NONE);
+ }
+
+ /**
+ * Creates a copy of DefaultFabricNetwork instance.
+ *
+ * @param fabricNetwork DefaultFabricNetwork instance
+ * @return the copy of the DefaultFabricNetwork instance
+ */
+ public static FabricNetwork of(FabricNetwork fabricNetwork) {
+ Objects.requireNonNull(fabricNetwork);
+ DefaultFabricNetwork fabricNetworkCopy =
+ new DefaultFabricNetwork(fabricNetwork.name(), fabricNetwork.encapsulation());
+ fabricNetworkCopy.interfaceNames.addAll(fabricNetwork.interfaceNames());
+ fabricNetworkCopy.forward = (ALLOW_ETH_ADDRESS_SELECTOR) && fabricNetwork.isForward();
+ fabricNetworkCopy.broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) && fabricNetwork.isBroadcast();
+ fabricNetworkCopy.interfaces.addAll(fabricNetwork.interfaces());
+ fabricNetworkCopy.hostIds.addAll(fabricNetwork.hostIds());
+ fabricNetworkCopy.setDirty(fabricNetwork.isDirty());
+ return fabricNetworkCopy;
+ }
+
+ // field queries
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public Set<String> interfaceNames() {
+ return ImmutableSet.copyOf(interfaceNames);
+ }
+
+ @Override
+ public EncapsulationType encapsulation() {
+ return encapsulation;
+ }
+
+ @Override
+ public boolean isForward() {
+ return forward;
+ }
+
+ @Override
+ public boolean isBroadcast() {
+ return broadcast;
+ }
+
+ @Override
+ public Set<Interface> interfaces() {
+ return ImmutableSet.copyOf(interfaces);
+ }
+
+ @Override
+ public Set<HostId> hostIds() {
+ return ImmutableSet.copyOf(hostIds);
+ }
+
+ @Override
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ @Override
+ public boolean contains(Interface iface) {
+ return interfaces.contains(iface);
+ }
+
+ @Override
+ public boolean contains(ConnectPoint port, VlanId vlanId) {
+ for (Interface iface : interfaces) {
+ if (iface.connectPoint().equals(port) && iface.vlan().equals(vlanId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean contains(DeviceId deviceId) {
+ for (Interface iface : interfaces) {
+ if (iface.connectPoint().deviceId().equals(deviceId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void addInterface(Interface iface) {
+ Objects.requireNonNull(iface);
+ if (interfaces.add(iface)) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void addHost(Host host) {
+ Objects.requireNonNull(host);
+ if (hostIds.add(host.id())) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean newDirty) {
+ dirty = newDirty;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("name", name)
+ .add("interfaceNames", interfaceNames)
+ .add("encapsulation", encapsulation)
+ .add("forward", forward)
+ .add("broadcast", broadcast)
+ .add("interfaces", interfaces)
+ .add("hostIds", hostIds)
+ .add("isDirty", dirty)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof DefaultFabricNetwork)) {
+ return false;
+ }
+ DefaultFabricNetwork other = (DefaultFabricNetwork) obj;
+ return Objects.equals(other.name, this.name)
+ && Objects.equals(other.interfaceNames, this.interfaceNames)
+ && Objects.equals(other.encapsulation, this.encapsulation)
+ && Objects.equals(other.forward, this.forward)
+ && Objects.equals(other.broadcast, this.broadcast)
+ && Objects.equals(other.interfaces, this.interfaces)
+ && Objects.equals(other.hostIds, this.hostIds);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, interfaces, encapsulation, forward, broadcast);
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return fabric network builder
+ */
+ public static DefaultFabricNetworkBuilder builder() {
+ return new DefaultFabricNetworkBuilder();
+ }
+
+ /**
+ * A builder class for fabric network.
+ */
+ public static final class DefaultFabricNetworkBuilder implements Builder {
+ private String name;
+ private Set<String> interfaceNames;
+ private EncapsulationType encapsulation;
+ private boolean forward;
+ private boolean broadcast;
+
+ private DefaultFabricNetworkBuilder() {
+ }
+
+ @Override
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @Override
+ public Builder interfaceNames(Set<String> interfaceNames) {
+ this.interfaceNames = interfaceNames;
+ return this;
+ }
+
+ @Override
+ public Builder encapsulation(EncapsulationType encapsulation) {
+ this.encapsulation = encapsulation;
+ return this;
+ }
+
+ @Override
+ public Builder forward(boolean forward) {
+ this.forward = forward;
+ return this;
+ }
+
+ @Override
+ public Builder broadcast(boolean broadcast) {
+ this.broadcast = broadcast;
+ return this;
+ }
+
+ @Override
+ public FabricNetwork build() {
+ checkArgument(name != null, NOT_NULL_MSG, "name");
+ return new DefaultFabricNetwork(name, interfaceNames,
+ encapsulation, forward, broadcast);
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricRoute.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricRoute.java
new file mode 100644
index 0000000..6b9a132
--- /dev/null
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricRoute.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.simplefabric.api.FabricRoute;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a route.
+ */
+public final class DefaultFabricRoute implements FabricRoute {
+
+ private static final String VERSION_MISMATCH =
+ "Prefix and next hop must be in the same address family";
+
+ private static final NodeId UNDEFINED = new NodeId("-");
+
+ private final Source source;
+ private final IpPrefix prefix;
+ private final IpAddress nextHop;
+ private final NodeId sourceNode;
+
+ /**
+ * Creates a route.
+ *
+ * @param source route source
+ * @param prefix IP prefix
+ * @param nextHop next hop IP address
+ */
+ private DefaultFabricRoute(Source source, IpPrefix prefix, IpAddress nextHop) {
+ this(source, prefix, nextHop, UNDEFINED);
+ }
+
+ /**
+ * Creates a route.
+ *
+ * @param source route source
+ * @param prefix IP prefix
+ * @param nextHop next hop IP address
+ * @param sourceNode ONOS node the route was sourced from
+ */
+ private DefaultFabricRoute(Source source, IpPrefix prefix,
+ IpAddress nextHop, NodeId sourceNode) {
+ this.source = checkNotNull(source);
+ this.prefix = prefix;
+ this.nextHop = nextHop;
+ this.sourceNode = checkNotNull(sourceNode);
+ }
+
+ @Override
+ public Source source() {
+ return source;
+ }
+
+ @Override
+ public IpPrefix prefix() {
+ return prefix;
+ }
+
+ @Override
+ public IpAddress nextHop() {
+ return nextHop;
+ }
+
+ @Override
+ public NodeId sourceNode() {
+ return sourceNode;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(prefix, nextHop);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof DefaultFabricRoute)) {
+ return false;
+ }
+
+ DefaultFabricRoute that = (DefaultFabricRoute) other;
+
+ return Objects.equals(this.prefix, that.prefix) &&
+ Objects.equals(this.nextHop, that.nextHop);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("prefix", prefix)
+ .add("nextHop", nextHop)
+ .toString();
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return fabric route builder
+ */
+ public static DefaultFabricRouteBuilder builder() {
+ return new DefaultFabricRouteBuilder();
+ }
+
+ /**
+ * A builder class for fabric route.
+ */
+ public static final class DefaultFabricRouteBuilder implements Builder {
+ private Source source;
+ private IpPrefix prefix;
+ private IpAddress nextHop;
+ private NodeId sourceNode;
+
+ private DefaultFabricRouteBuilder() {
+ }
+
+ @Override
+ public Builder source(Source source) {
+ this.source = source;
+ return this;
+ }
+
+ @Override
+ public Builder prefix(IpPrefix prefix) {
+ this.prefix = prefix;
+ return this;
+ }
+
+ @Override
+ public Builder nextHop(IpAddress nextHop) {
+ this.nextHop = nextHop;
+ return this;
+ }
+
+ @Override
+ public Builder sourceNode(NodeId sourceNode) {
+ this.sourceNode = sourceNode;
+ return this;
+ }
+
+ @Override
+ public FabricRoute build() {
+
+ checkNotNull(prefix);
+ checkNotNull(nextHop);
+ checkArgument(prefix.version().equals(nextHop.version()), VERSION_MISMATCH);
+
+ if (sourceNode != null) {
+ return new DefaultFabricRoute(source, prefix, nextHop, sourceNode);
+ } else {
+ return new DefaultFabricRoute(source, prefix, nextHop);
+ }
+ }
+ }
+}
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricSubnet.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricSubnet.java
new file mode 100644
index 0000000..b7fec47
--- /dev/null
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricSubnet.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.simplefabric.impl;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.simplefabric.api.FabricSubnet;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Configuration details for an ip subnet entry.
+ */
+public final class DefaultFabricSubnet implements FabricSubnet {
+
+ private static final String NOT_NULL_MSG = "FabricSubnet % cannot be null";
+
+ private final IpPrefix prefix;
+ private final IpAddress gatewayIp;
+ private final MacAddress gatewayMac;
+ private EncapsulationType encapsulation;
+ private final String networkName;
+
+ /**
+ * Creates a new subnet entry.
+ *
+ * @param prefix an ip subnet
+ * @param gatewayIp IP of the virtual gateway
+ * @param gatewayMac MacAddress of the virtual gateway
+ * @param encapsulation encapsulation type
+ * @param networkName network name
+ */
+ private DefaultFabricSubnet(IpPrefix prefix, IpAddress gatewayIp,
+ MacAddress gatewayMac, EncapsulationType encapsulation,
+ String networkName) {
+ this.prefix = prefix;
+ this.gatewayIp = gatewayIp;
+ this.gatewayMac = gatewayMac;
+ this.encapsulation = encapsulation;
+ this.networkName = networkName;
+ }
+
+ @Override
+ public IpPrefix prefix() {
+ return prefix;
+ }
+
+ @Override
+ public IpAddress gatewayIp() {
+ return gatewayIp;
+ }
+
+ @Override
+ public MacAddress gatewayMac() {
+ return gatewayMac;
+ }
+
+ @Override
+ public EncapsulationType encapsulation() {
+ return encapsulation;
+ }
+
+ @Override
+ public String networkName() {
+ return networkName;
+ }
+
+ @Override
+ public boolean isIp4() {
+ return prefix.isIp4();
+ }
+
+ @Override
+ public boolean isIp6() {
+ return prefix.isIp6();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(prefix, gatewayIp, gatewayMac, encapsulation, networkName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof DefaultFabricSubnet)) {
+ return false;
+ }
+ DefaultFabricSubnet that = (DefaultFabricSubnet) obj;
+ return Objects.equals(this.prefix, that.prefix)
+ && Objects.equals(this.gatewayIp, that.gatewayIp)
+ && Objects.equals(this.gatewayMac, that.gatewayMac)
+ && Objects.equals(this.encapsulation, that.encapsulation)
+ && Objects.equals(this.networkName, that.networkName);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("prefix", prefix)
+ .add("gatewayIp", gatewayIp)
+ .add("gatewayMac", gatewayMac)
+ .add("encapsulation", encapsulation)
+ .add("networkName", networkName)
+ .toString();
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return fabric IP subnet builder
+ */
+ public static DefaultSubnetBuilder builder() {
+ return new DefaultSubnetBuilder();
+ }
+
+ /**
+ * A builder class for Ip Subnet.
+ */
+ public static final class DefaultSubnetBuilder implements Builder {
+ private IpPrefix prefix;
+ private IpAddress gatewayIp;
+ private MacAddress gatewayMac;
+ private EncapsulationType encapsulation;
+ private String networkName;
+
+ private DefaultSubnetBuilder() {
+ }
+
+ @Override
+ public Builder prefix(IpPrefix prefix) {
+ this.prefix = prefix;
+ return this;
+ }
+
+ @Override
+ public Builder gatewayIp(IpAddress gatewayIp) {
+ this.gatewayIp = gatewayIp;
+ return this;
+ }
+
+ @Override
+ public Builder gatewayMac(MacAddress gatewayMac) {
+ this.gatewayMac = gatewayMac;
+ return this;
+ }
+
+ @Override
+ public Builder encapsulation(EncapsulationType encapsulation) {
+ this.encapsulation = encapsulation;
+ return this;
+ }
+
+ @Override
+ public Builder networkName(String networkName) {
+ this.networkName = networkName;
+ return this;
+ }
+
+ @Override
+ public FabricSubnet build() {
+ checkArgument(prefix != null, NOT_NULL_MSG, "prefix");
+ checkArgument(gatewayIp != null, NOT_NULL_MSG, "gatewayIp");
+ checkArgument(gatewayMac != null, NOT_NULL_MSG, "gatewayMac");
+ checkArgument(networkName != null, NOT_NULL_MSG, "name");
+
+ if (this.encapsulation == null) {
+ encapsulation = EncapsulationType.NONE;
+ }
+
+ return new DefaultFabricSubnet(prefix, gatewayIp, gatewayMac,
+ encapsulation, networkName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
index 53c33a4..1d4b97c 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
@@ -24,12 +24,9 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.EncapsulationType;
import org.onosproject.net.config.Config;
-import org.onosproject.simplefabric.api.DefaultFabricRoute;
-import org.onosproject.simplefabric.api.DefaultFabricSubnet;
-import org.onosproject.simplefabric.api.DefaultFabricNetwork;
+import org.onosproject.simplefabric.api.FabricNetwork;
import org.onosproject.simplefabric.api.FabricRoute;
import org.onosproject.simplefabric.api.FabricSubnet;
-import org.onosproject.simplefabric.api.FabricNetwork;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -128,11 +125,11 @@
}
try {
subnets.add(DefaultFabricSubnet.builder()
- .ipPrefix(IpPrefix.valueOf(jsonNode.get(PREFIX).asText()))
+ .prefix(IpPrefix.valueOf(jsonNode.get(PREFIX).asText()))
.gatewayIp(IpAddress.valueOf(jsonNode.get(GATEWAY_IP).asText()))
.gatewayMac(MacAddress.valueOf(jsonNode.get(GATEWAY_MAC).asText()))
.encapsulation(EncapsulationType.enumFromString(encapsulation))
- .name(jsonNode.get(NETWORK_NAME).asText())
+ .networkName(jsonNode.get(NETWORK_NAME).asText())
.build());
} catch (Exception e) {
log.warn("Fabric subnet parse failed; skip: jsonNode={}", jsonNode);
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
index de87ba1..1bdcacd 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
@@ -64,7 +64,6 @@
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.OutboundPacket;
import org.onosproject.net.packet.PacketService;
-import org.onosproject.simplefabric.api.DefaultFabricNetwork;
import org.onosproject.simplefabric.api.FabricNetwork;
import org.onosproject.simplefabric.api.FabricRoute;
import org.onosproject.simplefabric.api.FabricSubnet;
@@ -450,10 +449,10 @@
log.warn("simple fabric request mac failed for unknown fabricSubnet: {}", ip);
return false;
}
- FabricNetwork fabricNetwork = fabricNetwork(fabricSubnet.name());
+ FabricNetwork fabricNetwork = fabricNetwork(fabricSubnet.networkName());
if (fabricNetwork == null) {
log.warn("simple fabric request mac failed for unknown fabricNetwork name {}: {}",
- fabricSubnet.name(), ip);
+ fabricSubnet.networkName(), ip);
return false;
}
log.debug("simple fabric send request mac fabricNetwork {}: {}", fabricNetwork.name(), ip);
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
index 7a03b9d..9eefc03 100644
--- a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
@@ -245,7 +245,7 @@
for (FabricSubnet subnet : simpleFabric.defaultFabricSubnets()) {
newInterceptFlowRules.add(generateInterceptFlowRule(true, device.id(), subnet.prefix()));
// check if this devices has the fabricSubnet, then add ip broadcast flue rule
- FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(subnet.name());
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(subnet.networkName());
if (fabricNetwork != null && fabricNetwork.contains(device.id())) {
newInterceptFlowRules.add(generateLocalSubnetIpBctFlowRule(device.id(), subnet.prefix(),
fabricNetwork));
@@ -673,7 +673,7 @@
// destination is local subnet ip
if (ALLOW_ETH_ADDRESS_SELECTOR && dstSubnet.equals(srcSubnet)) {
// NOTE: if ALLOW_ETH_ADDRESS_SELECTOR=false; isForward is always false
- FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(dstSubnet.name());
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(dstSubnet.networkName());
treatmentSrcMac = ethPkt.getSourceMAC();
if (fabricNetwork != null && fabricNetwork.isForward()) {
// NOTE: no reactive route action but do forward packet for L2Forward do not handle packet