Added Karaf Shell framework for OVSDB plugin and printCache command-line. 00/10000/2
authorMadhu Venugopal <mavenugo@gmail.com>
Fri, 15 Aug 2014 18:34:30 +0000 (11:34 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Sat, 16 Aug 2014 01:11:18 +0000 (18:11 -0700)
More commands to follow soon.

Change-Id: Iee05b833d8d59394bf4ce09d99a9d85322e110c9
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
commons/parent/pom.xml
features/src/main/resources/features.xml
plugin-shell/pom.xml [new file with mode: 0644]
plugin-shell/src/main/java/org/opendaylight/ovsdb/plugin/shell/PrintCache.java [new file with mode: 0644]
plugin-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml [new file with mode: 0644]
pom.xml

index 0354977130a6b7e767079ec350bc9390a006bae3..0ee3cd6486f00d2f39d67f8d379f739715f60b75 100755 (executable)
@@ -26,6 +26,7 @@
     <!-- OVSB Component Versions -->
     <ovsdb.library.version>1.0.0-SNAPSHOT</ovsdb.library.version>
     <ovsdb.plugin.version>1.0.0-SNAPSHOT</ovsdb.plugin.version>
+    <plugin.shell.version>1.0.0-SNAPSHOT</plugin.shell.version>
     <openstack.netvirt.version>1.0.0-SNAPSHOT</openstack.netvirt.version>
     <openstack.netvirt.providers.version>1.0.0-SNAPSHOT</openstack.netvirt.providers.version>
     <ovsdb.northbound.version>0.6.0-SNAPSHOT</ovsdb.northbound.version>
@@ -69,6 +70,7 @@
     <portlet.version>2.0</portlet.version>
     <powermock.version>1.5.2</powermock.version>
     <httpcomponents.version>4.2.1</httpcomponents.version>
+    <karaf.shell.version>3.0.0</karaf.shell.version>
   </properties>
 
   <dependencyManagement>
index 27defdbfd164dc57daee68283d7b84fbbdcbbaba..7458cac9e8829aef0ff4e4262e3a9e24e057e58d 100644 (file)
@@ -31,6 +31,7 @@
         <feature version="${schema.openvswitch.version}">odl-ovsdb-schema-openvswitch</feature>
         <feature version="${schema.hardwarevtep.version}">odl-ovsdb-schema-hardwarevtep</feature>
         <bundle>mvn:org.opendaylight.ovsdb/plugin/${ovsdb.plugin.version}</bundle>
+        <bundle>mvn:org.opendaylight.ovsdb/plugin-shell/${plugin.shell.version}</bundle>
     </feature>
 
     <feature name="odl-ovsdb-northbound" description="OpenDaylight :: OVSDB :: Northbound" version='${ovsdb.northbound.version}'>
diff --git a/plugin-shell/pom.xml b/plugin-shell/pom.xml
new file mode 100644 (file)
index 0000000..bee4488
--- /dev/null
@@ -0,0 +1,55 @@
+<?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.ovsdb</groupId>
+    <artifactId>commons</artifactId>
+    <version>1.2.0-SNAPSHOT</version>
+    <relativePath>../commons/parent</relativePath>
+  </parent>
+
+  <artifactId>plugin-shell</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <name>OpenDaylight OVSDB Plugin Shell</name>
+  <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.opendaylight.ovsdb</groupId>
+      <artifactId>plugin</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.3.6</version>
+        <extensions>true</extensions>
+        <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>
diff --git a/plugin-shell/src/main/java/org/opendaylight/ovsdb/plugin/shell/PrintCache.java b/plugin-shell/src/main/java/org/opendaylight/ovsdb/plugin/shell/PrintCache.java
new file mode 100644 (file)
index 0000000..4140d82
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * 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
+ *
+ * Authors : Madhu Venugopal
+ */
+package org.opendaylight.ovsdb.plugin.shell;
+
+import java.util.Collection;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+
+@Command(scope = "ovs", name = "printCache", description="Prints OVSDB Cache")
+public class PrintCache extends OsgiCommandSupport{
+    private OvsdbInventoryService ovsdbInventory;
+
+    @Argument(index=0, name="nodeName", description="Node Name", required=true, multiValued=false)
+    String nodeName = null;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        Node node = Node.fromString(nodeName);
+        ovsdbInventory.printCache(node);
+        return null;
+    }
+
+    public void setOvsdbInventory(OvsdbInventoryService inventoryService){
+        this.ovsdbInventory = inventoryService;
+    }
+}
diff --git a/plugin-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/plugin-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644 (file)
index 0000000..4a213c6
--- /dev/null
@@ -0,0 +1,10 @@
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+    <reference id="ovsdbInventoryRef" interface="org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService"/>
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+        <command>
+          <action class="org.opendaylight.ovsdb.plugin.shell.PrintCache">
+            <property name="ovsdbInventory" ref="ovsdbInventoryRef"/>
+          </action>
+        </command>
+    </command-bundle>
+</blueprint>
diff --git a/pom.xml b/pom.xml
index 3cd3353a277f8cd685b8b823394b6074defbc292..46039dd9b806e5bf28a1c64e3b9c9e5025108edb 100755 (executable)
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,7 @@
     <module>schemas/openvswitch</module>
     <module>schemas/hardwarevtep</module>
     <module>plugin</module>
+    <module>plugin-shell</module>
     <module>plugin-mdsal-adapter</module>
     <module>northbound</module>
     <module>utils/mdsal-openflow</module>