use of org.openkilda.messaging.command.flow.InstallIngressFlow in project open-kilda by telstra.
the class TestUtils method createTopology.
public static Set<CommandMessage> createTopology(final SwitchService switchService, final IslService islService) {
Set<CommandMessage> commands = new HashSet<>();
switchService.add(new SwitchInfoData(srcSwitchId, SwitchEventType.ADDED, address, name, "OVS 1"));
switchService.add(new SwitchInfoData(firstTransitSwitchId, SwitchEventType.ADDED, address, name, "OVS 2"));
switchService.add(new SwitchInfoData(secondTransitSwitchId, SwitchEventType.ADDED, address, name, "OVS 1"));
switchService.add(new SwitchInfoData(dstSwitchId, SwitchEventType.ADDED, address, name, "OVS 2"));
switchService.activate(new SwitchInfoData(srcSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 1"));
switchService.activate(new SwitchInfoData(firstTransitSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 2"));
switchService.activate(new SwitchInfoData(secondTransitSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 1"));
switchService.activate(new SwitchInfoData(dstSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 2"));
PathNode srcNode;
PathNode dstNode;
List<PathNode> list;
srcNode = new PathNode(srcSwitchId, 1, 0);
dstNode = new PathNode(firstTransitSwitchId, 2, 1);
list = asList(srcNode, dstNode);
islService.discoverLink(new IslInfoData(10L, list, portSpeed));
islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
srcNode = new PathNode(firstTransitSwitchId, 1, 0);
dstNode = new PathNode(secondTransitSwitchId, 2, 1);
list = asList(srcNode, dstNode);
islService.discoverLink(new IslInfoData(10L, list, portSpeed));
islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
srcNode = new PathNode(secondTransitSwitchId, 1, 0);
dstNode = new PathNode(dstSwitchId, 2, 1);
list = asList(srcNode, dstNode);
islService.discoverLink(new IslInfoData(10L, list, portSpeed));
islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, COOKIE, srcSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, INPUT_VLAN_ID, TRANSIT_VLAN_ID, OutputVlanType.REPLACE, 10000L, 0L), METER_ID, DEFAULT_CORRELATION_ID, Destination.WFM));
commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, firstTransitSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, secondTransitSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, COOKIE, dstSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID, OUTPUT_VLAN_ID, OutputVlanType.REPLACE), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, OUTPUT_VLAN_ID, TRANSIT_VLAN_ID, OutputVlanType.REPLACE, 10000L, 0L), METER_ID, DEFAULT_CORRELATION_ID, Destination.WFM));
commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, 2, INPUT_VLAN_ID, OutputVlanType.REPLACE), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
return commands;
}
use of org.openkilda.messaging.command.flow.InstallIngressFlow in project open-kilda by telstra.
the class RecordHandler method doSyncRulesRequest.
/**
* Installs missed flows on the switch.
* @param message with list of flows.
*/
private void doSyncRulesRequest(final CommandMessage message) {
InstallMissedFlowsRequest request = (InstallMissedFlowsRequest) message.getData();
final String switchId = request.getSwitchId();
logger.debug("Processing rules to be updated for switch {}", switchId);
for (BaseInstallFlow command : request.getFlowCommands()) {
logger.debug("Processing command for switch {} {}", switchId, command);
try {
if (command instanceof InstallIngressFlow) {
installIngressFlow((InstallIngressFlow) command);
} else if (command instanceof InstallEgressFlow) {
installEgressFlow((InstallEgressFlow) command);
} else if (command instanceof InstallTransitFlow) {
installTransitFlow((InstallTransitFlow) command);
} else if (command instanceof InstallOneSwitchFlow) {
installOneSwitchFlow((InstallOneSwitchFlow) command);
}
} catch (SwitchOperationException e) {
logger.error("Error during flow installation", e);
}
}
}
use of org.openkilda.messaging.command.flow.InstallIngressFlow in project open-kilda by telstra.
the class ReplaceInstallFlowTest method installIngressPushFlow.
@Test
public void installIngressPushFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_push_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressPushFlowMod(data.getInputPort(), data.getOutputPort(), data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
use of org.openkilda.messaging.command.flow.InstallIngressFlow in project open-kilda by telstra.
the class ReplaceInstallFlowTest method installIngressReplaceFlow.
@Test
public void installIngressReplaceFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_replace_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressReplaceFlowMod(data.getInputPort(), data.getOutputPort(), data.getInputVlanId(), data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
use of org.openkilda.messaging.command.flow.InstallIngressFlow in project open-kilda by telstra.
the class RecordHandler method doProcessIngressFlow.
/**
* Processes install ingress flow message.
*
* @param message command message for flow installation
*/
private void doProcessIngressFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
InstallIngressFlow command = (InstallIngressFlow) message.getData();
try {
installIngressFlow(command);
message.setDestination(replyDestination);
context.getKafkaProducer().postMessage(replyToTopic, message);
} catch (SwitchOperationException e) {
throw new FlowCommandException(command.getId(), ErrorType.CREATION_FAILURE, e);
}
}
Aggregations