<artifactId>mappingservice.northbound</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mappingservice.shell</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mappingservice.southbound</artifactId>
<artifactId>mappingservice.northbound</artifactId>
<version>${lispflowmapping.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.lispflowmapping</groupId>
+ <artifactId>mappingservice.shell</artifactId>
+ <version>${lispflowmapping.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>mappingservice.southbound</artifactId>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>mappingservice.northbound</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.lispflowmapping</groupId>
+ <artifactId>mappingservice.shell</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.lispflowmapping</groupId>
<bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.yangmodel/${lispflowmapping.version}</bundle>
<bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.api/${lispflowmapping.version}</bundle>
<bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.implementation/${lispflowmapping.version}</bundle>
+ <bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.shell/${lispflowmapping.version}</bundle>
<bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.clusterdao/${lispflowmapping.version}</bundle>
</feature>
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.lispflowmapping.interfaces.lisp;
+
+/**
+ * This interface defines the methods that need to be implemented in order to
+ * provide commands for the Karaf shell.
+ *
+ * @author Lorand Jakab
+ *
+ */
+public interface IFlowMappingShell {
+ /**
+ * Print the full mapping database.
+ *
+ * @return the text to be printed on the Karaf console.
+ */
+ public String printMappings();
+}
import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMappingShell;
/**
* Main application activator class for registering the dependencies and
* initialising the Mapping Service application.
- *
+ *
*/
public class Activator extends ComponentActivatorAbstractBase {
/**
* Function called when the activator starts just after some initializations
* are done by the ComponentActivatorAbstractBase.
- *
+ *
*/
@Override
public void init() {
/**
* Function called when the activator stops just before the cleanup done by
* ComponentActivatorAbstractBase
- *
+ *
*/
@Override
public void destroy() {
/**
* Function that is used to communicate to dependency manager the list of
* known implementations for services inside a container
- *
- *
+ *
+ *
* @return An array containing all the CLASS objects that will be
* instantiated in order to get an fully working implementation
* Object
/**
* Function that is called when configuration of the dependencies is
* required.
- *
+ *
* @param c
* dependency manager Component object, used for configuring the
* dependencies exported and imported
// export the service
Dictionary<String, String> props = new Hashtable<String, String>();
props.put("name", "mappingservice");
- c.setInterface(new String[] { IFlowMapping.class.getName() }, props);
+ c.setInterface(new String[] { IFlowMapping.class.getName(), IFlowMappingShell.class.getName() }, props);
c.add(createContainerServiceDependency(containerName).setService(ILispDAO.class).setCallbacks("setLispDao", "unsetLispDao")
.setRequired(true));
c.add(createServiceDependency().setService(BindingAwareBroker.class).setRequired(true)
* destroyed only at time of bundle destruction, this is the major
* difference with the implementation retrieved via getImplementations where
* all of them are assumed to be in a container !
- *
- *
+ *
+ *
* @return The list of implementations the bundle will support, in Global
* version
*/
/**
* Configure the dependency for a given instance Global
- *
+ *
* @param c
* Component assigned for this instance, this will be what will
* be used for configuration
import org.opendaylight.lispflowmapping.interfaces.dao.ILispTypeConverter;
import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMappingShell;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapRequestResultHandler;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LispMappingService implements CommandProvider, IFlowMapping, BindingAwareConsumer, //
+public class LispMappingService implements CommandProvider, IFlowMapping, IFlowMappingShell, BindingAwareConsumer,
IMapRequestResultHandler, IMapNotifyHandler {
protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
}
public void _dumpAll(final CommandInterpreter ci) {
- ci.println("EID\tRLOCs");
+ ci.print(printMappings());
+ }
+
+ public String printMappings() {
+ final StringBuffer sb = new StringBuffer();
+ sb.append("EID\tRLOCs\n");
lispDao.getAll(new IRowVisitor() {
String lastKey = "";
public void visitRow(Object keyId, String valueKey, Object value) {
String key = keyId.getClass().getSimpleName() + "#" + keyId;
if (!lastKey.equals(key)) {
- ci.println();
- ci.print(key + "\t");
+ sb.append("\n" + key + "\t");
}
- ci.print(valueKey + "=" + value + "\t");
+ sb.append(valueKey + "=" + value + "\t");
lastKey = key;
}
});
- ci.println();
- return;
+ sb.append("\n");
+ return sb.toString();
}
public void _setShouldOverwriteRlocs(final CommandInterpreter ci) {
<module>northbound</module>
<module>neutron</module>
<module>netconf</module>
+ <module>shell</module>
<module>integrationtest</module>
</modules>
<dependencies>
--- /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.lispflowmapping</groupId>
+ <artifactId>mappingservice-parent</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>mappingservice.shell</artifactId>
+ <packaging>bundle</packaging>
+ <name>LISP Flow Mapping Karaf Shell Commands</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.commands</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.lispflowmapping</groupId>
+ <artifactId>mappingservice.api</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>org.apache.felix.service.command,
+ org.apache.karaf.shell.commands,
+ org.apache.karaf.shell.console,
+ org.opendaylight.lispflowmapping.interfaces.lisp</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.lispflowmapping.shell;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMappingShell;
+
+@Command(scope = "lisp", name = "mappings", description="Print LISP mapping database")
+public class LispMappings extends OsgiCommandSupport {
+ private IFlowMappingShell lispShellService;
+
+ @Override
+ protected Object doExecute() throws Exception {
+ System.out.print(lispShellService.printMappings());
+ return null;
+ }
+
+ public void setLispShellService(IFlowMappingShell lispShellService) {
+ this.lispShellService = lispShellService;
+ }
+}
--- /dev/null
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <reference id="lispShellServiceRef" interface="org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMappingShell"/>
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+ <command>
+ <action class="org.opendaylight.lispflowmapping.shell.LispMappings">
+ <property name="lispShellService" ref="lispShellServiceRef"/>
+ </action>
+ </command>
+ </command-bundle>
+</blueprint>