Hyunsun Moon
Committed by Gerrit Code Review

Fixed javadoc warnings and some cleanups

- Fixed javadoc warnings
- Removed commented code lines
- Removed OpenstackNetworkingConfig and SubjectFactories class which is no longer used
- Fixed scalablegateway app artifact ID
- Use PORT_NAME defined in net.AnnotationKeys

Change-Id: Id18501addefa12655e4946b9931ec094a34ee83c
/*
* Copyright 2016-present Open Networking Laboratory
*
* 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.openstacknetworking;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Maps;
import org.onlab.packet.Ip4Address;
import org.onosproject.net.DeviceId;
import org.onosproject.net.config.Config;
import org.slf4j.Logger;
import java.util.Map;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Network Config for OpenstackNetworking application.
*
*/
public class OpenstackNetworkingConfig extends Config<String> {
protected final Logger log = getLogger(getClass());
public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac";
public static final String GATEWAY_BRIDGE_ID = "gatewayBridgeId";
public static final String GATEWAY_EXTERNAL_INTERFACE_NAME = "gatewayExternalInterfaceName";
public static final String GATEWAY_EXTERNAL_INTERFACE_MAC = "gatewayExternalInterfaceMac";
public static final String NODES = "nodes";
public static final String DATAPLANE_IP = "dataPlaneIp";
public static final String BRIDGE_ID = "bridgeId";
/**
* Returns physical router mac.
*
* @return physical router mac
*/
public String physicalRouterMac() {
return this.get(PHYSICAL_ROUTER_MAC, "");
}
/**
* Returns gateway's bridge id.
*
* @return bridge id
*/
public String gatewayBridgeId() {
return this.get(GATEWAY_BRIDGE_ID, "");
}
/**
* Returns gateway's external interface name.
*
* @return external interface name
*/
public String gatewayExternalInterfaceName() {
return this.get(GATEWAY_EXTERNAL_INTERFACE_NAME, "");
}
/**
* Returns gateway's external interface mac.
*
* @return external interface mac
*/
public String gatewayExternalInterfaceMac() {
return this.get(GATEWAY_EXTERNAL_INTERFACE_MAC, "");
}
/**
* Returns the data plane IP map of nodes read from network config.
*
* @return data plane IP map
*/
public Map<DeviceId, Ip4Address> nodes() {
Map<DeviceId, Ip4Address> nodeMap = Maps.newHashMap();
JsonNode jsonNodes = object.get(NODES);
if (jsonNodes == null) {
log.error("There's no node information");
return null;
}
jsonNodes.forEach(jsonNode -> {
try {
nodeMap.putIfAbsent(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()),
Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText()));
} catch (IllegalArgumentException | NullPointerException e) {
log.error("Failed to read {}", e.toString());
}
});
return nodeMap;
}
}
......@@ -81,17 +81,10 @@ public interface OpenstackRoutingService {
void removeRouterInterface(OpenstackRouterInterface openstackRouterInterface);
/**
* Checks floatingIp disassociation when corresponding deleted vm.
*
* @param portId Deleted vm
* @param portInfo stored information about deleted vm
void checkDisassociatedFloatingIp(String portId, OpenstackPortInfo portInfo);
*/
/**
* Returns network id for routerInterface.
*
* @param portId routerInterface`s port id
* @return network id
*/
String networkIdForRouterInterface(String portId);
}
......
/*
* Copyright 2016 Open Networking Laboratory
*
* 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.openstacknetworking;
import org.onosproject.net.config.SubjectFactory;
/**
* SubjectFactory class for OpenstackNetworking configuration.
*
*/
public final class OpenstackSubjectFactories {
private OpenstackSubjectFactories() {
}
public static final SubjectFactory<String> USER_DEFINED_SUBJECT_FACTORY =
new SubjectFactory<String>(String.class, "userDefined") {
@Override
public String createSubject(String key) {
return key;
}
};
}
......@@ -35,7 +35,8 @@
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.requires>
org.onosproject.openstackinterface,
org.onosproject.openstacknode
org.onosproject.openstacknode,
org.onosproject.scalablegateway
</onos.app.requires>
</properties>
......@@ -65,7 +66,7 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-scalablegateway</artifactId>
<artifactId>onos-app-scalablegateway</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......
......@@ -146,31 +146,6 @@ public class OpenstackIcmpHandler {
PortNumber portNumber = context.inPacket().receivedFrom().port();
if (icmp.getIcmpType() == ICMP.TYPE_ECHO_REQUEST) {
//TODO: Considers icmp between internal subnets which are belonged to the same router.
//OpenstackPortInfo openstackPortInfo =
// getOpenstackPortInfo(Ip4Address.valueOf(ipPacket.getSourceAddress()), ethernet.getSourceMAC());
//checkNotNull(openstackPortInfo, "openstackPortInfo can not be null");
/* XXX Is this handling ICMP to gateway ?????
if (requestToOpenstackRoutingNetwork(ipPacket.getDestinationAddress())) {
Host host =
if (openstackPortInfo == null) {
if (config.gatewayBridgeId().equals(context.inPacket().receivedFrom().deviceId().toString())) {
if (portNumber.equals(getPortForAnnotationPortName(deviceId,
config.gatewayExternalInterfaceName()))) {
processIcmpPacketSentToExtenal(ipPacket, icmp, ipPacket.getSourceAddress(),
ethernet.getSourceMAC(), deviceId, portNumber);
return;
}
}
return;
} else {
processIcmpPacketSentToGateway(ipPacket, icmp, host);
return;
}
}
*/
Optional<Host> host = hostService.getHostsByMac(ethernet.getSourceMAC()).stream().findFirst();
if (!host.isPresent()) {
log.warn("No host found for MAC {}", ethernet.getSourceMAC());
......
......@@ -84,6 +84,7 @@ import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
@Component(immediate = true)
@Service
......@@ -137,8 +138,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
private ConsistentMap<String, String> routerInterfaceMap;
private static final ProviderId PID = new ProviderId("of", "org.onosproject.openstackroutering", true);
private static final String APP_ID = "org.onosproject.openstackrouting";
private static final String PORT_NAME = "portName";
private static final String PORTNAME_PREFIX_VM = "tap";
private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface";
private static final String FLOATING_IP_MAP_NAME = "openstackrouting-floatingip";
private static final String TP_PORT_MAP_NAME = "openstackrouting-tpportnum";
......@@ -251,8 +250,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
new OpenstackFloatingIPHandler(rulePopulator, openstackFloatingIp, Action.ASSOCIATE, null));
registerFloatingIpToHostService(openstackFloatingIp, Action.ASSOCIATE);
}
}
@Override
......@@ -383,34 +380,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
);
}
/*
@Override
public void checkDisassociatedFloatingIp(String portId, OpenstackPortInfo portInfo) {
if (floatingIpMap.size() < 1) {
log.info("No information in FloatingIpMap");
return;
}
OpenstackFloatingIP floatingIp = associatedFloatingIps()
.stream()
.filter(fIp -> fIp.portId().equals(portId))
.findAny()
.orElse(null);
if (floatingIp != null && portInfo != null) {
l3EventExecutorService.execute(
new OpenstackFloatingIPHandler(rulePopulator, floatingIp, false, portInfo));
OpenstackFloatingIP.Builder fBuilder = new OpenstackFloatingIP.Builder()
.floatingIpAddress(floatingIp.floatingIpAddress())
.id(floatingIp.id())
.networkId(floatingIp.networkId())
.status(floatingIp.status())
.tenantId(floatingIp.tenantId());
floatingIpMap.replace(floatingIp.id(), fBuilder.build());
} else if (portInfo == null) {
log.warn("portInfo is null as timing issue between ovs port update event and openstack deletePort event");
}
}
*/
@Override
public String networkIdForRouterInterface(String portId) {
return routerInterfaceMap.get(portId).value();
......@@ -662,7 +631,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
private class InternalHostListener implements HostListener {
private void hostDetected(Host host) {
String portId = host.annotations().value(Constants.PORT_ID);
OpenstackPort openstackPort = openstackService.port(portId);
if (openstackPort == null) {
......@@ -769,7 +737,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
default:
break;
}
}
}
......@@ -787,5 +754,4 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
// nothing to do
}
}
}
......
......@@ -69,6 +69,7 @@ import java.util.stream.StreamSupport;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.osgi.DefaultServiceDirectory.getService;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
/**
* Populates Routing Flow Rules.
......@@ -86,12 +87,10 @@ public class OpenstackRoutingRulePopulator {
private final OpenstackNodeService nodeService;
private static final String PORTNAME_PREFIX_TUNNEL = "vxlan";
private static final String PORTNAME = "portName";
private static final String PORTNAME_PREFIX_VM = "tap";
private static final String PORTNOTNULL = "Port can not be null";
private static final String DEVICENOTNULL = "Device can not be null";
private static final String EXTPORTNOTNULL = "External port can not be null";
private static final String TUNNEL_DESTINATION = "tunnelDst";
private static final int ROUTING_RULE_PRIORITY = 25000;
private static final int FLOATING_RULE_PRIORITY = 42000;
......@@ -113,6 +112,7 @@ public class OpenstackRoutingRulePopulator {
* @param flowObjectiveService FlowObjectiveService
* @param deviceService DeviceService
* @param driverService DriverService
* @param nodeService openstack node service
* @param gatewayService scalable gateway service
*/
public OpenstackRoutingRulePopulator(ApplicationId appId,
......@@ -205,7 +205,7 @@ public class OpenstackRoutingRulePopulator {
private Port getPortOfExternalInterface() {
return deviceService.getPorts(getGatewayNode().id()).stream()
.filter(p -> p.annotations().value(PORTNAME)
.filter(p -> p.annotations().value(PORT_NAME)
.equals(org.onosproject.openstacknode.Constants.PATCH_INTG_BRIDGE))
.findAny().orElse(null);
}
......@@ -293,7 +293,7 @@ public class OpenstackRoutingRulePopulator {
private boolean findPortinDevice(DeviceId deviceId, String openstackPortName) {
Port port = deviceService.getPorts(deviceId)
.stream()
.filter(p -> p.isEnabled() && p.annotations().value(PORTNAME).equals(openstackPortName))
.filter(p -> p.isEnabled() && p.annotations().value(PORT_NAME).equals(openstackPortName))
.findAny()
.orElse(null);
return port != null;
......@@ -332,7 +332,7 @@ public class OpenstackRoutingRulePopulator {
*/
public PortNumber getTunnelPort(DeviceId deviceId) {
Port port = deviceService.getPorts(deviceId).stream()
.filter(p -> p.annotations().value(PORTNAME).equals(PORTNAME_PREFIX_TUNNEL))
.filter(p -> p.annotations().value(PORT_NAME).equals(PORTNAME_PREFIX_TUNNEL))
.findAny().orElse(null);
if (port == null) {
......@@ -404,29 +404,6 @@ public class OpenstackRoutingRulePopulator {
flowObjectiveService.forward(deviceId, fo);
}
/*
private void populateRuleToGateway(DeviceId deviceId, Device gatewayDevice, long vni) {
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
.matchTunnelId(vni)
.matchEthDst(Constants.GATEWAY_MAC);
tBuilder.extension(buildNiciraExtenstion(deviceId, nodeService.nodes().get(gatewayDevice.id())), deviceId)
.setOutput(getTunnelPort(deviceId));
ForwardingObjective fo = DefaultForwardingObjective.builder()
.withSelector(sBuilder.build())
.withTreatment(tBuilder.build())
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withPriority(ROUTING_RULE_PRIORITY)
.fromApp(appId)
.add();
flowObjectiveService.forward(deviceId, fo);
}
*/
private Device getGatewayNode() {
// TODO Return the correct gateway node
......@@ -628,7 +605,6 @@ public class OpenstackRoutingRulePopulator {
getHostIpfromOpenstackPort(openstackPort).getIp4Address());
}
});
});
}
......@@ -679,7 +655,7 @@ public class OpenstackRoutingRulePopulator {
String openstackPortName = PORTNAME_PREFIX_VM + p.id().substring(0, 11);
return deviceService.getPorts(device.id())
.stream()
.filter(pt -> pt.annotations().value(PORTNAME).equals(openstackPortName))
.filter(pt -> pt.annotations().value(PORT_NAME).equals(openstackPortName))
.findAny()
.orElse(null);
}
......