org.opendaylight.controller.sal.utils.Status.getDescription()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.opendaylight.controller.sal.utils.Status.getDescription()方法的一些代码示例,展示了Status.getDescription()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status.getDescription()方法的具体详情如下:
包路径:org.opendaylight.controller.sal.utils.Status
类名称:Status
方法名:getDescription

Status.getDescription介绍

[英]Returns a human readable description of the failure if any
[中]返回故障的可读描述(如果有)

代码示例

代码示例来源:origin: org.opendaylight.controller/commons.northbound

/**
 * Returns Response for a given status. If the status provided is null or if
 * the corresponding StatusCode is not present in the ResponseStatusMapping,
 * it returns Response with StatusType as INTERNAL_SERVER_ERROR.
 *
 * @param status
 *            The Status
 * @return The Response for a given status.
 */
public static Response getResponse(Status status) {
  if ((status == null) || (!ResponseStatusMapping.containsKey(status.getCode()))) {
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Action Result Unknown").build();
  }
  return Response.status(ResponseStatusMapping.get(status.getCode())).entity(status.getDescription()).build();
}

代码示例来源:origin: org.opendaylight.controller/topologymanager

public Status saveConfigInternal() {
  Status saveStatus = configurationService.persistConfiguration(
      new ArrayList<ConfigurationObject>(userLinksDB.values()), USER_LINKS_FILE_NAME);
  if (!saveStatus.isSuccess()) {
    return new Status(StatusCode.INTERNALERROR, "Topology save failed: " + saveStatus.getDescription());
  }
  return saveStatus;
}

代码示例来源:origin: org.opendaylight.controller/containermanager.implementation

public Status saveContainerConfigLocal() {
  Status status = configurationService.persistConfiguration(
      new ArrayList<ConfigurationObject>(containerConfigs.values()), CONTAINERS_FILE_NAME);
  if (!status.isSuccess()) {
    return new Status(StatusCode.INTERNALERROR, "Failed to save container configurations: "
        + status.getDescription());
  }
  return status;
}

代码示例来源:origin: org.opendaylight.controller/configuration.implementation

@Override
public Status saveConfiguration() {
  boolean success = true;
  for (IConfigurationContainerAware configurationAware : configurationAwareList) {
    logger.trace("Save Config triggered for {}", configurationAware.getClass().getSimpleName());
    Status status = configurationAware.saveConfiguration();
    if (!status.isSuccess()) {
      success = false;
      logger.warn("Failed to save config for {} ({})", configurationAware.getClass().getSimpleName(),
          status.getDescription());
    }
  }
  if (success) {
    return new Status(StatusCode.SUCCESS);
  } else {
    return new Status(StatusCode.INTERNALERROR, "Failed to save one or more configurations");
  }
}

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

private Status addStaticFlow(FlowConfig config, boolean async) {
  // Configuration object validation
  Status status = config.validate();
  if (!status.isSuccess()) {
    log.warn("Invalid Configuration for flow {}. The failure is {}", config, status.getDescription());
    String error = "Invalid Configuration (" + status.getDescription() + ")";
    config.setStatus(error);
    return new Status(StatusCode.BADREQUEST, error);
  }
  return addStaticFlowInternal(config, async, false);
}

代码示例来源:origin: org.opendaylight.affinity/l2agent

private void installFlow(Match match, List<Action> actions, Node incoming_node, short priority) {
  Flow f = new Flow(match, actions);
  f.setPriority(priority);
  // Modify the flow on the network node
  Status status = programmer.addFlow(incoming_node, f);
  if (!status.isSuccess()) {
    logger.warn("SDN Plugin failed to program the flow: {}. The failure is: {}",
          f, status.getDescription());
    return;
  }
  logger.info("Installed flow {} in node {}", f, incoming_node);
}

代码示例来源:origin: org.opendaylight.controller/appauth

private Status removeRoleResourceGroupMapping(String groupName) {
  List<String> affectedRoles = new ArrayList<String>();
  Status result;
  for (Entry<String, Set<ResourceGroup>> pairs : groupsAuthorizations.entrySet()) {
    String role = pairs.getKey();
    Set<ResourceGroup> groups = pairs.getValue();
    for (ResourceGroup group : groups) {
      if (group.getGroupName().equals(groupName)) {
        affectedRoles.add(role);
        break;
      }
    }
  }
  StringBuffer msg = new StringBuffer();
  for (String role : affectedRoles) {
    result = unassignResourceGroupFromRole(groupName, role);
    if (!result.isSuccess()) {
      msg.append(result.getDescription());
      msg.append(' ');
    }
  }
  if (msg.length() != 0) {
    return new Status(StatusCode.BADREQUEST, msg.toString());
  } else {
    return new Status(StatusCode.SUCCESS);
  }
}

代码示例来源:origin: org.opendaylight.controller/appauth

@Override
public Status removeResourceGroup(String groupName) {
  // Default resource group cannot be deleted
  if (groupName == null || groupName.trim().isEmpty()) {
    return new Status(StatusCode.BADREQUEST, "Invalid group name");
  }
  if (groupName.equals(this.allResourcesGroupName)) {
    return new Status(StatusCode.NOTALLOWED,
        "All resource group cannot be removed");
  }
  resourceGroups.remove(groupName);
  Status result = removeRoleResourceGroupMapping(groupName);
  return result.isSuccess() ? result :
    new Status(StatusCode.SUCCESS, "Failed removing group from: " + result.getDescription());
}

代码示例来源:origin: org.opendaylight.controller/switchmanager.implementation

number++;
} else {
  log.warn("Failed to save subnet gateway configurations: " + status.getDescription());
  number++;
} else {
  log.warn("Failed to save span port configurations: " + status.getDescription());
  number++;
} else {
  log.warn("Failed to save node configurations: " + status.getDescription());

代码示例来源:origin: org.opendaylight.controller/usermanager.implementation

private Status addRemoveAuthInfo(AuthorizationConfig AAAconf, boolean delete) {
  Status configCheck = AAAconf.validate();
  if (!configCheck.isSuccess()) {
    String msg = "Invalid Authorization configuration: "
        + configCheck.getDescription();
    logger.warn(msg);
    return new Status(StatusCode.BADREQUEST, msg);
  }
  // Update configuration database
  if (delete) {
    authorizationConfList.remove(AAAconf.getUser());
  } else {
    authorizationConfList.put(AAAconf.getUser(), AAAconf);
  }
  return new Status(StatusCode.SUCCESS);
}

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

toBeRemoved -= 1;
} else {
  error = status.getDescription();

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

@Override
public void removeOutputPort(Node node, String flowName, List<NodeConnector> portList) {
  for (FlowEntryInstall index : this.nodeFlows.get(node)) {
    FlowEntryInstall flow = this.installedSwView.get(index);
    if (flow.getFlowName().equals(flowName)) {
      FlowEntry currentFlowEntry = flow.getOriginal();
      FlowEntry newFlowEntry = currentFlowEntry.clone();
      for (NodeConnector dstPort : portList) {
        Action action = new Output(dstPort);
        newFlowEntry.getFlow().removeAction(action);
      }
      Status status = modifyEntry(currentFlowEntry, newFlowEntry, false);
      if (status.isSuccess()) {
        log.trace("Ports {} removed from FlowEntry {}", portList, flowName);
      } else {
        log.warn("Failed to remove ports {} from Flow entry {}. The failure is: {}", portList,
            currentFlowEntry.toString(), status.getDescription());
      }
      return;
    }
  }
  log.warn("Failed to remove ports from Flow {} on Node {}: Entry Not Found", flowName, node);
}

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

@Override
public void addOutputPort(Node node, String flowName, List<NodeConnector> portList) {
  for (FlowEntryInstall flow : this.nodeFlows.get(node)) {
    if (flow.getFlowName().equals(flowName)) {
      FlowEntry currentFlowEntry = flow.getOriginal();
      FlowEntry newFlowEntry = currentFlowEntry.clone();
      for (NodeConnector dstPort : portList) {
        newFlowEntry.getFlow().addAction(new Output(dstPort));
      }
      Status error = modifyEntry(currentFlowEntry, newFlowEntry, false);
      if (error.isSuccess()) {
        log.trace("Ports {} added to FlowEntry {}", portList, flowName);
      } else {
        log.warn("Failed to add ports {} to Flow entry {}. The failure is: {}", portList,
            currentFlowEntry.toString(), error.getDescription());
      }
      return;
    }
  }
  log.warn("Failed to add ports to Flow {} on Node {}: Entry Not Found", flowName, node);
}

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

private void addStaticFlowsToSwitch(Node node) {
  for (ConcurrentMap.Entry<Integer, FlowConfig> entry : staticFlows.entrySet()) {
    FlowConfig config = entry.getValue();
    if (config.isPortGroupEnabled()) {
      continue;
    }
    if (config.getNode().equals(node)) {
      if (config.installInHw() && !config.getStatus().equals(StatusCode.SUCCESS.toString())) {
        Status status = this.installFlowEntryAsync(config.getFlowEntry());
        config.setStatus(status.getDescription());
      }
    }
  }
  // Update cluster cache
  refreshClusterStaticFlowsStatus(node);
}

代码示例来源:origin: org.opendaylight.snmp4sdn/snmp4sdn

return new Status(ret.getCode(), "MiscConfigServiceImpl: deleteARPEntry(): call deleteARPTableEntry() with node " + nodeID + " for arp_entry_ip " + ipAddress + " fails: " + ret.getDescription());

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

} else {
  log.warn("Failed to replace output port for flow {} on node {}. The failure is: {}", flowName, node,
      status.getDescription());

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

/**
 * Remove a flow entry that has been added previously First checks if the
 * entry is effectively present in the local database
 */
@SuppressWarnings("unused")
private Status removeEntry(Node node, String flowName) {
  FlowEntryInstall target = null;
  // Find in database
  for (FlowEntryInstall entry : installedSwView.values()) {
    if (entry.equalsByNodeAndName(node, flowName)) {
      target = entry;
      break;
    }
  }
  // If it is not there, stop any further processing
  if (target == null) {
    return new Status(StatusCode.SUCCESS, "Entry is not present");
  }
  // Remove from node
  Status status = programmer.removeFlow(target.getNode(), target.getInstall().getFlow());
  // Update DB
  if (status.isSuccess()) {
    updateSwViews(target, false);
  } else {
    // log the error
    log.trace("SDN Plugin failed to remove the flow: {}. The failure is: {}", target.getInstall(),
        status.getDescription());
  }
  return status;
}

代码示例来源:origin: org.opendaylight.vtn/manager.northbound

/**
 * Convert failure status returned by the VTN manager into web application
 * exception.
 *
 * @param status  Failure status.
 * @return  An exception.
 */
protected final WebApplicationException getException(Status status) {
  assert !status.isSuccess();
  StatusCode code = status.getCode();
  String desc = status.getDescription();
  if (code == StatusCode.BADREQUEST) {
    return new BadRequestException(desc);
  }
  if (code == StatusCode.CONFLICT) {
    return new ResourceConflictException(desc);
  }
  if (code == StatusCode.NOTACCEPTABLE) {
    return new NotAcceptableException(desc);
  }
  if (code == StatusCode.NOTFOUND) {
    throw new ResourceNotFoundException(desc);
  }
  String msg = RestMessages.INTERNALERROR + ": " + desc;
  return new InternalServerErrorException(msg);
}

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

private boolean installFlowsOnNodeConnectorUp(NodeConnector nodeConnector) {
  boolean updated = false;
  List<FlowConfig> flowConfigForNode = getStaticFlows(nodeConnector.getNode());
  for (FlowConfig flowConfig : flowConfigForNode) {
    if (doesFlowContainNodeConnector(flowConfig.getFlow(), nodeConnector)) {
      if (flowConfig.installInHw() && !flowConfig.getStatus().equals(StatusCode.SUCCESS.toString())) {
        Status status = this.installFlowEntryAsync(flowConfig.getFlowEntry());
        if (!status.isSuccess()) {
          flowConfig.setStatus(status.getDescription());
        } else {
          flowConfig.setStatus(StatusCode.SUCCESS.toString());
        }
        updated = true;
      }
    }
  }
  return updated;
}

代码示例来源:origin: org.opendaylight.snmp4sdn/snmp4sdn

ci.println();
ci.println("Fail: Delete VLAN (node:" + nodeId + "(ip: " + getNodeIP(nodeId) + ")" + ", vlanId:" + vlanId + ") on switch fail: " + status);
ci.println("  --> error code = " + status.getCode() + ": " + status.getDescription());
ci.println();

相关文章