aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/openstackswitching/api
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/openstackswitching/api')
-rw-r--r--framework/src/onos/apps/openstackswitching/api/pom.xml50
-rw-r--r--framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackNetwork.java127
-rw-r--r--framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackPort.java362
-rw-r--r--framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSubnet.java161
-rw-r--r--framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSwitchingService.java92
-rw-r--r--framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/package-info.java20
6 files changed, 812 insertions, 0 deletions
diff --git a/framework/src/onos/apps/openstackswitching/api/pom.xml b/framework/src/onos/apps/openstackswitching/api/pom.xml
new file mode 100644
index 00000000..f5e6f94f
--- /dev/null
+++ b/framework/src/onos/apps/openstackswitching/api/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015 Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-openstackswitching</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-app-openstackswitching-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>SONA Openstack Switching application API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackNetwork.java b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackNetwork.java
new file mode 100644
index 00000000..1b28d0c4
--- /dev/null
+++ b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackNetwork.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstackswitching;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+
+/**
+ * Represents the network information given by Neutron.
+ */
+public final class OpenstackNetwork {
+
+ private String name;
+ private String tenantId;
+ private String segmentId;
+ private String id;
+ private NetworkType networkType;
+
+ public enum NetworkType {
+ /**
+ * Currently only VXLAN moded is supported.
+ */
+ VXLAN,
+ VLAN,
+ STT,
+ LOCAL
+ }
+
+ /**
+ * Returns the builder object of the OpenstackNetwork class.
+ *
+ * @return OpenstackNetwork builder object
+ */
+ public static OpenstackNetwork.Builder builder() {
+ return new Builder();
+ }
+
+ private OpenstackNetwork(String name, String tenantId, String id, String sid,
+ NetworkType type) {
+ this.name = checkNotNull(name);
+ this.tenantId = checkNotNull(tenantId);
+ this.segmentId = checkNotNull(sid);
+ this.id = checkNotNull(id);
+ this.networkType = type;
+ }
+
+ public String name() {
+ return this.name;
+ }
+
+ public String tenantId() {
+ return this.tenantId;
+ }
+
+ public String id() {
+ return this.id;
+ }
+
+ public String segmentId() {
+ return this.segmentId;
+ }
+
+ public NetworkType networkType() {
+ return this.networkType;
+ }
+
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public static final class Builder {
+ private String name;
+ private String tenantId;
+ private String id;
+ private String sid;
+ private NetworkType networkType;
+
+ public Builder name(String name) {
+ this.name = name;
+
+ return this;
+ }
+
+ public Builder tenantId(String tenantId) {
+ this.tenantId = tenantId;
+
+ return this;
+ }
+
+ public Builder id(String id) {
+ this.id = id;
+
+ return this;
+ }
+
+ public Builder segmentId(String sid) {
+ this.sid = sid;
+
+ return this;
+ }
+
+ public Builder networkType(NetworkType type) {
+ this.networkType = type;
+
+ return this;
+ }
+
+ public OpenstackNetwork build() {
+ return new OpenstackNetwork(name, tenantId, id, sid, networkType);
+ }
+
+ }
+}
diff --git a/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackPort.java b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackPort.java
new file mode 100644
index 00000000..1613b597
--- /dev/null
+++ b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackPort.java
@@ -0,0 +1,362 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstackswitching;
+
+import com.google.common.collect.Lists;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.MacAddress;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * It represents the Openstack Port information.
+ */
+public final class OpenstackPort {
+
+ public enum PortStatus {
+ UP,
+ DOWN,
+ ACTIVE
+ }
+
+ private PortStatus status;
+ private String name;
+ // FIX_ME
+ private String allowedAddressPairs;
+ private boolean adminStateUp;
+ private String networkId;
+ private String tenantId;
+ private String deviceOwner;
+ private MacAddress macAddress;
+ // <subnet id, ip address>
+ private HashMap<String, Ip4Address> fixedIps;
+ private String id;
+ private List<String> securityGroups;
+ private String deviceId;
+
+ private OpenstackPort(PortStatus status, String name, boolean adminStateUp,
+ String networkId, String tenantId, String deviceOwner,
+ MacAddress macAddress, HashMap fixedIps, String id,
+ List<String> securityGroups, String deviceId) {
+
+ this.status = status;
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.networkId = checkNotNull(networkId);
+ this.tenantId = checkNotNull(tenantId);
+ this.deviceOwner = deviceOwner;
+ this.macAddress = checkNotNull(macAddress);
+ this.fixedIps = checkNotNull(fixedIps);
+ this.id = checkNotNull(id);
+ this.securityGroups = securityGroups;
+ this.deviceId = deviceId;
+ }
+
+
+
+ /**
+ * Returns OpenstackPort builder object.
+ *
+ * @return OpenstackPort builder
+ */
+ public static OpenstackPort.Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Returns port status.
+ *
+ * @return port status
+ */
+ public PortStatus status() {
+ return status;
+ }
+
+ /**
+ * Returns port name.
+ *
+ * @return port name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Returns whether admin state up or not.
+ *
+ * @return true if admin state up, false otherwise
+ */
+ public boolean isAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * Returns network ID.
+ *
+ * @return network ID
+ */
+ public String networkId() {
+ return networkId;
+ }
+
+ /**
+ * Returns device owner.
+ *
+ * @return device owner
+ */
+ public String deviceOwner() {
+ return deviceOwner;
+ }
+
+ /**
+ * Returns mac address.
+ *
+ * @return mac address
+ */
+ public MacAddress macAddress() {
+ return macAddress;
+ }
+
+ /**
+ * Returns the fixed IP information.
+ *
+ * @return fixed IP info
+ */
+ public HashMap fixedIps() {
+ return fixedIps;
+ }
+
+ /**
+ * Returns port ID.
+ *
+ * @return port ID
+ */
+ public String id() {
+ return id;
+ }
+
+ /**
+ * Returns security group information.
+ *
+ * @return security group info
+ */
+ public List<String> securityGroups() {
+ return securityGroups;
+ }
+
+ /**
+ * Returns device ID.
+ *
+ * @return device ID
+ */
+ public String deviceId() {
+ return deviceId;
+ }
+
+ // TODO : Implement the following functions when necessary
+ //@Override
+ //public void equals(Object that) {
+ //
+ //}
+ //
+ //@Override
+ //public int hashCode() {
+ //
+ //}
+
+ @Override
+ public Object clone() {
+ OpenstackPort op = new OpenstackPort(this.status, this.name, this.adminStateUp,
+ this.networkId, this.tenantId, this.deviceOwner, this.macAddress,
+ (HashMap) this.fixedIps.clone(), this.id,
+ Collections.unmodifiableList(this.securityGroups), this.deviceId);
+
+ return op;
+ }
+
+ /**
+ * OpenstackPort Builder class.
+ */
+ public static final class Builder {
+
+ private PortStatus status;
+ private String name;
+ // FIX_ME
+ private String allowedAddressPairs;
+ private boolean adminStateUp;
+ private String networkId;
+ private String tenantId;
+ private String deviceOwner;
+ private MacAddress macAddress;
+ // list of hash map <subnet id, ip address>
+ private HashMap<String, Ip4Address> fixedIps;
+ private String id;
+ private List<String> securityGroups;
+ private String deviceId;
+
+ Builder() {
+ fixedIps = new HashMap<>();
+ securityGroups = Lists.newArrayList();
+ }
+
+ /**
+ * Sets port status.
+ *
+ * @param status port status
+ * @return Builder object
+ */
+ public Builder portStatus(PortStatus status) {
+ this.status = status;
+
+ return this;
+ }
+
+ /**
+ * Sets port name.
+ *
+ * @param name port name
+ * @return Builder object
+ */
+ public Builder name(String name) {
+ this.name = name;
+
+ return this;
+ }
+
+ /**
+ * Sets whether admin state up or not.
+ *
+ * @param isAdminStateUp true if admin state is up, false otherwise
+ * @return Builder object
+ */
+ public Builder adminState(boolean isAdminStateUp) {
+ this.adminStateUp = isAdminStateUp;
+
+ return this;
+ }
+
+ /**
+ * Sets network ID.
+ *
+ * @param networkId network ID
+ * @return Builder object
+ */
+ public Builder netwrokId(String networkId) {
+ this.networkId = networkId;
+
+ return this;
+ }
+
+ /**
+ * Sets tenant ID.
+ *
+ * @param tenantId tenant ID
+ * @return Builder object
+ */
+ public Builder tenantId(String tenantId) {
+ this.tenantId = tenantId;
+
+ return this;
+ }
+
+ /**
+ * Sets device owner.
+ *
+ * @param owner device owner
+ * @return Builder object
+ */
+ public Builder deviceOwner(String owner) {
+ this.deviceOwner = owner;
+
+ return this;
+ }
+
+ /**
+ * Sets MAC address of the port.
+ *
+ * @param mac MAC address
+ * @return Builder object
+ */
+ public Builder macAddress(MacAddress mac) {
+ this.macAddress = mac;
+
+ return this;
+ }
+
+ /**
+ * Sets Fixed IP address information.
+ *
+ * @param fixedIpList Fixed IP info
+ * @return Builder object
+ */
+ public Builder fixedIps(HashMap<String, Ip4Address> fixedIpList) {
+ fixedIps.putAll(fixedIpList);
+
+ return this;
+ }
+
+ /**
+ * Sets ID of the port.
+ *
+ * @param id ID of the port
+ * @return Builder object
+ */
+ public Builder id(String id) {
+ this.id = id;
+
+ return this;
+ }
+
+ /**
+ * Sets security group of the port.
+ *
+ * @param securityGroup security group of the port
+ * @return Builder object
+ */
+ public Builder securityGroup(String securityGroup) {
+ securityGroups.add(securityGroup);
+
+ return this;
+ }
+
+ /**
+ * Sets device ID of the port.
+ *
+ * @param deviceId device ID
+ * @return Builder object
+ */
+ public Builder deviceId(String deviceId) {
+ this.deviceId = deviceId;
+
+ return this;
+ }
+
+ /**
+ * Builds an OpenstackPort object.
+ *
+ * @return OpenstackPort objecet
+ */
+ public OpenstackPort build() {
+ return new OpenstackPort(status, name, adminStateUp, networkId, networkId,
+ deviceOwner, macAddress, fixedIps, id, securityGroups, deviceId);
+ }
+ }
+}
+
diff --git a/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSubnet.java b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSubnet.java
new file mode 100644
index 00000000..bc536e88
--- /dev/null
+++ b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSubnet.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstackswitching;
+
+import org.onlab.packet.Ip4Address;
+
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents the subnet information given by Neutron.
+ *
+ */
+public final class OpenstackSubnet {
+ private String name;
+ private boolean enableHhcp;
+ private String networkId;
+ private String tenantId;
+ private List<Ip4Address> dnsNameservers;
+ private String gatewayIp;
+ private String cidr;
+ private String id;
+
+ private OpenstackSubnet(String name, boolean enableHhcp, String networkId,
+ String tenantId, List<Ip4Address> dnsNameservers, String gatewayIp,
+ String cidr, String id) {
+ this.name = name;
+ this.enableHhcp = enableHhcp;
+ this.networkId = checkNotNull(networkId);
+ this.tenantId = checkNotNull(tenantId);
+ this.dnsNameservers = dnsNameservers;
+ this.gatewayIp = gatewayIp;
+ this.cidr = checkNotNull(cidr);
+ this.id = checkNotNull(id);
+ }
+
+ /**
+ * Returns OpenstackSubnet builder object.
+ *
+ * @return OpenstackSubnet builder
+ */
+ public static OpenstackSubnet.Builder builder() {
+ return new Builder();
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public boolean enableHhcp() {
+ return enableHhcp;
+ }
+
+ public String networkId() {
+ return networkId;
+ }
+
+ public String tenantId() {
+ return tenantId;
+ }
+
+ public List<Ip4Address> dnsNameservers() {
+ return dnsNameservers;
+ }
+
+ public String gatewayIp() {
+ return gatewayIp;
+ }
+
+ public String cidr() {
+ return cidr;
+ }
+
+ public String id() {
+ return id;
+ }
+
+ /**
+ * OpenstackSubnet Builder class.
+ *
+ */
+ public static final class Builder {
+ private String name;
+ private boolean enableDhcp;
+ private String networkId;
+ private String tenantId;
+ private List<Ip4Address> dnsNameservers;
+ private String gatewayIp;
+ private String cidr;
+ private String id;
+
+ Builder() {}
+
+ public Builder setName(String name) {
+ this.name = name;
+
+ return this;
+ }
+
+ public Builder setEnableDhcp(boolean enableDhcp) {
+ this.enableDhcp = enableDhcp;
+
+ return this;
+ }
+
+ public Builder setNetworkId(String networkId) {
+ this.networkId = networkId;
+
+ return this;
+ }
+
+ public Builder setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+
+ return this;
+ }
+
+ public Builder setDnsNameservers(List<Ip4Address> dnsNameservers) {
+ this.dnsNameservers = dnsNameservers;
+
+ return this;
+ }
+
+ public Builder setGatewayIp(String gatewayIp) {
+ this.gatewayIp = gatewayIp;
+
+ return this;
+ }
+
+ public Builder setCidr(String cidr) {
+ this.cidr = cidr;
+
+ return this;
+ }
+
+ public Builder setId(String id) {
+ this.id = id;
+
+ return this;
+ }
+
+ public OpenstackSubnet build() {
+ return new OpenstackSubnet(name, enableDhcp, networkId, tenantId,
+ dnsNameservers, gatewayIp, cidr, id);
+ }
+ }
+}
diff --git a/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSwitchingService.java b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSwitchingService.java
new file mode 100644
index 00000000..59b8db0c
--- /dev/null
+++ b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/OpenstackSwitchingService.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstackswitching;
+
+import org.onosproject.net.Port;
+
+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.
+ *
+ */
+ void deletePorts();
+
+ /**
+ * Updates flow rules corresponding to the port information updated by Openstack.
+ *
+ */
+ void updatePorts();
+
+ /**
+ * 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 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
+ */
+ OpenstackNetwork network(String networkId);
+
+}
diff --git a/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/package-info.java b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/package-info.java
new file mode 100644
index 00000000..cd50f912
--- /dev/null
+++ b/framework/src/onos/apps/openstackswitching/api/src/main/java/org/onosproject/openstackswitching/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * OpenStack switch interface.
+ */
+package org.onosproject.openstackswitching;