mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-16 18:02:05 +02:00
Refactoring of OpenstackSwitching and OpenstackRouting
Change-Id: Ib7caea98006274dcdfebfe27c07e3533730ab23e
This commit is contained in:
parent
329a1276f0
commit
0c2a3daad4
@ -103,7 +103,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.onosproject</groupId>
|
<groupId>org.onosproject</groupId>
|
||||||
<artifactId>onos-app-openstackswitching-api</artifactId>
|
<artifactId>onos-app-openstacknetworking-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -19,8 +19,8 @@ import com.google.common.base.MoreObjects;
|
|||||||
import org.onlab.packet.IpAddress;
|
import org.onlab.packet.IpAddress;
|
||||||
import org.onlab.packet.IpPrefix;
|
import org.onlab.packet.IpPrefix;
|
||||||
import org.onosproject.net.Host;
|
import org.onosproject.net.Host;
|
||||||
import org.onosproject.openstackswitching.OpenstackNetwork;
|
import org.onosproject.openstacknetworking.OpenstackNetwork;
|
||||||
import org.onosproject.openstackswitching.OpenstackSubnet;
|
import org.onosproject.openstacknetworking.OpenstackSubnet;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -62,10 +62,10 @@ import org.onosproject.net.packet.PacketProcessor;
|
|||||||
import org.onosproject.net.packet.PacketService;
|
import org.onosproject.net.packet.PacketService;
|
||||||
import org.onosproject.net.provider.AbstractProvider;
|
import org.onosproject.net.provider.AbstractProvider;
|
||||||
import org.onosproject.net.provider.ProviderId;
|
import org.onosproject.net.provider.ProviderId;
|
||||||
import org.onosproject.openstackswitching.OpenstackNetwork;
|
import org.onosproject.openstacknetworking.OpenstackNetworkingService;
|
||||||
import org.onosproject.openstackswitching.OpenstackPort;
|
import org.onosproject.openstacknetworking.OpenstackNetwork;
|
||||||
import org.onosproject.openstackswitching.OpenstackSubnet;
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
import org.onosproject.openstackswitching.OpenstackSwitchingService;
|
import org.onosproject.openstacknetworking.OpenstackSubnet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -123,7 +123,7 @@ public class CordVtn extends AbstractProvider implements CordVtnService, HostPro
|
|||||||
protected GroupService groupService;
|
protected GroupService groupService;
|
||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
protected OpenstackSwitchingService openstackService;
|
protected OpenstackNetworkingService openstackService;
|
||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
protected DhcpService dhcpService;
|
protected DhcpService dhcpService;
|
||||||
|
@ -71,8 +71,8 @@ import org.onosproject.net.group.GroupBuckets;
|
|||||||
import org.onosproject.net.group.GroupDescription;
|
import org.onosproject.net.group.GroupDescription;
|
||||||
import org.onosproject.net.group.GroupKey;
|
import org.onosproject.net.group.GroupKey;
|
||||||
import org.onosproject.net.group.GroupService;
|
import org.onosproject.net.group.GroupService;
|
||||||
import org.onosproject.openstackswitching.OpenstackNetwork;
|
import org.onosproject.openstacknetworking.OpenstackNetwork;
|
||||||
import org.onosproject.openstackswitching.OpenstackSubnet;
|
import org.onosproject.openstacknetworking.OpenstackSubnet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
~ Copyright 2015 Open Networking Laboratory
|
~ Copyright 2016 Open Networking Laboratory
|
||||||
~
|
~
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ you may not use this file except in compliance with the License.
|
~ you may not use this file except in compliance with the License.
|
||||||
@ -16,35 +16,34 @@
|
|||||||
-->
|
-->
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.onosproject</groupId>
|
<groupId>org.onosproject</groupId>
|
||||||
<artifactId>onos-openstackswitching</artifactId>
|
<artifactId>onos-app-openstacknetworking</artifactId>
|
||||||
<version>1.5.0-SNAPSHOT</version>
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>onos-app-openstackswitching-api</artifactId>
|
<artifactId>onos-app-openstacknetworking-api</artifactId>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<description>SONA Openstack Switching application API</description>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.onosproject</groupId>
|
|
||||||
<artifactId>onos-api</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.osgi</groupId>
|
<groupId>org.osgi</groupId>
|
||||||
<artifactId>org.osgi.compendium</artifactId>
|
<artifactId>org.osgi.compendium</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.osgi</groupId>
|
<groupId>org.onosproject</groupId>
|
||||||
<artifactId>org.osgi.core</artifactId>
|
<artifactId>onos-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-core-serializers</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.google.common.collect.Maps;
|
||||||
|
import org.onlab.packet.Ip4Address;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A configurable external gateway modes extension model in openstack router.
|
||||||
|
*/
|
||||||
|
public final class OpenstackExternalGateway {
|
||||||
|
|
||||||
|
private final String networkId;
|
||||||
|
private final boolean enablePnat;
|
||||||
|
private final Map<String, Ip4Address> externalFixedIps;
|
||||||
|
|
||||||
|
private OpenstackExternalGateway(String networkId, boolean enablePnat,
|
||||||
|
Map<String, Ip4Address> externalFixedIps) {
|
||||||
|
this.networkId = networkId;
|
||||||
|
this.enablePnat = enablePnat;
|
||||||
|
this.externalFixedIps = externalFixedIps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns network ID.
|
||||||
|
*
|
||||||
|
* @return Network ID
|
||||||
|
*/
|
||||||
|
public String networkId() {
|
||||||
|
return networkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the PNAT status for external gateway.
|
||||||
|
*
|
||||||
|
* @return PNAT status
|
||||||
|
*/
|
||||||
|
public boolean isEnablePnat() {
|
||||||
|
return enablePnat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns external fixed IP informations.
|
||||||
|
*
|
||||||
|
* @return External fixed IP informations
|
||||||
|
*/
|
||||||
|
public Map<String, Ip4Address> externalFixedIps() {
|
||||||
|
return externalFixedIps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof OpenstackExternalGateway) {
|
||||||
|
OpenstackExternalGateway that = (OpenstackExternalGateway) o;
|
||||||
|
|
||||||
|
return this.networkId.equals(that.networkId) &&
|
||||||
|
this.enablePnat == that.enablePnat &&
|
||||||
|
this.externalFixedIps.equals(that.externalFixedIps);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(networkId, enablePnat, externalFixedIps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Openstack External Gateway Builder class.
|
||||||
|
*/
|
||||||
|
public static final class Builder {
|
||||||
|
private String networkId;
|
||||||
|
private boolean enablePnat;
|
||||||
|
private Map<String, Ip4Address> externalFixedIps;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
externalFixedIps = Maps.newHashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets network ID.
|
||||||
|
*
|
||||||
|
* @param networkId Network ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder networkId(String networkId) {
|
||||||
|
this.networkId = networkId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether PNAT status is enabled or not.
|
||||||
|
*
|
||||||
|
* @param enablePnat true if PNAT status is enabled, false otherwise
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder enablePnat(boolean enablePnat) {
|
||||||
|
this.enablePnat = enablePnat;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets external fixed IP address information.
|
||||||
|
*
|
||||||
|
* @param externalFixedIps External fixed IP information
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Builder externalFixedIps(Map<String, Ip4Address> externalFixedIps) {
|
||||||
|
this.externalFixedIps.putAll(externalFixedIps);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds an OpenstackExternalGateway object.
|
||||||
|
*
|
||||||
|
* @return OpenstackExternalGateway object
|
||||||
|
*/
|
||||||
|
public OpenstackExternalGateway build() {
|
||||||
|
return new OpenstackExternalGateway(networkId, enablePnat, externalFixedIps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,266 @@
|
|||||||
|
/*
|
||||||
|
* 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.onlab.packet.Ip4Address;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Openstack Neutron Floating IP Model.
|
||||||
|
*/
|
||||||
|
public final class OpenstackFloatingIP {
|
||||||
|
|
||||||
|
public enum FloatingIPStatus {
|
||||||
|
UP,
|
||||||
|
DOWN,
|
||||||
|
ACTIVE,
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String tenantId;
|
||||||
|
private final String networkId;
|
||||||
|
private final Ip4Address fixedIpAddress;
|
||||||
|
private final String portId;
|
||||||
|
private final String routerId;
|
||||||
|
private final String id;
|
||||||
|
private final Ip4Address floatingIpAddress;
|
||||||
|
private final FloatingIPStatus status;
|
||||||
|
|
||||||
|
private OpenstackFloatingIP(FloatingIPStatus status, String id, String tenantId,
|
||||||
|
String networkId, Ip4Address fixedIpAddress, String portId,
|
||||||
|
String routerId, Ip4Address floatingIpAddress) {
|
||||||
|
this.status = status;
|
||||||
|
this.id = id;
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
this.networkId = networkId;
|
||||||
|
this.fixedIpAddress = fixedIpAddress;
|
||||||
|
this.portId = portId;
|
||||||
|
this.routerId = routerId;
|
||||||
|
this.floatingIpAddress = floatingIpAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns floating IP status.
|
||||||
|
*
|
||||||
|
* @return floating IP status
|
||||||
|
*/
|
||||||
|
public FloatingIPStatus status() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns floating IP`s ID.
|
||||||
|
*
|
||||||
|
* @return floating IP`s ID
|
||||||
|
*/
|
||||||
|
public String id() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns tenant ID.
|
||||||
|
*
|
||||||
|
* @return tenant ID
|
||||||
|
*/
|
||||||
|
public String tenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns network ID.
|
||||||
|
*
|
||||||
|
* @return network ID
|
||||||
|
*/
|
||||||
|
public String networkId() {
|
||||||
|
return networkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns fixed IP Address.
|
||||||
|
*
|
||||||
|
* @return fixed IP Address
|
||||||
|
*/
|
||||||
|
public Ip4Address fixedIpAddress() {
|
||||||
|
return fixedIpAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns port ID.
|
||||||
|
*
|
||||||
|
* @return port ID
|
||||||
|
*/
|
||||||
|
public String portId() {
|
||||||
|
return portId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns router ID.
|
||||||
|
*
|
||||||
|
* @return router ID
|
||||||
|
*/
|
||||||
|
public String routerId() {
|
||||||
|
return routerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns floating IP address.
|
||||||
|
*
|
||||||
|
* @return Floating IP address
|
||||||
|
*/
|
||||||
|
public Ip4Address floatingIpAddress() {
|
||||||
|
return floatingIpAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof OpenstackFloatingIP) {
|
||||||
|
OpenstackFloatingIP that = (OpenstackFloatingIP) o;
|
||||||
|
|
||||||
|
return this.status.equals(that.status) &&
|
||||||
|
this.id.equals(that.id) &&
|
||||||
|
this.tenantId.equals(that.tenantId) &&
|
||||||
|
this.networkId.equals(that.networkId) &&
|
||||||
|
this.fixedIpAddress.equals(that.fixedIpAddress) &&
|
||||||
|
this.floatingIpAddress.equals(that.floatingIpAddress) &&
|
||||||
|
this.portId.equals(that.portId) &&
|
||||||
|
this.routerId.equals(that.routerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(status, id, tenantId, networkId, floatingIpAddress, fixedIpAddress, portId, routerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Openstack Floating IP Builder class.
|
||||||
|
*/
|
||||||
|
public static final class Builder {
|
||||||
|
private String tenantId;
|
||||||
|
private String networkId;
|
||||||
|
private Ip4Address fixedIpAddress;
|
||||||
|
private String portId;
|
||||||
|
private String routerId;
|
||||||
|
private String id;
|
||||||
|
private Ip4Address floatingIpAddress;
|
||||||
|
private FloatingIPStatus status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets tenant ID.
|
||||||
|
*
|
||||||
|
* @param tenantId tenant ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder tenantId(String tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets floating IP status.
|
||||||
|
*
|
||||||
|
* @param status Floating IP status
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder status(FloatingIPStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Floating IP`s ID.
|
||||||
|
*
|
||||||
|
* @param id Floating IP`s ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets network ID.
|
||||||
|
*
|
||||||
|
* @param networkId Network ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder networkId(String networkId) {
|
||||||
|
this.networkId = networkId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets fixed IP address.
|
||||||
|
*
|
||||||
|
* @param fixedIpAddress Fixed IP address
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder fixedIpAddress(Ip4Address fixedIpAddress) {
|
||||||
|
this.fixedIpAddress = fixedIpAddress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets port ID.
|
||||||
|
*
|
||||||
|
* @param portId port ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder portId(String portId) {
|
||||||
|
this.portId = portId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets router ID.
|
||||||
|
*
|
||||||
|
* @param routerId router ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder routerId(String routerId) {
|
||||||
|
this.routerId = routerId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets floating IP address.
|
||||||
|
*
|
||||||
|
* @param floatingIpAddress Floating IP address
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder floatingIpAddress(Ip4Address floatingIpAddress) {
|
||||||
|
this.floatingIpAddress = floatingIpAddress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds an OpenstackFloatingIP object.
|
||||||
|
*
|
||||||
|
* @return OpenstackFloatingIP object
|
||||||
|
*/
|
||||||
|
public OpenstackFloatingIP build() {
|
||||||
|
return new OpenstackFloatingIP(status, id, tenantId, networkId,
|
||||||
|
fixedIpAddress, portId, routerId, floatingIpAddress);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching;
|
package org.onosproject.openstacknetworking;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking;
|
||||||
|
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.net.config.Config;
|
import org.onosproject.net.config.Config;
|
||||||
@ -22,7 +22,7 @@ import org.onosproject.net.config.basics.BasicElementConfig;
|
|||||||
/**
|
/**
|
||||||
* Handles configuration for OpenstackSwitching app.
|
* Handles configuration for OpenstackSwitching app.
|
||||||
*/
|
*/
|
||||||
public class OpenstackSwitchingConfig extends Config<ApplicationId> {
|
public class OpenstackNetworkingConfig extends Config<ApplicationId> {
|
||||||
public static final String DONOTPUSH = "do_not_push_flows";
|
public static final String DONOTPUSH = "do_not_push_flows";
|
||||||
public static final String NEUTRON_SERVER = "neutron_server";
|
public static final String NEUTRON_SERVER = "neutron_server";
|
||||||
public static final String KEYSTONE_SERVER = "keystone_server";
|
public static final String KEYSTONE_SERVER = "keystone_server";
|
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015-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.Port;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles port management REST API from Openstack for VMs.
|
||||||
|
*/
|
||||||
|
public interface OpenstackNetworkingService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 list.
|
||||||
|
*
|
||||||
|
* @return port information list
|
||||||
|
*/
|
||||||
|
Collection<OpenstackPort> ports();
|
||||||
|
/**
|
||||||
|
* Returns port information for the port given.
|
||||||
|
*
|
||||||
|
* @param port port reference
|
||||||
|
* @return port information
|
||||||
|
*/
|
||||||
|
OpenstackPort port(Port port);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, or null if not present
|
||||||
|
*/
|
||||||
|
OpenstackNetwork network(String networkId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the information of all openstack networks.
|
||||||
|
*
|
||||||
|
* @return collection of network information
|
||||||
|
*/
|
||||||
|
Collection<OpenstackNetwork> networks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns subnet information for the subnet ID give.
|
||||||
|
*
|
||||||
|
* @param subnetId Subnet ID
|
||||||
|
* @return subnet information, or null if not present
|
||||||
|
*/
|
||||||
|
OpenstackSubnet subnet(String subnetId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns collection of openstack subnet information.
|
||||||
|
*
|
||||||
|
* @return collection of openststack subnet information
|
||||||
|
*/
|
||||||
|
Collection<OpenstackSubnet> subnets();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the router information list.
|
||||||
|
*
|
||||||
|
* @return router information list
|
||||||
|
*/
|
||||||
|
Collection<OpenstackRouter> routers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the router information for the router ID given.
|
||||||
|
*
|
||||||
|
* @param routerId router ID
|
||||||
|
* @return router information
|
||||||
|
*/
|
||||||
|
OpenstackRouter router(String routerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retruns OpenstackPortInfo map.
|
||||||
|
*
|
||||||
|
* @return OpenstackPortInfo map
|
||||||
|
*/
|
||||||
|
Map<String, OpenstackPortInfo> openstackPortInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets configurations specified by net-config.xml file.
|
||||||
|
*
|
||||||
|
* @param neutronUrl neutron server url
|
||||||
|
* @param keystoneUrl keystone server url
|
||||||
|
* @param userName horizon user name
|
||||||
|
* @param pass horizon passowrd
|
||||||
|
*/
|
||||||
|
void setConfigurations(String neutronUrl, String keystoneUrl, String userName, String pass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns Security Group information of the security groupd id given.
|
||||||
|
*
|
||||||
|
* @param id security group id
|
||||||
|
* @return security group information
|
||||||
|
*/
|
||||||
|
OpenstackSecurityGroup getSecurityGroup(String id);
|
||||||
|
|
||||||
|
}
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching;
|
package org.onosproject.openstacknetworking;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import org.onlab.packet.Ip4Address;
|
import org.onlab.packet.Ip4Address;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching;
|
package org.onosproject.openstacknetworking;
|
||||||
|
|
||||||
import org.onlab.packet.Ip4Address;
|
import org.onlab.packet.Ip4Address;
|
||||||
import org.onlab.packet.MacAddress;
|
import org.onlab.packet.MacAddress;
|
@ -0,0 +1,218 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Openstack Neutron Router Model.
|
||||||
|
*/
|
||||||
|
public final class OpenstackRouter {
|
||||||
|
|
||||||
|
public enum RouterStatus {
|
||||||
|
UP,
|
||||||
|
DOWN,
|
||||||
|
ACTIVE,
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String tenantId;
|
||||||
|
private final String id;
|
||||||
|
private final String name;
|
||||||
|
private final RouterStatus status;
|
||||||
|
private final boolean adminStateUp;
|
||||||
|
private final OpenstackExternalGateway gatewayExternalInfo;
|
||||||
|
|
||||||
|
private OpenstackRouter(String id, String tenantId, String name, RouterStatus status,
|
||||||
|
boolean adminStateUp, OpenstackExternalGateway gatewayExternalInfo) {
|
||||||
|
this.id = id;
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
this.name = name;
|
||||||
|
this.status = status;
|
||||||
|
this.adminStateUp = adminStateUp;
|
||||||
|
this.gatewayExternalInfo = gatewayExternalInfo;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns tenant ID.
|
||||||
|
*
|
||||||
|
* @return tenant ID
|
||||||
|
*/
|
||||||
|
public String tenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns router ID.
|
||||||
|
*
|
||||||
|
* @return router ID
|
||||||
|
*/
|
||||||
|
public String id() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns router name.
|
||||||
|
*
|
||||||
|
* @return router name
|
||||||
|
*/
|
||||||
|
public String name() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns router status.
|
||||||
|
*
|
||||||
|
* @return router stauts
|
||||||
|
*/
|
||||||
|
public RouterStatus status() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether admin state up or not.
|
||||||
|
*
|
||||||
|
* @return true if admin state up, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean adminStateUp() {
|
||||||
|
return adminStateUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns external gateway information.
|
||||||
|
*
|
||||||
|
* @return external gateway information
|
||||||
|
*/
|
||||||
|
public OpenstackExternalGateway gatewayExternalInfo() {
|
||||||
|
return gatewayExternalInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof OpenstackRouter) {
|
||||||
|
OpenstackRouter that = (OpenstackRouter) o;
|
||||||
|
|
||||||
|
return this.adminStateUp == that.adminStateUp &&
|
||||||
|
this.gatewayExternalInfo.equals(that.gatewayExternalInfo) &&
|
||||||
|
this.id.equals(that.id) &&
|
||||||
|
this.name.equals(that.name) &&
|
||||||
|
this.status.equals(that.status) &&
|
||||||
|
this.tenantId.equals(that.tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(adminStateUp, gatewayExternalInfo, id, name, status, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Openstack Router Builder class.
|
||||||
|
*/
|
||||||
|
public static final class Builder {
|
||||||
|
|
||||||
|
private String tenantId;
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private RouterStatus status;
|
||||||
|
private Boolean adminStateUp;
|
||||||
|
private OpenstackExternalGateway gatewayExternalInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets router ID.
|
||||||
|
*
|
||||||
|
* @param id router ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets router name.
|
||||||
|
*
|
||||||
|
* @param name router name
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets router status.
|
||||||
|
*
|
||||||
|
* @param status router status
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder status(RouterStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets tenant ID.
|
||||||
|
*
|
||||||
|
* @param tenantId Tenant ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder tenantId(String tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether admin state up or not.
|
||||||
|
*
|
||||||
|
* @param adminStateUp true if admin state is up, false otherwise
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder adminStateUp(boolean adminStateUp) {
|
||||||
|
this.adminStateUp = adminStateUp;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets external gateway information.
|
||||||
|
*
|
||||||
|
* @param gatewayExternalInfo external gateway information
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder gatewayExternalInfo(OpenstackExternalGateway gatewayExternalInfo) {
|
||||||
|
this.gatewayExternalInfo = gatewayExternalInfo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds an OpenstackRouter object.
|
||||||
|
*
|
||||||
|
* @return OpenstasckRouter object
|
||||||
|
*/
|
||||||
|
public OpenstackRouter build() {
|
||||||
|
return new OpenstackRouter(id, tenantId, name, status,
|
||||||
|
adminStateUp, gatewayExternalInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* 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 java.util.Objects;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Openstack Neutron Router Interface Model.
|
||||||
|
*/
|
||||||
|
public final class OpenstackRouterInterface {
|
||||||
|
private final String id;
|
||||||
|
private final String tenantId;
|
||||||
|
private final String subnetId;
|
||||||
|
private final String portId;
|
||||||
|
|
||||||
|
private OpenstackRouterInterface(String id, String tenantId,
|
||||||
|
String subnetId, String portId) {
|
||||||
|
this.id = checkNotNull(id);
|
||||||
|
this.tenantId = checkNotNull(tenantId);
|
||||||
|
this.subnetId = checkNotNull(subnetId);
|
||||||
|
this.portId = checkNotNull(portId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns Router Interface ID.
|
||||||
|
*
|
||||||
|
* @return router interface ID
|
||||||
|
*/
|
||||||
|
public String id() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns tenant ID.
|
||||||
|
*
|
||||||
|
* @return tenant ID
|
||||||
|
*/
|
||||||
|
public String tenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns subnet ID.
|
||||||
|
*
|
||||||
|
* @return subnet ID
|
||||||
|
*/
|
||||||
|
public String subnetId() {
|
||||||
|
return subnetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns port ID.
|
||||||
|
*
|
||||||
|
* @return port ID
|
||||||
|
*/
|
||||||
|
public String portId() {
|
||||||
|
return portId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o instanceof OpenstackRouterInterface) {
|
||||||
|
OpenstackRouterInterface that = (OpenstackRouterInterface) o;
|
||||||
|
|
||||||
|
return this.id.equals(that.id) &&
|
||||||
|
this.portId.equals(that.portId) &&
|
||||||
|
this.subnetId.equals(that.subnetId) &&
|
||||||
|
this.tenantId.equals(that.tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, portId, subnetId, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Openstack Router Interface Builder class.
|
||||||
|
*/
|
||||||
|
public static final class Builder {
|
||||||
|
private String id;
|
||||||
|
private String tenantId;
|
||||||
|
private String subnetId;
|
||||||
|
private String portId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Router Interface ID.
|
||||||
|
*
|
||||||
|
* @param id router interface ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets tenant ID.
|
||||||
|
*
|
||||||
|
* @param tenantId tenant ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder tenantId(String tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets subnet ID.
|
||||||
|
*
|
||||||
|
* @param subnetId subnet ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder subnetId(String subnetId) {
|
||||||
|
this.subnetId = subnetId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets port ID.
|
||||||
|
*
|
||||||
|
* @param portId port ID
|
||||||
|
* @return Builder object
|
||||||
|
*/
|
||||||
|
public Builder portId(String portId) {
|
||||||
|
this.portId = portId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds an Openstack Router Interface object.
|
||||||
|
*
|
||||||
|
* @return OpenstackRouterInterface object
|
||||||
|
*/
|
||||||
|
public OpenstackRouterInterface build() {
|
||||||
|
return new OpenstackRouterInterface(id, tenantId, subnetId, portId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface of Openstack Routing.
|
||||||
|
*/
|
||||||
|
public interface OpenstackRoutingService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the Floating IP information created by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackFloatingIP Floating IP information
|
||||||
|
*/
|
||||||
|
void createFloatingIP(OpenstackFloatingIP openstackFloatingIP);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates flow rules corresponding to the Floating IP information updated by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackFloatingIP Floating IP information
|
||||||
|
*/
|
||||||
|
void updateFloatingIP(OpenstackFloatingIP openstackFloatingIP);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes flow rules corresponding to Floating IP information removed by Openstack.
|
||||||
|
*
|
||||||
|
* @param id Deleted Floating IP`s ID
|
||||||
|
*/
|
||||||
|
void deleteFloatingIP(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the router information created by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackRouter Floating IP information
|
||||||
|
*/
|
||||||
|
void createRouter(OpenstackRouter openstackRouter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates flow rules corresponding to the router information updated by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackRouter Router information
|
||||||
|
*/
|
||||||
|
void updateRouter(OpenstackRouter openstackRouter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes flow rules corresponding to the router information removed by Openstack.
|
||||||
|
*
|
||||||
|
* @param id Deleted router`s ID
|
||||||
|
*/
|
||||||
|
void deleteRouter(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates flow rules corresponding to the router information updated by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackRouterInterface Router information
|
||||||
|
*/
|
||||||
|
void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes flow rules corresponding to the router information removed by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackRouterInterface Router information
|
||||||
|
*/
|
||||||
|
void removeRouterInterface(OpenstackRouterInterface openstackRouterInterface);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -112,7 +112,7 @@ public final class OpenstackSecurityGroup {
|
|||||||
this.rules.containsAll(that.rules);
|
this.rules.containsAll(that.rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -13,23 +13,27 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents Openstack Security Group Rules.
|
* Represents Openstack Security Group Rules.
|
||||||
*/
|
*/
|
||||||
public final class OpenstackSecurityGroupRule {
|
public final class OpenstackSecurityGroupRule {
|
||||||
|
|
||||||
private String direction;
|
private final String direction;
|
||||||
private String ethertype;
|
private final String ethertype;
|
||||||
private String id;
|
private final String id;
|
||||||
private String portRangeMax;
|
private final String portRangeMax;
|
||||||
private String portRangeMin;
|
private final String portRangeMin;
|
||||||
private String protocol;
|
private final String protocol;
|
||||||
private String remoteGroupId;
|
private final String remoteGroupId;
|
||||||
private String remoteIpPrefix;
|
private final String remoteIpPrefix;
|
||||||
private String secuityGroupId;
|
private final String secuityGroupId;
|
||||||
private String tenantId;
|
private final String tenantId;
|
||||||
|
|
||||||
private OpenstackSecurityGroupRule(String direction,
|
private OpenstackSecurityGroupRule(String direction,
|
||||||
String ethertype,
|
String ethertype,
|
||||||
@ -43,7 +47,7 @@ public final class OpenstackSecurityGroupRule {
|
|||||||
String tenantId) {
|
String tenantId) {
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
this.ethertype = ethertype;
|
this.ethertype = ethertype;
|
||||||
this.id = id;
|
this.id = checkNotNull(id);
|
||||||
this.portRangeMax = portRangeMax;
|
this.portRangeMax = portRangeMax;
|
||||||
this.portRangeMin = portRangeMin;
|
this.portRangeMin = portRangeMin;
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
@ -53,15 +57,6 @@ public final class OpenstackSecurityGroupRule {
|
|||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the builder object for the OpenstackSecurityGroupRule.
|
|
||||||
*
|
|
||||||
* @return OpenstackSecurityGroupRule builder object
|
|
||||||
*/
|
|
||||||
public static OpenstackSecurityGroupRule.Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuilder(" [")
|
return new StringBuilder(" [")
|
||||||
@ -78,6 +73,35 @@ public final class OpenstackSecurityGroupRule {
|
|||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this instanceof OpenstackSecurityGroupRule) {
|
||||||
|
OpenstackSecurityGroupRule that = (OpenstackSecurityGroupRule) o;
|
||||||
|
return this.direction.equals(that.direction) &&
|
||||||
|
this.ethertype.equals(that.direction) &&
|
||||||
|
this.id.equals(that.id) &&
|
||||||
|
this.portRangeMax.equals(that.portRangeMax) &&
|
||||||
|
this.portRangeMin.equals(that.portRangeMin) &&
|
||||||
|
this.protocol.equals(that.protocol) &&
|
||||||
|
this.remoteGroupId.equals(that.remoteGroupId) &&
|
||||||
|
this.secuityGroupId.equals(that.secuityGroupId) &&
|
||||||
|
this.remoteIpPrefix.equals(that.remoteIpPrefix) &&
|
||||||
|
this.tenantId.equals(that.tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(direction, ethertype, id, portRangeMax, portRangeMin, protocol,
|
||||||
|
remoteGroupId, remoteIpPrefix, secuityGroupId, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a security group rule builder object.
|
* Represents a security group rule builder object.
|
||||||
*/
|
*/
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching;
|
package org.onosproject.openstacknetworking;
|
||||||
|
|
||||||
import org.onlab.packet.Ip4Address;
|
import org.onlab.packet.Ip4Address;
|
||||||
|
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015-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 java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles port management REST API from Openstack for VMs.
|
||||||
|
*/
|
||||||
|
public interface OpenstackSwitchingService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the port information created by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackPort port information
|
||||||
|
*/
|
||||||
|
void createPorts(OpenstackPort openstackPort);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes flow rules corresponding to the port removed by Openstack.
|
||||||
|
*
|
||||||
|
* @param uuid UUID
|
||||||
|
*/
|
||||||
|
void removePort(String uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates flow rules corresponding to the port information updated by Openstack.
|
||||||
|
*
|
||||||
|
* @param openstackPort OpenStack port
|
||||||
|
*/
|
||||||
|
void updatePort(OpenstackPort openstackPort);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the network information created by openstack.
|
||||||
|
*
|
||||||
|
* @param openstackNetwork network information
|
||||||
|
*/
|
||||||
|
void createNetwork(OpenstackNetwork openstackNetwork);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the subnet information created by openstack.
|
||||||
|
*
|
||||||
|
* @param openstackSubnet subnet information
|
||||||
|
*/
|
||||||
|
void createSubnet(OpenstackSubnet openstackSubnet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retruns OpenstackPortInfo map.
|
||||||
|
*
|
||||||
|
* @return OpenstackPortInfo map
|
||||||
|
*/
|
||||||
|
Map<String, OpenstackPortInfo> openstackPortInfo();
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015 Open Networking Laboratory
|
* Copyright 2016 Open Networking Laboratory
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -15,6 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OpenStack switching REST API.
|
* Application for OpenstackRouting.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking;
|
@ -14,12 +14,15 @@
|
|||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<app name="org.onosproject.openstackswitching" origin="ON.Lab" version="${project.version}"
|
<app name="org.onosproject.openstacknetworking" origin="ON.Lab" version="${project.version}"
|
||||||
category="default" url="http://onosproject.org"
|
category="default" url="http://onosproject.org"
|
||||||
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
|
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
|
||||||
features="${project.artifactId}">
|
features="${project.artifactId}">
|
||||||
<description>${project.description}</description>
|
<description>${project.description}</description>
|
||||||
|
<artifact>mvn:${project.groupId}/onos-app-openstacknetworking-api/${project.version}</artifact>
|
||||||
|
<artifact>mvn:${project.groupId}/onos-app-openstacknetworking-web/${project.version}</artifact>
|
||||||
<artifact>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</artifact>
|
<artifact>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</artifact>
|
||||||
|
<artifact>mvn:${project.groupId}/onos-app-openstackrouting/${project.version}</artifact>
|
||||||
<artifact>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</artifact>
|
<artifact>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</artifact>
|
||||||
<artifact>mvn:${project.groupId}/onos-app-dhcp/${project.version}</artifact>
|
<artifact>mvn:${project.groupId}/onos-app-dhcp/${project.version}</artifact>
|
||||||
</app>
|
</app>
|
@ -18,7 +18,8 @@
|
|||||||
<feature name="${project.artifactId}" version="${project.version}"
|
<feature name="${project.artifactId}" version="${project.version}"
|
||||||
description="${project.description}">
|
description="${project.description}">
|
||||||
<feature>onos-api</feature>
|
<feature>onos-api</feature>
|
||||||
<bundle>mvn:${project.groupId}/onos-app-openstackswitching-api/${project.version}</bundle>
|
<bundle>mvn:${project.groupId}/onos-app-openstacknetworking-api/${project.version}</bundle>
|
||||||
|
<bundle>mvn:${project.groupId}/onos-app-openstacknetworking-web/${project.version}</bundle>
|
||||||
<bundle>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</bundle>
|
<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-api/${project.version}</bundle>
|
||||||
<bundle>mvn:${project.groupId}/onos-app-dhcp/${project.version}</bundle>
|
<bundle>mvn:${project.groupId}/onos-app-dhcp/${project.version}</bundle>
|
63
apps/openstacknetworking/app/pom.xml
Normal file
63
apps/openstacknetworking/app/pom.xml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstacknetworking</artifactId>
|
||||||
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>onos-app-openstacknetworking-app</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<onos.app.name>org.onosproject.openstacknetworking</onos.app.name>
|
||||||
|
<onos.app.category>default</onos.app.category>
|
||||||
|
<onos.app.url>http://onosproject.org</onos.app.url>
|
||||||
|
<onos.app.readme>Openstack Networking Application.</onos.app.readme>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<description>SONA Openstack Networking main Application</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstackswitching</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstackrouting</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstacknetworking-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstacknetworking-web</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
51
apps/openstacknetworking/network-cfg.json
Normal file
51
apps/openstacknetworking/network-cfg.json
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"apps" : {
|
||||||
|
"org.onosproject.openstackswitching" : {
|
||||||
|
"openstackswitching" : {
|
||||||
|
"do_not_push_flows" : "false",
|
||||||
|
"neutron_server" : "http://192.168.56.103:9696/v2.0/",
|
||||||
|
"keystone_server" : "http://192.168.56.103:5000/v2.0/",
|
||||||
|
"user_name" : "admin",
|
||||||
|
"password" : "nova",
|
||||||
|
"physicalRouterMac" : "00:00:00:00:00:20",
|
||||||
|
"nodes" : [
|
||||||
|
{
|
||||||
|
"hostname" : "compute-01",
|
||||||
|
"ovsdbIp" : "192.168.56.102",
|
||||||
|
"ovsdbPort" : "6640",
|
||||||
|
"bridgeId" : "of:0000000000000001",
|
||||||
|
"openstackNodeType" : "COMPUTENODE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname" : "compute-02",
|
||||||
|
"ovsdbIp" : "192.168.56.101",
|
||||||
|
"ovsdbPort" : "6640",
|
||||||
|
"bridgeId" : "of:0000000000000002",
|
||||||
|
"openstackNodeType" : "COMPUTENODE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname" : "network",
|
||||||
|
"ovsdbIp" : "192.168.56.106",
|
||||||
|
"ovsdbPort" : "6640",
|
||||||
|
"bridgeId" : "of:0000000000000003",
|
||||||
|
"openstackNodeType" : "GATEWAYNODE",
|
||||||
|
"externalIfName" : "eth3",
|
||||||
|
"externalIfMacAddress" : "00:00:00:00:00:11"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devices" : {
|
||||||
|
"of:0000000000000001" : {
|
||||||
|
"basic" : {
|
||||||
|
"driver" : "sona"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"of:0000000000000002" : {
|
||||||
|
"basic" : {
|
||||||
|
"driver" : "sona"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
apps/openstacknetworking/openstackrouting/pom.xml
Normal file
54
apps/openstacknetworking/openstackrouting/pom.xml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstacknetworking</artifactId>
|
||||||
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>onos-app-openstackrouting</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.osgi</groupId>
|
||||||
|
<artifactId>org.osgi.compendium</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-core-serializers</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstacknetworking-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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.routing;
|
||||||
|
|
||||||
|
import org.onosproject.event.AbstractEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle FloatingIP Event for Managing Flow Rules In Openstack Nodes.
|
||||||
|
*/
|
||||||
|
public class OpenstackFloatingIPHandler implements Runnable {
|
||||||
|
|
||||||
|
volatile AbstractEvent event;
|
||||||
|
OpenstackFloatingIPHandler(AbstractEvent event) {
|
||||||
|
this.event = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.routing;
|
||||||
|
|
||||||
|
import org.onosproject.net.packet.PacketContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ICMP packet processing for Managing Flow Rules In Openstack Nodes.
|
||||||
|
*/
|
||||||
|
public class OpenstackIcmpHandler implements Runnable {
|
||||||
|
|
||||||
|
volatile PacketContext context;
|
||||||
|
private OpenstackRoutingRulePopulator rulePopulator;
|
||||||
|
OpenstackIcmpHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context) {
|
||||||
|
this.context = context;
|
||||||
|
this.rulePopulator = rulePopulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* 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.routing;
|
||||||
|
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
|
import org.onlab.packet.IPv4;
|
||||||
|
import org.onlab.packet.MacAddress;
|
||||||
|
import org.onlab.packet.TCP;
|
||||||
|
import org.onlab.packet.UDP;
|
||||||
|
import org.onosproject.net.DeviceId;
|
||||||
|
import org.onosproject.net.PortNumber;
|
||||||
|
import org.onosproject.net.flow.DefaultTrafficTreatment;
|
||||||
|
import org.onosproject.net.flow.TrafficTreatment;
|
||||||
|
import org.onosproject.net.packet.DefaultOutboundPacket;
|
||||||
|
import org.onosproject.net.packet.InboundPacket;
|
||||||
|
import org.onosproject.net.packet.PacketContext;
|
||||||
|
import org.onosproject.net.packet.PacketService;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle NAT packet processing for Managing Flow Rules In Openstack Nodes.
|
||||||
|
*/
|
||||||
|
public class OpenstackPnatHandler implements Runnable {
|
||||||
|
|
||||||
|
volatile PacketContext context;
|
||||||
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
|
protected PacketService packetService;
|
||||||
|
|
||||||
|
private final OpenstackRoutingRulePopulator rulePopulator;
|
||||||
|
private final int portNum;
|
||||||
|
private final OpenstackPort openstackPort;
|
||||||
|
|
||||||
|
OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context,
|
||||||
|
int portNum, OpenstackPort openstackPort) {
|
||||||
|
this.rulePopulator = checkNotNull(rulePopulator);
|
||||||
|
this.context = checkNotNull(context);
|
||||||
|
this.portNum = checkNotNull(portNum);
|
||||||
|
this.openstackPort = checkNotNull(openstackPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
InboundPacket inboundPacket = context.inPacket();
|
||||||
|
Ethernet ethernet = checkNotNull(inboundPacket.parsed());
|
||||||
|
|
||||||
|
//TODO: Considers IPV6
|
||||||
|
if (ethernet.getEtherType() != Ethernet.TYPE_IPV4) {
|
||||||
|
log.warn("Now, we just consider IP version 4");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
packetOut(inboundPacket, portNum);
|
||||||
|
|
||||||
|
rulePopulator.populatePnatFlowRules(inboundPacket, openstackPort, portNum,
|
||||||
|
getExternalInterfaceMacAddress(), getExternalRouterMacAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void packetOut(InboundPacket inboundPacket, int portNum) {
|
||||||
|
Ethernet ethernet = checkNotNull(inboundPacket.parsed());
|
||||||
|
IPv4 iPacket = (IPv4) ethernet.getPayload();
|
||||||
|
|
||||||
|
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
|
||||||
|
|
||||||
|
switch (iPacket.getProtocol()) {
|
||||||
|
case IPv4.PROTOCOL_TCP:
|
||||||
|
TCP tcpPacket = (TCP) iPacket.getPayload();
|
||||||
|
tcpPacket.setSourcePort(portNum);
|
||||||
|
tcpPacket.resetChecksum();
|
||||||
|
tcpPacket.setParent(iPacket);
|
||||||
|
iPacket.setPayload(tcpPacket);
|
||||||
|
break;
|
||||||
|
case IPv4.PROTOCOL_UDP:
|
||||||
|
UDP udpPacket = (UDP) iPacket.getPayload();
|
||||||
|
udpPacket.setSourcePort(portNum);
|
||||||
|
udpPacket.resetChecksum();
|
||||||
|
udpPacket.setParent(iPacket);
|
||||||
|
iPacket.setPayload(udpPacket);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
iPacket.resetChecksum();
|
||||||
|
iPacket.setPayload(ethernet);
|
||||||
|
ethernet.setSourceMACAddress(getExternalInterfaceMacAddress())
|
||||||
|
.setDestinationMACAddress(getExternalRouterMacAddress());
|
||||||
|
ethernet.resetChecksum();
|
||||||
|
|
||||||
|
treatment.setOutput(getExternalPort(inboundPacket.receivedFrom().deviceId()));
|
||||||
|
|
||||||
|
packetService.emit(new DefaultOutboundPacket(inboundPacket.receivedFrom().deviceId(),
|
||||||
|
treatment.build(), ByteBuffer.wrap(ethernet.serialize())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private PortNumber getExternalPort(DeviceId deviceId) {
|
||||||
|
// TODO
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private MacAddress getExternalInterfaceMacAddress() {
|
||||||
|
// TODO
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private MacAddress getExternalRouterMacAddress() {
|
||||||
|
// TODO
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
* 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.routing;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
|
import org.apache.felix.scr.annotations.Component;
|
||||||
|
import org.apache.felix.scr.annotations.Deactivate;
|
||||||
|
import org.apache.felix.scr.annotations.Reference;
|
||||||
|
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||||
|
import org.apache.felix.scr.annotations.Service;
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
|
import org.onlab.packet.IPv4;
|
||||||
|
import org.onlab.packet.Ip4Address;
|
||||||
|
import org.onlab.packet.MacAddress;
|
||||||
|
import org.onosproject.core.ApplicationId;
|
||||||
|
import org.onosproject.core.CoreService;
|
||||||
|
import org.onosproject.net.device.DeviceService;
|
||||||
|
import org.onosproject.net.driver.DriverService;
|
||||||
|
import org.onosproject.net.flowobjective.FlowObjectiveService;
|
||||||
|
import org.onosproject.net.packet.InboundPacket;
|
||||||
|
import org.onosproject.net.packet.PacketContext;
|
||||||
|
import org.onosproject.net.packet.PacketProcessor;
|
||||||
|
import org.onosproject.net.packet.PacketService;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackFloatingIP;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackNetworkingService;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackRouter;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackRouterInterface;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackRoutingService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.onlab.util.Tools.groupedThreads;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Component(immediate = true)
|
||||||
|
/**
|
||||||
|
* Populates flow rules about L3 functionality for VMs in Openstack.
|
||||||
|
*/
|
||||||
|
public class OpenstackRoutingManager implements OpenstackRoutingService {
|
||||||
|
private final Logger log = LoggerFactory
|
||||||
|
.getLogger(getClass());
|
||||||
|
|
||||||
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
|
protected CoreService coreService;
|
||||||
|
|
||||||
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
|
protected PacketService packetService;
|
||||||
|
|
||||||
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
|
protected DeviceService deviceService;
|
||||||
|
|
||||||
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
|
protected OpenstackNetworkingService openstackService;
|
||||||
|
|
||||||
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
|
protected FlowObjectiveService flowObjectiveService;
|
||||||
|
|
||||||
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
|
protected DriverService driverService;
|
||||||
|
|
||||||
|
private ApplicationId appId;
|
||||||
|
private Map<String, OpenstackRouterInterface> routerInterfaceMap = Maps.newHashMap();
|
||||||
|
private Map<Integer, String> portNumMap = initPortNumMap();
|
||||||
|
private static final String APP_ID = "org.onosproject.openstackrouting";
|
||||||
|
private Map<Integer, String> initPortNumMap() {
|
||||||
|
Map<Integer, String> map = Maps.newHashMap();
|
||||||
|
for (int i = 1024; i < 65535; i++) {
|
||||||
|
map.put(i, "");
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor();
|
||||||
|
private ExecutorService l3EventExecutorService =
|
||||||
|
Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "L3-event"));
|
||||||
|
private ExecutorService icmpEventExecutorService =
|
||||||
|
Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "icmp-event"));
|
||||||
|
|
||||||
|
@Activate
|
||||||
|
protected void activate() {
|
||||||
|
appId = coreService.registerApplication(APP_ID);
|
||||||
|
packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1));
|
||||||
|
|
||||||
|
log.info("onos-openstackrouting started");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deactivate
|
||||||
|
protected void deactivate() {
|
||||||
|
packetService.removeProcessor(internalPacketProcessor);
|
||||||
|
log.info("onos-openstackrouting stopped");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFloatingIP(String id) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createRouter(OpenstackRouter openstackRouter) {
|
||||||
|
checkExternalConnection(openstackRouter, getOpenstackRouterInterface(openstackRouter));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRouter(OpenstackRouter openstackRouter) {
|
||||||
|
checkExternalConnection(openstackRouter, getOpenstackRouterInterface(openstackRouter));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteRouter(String id) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRouterInterface(OpenstackRouterInterface routerInterface) {
|
||||||
|
routerInterfaceMap.putIfAbsent(routerInterface.portId(), routerInterface);
|
||||||
|
List<OpenstackRouterInterface> routerInterfaces = Lists.newArrayList();
|
||||||
|
routerInterfaces.add(routerInterface);
|
||||||
|
checkExternalConnection(getOpenstackRouter(routerInterface.tenantId()), routerInterfaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeRouterInterface(OpenstackRouterInterface routerInterface) {
|
||||||
|
OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId,
|
||||||
|
openstackService, flowObjectiveService, deviceService, driverService);
|
||||||
|
rulePopulator.removeExternalRules(routerInterface);
|
||||||
|
routerInterfaceMap.remove(routerInterface.portId());
|
||||||
|
}
|
||||||
|
private class InternalPacketProcessor implements PacketProcessor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(PacketContext context) {
|
||||||
|
|
||||||
|
if (context.isHandled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InboundPacket pkt = context.inPacket();
|
||||||
|
Ethernet ethernet = pkt.parsed();
|
||||||
|
|
||||||
|
if (ethernet != null && ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
|
||||||
|
IPv4 iPacket = (IPv4) ethernet.getPayload();
|
||||||
|
OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId,
|
||||||
|
openstackService, flowObjectiveService, deviceService,
|
||||||
|
driverService);
|
||||||
|
switch (iPacket.getProtocol()) {
|
||||||
|
case IPv4.PROTOCOL_ICMP:
|
||||||
|
icmpEventExecutorService.execute(new OpenstackIcmpHandler(rulePopulator, context));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
int portNum = getPortNum(ethernet.getSourceMAC(), iPacket.getDestinationAddress());
|
||||||
|
OpenstackPort openstackPort = getOpenstackPort(ethernet.getSourceMAC(),
|
||||||
|
Ip4Address.valueOf(iPacket.getSourceAddress()));
|
||||||
|
l3EventExecutorService.execute(new OpenstackPnatHandler(rulePopulator, context,
|
||||||
|
portNum, openstackPort));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getPortNum(MacAddress sourceMac, int destinationAddress) {
|
||||||
|
int portNum = portNumMap.keySet().stream()
|
||||||
|
.filter(k -> portNumMap.get(k).equals("")).findFirst().orElse(0);
|
||||||
|
portNumMap.replace(portNum, sourceMac.toString().concat(":").concat(String.valueOf(destinationAddress)));
|
||||||
|
return portNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkExternalConnection(OpenstackRouter router,
|
||||||
|
Collection<OpenstackRouterInterface> routerInterfaces) {
|
||||||
|
checkNotNull(router, "Router can not be null");
|
||||||
|
checkNotNull(routerInterfaces, "RouterInterfaces can not be null");
|
||||||
|
Ip4Address externalIp = router.gatewayExternalInfo().externalFixedIps()
|
||||||
|
.values().stream().findFirst().orElse(null);
|
||||||
|
if ((externalIp == null) || (!router.gatewayExternalInfo().isEnablePnat())) {
|
||||||
|
log.debug("Failed to set pnat configuration");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
routerInterfaces.forEach(routerInterface -> {
|
||||||
|
initiateL3Rule(router, routerInterface);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initiateL3Rule(OpenstackRouter router, OpenstackRouterInterface routerInterface) {
|
||||||
|
long vni = Long.parseLong(openstackService.network(openstackService
|
||||||
|
.port(routerInterface.portId()).networkId()).segmentId());
|
||||||
|
OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId,
|
||||||
|
openstackService, flowObjectiveService, deviceService, driverService);
|
||||||
|
rulePopulator.populateExternalRules(vni, router, routerInterface);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Collection<OpenstackRouterInterface> getOpenstackRouterInterface(OpenstackRouter router) {
|
||||||
|
return routerInterfaceMap.values().stream().filter(i -> i.id().equals(router.id()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private OpenstackRouter getOpenstackRouter(String tenantId) {
|
||||||
|
return openstackService.routers().stream().filter(r ->
|
||||||
|
r.tenantId().equals(tenantId)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OpenstackPort getOpenstackPort(MacAddress sourceMac, Ip4Address ip4Address) {
|
||||||
|
OpenstackPort openstackPort = openstackService.ports("").stream()
|
||||||
|
.filter(p -> p.macAddress().equals(sourceMac)).findFirst().orElse(null);
|
||||||
|
return openstackPort.fixedIps().values().stream().findFirst().orElse(null)
|
||||||
|
.equals(ip4Address) ? openstackPort : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,371 @@
|
|||||||
|
/*
|
||||||
|
* 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.routing;
|
||||||
|
|
||||||
|
import org.onlab.packet.Ethernet;
|
||||||
|
import org.onlab.packet.IPv4;
|
||||||
|
import org.onlab.packet.Ip4Address;
|
||||||
|
import org.onlab.packet.IpAddress;
|
||||||
|
import org.onlab.packet.IpPrefix;
|
||||||
|
import org.onlab.packet.MacAddress;
|
||||||
|
import org.onlab.packet.TCP;
|
||||||
|
import org.onlab.packet.TpPort;
|
||||||
|
import org.onlab.packet.UDP;
|
||||||
|
import org.onosproject.core.ApplicationId;
|
||||||
|
import org.onosproject.net.Device;
|
||||||
|
import org.onosproject.net.DeviceId;
|
||||||
|
import org.onosproject.net.Port;
|
||||||
|
import org.onosproject.net.PortNumber;
|
||||||
|
import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
|
||||||
|
import org.onosproject.net.device.DeviceService;
|
||||||
|
import org.onosproject.net.driver.DefaultDriverData;
|
||||||
|
import org.onosproject.net.driver.DefaultDriverHandler;
|
||||||
|
import org.onosproject.net.driver.Driver;
|
||||||
|
import org.onosproject.net.driver.DriverHandler;
|
||||||
|
import org.onosproject.net.driver.DriverService;
|
||||||
|
import org.onosproject.net.flow.DefaultTrafficSelector;
|
||||||
|
import org.onosproject.net.flow.DefaultTrafficTreatment;
|
||||||
|
import org.onosproject.net.flow.TrafficSelector;
|
||||||
|
import org.onosproject.net.flow.TrafficTreatment;
|
||||||
|
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.flowobjective.DefaultForwardingObjective;
|
||||||
|
import org.onosproject.net.flowobjective.FlowObjectiveService;
|
||||||
|
import org.onosproject.net.flowobjective.ForwardingObjective;
|
||||||
|
import org.onosproject.net.packet.InboundPacket;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackNetworkingService;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackRouter;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackRouterInterface;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates Routing Flow Rules.
|
||||||
|
*/
|
||||||
|
public class OpenstackRoutingRulePopulator {
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory
|
||||||
|
.getLogger(OpenstackRoutingRulePopulator.class);
|
||||||
|
private ApplicationId appId;
|
||||||
|
private FlowObjectiveService flowObjectiveService;
|
||||||
|
private OpenstackNetworkingService openstackService;
|
||||||
|
private DeviceService deviceService;
|
||||||
|
private DriverService driverService;
|
||||||
|
|
||||||
|
public static final String PORTNAME_PREFIX_VM = "tap";
|
||||||
|
public static final String PORTNAME_PREFIX_ROUTER = "qr";
|
||||||
|
public static final String PORTNAME_PREFIX_TUNNEL = "vxlan";
|
||||||
|
public static final String PORTNAME = "portName";
|
||||||
|
|
||||||
|
private static final int ROUTING_RULE_PRIORITY = 25000;
|
||||||
|
private static final int PNAT_RULE_PRIORITY = 24000;
|
||||||
|
private static final int PNAT_TIMEOUT = 120;
|
||||||
|
private static final MacAddress GATEWAYMAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f");
|
||||||
|
|
||||||
|
private InboundPacket inboundPacket;
|
||||||
|
private OpenstackPort openstackPort;
|
||||||
|
private int portNum;
|
||||||
|
private MacAddress externalInterface;
|
||||||
|
private MacAddress externalRouter;
|
||||||
|
private OpenstackRouter router;
|
||||||
|
private OpenstackRouterInterface routerInterface;
|
||||||
|
|
||||||
|
// TODO: This will be replaced to get the information from openstackswitchingservice.
|
||||||
|
private static final String EXTERNAL_INTERFACE_NAME = "eth3";
|
||||||
|
|
||||||
|
public OpenstackRoutingRulePopulator(ApplicationId appId, OpenstackNetworkingService openstackService,
|
||||||
|
FlowObjectiveService flowObjectiveService,
|
||||||
|
DeviceService deviceService, DriverService driverService) {
|
||||||
|
this.appId = appId;
|
||||||
|
this.flowObjectiveService = flowObjectiveService;
|
||||||
|
this.openstackService = openstackService;
|
||||||
|
this.deviceService = deviceService;
|
||||||
|
this.driverService = driverService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void populatePnatFlowRules(InboundPacket inboundPacket, OpenstackPort openstackPort, int portNum,
|
||||||
|
MacAddress externalInterfaceMacAddress, MacAddress externalRouterMacAddress) {
|
||||||
|
this.inboundPacket = inboundPacket;
|
||||||
|
this.openstackPort = openstackPort;
|
||||||
|
this.portNum = portNum;
|
||||||
|
this.externalInterface = externalInterfaceMacAddress;
|
||||||
|
this.externalRouter = externalRouterMacAddress;
|
||||||
|
|
||||||
|
long vni = getVni(openstackPort);
|
||||||
|
|
||||||
|
populatePnatIncomingFlowRules(vni);
|
||||||
|
populatePnatOutgoingFlowRules(vni);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populatePnatOutgoingFlowRules(long vni) {
|
||||||
|
IPv4 iPacket = (IPv4) inboundPacket.parsed().getPayload();
|
||||||
|
|
||||||
|
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
|
||||||
|
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
|
||||||
|
.matchIPProtocol(iPacket.getProtocol())
|
||||||
|
.matchTunnelId(vni)
|
||||||
|
.matchIPSrc(IpPrefix.valueOf(iPacket.getSourceAddress(), 32))
|
||||||
|
.matchIPDst(IpPrefix.valueOf(iPacket.getDestinationAddress(), 32));
|
||||||
|
|
||||||
|
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
|
||||||
|
tBuilder.setEthSrc(externalInterface)
|
||||||
|
.setEthDst(externalRouter);
|
||||||
|
|
||||||
|
switch (iPacket.getProtocol()) {
|
||||||
|
case IPv4.PROTOCOL_TCP:
|
||||||
|
TCP tcpPacket = (TCP) iPacket.getPayload();
|
||||||
|
sBuilder.matchTcpSrc(TpPort.tpPort(tcpPacket.getSourcePort()))
|
||||||
|
.matchTcpDst(TpPort.tpPort(tcpPacket.getDestinationPort()));
|
||||||
|
tBuilder.setTcpDst(TpPort.tpPort(portNum));
|
||||||
|
break;
|
||||||
|
case IPv4.PROTOCOL_UDP:
|
||||||
|
UDP udpPacket = (UDP) iPacket.getPayload();
|
||||||
|
sBuilder.matchUdpDst(TpPort.tpPort(udpPacket.getSourcePort()))
|
||||||
|
.matchUdpDst(TpPort.tpPort(udpPacket.getDestinationPort()));
|
||||||
|
tBuilder.setUdpDst(TpPort.tpPort(portNum));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Port port = getPortNumOfExternalInterface();
|
||||||
|
checkNotNull(port, "Port can not be null");
|
||||||
|
tBuilder.setOutput(port.number());
|
||||||
|
|
||||||
|
ForwardingObjective fo = DefaultForwardingObjective.builder()
|
||||||
|
.withSelector(sBuilder.build())
|
||||||
|
.withTreatment(tBuilder.build())
|
||||||
|
.withFlag(ForwardingObjective.Flag.VERSATILE)
|
||||||
|
.withPriority(PNAT_RULE_PRIORITY)
|
||||||
|
.makeTemporary(PNAT_TIMEOUT)
|
||||||
|
.fromApp(appId)
|
||||||
|
.add();
|
||||||
|
|
||||||
|
flowObjectiveService.forward(inboundPacket.receivedFrom().deviceId(), fo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Port getPortNumOfExternalInterface() {
|
||||||
|
return deviceService.getPorts(inboundPacket.receivedFrom().deviceId()).stream()
|
||||||
|
.filter(p -> p.annotations().value("portName").equals(EXTERNAL_INTERFACE_NAME))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void populatePnatIncomingFlowRules(long vni) {
|
||||||
|
IPv4 iPacket = (IPv4) inboundPacket.parsed().getPayload();
|
||||||
|
DeviceId deviceId = inboundPacket.receivedFrom().deviceId();
|
||||||
|
|
||||||
|
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
|
||||||
|
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
|
||||||
|
.matchIPProtocol(iPacket.getProtocol())
|
||||||
|
.matchIPSrc(IpPrefix.valueOf(iPacket.getDestinationAddress(), 32));
|
||||||
|
|
||||||
|
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
|
||||||
|
tBuilder.setTunnelId(vni)
|
||||||
|
.setIpDst(IpAddress.valueOf(iPacket.getSourceAddress()));
|
||||||
|
|
||||||
|
switch (iPacket.getProtocol()) {
|
||||||
|
case IPv4.PROTOCOL_TCP:
|
||||||
|
TCP tcpPacket = (TCP) iPacket.getPayload();
|
||||||
|
sBuilder.matchTcpSrc(TpPort.tpPort(tcpPacket.getDestinationPort()))
|
||||||
|
.matchTcpDst(TpPort.tpPort(portNum));
|
||||||
|
tBuilder.setTcpDst(TpPort.tpPort(tcpPacket.getSourcePort()));
|
||||||
|
break;
|
||||||
|
case IPv4.PROTOCOL_UDP:
|
||||||
|
UDP udpPacket = (UDP) iPacket.getPayload();
|
||||||
|
sBuilder.matchUdpSrc(TpPort.tpPort(udpPacket.getDestinationPort()))
|
||||||
|
.matchUdpDst(TpPort.tpPort(portNum));
|
||||||
|
tBuilder.setUdpDst(TpPort.tpPort(udpPacket.getSourcePort()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tBuilder.extension(buildNiciraExtenstion(deviceId, Ip4Address.valueOf(iPacket.getSourceAddress())), deviceId)
|
||||||
|
.setOutput(getTunnelPort(deviceId));
|
||||||
|
|
||||||
|
ForwardingObjective fo = DefaultForwardingObjective.builder()
|
||||||
|
.withSelector(sBuilder.build())
|
||||||
|
.withTreatment(tBuilder.build())
|
||||||
|
.withFlag(ForwardingObjective.Flag.VERSATILE)
|
||||||
|
.withPriority(PNAT_RULE_PRIORITY)
|
||||||
|
.makeTemporary(PNAT_TIMEOUT)
|
||||||
|
.fromApp(appId)
|
||||||
|
.add();
|
||||||
|
|
||||||
|
flowObjectiveService.forward(inboundPacket.receivedFrom().deviceId(), fo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExtensionTreatment buildNiciraExtenstion(DeviceId id, Ip4Address hostIp) {
|
||||||
|
Driver driver = driverService.getDriver(id);
|
||||||
|
DriverHandler driverHandler = new DefaultDriverHandler(new DefaultDriverData(driver, id));
|
||||||
|
ExtensionTreatmentResolver resolver = driverHandler.behaviour(ExtensionTreatmentResolver.class);
|
||||||
|
|
||||||
|
ExtensionTreatment extensionInstruction =
|
||||||
|
resolver.getExtensionInstruction(
|
||||||
|
ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type());
|
||||||
|
|
||||||
|
try {
|
||||||
|
extensionInstruction.setPropertyValue("tunnelDst", hostIp);
|
||||||
|
} catch (ExtensionPropertyException e) {
|
||||||
|
log.error("Error setting Nicira extension setting {}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return extensionInstruction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PortNumber getTunnelPort(DeviceId deviceId) {
|
||||||
|
Port port = deviceService.getPorts(deviceId).stream()
|
||||||
|
.filter(p -> p.annotations().value("portName").equals(PORTNAME_PREFIX_TUNNEL))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
|
||||||
|
if (port == null) {
|
||||||
|
log.error("No TunnelPort was created.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return port.number();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void populateExternalRules(long vni, OpenstackRouter router,
|
||||||
|
OpenstackRouterInterface routerInterface) {
|
||||||
|
this.router = router;
|
||||||
|
this.routerInterface = routerInterface;
|
||||||
|
|
||||||
|
// 1. computeNode to gateway
|
||||||
|
populateComputeNodeRules(vni);
|
||||||
|
// 2. gatewayNode to controller
|
||||||
|
populateRuleGatewaytoController(vni);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateRuleGatewaytoController(long vni) {
|
||||||
|
Device gatewayDevice = getGatewayNode();
|
||||||
|
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
|
||||||
|
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
|
||||||
|
|
||||||
|
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
|
||||||
|
.matchTunnelId(vni)
|
||||||
|
.matchEthDst(GATEWAYMAC);
|
||||||
|
tBuilder.setOutput(PortNumber.CONTROLLER);
|
||||||
|
|
||||||
|
ForwardingObjective fo = DefaultForwardingObjective.builder()
|
||||||
|
.withSelector(sBuilder.build())
|
||||||
|
.withTreatment(tBuilder.build())
|
||||||
|
.withFlag(ForwardingObjective.Flag.VERSATILE)
|
||||||
|
.withPriority(ROUTING_RULE_PRIORITY)
|
||||||
|
.fromApp(appId)
|
||||||
|
.add();
|
||||||
|
|
||||||
|
flowObjectiveService.forward(gatewayDevice.id(), fo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateComputeNodeRules(long vni) {
|
||||||
|
Device gatewayDevice = getGatewayNode();
|
||||||
|
|
||||||
|
StreamSupport.stream(deviceService.getAvailableDevices().spliterator(), false)
|
||||||
|
.filter(d -> !checkGatewayNode(d.id()))
|
||||||
|
.forEach(d -> populateRuleToGateway(d, gatewayDevice, vni));
|
||||||
|
/*deviceService.getAvailableDevices().forEach(d -> {
|
||||||
|
if (!checkGatewayNode(d.id())) {
|
||||||
|
populateRuleToGateway(d, gatewayDevice, vni);
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateRuleToGateway(Device d, Device gatewayDevice, long vni) {
|
||||||
|
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
|
||||||
|
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
|
||||||
|
|
||||||
|
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
|
||||||
|
.matchTunnelId(vni)
|
||||||
|
.matchEthDst(GATEWAYMAC);
|
||||||
|
tBuilder.extension(buildNiciraExtenstion(d.id(), getIPAddressforDevice(gatewayDevice)), d.id())
|
||||||
|
.setOutput(getTunnelPort(d.id()));
|
||||||
|
|
||||||
|
ForwardingObjective fo = DefaultForwardingObjective.builder()
|
||||||
|
.withSelector(sBuilder.build())
|
||||||
|
.withTreatment(tBuilder.build())
|
||||||
|
.withFlag(ForwardingObjective.Flag.SPECIFIC)
|
||||||
|
.withPriority(ROUTING_RULE_PRIORITY)
|
||||||
|
.fromApp(appId)
|
||||||
|
.add();
|
||||||
|
|
||||||
|
flowObjectiveService.forward(d.id(), fo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Ip4Address getIPAddressforDevice(Device device) {
|
||||||
|
return Ip4Address.valueOf(device.annotations().value("channelId").split(":")[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Device getGatewayNode() {
|
||||||
|
final Device[] device = new Device[1];
|
||||||
|
deviceService.getAvailableDevices().forEach(d -> {
|
||||||
|
if (checkGatewayNode(d.id())) {
|
||||||
|
device[0] = d;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return device[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkGatewayNode(DeviceId deviceId) {
|
||||||
|
return !deviceService.getPorts(deviceId).stream().anyMatch(port ->
|
||||||
|
port.annotations().value("portName").startsWith(PORTNAME_PREFIX_ROUTER) ||
|
||||||
|
port.annotations().value("portName").startsWith(PORTNAME_PREFIX_VM));
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getVni(OpenstackPort openstackPort) {
|
||||||
|
return Long.parseLong(openstackService.network(openstackPort.networkId()).segmentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeExternalRules(OpenstackRouterInterface routerInterface) {
|
||||||
|
OpenstackPort openstackPort = openstackService.port(routerInterface.portId());
|
||||||
|
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
|
||||||
|
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
|
||||||
|
.matchTunnelId(getVni(openstackPort))
|
||||||
|
.matchEthDst(GATEWAYMAC);
|
||||||
|
|
||||||
|
StreamSupport.stream(deviceService.getAvailableDevices().spliterator(), false)
|
||||||
|
.forEach(d -> {
|
||||||
|
if (checkGatewayNode(d.id())) {
|
||||||
|
removeExternalRule(d.id(), sBuilder, ForwardingObjective.Flag.VERSATILE);
|
||||||
|
} else {
|
||||||
|
removeExternalRule(d.id(), sBuilder, ForwardingObjective.Flag.SPECIFIC);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeExternalRule(DeviceId id, TrafficSelector.Builder sBuilder, ForwardingObjective.Flag flag) {
|
||||||
|
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
|
||||||
|
|
||||||
|
ForwardingObjective fo = DefaultForwardingObjective.builder()
|
||||||
|
.withSelector(sBuilder.build())
|
||||||
|
.withTreatment(tBuilder.build())
|
||||||
|
.withFlag(flag)
|
||||||
|
.withPriority(ROUTING_RULE_PRIORITY)
|
||||||
|
.fromApp(appId)
|
||||||
|
.remove();
|
||||||
|
|
||||||
|
flowObjectiveService.forward(id, fo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application for OpenstackRouting.
|
||||||
|
*/
|
||||||
|
package org.onosproject.openstacknetworking.routing;
|
66
apps/openstacknetworking/openstackswitching/pom.xml
Normal file
66
apps/openstacknetworking/openstackswitching/pom.xml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2015-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.
|
||||||
|
-->
|
||||||
|
<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-app-openstacknetworking</artifactId>
|
||||||
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>onos-app-openstackswitching</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-openstacknetworking-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-dhcp</artifactId>
|
||||||
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-app-dhcp-api</artifactId>
|
||||||
|
<version>1.5.0-SNAPSHOT</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>org.onosproject</groupId>
|
||||||
|
<artifactId>onlab-misc</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking.switching;
|
||||||
|
|
||||||
import org.onlab.packet.ARP;
|
import org.onlab.packet.ARP;
|
||||||
import org.onlab.packet.Ethernet;
|
import org.onlab.packet.Ethernet;
|
||||||
@ -27,8 +27,9 @@ import org.onosproject.net.host.HostService;
|
|||||||
import org.onosproject.net.packet.DefaultOutboundPacket;
|
import org.onosproject.net.packet.DefaultOutboundPacket;
|
||||||
import org.onosproject.net.packet.InboundPacket;
|
import org.onosproject.net.packet.InboundPacket;
|
||||||
import org.onosproject.net.packet.PacketService;
|
import org.onosproject.net.packet.PacketService;
|
||||||
import org.onosproject.openstackswitching.OpenstackPort;
|
import org.onosproject.openstacknetworking.OpenstackNetworkingService;
|
||||||
import org.onosproject.openstackswitching.OpenstackPortInfo;
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackPortInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -45,19 +46,19 @@ public class OpenstackArpHandler {
|
|||||||
.getLogger(OpenstackArpHandler.class);
|
.getLogger(OpenstackArpHandler.class);
|
||||||
private static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f");
|
private static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f");
|
||||||
private PacketService packetService;
|
private PacketService packetService;
|
||||||
private OpenstackRestHandler restHandler;
|
private OpenstackNetworkingService openstackService;
|
||||||
private HostService hostService;
|
private HostService hostService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns OpenstackArpHandler reference.
|
* Returns OpenstackArpHandler reference.
|
||||||
*
|
*
|
||||||
* @param restHandler rest API handler reference
|
* @param openstackService OpenstackNetworkingService reference
|
||||||
* @param packetService PacketService reference
|
* @param packetService PacketService reference
|
||||||
* @param hostService host service
|
* @param hostService host service
|
||||||
*/
|
*/
|
||||||
public OpenstackArpHandler(OpenstackRestHandler restHandler, PacketService packetService,
|
public OpenstackArpHandler(OpenstackNetworkingService openstackService, PacketService packetService,
|
||||||
HostService hostService) {
|
HostService hostService) {
|
||||||
this.restHandler = checkNotNull(restHandler);
|
this.openstackService = openstackService;
|
||||||
this.packetService = packetService;
|
this.packetService = packetService;
|
||||||
this.hostService = hostService;
|
this.hostService = hostService;
|
||||||
}
|
}
|
||||||
@ -123,7 +124,7 @@ public class OpenstackArpHandler {
|
|||||||
private MacAddress getMacFromOpenstack(IpAddress targetIp) {
|
private MacAddress getMacFromOpenstack(IpAddress targetIp) {
|
||||||
checkNotNull(targetIp);
|
checkNotNull(targetIp);
|
||||||
|
|
||||||
OpenstackPort openstackPort = restHandler.getPorts()
|
OpenstackPort openstackPort = openstackService.ports()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(port -> port.fixedIps().containsValue(targetIp))
|
.filter(port -> port.fixedIps().containsValue(targetIp))
|
||||||
.findFirst()
|
.findFirst()
|
@ -13,8 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking.switching;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@ -50,29 +51,26 @@ import org.onosproject.net.packet.InboundPacket;
|
|||||||
import org.onosproject.net.packet.PacketContext;
|
import org.onosproject.net.packet.PacketContext;
|
||||||
import org.onosproject.net.packet.PacketProcessor;
|
import org.onosproject.net.packet.PacketProcessor;
|
||||||
import org.onosproject.net.packet.PacketService;
|
import org.onosproject.net.packet.PacketService;
|
||||||
import org.onosproject.openstackrouting.OpenstackRouter;
|
import org.onosproject.openstacknetworking.OpenstackNetwork;
|
||||||
import org.onosproject.openstackrouting.OpenstackRouterInterface;
|
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
|
||||||
import org.onosproject.openstackrouting.OpenstackRoutingService;
|
import org.onosproject.openstacknetworking.OpenstackNetworkingService;
|
||||||
import org.onosproject.openstackswitching.OpenstackNetwork;
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
import org.onosproject.openstackswitching.OpenstackPort;
|
import org.onosproject.openstacknetworking.OpenstackPortInfo;
|
||||||
import org.onosproject.openstackswitching.OpenstackPortInfo;
|
import org.onosproject.openstacknetworking.OpenstackSecurityGroup;
|
||||||
import org.onosproject.openstackswitching.OpenstackSubnet;
|
import org.onosproject.openstacknetworking.OpenstackSubnet;
|
||||||
import org.onosproject.openstackswitching.OpenstackSwitchingService;
|
import org.onosproject.openstacknetworking.OpenstackSwitchingService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
|
import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
|
||||||
import static org.onlab.util.Tools.groupedThreads;
|
import static org.onlab.util.Tools.groupedThreads;
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
|
||||||
@Service
|
@Service
|
||||||
@Component(immediate = true)
|
@Component(immediate = true)
|
||||||
/**
|
/**
|
||||||
@ -80,8 +78,8 @@ import static org.onlab.util.Tools.groupedThreads;
|
|||||||
*/
|
*/
|
||||||
public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory
|
private final Logger log = LoggerFactory
|
||||||
.getLogger(OpenstackSwitchingManager.class);
|
.getLogger(getClass());
|
||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
protected CoreService coreService;
|
protected CoreService coreService;
|
||||||
@ -108,7 +106,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
protected DriverService driverService;
|
protected DriverService driverService;
|
||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
protected OpenstackRoutingService openstackRoutingService;
|
protected OpenstackNetworkingService openstackService;
|
||||||
|
|
||||||
public static final String PORTNAME_PREFIX_VM = "tap";
|
public static final String PORTNAME_PREFIX_VM = "tap";
|
||||||
public static final String PORTNAME_PREFIX_ROUTER = "qr-";
|
public static final String PORTNAME_PREFIX_ROUTER = "qr-";
|
||||||
@ -125,7 +123,6 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
private String password;
|
private String password;
|
||||||
private String physicalRouterMac;
|
private String physicalRouterMac;
|
||||||
private OpenstackArpHandler arpHandler;
|
private OpenstackArpHandler arpHandler;
|
||||||
private OpenstackRestHandler restHandler;
|
|
||||||
|
|
||||||
private ExecutorService deviceEventExcutorService =
|
private ExecutorService deviceEventExcutorService =
|
||||||
Executors.newSingleThreadExecutor(groupedThreads("onos/openstackswitching", "device-event"));
|
Executors.newSingleThreadExecutor(groupedThreads("onos/openstackswitching", "device-event"));
|
||||||
@ -136,17 +133,20 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
private InternalDeviceListener internalDeviceListener = new InternalDeviceListener();
|
private InternalDeviceListener internalDeviceListener = new InternalDeviceListener();
|
||||||
private InternalConfigListener internalConfigListener = new InternalConfigListener();
|
private InternalConfigListener internalConfigListener = new InternalConfigListener();
|
||||||
private InternalHostListener internalHostListener = new InternalHostListener();
|
private InternalHostListener internalHostListener = new InternalHostListener();
|
||||||
|
|
||||||
|
|
||||||
private final Set<ConfigFactory> factories = ImmutableSet.of(
|
private final Set<ConfigFactory> factories = ImmutableSet.of(
|
||||||
new ConfigFactory<ApplicationId, OpenstackSwitchingConfig>(APP_SUBJECT_FACTORY,
|
new ConfigFactory<ApplicationId, OpenstackNetworkingConfig>(APP_SUBJECT_FACTORY,
|
||||||
OpenstackSwitchingConfig.class,
|
OpenstackNetworkingConfig.class,
|
||||||
"openstackswitching") {
|
"openstackswitching") {
|
||||||
@Override
|
@Override
|
||||||
public OpenstackSwitchingConfig createConfig() {
|
public OpenstackNetworkingConfig createConfig() {
|
||||||
return new OpenstackSwitchingConfig();
|
return new OpenstackNetworkingConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
private Map<String, OpenstackPortInfo> openstackPortInfoMap = Maps.newHashMap();
|
private Map<String, OpenstackPortInfo> openstackPortInfoMap = Maps.newHashMap();
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
@ -189,14 +189,14 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
|
|
||||||
if (!openstackPort.securityGroups().isEmpty()) {
|
if (!openstackPort.securityGroups().isEmpty()) {
|
||||||
openstackPort.securityGroups().forEach(sgId -> {
|
openstackPort.securityGroups().forEach(sgId -> {
|
||||||
OpenstackSecurityGroup sg = restHandler.getSecurityGroup(sgId);
|
OpenstackSecurityGroup sg = openstackService.getSecurityGroup(sgId);
|
||||||
log.debug("SecurityGroup : {}", sg.toString());
|
log.debug("SecurityGroup : {}", sg.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deletePort(String uuid) {
|
public void removePort(String uuid) {
|
||||||
// When VMs are remvoed, the flow rules for the VMs are removed using ONOS port update event.
|
// When VMs are remvoed, the flow rules for the VMs are removed using ONOS port update event.
|
||||||
// But, when router is removed, no ONOS port event occurs and we need to use Neutron port event.
|
// But, when router is removed, no ONOS port event occurs and we need to use Neutron port event.
|
||||||
// Here we should not touch any rules for VMs.
|
// Here we should not touch any rules for VMs.
|
||||||
@ -212,7 +212,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
if (pName.equals(routerPortName)) {
|
if (pName.equals(routerPortName)) {
|
||||||
OpenstackSwitchingRulePopulator rulePopulator =
|
OpenstackSwitchingRulePopulator rulePopulator =
|
||||||
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
||||||
deviceService, restHandler, driverService);
|
deviceService, openstackService, driverService);
|
||||||
|
|
||||||
rulePopulator.removeSwitchingRules(doNotPushFlows, port, openstackPortInfoMap);
|
rulePopulator.removeSwitchingRules(doNotPushFlows, port, openstackPortInfoMap);
|
||||||
openstackPortInfoMap.remove(routerPortName);
|
openstackPortInfoMap.remove(routerPortName);
|
||||||
@ -236,125 +236,8 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<OpenstackPort> ports(String networkId) {
|
public Map<String, OpenstackPortInfo> openstackPortInfo() {
|
||||||
Collection<OpenstackPort> ports = restHandler.getPorts();
|
return ImmutableMap.copyOf(this.openstackPortInfoMap);
|
||||||
List<OpenstackPort> portList = ports.stream()
|
|
||||||
.filter(p -> p.networkId().equals(networkId))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
return portList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<OpenstackPort> ports() {
|
|
||||||
return restHandler.getPorts();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OpenstackPort port(Port port) {
|
|
||||||
Collection<OpenstackPort> ports = restHandler.getPorts();
|
|
||||||
String uuid = port.annotations().value(PORTNAME).substring(3);
|
|
||||||
return ports.stream()
|
|
||||||
.filter(p -> p.id().startsWith(uuid))
|
|
||||||
.findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OpenstackPort port(String portId) {
|
|
||||||
Collection<OpenstackPort> ports = restHandler.getPorts();
|
|
||||||
return ports.stream()
|
|
||||||
.filter(p -> p.id().equals(portId))
|
|
||||||
.findFirst().orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OpenstackNetwork network(String networkId) {
|
|
||||||
try {
|
|
||||||
Collection<OpenstackSubnet> subnets = restHandler.getSubnets().stream()
|
|
||||||
.filter(s -> s.networkId().equals(networkId))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
Collection<OpenstackNetwork> networks = restHandler.getNetworks();
|
|
||||||
OpenstackNetwork openstackNetwork = networks.stream()
|
|
||||||
.filter(n -> n.id().equals(networkId))
|
|
||||||
.findFirst().get();
|
|
||||||
|
|
||||||
return OpenstackNetwork.builder()
|
|
||||||
.id(openstackNetwork.id())
|
|
||||||
.name(openstackNetwork.name())
|
|
||||||
.networkType(openstackNetwork.networkType())
|
|
||||||
.segmentId(openstackNetwork.segmentId())
|
|
||||||
.tenantId(openstackNetwork.tenantId())
|
|
||||||
.subnets(subnets)
|
|
||||||
.build();
|
|
||||||
} catch (NoSuchElementException e) {
|
|
||||||
log.warn("There is no network infor for net ID {}", networkId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OpenstackSubnet subnet(String subnetId) {
|
|
||||||
Collection<OpenstackSubnet> subnets = restHandler.getSubnets();
|
|
||||||
try {
|
|
||||||
return subnets.stream()
|
|
||||||
.filter(s -> s.id().equals(subnetId))
|
|
||||||
.findFirst().get();
|
|
||||||
} catch (NoSuchElementException e) {
|
|
||||||
log.warn("There is no subnet info for subnet ID {}", subnetId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createRouter(OpenstackRouter openstackRouter) {
|
|
||||||
openstackRoutingService.createRouter(openstackRouter);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void updateRouter(String routerId) {
|
|
||||||
openstackRoutingService.updateRouter(router(routerId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeRouterInterface(OpenstackRouterInterface openstackRouterInterface) {
|
|
||||||
openstackRoutingService.removeRouterInterface(openstackRouterInterface);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void deleteRouter(String id) {
|
|
||||||
openstackRoutingService.deleteRouter(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface) {
|
|
||||||
openstackRoutingService.updateRouterInterface(openstackRouterInterface);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OpenstackRouter router(String routerId) {
|
|
||||||
Collection<OpenstackRouter> openstackRouters = restHandler.getRouters();
|
|
||||||
try {
|
|
||||||
return openstackRouters.stream()
|
|
||||||
.filter(r -> r.id().equals(routerId))
|
|
||||||
.findAny().get();
|
|
||||||
} catch (NoSuchElementException e) {
|
|
||||||
log.warn("There is no router info for subnet ID {}", routerId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<OpenstackRouter> routers() {
|
|
||||||
return restHandler.getRouters();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<OpenstackPortInfo> portInfos() {
|
|
||||||
return openstackPortInfoMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String physicalRouterMac() {
|
|
||||||
return physicalRouterMac;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processDeviceAdded(Device device) {
|
private void processDeviceAdded(Device device) {
|
||||||
@ -366,10 +249,10 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
if (port.isEnabled() || port.annotations().value(PORTNAME).startsWith(PORTNAME_PREFIX_ROUTER)) {
|
if (port.isEnabled() || port.annotations().value(PORTNAME).startsWith(PORTNAME_PREFIX_ROUTER)) {
|
||||||
OpenstackSwitchingRulePopulator rulePopulator =
|
OpenstackSwitchingRulePopulator rulePopulator =
|
||||||
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
||||||
deviceService, restHandler, driverService);
|
deviceService, openstackService, driverService);
|
||||||
|
|
||||||
rulePopulator.populateSwitchingRules(doNotPushFlows, device, port);
|
rulePopulator.populateSwitchingRules(doNotPushFlows, device, port);
|
||||||
updatePortMap(device.id(), port, restHandler.getNetworks(), restHandler.getSubnets(),
|
updatePortMap(device.id(), port, openstackService.networks(), openstackService.subnets(),
|
||||||
rulePopulator.openstackPort(port));
|
rulePopulator.openstackPort(port));
|
||||||
|
|
||||||
//In case portupdate event is driven by vm shutoff from openstack
|
//In case portupdate event is driven by vm shutoff from openstack
|
||||||
@ -377,7 +260,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
log.debug("Flowrules according to the port {} were removed", port.number().toString());
|
log.debug("Flowrules according to the port {} were removed", port.number().toString());
|
||||||
OpenstackSwitchingRulePopulator rulePopulator =
|
OpenstackSwitchingRulePopulator rulePopulator =
|
||||||
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
||||||
deviceService, restHandler, driverService);
|
deviceService, openstackService, driverService);
|
||||||
|
|
||||||
rulePopulator.removeSwitchingRules(doNotPushFlows, port, openstackPortInfoMap);
|
rulePopulator.removeSwitchingRules(doNotPushFlows, port, openstackPortInfoMap);
|
||||||
dhcpService.removeStaticMapping(openstackPortInfoMap.get(port.annotations().value(PORTNAME)).mac());
|
dhcpService.removeStaticMapping(openstackPortInfoMap.get(port.annotations().value(PORTNAME)).mac());
|
||||||
@ -393,10 +276,10 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
private void initializeFlowRules() {
|
private void initializeFlowRules() {
|
||||||
OpenstackSwitchingRulePopulator rulePopulator =
|
OpenstackSwitchingRulePopulator rulePopulator =
|
||||||
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
new OpenstackSwitchingRulePopulator(appId, flowObjectiveService,
|
||||||
deviceService, restHandler, driverService);
|
deviceService, openstackService, driverService);
|
||||||
|
|
||||||
Collection<OpenstackNetwork> networks = restHandler.getNetworks();
|
Collection<OpenstackNetwork> networks = openstackService.networks();
|
||||||
Collection<OpenstackSubnet> subnets = restHandler.getSubnets();
|
Collection<OpenstackSubnet> subnets = openstackService.subnets();
|
||||||
|
|
||||||
deviceService.getDevices().forEach(device -> {
|
deviceService.getDevices().forEach(device -> {
|
||||||
log.debug("device {} num of ports {} ", device.id(),
|
log.debug("device {} num of ports {} ", device.id(),
|
||||||
@ -458,7 +341,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
|
|
||||||
ip4Address = (Ip4Address) openstackPort.fixedIps().values().stream().findFirst().orElse(null);
|
ip4Address = (Ip4Address) openstackPort.fixedIps().values().stream().findFirst().orElse(null);
|
||||||
|
|
||||||
openstackSubnet = restHandler.getSubnets().stream()
|
openstackSubnet = openstackService.subnets().stream()
|
||||||
.filter(n -> n.networkId().equals(openstackPort.networkId()))
|
.filter(n -> n.networkId().equals(openstackPort.networkId()))
|
||||||
.findFirst().get();
|
.findFirst().get();
|
||||||
|
|
||||||
@ -579,16 +462,18 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
private class InternalConfigListener implements NetworkConfigListener {
|
private class InternalConfigListener implements NetworkConfigListener {
|
||||||
|
|
||||||
public void configureNetwork() {
|
public void configureNetwork() {
|
||||||
OpenstackSwitchingConfig cfg =
|
OpenstackNetworkingConfig cfg =
|
||||||
cfgService.getConfig(appId, OpenstackSwitchingConfig.class);
|
cfgService.getConfig(appId, OpenstackNetworkingConfig.class);
|
||||||
if (cfg == null) {
|
if (cfg == null) {
|
||||||
log.error("There is no openstack server information in config.");
|
log.error("There is no openstack server information in config.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
doNotPushFlows = cfg.doNotPushFlows();
|
doNotPushFlows = cfg.doNotPushFlows();
|
||||||
physicalRouterMac = cfg.physicalRouterMac();
|
physicalRouterMac = cfg.physicalRouterMac();
|
||||||
restHandler = new OpenstackRestHandler(cfg);
|
openstackService.setConfigurations(cfg.neutronServer(), cfg.keystoneServer(),
|
||||||
arpHandler = new OpenstackArpHandler(restHandler, packetService, hostService);
|
cfg.userName(), cfg.password());
|
||||||
|
arpHandler = new OpenstackArpHandler(openstackService, packetService, hostService);
|
||||||
initializeFlowRules();
|
initializeFlowRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +481,9 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
|
|||||||
public void event(NetworkConfigEvent event) {
|
public void event(NetworkConfigEvent event) {
|
||||||
if (((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
|
if (((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
|
||||||
event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) &&
|
event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) &&
|
||||||
event.configClass().equals(OpenstackSwitchingConfig.class)) {
|
event.configClass().equals(OpenstackNetworkingConfig.class)) {
|
||||||
|
|
||||||
|
log.info("Network configuration changed");
|
||||||
networkEventExcutorService.execute(this::configureNetwork);
|
networkEventExcutorService.execute(this::configureNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking.switching;
|
||||||
|
|
||||||
import org.onlab.packet.Ethernet;
|
import org.onlab.packet.Ethernet;
|
||||||
import org.onlab.packet.Ip4Address;
|
import org.onlab.packet.Ip4Address;
|
||||||
@ -40,9 +40,10 @@ import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
|
|||||||
import org.onosproject.net.flowobjective.DefaultForwardingObjective;
|
import org.onosproject.net.flowobjective.DefaultForwardingObjective;
|
||||||
import org.onosproject.net.flowobjective.FlowObjectiveService;
|
import org.onosproject.net.flowobjective.FlowObjectiveService;
|
||||||
import org.onosproject.net.flowobjective.ForwardingObjective;
|
import org.onosproject.net.flowobjective.ForwardingObjective;
|
||||||
import org.onosproject.openstackswitching.OpenstackNetwork;
|
import org.onosproject.openstacknetworking.OpenstackNetwork;
|
||||||
import org.onosproject.openstackswitching.OpenstackPort;
|
import org.onosproject.openstacknetworking.OpenstackNetworkingService;
|
||||||
import org.onosproject.openstackswitching.OpenstackPortInfo;
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackPortInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -63,7 +64,6 @@ public class OpenstackSwitchingRulePopulator {
|
|||||||
private FlowObjectiveService flowObjectiveService;
|
private FlowObjectiveService flowObjectiveService;
|
||||||
private DriverService driverService;
|
private DriverService driverService;
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
private OpenstackRestHandler restHandler;
|
|
||||||
private ApplicationId appId;
|
private ApplicationId appId;
|
||||||
|
|
||||||
private Collection<OpenstackNetwork> openstackNetworkList;
|
private Collection<OpenstackNetwork> openstackNetworkList;
|
||||||
@ -75,22 +75,20 @@ public class OpenstackSwitchingRulePopulator {
|
|||||||
* @param appId application id
|
* @param appId application id
|
||||||
* @param flowObjectiveService FlowObjectiveService reference
|
* @param flowObjectiveService FlowObjectiveService reference
|
||||||
* @param deviceService DeviceService reference
|
* @param deviceService DeviceService reference
|
||||||
* @param restHandler OpenstackRestHandler reference
|
|
||||||
* @param driverService DriverService reference
|
* @param driverService DriverService reference
|
||||||
*/
|
*/
|
||||||
public OpenstackSwitchingRulePopulator(ApplicationId appId,
|
public OpenstackSwitchingRulePopulator(ApplicationId appId,
|
||||||
FlowObjectiveService flowObjectiveService,
|
FlowObjectiveService flowObjectiveService,
|
||||||
DeviceService deviceService,
|
DeviceService deviceService,
|
||||||
OpenstackRestHandler restHandler,
|
OpenstackNetworkingService openstackService,
|
||||||
DriverService driverService) {
|
DriverService driverService) {
|
||||||
this.flowObjectiveService = flowObjectiveService;
|
this.flowObjectiveService = flowObjectiveService;
|
||||||
this.deviceService = deviceService;
|
this.deviceService = deviceService;
|
||||||
this.driverService = driverService;
|
this.driverService = driverService;
|
||||||
this.restHandler = restHandler;
|
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
|
|
||||||
openstackNetworkList = restHandler.getNetworks();
|
openstackNetworkList = openstackService.networks();
|
||||||
openstackPortList = restHandler.getPorts();
|
openstackPortList = openstackService.ports();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -17,4 +17,4 @@
|
|||||||
/**
|
/**
|
||||||
* OpenStack switch implementation.
|
* OpenStack switch implementation.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking.switching;
|
45
apps/openstacknetworking/pom.xml
Normal file
45
apps/openstacknetworking/pom.xml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.onosproject</groupId>
|
||||||
|
<artifactId>onos-apps</artifactId>
|
||||||
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>onos-app-openstacknetworking</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>app</module>
|
||||||
|
<module>web</module>
|
||||||
|
<module>api</module>
|
||||||
|
<module>openstackswitching</module>
|
||||||
|
<module>openstackrouting</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
<description>SONA Openstack Networking XXXX Application</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
25
apps/openstacknetworking/web/features.xml
Normal file
25
apps/openstacknetworking/web/features.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2015-16 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}">
|
||||||
|
<feature name="${project.artifactId}" version="${project.version}"
|
||||||
|
description="${project.description}">
|
||||||
|
<feature>onos-api</feature>
|
||||||
|
<bundle>mvn:${project.groupId}/onos-app-openstacknetworking-api/${project.version}</bundle>
|
||||||
|
<bundle>mvn:${project.groupId}/onos-app-openstacknetworking-web/${project.version}</bundle>
|
||||||
|
<bundle>mvn:com.sun.jersey/jersey-client/1.19</bundle>
|
||||||
|
</feature>
|
||||||
|
</features>
|
@ -21,31 +21,28 @@
|
|||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.onosproject</groupId>
|
<groupId>org.onosproject</groupId>
|
||||||
<artifactId>onos-openstackswitching</artifactId>
|
<artifactId>onos-app-openstacknetworking</artifactId>
|
||||||
<version>1.5.0-SNAPSHOT</version>
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>onos-app-openstackswitching</artifactId>
|
<artifactId>onos-app-openstacknetworking-web</artifactId>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<description>SONA Openstack Switching applications</description>
|
|
||||||
<properties>
|
<properties>
|
||||||
<web.context>/onos/openstackswitching</web.context>
|
<web.context>/onos/openstackswitching</web.context>
|
||||||
<api.version>1.0.0</api.version>
|
<api.version>1.0.0</api.version>
|
||||||
<api.title>ONOS OpenStack Switching REST API</api.title>
|
<api.title>ONOS Openstack Networking REST API</api.title>
|
||||||
<api.description>
|
<api.description>
|
||||||
APIs for receiving Neutron information.
|
APIs for interacting with Openstack Neutron Plugin.
|
||||||
</api.description>
|
</api.description>
|
||||||
<api.package>org.onosproject.openstackswitching.web</api.package>
|
<api.package>org.onosproject.openstacknetworking.web</api.package>
|
||||||
<onos.app.origin>SKT, Inc.</onos.app.origin>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.onosproject</groupId>
|
<groupId>org.onosproject</groupId>
|
||||||
<artifactId>onos-app-openstackswitching-api</artifactId>
|
<artifactId>onos-app-openstacknetworking-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import org.onosproject.openstackrouting.OpenstackRouter;
|
import org.onosproject.openstacknetworking.OpenstackRouter;
|
||||||
import org.onosproject.openstackrouting.OpenstackRouterInterface;
|
import org.onosproject.openstacknetworking.OpenstackRouterInterface;
|
||||||
import org.onosproject.openstackswitching.OpenstackSwitchingService;
|
import org.onosproject.openstacknetworking.OpenstackRoutingService;
|
||||||
import org.onosproject.rest.AbstractWebResource;
|
import org.onosproject.rest.AbstractWebResource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -42,8 +42,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
@Path("routers")
|
@Path("routers")
|
||||||
public class OpensatckRouterWebResource extends AbstractWebResource {
|
public class OpensatckRouterWebResource extends AbstractWebResource {
|
||||||
protected static final Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackNetworkWebResource.class);
|
|
||||||
|
|
||||||
private static final OpenstackRouterInterfaceCodec ROUTER_INTERFACE_CODEC
|
private static final OpenstackRouterInterfaceCodec ROUTER_INTERFACE_CODEC
|
||||||
= new OpenstackRouterInterfaceCodec();
|
= new OpenstackRouterInterfaceCodec();
|
||||||
@ -62,9 +61,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
|
|||||||
OpenstackRouter openstackRouter
|
OpenstackRouter openstackRouter
|
||||||
= ROUTER_CODEC.decode(routerNode, this);
|
= ROUTER_CODEC.decode(routerNode, this);
|
||||||
|
|
||||||
OpenstackSwitchingService switchingService
|
OpenstackRoutingService routingService
|
||||||
= getService(OpenstackSwitchingService.class);
|
= getService(OpenstackRoutingService.class);
|
||||||
switchingService.createRouter(openstackRouter);
|
routingService.createRouter(openstackRouter);
|
||||||
|
|
||||||
log.debug("REST API CREATE router is called {}", input.toString());
|
log.debug("REST API CREATE router is called {}", input.toString());
|
||||||
return Response.status(Response.Status.OK).build();
|
return Response.status(Response.Status.OK).build();
|
||||||
@ -80,14 +79,20 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Response updateRouter(@PathParam("id") String id) {
|
public Response updateRouter(InputStream input) {
|
||||||
checkNotNull(id);
|
checkNotNull(input);
|
||||||
try {
|
try {
|
||||||
OpenstackSwitchingService switchingService
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
= getService(OpenstackSwitchingService.class);
|
ObjectNode routerNode = (ObjectNode) mapper.readTree(input);
|
||||||
switchingService.updateRouter(id);
|
|
||||||
|
|
||||||
log.debug("REST API UPDATE router is called from router {}", id);
|
OpenstackRouter openstackRouter
|
||||||
|
= ROUTER_CODEC.decode(routerNode, this);
|
||||||
|
|
||||||
|
OpenstackRoutingService routingService
|
||||||
|
= getService(OpenstackRoutingService.class);
|
||||||
|
routingService.updateRouter(openstackRouter);
|
||||||
|
|
||||||
|
log.debug("REST API UPDATE router is called from router {}", input.toString());
|
||||||
return Response.status(Response.Status.OK).build();
|
return Response.status(Response.Status.OK).build();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Updates Router failed because of exception {}",
|
log.error("Updates Router failed because of exception {}",
|
||||||
@ -110,9 +115,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
|
|||||||
OpenstackRouterInterface openstackRouterInterface
|
OpenstackRouterInterface openstackRouterInterface
|
||||||
= ROUTER_INTERFACE_CODEC.decode(routerIfNode, this);
|
= ROUTER_INTERFACE_CODEC.decode(routerIfNode, this);
|
||||||
|
|
||||||
OpenstackSwitchingService switchingService
|
OpenstackRoutingService routingService
|
||||||
= getService(OpenstackSwitchingService.class);
|
= getService(OpenstackRoutingService.class);
|
||||||
switchingService.updateRouterInterface(openstackRouterInterface);
|
routingService.updateRouterInterface(openstackRouterInterface);
|
||||||
|
|
||||||
log.debug("REST API AddRouterInterface is called from router {} portId: {}, subnetId: {}, tenantId: {}",
|
log.debug("REST API AddRouterInterface is called from router {} portId: {}, subnetId: {}, tenantId: {}",
|
||||||
openstackRouterInterface.id(), openstackRouterInterface.portId(),
|
openstackRouterInterface.id(), openstackRouterInterface.portId(),
|
||||||
@ -129,11 +134,12 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
|
|||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Response deleteRouter(@PathParam("id") String id) {
|
public Response deleteRouter(@PathParam("id") String id) {
|
||||||
checkNotNull(id);
|
checkNotNull(id);
|
||||||
OpenstackSwitchingService switchingService =
|
OpenstackRoutingService routingService
|
||||||
getService(OpenstackSwitchingService.class);
|
= getService(OpenstackRoutingService.class);
|
||||||
switchingService.deleteRouter(id);
|
routingService.deleteRouter(id);
|
||||||
|
|
||||||
log.debug("REST API DELETE routers is called {}", id);
|
log.debug("REST API DELETE routers is called {}", id);
|
||||||
return Response.status(Response.Status.OK).build();
|
return Response.status(Response.Status.OK).build();
|
||||||
@ -153,9 +159,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
|
|||||||
OpenstackRouterInterface openstackRouterInterface
|
OpenstackRouterInterface openstackRouterInterface
|
||||||
= ROUTER_INTERFACE_CODEC.decode(routerIfNode, this);
|
= ROUTER_INTERFACE_CODEC.decode(routerIfNode, this);
|
||||||
|
|
||||||
OpenstackSwitchingService switchingService
|
OpenstackRoutingService routingService
|
||||||
= getService(OpenstackSwitchingService.class);
|
= getService(OpenstackRoutingService.class);
|
||||||
switchingService.removeRouterInterface(openstackRouterInterface);
|
routingService.removeRouterInterface(openstackRouterInterface);
|
||||||
|
|
||||||
log.debug("REST API RemoveRouterInterface is called from router {} portId: {}, subnetId: {}," +
|
log.debug("REST API RemoveRouterInterface is called from router {} portId: {}, subnetId: {}," +
|
||||||
"tenantId: {}", openstackRouterInterface.id(), openstackRouterInterface.portId(),
|
"tenantId: {}", openstackRouterInterface.id(), openstackRouterInterface.portId(),
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import org.onosproject.codec.CodecContext;
|
import org.onosproject.codec.CodecContext;
|
||||||
import org.onosproject.codec.JsonCodec;
|
import org.onosproject.codec.JsonCodec;
|
||||||
import org.onosproject.openstackswitching.OpenstackNetwork;
|
import org.onosproject.openstacknetworking.OpenstackNetwork;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -29,8 +29,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class OpenstackNetworkCodec extends JsonCodec<OpenstackNetwork> {
|
public class OpenstackNetworkCodec extends JsonCodec<OpenstackNetwork> {
|
||||||
|
|
||||||
protected static final Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackNetworkCodec.class);
|
|
||||||
|
|
||||||
private static final String NETWORK = "network";
|
private static final String NETWORK = "network";
|
||||||
private static final String NAME = "name";
|
private static final String NAME = "name";
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import org.onosproject.rest.AbstractWebResource;
|
import org.onosproject.rest.AbstractWebResource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -35,8 +35,7 @@ import java.io.InputStream;
|
|||||||
@Path("networks")
|
@Path("networks")
|
||||||
public class OpenstackNetworkWebResource extends AbstractWebResource {
|
public class OpenstackNetworkWebResource extends AbstractWebResource {
|
||||||
|
|
||||||
protected static final Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackNetworkWebResource.class);
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.impl;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
@ -21,21 +21,32 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.sun.jersey.api.client.Client;
|
import com.sun.jersey.api.client.Client;
|
||||||
import com.sun.jersey.api.client.WebResource;
|
import com.sun.jersey.api.client.WebResource;
|
||||||
import org.onosproject.openstackrouting.OpenstackRouter;
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
import org.onosproject.openstackswitching.OpenstackNetwork;
|
import org.apache.felix.scr.annotations.Component;
|
||||||
import org.onosproject.openstackswitching.OpenstackPort;
|
import org.apache.felix.scr.annotations.Deactivate;
|
||||||
import org.onosproject.openstackswitching.OpenstackSubnet;
|
import org.apache.felix.scr.annotations.Reference;
|
||||||
import org.onosproject.openstackswitching.web.OpenstackNetworkCodec;
|
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
||||||
import org.onosproject.openstackswitching.web.OpenstackPortCodec;
|
import org.apache.felix.scr.annotations.Service;
|
||||||
import org.onosproject.openstackswitching.web.OpenstackSecurityGroupCodec;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.openstackswitching.web.OpenstackRouterCodec;
|
import org.onosproject.core.CoreService;
|
||||||
import org.onosproject.openstackswitching.web.OpenstackSubnetCodec;
|
import org.onosproject.net.Port;
|
||||||
|
import org.onosproject.net.driver.DriverService;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackNetwork;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackNetworkingService;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackPortInfo;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackRouter;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackSecurityGroup;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackSubnet;
|
||||||
|
import org.onosproject.openstacknetworking.OpenstackSwitchingService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.net.MediaType.JSON_UTF_8;
|
import static com.google.common.net.MediaType.JSON_UTF_8;
|
||||||
@ -45,7 +56,9 @@ import static org.slf4j.LoggerFactory.getLogger;
|
|||||||
* Handles REST Calls to Openstack Neutron.
|
* Handles REST Calls to Openstack Neutron.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class OpenstackRestHandler {
|
@Service
|
||||||
|
@Component(immediate = true)
|
||||||
|
public class OpenstackNetworkingManager implements OpenstackNetworkingService {
|
||||||
|
|
||||||
private static final String URI_NETWORKS = "networks";
|
private static final String URI_NETWORKS = "networks";
|
||||||
private static final String URI_PORTS = "ports";
|
private static final String URI_PORTS = "ports";
|
||||||
@ -70,16 +83,29 @@ public class OpenstackRestHandler {
|
|||||||
private String userName;
|
private String userName;
|
||||||
private String pass;
|
private String pass;
|
||||||
|
|
||||||
/**
|
private static final String PORT_NAME = "portName";
|
||||||
* Creates OpenstackRestHandler instance.
|
|
||||||
*
|
private ApplicationId appId;
|
||||||
* @param cfg OpenstackSwitchingConfig reference
|
|
||||||
*/
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
public OpenstackRestHandler(OpenstackSwitchingConfig cfg) {
|
protected CoreService coreService;
|
||||||
this.neutronUrl = checkNotNull(cfg.neutronServer());
|
|
||||||
this.keystoneUrl = checkNotNull(cfg.keystoneServer());
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
this.userName = checkNotNull(cfg.userName());
|
protected DriverService driverService;
|
||||||
this.pass = checkNotNull(cfg.password());
|
|
||||||
|
protected OpenstackSwitchingService openstackSwitchingService;
|
||||||
|
|
||||||
|
@Activate
|
||||||
|
protected void activate() {
|
||||||
|
appId = coreService
|
||||||
|
.registerApplication("org.onosproject.openstacknetworking");
|
||||||
|
|
||||||
|
log.info("started");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deactivate
|
||||||
|
protected void deactivate() {
|
||||||
|
log.info("stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,4 +275,79 @@ public class OpenstackRestHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<OpenstackPort> ports(String networkId) {
|
||||||
|
return getPorts().stream()
|
||||||
|
.filter(port -> port.networkId().equals(networkId))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<OpenstackPort> ports() {
|
||||||
|
return getPorts();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenstackPort port(Port port) {
|
||||||
|
String uuid = port.annotations().value(PORT_NAME).substring(3);
|
||||||
|
return getPorts().stream()
|
||||||
|
.filter(p -> p.id().startsWith(uuid))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenstackPort port(String portId) {
|
||||||
|
return getPorts().stream()
|
||||||
|
.filter(p -> p.id().equals(portId))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenstackNetwork network(String networkId) {
|
||||||
|
return getNetworks().stream()
|
||||||
|
.filter(n -> n.id().equals(networkId))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<OpenstackNetwork> networks() {
|
||||||
|
return getNetworks();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenstackSubnet subnet(String subnetId) {
|
||||||
|
return getSubnets().stream()
|
||||||
|
.filter(subnet -> subnet.id().equals(subnetId))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<OpenstackSubnet> subnets() {
|
||||||
|
return getSubnets();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<OpenstackRouter> routers() {
|
||||||
|
return getRouters();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenstackRouter router(String routerId) {
|
||||||
|
return getRouters().stream()
|
||||||
|
.filter(router -> router.id().equals(routerId))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, OpenstackPortInfo> openstackPortInfo() {
|
||||||
|
return openstackSwitchingService.openstackPortInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setConfigurations(String neutronUrl, String keystoneUrl, String userName, String pass) {
|
||||||
|
this.neutronUrl = checkNotNull(neutronUrl);
|
||||||
|
this.keystoneUrl = checkNotNull(keystoneUrl);
|
||||||
|
this.userName = checkNotNull(userName);
|
||||||
|
this.pass = checkNotNull(pass);
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
@ -25,7 +25,7 @@ import org.onlab.packet.IpAddress;
|
|||||||
import org.onlab.packet.MacAddress;
|
import org.onlab.packet.MacAddress;
|
||||||
import org.onosproject.codec.CodecContext;
|
import org.onosproject.codec.CodecContext;
|
||||||
import org.onosproject.codec.JsonCodec;
|
import org.onosproject.codec.JsonCodec;
|
||||||
import org.onosproject.openstackswitching.OpenstackPort;
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -33,13 +33,14 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes and decodes the OpenstackPort.
|
* Encodes and decodes the OpenstackPort.
|
||||||
*/
|
*/
|
||||||
public class OpenstackPortCodec extends JsonCodec<OpenstackPort> {
|
public class OpenstackPortCodec extends JsonCodec<OpenstackPort> {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackPortCodec.class);
|
|
||||||
|
|
||||||
// JSON field names
|
// JSON field names
|
||||||
private static final String PORT = "port";
|
private static final String PORT = "port";
|
||||||
@ -62,6 +63,7 @@ public class OpenstackPortCodec extends JsonCodec<OpenstackPort> {
|
|||||||
@Override
|
@Override
|
||||||
public OpenstackPort decode(ObjectNode json, CodecContext context) {
|
public OpenstackPort decode(ObjectNode json, CodecContext context) {
|
||||||
|
|
||||||
|
checkNotNull(json);
|
||||||
HashMap<String, Ip4Address> fixedIpMap = new HashMap<>();
|
HashMap<String, Ip4Address> fixedIpMap = new HashMap<>();
|
||||||
JsonNode portInfo = json.get(PORT);
|
JsonNode portInfo = json.get(PORT);
|
||||||
if (portInfo == null) {
|
if (portInfo == null) {
|
@ -13,12 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import org.onosproject.openstackswitching.OpenstackPort;
|
import org.onosproject.openstacknetworking.OpenstackPort;
|
||||||
import org.onosproject.openstackswitching.OpenstackSwitchingService;
|
import org.onosproject.openstacknetworking.OpenstackSwitchingService;
|
||||||
import org.onosproject.rest.AbstractWebResource;
|
import org.onosproject.rest.AbstractWebResource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -40,8 +40,7 @@ import java.io.InputStream;
|
|||||||
@Path("ports")
|
@Path("ports")
|
||||||
public class OpenstackPortWebResource extends AbstractWebResource {
|
public class OpenstackPortWebResource extends AbstractWebResource {
|
||||||
|
|
||||||
protected static final Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackPortWebResource.class);
|
|
||||||
|
|
||||||
private static final OpenstackPortCodec PORT_CODEC = new OpenstackPortCodec();
|
private static final OpenstackPortCodec PORT_CODEC = new OpenstackPortCodec();
|
||||||
|
|
||||||
@ -70,11 +69,12 @@ public class OpenstackPortWebResource extends AbstractWebResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Path("{portUUID}")
|
@Path("{portUUID}")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@DELETE
|
@DELETE
|
||||||
public Response deletePorts(@PathParam("portUUID") String id) {
|
public Response deletePorts(@PathParam("portUUID") String id) {
|
||||||
OpenstackSwitchingService switchingService =
|
OpenstackSwitchingService switchingService =
|
||||||
getService(OpenstackSwitchingService.class);
|
getService(OpenstackSwitchingService.class);
|
||||||
switchingService.deletePort(id);
|
switchingService.removePort(id);
|
||||||
return Response.status(Response.Status.OK).build();
|
return Response.status(Response.Status.OK).build();
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
@ -22,8 +22,8 @@ import com.google.common.collect.Maps;
|
|||||||
import org.onlab.packet.Ip4Address;
|
import org.onlab.packet.Ip4Address;
|
||||||
import org.onosproject.codec.CodecContext;
|
import org.onosproject.codec.CodecContext;
|
||||||
import org.onosproject.codec.JsonCodec;
|
import org.onosproject.codec.JsonCodec;
|
||||||
import org.onosproject.openstackrouting.OpenstackExternalGateway;
|
import org.onosproject.openstacknetworking.OpenstackExternalGateway;
|
||||||
import org.onosproject.openstackrouting.OpenstackRouter;
|
import org.onosproject.openstacknetworking.OpenstackRouter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -33,8 +33,7 @@ import java.util.Map;
|
|||||||
* Implementation of the OpenstackRouter Codec.
|
* Implementation of the OpenstackRouter Codec.
|
||||||
*/
|
*/
|
||||||
public class OpenstackRouterCodec extends JsonCodec<OpenstackRouter> {
|
public class OpenstackRouterCodec extends JsonCodec<OpenstackRouter> {
|
||||||
protected static final Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackNetworkCodec.class);
|
|
||||||
|
|
||||||
private static final String ROUTER = "router";
|
private static final String ROUTER = "router";
|
||||||
private static final String TENANT_ID = "tenant_id";
|
private static final String TENANT_ID = "tenant_id";
|
||||||
@ -72,7 +71,7 @@ public class OpenstackRouterCodec extends JsonCodec<OpenstackRouter> {
|
|||||||
String status = checkNotNull(routerInfo.path(STATUS).asText());
|
String status = checkNotNull(routerInfo.path(STATUS).asText());
|
||||||
String adminStateUp = checkNotNull(routerInfo.path(ADMIN_STATE_UP).asText());
|
String adminStateUp = checkNotNull(routerInfo.path(ADMIN_STATE_UP).asText());
|
||||||
|
|
||||||
OpenstackExternalGateway.Builder osExtBuiler = OpenstackExternalGateway.builder();
|
OpenstackExternalGateway.Builder osExtBuiler = new OpenstackExternalGateway.Builder();
|
||||||
|
|
||||||
if (!routerInfo.path(EXTERNAL_GW_INFO).isMissingNode()) {
|
if (!routerInfo.path(EXTERNAL_GW_INFO).isMissingNode()) {
|
||||||
String externalGatewayNetId = checkNotNull(routerInfo.path(EXTERNAL_GW_INFO).path(NETWORK_ID).asText());
|
String externalGatewayNetId = checkNotNull(routerInfo.path(EXTERNAL_GW_INFO).path(NETWORK_ID).asText());
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import org.onosproject.codec.CodecContext;
|
import org.onosproject.codec.CodecContext;
|
||||||
import org.onosproject.codec.JsonCodec;
|
import org.onosproject.codec.JsonCodec;
|
||||||
import org.onosproject.openstackrouting.OpenstackRouterInterface;
|
import org.onosproject.openstacknetworking.OpenstackRouterInterface;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -27,8 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* Implementation of the OpenstackRouterInterface Codec.
|
* Implementation of the OpenstackRouterInterface Codec.
|
||||||
*/
|
*/
|
||||||
public class OpenstackRouterInterfaceCodec extends JsonCodec<OpenstackRouterInterface> {
|
public class OpenstackRouterInterfaceCodec extends JsonCodec<OpenstackRouterInterface> {
|
||||||
protected static final Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackNetworkCodec.class);
|
|
||||||
|
|
||||||
private static final String ID = "id";
|
private static final String ID = "id";
|
||||||
private static final String TENANT_ID = "tenant_id";
|
private static final String TENANT_ID = "tenant_id";
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
@ -21,8 +21,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.onosproject.codec.CodecContext;
|
import org.onosproject.codec.CodecContext;
|
||||||
import org.onosproject.codec.JsonCodec;
|
import org.onosproject.codec.JsonCodec;
|
||||||
import org.onosproject.openstackswitching.impl.OpenstackSecurityGroup;
|
import org.onosproject.openstacknetworking.OpenstackSecurityGroup;
|
||||||
import org.onosproject.openstackswitching.impl.OpenstackSecurityGroupRule;
|
import org.onosproject.openstacknetworking.OpenstackSecurityGroupRule;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -33,8 +33,7 @@ import java.util.Collection;
|
|||||||
*/
|
*/
|
||||||
public class OpenstackSecurityGroupCodec extends JsonCodec<OpenstackSecurityGroup> {
|
public class OpenstackSecurityGroupCodec extends JsonCodec<OpenstackSecurityGroup> {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackSecurityGroupCodec.class);
|
|
||||||
|
|
||||||
private static final String SECURITY_GROUP = "security_group";
|
private static final String SECURITY_GROUP = "security_group";
|
||||||
private static final String DESCRIPTION = "description";
|
private static final String DESCRIPTION = "description";
|
||||||
@ -66,7 +65,7 @@ public class OpenstackSecurityGroupCodec extends JsonCodec<OpenstackSecurityGrou
|
|||||||
Collection<OpenstackSecurityGroupRule> rules = Lists.newArrayList();
|
Collection<OpenstackSecurityGroupRule> rules = Lists.newArrayList();
|
||||||
for (JsonNode ruleInfo: ruleInfoList) {
|
for (JsonNode ruleInfo: ruleInfoList) {
|
||||||
OpenstackSecurityGroupRule openstackSecurityGroupRule =
|
OpenstackSecurityGroupRule openstackSecurityGroupRule =
|
||||||
OpenstackSecurityGroupRule.builder()
|
new OpenstackSecurityGroupRule.Builder()
|
||||||
.direction(ruleInfo.path(DIRECTION).asText())
|
.direction(ruleInfo.path(DIRECTION).asText())
|
||||||
.etherType(ruleInfo.path(EHTERTYPE).asText())
|
.etherType(ruleInfo.path(EHTERTYPE).asText())
|
||||||
.id(ruleInfo.path(ID).asText())
|
.id(ruleInfo.path(ID).asText())
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@ -24,18 +24,19 @@ import com.google.common.collect.Lists;
|
|||||||
import org.onlab.packet.Ip4Address;
|
import org.onlab.packet.Ip4Address;
|
||||||
import org.onosproject.codec.CodecContext;
|
import org.onosproject.codec.CodecContext;
|
||||||
import org.onosproject.codec.JsonCodec;
|
import org.onosproject.codec.JsonCodec;
|
||||||
import org.onosproject.openstackswitching.OpenstackSubnet;
|
import org.onosproject.openstacknetworking.OpenstackSubnet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes and decodes the OpenstackSubnet.
|
* Encodes and decodes the OpenstackSubnet.
|
||||||
*/
|
*/
|
||||||
public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
|
public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
|
||||||
private static Logger log = LoggerFactory
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
.getLogger(OpenstackSubnetCodec.class);
|
|
||||||
|
|
||||||
// JSON Field names
|
// JSON Field names
|
||||||
private static final String SUBNET = "subnet";
|
private static final String SUBNET = "subnet";
|
||||||
@ -50,6 +51,7 @@ public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OpenstackSubnet decode(ObjectNode json, CodecContext context) {
|
public OpenstackSubnet decode(ObjectNode json, CodecContext context) {
|
||||||
|
checkNotNull(json);
|
||||||
JsonNode subnetInfo = json.get(SUBNET);
|
JsonNode subnetInfo = json.get(SUBNET);
|
||||||
if (subnetInfo == null) {
|
if (subnetInfo == null) {
|
||||||
subnetInfo = json;
|
subnetInfo = json;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching.web;
|
package org.onosproject.openstacknetworking.web;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles Rest API call from Neutron ML2 plugin.
|
* Handles Rest API call from Neutron ML2 plugin.
|
||||||
@ -47,21 +47,18 @@ public class OpenstackSubnetWebResource extends AbstractWebResource {
|
|||||||
|
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{subnetUUID}")
|
@Path("{subnetId}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Response updateSubnet(@PathParam("id") String id,
|
public Response updateSubnet(@PathParam("subnetId") String id,
|
||||||
final InputStream input) {
|
final InputStream input) {
|
||||||
return Response.status(Response.Status.OK).build();
|
return Response.status(Response.Status.OK).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{subnetUUID}")
|
@Path("{subnetId}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
public Response deleteSubnet(@PathParam("subnetId") String id) {
|
||||||
public Response deleteSubnet(@PathParam("id") String id,
|
|
||||||
final InputStream input) {
|
|
||||||
return Response.status(Response.Status.OK).build();
|
return Response.status(Response.Status.OK).build();
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OpenStack switch API.
|
* OpenStack networking implementation.
|
||||||
*/
|
*/
|
||||||
package org.onosproject.openstackswitching;
|
package org.onosproject.openstacknetworking.web;
|
@ -30,10 +30,10 @@
|
|||||||
<init-param>
|
<init-param>
|
||||||
<param-name>com.sun.jersey.config.property.classnames</param-name>
|
<param-name>com.sun.jersey.config.property.classnames</param-name>
|
||||||
<param-value>
|
<param-value>
|
||||||
org.onosproject.openstackswitching.web.OpenstackPortWebResource,
|
org.onosproject.openstacknetworking.web.OpenstackPortWebResource,
|
||||||
org.onosproject.openstackswitching.web.OpenstackNetworkWebResource,
|
org.onosproject.openstacknetworking.web.OpenstackNetworkWebResource,
|
||||||
org.onosproject.openstackswitching.web.OpenstackSubnetWebResource,
|
org.onosproject.openstacknetworking.web.OpenstackSubnetWebResource,
|
||||||
org.onosproject.openstackswitching.web.OpensatckRouterWebResource
|
org.onosproject.openstacknetworking.web.OpensatckRouterWebResource
|
||||||
</param-value>
|
</param-value>
|
||||||
</init-param>
|
</init-param>
|
||||||
<load-on-startup>1</load-on-startup>
|
<load-on-startup>1</load-on-startup>
|
@ -1,174 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015-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.openstackswitching;
|
|
||||||
|
|
||||||
import org.onosproject.net.Port;
|
|
||||||
import org.onosproject.openstackrouting.OpenstackRouter;
|
|
||||||
import org.onosproject.openstackrouting.OpenstackRouterInterface;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles port management REST API from Openstack for VMs.
|
|
||||||
*/
|
|
||||||
public interface OpenstackSwitchingService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store the port information created by Openstack.
|
|
||||||
*
|
|
||||||
* @param openstackPort port information
|
|
||||||
*/
|
|
||||||
void createPorts(OpenstackPort openstackPort);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes flow rules corresponding to the port removed by Openstack.
|
|
||||||
*
|
|
||||||
* @param uuid UUID
|
|
||||||
*/
|
|
||||||
void deletePort(String uuid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates flow rules corresponding to the port information updated by Openstack.
|
|
||||||
*
|
|
||||||
* @param openstackPort OpenStack port
|
|
||||||
*/
|
|
||||||
void updatePort(OpenstackPort openstackPort);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores the network information created by openstack.
|
|
||||||
*
|
|
||||||
* @param openstackNetwork network information
|
|
||||||
*/
|
|
||||||
void createNetwork(OpenstackNetwork openstackNetwork);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 list.
|
|
||||||
*
|
|
||||||
* @return port information list
|
|
||||||
*/
|
|
||||||
Collection<OpenstackPort> ports();
|
|
||||||
/**
|
|
||||||
* Returns port information for the port given.
|
|
||||||
*
|
|
||||||
* @param port port reference
|
|
||||||
* @return port information
|
|
||||||
*/
|
|
||||||
OpenstackPort port(Port port);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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, or null if not present
|
|
||||||
*/
|
|
||||||
OpenstackNetwork network(String networkId);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns subnet information for the subnet ID give.
|
|
||||||
*
|
|
||||||
* @param subnetId Subnet ID
|
|
||||||
* @return subnet information, or null if not present
|
|
||||||
*/
|
|
||||||
OpenstackSubnet subnet(String subnetId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the created router information to OpenstackRouting service.
|
|
||||||
*
|
|
||||||
* @param openstackRouter Router Information
|
|
||||||
*/
|
|
||||||
void createRouter(OpenstackRouter openstackRouter);
|
|
||||||
/**
|
|
||||||
* Sends the updated router information to OpenstackRouting service.
|
|
||||||
*
|
|
||||||
* @param routerId Router ID
|
|
||||||
*/
|
|
||||||
void updateRouter(String routerId);
|
|
||||||
/**
|
|
||||||
* Sends the removed router information to OpenstackRouting service.
|
|
||||||
*
|
|
||||||
* @param routerId Router ID
|
|
||||||
*/
|
|
||||||
void deleteRouter(String routerId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the updated router interface information to OpenstackRouting service.
|
|
||||||
*
|
|
||||||
* @param openstackRouterInterface Router interface information
|
|
||||||
*/
|
|
||||||
void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the removed router interface information to OpenstackRouting service.
|
|
||||||
*
|
|
||||||
* @param openstackRouterInterface Router interface information
|
|
||||||
*/
|
|
||||||
void removeRouterInterface(OpenstackRouterInterface openstackRouterInterface);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the router information list.
|
|
||||||
*
|
|
||||||
* @return router information list
|
|
||||||
*/
|
|
||||||
Collection<OpenstackRouter> routers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the router information for the router ID given.
|
|
||||||
*
|
|
||||||
* @param routerId router ID
|
|
||||||
* @return router information
|
|
||||||
*/
|
|
||||||
OpenstackRouter router(String routerId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the OpensatckPortInfo list.
|
|
||||||
*
|
|
||||||
* @return OpensatckPortInfo list
|
|
||||||
*/
|
|
||||||
Collection<OpenstackPortInfo> portInfos();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the MacAddress for physical router.
|
|
||||||
*
|
|
||||||
* @return physical router mac
|
|
||||||
*/
|
|
||||||
String physicalRouterMac();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -59,16 +59,15 @@
|
|||||||
<module>igmp</module>
|
<module>igmp</module>
|
||||||
<module>pim</module>
|
<module>pim</module>
|
||||||
<module>mlb</module>
|
<module>mlb</module>
|
||||||
<module>openstackswitching</module>
|
|
||||||
<module>pathpainter</module>
|
<module>pathpainter</module>
|
||||||
<module>drivermatrix</module>
|
<module>drivermatrix</module>
|
||||||
<module>cpman</module>
|
<module>cpman</module>
|
||||||
<module>events</module>
|
<module>events</module>
|
||||||
<module>vrouter</module>
|
<module>vrouter</module>
|
||||||
<module>openstackrouting</module>
|
|
||||||
<module>cordmcast</module>
|
<module>cordmcast</module>
|
||||||
<module>vpls</module>
|
<module>vpls</module>
|
||||||
<module>openstacknode</module>
|
<module>openstacknode</module>
|
||||||
|
<module>openstacknetworking</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user