[ONOS-7444] Optimize SONA gw doesn't use vrouter app and quagga anymore
Change-Id: I70fd7a9dbe219a9ea6081d0f19bf051a1bee090a
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
index 06e592c..8bf4ceb 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/Constants.java
@@ -28,4 +28,11 @@
public static final String DEFAULT_TUNNEL = "vxlan";
public static final String PATCH_INTG_BRIDGE = "patch-intg";
public static final String PATCH_ROUT_BRIDGE = "patch-rout";
+ public static final String GATEWAY = "GATEWAY";
+ public static final String HOST_NAME = "hostname";
+ public static final String TYPE = "type";
+ public static final String MANAGEMENT_IP = "managementIp";
+ public static final String DATA_IP = "dataIp";
+ public static final String VLAN_INTF_NAME = "vlanPort";
+ public static final String UPLINK_PORT = "uplinkPort";
}
\ No newline at end of file
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java
index f65901c..f34bdb7 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NodeState.java
@@ -45,20 +45,6 @@
@Override
public NodeState nextState() {
- return PORT_CREATED;
- }
- },
- /**
- * Indicates required ports are added.
- */
- PORT_CREATED {
- @Override
- public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
- handler.processPortCreatedState(osNode);
- }
-
- @Override
- public NodeState nextState() {
return COMPLETE;
}
},
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
index ca03b86..f1e2bc5 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
@@ -72,13 +72,6 @@
DeviceId intgBridge();
/**
- * Returns the router bridge device ID.
- *
- * @return device id; null if the node type is compute
- */
- DeviceId routerBridge();
-
- /**
* Returns the management network IP address of the node.
*
* @return ip address
@@ -151,6 +144,13 @@
MacAddress vlanPortMac();
/**
+ * Returns the uplink port name.
+ *
+ * @return uplink port name; null if the node type is compute
+ */
+ String uplinkPort();
+
+ /**
* Returns new openstack node instance with given state.
*
* @param newState updated state
@@ -195,14 +195,6 @@
Builder intgBridge(DeviceId intgBridge);
/**
- * Returns openstack node builder with supplied router bridge ID.
- *
- * @param routerBridge router bridge id
- * @return openstack node builder
- */
- Builder routerBridge(DeviceId routerBridge);
-
- /**
* Returns openstack node builder with supplied management IP address.
*
* @param managementIp management ip address
@@ -227,6 +219,14 @@
Builder vlanIntf(String vlanIntf);
/**
+ * Returns openstack node builder with supplied uplink port.
+ *
+ * @param uplinkPort uplink port name
+ * @return openstack node builder
+ */
+ Builder uplinkPort(String uplinkPort);
+
+ /**
* Returns openstack node builder with supplied node state.
*
* @param state node state
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
index 0264d17..a421410 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNodeHandler.java
@@ -37,14 +37,6 @@
void processDeviceCreatedState(OpenstackNode osNode);
/**
- * Processes the given node for port created state.
- * It creates gateway groups on compute node.
- *
- * @param osNode openstack node
- */
- void processPortCreatedState(OpenstackNode osNode);
-
- /**
* Processes the given node for complete state.
* It performs post-init jobs for the complete node.
*
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java
index 75d09cf..3ad60ef 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeCheckCommand.java
@@ -23,17 +23,11 @@
import org.onosproject.net.Port;
import org.onosproject.net.Device;
import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.group.Group;
-import org.onosproject.net.group.GroupBucket;
-import org.onosproject.net.group.GroupService;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackNodeService;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
import static org.onosproject.openstacknode.api.Constants.*;
-import static org.onosproject.openstacknode.api.OpenstackNode.NetworkMode.VLAN;
-import static org.onosproject.openstacknode.api.OpenstackNode.NetworkMode.VXLAN;
-import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
/**
* Checks detailed node init state.
@@ -48,14 +42,11 @@
private static final String MSG_OK = "OK";
private static final String MSG_NO = "NO";
- private static final String BUCKET_FORMAT =
- " bucket=%s, bytes=%s, packets=%s, actions=%s";
@Override
protected void execute() {
OpenstackNodeService osNodeService = AbstractShellCommand.get(OpenstackNodeService.class);
DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
- GroupService groupService = AbstractShellCommand.get(GroupService.class);
OpenstackNode osNode = osNodeService.node(hostname);
if (osNode == null) {
@@ -78,7 +69,9 @@
if (osNode.vlanIntf() != null) {
printPortState(deviceService, osNode.intgBridge(), osNode.vlanIntf());
}
- printGatewayGroupState(osNodeService, groupService, osNode);
+ if (osNode.type() == OpenstackNode.NodeType.GATEWAY) {
+ printPortState(deviceService, osNode.intgBridge(), osNode.uplinkPort());
+ }
} else {
print("%s %s=%s is not available",
MSG_NO,
@@ -104,43 +97,4 @@
print("%s %s does not exist", MSG_NO, portName);
}
}
-
- private void printGatewayGroupState(OpenstackNodeService osNodeService,
- GroupService groupService, OpenstackNode osNode) {
- if (osNode.type() == GATEWAY) {
- return;
- }
- if (osNodeService.completeNodes(GATEWAY).isEmpty()) {
- print("N/A No complete state gateway nodes exist");
- return;
- }
- if (osNode.dataIp() != null) {
- Group osGroup = groupService.getGroup(osNode.intgBridge(),
- osNode.gatewayGroupKey(VXLAN));
- if (osGroup == null || osGroup.state() != Group.GroupState.ADDED) {
- print("%s VXLAN gateway group does not exist", MSG_NO);
- } else {
- print("%s VXLAN group 0x%s added", MSG_OK, Integer.toHexString(osGroup.id().id()));
- int i = 0;
- for (GroupBucket bucket : osGroup.buckets().buckets()) {
- print(BUCKET_FORMAT, ++i, bucket.bytes(), bucket.packets(),
- bucket.treatment().allInstructions());
- }
- }
- }
- if (osNode.vlanIntf() != null) {
- Group osGroup = groupService.getGroup(osNode.intgBridge(),
- osNode.gatewayGroupKey(VLAN));
- if (osGroup == null || osGroup.state() != Group.GroupState.ADDED) {
- print("\n%s VLAN gateway group does not exist", MSG_NO);
- } else {
- print("\n%s VLAN group 0x%s added", MSG_OK, Integer.toHexString(osGroup.id().id()));
- int i = 0;
- for (GroupBucket bucket : osGroup.buckets().buckets()) {
- print(BUCKET_FORMAT, ++i, bucket.bytes(), bucket.packets(),
- bucket.treatment().allInstructions());
- }
- }
- }
- }
}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java
index f7207df..4d5d900 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/cli/OpenstackNodeListCommand.java
@@ -46,17 +46,17 @@
if (outputJson()) {
print("%s", json(osNodes));
} else {
- print(FORMAT, "Hostname", "Type", "Integration Bridge", "Router Bridge",
- "Management IP", "Data IP", "VLAN Intf", "State");
+ print(FORMAT, "Hostname", "Type", "Integration Bridge",
+ "Management IP", "Data IP", "VLAN Intf", "Uplink Port", "State");
for (OpenstackNode osNode : osNodes) {
print(FORMAT,
osNode.hostname(),
osNode.type(),
osNode.intgBridge(),
- osNode.routerBridge() != null ? osNode.routerBridge() : "",
osNode.managementIp(),
osNode.dataIp() != null ? osNode.dataIp() : "",
osNode.vlanIntf() != null ? osNode.vlanIntf() : "",
+ osNode.uplinkPort() != null ? osNode.uplinkPort() : "",
osNode.state());
}
print("Total %s nodes", osNodeService.nodes().size());
@@ -71,12 +71,12 @@
.put("hostname", osNode.hostname())
.put("type", osNode.type().name())
.put("integrationBridge", osNode.intgBridge().toString())
- .put("routerBridge", osNode.routerBridge().toString())
.put("managementIp", osNode.managementIp().toString())
.put("dataIp", osNode.dataIp().toString())
.put("vlanIntf", osNode.vlanIntf())
.put("tunnelPortNum", osNode.tunnelPortNum().toString())
.put("vlanPortNum", osNode.vlanPortNum().toString())
+ .put("uplinkPort", osNode.uplinkPort())
.put("state", osNode.state().name()));
}
return result;
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java
index f02684a..6650be6 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNode.java
@@ -46,27 +46,28 @@
private final String hostname;
private final NodeType type;
private final DeviceId intgBridge;
- private final DeviceId routerBridge;
private final IpAddress managementIp;
private final IpAddress dataIp;
private final String vlanIntf;
+ private final String uplinkPort;
private final NodeState state;
- protected DefaultOpenstackNode(String hostname,
- NodeType type,
- DeviceId intgBridge,
- DeviceId routerBridge,
- IpAddress managementIp,
- IpAddress dataIp,
- String vlanIntf,
- NodeState state) {
+ private static final String OVSDB = "ovsdb:";
+
+ protected DefaultOpenstackNode(String hostname, NodeType type,
+ DeviceId intgBridge,
+ IpAddress managementIp,
+ IpAddress dataIp,
+ String vlanIntf,
+ String uplinkPort,
+ NodeState state) {
this.hostname = hostname;
this.type = type;
this.intgBridge = intgBridge;
- this.routerBridge = routerBridge;
this.managementIp = managementIp;
this.dataIp = dataIp;
this.vlanIntf = vlanIntf;
+ this.uplinkPort = uplinkPort;
this.state = state;
}
@@ -82,7 +83,7 @@
@Override
public DeviceId ovsdb() {
- return DeviceId.deviceId("ovsdb:" + managementIp().toString());
+ return DeviceId.deviceId(OVSDB + managementIp().toString());
}
@Override
@@ -91,11 +92,6 @@
}
@Override
- public DeviceId routerBridge() {
- return routerBridge;
- }
-
- @Override
public IpAddress managementIp() {
return managementIp;
}
@@ -111,6 +107,11 @@
}
@Override
+ public String uplinkPort() {
+ return uplinkPort;
+ }
+
+ @Override
public NodeState state() {
return state;
}
@@ -187,9 +188,9 @@
if (Objects.equals(hostname, that.hostname) &&
Objects.equals(type, that.type) &&
Objects.equals(intgBridge, that.intgBridge) &&
- Objects.equals(routerBridge, that.routerBridge) &&
Objects.equals(managementIp, that.managementIp) &&
Objects.equals(dataIp, that.dataIp) &&
+ Objects.equals(uplinkPort, that.uplinkPort) &&
Objects.equals(vlanIntf, that.vlanIntf)) {
return true;
}
@@ -202,10 +203,10 @@
return Objects.hash(hostname,
type,
intgBridge,
- routerBridge,
managementIp,
dataIp,
- vlanIntf);
+ vlanIntf,
+ uplinkPort);
}
@Override
@@ -214,10 +215,10 @@
.add("hostname", hostname)
.add("type", type)
.add("integrationBridge", intgBridge)
- .add("routerBridge", routerBridge)
.add("managementIp", managementIp)
.add("dataIp", dataIp)
.add("vlanIntf", vlanIntf)
+ .add("uplinkPort", uplinkPort)
.add("state", state)
.toString();
}
@@ -228,10 +229,10 @@
.type(type)
.hostname(hostname)
.intgBridge(intgBridge)
- .routerBridge(routerBridge)
.managementIp(managementIp)
.dataIp(dataIp)
.vlanIntf(vlanIntf)
+ .uplinkPort(uplinkPort)
.state(newState)
.build();
}
@@ -256,10 +257,10 @@
.hostname(osNode.hostname())
.type(osNode.type())
.intgBridge(osNode.intgBridge())
- .routerBridge(osNode.routerBridge())
.managementIp(osNode.managementIp())
.dataIp(osNode.dataIp())
.vlanIntf(osNode.vlanIntf())
+ .uplinkPort(osNode.uplinkPort())
.state(osNode.state());
}
@@ -268,10 +269,10 @@
private String hostname;
private NodeType type;
private DeviceId intgBridge;
- private DeviceId routerBridge;
private IpAddress managementIp;
private IpAddress dataIp;
private String vlanIntf;
+ private String uplinkPort;
private NodeState state;
private Builder() {
@@ -285,8 +286,8 @@
checkArgument(managementIp != null, "Node management IP cannot be null");
checkArgument(state != null, "Node state cannot be null");
- if (type == NodeType.GATEWAY && routerBridge == null) {
- throw new IllegalArgumentException("Router bridge is required for gateway node");
+ if (type == NodeType.GATEWAY && uplinkPort == null) {
+ throw new IllegalArgumentException("Uplink port is required for gateway node");
}
if (dataIp == null && Strings.isNullOrEmpty(vlanIntf)) {
throw new IllegalArgumentException("Either data IP or VLAN interface is required");
@@ -295,10 +296,10 @@
return new DefaultOpenstackNode(hostname,
type,
intgBridge,
- routerBridge,
managementIp,
dataIp,
vlanIntf,
+ uplinkPort,
state);
}
@@ -323,12 +324,6 @@
}
@Override
- public Builder routerBridge(DeviceId routerBridge) {
- this.routerBridge = routerBridge;
- return this;
- }
-
- @Override
public Builder managementIp(IpAddress managementIp) {
this.managementIp = managementIp;
return this;
@@ -347,6 +342,12 @@
}
@Override
+ public Builder uplinkPort(String uplinkPort) {
+ this.uplinkPort = uplinkPort;
+ return this;
+ }
+
+ @Override
public Builder state(NodeState state) {
this.state = state;
return this;
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
index 625d41d..7b8cda1 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
@@ -15,9 +15,6 @@
*/
package org.onosproject.openstacknode.impl;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -42,11 +39,9 @@
import org.onosproject.net.behaviour.BridgeName;
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.net.behaviour.DefaultBridgeDescription;
-import org.onosproject.net.behaviour.DefaultPatchDescription;
import org.onosproject.net.behaviour.DefaultTunnelDescription;
import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
import org.onosproject.net.behaviour.InterfaceConfig;
-import org.onosproject.net.behaviour.PatchDescription;
import org.onosproject.net.behaviour.TunnelDescription;
import org.onosproject.net.behaviour.TunnelEndPoints;
import org.onosproject.net.behaviour.TunnelKeys;
@@ -54,21 +49,11 @@
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.instructions.ExtensionPropertyException;
import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.group.DefaultGroupDescription;
-import org.onosproject.net.group.Group;
-import org.onosproject.net.group.GroupBucket;
-import org.onosproject.net.group.GroupBuckets;
-import org.onosproject.net.group.GroupDescription;
-import org.onosproject.net.group.GroupEvent;
-import org.onosproject.net.group.GroupListener;
-import org.onosproject.net.group.GroupService;
+
import org.onosproject.openstacknode.api.NodeState;
import org.onosproject.openstacknode.api.OpenstackNode;
-import org.onosproject.openstacknode.api.OpenstackNode.NetworkMode;
import org.onosproject.openstacknode.api.OpenstackNodeAdminService;
import org.onosproject.openstacknode.api.OpenstackNodeEvent;
import org.onosproject.openstacknode.api.OpenstackNodeHandler;
@@ -87,19 +72,13 @@
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
-import static com.google.common.base.Preconditions.checkArgument;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.onlab.packet.TpPort.tpPort;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST;
-import static org.onosproject.net.group.DefaultGroupBucket.createSelectGroupBucket;
import static org.onosproject.openstacknode.api.Constants.*;
-import static org.onosproject.openstacknode.api.Constants.PATCH_INTG_BRIDGE;
import static org.onosproject.openstacknode.api.NodeState.*;
-import static org.onosproject.openstacknode.api.OpenstackNode.NetworkMode.VLAN;
-import static org.onosproject.openstacknode.api.OpenstackNode.NetworkMode.VXLAN;
-import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
import static org.onosproject.openstacknode.api.OpenstackNodeService.APP_ID;
import static org.slf4j.LoggerFactory.getLogger;
@@ -137,9 +116,6 @@
protected OvsdbController ovsdbController;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected GroupService groupService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected OpenstackNodeService osNodeService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -157,7 +133,6 @@
private final DeviceListener ovsdbListener = new InternalOvsdbListener();
private final DeviceListener bridgeListener = new InternalBridgeListener();
- private final GroupListener groupListener = new InternalGroupListener();
private final OpenstackNodeListener osNodeListener = new InternalOpenstackNodeListener();
private ApplicationId appId;
@@ -170,7 +145,6 @@
componentConfigService.registerProperties(getClass());
leadershipService.runForLeadership(appId.name());
- groupService.addListener(groupListener);
deviceService.addListener(ovsdbListener);
deviceService.addListener(bridgeListener);
osNodeService.addListener(osNodeListener);
@@ -183,7 +157,6 @@
osNodeService.removeListener(osNodeListener);
deviceService.removeListener(bridgeListener);
deviceService.removeListener(ovsdbListener);
- groupService.removeListener(groupListener);
componentConfigService.unregisterProperties(getClass(), false);
leadershipService.withdraw(appId.name());
eventExecutor.shutdown();
@@ -211,64 +184,31 @@
if (!deviceService.isAvailable(osNode.intgBridge())) {
createBridge(osNode, INTEGRATION_BRIDGE, osNode.intgBridge());
}
- if (osNode.type() == GATEWAY &&
- !isBridgeCreated(osNode.ovsdb(), ROUTER_BRIDGE)) {
- createBridge(osNode, ROUTER_BRIDGE, osNode.routerBridge());
- }
}
@Override
public void processDeviceCreatedState(OpenstackNode osNode) {
- if (!isOvsdbConnected(osNode)) {
- ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPort));
- return;
- }
- if (osNode.type() == GATEWAY && (
- !isIntfEnabled(osNode, PATCH_INTG_BRIDGE) ||
- !isIntfCreated(osNode, PATCH_ROUT_BRIDGE)
- )) {
- createPatchInterface(osNode);
- }
- if (osNode.dataIp() != null &&
- !isIntfEnabled(osNode, DEFAULT_TUNNEL)) {
- createTunnelInterface(osNode);
- }
- if (osNode.vlanIntf() != null &&
- !isIntfEnabled(osNode, osNode.vlanIntf())) {
- addSystemInterface(osNode, INTEGRATION_BRIDGE, osNode.vlanIntf());
- }
- }
+ try {
+ if (!isOvsdbConnected(osNode)) {
+ ovsdbController.connect(osNode.managementIp(), tpPort(ovsdbPort));
+ return;
+ }
- @Override
- public void processPortCreatedState(OpenstackNode osNode) {
- switch (osNode.type()) {
- case COMPUTE:
- if (osNode.dataIp() != null) {
- addOrUpdateGatewayGroup(osNode,
- osNodeService.completeNodes(GATEWAY),
- VXLAN);
- }
- if (osNode.vlanIntf() != null) {
- addOrUpdateGatewayGroup(osNode,
- osNodeService.completeNodes(GATEWAY),
- VLAN);
- }
- break;
- case GATEWAY:
- Set<OpenstackNode> gateways =
- Sets.newHashSet(osNodeService.completeNodes(GATEWAY));
- gateways.add(osNode);
- osNodeService.completeNodes(COMPUTE).forEach(n -> {
- if (n.dataIp() != null) {
- addOrUpdateGatewayGroup(n, gateways, VXLAN);
- }
- if (n.vlanIntf() != null) {
- addOrUpdateGatewayGroup(n, gateways, VLAN);
- }
- });
- break;
- default:
- break;
+ if (osNode.type() == GATEWAY) {
+ addSystemInterface(osNode, INTEGRATION_BRIDGE, osNode.uplinkPort());
+ }
+
+ if (osNode.dataIp() != null &&
+ !isIntfEnabled(osNode, DEFAULT_TUNNEL)) {
+ createTunnelInterface(osNode);
+ }
+
+ if (osNode.vlanIntf() != null &&
+ !isIntfEnabled(osNode, osNode.vlanIntf())) {
+ addSystemInterface(osNode, INTEGRATION_BRIDGE, osNode.vlanIntf());
+ }
+ } catch (Exception e) {
+ log.error("Exception occured because of {}", e.toString());
}
}
@@ -283,28 +223,7 @@
@Override
public void processIncompleteState(OpenstackNode osNode) {
- if (osNode.type() == COMPUTE) {
- if (osNode.dataIp() != null) {
- groupService.removeGroup(osNode.intgBridge(), osNode.gatewayGroupKey(VXLAN), appId);
- }
- if (osNode.vlanIntf() != null) {
- groupService.removeGroup(osNode.intgBridge(), osNode.gatewayGroupKey(VLAN), appId);
- }
- }
- if (osNode.type() == GATEWAY) {
- osNodeService.completeNodes(COMPUTE).forEach(n -> {
- if (n.dataIp() != null) {
- addOrUpdateGatewayGroup(n,
- osNodeService.completeNodes(GATEWAY),
- VXLAN);
- }
- if (n.vlanIntf() != null) {
- addOrUpdateGatewayGroup(n,
- osNodeService.completeNodes(GATEWAY),
- VLAN);
- }
- });
- }
+ //TODO
}
private boolean isOvsdbConnected(OpenstackNode osNode) {
@@ -322,22 +241,16 @@
return;
}
- // TODO fix this when we use single ONOS cluster for both openstackNode and vRouter
- Set<IpAddress> controllerIps;
- if (bridgeName.equals(ROUTER_BRIDGE)) {
- // TODO checks if empty controller does not break anything
- controllerIps = ImmutableSet.of();
- } else {
- controllerIps = clusterService.getNodes().stream()
+ Set<IpAddress> controllerIps = clusterService.getNodes().stream()
.map(ControllerNode::ip)
.collect(Collectors.toSet());
- }
List<ControllerInfo> controllers = controllerIps.stream()
.map(ip -> new ControllerInfo(ip, DEFAULT_OFPORT, DEFAULT_OF_PROTO))
.collect(Collectors.toList());
String dpid = deviceId.toString().substring(DPID_BEGIN);
+
BridgeDescription bridgeDesc = DefaultBridgeDescription.builder()
.name(bridgeName)
.failMode(BridgeDescription.FailMode.SECURE)
@@ -382,91 +295,6 @@
ifaceConfig.addTunnelMode(DEFAULT_TUNNEL, tunnelDesc);
}
- private void createPatchInterface(OpenstackNode osNode) {
- checkArgument(osNode.type().equals(OpenstackNode.NodeType.GATEWAY));
- if (isIntfEnabled(osNode, PATCH_INTG_BRIDGE) &&
- isIntfCreated(osNode, PATCH_ROUT_BRIDGE)) {
- return;
- }
-
- Device device = deviceService.getDevice(osNode.ovsdb());
- if (device == null || !device.is(InterfaceConfig.class)) {
- log.error("Failed to create patch interfaces on {}", osNode.hostname());
- return;
- }
-
- PatchDescription patchIntg = DefaultPatchDescription.builder()
- .deviceId(INTEGRATION_BRIDGE)
- .ifaceName(PATCH_INTG_BRIDGE)
- .peer(PATCH_ROUT_BRIDGE)
- .build();
-
- PatchDescription patchRout = DefaultPatchDescription.builder()
- .deviceId(ROUTER_BRIDGE)
- .ifaceName(PATCH_ROUT_BRIDGE)
- .peer(PATCH_INTG_BRIDGE)
- .build();
-
- InterfaceConfig ifaceConfig = device.as(InterfaceConfig.class);
- ifaceConfig.addPatchMode(PATCH_INTG_BRIDGE, patchIntg);
- ifaceConfig.addPatchMode(PATCH_ROUT_BRIDGE, patchRout);
- }
-
- private void addOrUpdateGatewayGroup(OpenstackNode osNode,
- Set<OpenstackNode> gatewayNodes,
- NetworkMode mode) {
- GroupBuckets buckets = gatewayGroupBuckets(osNode, gatewayNodes, mode);
- if (groupService.getGroup(osNode.intgBridge(), osNode.gatewayGroupKey(mode)) == null) {
- GroupDescription groupDescription = new DefaultGroupDescription(
- osNode.intgBridge(),
- GroupDescription.Type.SELECT,
- buckets,
- osNode.gatewayGroupKey(mode),
- osNode.gatewayGroupId(mode).id(),
- appId);
- groupService.addGroup(groupDescription);
- log.debug("Created gateway group for {}", osNode.hostname());
- } else {
- groupService.setBucketsForGroup(
- osNode.intgBridge(),
- osNode.gatewayGroupKey(mode),
- buckets,
- osNode.gatewayGroupKey(mode),
- appId);
- log.debug("Updated gateway group for {}", osNode.hostname());
- }
- }
-
- private GroupBuckets gatewayGroupBuckets(OpenstackNode osNode,
- Set<OpenstackNode> gatewayNodes,
- NetworkMode mode) {
- List<GroupBucket> bucketList = Lists.newArrayList();
- switch (mode) {
- case VXLAN:
- gatewayNodes.stream().filter(n -> n.dataIp() != null).forEach(n -> {
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .extension(tunnelDstTreatment(osNode.intgBridge(),
- n.dataIp()),
- osNode.intgBridge())
- .setOutput(osNode.tunnelPortNum())
- .build();
- bucketList.add(createSelectGroupBucket(treatment));
- });
- return new GroupBuckets(bucketList);
- case VLAN:
- gatewayNodes.stream().filter(n -> n.vlanIntf() != null).forEach(n -> {
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setEthDst(n.vlanPortMac())
- .setOutput(osNode.vlanPortNum())
- .build();
- bucketList.add(createSelectGroupBucket(treatment));
- });
- return new GroupBuckets(bucketList);
- default:
- return null;
- }
- }
-
private ExtensionTreatment tunnelDstTreatment(DeviceId deviceId, IpAddress remoteIp) {
Device device = deviceService.getDevice(deviceId);
if (device != null && !device.is(ExtensionTreatmentResolver.class)) {
@@ -489,17 +317,6 @@
}
}
- private boolean isBridgeCreated(DeviceId ovsdbId, String bridgeName) {
- Device device = deviceService.getDevice(ovsdbId);
- if (device == null || !deviceService.isAvailable(device.id()) ||
- !device.is(BridgeConfig.class)) {
- return false;
- }
- BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
- return bridgeConfig.getBridges().stream()
- .anyMatch(bridge -> bridge.name().equals(bridgeName));
- }
-
private boolean isIntfEnabled(OpenstackNode osNode, String intf) {
if (!deviceService.isAvailable(osNode.intgBridge())) {
return false;
@@ -510,67 +327,12 @@
port.isEnabled());
}
- private boolean isIntfCreated(OpenstackNode osNode, String intf) {
- Device device = deviceService.getDevice(osNode.ovsdb());
- if (device == null || !deviceService.isAvailable(osNode.ovsdb()) ||
- !device.is(BridgeConfig.class)) {
- return false;
- }
-
- BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
- return bridgeConfig.getPorts().stream()
- .anyMatch(port -> port.annotations().value(PORT_NAME).equals(intf));
- }
-
- private boolean isGroupCreated(OpenstackNode osNode) {
- for (OpenstackNode gNode : osNodeService.completeNodes(GATEWAY)) {
- if (!isGatewayBucketAdded(osNode, gNode)) {
- return false;
- }
- }
- return true;
- }
-
- private boolean isGatewayBucketAdded(OpenstackNode cNode, OpenstackNode gNode) {
- if (cNode.dataIp() != null) {
- Group osGroup = groupService.getGroup(cNode.intgBridge(),
- cNode.gatewayGroupKey(VXLAN));
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .extension(tunnelDstTreatment(gNode.intgBridge(),
- gNode.dataIp()),
- cNode.intgBridge())
- .setOutput(cNode.tunnelPortNum())
- .build();
- GroupBucket bucket = createSelectGroupBucket(treatment);
- if (osGroup == null || !osGroup.buckets().buckets().contains(bucket)) {
- return false;
- }
- }
- if (cNode.vlanIntf() != null) {
- Group osGroup = groupService.getGroup(cNode.intgBridge(),
- cNode.gatewayGroupKey(VLAN));
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setEthDst(gNode.vlanPortMac())
- .setOutput(cNode.vlanPortNum())
- .build();
- GroupBucket bucket = createSelectGroupBucket(treatment);
- if (osGroup == null || !osGroup.buckets().buckets().contains(bucket)) {
- return false;
- }
- }
- return true;
- }
-
private boolean isCurrentStateDone(OpenstackNode osNode) {
switch (osNode.state()) {
case INIT:
if (!deviceService.isAvailable(osNode.intgBridge())) {
return false;
}
- if (osNode.type() == GATEWAY &&
- !isBridgeCreated(osNode.ovsdb(), ROUTER_BRIDGE)) {
- return false;
- }
return true;
case DEVICE_CREATED:
if (osNode.dataIp() != null &&
@@ -581,23 +343,11 @@
!isIntfEnabled(osNode, osNode.vlanIntf())) {
return false;
}
- if (osNode.type() == GATEWAY && (
- !isIntfEnabled(osNode, PATCH_INTG_BRIDGE) ||
- !isIntfCreated(osNode, PATCH_ROUT_BRIDGE))) {
+ if (osNode.type() == GATEWAY &&
+ !isIntfEnabled(osNode, osNode.uplinkPort())) {
return false;
}
return true;
- case PORT_CREATED:
- if (osNode.type() == COMPUTE) {
- return isGroupCreated(osNode);
- } else {
- for (OpenstackNode cNode : osNodeService.completeNodes(COMPUTE)) {
- if (!isGatewayBucketAdded(cNode, osNode)) {
- return false;
- }
- }
- return true;
- }
case COMPLETE:
return false;
case INCOMPLETE:
@@ -700,9 +450,7 @@
if (osNode.state() == DEVICE_CREATED && (
Objects.equals(portName, DEFAULT_TUNNEL) ||
Objects.equals(portName, osNode.vlanIntf()) ||
- Objects.equals(portName, PATCH_INTG_BRIDGE) ||
- Objects.equals(portName, PATCH_ROUT_BRIDGE))) {
- // FIXME we never gets PATCH_ROUTE_BRIDGE port added events as of now
+ Objects.equals(portName, osNode.uplinkPort()))) {
log.debug("Interface {} added to {}", portName, event.subject().id());
bootstrapNode(osNode);
}
@@ -715,8 +463,7 @@
if (osNode.state() == COMPLETE && (
Objects.equals(portName, DEFAULT_TUNNEL) ||
Objects.equals(portName, osNode.vlanIntf()) ||
- Objects.equals(portName, PATCH_INTG_BRIDGE) ||
- Objects.equals(portName, PATCH_ROUT_BRIDGE))) {
+ Objects.equals(portName, osNode.uplinkPort()))) {
log.warn("Interface {} removed from {}", portName, event.subject().id());
setState(osNode, INCOMPLETE);
}
@@ -731,54 +478,6 @@
}
}
- private class InternalGroupListener implements GroupListener {
-
- @Override
- public boolean isRelevant(GroupEvent event) {
- NodeId leader = leadershipService.getLeader(appId.name());
- return Objects.equals(localNode, leader);
- }
-
- @Override
- public void event(GroupEvent event) {
- switch (event.type()) {
- case GROUP_ADDED:
- eventExecutor.execute(() -> {
- log.trace("Group added, ID:{} state:{}", event.subject().id(),
- event.subject().state());
- processGroup(event.subject());
- });
- break;
- case GROUP_UPDATED:
- eventExecutor.execute(() -> {
- log.trace("Group updated, ID:{} state:{}", event.subject().id(),
- event.subject().state());
- processGroup(event.subject());
- });
- break;
- case GROUP_REMOVED:
- // TODO handle group removed
- break;
- default:
- break;
- }
- }
-
- private void processGroup(Group group) {
- OpenstackNode osNode = osNodeService.nodes(COMPUTE).stream()
- .filter(n -> n.state() == PORT_CREATED &&
- (n.gatewayGroupId(VXLAN).equals(group.id()) ||
- n.gatewayGroupId(VLAN).equals(group.id())))
- .findAny().orElse(null);
- if (osNode != null) {
- bootstrapNode(osNode);
- }
- osNodeService.nodes(GATEWAY).stream()
- .filter(gNode -> gNode.state() == PORT_CREATED)
- .forEach(DefaultOpenstackNodeHandler.this::bootstrapNode);
- }
- }
-
private class InternalOpenstackNodeListener implements OpenstackNodeListener {
@Override
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
index 4642dd7..f3ece18 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/OpenstackNodeManager.java
@@ -171,8 +171,7 @@
public OpenstackNode node(DeviceId deviceId) {
OpenstackNode result = osNodeStore.nodes().stream()
.filter(osNode -> Objects.equals(osNode.intgBridge(), deviceId) ||
- Objects.equals(osNode.ovsdb(), deviceId) ||
- Objects.equals(osNode.routerBridge(), deviceId))
+ Objects.equals(osNode.ovsdb(), deviceId))
.findFirst().orElse(null);
return result;
}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
index 9d311b2..3f8936e 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
@@ -27,6 +27,13 @@
import org.onosproject.openstacknode.api.OpenstackNodeService;
import org.onosproject.openstacknode.impl.DefaultOpenstackNode;
import org.onosproject.rest.AbstractWebResource;
+import static org.onosproject.openstacknode.api.Constants.GATEWAY;
+import static org.onosproject.openstacknode.api.Constants.HOST_NAME;
+import static org.onosproject.openstacknode.api.Constants.MANAGEMENT_IP;
+import static org.onosproject.openstacknode.api.Constants.DATA_IP;
+import static org.onosproject.openstacknode.api.Constants.VLAN_INTF_NAME;
+import static org.onosproject.openstacknode.api.Constants.UPLINK_PORT;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,16 +64,8 @@
private static final String UPDATE = "UPDATE";
private static final String NODE_ID = "NODE_ID";
private static final String DELETE = "DELETE";
-
- private static final String HOST_NAME = "hostname";
private static final String TYPE = "type";
- private static final String MANAGEMENT_IP = "managementIp";
- private static final String DATA_IP = "dataIp";
private static final String INTEGRATION_BRIDGE = "integrationBridge";
- private static final String VLAN_INTF_NAME = "vlanPort";
-
- // GATEWAY node specific fields
- private static final String ROUTER_BRIDGE = "routerBridge";
private final OpenstackNodeAdminService osNodeAdminService =
@@ -148,10 +147,7 @@
String type = node.get(TYPE).asText();
String mIp = node.get(MANAGEMENT_IP).asText();
String iBridge = node.get(INTEGRATION_BRIDGE).asText();
- String rBridge = null;
- if (node.get(ROUTER_BRIDGE) != null) {
- rBridge = node.get(ROUTER_BRIDGE).asText();
- }
+
DefaultOpenstackNode.Builder nodeBuilder = DefaultOpenstackNode.builder()
.hostname(hostname)
.type(OpenstackNode.NodeType.valueOf(type))
@@ -159,15 +155,15 @@
.intgBridge(DeviceId.deviceId(iBridge))
.state(NodeState.INIT);
+ if (type.equals(GATEWAY)) {
+ nodeBuilder.uplinkPort(node.get(UPLINK_PORT).asText());
+ }
if (node.get(VLAN_INTF_NAME) != null) {
nodeBuilder.vlanIntf(node.get(VLAN_INTF_NAME).asText());
}
if (node.get(DATA_IP) != null) {
nodeBuilder.dataIp(IpAddress.valueOf(node.get(DATA_IP).asText()));
}
- if (rBridge != null) {
- nodeBuilder.routerBridge(DeviceId.deviceId(rBridge));
- }
log.trace("node is {}", nodeBuilder.build().toString());
nodeSet.add(nodeBuilder.build());
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
index b748bb8..a55cb25 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
@@ -40,7 +40,6 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreServiceAdapter;
import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.core.GroupId;
import org.onosproject.net.Annotations;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
@@ -70,14 +69,6 @@
import org.onosproject.net.flow.instructions.ExtensionPropertyException;
import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
-import org.onosproject.net.group.DefaultGroup;
-import org.onosproject.net.group.Group;
-import org.onosproject.net.group.GroupBuckets;
-import org.onosproject.net.group.GroupDescription;
-import org.onosproject.net.group.GroupEvent;
-import org.onosproject.net.group.GroupKey;
-import org.onosproject.net.group.GroupListener;
-import org.onosproject.net.group.GroupService;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.openstacknode.api.NodeState;
import org.onosproject.openstacknode.api.OpenstackNode;
@@ -113,7 +104,6 @@
import static org.onosproject.openstacknode.api.NodeState.DEVICE_CREATED;
import static org.onosproject.openstacknode.api.NodeState.INCOMPLETE;
import static org.onosproject.openstacknode.api.NodeState.INIT;
-import static org.onosproject.openstacknode.api.NodeState.PORT_CREATED;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
@@ -145,38 +135,28 @@
private static final String COMPUTE_1_HOSTNAME = "compute_1";
private static final String COMPUTE_2_HOSTNAME = "compute_2";
private static final String COMPUTE_3_HOSTNAME = "compute_3";
- private static final String COMPUTE_4_HOSTNAME = "compute_4";
private static final String GATEWAY_1_HOSTNAME = "gateway_1";
private static final String GATEWAY_2_HOSTNAME = "gateway_2";
private static final String GATEWAY_3_HOSTNAME = "gateway_3";
- private static final String GATEWAY_4_HOSTNAME = "gateway_4";
private static final IpAddress COMPUTE_1_IP = IpAddress.valueOf("10.100.0.1");
private static final IpAddress COMPUTE_2_IP = IpAddress.valueOf("10.100.0.2");
private static final IpAddress COMPUTE_3_IP = IpAddress.valueOf("10.100.0.3");
- private static final IpAddress COMPUTE_4_IP = IpAddress.valueOf("10.100.0.4");
private static final IpAddress GATEWAY_1_IP = IpAddress.valueOf("10.100.0.5");
private static final IpAddress GATEWAY_2_IP = IpAddress.valueOf("10.100.0.6");
private static final IpAddress GATEWAY_3_IP = IpAddress.valueOf("10.100.0.7");
- private static final IpAddress GATEWAY_4_IP = IpAddress.valueOf("10.100.0.8");
+
+ private static final String GATEWAY_UPLINK_PORT = "eth0";
private static final Device COMPUTE_1_INTG_DEVICE = createOpenFlowDevice(1, INTEGRATION_BRIDGE);
private static final Device COMPUTE_2_INTG_DEVICE = createOpenFlowDevice(2, INTEGRATION_BRIDGE);
private static final Device COMPUTE_3_INTG_DEVICE = createOpenFlowDevice(3, INTEGRATION_BRIDGE);
- private static final Device COMPUTE_4_INTG_DEVICE = createOpenFlowDevice(4, INTEGRATION_BRIDGE);
- private static final Device GATEWAY_1_INTG_DEVICE = createOpenFlowDevice(5, INTEGRATION_BRIDGE);
- private static final Device GATEWAY_1_ROUT_DEVICE = createOpenFlowDevice(6, ROUTER_BRIDGE);
- private static final Device GATEWAY_2_INTG_DEVICE = createOpenFlowDevice(7, INTEGRATION_BRIDGE);
- private static final Device GATEWAY_2_ROUT_DEVICE = createOpenFlowDevice(8, ROUTER_BRIDGE);
- private static final Device GATEWAY_3_INTG_DEVICE = createOpenFlowDevice(9, INTEGRATION_BRIDGE);
- private static final Device GATEWAY_3_ROUT_DEVICE = createOpenFlowDevice(10, ROUTER_BRIDGE);
- private static final Device GATEWAY_4_INTG_DEVICE = createOpenFlowDevice(11, INTEGRATION_BRIDGE);
- private static final Device GATEWAY_4_ROUT_DEVICE = createOpenFlowDevice(12, ROUTER_BRIDGE);
+ private static final Device GATEWAY_1_INTG_DEVICE = createOpenFlowDevice(4, INTEGRATION_BRIDGE);
+ private static final Device GATEWAY_2_INTG_DEVICE = createOpenFlowDevice(5, INTEGRATION_BRIDGE);
+ private static final Device GATEWAY_3_INTG_DEVICE = createOpenFlowDevice(6, INTEGRATION_BRIDGE);
private static final Device COMPUTE_1_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_1_IP);
private static final Device COMPUTE_2_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_2_IP);
- private static final Device COMPUTE_3_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_3_IP);
- private static final Device COMPUTE_4_OVSDB_DEVICE = createOvsdbDevice(COMPUTE_4_IP);
private static final Device GATEWAY_1_OVSDB_DEVICE = createOvsdbDevice(GATEWAY_1_IP);
private static final Device GATEWAY_2_OVSDB_DEVICE = createOvsdbDevice(GATEWAY_2_IP);
@@ -201,14 +181,6 @@
COMPUTE,
COMPUTE_3_INTG_DEVICE,
COMPUTE_3_IP,
- PORT_CREATED
- );
-
- private static final OpenstackNode COMPUTE_4 = createNode(
- COMPUTE_4_HOSTNAME,
- COMPUTE,
- COMPUTE_4_INTG_DEVICE,
- COMPUTE_4_IP,
COMPLETE
);
@@ -216,8 +188,8 @@
GATEWAY_1_HOSTNAME,
GATEWAY,
GATEWAY_1_INTG_DEVICE,
- GATEWAY_1_ROUT_DEVICE,
GATEWAY_1_IP,
+ GATEWAY_UPLINK_PORT,
INIT
);
@@ -225,8 +197,8 @@
GATEWAY_2_HOSTNAME,
GATEWAY,
GATEWAY_2_INTG_DEVICE,
- GATEWAY_2_ROUT_DEVICE,
GATEWAY_2_IP,
+ GATEWAY_UPLINK_PORT,
DEVICE_CREATED
);
@@ -234,17 +206,8 @@
GATEWAY_3_HOSTNAME,
GATEWAY,
GATEWAY_3_INTG_DEVICE,
- GATEWAY_3_ROUT_DEVICE,
GATEWAY_3_IP,
- PORT_CREATED
- );
-
- private static final OpenstackNode GATEWAY_4 = createNode(
- GATEWAY_4_HOSTNAME,
- GATEWAY,
- GATEWAY_4_INTG_DEVICE,
- GATEWAY_4_ROUT_DEVICE,
- GATEWAY_4_IP,
+ GATEWAY_UPLINK_PORT,
COMPLETE
);
@@ -280,7 +243,6 @@
target.deviceService = TEST_DEVICE_SERVICE;
target.deviceAdminService = mockDeviceAdminService;
target.ovsdbController = mockOvsdbController;
- target.groupService = new TestGroupService();
target.osNodeService = testNodeManager;
target.osNodeAdminService = testNodeManager;
target.componentConfigService = new TestComponentConfigService();
@@ -341,7 +303,7 @@
assertEquals(ERR_STATE_NOT_MATCH, DEVICE_CREATED,
testNodeManager.node(COMPUTE_2_HOSTNAME).state());
target.processDeviceCreatedState(COMPUTE_2);
- assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED,
+ assertEquals(ERR_STATE_NOT_MATCH, COMPLETE,
testNodeManager.node(COMPUTE_2_HOSTNAME).state());
}
@@ -354,69 +316,28 @@
testNodeManager.createNode(GATEWAY_2);
TEST_DEVICE_SERVICE.devMap.put(GATEWAY_2_OVSDB_DEVICE.id(), GATEWAY_2_OVSDB_DEVICE);
TEST_DEVICE_SERVICE.devMap.put(GATEWAY_2_INTG_DEVICE.id(), GATEWAY_2_INTG_DEVICE);
+ TEST_DEVICE_SERVICE.portList.add(createPort(GATEWAY_2_INTG_DEVICE, GATEWAY_UPLINK_PORT));
assertEquals(ERR_STATE_NOT_MATCH, DEVICE_CREATED,
testNodeManager.node(GATEWAY_2_HOSTNAME).state());
target.processDeviceCreatedState(GATEWAY_2);
- assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED,
+ assertEquals(ERR_STATE_NOT_MATCH, COMPLETE,
testNodeManager.node(GATEWAY_2_HOSTNAME).state());
}
/**
- * Checks if the compute node state changes from PORT_CREATED to
- * COMPLETE after processing PORT_CREATED state.
- */
- @Test
- public void testComputeNodeProcessPortCreatedState() {
- testNodeManager.createNode(COMPUTE_3);
- TEST_DEVICE_SERVICE.devMap.put(COMPUTE_3_OVSDB_DEVICE.id(), COMPUTE_3_OVSDB_DEVICE);
- TEST_DEVICE_SERVICE.devMap.put(COMPUTE_3_INTG_DEVICE.id(), COMPUTE_3_INTG_DEVICE);
- TEST_DEVICE_SERVICE.portList.add(createPort(COMPUTE_3_INTG_DEVICE, DEFAULT_TUNNEL));
-
- testNodeManager.createNode(GATEWAY_4);
- TEST_DEVICE_SERVICE.devMap.put(GATEWAY_4_INTG_DEVICE.id(), GATEWAY_4_INTG_DEVICE);
-
- assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED,
- testNodeManager.node(COMPUTE_3_HOSTNAME).state());
- target.processPortCreatedState(COMPUTE_3);
- assertEquals(ERR_STATE_NOT_MATCH, COMPLETE,
- testNodeManager.node(COMPUTE_3_HOSTNAME).state());
- }
-
- /**
- * Checks if the gateway node state changes from PORT_CREATED to
- * COMPLETE after processing PORT_CREATED state.
- */
- @Test
- public void testGatewayNodeProcessPortCreatedState() {
- testNodeManager.createNode(COMPUTE_4);
- TEST_DEVICE_SERVICE.devMap.put(COMPUTE_4_OVSDB_DEVICE.id(), COMPUTE_4_OVSDB_DEVICE);
- TEST_DEVICE_SERVICE.devMap.put(COMPUTE_4_INTG_DEVICE.id(), COMPUTE_4_INTG_DEVICE);
- TEST_DEVICE_SERVICE.portList.add(createPort(COMPUTE_4_INTG_DEVICE, DEFAULT_TUNNEL));
-
- testNodeManager.createNode(GATEWAY_3);
- TEST_DEVICE_SERVICE.devMap.put(GATEWAY_3_INTG_DEVICE.id(), GATEWAY_4_INTG_DEVICE);
-
- assertEquals(ERR_STATE_NOT_MATCH, PORT_CREATED,
- testNodeManager.node(GATEWAY_3_HOSTNAME).state());
- target.processPortCreatedState(GATEWAY_3);
- assertEquals(ERR_STATE_NOT_MATCH, COMPLETE,
- testNodeManager.node(GATEWAY_3_HOSTNAME).state());
- }
-
- /**
* Checks if the compute node state changes from COMPLETE to INCOMPLETE
* when integration bridge is disconnected.
*/
@Test
public void testBackToIncompleteWhenBrIntDisconnected() {
- testNodeManager.createNode(COMPUTE_4);
+ testNodeManager.createNode(COMPUTE_3);
assertEquals(ERR_STATE_NOT_MATCH, COMPLETE,
- testNodeManager.node(COMPUTE_4_HOSTNAME).state());
- TEST_DEVICE_SERVICE.removeDevice(COMPUTE_4_INTG_DEVICE);
+ testNodeManager.node(COMPUTE_3_HOSTNAME).state());
+ TEST_DEVICE_SERVICE.removeDevice(COMPUTE_3_INTG_DEVICE);
assertEquals(ERR_STATE_NOT_MATCH, INCOMPLETE,
- testNodeManager.node(COMPUTE_4_HOSTNAME).state());
+ testNodeManager.node(COMPUTE_3_HOSTNAME).state());
}
/**
@@ -425,14 +346,14 @@
*/
@Test
public void testBackToIncompleteWhenVxlanRemoved() {
- testNodeManager.createNode(COMPUTE_4);
+ testNodeManager.createNode(COMPUTE_3);
assertEquals(ERR_STATE_NOT_MATCH, COMPLETE,
- testNodeManager.node(COMPUTE_4_HOSTNAME).state());
- TEST_DEVICE_SERVICE.removePort(COMPUTE_4_INTG_DEVICE, createPort(
- COMPUTE_4_INTG_DEVICE, DEFAULT_TUNNEL));
+ testNodeManager.node(COMPUTE_3_HOSTNAME).state());
+ TEST_DEVICE_SERVICE.removePort(COMPUTE_3_INTG_DEVICE, createPort(
+ COMPUTE_3_INTG_DEVICE, DEFAULT_TUNNEL));
assertEquals(ERR_STATE_NOT_MATCH, INCOMPLETE,
- testNodeManager.node(COMPUTE_4_HOSTNAME).state());
+ testNodeManager.node(COMPUTE_3_HOSTNAME).state());
}
@@ -474,26 +395,24 @@
hostname,
type,
intgBridge.id(),
- null,
ipAddr,
ipAddr,
- null, state);
+ null, null, state);
}
private static OpenstackNode createNode(String hostname,
OpenstackNode.NodeType type,
Device intgBridge,
- Device routerBridge,
IpAddress ipAddr,
+ String uplinkPort,
NodeState state) {
return new TestOpenstackNode(
hostname,
type,
intgBridge.id(),
- routerBridge.id(),
ipAddr,
ipAddr,
- null, state);
+ null, uplinkPort, state);
}
private static final class TestDevice extends DefaultDevice {
@@ -546,18 +465,18 @@
private TestOpenstackNode(String hostname,
NodeType type,
DeviceId intgBridge,
- DeviceId routerBridge,
IpAddress managementIp,
IpAddress dataIp,
String vlanIntf,
+ String uplinkPort,
NodeState state) {
super(hostname,
type,
intgBridge,
- routerBridge,
managementIp,
dataIp,
vlanIntf,
+ uplinkPort,
state);
}
@@ -572,11 +491,6 @@
}
@Override
- public PortNumber patchPortNum() {
- return PortNumber.portNumber(1);
- }
-
- @Override
public MacAddress vlanPortMac() {
return MacAddress.NONE;
}
@@ -621,8 +535,7 @@
public OpenstackNode node(DeviceId deviceId) {
return osNodeMap.values().stream()
.filter(osNode -> Objects.equals(osNode.intgBridge(), deviceId) ||
- Objects.equals(osNode.ovsdb(), deviceId) ||
- Objects.equals(osNode.routerBridge(), deviceId))
+ Objects.equals(osNode.ovsdb(), deviceId))
.findFirst().orElse(null);
}
@@ -885,81 +798,6 @@
}
}
- private static class TestGroupService implements GroupService {
- Map<GroupKey, Group> groupMap = Maps.newHashMap();
- Map<GroupKey, GroupBuckets> groupBucketsMap = Maps.newHashMap();
- List<GroupListener> listeners = Lists.newArrayList();
-
- @Override
- public void addListener(GroupListener listener) {
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(GroupListener listener) {
- listeners.remove(listener);
- }
-
- @Override
- public void addGroup(GroupDescription groupDesc) {
- DefaultGroup group = new DefaultGroup(GroupId.valueOf(groupDesc.givenGroupId()), groupDesc);
- group.setState(Group.GroupState.ADDED);
- groupMap.put(groupDesc.appCookie(), group);
- groupBucketsMap.put(groupDesc.appCookie(), groupDesc.buckets());
-
- GroupEvent event = new GroupEvent(GroupEvent.Type.GROUP_ADDED, group);
- listeners.stream().filter(listener -> listener.isRelevant(event))
- .forEach(listener -> listener.event(event));
- }
-
- @Override
- public Group getGroup(DeviceId deviceId, GroupKey appCookie) {
- return groupMap.get(appCookie);
- }
-
- @Override
- public void addBucketsToGroup(DeviceId deviceId, GroupKey oldCookie, GroupBuckets buckets,
- GroupKey newCookie, ApplicationId appId) {
-
- }
-
- @Override
- public void removeBucketsFromGroup(DeviceId deviceId, GroupKey oldCookie, GroupBuckets buckets,
- GroupKey newCookie, ApplicationId appId) {
-
- }
-
- @Override
- public void purgeGroupEntries(DeviceId deviceId) {
-
- }
-
- @Override
- public void removeGroup(DeviceId deviceId, GroupKey appCookie, ApplicationId appId) {
-
- }
-
- @Override
- public Iterable<Group> getGroups(DeviceId deviceId, ApplicationId appId) {
- return null;
- }
-
- @Override
- public Iterable<Group> getGroups(DeviceId deviceId) {
- return null;
- }
-
- @Override
- public void setBucketsForGroup(DeviceId deviceId, GroupKey oldCookie, GroupBuckets buckets,
- GroupKey newCookie, ApplicationId appId) {
- groupBucketsMap.put(newCookie, buckets);
- GroupEvent event = new GroupEvent(GroupEvent.Type.GROUP_UPDATED, groupMap.get(newCookie));
- listeners.stream().filter(listener -> listener.isRelevant(event))
- .forEach(listener -> listener.event(event));
- }
-
- }
-
private static class TestExtensionTreatment implements ExtensionTreatment {
Ip4Address tunnelDst;
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java
index b881dff..47ce53d 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeTest.java
@@ -133,20 +133,4 @@
.state(NodeState.INIT)
.build();
}
-
- /**
- * Checks building a gateway type node without router bridge ID
- * fails with proper exception.
- */
- @Test(expected = IllegalArgumentException.class)
- public void testGatewayWithoutRouterBridgeId() {
- DefaultOpenstackNode.builder()
- .hostname(HOSTNAME_1)
- .type(OpenstackNode.NodeType.GATEWAY)
- .intgBridge(DEVICE_1.id())
- .managementIp(TEST_IP)
- .dataIp(TEST_IP)
- .state(NodeState.INIT)
- .build();
- }
}
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
index 28cdfde..df9ae73 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeManagerTest.java
@@ -64,11 +64,12 @@
private static final String COMPUTE_3_HOSTNAME = "compute_3";
private static final String GATEWAY_1_HOSTNAME = "gateway_1";
+ private static final String GATEWAY_1_UPLINKPORT = "eth0";
+
private static final Device COMPUTE_1_INTG_DEVICE = createDevice(1);
private static final Device COMPUTE_2_INTG_DEVICE = createDevice(2);
private static final Device COMPUTE_3_INTG_DEVICE = createDevice(3);
private static final Device GATEWAY_1_INTG_DEVICE = createDevice(4);
- private static final Device GATEWAY_1_ROUT_DEVICE = createDevice(5);
private static final OpenstackNode COMPUTE_1 = createNode(
COMPUTE_1_HOSTNAME,
@@ -95,8 +96,8 @@
GATEWAY_1_HOSTNAME,
OpenstackNode.NodeType.GATEWAY,
GATEWAY_1_INTG_DEVICE,
- GATEWAY_1_ROUT_DEVICE,
IpAddress.valueOf("10.100.0.4"),
+ GATEWAY_1_UPLINKPORT,
NodeState.COMPLETE
);
@@ -288,8 +289,6 @@
target.node(GATEWAY_1_INTG_DEVICE.id()), GATEWAY_1));
assertTrue(ERR_NOT_FOUND, Objects.equals(
target.node(GATEWAY_1.ovsdb()), GATEWAY_1));
- assertTrue(ERR_NOT_FOUND, Objects.equals(
- target.node(GATEWAY_1.routerBridge()), GATEWAY_1));
}
private void validateEvents(Enum... types) {
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
index 53bd593..fbec333 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/OpenstackNodeTest.java
@@ -57,15 +57,15 @@
}
protected static OpenstackNode createNode(String hostname, NodeType type,
- Device intgBridge, Device routerBridge,
- IpAddress ipAddr, NodeState state) {
+ Device intgBridge, IpAddress ipAddr,
+ String uplinkPort, NodeState state) {
return org.onosproject.openstacknode.impl.DefaultOpenstackNode.builder()
.hostname(hostname)
.type(type)
.intgBridge(intgBridge.id())
- .routerBridge(routerBridge.id())
.managementIp(ipAddr)
.dataIp(ipAddr)
+ .uplinkPort(uplinkPort)
.state(state)
.build();
}
diff --git a/apps/openstacknode/network-cfg.json b/apps/openstacknode/network-cfg.json
index 6cca7ed..a9918d9 100644
--- a/apps/openstacknode/network-cfg.json
+++ b/apps/openstacknode/network-cfg.json
@@ -26,9 +26,7 @@
"dataIp" : "172.16.130.7",
"vlanPort" : "eth2",
"integrationBridge" : "of:00000000000000a3",
- "routerBridge" : "of:00000000000000b1",
- "uplinkPort" : "quagga-router",
- "routerController" : "172.17.0.2"
+ "uplinkPort" : "ens6"
}
]