use of org.projectfloodlight.openflow.types.DatapathId 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.projectfloodlight.openflow.types.DatapathId 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());
}
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method doDeleteMeter.
private void doDeleteMeter(CommandMessage message, String replyToTopic) {
DeleteMeterRequest request = (DeleteMeterRequest) message.getData();
logger.info("Deleting meter '{}'. Switch: '{}'", request.getMeterId(), request.getSwitchId());
final IKafkaProducerService producerService = getKafkaProducer();
try {
DatapathId dpid = DatapathId.of(request.getSwitchId().toLong());
context.getSwitchManager().deleteMeter(dpid, request.getMeterId());
boolean deleted = context.getSwitchManager().dumpMeters(dpid).stream().noneMatch(config -> config.getMeterId() == request.getMeterId());
DeleteMeterResponse response = new DeleteMeterResponse(deleted);
InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), infoMessage);
} catch (SwitchOperationException e) {
logger.error("Deleting meter '{}' from switch '{}' was unsuccessful: {}", request.getMeterId(), request.getSwitchId(), e.getMessage());
anError(ErrorType.DATA_INVALID).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method doRemoveIslDefaultRule.
private void doRemoveIslDefaultRule(CommandMessage message) {
RemoveIslDefaultRulesCommand toRemove = (RemoveIslDefaultRulesCommand) message.getData();
RemoveIslDefaultRulesResult result = new RemoveIslDefaultRulesResult(toRemove.getSrcSwitch(), toRemove.getSrcPort(), toRemove.getDstSwitch(), toRemove.getDstPort(), true);
DatapathId dpid = DatapathId.of(toRemove.getSrcSwitch().toLong());
try {
context.getSwitchManager().removeMultitableEndpointIslRules(dpid, toRemove.getSrcPort());
context.getSwitchManager().removeServer42IslRttInputFlow(dpid, toRemove.getSrcPort());
} catch (SwitchOperationException e) {
logger.error("Failed to remove isl rules for switch: '{}'", toRemove.getSrcSwitch(), e);
result.setSuccess(false);
}
getKafkaProducer().sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), record.key(), new InfoMessage(result, System.currentTimeMillis(), message.getCorrelationId(), context.getRegion()));
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method doPortsCommandDataRequest.
private void doPortsCommandDataRequest(Set<SwitchId> scope, PortsCommandData payload, String correlationId) {
ISwitchManager switchManager = context.getModuleContext().getServiceImpl(ISwitchManager.class);
try {
logger.info("Getting ports data. Requester: {}", payload.getRequester());
Map<DatapathId, IOFSwitch> allSwitchMap = context.getSwitchManager().getAllSwitchMap(true);
for (Map.Entry<DatapathId, IOFSwitch> entry : allSwitchMap.entrySet()) {
SwitchId switchId = new SwitchId(entry.getKey().toString());
if (!scope.contains(switchId)) {
continue;
}
try {
IOFSwitch sw = entry.getValue();
Set<PortStatusData> statuses = new HashSet<>();
for (OFPortDesc portDesc : switchManager.getPhysicalPorts(sw.getId())) {
statuses.add(new PortStatusData(portDesc.getPortNo().getPortNumber(), portDesc.isEnabled() ? PortStatus.UP : PortStatus.DOWN));
}
SwitchPortStatusData response = SwitchPortStatusData.builder().switchId(switchId).ports(statuses).requester(payload.getRequester()).build();
InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), correlationId);
getKafkaProducer().sendMessageAndTrack(context.getKafkaStatsTopic(), infoMessage);
} catch (Exception e) {
logger.error("Could not get port stats data for switch '{}' with error '{}'", switchId, e.getMessage(), e);
}
}
} catch (Exception e) {
logger.error("Could not get port data for stats '{}'", e.getMessage(), e);
}
}
Aggregations