/** * 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(); }
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; }
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; }
@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"); } }
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); }
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); }
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); } }
@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()); }
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());
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); }
toBeRemoved -= 1; } else { error = status.getDescription();
@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); }
@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); }
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); }
return new Status(ret.getCode(), "MiscConfigServiceImpl: deleteARPEntry(): call deleteARPTableEntry() with node " + nodeID + " for arp_entry_ip " + ipAddress + " fails: " + ret.getDescription());
} else { log.warn("Failed to replace output port for flow {} on node {}. The failure is: {}", flowName, node, status.getDescription());
/** * 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; }
/** * 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); }
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; }
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();