From: Jonathan Fok kan Date: Thu, 31 Jul 2014 21:05:01 +0000 (-0400) Subject: added feature topology manager shell X-Git-Tag: release/helium~363^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=776b087b1e29c356cc912fd0a0b672fe2981a139 added feature topology manager shell The shell is installed when odl-nsf-managers is installed Change-Id: I460c71231ed54342983271304356737a1cb6c377 Signed-off-by: Jonathan Fok Kan --- diff --git a/features/nsf/src/main/resources/features.xml b/features/nsf/src/main/resources/features.xml index fb61f33fb3..37c69cf753 100644 --- a/features/nsf/src/main/resources/features.xml +++ b/features/nsf/src/main/resources/features.xml @@ -34,6 +34,7 @@ mvn:org.opendaylight.controller/forwardingrulesmanager.implementation/${forwardingrulesmanager.implementation.version} mvn:org.opendaylight.controller/topologymanager/${topologymanager.version} + mvn:org.opendaylight.controller/topologymanager.shell/${topologymanager.shell.version} mvn:org.opendaylight.controller/networkconfig.neutron/${networkconfig.neutron.version} mvn:org.opendaylight.controller/networkconfig.neutron.implementation/${networkconfig.neutron.implementation.version} @@ -70,4 +71,4 @@ mvn:org.opendaylight.controller/topology.northbound/${topology.northbound.version} mvn:org.opendaylight.controller/usermanager.northbound/${usermanager.northbound.version} - \ No newline at end of file + diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index be88e4a505..235b95b742 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -179,6 +179,7 @@ 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT + 1.0.0-SNAPSHOT 0.4.2-SNAPSHOT 1.2.0 1.2.2 diff --git a/opendaylight/topologymanager/implementation/pom.xml b/opendaylight/topologymanager/implementation/pom.xml index 196982b361..746135891e 100644 --- a/opendaylight/topologymanager/implementation/pom.xml +++ b/opendaylight/topologymanager/implementation/pom.xml @@ -44,6 +44,7 @@ org.apache.felix maven-bundle-plugin + ${bundle.plugin.version} true diff --git a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManagerShell.java b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManagerShell.java new file mode 100644 index 0000000000..22bd9c0512 --- /dev/null +++ b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManagerShell.java @@ -0,0 +1,17 @@ +/** +* Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution, +* and is available at http://www.eclipse.org/legal/epl-v10.html +*/ +package org.opendaylight.controller.topologymanager; + +import java.util.List; + +public interface ITopologyManagerShell { + public List printUserLink(); + public List addUserLink(String name, String ncStr1, String ncStr2); + public List deleteUserLinkShell(String name); + public List printNodeEdges(); +} diff --git a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/Activator.java b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/Activator.java index 4ccbb0197d..80d7083ec0 100644 --- a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/Activator.java +++ b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/Activator.java @@ -26,6 +26,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.topologymanager.ITopologyManager; import org.opendaylight.controller.topologymanager.ITopologyManagerAware; import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware; +import org.opendaylight.controller.topologymanager.ITopologyManagerShell; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,6 +74,7 @@ public class Activator extends ComponentActivatorAbstractBase { c.setInterface(new String[] { IListenTopoUpdates.class.getName(), ITopologyManager.class.getName(), + ITopologyManagerShell.class.getName(), IConfigurationContainerAware.class.getName(), ICacheUpdateAware.class.getName() }, props); diff --git a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java index ff1c026a34..b0e87c48f3 100644 --- a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java +++ b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java @@ -57,6 +57,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.topologymanager.ITopologyManager; import org.opendaylight.controller.topologymanager.ITopologyManagerAware; import org.opendaylight.controller.topologymanager.ITopologyManagerClusterWideAware; +import org.opendaylight.controller.topologymanager.ITopologyManagerShell; import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -71,6 +72,7 @@ import org.slf4j.LoggerFactory; public class TopologyManagerImpl implements ICacheUpdateAware, ITopologyManager, + ITopologyManagerShell, IConfigurationContainerAware, IListenTopoUpdates, IObjectReader, @@ -1010,4 +1012,82 @@ public class TopologyManagerImpl implements } } } + + public List printUserLink() { + List result = new ArrayList(); + for (String name : this.userLinksDB.keySet()) { + TopologyUserLinkConfig linkConfig = userLinksDB.get(name); + result.add("Name : " + name); + result.add(linkConfig.toString()); + result.add("Edge " + getLinkTuple(linkConfig)); + result.add("Reverse Edge " + getReverseLinkTuple(linkConfig)); + } + return result; + } + + public List addUserLink(String name, String ncStr1, String ncStr2) { + List result = new ArrayList(); + if ((name == null)) { + result.add("Please enter a valid Name"); + return result; + } + + if (ncStr1 == null) { + result.add("Please enter two node connector strings"); + return result; + } + if (ncStr2 == null) { + result.add("Please enter second node connector string"); + return result; + } + + NodeConnector nc1 = NodeConnector.fromString(ncStr1); + if (nc1 == null) { + result.add("Invalid input node connector 1 string: " + ncStr1); + return result; + } + NodeConnector nc2 = NodeConnector.fromString(ncStr2); + if (nc2 == null) { + result.add("Invalid input node connector 2 string: " + ncStr2); + return result; + } + + TopologyUserLinkConfig config = new TopologyUserLinkConfig(name, ncStr1, ncStr2); + result.add(this.addUserLink(config).toString()); + return result; + } + + public List deleteUserLinkShell(String name) { + List result = new ArrayList(); + if ((name == null)) { + result.add("Please enter a valid Name"); + return result; + } + this.deleteUserLink(name); + return result; + } + + public List printNodeEdges() { + List result = new ArrayList(); + Map> nodeEdges = getNodeEdges(); + if (nodeEdges == null) { + return result; + } + Set nodeSet = nodeEdges.keySet(); + if (nodeSet == null) { + return result; + } + result.add(" Node Edge"); + for (Node node : nodeSet) { + Set edgeSet = nodeEdges.get(node); + if (edgeSet == null) { + continue; + } + for (Edge edge : edgeSet) { + result.add(node + " " + edge); + } + } + return result; + } + } diff --git a/opendaylight/topologymanager/shell/pom.xml b/opendaylight/topologymanager/shell/pom.xml new file mode 100644 index 0000000000..078b55c596 --- /dev/null +++ b/opendaylight/topologymanager/shell/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.2-SNAPSHOT + ../../commons/opendaylight + + topologymanager.shell + ${topologymanager.shell.version} + bundle + + + junit + junit + + + org.apache.karaf.shell + org.apache.karaf.shell.console + ${karaf.shell.version} + + + org.mockito + mockito-all + + + org.opendaylight.controller + topologymanager + ${topologymanager.version} + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + + + org.apache.felix.service.command, + org.apache.karaf.shell.commands, + org.apache.karaf.shell.console, + * + + + + + + + diff --git a/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/AddUserLink.java b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/AddUserLink.java new file mode 100644 index 0000000000..1565a8733b --- /dev/null +++ b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/AddUserLink.java @@ -0,0 +1,39 @@ +/** +* Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution, +* and is available at http://www.eclipse.org/legal/epl-v10.html +*/ +package org.opendaylight.controller.topologymanager.shell; + +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Argument; +import org.apache.karaf.shell.console.OsgiCommandSupport; +import org.opendaylight.controller.topologymanager.ITopologyManagerShell; + +@Command(scope = "topologymanager", name = "addUserLink", description="Adds user link") +public class AddUserLink extends OsgiCommandSupport{ + private ITopologyManagerShell topologyManager; + + @Argument(index=0, name="name", description="name", required=true, multiValued=false) + String name = null; + + @Argument(index=1, name="ncStr1", description="ncStr1", required=true, multiValued=false) + String ncStr1 = null; + + @Argument(index=2, name="ncStr2", description="ncStr2", required=true, multiValued=false) + String ncStr2 = null; + + @Override + protected Object doExecute() throws Exception { + for(String p : topologyManager.addUserLink(name, ncStr1, ncStr2)) { + System.out.println(p); + } + return null; + } + + public void setTopologyManager(ITopologyManagerShell topologyManager){ + this.topologyManager = topologyManager; + } +} diff --git a/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/DeleteUserLink.java b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/DeleteUserLink.java new file mode 100644 index 0000000000..b226c3c2e2 --- /dev/null +++ b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/DeleteUserLink.java @@ -0,0 +1,33 @@ +/** +* Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution, +* and is available at http://www.eclipse.org/legal/epl-v10.html +*/ +package org.opendaylight.controller.topologymanager.shell; + +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Argument; +import org.apache.karaf.shell.console.OsgiCommandSupport; +import org.opendaylight.controller.topologymanager.ITopologyManagerShell; + +@Command(scope = "topologymanager", name = "deleteUserLink", description="deletes user link") +public class DeleteUserLink extends OsgiCommandSupport{ + private ITopologyManagerShell topologyManager; + + @Argument(index=0, name="name", description="name", required=true, multiValued=false) + String name = null; + + @Override + protected Object doExecute() throws Exception { + for(String p : topologyManager.deleteUserLinkShell(name)) { + System.out.println(p); + } + return null; + } + + public void setTopologyManager(ITopologyManagerShell topologyManager){ + this.topologyManager = topologyManager; + } +} diff --git a/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/PrintNodeEdges.java b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/PrintNodeEdges.java new file mode 100644 index 0000000000..9c5e806b6d --- /dev/null +++ b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/PrintNodeEdges.java @@ -0,0 +1,29 @@ +/** +* Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution, +* and is available at http://www.eclipse.org/legal/epl-v10.html +*/ +package org.opendaylight.controller.topologymanager.shell; + +import org.apache.felix.gogo.commands.Command; +import org.apache.karaf.shell.console.OsgiCommandSupport; +import org.opendaylight.controller.topologymanager.ITopologyManagerShell; + +@Command(scope = "topologymanager", name = "printNodeEdges", description="Prints node edges") +public class PrintNodeEdges extends OsgiCommandSupport{ + private ITopologyManagerShell topologyManager; + + @Override + protected Object doExecute() throws Exception { + for(String p : topologyManager.printNodeEdges()) { + System.out.println(p); + } + return null; + } + + public void setTopologyManager(ITopologyManagerShell topologyManager){ + this.topologyManager = topologyManager; + } +} diff --git a/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/PrintUserLink.java b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/PrintUserLink.java new file mode 100644 index 0000000000..df7ab35073 --- /dev/null +++ b/opendaylight/topologymanager/shell/src/main/java/org/opendaylight/controller/topologymanager/shell/PrintUserLink.java @@ -0,0 +1,29 @@ +/** +* Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution, +* and is available at http://www.eclipse.org/legal/epl-v10.html +*/ +package org.opendaylight.controller.topologymanager.shell; + +import org.apache.felix.gogo.commands.Command; +import org.apache.karaf.shell.console.OsgiCommandSupport; +import org.opendaylight.controller.topologymanager.ITopologyManagerShell; + +@Command(scope = "topologymanager", name = "printUserLink", description="Prints user link") +public class PrintUserLink extends OsgiCommandSupport{ + private ITopologyManagerShell topologyManager; + + @Override + protected Object doExecute() throws Exception { + for(String p : topologyManager.printUserLink()) { + System.out.println(p); + } + return null; + } + + public void setTopologyManager(ITopologyManagerShell topologyManager){ + this.topologyManager = topologyManager; + } +} diff --git a/opendaylight/topologymanager/shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/opendaylight/topologymanager/shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 0000000000..96b0b10f10 --- /dev/null +++ b/opendaylight/topologymanager/shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +