public static OperationDefinition getOperationDefinition(ResourceType type, String operationName) { for (OperationDefinition operationDefinition : type.getOperationDefinitions()) { if (operationDefinition.getName().equals(operationName)) { return operationDefinition; } } return null; }
/** * Returns the operation definition for the operation with the specified name on the * {@link org.rhq.core.domain.resource.Resource} with the specified id. * * @param resourceId a <code>Resource</code> id * @param operationName an operation name * * @return the operation definition for the operation with the specified name on the <code>Resource</code> with the * specified id * * @throws PluginContainerException if the resource type could not be determined for the specified <code> * Resource</code> id */ @Nullable private OperationDefinition getOperationDefinition(int resourceId, String operationName) throws PluginContainerException { ResourceType resourceType = getResourceType(resourceId); Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions(); if (operationDefinitions != null) { for (OperationDefinition operationDefinition : operationDefinitions) { if (operationDefinition.getName().equals(operationName)) { return operationDefinition; } } } return null; }
/** * Return the parameter definition for the operation with the name passed * @param operationName Name of the operation to look for * @return A configuration definition or null on failure */ ConfigurationDefinition getParameterDefinitionsForOperation(String operationName) { ResourceType type = context.getResourceType(); Set<OperationDefinition> operationDefinitions = type.getOperationDefinitions(); for (OperationDefinition definition : operationDefinitions) { if (definition.getName().equals(operationName)) { return definition.getParametersConfigurationDefinition(); } } return null; }
private static void addRepresentation(OperationDefinition od, StringBuilder bld) { bld.append(od.getName()); addRepresentation(od.getResultsConfigurationDefinition(), bld); addRepresentation(od.getParametersConfigurationDefinition(), bld); }
private OperationDefinition validateOperationNameAndParameters(ResourceType resourceType, String operationName, Configuration parameters) { Set<OperationDefinition> operationDefinitions = resourceType.getOperationDefinitions(); OperationDefinition matchingOperationDefinition = null; for (OperationDefinition operationDefinition : operationDefinitions) { if (operationDefinition.getName().equals(operationName)) { matchingOperationDefinition = operationDefinition; break; } } if (matchingOperationDefinition == null) { throw new IllegalArgumentException("[" + operationName + "] is not a valid operation name for Resources of type [" + resourceType.getName() + "]."); } ConfigurationDefinition parametersDefinition = matchingOperationDefinition .getParametersConfigurationDefinition(); List<String> errors = ConfigurationUtility.validateConfiguration(parameters, parametersDefinition); if (!errors.isEmpty()) { throw new IllegalArgumentException("Parameters for [" + operationName + "] on Resource of type [" + resourceType.getName() + "] are not valid: " + errors); } return matchingOperationDefinition; }
if (resourceType.getOperationDefinitions() != null) { for (OperationDefinition def : resourceType.getOperationDefinitions()) { exportWriter.printf("%s <operation>%s</operation>\n", indent, def.getName());
if (resourceOperationHistory.getOperationDefinition().getName().equals("announce")) { try { storageNodeOperationsHandler.handleAnnounce(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("prepareForBootstrap")) { try { storageNodeOperationsHandler.handlePrepareForBootstrap(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("addNodeMaintenance")) { try { storageNodeOperationsHandler.handleAddNodeMaintenance(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("decommission")) { try { storageNodeOperationsHandler.handleDecommission(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("removeNodeMaintenance")) { try { storageNodeOperationsHandler.handleRemoveNodeMaintenance(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("unannounce")) { try { storageNodeOperationsHandler.handleUnannounce(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("uninstall")) { try { storageNodeOperationsHandler.handleUninstall(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("repair")) {
Set<OperationDefinition> opDefs = rt.getOperationDefinitions(); for (OperationDefinition def : opDefs) { System.out.println(def.getName() + " : " + def.getDescription()); ConfigurationDefinition params = def.getParametersConfigurationDefinition(); if (params != null && params.getPropertyDefinitions() != null
odr.setName(def.getName());
OperationDefinitionRest odr = new OperationDefinitionRest(); odr.setId(def.getId()); odr.setName(def.getName());
operationRest.setId((int)System.currentTimeMillis()); // TODO better id (?)(we need one for pUT later on) operationRest.setReadyToSubmit(false); operationRest.setName(opDef.getName()); ConfigurationDefinition paramDefinition = opDef.getParametersConfigurationDefinition(); if (paramDefinition != null) {
log.error("Plugin error: Operation [" + this.operationDefinition.getName() + "] is defined as returning no results, but it returned non-null results: " + result.toString(true));
hist.setResourceName(history.getResource().getName()); hist.setOperationName(history.getOperationDefinition().getName()); hist.lastModified(history.getModifiedTime()); if (history.getErrorMessage()!=null) {
resourceId, definition.getName(), 0, 0, 0, 30000, parameters, "Executed from commandline");