<bundle>mvn:org.opendaylight.controller/hosttracker/${hosttracker.api.version}</bundle>
<bundle>mvn:org.opendaylight.controller/hosttracker.implementation/${hosttracker.implementation.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/hosttracker.shell/${hosttracker.shell.version}</bundle>
<bundle>mvn:org.opendaylight.controller/forwarding.staticrouting</bundle>
<hosttracker.api.version>0.5.2-SNAPSHOT</hosttracker.api.version>
<hosttracker.implementation.version>0.5.2-SNAPSHOT</hosttracker.implementation.version>
<hosttracker.northbound.version>0.4.2-SNAPSHOT</hosttracker.northbound.version>
+ <hosttracker.shell.version>1.0.0-SNAPSHOT</hosttracker.shell.version>
<hosttracker_new.api.version>0.4.2-SNAPSHOT</hosttracker_new.api.version>
<hosttracker_new.implementation.version>0.4.2-SNAPSHOT</hosttracker_new.implementation.version>
<httpservice-bridge.northbound.version>0.0.2-SNAPSHOT</httpservice-bridge.northbound.version>
--- /dev/null
+package org.opendaylight.controller.hosttracker;
+
+import java.util.List;
+
+public interface IHostTrackerShell{
+
+ public List<String> dumpPendingArpReqList();
+ public List<String> dumpFailedArpReqList();
+}
\ No newline at end of file
import org.apache.felix.dm.Component;
import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
import org.opendaylight.controller.clustering.services.IClusterContainerServices;
+import org.opendaylight.controller.hosttracker.IHostTrackerShell;
import org.opendaylight.controller.hosttracker.IfHostListener;
import org.opendaylight.controller.hosttracker.IfIptoHost;
import org.opendaylight.controller.hosttracker.IfNewHostNotify;
IInventoryListener.class.getName(),
IfIptoHost.class.getName(),
IfHostListener.class.getName(),
+ IHostTrackerShell.class.getName(),
ITopologyManagerAware.class.getName(),
ICacheUpdateAware.class.getName() }, props);
import org.opendaylight.controller.clustering.services.IClusterServices;
import org.opendaylight.controller.hosttracker.HostIdFactory;
import org.opendaylight.controller.hosttracker.IHostId;
+import org.opendaylight.controller.hosttracker.IHostTrackerShell;
import org.opendaylight.controller.hosttracker.IPHostId;
import org.opendaylight.controller.hosttracker.IPMacHostId;
import org.opendaylight.controller.hosttracker.IfHostListener;
*
*/
-public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAware, IInventoryListener,
+public class HostTracker implements IfIptoHost, IfHostListener, IHostTrackerShell, ISwitchManagerAware, IInventoryListener,
ITopologyManagerAware, ICacheUpdateAware<IHostId, HostNodeConnector>, CommandProvider {
static final String ACTIVE_HOST_CACHE = "hosttracker.ActiveHosts";
static final String INACTIVE_HOST_CACHE = "hosttracker.InactiveHosts";
IHostId id = HostIdFactory.create(addr, null);
return getHostNetworkHierarchy(id);
}
+
+ @Override
+ public List<String> dumpPendingArpReqList() {
+ ARPPending arphost;
+ List<String> arpReq = new ArrayList<String>();
+ for (Entry<IHostId, ARPPending> entry : ARPPendingList.entrySet()) {
+ arpReq.add(entry.getValue().getHostId().toString());
+ }
+ return arpReq;
+ }
+
+ @Override
+ public List<String> dumpFailedArpReqList() {
+ ARPPending arphost;
+ List<String> arpReq = new ArrayList<String>();
+ for (Entry<IHostId, ARPPending> entry : failedARPReqList.entrySet()) {
+ arpReq.add(entry.getValue().getHostId().toString());
+ }
+ return arpReq;
+ }
}
--- /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>hosttracker.shell</artifactId>
+ <version>${hosttracker.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>3.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker.implementation</artifactId>
+ <version>${hosttracker.implementation.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
+package org.opendaylight.controller.hosttracker.shell;
+/**
+* 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
+*/
+
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.controller.hosttracker.IHostTrackerShell;
+
+@Command(scope = "hosttracker", name = "dumpFailedARPReqList", description="Display the dump failed ARPReqList")
+public class DumpFailedARPReqList extends OsgiCommandSupport{
+
+ private IHostTrackerShell hostTracker;
+
+ @Override
+ protected Object doExecute() throws Exception {
+ System.out.print(hostTracker.dumpFailedArpReqList());
+ return null;
+ }
+
+ public void setHostTracker(IHostTrackerShell hostTracker){
+ this.hostTracker = hostTracker;
+ }
+}
--- /dev/null
+package org.opendaylight.controller.hosttracker.shell;
+/**
+* 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
+*/
+
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.controller.hosttracker.IHostTrackerShell;
+
+@Command(scope = "hosttracker", name = "dumpPendingARPReqList", description="Display the dump pending ARPReqList")
+public class DumpPendingARPReqList extends OsgiCommandSupport{
+
+ private IHostTrackerShell hostTracker;
+
+ @Override
+ protected Object doExecute() throws Exception {
+ System.out.print(hostTracker.dumpPendingArpReqList());
+ return null;
+ }
+
+ public void setHostTracker(IHostTrackerShell hostTracker){
+ this.hostTracker = hostTracker;
+ }
+}
\ No newline at end of file
--- /dev/null
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <reference id="HostTrackerRef" interface="org.opendaylight.controller.hosttracker.IHostTrackerShell"/>
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+
+ <command>
+ <action class="org.opendaylight.controller.hosttracker.shell.DumpFailedARPReqList">
+ <property name="hostTracker" ref="HostTrackerRef"/>
+ </action>
+ </command>
+ <command>
+ <action class="org.opendaylight.controller.hosttracker.shell.DumpPendingARPReqList">
+ <property name="hostTracker" ref="HostTrackerRef"/>
+ </action>
+ </command>
+ </command-bundle>
+</blueprint>
--- /dev/null
+package org.opendaylight.controller.hosttracker.shell;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import org.opendaylight.controller.hosttracker.IHostTrackerShell;
+
+public class HostTrackerShellTest {
+
+ private final long COMMAND_TIMEOUT = 1000;
+ private IHostTrackerShell hostTracker;
+
+ @Test
+ public void testDumpPendingARPReqList() throws Exception {
+ DumpPendingARPReqList dumpPendTest = new DumpPendingARPReqList();
+ hostTracker = mock(IHostTrackerShell.class);
+ List<String> failedList = new ArrayList<String>(Arrays.asList("a", "b", "c"));
+ when(hostTracker.dumpPendingArpReqList()).thenReturn(failedList);
+ dumpPendTest.setHostTracker(hostTracker);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(baos));
+ dumpPendTest.doExecute();
+ //Assert.assertTrue(true);
+ Assert.assertEquals("[a, b, c]", baos.toString());
+ }
+
+ @Test
+ public void testDumpFailedARPReqList() throws Exception {
+ DumpFailedARPReqList dumpFailTest = new DumpFailedARPReqList();
+ hostTracker = mock(IHostTrackerShell.class);
+ List<String> failedList = new ArrayList<String>(Arrays.asList("a", "b", "c"));
+ when(hostTracker.dumpFailedArpReqList()).thenReturn(failedList);
+ dumpFailTest.setHostTracker(hostTracker);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(baos));
+ dumpFailTest.doExecute();
+ //Assert.assertTrue(true);
+ Assert.assertEquals("[a, b, c]", baos.toString());
+ }
+}