use of org.openkilda.model.LinkProps in project open-kilda by telstra.
the class LinkOperationsBolt method dropLinkProps.
private LinkPropsResponse dropLinkProps(LinkPropsDrop request) {
LinkProps linkPropsToDrop = LinkProps.builder().srcSwitchId(request.getPropsMask().getSource().getDatapath()).srcPort(request.getPropsMask().getSource().getPortNumber()).dstSwitchId(request.getPropsMask().getDest().getDatapath()).dstPort(request.getPropsMask().getDest().getPortNumber()).build();
LinkProps reverseLinkPropsToDrop = swapLinkProps(linkPropsToDrop);
try {
LinkProps result = deleteLinkProps(linkPropsToDrop, reverseLinkPropsToDrop);
return new LinkPropsResponse(request, LinkPropsMapper.INSTANCE.map(result), null);
} catch (Exception e) {
log.error("Unhandled exception in drop linkprops operation.", e);
return new LinkPropsResponse(request, null, e.getMessage());
}
}
use of org.openkilda.model.LinkProps in project open-kilda by telstra.
the class LinkOperationsBolt method putLinkProps.
private LinkPropsResponse putLinkProps(LinkPropsPut request) {
try {
LinkProps toSetForward = LinkPropsMapper.INSTANCE.map(request.getLinkProps());
LinkProps toSetBackward = swapLinkProps(toSetForward);
LinkProps result = createOrUpdateProps(toSetForward);
createOrUpdateProps(toSetBackward);
return new LinkPropsResponse(request, LinkPropsMapper.INSTANCE.map(result), null);
} catch (LinkPropsException e) {
throw new MessageException(ErrorType.DATA_INVALID, "Can't create/update link props", e.getMessage());
} catch (Exception e) {
log.error("Unhandled exception in create or update linkprops operation.", e);
return new LinkPropsResponse(request, null, e.getMessage());
}
}
use of org.openkilda.model.LinkProps in project open-kilda by telstra.
the class IslFsm method initializeFromLinkProps.
private void initializeFromLinkProps(Endpoint source, Endpoint dest, IslBuilder isl) {
Optional<LinkProps> linkProps = loadLinkProps(source, dest);
if (linkProps.isPresent()) {
LinkProps entry = linkProps.get();
Integer cost = entry.getCost();
if (cost != null) {
isl.cost(cost);
}
Long maxBandwidth = entry.getMaxBandwidth();
if (maxBandwidth != null) {
isl.maxBandwidth(maxBandwidth);
}
}
}
use of org.openkilda.model.LinkProps in project open-kilda by telstra.
the class SwitchIntegrationService method getIslLinkProps.
/**
* Gets the isl link cost.
*
* @return the isl link cost
*/
public List<LinkProps> getIslLinkProps(final LinkProps keys) {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(applicationProperties.getNbBaseUrl() + IConstants.NorthBoundUrl.GET_LINK_PROPS);
builder = setLinkProps(keys, builder);
String fullUri = builder.build().toUriString();
HttpResponse response = restClientManager.invoke(fullUri, HttpMethod.GET, "", "", applicationService.getAuthHeader());
try {
if (RestClientManager.isValidResponse(response)) {
List<LinkProps> linkPropsResponses = restClientManager.getResponseList(response, LinkProps.class);
if (!CollectionUtil.isEmpty(linkPropsResponses)) {
return linkPropsResponses;
}
}
} catch (InvalidResponseException e) {
LOGGER.warn("Error occurred while getting isl link props ", e);
return null;
}
return null;
}
use of org.openkilda.model.LinkProps in project open-kilda by telstra.
the class SwitchService method getLinkProps.
/**
* Gets the link props.
*
* @param srcSwitch the src switch
*
* @param srcPort the src port
*
* @param dstSwitch the dst switch
*
* @param dstPort the dst port
*
* @return the link props
*/
public LinkProps getLinkProps(final String srcSwitch, final String srcPort, final String dstSwitch, final String dstPort) {
if (StringUtil.isAnyNullOrEmpty(srcSwitch, srcPort, dstPort, dstSwitch)) {
throw new InvalidResponseException(HttpError.PRECONDITION_FAILED.getCode(), HttpError.PRECONDITION_FAILED.getMessage());
}
LinkProps keys = new LinkProps();
keys.setDstPort(dstPort);
keys.setDstSwitch(dstSwitch);
keys.setSrcPort(srcPort);
keys.setSrcSwitch(srcSwitch);
List<LinkProps> linkPropsList = switchIntegrationService.getIslLinkProps(keys);
LinkProps linkProps = null;
if (linkPropsList != null && linkPropsList.size() > 1) {
throw new InvalidResponseException(HttpError.PRECONDITION_FAILED.getCode(), HttpError.PRECONDITION_FAILED.getMessage());
} else {
if (linkPropsList != null && linkPropsList.size() == 1) {
linkProps = linkPropsList.get(0);
if (!linkProps.getDstPort().equals(keys.getDstPort()) || !linkProps.getDstSwitch().equals(keys.getDstSwitch()) || !linkProps.getSrcPort().equals(keys.getSrcPort()) || !linkProps.getSrcSwitch().equals(keys.getSrcSwitch())) {
throw new InvalidResponseException(HttpError.NO_CONTENT.getCode(), HttpError.NO_CONTENT.getMessage());
}
}
}
return linkProps;
}
Aggregations