Jonathan Hart
Committed by Gerrit Code Review

Remove old CordFabric app

Change-Id: Id8b22f3ab78adae6f09e94f54ec15bc743459cb2
<?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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>onos-app-cordfabric</artifactId>
<packaging>bundle</packaging>
<description>Simple fabric application for CORD</description>
<properties>
<onos.app.name>org.onosproject.cordfabric</onos.app.name>
<onos.app.title>CORD Fabric App</onos.app.title>
<onos.app.category>Traffic Steering</onos.app.category>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.readme>Simple fabric application for CORD.</onos.app.readme>
<web.context>/onos/cordfabric</web.context>
<api.version>1.0.0</api.version>
<api.title>ONOS CORD Fabric REST API</api.title>
<api.description>
APIs for interacting with the CORD Fabric application.
</api.description>
<api.package>org.onosproject.cordfabric</api.package>
</properties>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_wab>src/main/webapp/</_wab>
<Include-Resource>
WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
{maven-resources}
</Include-Resource>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Import-Package>
org.slf4j,
org.osgi.framework,
javax.ws.rs,
javax.ws.rs.core,
org.glassfish.jersey,
org.glassfish.jersey.servlet,
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.node,
org.apache.karaf.shell.commands,
com.google.common.*,
org.onlab.packet.*,
org.onosproject.*,
</Import-Package>
<Web-ContextPath>${web.context}</Web-ContextPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
/*
* 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.cordfabric;
import org.onlab.packet.VlanId;
import java.util.List;
/**
* Service used to interact with fabric.
*/
public interface FabricService {
/**
* Remaps a vlan to the specified ports. The specified ports will be the
* only ports in this vlan once the operation completes.
*
* @param vlan vlan object to add
*/
void addVlan(FabricVlan vlan);
/**
* Removes a vlan from all ports in the fabric.
*
* @param vlanId ID of vlan to remove
*/
void removeVlan(VlanId vlanId);
/**
* Returns the vlan to port mapping for all vlans/ports configured in the
* fabric.
*
* @return mapping of vlan to port
*/
List<FabricVlan> getVlans();
}
/*
* 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.cordfabric;
import com.google.common.collect.ImmutableList;
import org.onlab.packet.VlanId;
import org.onosproject.net.ConnectPoint;
import java.util.Collection;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Vlan which spans multiple fabric ports.
*/
public class FabricVlan {
private final VlanId vlan;
private final List<ConnectPoint> ports;
private final boolean iptv;
public FabricVlan(VlanId vlan, Collection<ConnectPoint> ports, boolean iptv) {
checkNotNull(vlan);
checkNotNull(ports);
this.vlan = vlan;
this.ports = ImmutableList.copyOf(ports);
this.iptv = iptv;
}
public VlanId vlan() {
return vlan;
}
public List<ConnectPoint> ports() {
return ports;
}
public boolean iptv() {
return iptv;
}
}
/*
* 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.cordfabric;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onlab.packet.VlanId;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.net.ConnectPoint;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Codec for encoding/decoding a FabricVlan object to/from JSON.
*/
public final class FabricVlanCodec extends JsonCodec<FabricVlan> {
// JSON field names
private static final String VLAN = "vlan";
private static final String PORTS = "ports";
private static final String IPTV = "iptv";
@Override
public ObjectNode encode(FabricVlan vlan, CodecContext context) {
checkNotNull(vlan, "Vlan cannot be null");
final ObjectNode result = context.mapper().createObjectNode()
.put(VLAN, vlan.vlan().toShort());
final ArrayNode jsonPorts = result.putArray(PORTS);
vlan.ports().forEach(cp -> jsonPorts.add(context.codec(ConnectPoint.class).encode(cp, context)));
return result;
}
@Override
public FabricVlan decode(ObjectNode json, CodecContext context) {
short vlan = json.path(VLAN).shortValue();
boolean iptv = json.path(IPTV).booleanValue();
List<ConnectPoint> ports = new ArrayList<>();
ArrayNode portArray = (ArrayNode) json.path(PORTS);
for (JsonNode o : portArray) {
ports.add(context.codec(ConnectPoint.class).decode((ObjectNode) o, context));
}
return new FabricVlan(VlanId.vlanId(vlan), ports, iptv);
}
}
/*
* 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.cordfabric;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onlab.packet.VlanId;
import org.onosproject.rest.AbstractWebResource;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* Web resource for interacting with the fabric.
*/
@Path("vlans")
public class FabricWebResource extends AbstractWebResource {
private static final FabricVlanCodec VLAN_CODEC = new FabricVlanCodec();
/**
* Get all CORD fabric VLANs.
*
* @return array of cord VLANs in the system.
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getVlans() {
FabricService fabricService = get(FabricService.class);
List<FabricVlan> vlans = fabricService.getVlans();
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("vlans", new FabricVlanCodec().encode(vlans, this));
return ok(result.toString()).build();
}
/**
* Create a CORD fabric VLAN.
*
* @param input JSON stream describing new VLAN
* @return status of the request - CREATED if the JSON is correct,
* INTERNAL_SERVER_ERROR if the JSON is invalid
* @throws IOException if the JSON is invalid
*/
@POST
@Path("add")
@Consumes(MediaType.APPLICATION_JSON)
public Response addVlan(InputStream input) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode vlanJson = (ObjectNode) mapper.readTree(input);
FabricService fabricService = get(FabricService.class);
fabricService.addVlan(VLAN_CODEC.decode(vlanJson, this));
return Response.ok().build();
}
/**
* Delete a CORD fabric VLAN.
*
* @param vlan identifier of the VLAN to remove
* @return status of the request - OK
*/
@DELETE
@Path("{vlan}")
public Response deleteVlan(@PathParam("vlan") String vlan) {
VlanId vlanId = VlanId.vlanId(Short.parseShort(vlan));
FabricService fabricService = get(FabricService.class);
fabricService.removeVlan(vlanId);
return Response.ok().build();
}
}
/*
* 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.cordfabric.cli;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onlab.packet.VlanId;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.cordfabric.FabricService;
import org.onosproject.cordfabric.FabricVlan;
import org.onosproject.net.ConnectPoint;
import java.util.ArrayList;
import java.util.List;
/**
* Adds a vlan to the fabric.
*/
@Command(scope = "onos", name = "add-fabric-vlan",
description = "Adds a VLAN to the fabric")
public class FabricAddCommand extends AbstractShellCommand {
@Argument(index = 0, name = "vlanid", description = "VLAN ID",
required = true, multiValued = false)
private String vlanIdString = null;
@Argument(index = 1, name = "ports",
description = "List of ports in the VLAN",
required = true, multiValued = true)
private String[] portStrings = null;
@Override
protected void execute() {
FabricService service = AbstractShellCommand.get(FabricService.class);
VlanId vlan = VlanId.vlanId(Short.parseShort(vlanIdString));
if (portStrings.length < 2) {
throw new IllegalArgumentException("Must have at least 2 ports");
}
List<ConnectPoint> ports = new ArrayList<>(portStrings.length);
for (String portString : portStrings) {
ports.add(ConnectPoint.deviceConnectPoint(portString));
}
service.addVlan(new FabricVlan(vlan, ports, false));
}
}
/*
* 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.cordfabric.cli;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onlab.packet.VlanId;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.cordfabric.FabricService;
/**
* Removes a vlan from the fabric.
*/
@Command(scope = "onos", name = "remove-fabric-vlan",
description = "Removes a VLAN from the fabric")
public class FabricRemoveCommand extends AbstractShellCommand {
@Argument(index = 0, name = "vlanid", description = "VLAN ID",
required = true, multiValued = false)
private String vlanIdString = null;
@Override
protected void execute() {
FabricService service = AbstractShellCommand.get(FabricService.class);
VlanId vlan = VlanId.vlanId(Short.parseShort(vlanIdString));
service.removeVlan(vlan);
}
}
/*
* 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.cordfabric.cli;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.cordfabric.FabricService;
import org.onosproject.cordfabric.FabricVlan;
import java.util.List;
/**
* Shows the vlans in the fabric.
*/
@Command(scope = "onos", name = "fabric",
description = "Shows the fabric vlans")
public class FabricShowCommand extends AbstractShellCommand {
private static final String VLAN_HEADER_LINE_FORMAT = "VLAN %s";
private static final String PORT_LINE_FORMAT = "\t%s";
@Override
protected void execute() {
FabricService service = AbstractShellCommand.get(FabricService.class);
List<FabricVlan> vlans = service.getVlans();
vlans.forEach(fabricVlan -> {
print(VLAN_HEADER_LINE_FORMAT, fabricVlan.vlan());
fabricVlan.ports().forEach(cp -> print(PORT_LINE_FORMAT, cp));
});
}
}
/*
* 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.
*/
/**
* Console commands for managing fabric of VLANs.
*/
package org.onosproject.cordfabric.cli;
\ No newline at end of file
/*
* 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.
*/
/**
* Service for managing fabric of VLANs.
*/
package org.onosproject.cordfabric;
\ No newline at end of file
<!--
~ 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.
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
<command>
<action class="org.onosproject.cordfabric.cli.FabricShowCommand"/>
</command>
<command>
<action class="org.onosproject.cordfabric.cli.FabricAddCommand"/>
<completers>
<ref component-id="placeholderCompleter"/>
<ref component-id="connectPointCompleter"/>
</completers>
</command>
<command>
<action class="org.onosproject.cordfabric.cli.FabricRemoveCommand"/>
</command>
</command-bundle>
<bean id="connectPointCompleter" class="org.onosproject.cli.net.ConnectPointCompleter"/>
<bean id="placeholderCompleter" class="org.onosproject.cli.PlaceholderCompleter"/>
</blueprint>
<?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.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="ONOS" version="2.5">
<display-name>CORD Fabric REST API v1.0</display-name>
<servlet>
<servlet-name>JAX-RS Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>
org.onosproject.cordfabric.FabricWebResource
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Service</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
......@@ -46,7 +46,6 @@
<module>bgprouter</module>
<module>test</module>
<module>segmentrouting</module>
<module>cordfabric</module>
<module>xos-integration</module>
<module>pcep-api</module>
<module>iptopology-api</module>
......