use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class PingResponseCommandTest method success.
@Test
public void success() throws Exception {
final PingService realPingService = new PingService();
moduleContext.addService(PingService.class, realPingService);
final ISwitchManager realSwitchManager = new SwitchManager();
moduleContext.addService(ISwitchManager.class, realSwitchManager);
InputService inputService = createMock(InputService.class);
moduleContext.addService(InputService.class, inputService);
inputService.addTranslator(eq(OFType.PACKET_IN), anyObject());
replayAll();
final DatapathId dpIdBeta = DatapathId.of(0x0000fffe000002L);
final Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 8), new NetworkEndpoint(new SwitchId(dpId.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
final PingData payload = PingData.of(ping);
moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
realPingService.setup(moduleContext);
byte[] signedPayload = realPingService.getSignature().sign(payload);
byte[] wireData = realPingService.wrapData(ping, signedPayload).serialize();
OFFactory ofFactory = new OFFactoryVer13();
OFPacketIn message = ofFactory.buildPacketIn().setReason(OFPacketInReason.ACTION).setXid(1L).setCookie(PingService.OF_CATCH_RULE_COOKIE).setData(wireData).build();
FloodlightContext metadata = new FloodlightContext();
IPacket decodedEthernet = new Ethernet().deserialize(wireData, 0, wireData.length);
Assert.assertTrue(decodedEthernet instanceof Ethernet);
IFloodlightProviderService.bcStore.put(metadata, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) decodedEthernet);
OfInput input = new OfInput(iofSwitch, message, metadata);
final PingResponseCommand command = makeCommand(input);
command.call();
final List<Message> replies = kafkaMessageCatcher.getValues();
Assert.assertEquals(1, replies.size());
InfoMessage response = (InfoMessage) replies.get(0);
PingResponse pingResponse = (PingResponse) response.getData();
Assert.assertNull(pingResponse.getError());
Assert.assertNotNull(pingResponse.getMeters());
Assert.assertEquals(payload.getPingId(), pingResponse.getPingId());
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkPropsPutTest method makeRequest.
/**
* Produce {@link LinkPropsPut} request with predefined data.
*/
public static LinkPropsPut makeRequest() {
HashMap<String, String> keyValuePairs = new HashMap<>();
keyValuePairs.put("cost", "10000");
LinkPropsDto linkProps = new LinkPropsDto(new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 8), keyValuePairs);
return new LinkPropsPut(linkProps);
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkPropsMapper method map.
/**
* Convert {@link LinkProps} to {@link LinkPropsDto}.
*/
public LinkPropsDto map(LinkProps linkProps) {
if (linkProps == null) {
return null;
}
Map<String, String> props = new HashMap<>();
if (linkProps.getCost() != null) {
props.put(LinkProps.COST_PROP_NAME, Integer.toString(linkProps.getCost()));
}
if (linkProps.getMaxBandwidth() != null) {
props.put(LinkProps.MAX_BANDWIDTH_PROP_NAME, Long.toString(linkProps.getMaxBandwidth()));
}
Long created = Optional.ofNullable(linkProps.getTimeCreate()).map(Instant::toEpochMilli).orElse(null);
Long modified = Optional.ofNullable(linkProps.getTimeModify()).map(Instant::toEpochMilli).orElse(null);
NetworkEndpoint source = new NetworkEndpoint(linkProps.getSrcSwitchId(), linkProps.getSrcPort());
NetworkEndpoint destination = new NetworkEndpoint(linkProps.getDstSwitchId(), linkProps.getDstPort());
return new LinkPropsDto(source, destination, props, created, modified);
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class IslHandler method islChangedNotifyFlowMonitor.
@Override
public void islChangedNotifyFlowMonitor(IslReference reference, boolean removed) {
Endpoint src = reference.getSource();
Endpoint dst = reference.getDest();
IslChangedInfoData islChangedInfoData = IslChangedInfoData.builder().source(new NetworkEndpoint(src.getDatapath(), src.getPortNumber())).destination(new NetworkEndpoint(dst.getDatapath(), dst.getPortNumber())).removed(removed).build();
emit(STREAM_FLOW_MONITORING_ID, getCurrentTuple(), makeIslChangedTuple(islChangedInfoData));
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkServiceTest method updateMaxBandwidth.
@Test
public void updateMaxBandwidth() {
final String correlationId = "update-max-bw-corrId";
Long maxBandwidth = 1000L;
SwitchId srcSwitch = new SwitchId("ff:fe:00:00:00:00:00:01");
Integer srcPort = 8;
SwitchId dstSwitch = new SwitchId("ff:fe:00:00:00:00:00:02");
Integer dstPort = 9;
LinkMaxBandwidthRequest inputRequest = new LinkMaxBandwidthRequest();
inputRequest.setMaxBandwidth(maxBandwidth);
HashMap<String, String> requestProps = new HashMap<>();
requestProps.put(LinkProps.MAX_BANDWIDTH_PROP_NAME, String.valueOf(maxBandwidth));
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), requestProps);
LinkPropsRequest request = new LinkPropsPut(linkProps);
LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
messageExchanger.mockResponse(correlationId, payload);
RequestCorrelationId.create(correlationId);
LinkMaxBandwidthDto result = linkService.updateLinkBandwidth(srcSwitch, srcPort, dstSwitch, dstPort, inputRequest).join();
assertEquals(srcSwitch.toString(), result.getSrcSwitch());
assertEquals(dstSwitch.toString(), result.getDstSwitch());
assertEquals(srcPort, result.getSrcPort());
assertEquals(dstPort, result.getDstPort());
assertEquals(maxBandwidth, result.getMaxBandwidth());
}
Aggregations