sanghoshin
Committed by Gerrit Code Review

SONA: Openstackswitching

 - Refactored the app to expose APIs to CordVtn App
 - Added clone method in OpenstackPort and OpenstackNetwork
 - Added NetworkConfig to select the working mode of the app
 - Added a few more APIs for getting network topology information
 - Integrated with the modified DhcpService app
Change-Id: I9e266aff10a00d80074d031276864fff195d2b3f
Showing 23 changed files with 510 additions and 152 deletions
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-openstackswitching</artifactId>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-openstackswitching-api</artifactId>
<packaging>bundle</packaging>
<description>SONA Openstack Switching application API</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
</dependencies>
</project>
......@@ -77,6 +77,11 @@ public final class OpenstackNetwork {
return this.networkType;
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
public static final class Builder {
private String name;
private String tenantId;
......
......@@ -19,6 +19,7 @@ import com.google.common.collect.Lists;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
......@@ -179,6 +180,16 @@ public final class OpenstackPort {
//
//}
@Override
public Object clone() {
OpenstackPort op = new OpenstackPort(this.status, this.name, this.adminStateUp,
this.networkId, this.tenantId, this.deviceOwner, this.macAddress,
(HashMap) this.fixedIps.clone(), this.id,
Collections.unmodifiableList(this.securityGroups), this.deviceId);
return op;
}
/**
* OpenstackPort Builder class.
*/
......
......@@ -15,6 +15,10 @@
*/
package org.onosproject.openstackswitching;
import org.onlab.packet.Ip4Address;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
......@@ -26,13 +30,13 @@ public final class OpenstackSubnet {
private boolean enableHhcp;
private String networkId;
private String tenantId;
private String dnsNameservers;
private List<Ip4Address> dnsNameservers;
private String gatewayIp;
private String cidr;
private String id;
private OpenstackSubnet(String name, boolean enableHhcp, String networkId,
String tenantId, String dnsNameservers, String gatewayIp,
String tenantId, List<Ip4Address> dnsNameservers, String gatewayIp,
String cidr, String id) {
this.name = name;
this.enableHhcp = enableHhcp;
......@@ -69,7 +73,7 @@ public final class OpenstackSubnet {
return tenantId;
}
public String dnsNameservers() {
public List<Ip4Address> dnsNameservers() {
return dnsNameservers;
}
......@@ -85,8 +89,6 @@ public final class OpenstackSubnet {
return id;
}
// TODO : Implement the following functions when necessary
/**
* OpenstackSubnet Builder class.
*
......@@ -96,7 +98,7 @@ public final class OpenstackSubnet {
private boolean enableDhcp;
private String networkId;
private String tenantId;
private String dnsNameservers;
private List<Ip4Address> dnsNameservers;
private String gatewayIp;
private String cidr;
private String id;
......@@ -127,7 +129,7 @@ public final class OpenstackSubnet {
return this;
}
public Builder setDnsNameservers(String dnsNameservers) {
public Builder setDnsNameservers(List<Ip4Address> dnsNameservers) {
this.dnsNameservers = dnsNameservers;
return this;
......
......@@ -15,8 +15,10 @@
*/
package org.onosproject.openstackswitching;
import java.util.Collection;
/**
* It handles port management REST API from Openstack for VMs.
* Handles port management REST API from Openstack for VMs.
*/
public interface OpenstackSwitchingService {
......@@ -40,16 +42,41 @@ public interface OpenstackSwitchingService {
void updatePorts();
/**
* Store the network information created by openstack.
* Stores the network information created by openstack.
*
* @param openstackNetwork network information
*/
void createNetwork(OpenstackNetwork openstackNetwork);
/**
* Store the subnet information created by openstack.
* Stores the subnet information created by openstack.
*
* @param openstackSubnet subnet information
*/
void createSubnet(OpenstackSubnet openstackSubnet);
/**
* Returns port information list for the network ID given.
*
* @param networkId Network ID of the ports
* @return port information list
*/
Collection<OpenstackPort> ports(String networkId);
/**
* Returns port information for the port ID given.
*
* @param portId Port ID
* @return port information
*/
OpenstackPort port(String portId);
/**
* Returns network information list for the network ID given.
*
* @param networkId Network ID
* @return network information list
*/
OpenstackNetwork network(String networkId);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015 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.
-->
<app name="org.onosproject.openstackswitching" origin="ON.Lab" version="${project.version}"
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
features="${project.artifactId}">
<description>${project.description}</description>
<artifact>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-dhcp/${project.version}</artifact>
</app>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Copyright 2015 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.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
<repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
<feature name="onos-app-openstackswitching" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-dhcp/${project.version}</bundle>
</feature>
</features>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-openstackswitching</artifactId>
<version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-openstackswitching</artifactId>
<packaging>bundle</packaging>
<description>SONA Openstack Switching applications</description>
<properties>
<onos.version>1.4.0-SNAPSHOT</onos.version>
<onos.app.name>org.onosproject.openstackswitching</onos.app.name>
<web.context>/onos/openstackswitching</web.context>
<api.version>1.0.0</api.version>
<api.title>ONOS OpenStack Switching REST API</api.title>
<api.description>
APIs for receiving Neutron information.
</api.description>
<api.package>org.onosproject.openstackswitching.web</api.package>
<onos.app.origin>SKT, Inc.</onos.app.origin>
</properties>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-openstackswitching-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-dhcp-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_wab>src/main/webapp/</_wab>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Import-Package>
org.slf4j,
org.osgi.framework,
javax.ws.rs,
javax.ws.rs.core,
com.sun.jersey.api.core,
com.sun.jersey.spi.container.servlet,
com.sun.jersey.server.impl.container.servlet,
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.node,
com.fasterxml.jackson.core,
org.apache.karaf.shell.commands,
com.google.common.*,
org.onlab.packet.*,
org.onosproject.*
</Import-Package>
<Web-ContextPath>${web.context}</Web-ContextPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -31,7 +31,7 @@ import java.nio.ByteBuffer;
import java.util.Map;
/**
* It handles ARP packet from VMs.
* Handles ARP packet from VMs.
*/
public class OpenstackArpHandler {
......
/*
* Copyright 2014 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.openstackswitching;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.config.Config;
import org.onosproject.net.config.basics.BasicElementConfig;
/**
* Handles configuration for OpenstackSwitching app.
*/
public class OpenstackSwitchingConfig extends Config<ApplicationId> {
public static final String DONOTPUSH = "do_not_push_flows";
/**
* Returns the flag whether the app pushes flows or not.
*
* @return the flag or false if not set
*/
public boolean doNotPushFlows() {
String flag = get(DONOTPUSH, "false");
return Boolean.valueOf(flag);
}
/**
* Sets the flag whether the app pushes flows or not.
*
* @param flag the flag whether the app pushes flows or not
* @return self
*/
public BasicElementConfig doNotPushFlows(boolean flag) {
return (BasicElementConfig) setOrClear(DONOTPUSH, flag);
}
}
......@@ -15,6 +15,7 @@
*/
package org.onosproject.openstackswitching;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.felix.scr.annotations.Activate;
......@@ -33,6 +34,10 @@ import org.onosproject.dhcp.DhcpService;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
import org.onosproject.net.config.ConfigFactory;
import org.onosproject.net.config.NetworkConfigEvent;
import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
......@@ -43,17 +48,21 @@ import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
@SuppressWarnings("ALL")
@Service
@Component(immediate = true)
/**
* It populates forwarding rules for VMs created by Openstack.
* Populates forwarding rules for VMs created by Openstack.
*/
public class OpenstackSwitchingManager implements OpenstackSwitchingService {
......@@ -73,11 +82,15 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
protected FlowObjectiveService flowObjectiveService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetworkConfigRegistry cfgService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DhcpService dhcpService;
public static final int DHCP_PORT = 67;
private ApplicationId appId;
private boolean doNotPushFlows;
private OpenstackArpHandler arpHandler;
private OpenstackSwitchingRulePopulator rulePopulator;
......@@ -85,7 +98,17 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor();
private InternalDeviceListener internalDeviceListener = new InternalDeviceListener();
private InternalConfigListener internalConfigListener = new InternalConfigListener();
private final Set<ConfigFactory> factories = ImmutableSet.of(
new ConfigFactory<ApplicationId, OpenstackSwitchingConfig>(APP_SUBJECT_FACTORY,
OpenstackSwitchingConfig.class,
"openstackswitching") {
@Override
public OpenstackSwitchingConfig createConfig() {
return new OpenstackSwitchingConfig();
}
}
);
// Map <port_id, OpenstackPort>
private Map<String, OpenstackPort> openstackPortMap;
// Map <network_id, OpenstackNetwork>
......@@ -101,17 +124,24 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
protected void activate() {
appId = coreService
.registerApplication("org.onosproject.openstackswitching");
rulePopulator = new OpenstackSwitchingRulePopulator(appId, flowObjectiveService);
packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1));
deviceService.addListener(internalDeviceListener);
cfgService.addListener(internalConfigListener);
factories.forEach(cfgService::registerConfigFactory);
OpenstackSwitchingConfig cfg =
cfgService.getConfig(appId, OpenstackSwitchingConfig.class);
if (cfg != null) {
doNotPushFlows = cfg.doNotPushFlows();
}
openstackPortMap = Maps.newHashMap();
openstackNetworkMap = Maps.newHashMap();
openstackSubnetMap = Maps.newHashMap();
vniPortMap = Maps.newHashMap();
tunnelPortMap = Maps.newHashMap();
arpHandler = new OpenstackArpHandler(openstackPortMap, packetService);
log.info("Started");
}
......@@ -119,6 +149,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
protected void deactivate() {
packetService.removeProcessor(internalPacketProcessor);
deviceService.removeListener(internalDeviceListener);
cfgService.removeListener(internalConfigListener);
deviceEventExcutorService.shutdown();
......@@ -127,43 +158,10 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
@Override
public void createPorts(OpenstackPort openstackPort) {
//For DHCP purpose
//registerDhcpInfo(openstackPort);
registerDhcpInfo(openstackPort);
openstackPortMap.put(openstackPort.id(), openstackPort);
}
/*
private void registerDhcpInfo(OpenstackPort openstackPort) {
Ip4Address ip4Address;
Ip4Address subnetMask;
Ip4Address dhcpServer;
Ip4Address gatewayIPAddress;
Ip4Address domainServer;
OpenstackSubnet openstackSubnet;
ip4Address = (Ip4Address) openstackPort.fixedIps().values().toArray()[0];
openstackSubnet = openstackSubnetMap.values().stream()
.filter(n -> n.networkId().equals(openstackPort.networkId()))
.findFirst().get();
int prefix;
String[] parts = openstackSubnet.cidr().split("/");
prefix = Integer.parseInt(parts[1]);
int mask = 0xffffffff << (32 - prefix);
byte[] bytes = new byte[]{(byte) (mask >>> 24),
(byte) (mask >> 16 & 0xff), (byte) (mask >> 8 & 0xff), (byte) (mask & 0xff)};
subnetMask = Ip4Address.valueOf(bytes);
gatewayIPAddress = Ip4Address.valueOf(openstackSubnet.gatewayIp());
dhcpServer = gatewayIPAddress;
domainServer = Ip4Address.valueOf("8.8.8.8");
dhcpService.setStaticMappingOpenstack(openstackPort.macAddress(),
ip4Address, subnetMask, dhcpServer, gatewayIPAddress, domainServer);
}
*/
@Override
public void deletePorts() {
......@@ -179,13 +177,41 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
openstackNetworkMap.put(openstackNetwork.id(), openstackNetwork);
}
@Override
public void createSubnet(OpenstackSubnet openstackSubnet) {
openstackSubnetMap.put(openstackSubnet.id(), openstackSubnet);
log.debug("Added Subnet Info {}", openstackNetworkMap.get(openstackSubnet.id()));
}
@Override
public Collection<OpenstackPort> ports(String networkId) {
List<OpenstackPort> portList = openstackPortMap.values().stream()
.filter(p -> p.networkId().equals(networkId))
.collect(Collectors.toList());
return portList;
}
@Override
public OpenstackPort port(String portName) {
String uuid = portName.substring(3);
return (OpenstackPort) openstackPortMap.values().stream()
.filter(p -> p.id().startsWith(uuid))
.findFirst().get().clone();
}
@Override
public OpenstackNetwork network(String networkId) {
OpenstackNetwork on = null;
try {
on = (OpenstackNetwork) openstackNetworkMap.get(networkId).clone();
} catch (CloneNotSupportedException e) {
log.error("Cloning is not supported {}", e);
}
return on;
}
private void processDeviceAdded(Device device) {
log.debug("device {} is added", device.id());
rulePopulator.populateDefaultRules(device.id());
......@@ -211,6 +237,49 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
// TODO: need to update the vniPortMap
}
private void registerDhcpInfo(OpenstackPort openstackPort) {
Ip4Address ip4Address;
Ip4Address subnetMask;
Ip4Address dhcpServer;
Ip4Address gatewayIPAddress;
Ip4Address domainServer;
OpenstackSubnet openstackSubnet;
ip4Address = (Ip4Address) openstackPort.fixedIps().values().toArray()[0];
openstackSubnet = openstackSubnetMap.values().stream()
.filter(n -> n.networkId().equals(openstackPort.networkId()))
.findFirst().get();
subnetMask = Ip4Address.valueOf(buildSubnetMask(openstackSubnet.cidr()));
gatewayIPAddress = Ip4Address.valueOf(openstackSubnet.gatewayIp());
dhcpServer = gatewayIPAddress;
// TODO: supports multiple DNS servers
if (openstackSubnet.dnsNameservers().isEmpty()) {
domainServer = Ip4Address.valueOf("8.8.8.8");
} else {
domainServer = openstackSubnet.dnsNameservers().get(0);
}
List<Ip4Address> options = Lists.newArrayList();
options.add(subnetMask);
options.add(dhcpServer);
options.add(gatewayIPAddress);
options.add(domainServer);
dhcpService.setStaticMapping(openstackPort.macAddress(), ip4Address, true, options);
}
private byte[] buildSubnetMask(String cidr) {
int prefix;
String[] parts = cidr.split("/");
prefix = Integer.parseInt(parts[1]);
int mask = 0xffffffff << (32 - prefix);
byte[] bytes = new byte[]{(byte) (mask >>> 24),
(byte) (mask >> 16 & 0xff), (byte) (mask >> 8 & 0xff), (byte) (mask & 0xff)};
return bytes;
}
/**
* Populates the flow rules for traffic to VMs in different Cnode using
* Nicira extention.
......@@ -407,8 +476,8 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
private class InternalDeviceListener implements DeviceListener {
@Override
public void event(DeviceEvent event) {
deviceEventExcutorService.execute(new InternalEventHandler(event));
public void event(DeviceEvent deviceEvent) {
deviceEventExcutorService.execute(new InternalEventHandler(deviceEvent));
}
}
......@@ -422,6 +491,11 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
@Override
public void run() {
if (doNotPushFlows) {
return;
}
switch (deviceEvent.type()) {
case DEVICE_ADDED:
processDeviceAdded((Device) deviceEvent.subject());
......@@ -453,6 +527,23 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
}
}
private class InternalConfigListener implements NetworkConfigListener {
@Override
public void event(NetworkConfigEvent event) {
if (((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) &&
event.configClass().equals(OpenstackSwitchingConfig.class)) {
OpenstackSwitchingConfig cfg = cfgService.getConfig(appId,
OpenstackSwitchingConfig.class);
if (cfg != null) {
doNotPushFlows = cfg.doNotPushFlows();
log.info("Switching mode reconfigured");
}
}
}
}
private final class PortInfo {
DeviceId deviceId;
String portName;
......
......@@ -37,8 +37,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* It populates switching flow rules.
*
* Populates switching flow rules.
*/
public class OpenstackSwitchingRulePopulator {
......
/*
* Copyright 2015 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.
*/
/**
* OpenStack switch interface.
*/
package org.onosproject.openstackswitching;
......@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
/**
* It encodes and decodes the OpenstackPort.
* Encodes and decodes the OpenstackPort.
*/
public class OpenstackPortCodec extends JsonCodec<OpenstackPort> {
......
......@@ -53,7 +53,7 @@ public class OpenstackPortWebResource extends AbstractWebResource {
OpenstackSwitchingService switchingService = get(OpenstackSwitchingService.class);
switchingService.createPorts(openstackPort);
log.info("REST API ports is called with {}", portNode.toString());
log.debug("REST API ports is called with {}", portNode.toString());
return Response.status(Response.Status.OK).build();
} catch (Exception e) {
log.error("Creates VirtualPort failed because of exception {}",
......
......@@ -18,17 +18,21 @@ package org.onosproject.openstackswitching.web;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;
import org.onlab.packet.Ip4Address;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.openstackswitching.OpenstackSubnet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* It encodes and decodes the OpenstackSubnet.
* Encodes and decodes the OpenstackSubnet.
*/
public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
private static Logger log = LoggerFactory
.getLogger(OpenstackSubnetCodec.class);
......@@ -52,7 +56,11 @@ public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
boolean enableDhcp = subnetInfo.path(ENABLE_DHCP).asBoolean();
String networkId = subnetInfo.path(NETWORK_ID).asText();
String tenantId = subnetInfo.path(TENANT_ID).asText();
String dnsNameservsers = subnetInfo.path(DNS_NAMESERVERS).asText();
ArrayNode dnsNameservsers = (ArrayNode) subnetInfo.path(DNS_NAMESERVERS);
List<Ip4Address> dnsList = Lists.newArrayList();
if (dnsNameservsers != null && !dnsNameservsers.isMissingNode()) {
dnsNameservsers.forEach(dns -> dnsList.add(Ip4Address.valueOf(dns.asText())));
}
String gatewayIp = subnetInfo.path(GATEWAY_IP).asText();
String cidr = subnetInfo.path(CIDR).asText();
String id = subnetInfo.path(ID).asText();
......@@ -62,7 +70,7 @@ public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
.setEnableDhcp(enableDhcp)
.setNetworkId(networkId)
.setTenantId(tenantId)
.setDnsNameservers(dnsNameservsers)
.setDnsNameservers(dnsList)
.setGatewayIp(gatewayIp)
.setCidr(cidr)
.setId(id)
......
......@@ -51,7 +51,7 @@ public class OpenstackSubnetWebResource extends AbstractWebResource {
OpenstackSwitchingService switchingService = get(OpenstackSwitchingService.class);
switchingService.createSubnet(openstackSubnet);
log.info("REST API subnets is called with {}", subnetNode.toString());
log.debug("REST API subnets is called with {}", subnetNode.toString());
return Response.status(Response.Status.OK).build();
} catch (Exception e) {
log.error("Creates VirtualSubnet failed because of exception {}",
......
......@@ -26,101 +26,18 @@
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-openstackswitching</artifactId>
<packaging>bundle</packaging>
<artifactId>onos-openstackswitching</artifactId>
<packaging>pom</packaging>
<description>SONA Openstack Switching applications</description>
<properties>
<onos.version>1.4.0-SNAPSHOT</onos.version>
<onos.app.name>org.onosproject.openstackswitching</onos.app.name>
<web.context>/onos/openstackswitching</web.context>
<api.version>1.0.0</api.version>
<api.title>ONOS OpenStack Switching REST API</api.title>
<api.description>
APIs for receiving Neutron information.
</api.description>
<api.package>org.onosproject.openstackswitching.web</api.package>
<onos.app.origin>SKT, Inc.</onos.app.origin>
</properties>
<description>SONA Openstack Switching application</description>
<modules>
<module>api</module>
<module>app</module>
</modules>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-dhcp-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_wab>src/main/webapp/</_wab>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Import-Package>
org.slf4j,
org.osgi.framework,
javax.ws.rs,
javax.ws.rs.core,
com.sun.jersey.api.core,
com.sun.jersey.spi.container.servlet,
com.sun.jersey.server.impl.container.servlet,
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.node,
com.fasterxml.jackson.core,
org.apache.karaf.shell.commands,
com.google.common.*,
org.onlab.packet.*,
org.onosproject.*
</Import-Package>
<Web-ContextPath>${web.context}</Web-ContextPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
......