Move patchpanel app to onos-app-samples
Change-Id: I03d995e42e488558dc69100a1ecef766586f33d2
diff --git a/apps/patchpanel/BUCK b/apps/patchpanel/BUCK
deleted file mode 100644
index 77f75b3..0000000
--- a/apps/patchpanel/BUCK
+++ /dev/null
@@ -1,16 +0,0 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//lib:org.apache.karaf.shell.console',
- '//cli:onos-cli',
-]
-
-osgi_jar (
- deps = COMPILE_DEPS,
-)
-
-onos_app (
- title = 'Patch Panel',
- category = 'Traffic Steering',
- url = 'http://onosproject.org',
- description = 'Creates patches between ports on a switch',
-)
diff --git a/apps/patchpanel/pom.xml b/apps/patchpanel/pom.xml
deleted file mode 100644
index 99eb985..0000000
--- a/apps/patchpanel/pom.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2016-present Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<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.9.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>patchpanel</artifactId>
- <packaging>bundle</packaging>
-
- <description>ONOS patch panel application</description>
- <url>http://onosproject.org</url>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <onos.app.name>org.onosproject.patchpanel</onos.app.name>
- <onos.app.title>Patch Panel</onos.app.title>
- <onos.app.origin>ON.Lab</onos.app.origin>
- <onos.app.category>Traffic Steering</onos.app.category>
- <onos.app.url>http://onosproject.org</onos.app.url>
- <onos.app.readme>Creates patches between ports on a switch</onos.app.readme>
- </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>
-
- </dependencies>
-
-</project>
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchListCommand.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchListCommand.java
deleted file mode 100644
index 9d8f088..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchListCommand.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This class defines the cli command for the PatchPanel class. It creates
- * an instance of the PatchPanelService class to call it's method addPatch().
- * The command takes 2 parameters, 2 connectPoints.
- */
-package org.onosproject.patchpanel.cli;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.patchpanel.impl.Patch;
-import org.onosproject.patchpanel.impl.PatchPanelService;
-
-/**
- * Lists the patches.
- */
-@Command(scope = "onos", name = "patches",
- description = "Lists the patches")
-public class PatchListCommand extends AbstractShellCommand {
-
- private static final String FORMAT = "%s: %s <-> %s";
-
- @Override
- protected void execute() {
- PatchPanelService patchPanelService = get(PatchPanelService.class);
-
- patchPanelService.getPatches().forEach(this::print);
- }
-
- private void print(Patch patch) {
- print(FORMAT, patch.id(), patch.port1(), patch.port2());
- }
-
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchPanelCommand.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchPanelCommand.java
deleted file mode 100644
index 5b6221a..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchPanelCommand.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This class defines the cli command for the PatchPanel class. It creates
- * an instance of the PatchPanelService class to call it's method addPatch().
- * The command takes 2 parameters, 2 connectPoints.
- */
-package org.onosproject.patchpanel.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.patchpanel.impl.PatchPanelService;
-
-/**
- * Command for adding a new patch.
- */
-@Command(scope = "onos", name = "patch",
- description = "Gets the 2 ports of one ConnectPoint that will be patched")
-public class PatchPanelCommand extends AbstractShellCommand {
- //the 2 arguments, both connect points
- @Argument(index = 0, name = "switch/portNumber", description = "ConnectPoint and first port number",
- required = true, multiValued = false)
- String port1 = null;
- @Argument (index = 1, name = "switch/portNumber2", description = "ConnectPoint and second port number",
- required = true, multiValued = false)
- String port2 = null;
-
- private ConnectPoint cp1, cp2;
- private PatchPanelService patchPanelService;
- private DeviceId deviceId, deviceId2;
-
- /**
- * This method creates an instance of the Service class and then uses the user
- * input to call the addPatch method in PatchPanel. It also
- * @throws IllegalArgumentException if the 2 connectpoints are of different devices
- */
- @Override
- protected void execute() {
- patchPanelService = get(PatchPanelService.class);
- boolean done = false;
- cp1 = ConnectPoint.deviceConnectPoint(port1);
- cp2 = ConnectPoint.deviceConnectPoint(port2);
- deviceId = cp1.deviceId();
- deviceId2 = cp2.deviceId();
- if (!(deviceId.equals(deviceId2))) {
- throw new IllegalArgumentException("ERROR: Two Different Device Id's");
- } else {
- done = patchPanelService.addPatch(cp1, cp2);
- }
- if (done) {
- log.info("This patch has been created");
- } else {
- log.info("This patch was NOT created");
- }
-
- }
-
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchRemoveCommand.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchRemoveCommand.java
deleted file mode 100644
index 429cd50..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/PatchRemoveCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This class defines the cli command for the PatchPanel class. It creates
- * an instance of the PatchPanelService class to call it's method addPatch().
- * The command takes 2 parameters, 2 connectPoints.
- */
-package org.onosproject.patchpanel.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.patchpanel.impl.PatchId;
-import org.onosproject.patchpanel.impl.PatchPanelService;
-
-/**
- * Removes a patch.
- */
-@Command(scope = "onos", name = "patch-remove",
- description = "Removes a patch")
-public class PatchRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "patchId", description = "ID of patch to remove",
- required = true, multiValued = false)
- String id = null;
-
- private PatchPanelService patchPanelService;
-
- @Override
- protected void execute() {
- patchPanelService = get(PatchPanelService.class);
- boolean done = false;
-
- PatchId patchId = PatchId.patchId(Integer.parseInt(id));
-
- done = patchPanelService.removePatch(patchId);
-
- if (done) {
- log.info("This patch has been removed");
- } else {
- log.info("This patch was NOT removed");
- }
-
- }
-
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/package-info.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/package-info.java
deleted file mode 100644
index f4e7c9e..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/cli/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Patch panel-related CLI commands(in cli folder).
- */
-package org.onosproject.patchpanel.cli;
-
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/Patch.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/Patch.java
deleted file mode 100644
index 3b1c821..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/Patch.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.patchpanel.impl;
-
-import org.onosproject.net.ConnectPoint;
-
-/**
- * Abstraction of a patch between two ports on a switch.
- */
-public class Patch {
-
- private final PatchId patchId;
- private final ConnectPoint port1;
- private final ConnectPoint port2;
-
- /**
- * Creates a new patch.
- *
- * @param patchId patch ID
- * @param port1 first switch port
- * @param port2 second switch port
- */
- public Patch(PatchId patchId, ConnectPoint port1, ConnectPoint port2) {
- this.patchId = patchId;
- this.port1 = port1;
- this.port2 = port2;
- }
-
- /**
- * Gets the patch ID.
- *
- * @return patch ID
- */
- public PatchId id() {
- return patchId;
- }
-
- /**
- * Gets the first connect point.
- *
- * @return connect point
- */
- public ConnectPoint port1() {
- return port1;
- }
-
- /**
- * Gets the second connect point.
- *
- * @return connect point
- */
- public ConnectPoint port2() {
- return port2;
- }
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchId.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchId.java
deleted file mode 100644
index d40cb21..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchId.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.patchpanel.impl;
-
-import org.onlab.util.Identifier;
-
-/**
- * Identifier of a patch.
- */
-public final class PatchId extends Identifier<Integer> {
-
- private PatchId(int id) {
- super(id);
- }
-
- /**
- * Creates a new patch based of an integer.
- *
- * @param id backing value
- * @return patch ID
- */
- public static PatchId patchId(int id) {
- return new PatchId(id);
- }
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanel.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanel.java
deleted file mode 100644
index e10b097..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanel.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.patchpanel.impl;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-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.onosproject.cli.net.ConnectPointCompleter;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultFlowRule;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.packet.PacketPriority;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * This class acts as a software patch panel application.
- * The user specifies 2 connectpoint on the same device that he/she would like to patch.
- * Using a flow rule, the 2 connectpoints are patched.
- */
-@Component(immediate = true)
-@Service
-public class PatchPanel implements PatchPanelService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- // OSGI: help bundle plugin discover runtime package dependency.
- @SuppressWarnings("unused")
- private ConnectPointCompleter connectPointCompleter;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowRuleService flowRuleService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- private Map<PatchId, Patch> patches;
-
- private ApplicationId appId;
-
- private AtomicInteger ids = new AtomicInteger();
-
-
- @Activate
- protected void activate() throws NullPointerException {
- patches = new HashMap<>();
-
- appId = coreService.registerApplication("org.onosproject.patchpanel");
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean addPatch(ConnectPoint cp1, ConnectPoint cp2) {
- checkNotNull(cp1);
- checkNotNull(cp2);
-
- checkArgument(cp1.deviceId().equals(cp2.deviceId()), "Ports must be on the same device");
- checkArgument(!cp1.equals(cp2), "Ports cannot be the same");
-
- if (patches.values().stream()
- .filter(patch -> patch.port1().equals(cp1) || patch.port1().equals(cp2)
- || patch.port2().equals(cp1) || patch.port2().equals(cp2))
- .findAny().isPresent()) {
- log.info("One or both of these ports are already in use, NO FLOW");
- return false;
- }
-
- Patch patch = new Patch(PatchId.patchId(ids.incrementAndGet()), cp1, cp2);
-
- patches.put(patch.id(), patch);
-
- setFlowRuleService(patch);
-
- return true;
- }
-
- @Override
- public boolean removePatch(PatchId id) {
- Patch patch = patches.remove(id);
- if (patch == null) {
- return false;
- }
-
- removePatchFlows(patch);
- return true;
- }
-
- @Override
- public Set<Patch> getPatches() {
- return ImmutableSet.copyOf(patches.values());
- }
-
- public void setFlowRuleService(Patch patch) {
- createFlowRules(patch).forEach(flowRuleService::applyFlowRules);
- }
-
- private void removePatchFlows(Patch patch) {
- createFlowRules(patch).forEach(flowRuleService::removeFlowRules);
- }
-
- private Collection<FlowRule> createFlowRules(Patch patch) {
- DeviceId deviceId = patch.port1().deviceId();
- PortNumber outPort = patch.port2().port();
- PortNumber inPort = patch.port1().port();
- FlowRule fr = DefaultFlowRule.builder()
- .forDevice(deviceId)
- .withSelector(DefaultTrafficSelector.builder().matchInPort(inPort).build())
- .withTreatment(DefaultTrafficTreatment.builder().setOutput(outPort).build())
- .withPriority(PacketPriority.REACTIVE.priorityValue())
- .makePermanent()
- .fromApp(appId).build();
-
- FlowRule fr2 = DefaultFlowRule.builder()
- .forDevice(deviceId)
- .withSelector(DefaultTrafficSelector.builder().matchInPort(outPort).build())
- .withTreatment(DefaultTrafficTreatment.builder().setOutput(inPort).build())
- .withPriority(PacketPriority.REACTIVE.priorityValue())
- .makePermanent()
- .fromApp(appId).build();
-
- return ImmutableList.of(fr, fr2);
- }
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelService.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelService.java
deleted file mode 100644
index 4ece312..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelService.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.patchpanel.impl;
-
-import org.onosproject.net.ConnectPoint;
-
-import java.util.Set;
-
-/**
- * A service for the patch panel application to export and use with the cli.
- */
-public interface PatchPanelService {
-
- /**
- * Adds a new patch between two connect points.
- *
- * @param cp the first connect point
- * @param cp2 the second connect point
- * @return true if the patch was created, false otherwise
- */
- boolean addPatch(ConnectPoint cp, ConnectPoint cp2);
-
- /**
- * Removes an existing patch.
- *
- * @param id patch ID
- * @return true if the patch was removed, otherwise false.
- */
- boolean removePatch(PatchId id);
-
- /**
- * Gets the set of patches in the system.
- *
- * @return set of patches
- */
- Set<Patch> getPatches();
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelUiComponent.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelUiComponent.java
deleted file mode 100644
index ea2f085..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelUiComponent.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.patchpanel.impl;
-
-import com.google.common.collect.ImmutableList;
-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.onosproject.ui.UiExtension;
-import org.onosproject.ui.UiExtensionService;
-import org.onosproject.ui.UiMessageHandlerFactory;
-import org.onosproject.ui.UiView;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-/**
- * ONOS UI Custom-View application component for the Patch Panel Application.
- */
-@Component(immediate = true)
-public class PatchPanelUiComponent {
-
- private static final String VIEW_ID = "sampleCustom";
- private static final String VIEW_TEXT = "Patch Panel Application";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected UiExtensionService uiExtensionService;
-
- // List of application views
- private final List<UiView> uiViews = ImmutableList.of(
- new UiView(UiView.Category.OTHER, VIEW_ID, VIEW_TEXT)
- );
-
- // Factory for UI message handlers
- private final UiMessageHandlerFactory messageHandlerFactory =
- () -> ImmutableList.of(new PatchPanelUiMessageHandler());
-
- // Application UI extension
- protected UiExtension extension =
- new UiExtension.Builder(getClass().getClassLoader(), uiViews)
- .resourcePath(VIEW_ID)
- .messageHandlerFactory(messageHandlerFactory)
- .build();
-
- @Activate
- protected void activate() {
- uiExtensionService.register(extension);
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- uiExtensionService.unregister(extension);
- log.info("Stopped");
- }
-
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelUiMessageHandler.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelUiMessageHandler.java
deleted file mode 100644
index d1f0cbf..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/PatchPanelUiMessageHandler.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.patchpanel.impl;
-
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableSet;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.Port;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.ui.RequestHandler;
-import org.onosproject.ui.UiMessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import static org.onosproject.net.ConnectPoint.deviceConnectPoint;
-
-/**
- * ONOS UI Custom-View message handler.
- * <p>
- * This class contains the request handlers that handle the response
- * to each event. In this particular implementation the second message
- * handler creates the patch and the first message handler loads the data.
- */
-public class PatchPanelUiMessageHandler extends UiMessageHandler {
-
- private static final String SAMPLE_CUSTOM_DATA_REQ = "sampleCustomDataRequest";
- private static final String SAMPLE_CUSTOM_DATA_RESP = "sampleCustomDataResponse";
- private static final String SAMPLE_CUSTOM_DATA_REQ2 = "sampleCustomDataRequest2";
- private static final String SAMPLE_CUSTOM_DATA_RESP2 = "sampleCustomDataResponse2";
- private static final String SAMPLE_CUSTOM_DATA_REQ3 = "sampleCustomDataRequest3";
- private static final String SAMPLE_CUSTOM_DATA_RESP3 = "sampleCustomDataResponse3";
-
- private static final String SLASH = "/";
- private static final String CPS = "cps";
- private static final String RESULT = "result";
- private static final String MESSAGE = "message";
-
- private static final String EOL = String.format("%n");
- private static final String WITH = " with ";
- private static final String CPOINTS = "cpoints";
-
- private List<ConnectPoint> previous = new ArrayList<>();
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- protected Collection<RequestHandler> createRequestHandlers() {
- return ImmutableSet.of(
- new DataRequestHandler(),
- new SecondDataRequestHandler(),
- new ThirdDataRequestHandler()
- );
- }
-
- // handler for data requests/events
- private final class DataRequestHandler extends RequestHandler {
- private DataRequestHandler() {
- super(SAMPLE_CUSTOM_DATA_REQ);
- }
-
- @Override
- public void process(ObjectNode payload) {
- DeviceService service = get(DeviceService.class);
- ObjectNode result = objectNode();
- ArrayNode cps = arrayNode();
- result.set(CPS, cps);
-
- for (Device device : service.getDevices()) {
- cps.add(device.id().toString());
- for (Port port : service.getPorts(device.id())) {
- if (!port.number().isLogical()) {
- cps.add(port.number().toString());
- log.info(device.id() + SLASH + port.number());
- }
- }
- }
- sendMessage(SAMPLE_CUSTOM_DATA_RESP, result);
- }
- }
-
- private final class SecondDataRequestHandler extends RequestHandler {
- private SecondDataRequestHandler() {
- super(SAMPLE_CUSTOM_DATA_REQ2);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String deviceId = payload.get(RESULT).get(0).asText();
- ConnectPoint cp1 = deviceConnectPoint(deviceId + SLASH + payload.get(RESULT).get(1).asText());
- ConnectPoint cp2 = deviceConnectPoint(deviceId + SLASH + payload.get(RESULT).get(2).asText());
- PatchPanelService pps = get(PatchPanelService.class);
-
- boolean done = pps.addPatch(cp1, cp2);
- String message;
- if (done) {
- message = "Patch has been created";
- previous.add(cp1);
- previous.add(cp2);
- } else {
- message = "One or both of these ports are already in use";
- if (cp1.port().equals(cp2.port())) {
- message = "Both ports can not be the same";
- }
- }
- payload.put(MESSAGE, message);
- sendMessage(SAMPLE_CUSTOM_DATA_RESP2, payload);
-
- }
- }
-
- private final class ThirdDataRequestHandler extends RequestHandler {
- private ThirdDataRequestHandler() {
- super(SAMPLE_CUSTOM_DATA_REQ3);
- }
-
- @Override
- public void process(ObjectNode payload) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < previous.size(); i++) {
- sb.append(previous.get(i)).append(i % 2 == 0 ? WITH : EOL);
- }
- payload.put(CPOINTS, sb.toString());
- sendMessage(SAMPLE_CUSTOM_DATA_RESP3, payload);
- }
- }
-
-}
diff --git a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/package-info.java b/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/package-info.java
deleted file mode 100644
index 7c109d2..0000000
--- a/apps/patchpanel/src/main/java/org/onosproject/patchpanel/impl/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Patch panel-related CLI commands(in implementation folder).
- */
-package org.onosproject.patchpanel.impl;
diff --git a/apps/patchpanel/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/patchpanel/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index 1db5a5d..0000000
--- a/apps/patchpanel/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<!--
- ~ Copyright 2016-present Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<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.patchpanel.cli.PatchPanelCommand"/>
- <completers>
- <ref component-id="ConnectPointCompleter"/>
- </completers>
- </command>
- <command>
- <action class="org.onosproject.patchpanel.cli.PatchRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.patchpanel.cli.PatchListCommand"/>
- </command>
- </command-bundle>
- <bean id="ConnectPointCompleter" class="org.onosproject.cli.net.ConnectPointCompleter"/>
-</blueprint>
diff --git a/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.css b/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.css
deleted file mode 100644
index ffeac0a..0000000
--- a/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.css
+++ /dev/null
@@ -1,48 +0,0 @@
-/* css for sample app custom view */
-
-#ov-sample-custom {
- padding: 20px;
-}
-.light #ov-sample-custom {
- color: navy;
-}
-.dark #ov-sample-custom {
- color: #88f;
-}
-
-#ov-sample-custom .button-panel {
- margin: 10px;
- width: 200px;
-}
-
-.light #ov-sample-custom .button-panel {
- background-color: #ccf;
-}
-.dark #ov-sample-custom .button-panel {
- background-color: #444;
-}
-
-#ov-sample-custom .my-button {
- cursor: pointer;
- padding: 4px;
- text-align: center;
-}
-
-.light #ov-sample-custom .my-button {
- color: white;
- background-color: #99d;
-}
-.dark #ov-sample-custom .my-button {
- color: black;
- background-color: #aaa;
-}
-
-#ov-sample-custom .number {
- font-size: 140%;
- text-align: right;
-}
-
-#ov-sample-custom .quote {
- margin: 10px 20px;
- font-style: italic;
-}
\ No newline at end of file
diff --git a/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.html b/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.html
deleted file mode 100644
index 34204b4..0000000
--- a/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!-- partial HTML of patch panel app -->
-<div id="ov-sample-custom" ng-controller="OvSampleCustomCtrl">
- <div class="button-panel">
- <div class="my-button" ng-click="getData()">
- Load Devices
- </div>
-
- </div>
- <div class="data-panel">
- <div>
- <label>Devices:
- <select ng-model="myDev" ng-options="dev.name for dev in devices"></select>
- </label>
-
- </div>
- </div>
- <div class="button-panel">
- <div class="my-button" ng-click="loadPorts()">
- Load Ports
- </div>
- </div>
- <div class="data-panel2">
- <label>First Port:
- <select ng-model="myPort1" ng-options="port.name for port in ports"></select>
- </label>
- <label>Second Port:
- <select ng-model="myPort2" ng-options="port.name for port in ports"></select>
- </label>
- </div>
- <div class="button-panel">
- <div class="my-button" ng-click="done()">
- Patch!
- </div>
- </div>
- <div class="data-panel3">
- <p>
- <span class="quote">{{data.message}} </span>
- </p>
- <pre>
-
-
- </pre>
- </div>
- <div class="button-panel">
- <div class="my-button" ng-click="used()">
- ConnectPoints in use
- </div>
- </div>
- <div class="data-panel4">
- <p>
- <span class="quote">{{data.cpoints}} </span>
- </p>
- </div>
-</div>
\ No newline at end of file
diff --git a/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.js b/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.js
deleted file mode 100644
index 08902e3..0000000
--- a/apps/patchpanel/src/main/resources/app/view/sampleCustom/sampleCustom.js
+++ /dev/null
@@ -1,122 +0,0 @@
-// js for patch panel app custom view
-(function () {
- 'use strict';
-
- // injected refs
- var $log, $scope, wss, ks;
-
- // constants
- var dataReq = 'sampleCustomDataRequest',
- dataResp = 'sampleCustomDataResponse';
- var dataReq2 = 'sampleCustomDataRequest2',
- dataResp2 = 'sampleCustomDataResponse2';
- var dataReq3 = 'sampleCustomDataRequest3',
- dataResp3 = 'sampleCustomDataResponse3';
-
-
- function addKeyBindings() {
- var map = {space: [getData, 'Fetch data from server'], _helpFormat: [['space']]};
- ks.keyBindings(map);
-
- }
-
- function getData() {
- wss.sendEvent(dataReq);
- }
- function used() {
- wss.sendEvent(dataReq3);
- }
- function loadPorts(){
- $scope.ports = [];
- var i;
- var index;
- for(i = 0; i < $scope.cps.length ; i++){
- if($scope.cps[i] == $scope.myDev){
- index = i;
- }
- }
- var j = index+1;
- while( $scope.data.cps[j].indexOf("o") != 0){
- var tempi = {name : $scope.data.cps[j]};
- $scope.ports.push(tempi);
- j++;
- }
- }
- function done(){
- var temp = [$scope.myDev.name, $scope.myPort1.name, $scope.myPort2.name];
- var temp1 = {result : temp};
- wss.sendEvent(dataReq2, temp1);
-
- }
- function respDataCb(data) {
- $scope.data = data;
- $scope.cps = [];
- $scope.devices = [];
- var i;
- for(i = 0; i < $scope.data.cps.length; i++){
- $scope.cps.push(temp);
- if($scope.data.cps[i].indexOf("o") == 0){
- var temp = {name : $scope.data.cps[i]};
- $scope.devices.push(temp);
- }
- }
- $scope.$apply();
- }
- function respDataCb2(data) {
- $scope.data = data;
- $scope.$apply();
- }
- function respDataCb3(data) {
- $scope.data = data;
- $scope.$apply();
- }
-
- var app = angular.module('ovSampleCustom', [])
- .controller('OvSampleCustomCtrl',
- ['$log', '$scope', 'WebSocketService', 'KeyService',
-
- function (_$log_, _$scope_, _wss_, _ks_) {
- $log = _$log_;
- $scope = _$scope_;
- wss = _wss_;
- ks = _ks_;
-
- $scope.cps = [];
- $scope.devices = [];
- $scope.ports = [];
- $scope.myDev = $scope.devices[0];
- $scope.myPort1 = $scope.ports[0];
- $scope.myPort2 = $scope.ports[0];
-
-
- var handlers = {};
- $scope.data = {};
-
- // data response handler
- handlers[dataResp] = respDataCb;
- handlers[dataResp2] = respDataCb2;
- handlers[dataResp3] = respDataCb3;
- wss.bindHandlers(handlers);
-
- addKeyBindings();
-
- // custom click handler
- $scope.getData = getData;
- $scope.loadPorts = loadPorts;
- $scope.used = used;
- $scope.done = done;
-
- // cleanup
- $scope.$on('$destroy', function () {
- wss.unbindHandlers(handlers);
- ks.unbindKeys();
- $log.log('OvSampleCustomCtrl has been destroyed');
- });
-
- $log.log('OvSampleCustomCtrl has been created');
- }]);
-
-
-
-}());
-
diff --git a/apps/patchpanel/src/main/resources/sampleCustom/css.html b/apps/patchpanel/src/main/resources/sampleCustom/css.html
deleted file mode 100644
index 4e7b709..0000000
--- a/apps/patchpanel/src/main/resources/sampleCustom/css.html
+++ /dev/null
@@ -1 +0,0 @@
-<link rel="stylesheet" href="app/view/sampleCustom/sampleCustom.css">
\ No newline at end of file
diff --git a/apps/patchpanel/src/main/resources/sampleCustom/js.html b/apps/patchpanel/src/main/resources/sampleCustom/js.html
deleted file mode 100644
index 6550b85..0000000
--- a/apps/patchpanel/src/main/resources/sampleCustom/js.html
+++ /dev/null
@@ -1 +0,0 @@
-<script src="app/view/sampleCustom/sampleCustom.js"></script>
\ No newline at end of file
diff --git a/apps/pom.xml b/apps/pom.xml
index 9dc33aa..f8f0725 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -61,7 +61,6 @@
<module>pim</module>
<module>mlb</module>
<module>pathpainter</module>
- <module>patchpanel</module>
<module>drivermatrix</module>
<module>cpman</module>
<module>events</module>
diff --git a/modules.defs b/modules.defs
index 0545759..08de85d 100644
--- a/modules.defs
+++ b/modules.defs
@@ -173,7 +173,6 @@
'//apps/cpman/app:onos-apps-cpman-app-oar',
'//apps/xosclient:onos-apps-xosclient-oar',
'//apps/scalablegateway:onos-apps-scalablegateway-oar',
- '//apps/patchpanel:onos-apps-patchpanel-oar',
'//apps/castor:onos-apps-castor-oar',
'//apps/yms:onos-apps-yms-oar',
'//apps/ofagent:onos-apps-ofagent-oar',