Renamed OnosDevice classes to Host.
Note this change only affects the driver level Host discovery module (and
any modules that make use of it). I did not rename the Device class in
the topology module yet.
Change-Id: I38bf42b2378da736199957d05467e8407548759e
diff --git a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
index 5976add..347d31f 100644
--- a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
+++ b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
@@ -20,8 +20,8 @@
import net.onrc.onos.core.datagrid.IDatagridService;
import net.onrc.onos.core.datagrid.IEventChannel;
import net.onrc.onos.core.datagrid.IEventChannelListener;
-import net.onrc.onos.core.devicemanager.IOnosDeviceService;
import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
+import net.onrc.onos.core.hostmanager.IHostService;
import net.onrc.onos.core.main.config.IConfigInfoService;
import net.onrc.onos.core.packet.ARP;
import net.onrc.onos.core.packet.Ethernet;
@@ -62,7 +62,7 @@
IDatagridService datagridService;
IFlowPusherService flowPusherService;
ITopologyService topologyService;
- IOnosDeviceService onosDeviceService;
+ IHostService hostService;
IPacketService packetService;
Map<String, String> configMap;
@@ -212,7 +212,7 @@
datagridService = EasyMock.createMock(IDatagridService.class);
flowPusherService = EasyMock.createMock(IFlowPusherService.class);
topologyService = EasyMock.createMock(ITopologyService.class);
- onosDeviceService = EasyMock.createMock(IOnosDeviceService.class);
+ hostService = EasyMock.createMock(IHostService.class);
packetService = EasyMock.createMock(IPacketService.class);
eg = EasyMock.createMock(IEventChannel.class);
el = EasyMock.createMock(IEventChannelListener.class);
@@ -241,7 +241,7 @@
EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
EasyMock.expect(context.getServiceImpl(IFlowPusherService.class)).andReturn(flowPusherService);
EasyMock.expect(context.getServiceImpl(ITopologyService.class)).andReturn(topologyService);
- EasyMock.expect(context.getServiceImpl(IOnosDeviceService.class)).andReturn(onosDeviceService);
+ EasyMock.expect(context.getServiceImpl(IHostService.class)).andReturn(hostService);
EasyMock.expect(context.getServiceImpl(IPacketService.class)).andReturn(packetService);
}
@@ -283,7 +283,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg,
+ topologyService, hostService, packetService, topology, eg,
el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -302,7 +302,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -320,7 +320,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -335,7 +335,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -354,7 +354,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -371,7 +371,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -387,7 +387,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -409,7 +409,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -428,7 +428,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
diff --git a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java b/src/test/java/net/onrc/onos/core/hostmanager/HostManagerTest.java
similarity index 69%
rename from src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java
rename to src/test/java/net/onrc/onos/core/hostmanager/HostManagerTest.java
index 39e739f..5f22091 100644
--- a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java
+++ b/src/test/java/net/onrc/onos/core/hostmanager/HostManagerTest.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.core.devicemanager;
+package net.onrc.onos.core.hostmanager;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
@@ -43,23 +43,23 @@
import org.openflow.protocol.OFType;
/**
- * Unit tests for the Device Manager module (OnosDeviceManger).
- * These test cases check the result of add/delete device and
- * verify the result of processPacketIn through inject faked packets
- * floodLightProvider, datagridService, networkGraphService,
- * controllerRegistryService, eventChannel are mocked out.
+ * Unit tests for the Host Manager module (HostManger).
+ * These test cases check the result of add/delete host and
+ * verify the result of processPacketIn by injecting fake packets.
+ * floodlightProvider, datagridService, topologyService,
+ * controllerRegistryService, eventChannel are mocked out.
*/
-public class OnosDeviceManagerTest extends FloodlightTestCase {
+public class HostManagerTest extends FloodlightTestCase {
private IPacket pkt0, pkt1, pkt2, pkt3, pkt4;
private IOFSwitch sw1;
private long sw1Dpid;
private long sw1DevPort, sw1DevPort2;
- private OnosDeviceManager odm;
+ private HostManager hostManager;
private OFPacketIn pktIn, pktIn2;
private FloodlightModuleContext modContext;
private ITopologyService networkGraphService;
- private IEventChannel<Long, OnosDevice> eventChannel;
- private IFloodlightProviderService floodLightProvider;
+ private IEventChannel<Long, Host> eventChannel;
+ private IFloodlightProviderService floodlightProvider;
private Date lastSeenTimestamp;
@Override
@@ -74,7 +74,7 @@
topology.createSampleTopology2();
modContext = new FloodlightModuleContext();
- floodLightProvider = createMock(IFloodlightProviderService.class);
+ floodlightProvider = createMock(IFloodlightProviderService.class);
datagridService = createMock(IDatagridService.class);
networkGraphService = createMock(ITopologyService.class);
controllerRegistryService = createMock(IControllerRegistryService.class);
@@ -83,14 +83,14 @@
networkGraphService.registerTopologyListener(anyObject(ITopologyListener.class));
expectLastCall();
- expect(datagridService.createChannel("onos.device", Long.class, OnosDevice.class))
+ expect(datagridService.createChannel("onos.host", Long.class, Host.class))
.andReturn(eventChannel).once();
expect(topology.getOutgoingLink(new Dpid(1L), new PortNumber((short) 100))).andReturn(null).anyTimes();
expect(datagridService.addListener(
- eq("onos.device"),
+ eq("onos.host"),
anyObject(IEventChannelListener.class),
eq(Long.class),
- eq(OnosDevice.class)))
+ eq(Host.class)))
.andReturn(eventChannel).once();
replay(datagridService);
@@ -99,7 +99,7 @@
modContext.addService(IDatagridService.class, datagridService);
modContext.addService(ITopologyService.class, networkGraphService);
- modContext.addService(IFloodlightProviderService.class, floodLightProvider);
+ modContext.addService(IFloodlightProviderService.class, floodlightProvider);
modContext.getServiceImpl(IFloodlightProviderService.class);
sw1Dpid = 1L;
sw1 = createMockSwitch(sw1Dpid);
@@ -108,7 +108,7 @@
sw1DevPort = 100;
sw1DevPort2 = 12L;
- odm = new OnosDeviceManager();
+ hostManager = new HostManager();
/*
* Broadcast source address
*/
@@ -223,26 +223,26 @@
}
/**
- * Test set operation on lastSeenTimstamp field in OnosDevice.
+ * Test set operation on lastSeenTimstamp field in Host.
*/
@Test
public void testSetLastSeenTimestamp() {
Ethernet eth = (Ethernet) pkt1;
- OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
+ Host srcHost = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
- srcDevice.setLastSeenTimestamp(lastSeenTimestamp);
- assertEquals(lastSeenTimestamp, srcDevice.getLastSeenTimestamp());
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
+ srcHost.setLastSeenTimestamp(lastSeenTimestamp);
+ assertEquals(lastSeenTimestamp, srcHost.getLastSeenTimestamp());
}
/**
- * test the functionality to get the source device from Packet header
+ * test the functionality to get the source host from Packet header
* information.
*/
@Test
- public void testGetSourceDeviceFromPacket() {
+ public void testGetSourceHostFromPacket() {
byte[] address = new byte[] {0x00, 0x44, 0x33, 0x22, 0x11, 0x01};
MACAddress srcMac = new MACAddress(address);
- OnosDevice dev1 = new OnosDevice(srcMac,
+ Host host1 = new Host(srcMac,
null,
sw1Dpid,
sw1DevPort,
@@ -252,36 +252,36 @@
* test DHCP packet case
*/
Ethernet eth = (Ethernet) pkt3;
- OnosDevice dev2 = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
- assertEquals(dev1, dev2);
+ Host host2 = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
+ assertEquals(host1, host2);
/*
* test ARP packet case
*/
eth = (Ethernet) pkt4;
- dev2 = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
- assertEquals(dev1, dev2);
+ host2 = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
+ assertEquals(host1, host2);
}
/**
- * This test will invoke addOnosDevice to add a new device through Packet pkt1.
+ * This test will invoke addHost to add a new host through Packet pkt1.
* @throws FloodlightModuleException
*/
@Test
- public void testProcessPacketInAddNewDevice() throws FloodlightModuleException {
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
- EasyMock.isA(OnosDeviceManager.class));
+ public void testProcessPacketInAddNewHost() throws FloodlightModuleException {
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
+ EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt1);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ Command cmd = hostManager.processPacketIn(sw1, pktIn, (Ethernet) pkt1);
assertEquals(Command.CONTINUE, cmd);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
@@ -290,17 +290,17 @@
*/
@Test
public void testProcessPacketInHasLink() throws FloodlightModuleException {
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
- EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
+ EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- Command cmd = odm.processPacketIn(sw1, pktIn2, (Ethernet) pkt1);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ Command cmd = hostManager.processPacketIn(sw1, pktIn2, (Ethernet) pkt1);
assertEquals(Command.CONTINUE, cmd);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
@@ -308,74 +308,74 @@
*/
@Test
public void testProcessPacketInStop() {
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt0);
+ Command cmd = hostManager.processPacketIn(sw1, pktIn, (Ethernet) pkt0);
assertEquals(Command.STOP, cmd);
}
/**
- * Test add a device from the information from packet.
+ * Test add a host from the information from packet.
* @throws FloodlightModuleException
*/
@Test
- public void testAddOnosDevice() throws FloodlightModuleException {
+ public void testAddHost() throws FloodlightModuleException {
Ethernet eth = (Ethernet) pkt1;
Long longmac = eth.getSourceMAC().toLong();
- OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
+ Host srcHost = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- odm.addOnosDevice(longmac, srcDevice);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ hostManager.addHost(longmac, srcHost);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
- * Test delete a device.
+ * Test delete a host.
* @throws FloodlightModuleException
*/
@Test
- public void testDeleteOnosDevice() throws FloodlightModuleException {
+ public void testDeleteHost() throws FloodlightModuleException {
Ethernet eth = (Ethernet) pkt1;
- OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
+ Host srcHost = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- odm.deleteOnosDevice(srcDevice);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ hostManager.deleteHost(srcHost);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
- * Test delete a device by using its source mac address.
+ * Test delete a host by using its source mac address.
* @throws FloodlightModuleException
*/
@Test
- public void testDeleteOnosDeviceByMac() throws FloodlightModuleException {
+ public void testDeleteHostByMac() throws FloodlightModuleException {
Ethernet eth = (Ethernet) pkt1;
MACAddress mac = eth.getSourceMAC();
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- odm.deleteOnosDeviceByMac(mac);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ hostManager.deleteHostByMac(mac);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
}
diff --git a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceTest.java b/src/test/java/net/onrc/onos/core/hostmanager/HostTest.java
similarity index 64%
rename from src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceTest.java
rename to src/test/java/net/onrc/onos/core/hostmanager/HostTest.java
index 6c79bf0..b9eed02 100644
--- a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceTest.java
+++ b/src/test/java/net/onrc/onos/core/hostmanager/HostTest.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.core.devicemanager;
+package net.onrc.onos.core.hostmanager;
import static org.junit.Assert.assertTrue;
@@ -10,10 +10,10 @@
import org.junit.Before;
import org.junit.Test;
-/*
- * This is the test for OnosDevice.class.
+/**
+ * This is the test for the Host class.
*/
-public class OnosDeviceTest {
+public class HostTest {
MACAddress mac1;
MACAddress mac2;
@@ -40,26 +40,26 @@
public void tearDown() throws Exception {
}
- /*
+ /**
* Test for making sure hashCode function works properly.
*/
@Test
public void testHashCode() {
- OnosDevice dev1 = new OnosDevice(mac1, null, dpid1, portNum1, date1);
- OnosDevice dev2 = new OnosDevice(mac2, null, dpid2, portNum2, date2);
+ Host host1 = new Host(mac1, null, dpid1, portNum1, date1);
+ Host host2 = new Host(mac2, null, dpid2, portNum2, date2);
- assertTrue(dev1.hashCode() == dev2.hashCode());
+ assertTrue(host1.hashCode() == host2.hashCode());
}
- /*
+ /**
* Test for making sure equals function works properly.
*/
@Test
public void testEqualsObject() {
- OnosDevice dev1 = new OnosDevice(mac1, null, dpid1, portNum1, date1);
- OnosDevice dev2 = new OnosDevice(mac2, null, dpid2, portNum2, date2);
+ Host host1 = new Host(mac1, null, dpid1, portNum1, date1);
+ Host host2 = new Host(mac2, null, dpid2, portNum2, date2);
- assertTrue(dev1.equals(dev2));
+ assertTrue(host1.equals(host2));
}
}