use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.
the class OpenstackSwitchingHostProviderTest method testProcessPortRemoved.
@Test
public void testProcessPortRemoved() {
org.onosproject.net.Port addedPort = new DefaultPort(DEV1, P1, true, ANNOTATIONS);
DeviceEvent addedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, addedPort);
target.portAddedHelper(addedEvent);
org.onosproject.net.Port removedPort = new DefaultPort(DEV2, P1, true, ANNOTATIONS);
DeviceEvent removedEvent = new DeviceEvent(DeviceEvent.Type.PORT_REMOVED, DEV2, removedPort);
target.portRemovedHelper(removedEvent);
assertNull(target.hostService.getHost(HostId.hostId(HOST_MAC)));
}
use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.
the class OpenstackSwitchingHostProviderTest method testProcessPortAddedForUpdate.
/**
* Tests the process port added method for updating case.
*/
@Test
public void testProcessPortAddedForUpdate() {
org.onosproject.net.Port addedPort = new DefaultPort(DEV1, P1, true, ANNOTATIONS);
DeviceEvent addedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, addedPort);
target.portAddedHelper(addedEvent);
// org.onosproject.net.Port updatedPort = new DefaultPort(DEV1, P2, true, ANNOTATIONS);
// DeviceEvent updatedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, updatedPort);
target.portAddedHelper(addedEvent);
HostId hostId = HostId.hostId(HOST_MAC);
HostDescription hostDesc = new DefaultHostDescription(HOST_MAC, VlanId.NONE, new HostLocation(CP11, System.currentTimeMillis()), ImmutableSet.of(HOST_IP11), ANNOTATIONS);
verifyHostResult(hostId, hostDesc);
}
use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.
the class OmsPortHelperTest method testOmsPortDescriptionCanBeConvertedToOmsPort.
@Test
public void testOmsPortDescriptionCanBeConvertedToOmsPort() {
PortNumber pn = PortNumber.portNumber(4900);
boolean isEnabled = true;
String anKey = "Base";
String anValue = "value";
SparseAnnotations an = DefaultAnnotations.builder().set(anKey, anValue).build();
Frequency minF = Frequency.ofGHz(3);
Frequency maxF = Frequency.ofGHz(33);
Frequency grid = Frequency.ofGHz(2);
PortDescription portDescription = OmsPortHelper.omsPortDescription(pn, isEnabled, minF, maxF, grid, an);
Port port = new DefaultPort(DEV, portDescription.portNumber(), portDescription.isEnabled(), portDescription.type(), portDescription.portSpeed(), portDescription.annotations());
Optional<OmsPort> maybeOms = OmsPortHelper.asOmsPort(port);
assertTrue(maybeOms.isPresent());
OmsPort oms = maybeOms.get();
assertThat(oms.isEnabled(), is(isEnabled));
assertThat(oms.number(), is(pn));
assertThat(oms.annotations().value(anKey), is(anValue));
assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
assertThat(oms.maxFrequency(), is(maxF));
assertThat(oms.minFrequency(), is(minF));
assertThat(oms.grid(), is(grid));
assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
}
use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.
the class VirtualNetworkIntentManagerTest method setupVirtualNetworkTopology.
/**
* Method to create the virtual network for further testing.
*
* @return virtual network
*/
private VirtualNetwork setupVirtualNetworkTopology() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
VirtualDevice virtualDevice1 = manager.createVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice virtualDevice2 = manager.createVirtualDevice(virtualNetwork.id(), DID2);
VirtualDevice virtualDevice3 = manager.createVirtualDevice(virtualNetwork.id(), DID3);
VirtualDevice virtualDevice4 = manager.createVirtualDevice(virtualNetwork.id(), DID4);
Port port1 = new DefaultPort(virtualDevice1, PortNumber.portNumber(1), true);
cp1 = new ConnectPoint(virtualDevice1.id(), port1.number());
manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), port1.number(), cp1);
Port port2 = new DefaultPort(virtualDevice1, PortNumber.portNumber(2), true);
cp2 = new ConnectPoint(virtualDevice1.id(), port2.number());
manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), port2.number(), cp2);
Port port3 = new DefaultPort(virtualDevice2, PortNumber.portNumber(3), true);
cp3 = new ConnectPoint(virtualDevice2.id(), port3.number());
manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), port3.number(), cp3);
Port port4 = new DefaultPort(virtualDevice2, PortNumber.portNumber(4), true);
cp4 = new ConnectPoint(virtualDevice2.id(), port4.number());
manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), port4.number(), cp4);
Port port5 = new DefaultPort(virtualDevice3, PortNumber.portNumber(5), true);
cp5 = new ConnectPoint(virtualDevice3.id(), port5.number());
manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), port5.number(), cp5);
Port port6 = new DefaultPort(virtualDevice3, PortNumber.portNumber(6), true);
cp6 = new ConnectPoint(virtualDevice3.id(), port6.number());
manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), port6.number(), cp6);
link1 = manager.createVirtualLink(virtualNetwork.id(), cp1, cp3);
virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
link2 = manager.createVirtualLink(virtualNetwork.id(), cp3, cp1);
virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
link3 = manager.createVirtualLink(virtualNetwork.id(), cp4, cp5);
virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
link4 = manager.createVirtualLink(virtualNetwork.id(), cp5, cp4);
virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
vnetIntentService = new VirtualNetworkIntentManager(manager, virtualNetwork.id());
vnetIntentService.intentStore = intentStore;
return virtualNetwork;
}
use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.
the class EdgeManagerTest method testEmit.
@Test
public void testEmit() {
byte[] arr = new byte[10];
Device referenceDevice;
DeviceEvent event;
int numDevices = 10;
int numInfraPorts = 5;
totalPorts = 10;
defaultPopulator(numDevices, numInfraPorts);
for (byte byteIndex = 0; byteIndex < arr.length; byteIndex++) {
arr[byteIndex] = byteIndex;
}
for (int i = 0; i < numDevices; i++) {
referenceDevice = NetTestTools.device(Integer.toString(i));
testDeviceManager.listener.event(new DeviceEvent(DEVICE_ADDED, referenceDevice, new DefaultPort(referenceDevice, PortNumber.portNumber(1), true)));
}
mgr.emitPacket(ByteBuffer.wrap(arr), Optional.empty());
assertEquals("There were an unexpected number of emitted packets", (totalPorts - numInfraPorts) * numDevices, packets.size());
Iterator<OutboundPacket> packetIter = packets.iterator();
OutboundPacket packet;
while (packetIter.hasNext()) {
packet = packetIter.next();
assertEquals("The packet had an incorrect payload.", arr, packet.data().array());
}
// Start testing emission to a specific device
packets.clear();
mgr.emitPacket(NetTestTools.did(Integer.toString(1)), ByteBuffer.wrap(arr), Optional.empty());
assertEquals("Unexpected number of outbound packets were emitted.", totalPorts - numInfraPorts, packets.size());
packetIter = packets.iterator();
while (packetIter.hasNext()) {
packet = packetIter.next();
assertEquals("The packet had an incorrect payload", arr, packet.data().array());
}
}
Aggregations