use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class SwitchTrackingService method dumpAllSwitchesAction.
private void dumpAllSwitchesAction(String dumpId) {
Collection<IOFSwitch> iofSwitches = switchManager.getAllSwitchMap(true).values();
for (IOFSwitch sw : iofSwitches) {
NetworkDumpSwitchData payload = null;
try {
payload = new NetworkDumpSwitchData(buildSwitch(sw), dumpId, sw.getControllerRole() != OFControllerRole.ROLE_SLAVE);
emitDiscoveryEvent(sw.getId(), payload);
} catch (SwitchOperationException e) {
log.error("Exclude {} from dump switches response - {}", sw.getId(), e.getMessage(), e);
}
}
}
use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class BfdCommand method call.
@Override
public Command call() throws Exception {
try {
IOFSwitch sw = switchManager.lookupSwitch(target);
validate(sw);
try (Session session = sessionService.open(new MessageContext(getContext().getCorrelationId()), sw)) {
handle(session);
}
} catch (SwitchOperationException e) {
handleError(e);
// early error response
sendResponse();
}
return null;
}
use of org.openkilda.floodlight.error.SwitchOperationException in project open-kilda by telstra.
the class MetersResource method getMeters.
// FIXME(surabujin): is it used anywhere?
/**
* Gets meters.
* @return the map of meters.
*/
@Get("json")
@SuppressWarnings("unchecked")
public Map<Long, Object> getMeters() {
Map<Long, Object> response = new HashMap<>();
String switchId = (String) this.getRequestAttributes().get("switch_id");
logger.debug("Get meters for switch: {}", switchId);
ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes().get(ISwitchManager.class.getCanonicalName());
try {
List<OFMeterConfig> meters = switchManager.dumpMeters(DatapathId.of(switchId));
if (meters != null) {
logger.debug("Meters from switch {} received: {}", switchId, meters.size());
for (OFMeterConfig entry : meters) {
response.put(entry.getMeterId(), entry);
}
}
} catch (UnsupportedSwitchOperationException ex) {
String messageString = "Not supported";
logger.error("{}: {}", messageString, switchId, ex);
MessageError responseMessage = new MessageError(CorrelationContext.getId(), System.currentTimeMillis(), ErrorType.PARAMETERS_INVALID.toString(), messageString, ex.getMessage());
response.putAll(MAPPER.convertValue(responseMessage, Map.class));
getResponse().setStatus(Status.SERVER_ERROR_NOT_IMPLEMENTED);
} catch (IllegalArgumentException | SwitchOperationException exception) {
String messageString = "No such switch";
logger.error("{}: {}", messageString, switchId, exception);
MessageError responseMessage = new MessageError(CorrelationContext.getId(), System.currentTimeMillis(), ErrorType.PARAMETERS_INVALID.toString(), messageString, exception.getMessage());
response.putAll(MAPPER.convertValue(responseMessage, Map.class));
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
}
return response;
}
Aggregations