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());
}
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();
}
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);
}
}
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;
}
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());
}
Aggregations