Search in sources :

Example 6 with RemoveFlow

use of org.openkilda.messaging.command.flow.RemoveFlow 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());
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) Test(org.junit.Test)

Example 7 with RemoveFlow

use of org.openkilda.messaging.command.flow.RemoveFlow in project open-kilda by telstra.

the class SwitchSyncFsm method sendRulesCommands.

protected void sendRulesCommands(SwitchSyncState from, SwitchSyncState to, SwitchSyncEvent event, Object context) {
    if (missingRules.isEmpty() && excessRules.isEmpty() && misconfiguredRules.isEmpty()) {
        log.info("Nothing to do with rules (switch={}, key={})", switchId, key);
        fire(NEXT);
        return;
    }
    if (!missingRules.isEmpty()) {
        log.info("Request to install switch rules has been sent (switch={}, key={})", switchId, key);
        missingRulesPendingResponsesCount = missingRules.size();
        for (BaseFlow command : missingRules) {
            carrier.sendCommandToSpeaker(key, new InstallFlowForSwitchManagerRequest(command));
        }
    }
    if (!excessRules.isEmpty()) {
        log.info("Request to remove switch rules has been sent (switch={}, key={})", switchId, key);
        excessRulesPendingResponsesCount = excessRules.size();
        for (RemoveFlow command : excessRules) {
            carrier.sendCommandToSpeaker(key, new RemoveFlowForSwitchManagerRequest(switchId, command));
        }
    }
    if (!misconfiguredRules.isEmpty()) {
        log.info("Request to reinstall default switch rules has been sent (switch={}, key={})", switchId, key);
        reinstallDefaultRulesPendingResponsesCount = misconfiguredRules.size();
        for (ReinstallDefaultFlowForSwitchManagerRequest command : misconfiguredRules) {
            carrier.sendCommandToSpeaker(key, command);
        }
    }
    continueIfRulesSynchronized();
}
Also used : RemoveFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) BaseFlow(org.openkilda.messaging.command.flow.BaseFlow) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)

Example 8 with RemoveFlow

use of org.openkilda.messaging.command.flow.RemoveFlow in project open-kilda by telstra.

the class RecordHandler method doDeleteFlow.

/**
 * Removes flow.
 *
 * @param message command message for flow installation
 */
private void doDeleteFlow(final CommandMessage message, String replyToTopic, Destination replyDestination) throws FlowCommandException {
    RemoveFlow command = (RemoveFlow) message.getData();
    logger.debug("deleting a flow: {}", command);
    DatapathId dpid = DatapathId.of(command.getSwitchId());
    ISwitchManager switchManager = context.getSwitchManager();
    try {
        switchManager.deleteFlow(dpid, command.getId(), command.getCookie());
        Integer meterId = meterPool.deallocate(command.getSwitchId(), command.getId());
        if (meterId != null) {
            switchManager.deleteMeter(dpid, meterId);
        }
        message.setDestination(replyDestination);
        context.getKafkaProducer().postMessage(replyToTopic, message);
    } catch (SwitchOperationException e) {
        throw new FlowCommandException(command.getId(), ErrorType.DELETION_FAILURE, e);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 9 with RemoveFlow

use of org.openkilda.messaging.command.flow.RemoveFlow in project open-kilda by telstra.

the class FlowTopologyTest method removeFlowCommand.

private RemoveFlow removeFlowCommand(final String flowId) throws IOException {
    System.out.println("TOPOLOGY: Remove flow");
    RemoveFlow commandData = new RemoveFlow(0L, flowId, COOKIE, "switch-id", 0L);
    CommandMessage commandMessage = new CommandMessage(commandData, 0, "remove-flow", Destination.WFM);
    // sendTopologyEngineMessage(commandMessage);
    sendFlowMessage(commandMessage);
    return commandData;
}
Also used : RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 10 with RemoveFlow

use of org.openkilda.messaging.command.flow.RemoveFlow in project open-kilda by telstra.

the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation.

@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation() {
    Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
    String inPort = "1";
    String inVlan = "10";
    String outPort = "2";
    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());
    assertEquals(Integer.valueOf(outPort), criteria.getOutPort());
    assertNull(criteria.getMetadataValue());
    assertNull(criteria.getMetadataMask());
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) Test(org.junit.Test)

Aggregations

RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)12 Test (org.junit.Test)6 CommandMessage (org.openkilda.messaging.command.CommandMessage)4 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)4 InfoMessage (org.openkilda.messaging.info.InfoMessage)4 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)4 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)4 CommandData (org.openkilda.messaging.command.CommandData)3 IOException (java.io.IOException)2 Values (org.apache.storm.tuple.Values)2 Message (org.openkilda.messaging.Message)2 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)2 InstallFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)2 ReinstallDefaultFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest)2 RemoveFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2 DatapathId (org.projectfloodlight.openflow.types.DatapathId)2 HashSet (java.util.HashSet)1 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1