<bundle>mvn:org.opendaylight.controller/forwardingrulesmanager.implementation/${forwardingrulesmanager.implementation.version}</bundle>
<bundle>mvn:org.opendaylight.controller/topologymanager/${topologymanager.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/topologymanager.shell/${topologymanager.shell.version}</bundle>
<bundle>mvn:org.opendaylight.controller/networkconfig.neutron/${networkconfig.neutron.version}</bundle>
<bundle>mvn:org.opendaylight.controller/networkconfig.neutron.implementation/${networkconfig.neutron.implementation.version}</bundle>
<bundle>mvn:org.opendaylight.controller/topology.northbound/${topology.northbound.version}</bundle>
<bundle>mvn:org.opendaylight.controller/usermanager.northbound/${usermanager.northbound.version}</bundle>
</feature>
-</features>
\ No newline at end of file
+</features>
<topology.northbound.version>0.4.2-SNAPSHOT</topology.northbound.version>
<topology.web.version>0.4.2-SNAPSHOT</topology.web.version>
<topologymanager.version>0.4.2-SNAPSHOT</topologymanager.version>
+ <topologymanager.shell.version>1.0.0-SNAPSHOT</topologymanager.shell.version>
<troubleshoot.web.version>0.4.2-SNAPSHOT</troubleshoot.web.version>
<typesafe.config.version>1.2.0</typesafe.config.version>
<uncommons.maths.version>1.2.2</uncommons.maths.version>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
+ <version>${bundle.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
--- /dev/null
+/**
+* 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<String> printUserLink();
+ public List<String> addUserLink(String name, String ncStr1, String ncStr2);
+ public List<String> deleteUserLinkShell(String name);
+ public List<String> printNodeEdges();
+}
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;
c.setInterface(new String[] { IListenTopoUpdates.class.getName(),
ITopologyManager.class.getName(),
+ ITopologyManagerShell.class.getName(),
IConfigurationContainerAware.class.getName(),
ICacheUpdateAware.class.getName() }, props);
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;
public class TopologyManagerImpl implements
ICacheUpdateAware<Object, Object>,
ITopologyManager,
+ ITopologyManagerShell,
IConfigurationContainerAware,
IListenTopoUpdates,
IObjectReader,
}
}
}
+
+ public List<String> printUserLink() {
+ List<String> result = new ArrayList<String>();
+ 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<String> addUserLink(String name, String ncStr1, String ncStr2) {
+ List<String> result = new ArrayList<String>();
+ 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<String> deleteUserLinkShell(String name) {
+ List<String> result = new ArrayList<String>();
+ if ((name == null)) {
+ result.add("Please enter a valid Name");
+ return result;
+ }
+ this.deleteUserLink(name);
+ return result;
+ }
+
+ public List<String> printNodeEdges() {
+ List<String> result = new ArrayList<String>();
+ Map<Node, Set<Edge>> nodeEdges = getNodeEdges();
+ if (nodeEdges == null) {
+ return result;
+ }
+ Set<Node> nodeSet = nodeEdges.keySet();
+ if (nodeSet == null) {
+ return result;
+ }
+ result.add(" Node Edge");
+ for (Node node : nodeSet) {
+ Set<Edge> edgeSet = nodeEdges.get(node);
+ if (edgeSet == null) {
+ continue;
+ }
+ for (Edge edge : edgeSet) {
+ result.add(node + " " + edge);
+ }
+ }
+ return result;
+ }
+
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.2-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+ <artifactId>topologymanager.shell</artifactId>
+ <version>${topologymanager.shell.version}</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>${karaf.shell.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>topologymanager</artifactId>
+ <version>${topologymanager.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${bundle.plugin.version}</version>
+ <configuration>
+ <instructions>
+ <Import-Package>org.apache.felix.service.command,
+ org.apache.karaf.shell.commands,
+ org.apache.karaf.shell.console,
+ *</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
--- /dev/null
+/**
+* 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;
+ }
+}
--- /dev/null
+/**
+* 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;
+ }
+}
--- /dev/null
+/**
+* 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;
+ }
+}
--- /dev/null
+/**
+* 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;
+ }
+}
--- /dev/null
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <reference id="topologyManagerRef" interface="org.opendaylight.controller.topologymanager.ITopologyManagerShell"/>
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+
+ <command>
+ <action class="org.opendaylight.controller.topologymanager.shell.AddUserLink">
+ <property name="topologyManager" ref="topologyManagerRef"/>
+ </action>
+ </command>
+
+ <command>
+ <action class="org.opendaylight.controller.topologymanager.shell.DeleteUserLink">
+ <property name="topologyManager" ref="topologyManagerRef"/>
+ </action>
+ </command>
+
+ <command>
+ <action class="org.opendaylight.controller.topologymanager.shell.PrintNodeEdges">
+ <property name="topologyManager" ref="topologyManagerRef"/>
+ </action>
+ </command>
+
+ <command>
+ <action class="org.opendaylight.controller.topologymanager.shell.PrintUserLink">
+ <property name="topologyManager" ref="topologyManagerRef"/>
+ </action>
+ </command>
+
+ </command-bundle>
+
+
+</blueprint>