use of org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest in project open-kilda by telstra.
the class RecordHandlerTest method shouldInstallServer42IslRttInputRule.
@Test
public void shouldInstallServer42IslRttInputRule() throws SwitchOperationException {
int islPort = 123;
PortColourCookie cookie = PortColourCookie.builder().portNumber(islPort).type(SERVER_42_ISL_RTT_INPUT).build();
expect(switchManager.installServer42IslRttInputFlow(DATAPATH_ID, SERVER42_PORT, islPort)).andReturn(cookie.getValue()).once();
replay(switchManager);
InstallServer42Flow request = InstallServer42Flow.builder().id("test").switchId(SWITCH_ID).cookie(cookie.getValue()).inputPort(SERVER42_PORT).outputPort(0).server42MacAddress(SERVER42_MAC_ADDRESS).server42Vlan(SERVER42_VLAN).build();
recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
verify(switchManager);
}
use of org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest in project open-kilda by telstra.
the class RecordHandlerTest method installServer42SharedTest.
@Test
public void installServer42SharedTest() throws SwitchOperationException {
FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.SERVER42_QINQ_OUTER_VLAN).portNumber(SERVER42_PORT).vlanId(VLAN_1).build();
switchManager.installServer42OuterVlanMatchSharedFlow(DATAPATH_ID, cookie);
expectLastCall().once();
replay(switchManager);
InstallServer42Flow request = InstallServer42Flow.builder().id("shared").switchId(SWITCH_ID).cookie(cookie.getValue()).inputPort(SERVER42_PORT).outputPort(0).build();
recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
verify(switchManager);
}
use of org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest in project open-kilda by telstra.
the class RecordHandlerTest method shouldInstallServer42IslRttOutputRule.
@Test
public void shouldInstallServer42IslRttOutputRule() throws SwitchOperationException {
long cookie = SERVER_42_ISL_RTT_OUTPUT_COOKIE;
expect(switchManager.installServer42IslRttOutputFlow(DATAPATH_ID, SERVER42_PORT, SERVER42_VLAN, SERVER42_MAC_ADDRESS)).andReturn(cookie).once();
replay(switchManager);
InstallServer42Flow request = InstallServer42Flow.builder().id("test").switchId(SWITCH_ID).cookie(cookie).inputPort(0).outputPort(SERVER42_PORT).server42MacAddress(SERVER42_MAC_ADDRESS).server42Vlan(SERVER42_VLAN).build();
recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
verify(switchManager);
}
use of org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest in project open-kilda by telstra.
the class ControllerToSpeakerSharedProxyBolt method handleRegionNotFoundError.
private void handleRegionNotFoundError(CommandMessage commandMessage, SwitchId switchId) {
String errorDetails = String.format("Switch %s not found", switchId.toString());
ErrorData errorData = new ErrorData(ErrorType.NOT_FOUND, errorDetails, errorDetails);
ErrorMessage errorMessage = new ErrorMessage(errorData, System.currentTimeMillis(), commandMessage.getCorrelationId(), null);
Tuple input = getCurrentTuple();
if (commandMessage.getData() instanceof DumpRulesForFlowHsRequest || commandMessage.getData() instanceof DumpMetersForFlowHsRequest) {
MessageContext messageContext = new MessageContext(commandMessage);
SpeakerDataResponse result = new SpeakerDataResponse(messageContext, errorData);
// FIXME(surabujin): there is no subscriber on this stream now
getOutput().emit(Stream.FLOWHS_WORKER, input, makeFlowHsWorkerTuple(commandMessage.getCorrelationId(), result));
} else if (commandMessage.getData() instanceof DumpRulesForSwitchManagerRequest || commandMessage.getData() instanceof DumpMetersForSwitchManagerRequest || commandMessage.getData() instanceof InstallFlowForSwitchManagerRequest || commandMessage.getData() instanceof RemoveFlowForSwitchManagerRequest || commandMessage.getData() instanceof ReinstallDefaultFlowForSwitchManagerRequest) {
getOutput().emit(Stream.KILDA_SWITCH_MANAGER, input, makeSwitchManagerTuple(commandMessage.getCorrelationId(), errorMessage));
} else if (commandMessage.getData() instanceof DumpSwitchPortsDescriptionRequest || commandMessage.getData() instanceof DumpPortDescriptionRequest || commandMessage.getData() instanceof DumpRulesRequest || commandMessage.getData() instanceof DumpMetersRequest || commandMessage.getData() instanceof DeleteMeterRequest || commandMessage.getData() instanceof PortConfigurationRequest) {
getOutput().emit(Stream.NORTHBOUND_REPLY, input, makeNorthboundTuple(commandMessage.getCorrelationId(), errorMessage));
} else {
log.error("Unable to lookup region for message: {}. switch is not tracked.", commandMessage);
}
}
use of org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest 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();
}
Aggregations