use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class SwitchRuleServiceImpl method deleteRules.
@Override
public void deleteRules(String key, SwitchRulesDeleteRequest data) {
isOperationCompleted = false;
SwitchId switchId = data.getSwitchId();
if (!switchRepository.exists(switchId)) {
ErrorData errorData = new ErrorData(ErrorType.NOT_FOUND, format("Switch %s not found", switchId), "Error when deleting switch rules");
ErrorMessage errorMessage = new ErrorMessage(errorData, System.currentTimeMillis(), key);
carrier.response(key, errorMessage);
return;
}
Optional<SwitchProperties> switchProperties = switchPropertiesRepository.findBySwitchId(switchId);
KildaFeatureToggles featureToggles = featureTogglesRepository.getOrDefault();
boolean server42FlowRttFeatureToggle = featureToggles.getServer42FlowRtt();
data.setServer42FlowRttFeatureToggle(server42FlowRttFeatureToggle);
data.setServer42IslRttEnabled(featureToggles.getServer42IslRtt() && switchProperties.map(SwitchProperties::hasServer42IslRttEnabled).orElse(false));
if (switchProperties.isPresent()) {
data.setMultiTable(switchProperties.get().isMultiTable());
data.setSwitchLldp(switchProperties.get().isSwitchLldp());
data.setSwitchArp(switchProperties.get().isSwitchArp());
data.setServer42FlowRttSwitchProperty(switchProperties.get().isServer42FlowRtt());
data.setServer42Port(switchProperties.get().getServer42Port());
data.setServer42Vlan(switchProperties.get().getServer42Vlan());
data.setServer42MacAddress(switchProperties.get().getServer42MacAddress());
Collection<FlowPath> flowPaths = flowPathRepository.findBySrcSwitch(switchId);
List<Integer> flowPorts = new ArrayList<>();
Set<Integer> flowLldpPorts = new HashSet<>();
Set<Integer> flowArpPorts = new HashSet<>();
Set<Integer> server42FlowPorts = new HashSet<>();
fillFlowPorts(switchProperties.get(), flowPaths, flowPorts, flowLldpPorts, flowArpPorts, server42FlowPorts, server42FlowRttFeatureToggle && switchProperties.get().isServer42FlowRtt());
data.setFlowPorts(flowPorts);
data.setFlowLldpPorts(flowLldpPorts);
data.setFlowArpPorts(flowArpPorts);
data.setServer42FlowRttPorts(server42FlowPorts);
List<Integer> islPorts = islRepository.findBySrcSwitch(switchId).stream().map(isl -> isl.getSrcPort()).collect(Collectors.toList());
data.setIslPorts(islPorts);
}
carrier.sendCommandToSpeaker(key, data);
}
use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class SpeakerStatsRequesterBoltTest method doNotRequestGrpcStatsIfNoActiveSwitchesTest.
@Test
public void doNotRequestGrpcStatsIfNoActiveSwitchesTest() {
KildaFeatureToggles featureToggles = new KildaFeatureToggles(KildaFeatureToggles.DEFAULTS);
featureToggles.setCollectGrpcStats(true);
when(switchRepository.findActive()).thenReturn(Collections.emptyList());
when(featureTogglesRepository.getOrDefault()).thenReturn(featureToggles);
runDoNotRequestGrpcStatsTest();
verify(switchRepository, times(1)).findActive();
}
use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class SpeakerStatsRequesterBoltTest method doNotRequestGrpcStatsIfNoNoviflowSwitchesTest.
@Test
public void doNotRequestGrpcStatsIfNoNoviflowSwitchesTest() {
KildaFeatureToggles featureToggles = new KildaFeatureToggles(KildaFeatureToggles.DEFAULTS);
featureToggles.setCollectGrpcStats(true);
Switch sw = Switch.builder().switchId(new SwitchId(1)).build();
sw.setOfDescriptionSoftware("some");
when(switchRepository.findActive()).thenReturn(Collections.emptyList());
when(featureTogglesRepository.getOrDefault()).thenReturn(featureToggles);
runDoNotRequestGrpcStatsTest();
verify(switchRepository, times(1)).findActive();
}
use of org.openkilda.model.KildaFeatureToggles in project open-kilda by telstra.
the class SpeakerStatsRequesterBoltTest method requestGrpcStatsForNoviflowSwitchesTest.
@Test
public void requestGrpcStatsForNoviflowSwitchesTest() {
KildaFeatureToggles featureToggles = new KildaFeatureToggles(KildaFeatureToggles.DEFAULTS);
featureToggles.setCollectGrpcStats(true);
String address = "192.168.1.1";
Switch sw = Switch.builder().switchId(new SwitchId(1)).socketAddress(new IpSocketAddress(address, 20)).build();
sw.setOfDescriptionSoftware("NW500.1.1");
when(switchRepository.findActive()).thenReturn(Collections.singleton(sw));
when(featureTogglesRepository.getOrDefault()).thenReturn(featureToggles);
StatsRequesterBolt statsRequesterBolt = new StatsRequesterBolt(persistenceManager, ZooKeeperSpout.SPOUT_ID);
statsRequesterBolt.prepare(Collections.emptyMap(), topologyContext, output);
statsRequesterBolt.execute(startTuple);
verify(output).emit(eq(ZkStreams.ZK.toString()), any(Tuple.class), anyList());
statsRequesterBolt.execute(input);
ArgumentCaptor<Values> values = ArgumentCaptor.forClass(Values.class);
verify(output, times(1)).emit(eq(STATS_REQUEST_STREAM), any(Tuple.class), anyList());
verify(output, times(1)).emit(eq(GRPC_REQUEST_STREAM), any(Tuple.class), values.capture());
Values capturedValues = values.getValue();
assertTrue(capturedValues.get(0) instanceof CommandMessage);
CommandMessage commandMessage = (CommandMessage) capturedValues.get(0);
assertTrue(commandMessage.getData() instanceof GetPacketInOutStatsRequest);
GetPacketInOutStatsRequest request = (GetPacketInOutStatsRequest) commandMessage.getData();
assertEquals(address, request.getAddress());
}
Aggregations