use of org.openkilda.messaging.info.rule.FlowEntry in project open-kilda by telstra.
the class RecordHandler method doDumpRulesRequest.
private void doDumpRulesRequest(final CommandMessage message) {
DumpRulesRequest request = (DumpRulesRequest) message.getData();
final String switchId = request.getSwitchId();
logger.debug("Loading installed rules for switch {}", switchId);
OFFlowStatsReply reply = context.getSwitchManager().dumpFlowTable(DatapathId.of(switchId));
List<FlowEntry> flows = reply.getEntries().stream().map(OFFlowStatsConverter::toFlowEntry).collect(Collectors.toList());
SwitchFlowEntries response = SwitchFlowEntries.builder().switchId(switchId).flowEntries(flows).build();
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
context.getKafkaProducer().postMessage(TOPO_ENG_TOPIC, infoMessage);
}
use of org.openkilda.messaging.info.rule.FlowEntry in project open-kilda by telstra.
the class RecordHandler method processDumpRulesRequest.
private void processDumpRulesRequest(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
try {
logger.debug("Loading installed rules for switch {}", switchId);
List<OFFlowStatsEntry> flowEntries = context.getSwitchManager().dumpFlowTable(DatapathId.of(switchId.toLong()));
List<FlowEntry> flows = flowEntries.stream().map(OfFlowStatsMapper.INSTANCE::toFlowEntry).collect(Collectors.toList());
SwitchFlowEntries response = SwitchFlowEntries.builder().switchId(switchId).flowEntries(flows).build();
sender.accept(response);
} catch (SwitchOperationException e) {
logger.error("Dumping of rules on switch '{}' was unsuccessful: {}", switchId, e.getMessage());
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("The switch was not found when requesting a rules dump.").buildData();
sender.accept(errorData);
}
}
use of org.openkilda.messaging.info.rule.FlowEntry in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithStringOutPort.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithStringOutPort() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String inVlan = "10";
String outPort = "in_port";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, inVlan, outPort, null, false, null, null);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertEquals(Integer.valueOf(inVlan), criteria.getEncapsulationId());
assertNull(criteria.getOutPort());
assertNull(criteria.getMetadataValue());
assertNull(criteria.getMetadataMask());
}
use of org.openkilda.messaging.info.rule.FlowEntry in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithVxlanEncapsulationIngress.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithVxlanEncapsulationIngress() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String outPort = "2";
String tunnelId = "10";
String metadataValue = "0x15";
String metadataMask = "0xFF";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, null, outPort, tunnelId, true, metadataValue, metadataMask);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertNull(criteria.getEncapsulationId());
assertEquals(Integer.valueOf(outPort), criteria.getOutPort());
assertEquals(Long.decode(metadataValue), criteria.getMetadataValue());
assertEquals(Long.decode(metadataMask), criteria.getMetadataMask());
}
use of org.openkilda.messaging.info.rule.FlowEntry in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithVxlanEncapsulationTransitAndEgress.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithVxlanEncapsulationTransitAndEgress() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String outPort = "2";
String tunnelId = "10";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, null, outPort, tunnelId, false, null, null);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertEquals(Integer.valueOf(tunnelId), criteria.getEncapsulationId());
assertEquals(Integer.valueOf(outPort), criteria.getOutPort());
assertNull(criteria.getMetadataValue());
assertNull(criteria.getMetadataMask());
}
Aggregations