use of org.openkilda.floodlight.switchmanager.ISwitchManager in project open-kilda by telstra.
the class RecordHandler method dumpMeters.
private void dumpMeters(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
try {
logger.debug("Get all meters for switch {}", switchId);
ISwitchManager switchManager = context.getSwitchManager();
List<OFMeterConfig> meterEntries = switchManager.dumpMeters(DatapathId.of(switchId.toLong()));
List<MeterEntry> meters = meterEntries.stream().map(OfMeterConverter::toMeterEntry).collect(Collectors.toList());
SwitchMeterEntries response = SwitchMeterEntries.builder().switchId(switchId).meterEntries(meters).build();
sender.accept(response);
} catch (UnsupportedSwitchOperationException e) {
logger.info("Meters not supported: {}", switchId);
sender.accept(new SwitchMeterUnsupported(switchId));
} catch (SwitchNotFoundException e) {
logger.info("Dumping switch meters is unsuccessful. Switch {} not found", switchId);
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(switchId.toString()).buildData();
sender.accept(errorData);
} catch (SwitchOperationException e) {
logger.error("Unable to dump meters", e);
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump meters").buildData();
sender.accept(errorData);
}
}
use of org.openkilda.floodlight.switchmanager.ISwitchManager in project open-kilda by telstra.
the class RecordHandler method dumpRuleManagerMeters.
private void dumpRuleManagerMeters(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
try {
logger.debug("Get all meters for switch {}", switchId);
ISwitchManager switchManager = context.getSwitchManager();
DatapathId datapathId = DatapathId.of(switchId.toLong());
List<OFMeterConfig> meterEntries = switchManager.dumpMeters(datapathId);
IOFSwitch iofSwitch = switchManager.lookupSwitch(datapathId);
boolean inaccurate = featureDetectorService.detectSwitch(iofSwitch).contains(SwitchFeature.INACCURATE_METER);
List<MeterSpeakerData> meters = meterEntries.stream().map(entry -> org.openkilda.floodlight.converter.rulemanager.OfMeterConverter.INSTANCE.convertToMeterSpeakerData(entry, inaccurate)).collect(Collectors.toList());
MeterDumpResponse response = MeterDumpResponse.builder().switchId(switchId).meterSpeakerData(meters).build();
sender.accept(response);
} catch (UnsupportedSwitchOperationException e) {
logger.info("Meters not supported: {}", switchId);
sender.accept(new SwitchMeterUnsupported(switchId));
} catch (SwitchNotFoundException e) {
logger.info("Dumping switch meters is unsuccessful. Switch {} not found", switchId);
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(switchId.toString()).buildData();
sender.accept(errorData);
} catch (SwitchOperationException e) {
logger.error("Unable to dump meters", e);
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump meters").buildData();
sender.accept(errorData);
}
}
use of org.openkilda.floodlight.switchmanager.ISwitchManager in project open-kilda by telstra.
the class RecordHandler method processInstallServer42IslRttRule.
private Long processInstallServer42IslRttRule(SwitchId switchId, long cookie, int server42Port, int server42Vlan, MacAddress server42MacAddress) throws SwitchOperationException {
ISwitchManager switchManager = context.getSwitchManager();
DatapathId dpid = DatapathId.of(switchId.toLong());
if (cookie == SERVER_42_ISL_RTT_OUTPUT_COOKIE) {
return switchManager.installServer42IslRttOutputFlow(dpid, server42Port, server42Vlan, server42MacAddress);
} else if (new Cookie(cookie).getType() == CookieType.SERVER_42_ISL_RTT_INPUT) {
PortColourCookie portColourCookie = new PortColourCookie(cookie);
int islPort = portColourCookie.getPortNumber();
return switchManager.installServer42IslRttInputFlow(dpid, server42Port, islPort);
} else {
logger.warn("Skipping the installation of unexpected server 42 switch rule {} for switch {}", Long.toHexString(cookie), switchId);
return null;
}
}
use of org.openkilda.floodlight.switchmanager.ISwitchManager in project open-kilda by telstra.
the class RecordHandler method processDeleteFlow.
private List<Long> processDeleteFlow(RemoveFlow command, DatapathId dpid) throws SwitchOperationException {
logger.info("Deleting flow {} from switch {}", command.getId(), dpid);
if (command.isCleanUpIngress()) {
context.getSwitchManager().removeIntermediateIngressRule(dpid, command.getCriteria().getInPort());
}
if (command.isCleanUpIngressLldp()) {
context.getSwitchManager().removeLldpInputCustomerFlow(dpid, command.getCriteria().getInPort());
}
if (command.isCleanUpIngressArp()) {
context.getSwitchManager().removeArpInputCustomerFlow(dpid, command.getCriteria().getInPort());
}
DeleteRulesCriteria criteria = Optional.ofNullable(command.getCriteria()).orElseGet(() -> DeleteRulesCriteria.builder().cookie(command.getCookie()).build());
ISwitchManager switchManager = context.getSwitchManager();
List<Long> cookiesOfRemovedRules = switchManager.deleteRulesByCriteria(dpid, command.isMultiTable(), command.getRuleType(), criteria);
if (cookiesOfRemovedRules.isEmpty()) {
logger.warn("No rules were removed by criteria {} for flow {} from switch {}", criteria, command.getId(), dpid);
}
Long meterId = command.getMeterId();
if (meterId != null) {
try {
switchManager.deleteMeter(dpid, meterId);
} catch (UnsupportedOperationException e) {
logger.info("Skip meter {} deletion from switch {}: {}", meterId, dpid, e.getMessage());
} catch (SwitchOperationException e) {
logger.error("Failed to delete meter {} from switch {}: {}", meterId, dpid, e.getMessage());
}
}
return cookiesOfRemovedRules;
}
use of org.openkilda.floodlight.switchmanager.ISwitchManager in project open-kilda by telstra.
the class RecordHandler method processInstallServer42RttRule.
private void processInstallServer42RttRule(InstallServer42Flow command) throws SwitchOperationException {
ISwitchManager switchManager = context.getSwitchManager();
DatapathId dpid = DatapathId.of(command.getSwitchId().toLong());
Cookie cookie = new Cookie(command.getCookie());
FlowSharedSegmentCookie sharedSegmentCookie = new FlowSharedSegmentCookie(command.getCookie());
if (command.getCookie() == SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) {
switchManager.installServer42FlowRttOutputVlanFlow(dpid, command.getOutputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
} else if (command.getCookie() == SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) {
switchManager.installServer42FlowRttOutputVxlanFlow(dpid, command.getOutputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
} else if (cookie.getType() == CookieType.SERVER_42_FLOW_RTT_INPUT) {
PortColourCookie portColourCookie = new PortColourCookie(command.getCookie());
int customerPort = portColourCookie.getPortNumber();
switchManager.installServer42FlowRttInputFlow(dpid, command.getInputPort(), customerPort, command.getServer42MacAddress());
} else if (cookie.getType() == CookieType.SHARED_OF_FLOW && sharedSegmentCookie.getSegmentType() == SharedSegmentType.SERVER42_QINQ_OUTER_VLAN) {
switchManager.installServer42OuterVlanMatchSharedFlow(dpid, sharedSegmentCookie);
} else if (command.getCookie() == SERVER_42_ISL_RTT_OUTPUT_COOKIE) {
processInstallServer42IslRttRule(command.getSwitchId(), command.getCookie(), command.getOutputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
} else if (cookie.getType() == CookieType.SERVER_42_ISL_RTT_INPUT) {
processInstallServer42IslRttRule(command.getSwitchId(), command.getCookie(), command.getInputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
} else {
logger.warn("Skipping the installation of unexpected server 42 switch rule {} for switch {}", Long.toHexString(command.getCookie()), command.getSwitchId());
}
}
Aggregations