当前位置: 首页>>代码示例>>Java>>正文


Java MatchType类代码示例

本文整理汇总了Java中com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType的典型用法代码示例。如果您正苦于以下问题:Java MatchType类的具体用法?Java MatchType怎么用?Java MatchType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MatchType类属于com.hp.oo.sdk.content.plugin.ActionMetadata包,在下文中一共展示了MatchType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeEmptyElements

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
@Action(name = "Remove Empty Elements",
        outputs = {
                @Output(OutputNames.RETURN_CODE),
                @Output(OutputNames.RETURN_RESULT)
        },
        responses = {
                @Response(text = ResponseNames.SUCCESS, field = OutputNames.RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = ResponseNames.FAILURE, field = OutputNames.RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> removeEmptyElements(@Param(value = Constants.InputNames.JSON_OBJECT, required = true) String json) {
    try {
        final String result = new JsonService().removeEmptyElementsJson(json);
        return OutputUtilities.getSuccessResultsMap(result);
    } catch (Exception ex) {
        return OutputUtilities.getFailureResultsMap(ex);
    }

}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:19,代码来源:RemoveEmptyElementAction.java

示例2: execute

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * This operation takes a reference to JSON (in the form of a string) and runs a specified JSON Path query on it.
 * It returns the results as a JSON Object.
 *
 * @param jsonObject The JSON in the form of a string.
 * @param jsonPath   The JSON Path query to run.
 * @return           A map which contains the resulted JSON from the given path.
 */
@Action(name = "JSON Path Query",
        outputs = {
                @Output(OutputNames.RETURN_RESULT),
                @Output(OutputNames.RETURN_CODE),
                @Output(OutputNames.EXCEPTION)
        },
        responses = {
                @Response(text = ResponseNames.SUCCESS, field = OutputNames.RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = ResponseNames.FAILURE, field = OutputNames.RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> execute(
        @Param(value = Constants.InputNames.JSON_OBJECT, required = true) String jsonObject,
        @Param(value = Constants.InputNames.JSON_PATH, required = true) String jsonPath) {
    try {
        final JsonNode jsonNode = JsonService.evaluateJsonPathQuery(jsonObject, jsonPath);
        if (!jsonNode.isNull()) {
            return OutputUtilities.getSuccessResultsMap(jsonNode.toString());
        }
        return OutputUtilities.getSuccessResultsMap(NULL_STRING);
    } catch (Exception exception) {
        return OutputUtilities.getFailureResultsMap(exception);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:32,代码来源:JsonPathQuery.java

示例3: applyXslTransformation

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * @param xmlDocument     The location of the XML document to transform. Can be a local file path, an HTTP URL,
 *                        or the actual xml to transform, as constant. This is optional as some stylesheets do not need
 *                        an XML document and can create output based on runtime parameters.
 * @param xslTemplate     The location of the XSL stylesheet to use. Can be a local file path,
 *                        an HTTP URL or the actual template as constant.
 * @param outputFile      The local file to write the output of the transformation. If an output file is not specified
 *                        the output of the transformation will be returned as returnResult.
 * @param parsingFeatures The list of XML parsing features separated by new line (CRLF).
 *                        The feature name - value must be separated by empty space.
 *                        Setting specific features this field could be used to avoid XML security issues like
 *                        "XML Entity Expansion injection" and "XML External Entity injection".
 *                        To avoid aforementioned security issues we strongly recommend to set this input to the following values:
 *                        http://apache.org/xml/features/disallow-doctype-decl true
 *                        http://xml.org/sax/features/external-general-entities false
 *                        http://xml.org/sax/features/external-parameter-entities false
 *                        When the "http://apache.org/xml/features/disallow-doctype-decl" feature is set to "true"
 *                        the parser will throw a FATAL ERROR if the incoming document contains a DOCTYPE declaration.
 *                        When the "http://xml.org/sax/features/external-general-entities" feature is set to "false"
 *                        the parser will not include external general entities.
 *                        When the "http://xml.org/sax/features/external-parameter-entities" feature is set to "false"
 *                        the parser will not include external parameter entities or the external DTD subset.
 *                        If any of the validations fails, the operation will fail with an error message describing the problem.
 *                        Default value:
 *                        http://apache.org/xml/features/disallow-doctype-decl true
 *                        http://xml.org/sax/features/external-general-entities false
 *                        http://xml.org/sax/features/external-parameter-entities false
 * @return The output of the transformation, if no output file is specified.
 */
@Action(name = "Apply XSL Transformation",
        outputs = {
                @Output(RETURN_CODE),
                @Output(RETURN_RESULT),
                @Output(EXCEPTION)
        },
        responses = {
                @Response(text = ResponseNames.SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                @Response(text = ResponseNames.FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, isDefault = true, isOnFail = true)
        })
public Map<String, String> applyXslTransformation(
        @Param(value = XML_DOCUMENT) String xmlDocument,
        @Param(value = XSL_TEMPLATE, required = true) String xslTemplate,
        @Param(value = Constants.Inputs.OUTPUT_FILE) String outputFile,
        @Param(value = Constants.Inputs.FEATURES) String parsingFeatures) {

    try {
        final ApplyXslTransformationInputs applyXslTransformationInputs = new ApplyXslTransformationInputs.ApplyXslTransformationInputsBuilder()
                .withXmlDocument(xmlDocument)
                .withXslTemplate(xslTemplate)
                .withOutputFile(outputFile)
                .withParsingFeatures(parsingFeatures)
                .build();

        return new ApplyXslTransformationService().execute(applyXslTransformationInputs);
    } catch (Exception e) {
        return OutputUtilities.getFailureResultsMap(e);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:59,代码来源:ApplyXslTransformation.java

示例4: sortList

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * This method sorts a list of strings. If the list contains only numerical strings, it is sorted in numerical order.
 * Otherwise it is sorted alphabetically.
 *
 * @param list      The list to be sorted.
 * @param delimiter The list delimiter.
 * @param reverse   A boolean value for sorting the list in reverse order.
 * @return The sorted list.
 */
@Action(name = "List Sort",
        outputs = {
                @Output(RESULT_TEXT),
                @Output(RESPONSE),
                @Output(RETURN_RESULT),
                @Output(RETURN_CODE)
        },
        responses = {
                @Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)
        })
public Map<String, String> sortList(@Param(value = LIST, required = true) String list,
                                    @Param(value = DELIMITER, required = true) String delimiter,
                                    @Param(value = REVERSE) String reverse) {

    Map<String, String> result = new HashMap<>();
    try {
        String sortedList = sort(list, Boolean.parseBoolean(reverse), delimiter);
        result.put(RESULT_TEXT, sortedList);
        result.put(RESPONSE, SUCCESS);
        result.put(RETURN_RESULT, sortedList);
        result.put(RETURN_CODE, RETURN_CODE_SUCCESS);
    } catch (Exception e) {
        result.put(RESULT_TEXT, e.getMessage());
        result.put(RESPONSE, FAILURE);
        result.put(RETURN_RESULT, e.getMessage());
        result.put(RETURN_CODE, RETURN_CODE_FAILURE);
    }
    return result;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:40,代码来源:ListSortAction.java

示例5: appendElement

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * This method appends an element to a list of strings.
 *
 * @param list      The list to append to.
 * @param element   The element to add to the list.
 * @param delimiter The list delimiter. Delimiter can be empty string.
 * @return The new list.
 */
@Action(name = "List Appender",
        outputs = {
                @Output(RESPONSE),
                @Output(RETURN_RESULT),
                @Output(RETURN_CODE)
        },
        responses = {
                @Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)
        })
public Map<String, String> appendElement(@Param(value = LIST, required = true) String list,
                                         @Param(value = ELEMENT, required = true) String element,
                                         @Param(value = DELIMITER) String delimiter) {
    Map<String, String> result = new HashMap<>();
    try {
        StringBuilder sb = new StringBuilder();
        sb = StringUtils.isEmpty(list) ? sb.append(element) : sb.append(list).append(delimiter).append(element);
        result.put(RESPONSE, SUCCESS);
        result.put(RETURN_RESULT, sb.toString());
        result.put(RETURN_CODE, RETURN_CODE_SUCCESS);
    } catch (Exception e) {
        result.put(RESPONSE, FAILURE);
        result.put(RETURN_RESULT, e.getMessage());
        result.put(RETURN_CODE, RETURN_CODE_FAILURE);
    }
    return result;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:36,代码来源:ListAppenderAction.java

示例6: prependElement

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * This method pre-pends an element to a list of strings.
 *
 * @param list      The list to pre-pend to.
 * @param element   The element to pre-pend to the list.
 * @param delimiter The list delimiter. Delimiter can be empty string.
 * @return The new list.
 */
@Action(name = "List Prepender",
        outputs = {
                @Output(RESPONSE),
                @Output(RETURN_RESULT),
                @Output(RETURN_CODE)
        },
        responses = {
                @Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)
        })
public Map<String, String> prependElement(@Param(value = LIST, required = true) String list,
                                          @Param(value = ELEMENT, required = true) String element,
                                          @Param(value = DELIMITER) String delimiter) {
    Map<String, String> result = new HashMap<>();
    try {
        StringBuilder sb = new StringBuilder();
        sb = StringUtils.isEmpty(list) ? sb.append(element) : sb.append(element).append(delimiter).append(list);
        result.put(RESPONSE, SUCCESS);
        result.put(RETURN_RESULT, sb.toString());
        result.put(RETURN_CODE, RETURN_CODE_SUCCESS);
    } catch (Exception e) {
        result.put(RESPONSE, FAILURE);
        result.put(RETURN_RESULT, e.getMessage());
        result.put(RETURN_CODE, RETURN_CODE_FAILURE);
    }
    return result;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:36,代码来源:ListPrependerAction.java

示例7: removeElement

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * This method removes an element from a list of strings.
 *
 * @param list      The list to remove from.
 * @param index     The index of the element to remove from the list.
 * @param delimiter The list delimiter.
 * @return The new list.
 */
@Action(name = "List Remover",
        outputs = {
                @Output(RESPONSE),
                @Output(RETURN_RESULT),
                @Output(RETURN_CODE)
        },
        responses = {
                @Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)
        })
public Map<String, String> removeElement(@Param(value = LIST, required = true) String list,
                                         @Param(value = ELEMENT, required = true) String index,
                                         @Param(value = DELIMITER, required = true) String delimiter) {
    Map<String, String> result = new HashMap<>();
    try {
        if (StringUtils.isEmpty(list) || StringUtils.isEmpty(index) || StringUtils.isEmpty(delimiter)) {
            throw new RuntimeException(EMPTY_INPUT_EXCEPTION);
        } else {
            String[] elements = StringUtils.split(list, delimiter);
            elements = ArrayUtils.remove(elements, Integer.parseInt(index));
            result.put(RESPONSE, SUCCESS);
            result.put(RETURN_RESULT, StringUtils.join(elements, delimiter));
            result.put(RETURN_CODE, RETURN_CODE_SUCCESS);
        }
    } catch (Exception e) {
        result.put(RESPONSE, FAILURE);
        result.put(RETURN_RESULT, e.getMessage());
        result.put(RETURN_CODE, RETURN_CODE_FAILURE);
    }
    return result;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:40,代码来源:ListRemoverAction.java

示例8: getListSize

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * This method returns the length of a list of strings.
 *
 * @param list      The list to be processed.
 * @param delimiter The list delimiter.
 * @return The length of the list.
 */
@Action(name = "List Size",
        outputs = {
                @Output(RESULT_TEXT),
                @Output(RESPONSE),
                @Output(RETURN_RESULT),
                @Output(RETURN_CODE)
        },
        responses = {
                @Response(text = Constants.ResponseNames.SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                @Response(text = Constants.ResponseNames.FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)
        })
public Map<String, String> getListSize(@Param(value = LIST, required = true) String list,
                                       @Param(value = DELIMITER, required = true) String delimiter) {
    Map<String, String> result = new HashMap<>();
    try {
        String[] table = ListProcessor.toArray(list, delimiter);
        result.put(RESULT_TEXT, String.valueOf(table.length));
        result.put(RESPONSE, Constants.ResponseNames.SUCCESS);
        result.put(RETURN_RESULT, String.valueOf(table.length));
        result.put(RETURN_CODE, RETURN_CODE_SUCCESS);
    } catch (Exception e) {
        result.put(RESULT_TEXT, e.getMessage());
        result.put(RESPONSE, Constants.ResponseNames.FAILURE);
        result.put(RETURN_RESULT, e.getMessage());
        result.put(RETURN_CODE, RETURN_CODE_FAILURE);
    }
    return result;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:36,代码来源:ListSizeAction.java

示例9: copyTo

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * Executes a Shell command(s) on the remote machine using the SSH protocol.
 *
 * @param sourceHost The hostname or ip address of the source remote machine.
 * @param sourcePath The path to the file that needs to be copied from the source remote machine.
 * @param sourcePort The port number for running the command on the source remote machine.
 * @param sourceUsername The username of the account on the source remote machine.
 * @param sourcePassword The password of the user for the source remote machine.
 * @param sourcePrivateKeyFile The path to the private key file (OpenSSH type) on the source machine.
 * @param destinationHost The hostname or ip address of the destination remote machine.
 * @param destinationPath The path to the location where the file will be copied on the destination remote machine.
 * @param destinationPort The port number for running the command on the destination remote machine.
 * @param destinationUsername The username of the account on the destination remote machine.
 * @param destinationPassword The password of the user for the destination remote machine.
 * @param destinationPrivateKeyFile The path to the private key file (OpenSSH type) on the destination machine.
 * @param knownHostsPolicy The policy used for managing known_hosts file. Valid values: allow, strict, add. Default value: strict
 * @param knownHostsPath The path to the known hosts file.
 * @param timeout Time in milliseconds to wait for the command to complete. Default value is 90000 (90 seconds)
 * @param proxyHost The HTTP proxy host
 * @param proxyPort The HTTP proxy port
 *
 * @return - a map containing the output of the operation. Keys present in the map are:
 *     <br><b>returnResult</b> - The primary output.
 *     <br><b>returnCode</b> - the return code of the operation. 0 if the operation goes to success, -1 if the operation goes to failure.
 *     <br><b>exception</b> - the exception message if the operation goes to failure.
 *
 */

@Action(name = "Remote Secure Copy",
        outputs = {
                @Output(Constants.OutputNames.RETURN_CODE),
                @Output(Constants.OutputNames.RETURN_RESULT),
                @Output(Constants.OutputNames.EXCEPTION)
        },
        responses = {
                @Response(text = Constants.ResponseNames.SUCCESS, field = Constants.OutputNames.RETURN_CODE, value = Constants.ReturnCodes.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = Constants.ResponseNames.FAILURE, field = Constants.OutputNames.RETURN_CODE, value = Constants.ReturnCodes.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        }
)
public Map<String, String> copyTo(
        @Param(value = Constants.InputNames.SOURCE_HOST) String sourceHost,
        @Param(value = Constants.InputNames.SOURCE_PATH, required = true) String sourcePath,
        @Param(Constants.InputNames.SOURCE_PORT) String sourcePort,
        @Param(Constants.InputNames.SOURCE_USERNAME) String sourceUsername,
        @Param(value = Constants.InputNames.SOURCE_PASSWORD, encrypted = true) String sourcePassword,
        @Param(Constants.InputNames.SOURCE_PRIVATE_KEY_FILE) String sourcePrivateKeyFile,
        @Param(value = Constants.InputNames.DESTINATION_HOST, required = true) String destinationHost,
        @Param(value = Constants.InputNames.DESTINATION_PATH, required = true) String destinationPath,
        @Param(Constants.InputNames.DESTINATION_PORT) String destinationPort,
        @Param(value = Constants.InputNames.DESTINATION_USERNAME, required = true) String destinationUsername,
        @Param(value = Constants.InputNames.DESTINATION_PASSWORD, encrypted = true) String destinationPassword,
        @Param(Constants.InputNames.DESTINATION_PRIVATE_KEY_FILE) String destinationPrivateKeyFile,
        @Param(Constants.InputNames.KNOWN_HOSTS_POLICY) String knownHostsPolicy,
        @Param(Constants.InputNames.KNOWN_HOSTS_PATH) String knownHostsPath,
        @Param(Constants.InputNames.TIMEOUT) String timeout,
        @Param(Constants.InputNames.PROXY_HOST) String proxyHost,
        @Param(Constants.InputNames.PROXY_PORT) String proxyPort) {

    RemoteSecureCopyInputs remoteSecureCopyInputs = new RemoteSecureCopyInputs(sourcePath, destinationHost, destinationPath, destinationUsername);
    remoteSecureCopyInputs.setSrcHost(sourceHost);
    remoteSecureCopyInputs.setSrcPort(sourcePort);
    remoteSecureCopyInputs.setSrcPrivateKeyFile(sourcePrivateKeyFile);
    remoteSecureCopyInputs.setSrcUsername(sourceUsername);
    remoteSecureCopyInputs.setSrcPassword(sourcePassword);
    remoteSecureCopyInputs.setDestPort(destinationPort);
    remoteSecureCopyInputs.setDestPrivateKeyFile(destinationPrivateKeyFile);
    remoteSecureCopyInputs.setDestPassword(destinationPassword);
    remoteSecureCopyInputs.setKnownHostsPolicy(knownHostsPolicy);
    remoteSecureCopyInputs.setKnownHostsPath(knownHostsPath);
    remoteSecureCopyInputs.setTimeout(timeout);
    remoteSecureCopyInputs.setProxyHost(proxyHost);
    remoteSecureCopyInputs.setProxyPort(proxyPort);

    return new RemoteSecureCopyService().execute(remoteSecureCopyInputs);

}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:77,代码来源:RemoteSecureCopyAction.java

示例10: listVMsAndTemplates

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * Connects to a specified data center and to retrieve retrieve a list with all the virtual machines and templates
 * within.
 *
 * @param host          VMware host or IP - Example: "vc6.subdomain.example.com"
 * @param port          optional - the port to connect through - Examples: "443", "80" - Default: "443"
 * @param protocol      optional - the connection protocol - Valid: "http", "https" - Default: "https"
 * @param username      the VMware username use to connect
 * @param password      the password associated with "username" input
 * @param trustEveryone optional - if "true" will allow connections from any host, if "false" the connection will
 *                      be allowed only using a valid vCenter certificate - Default: "true"
 *                      Check the: https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_java_development.4.3.html
 *                      to see how to import a certificate into Java Keystore and
 *                      https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_sg_server_certificate_Appendix.6.4.html
 *                      to see how to obtain a valid vCenter certificate
 * @param closeSession  Whether to use the flow session context to cache the Connection to the host or not. If set to
 *                      "false" it will close and remove any connection from the session context, otherwise the Connection
 *                      will be kept alive and not removed.
 *                      Valid values: "true", "false"
 *                      Default value: "true"
 * @param delimiter     the delimiter that will be used in response list - Default: ","
 * @return resultMap with String as key and value that contains returnCode of the operation, a list that contains
 * all the virtual machines and templates within the data center  or failure message and the exception if there is
 * one
 */
@Action(name = "List VMs and Templates",
        outputs = {
                @Output(Outputs.RETURN_CODE),
                @Output(Outputs.RETURN_RESULT),
                @Output(Outputs.EXCEPTION)
        },
        responses = {
                @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> listVMsAndTemplates(@Param(value = HOST, required = true) String host,
                                               @Param(value = PORT) String port,
                                               @Param(value = PROTOCOL) String protocol,
                                               @Param(value = USERNAME, required = true) String username,
                                               @Param(value = PASSWORD, encrypted = true) String password,
                                               @Param(value = TRUST_EVERYONE) String trustEveryone,
                                               @Param(value = CLOSE_SESSION) String closeSession,

                                               @Param(value = DELIMITER) String delimiter,
                                               @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) {
    try {
        final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder()
                .withHost(host)
                .withPort(port)
                .withProtocol(protocol)
                .withUsername(username)
                .withPassword(password)
                .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE))
                .withCloseSession(defaultIfEmpty(closeSession, TRUE))
                .withGlobalSessionObject(globalSessionObject)
                .build();

        final VmInputs vmInputs = new VmInputs.VmInputsBuilder().build();

        return new VmService().listVMsAndTemplates(httpInputs, vmInputs, delimiter);
    } catch (Exception ex) {
        return getFailureResultsMap(ex);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:67,代码来源:ListVMsAndTemplates.java

示例11: deleteVM

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * Connects to a specified data center and deletes a virtual machine identified by the inputs provided.
 *
 * @param host               VMware host or IP - Example: "vc6.subdomain.example.com"
 * @param port               optional - the port to connect through - Examples: "443", "80" - Default: "443"
 * @param protocol           optional - the connection protocol - Valid: "http", "https" - Default: "https"
 * @param username           the VMware username use to connect
 * @param password           the password associated with "username" input
 * @param trustEveryone      optional - if "true" will allow connections from any host, if "false" the connection will
 *                           be allowed only using a valid vCenter certificate - Default: "true"
 *                           Check the: https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_java_development.4.3.html
 *                           to see how to import a certificate into Java Keystore and
 *                           https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_sg_server_certificate_Appendix.6.4.html
 *                           to see how to obtain a valid vCenter certificate
 * @param closeSession       Whether to use the flow session context to cache the Connection to the host or not. If set to
 *                           "false" it will close and remove any connection from the session context, otherwise the Connection
 *                           will be kept alive and not removed.
 *                           Valid values: "true", "false"
 *                           Default value: "true"
 * @param virtualMachineName the name of the virtual machine that will be deleted
 * @return resultMap with String as key and value that contains returnCode of the operation, success message with
 * task id of the execution or failure message and the exception if there is one
 */
@Action(name = "Delete Virtual Machine",
        outputs = {
                @Output(Outputs.RETURN_CODE),
                @Output(Outputs.RETURN_RESULT),
                @Output(Outputs.EXCEPTION)
        },
        responses = {
                @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> deleteVM(@Param(value = HOST, required = true) String host,
                                    @Param(value = PORT) String port,
                                    @Param(value = PROTOCOL) String protocol,
                                    @Param(value = USERNAME, required = true) String username,
                                    @Param(value = PASSWORD, encrypted = true) String password,
                                    @Param(value = TRUST_EVERYONE) String trustEveryone,
                                    @Param(value = CLOSE_SESSION) String closeSession,

                                    @Param(value = VM_NAME, required = true) String virtualMachineName,
                                    @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) {

    try {
        final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder()
                .withHost(host)
                .withPort(port)
                .withProtocol(protocol)
                .withUsername(username)
                .withPassword(password)
                .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE))
                .withCloseSession(defaultIfEmpty(closeSession, TRUE))
                .withGlobalSessionObject(globalSessionObject)
                .build();

        final VmInputs vmInputs = new VmInputs.VmInputsBuilder()
                .withVirtualMachineName(virtualMachineName)
                .build();

        return new VmService().deleteVM(httpInputs, vmInputs);
    } catch (Exception ex) {
        return OutputUtilities.getFailureResultsMap(ex);
    }

}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:69,代码来源:DeleteVM.java

示例12: getOsDescriptors

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * Connects to a data center to retrieve a list with all the guest operating system descriptors supported by the
 * host system.
 *
 * @param host           VMware host or IP - Example: "vc6.subdomain.example.com"
 * @param port           optional - the port to connect through - Examples: "443", "80" - Default: "443"
 * @param protocol       optional - the connection protocol - Valid: "http", "https" - Default: "https"
 * @param username       the VMware username use to connect
 * @param password       the password associated with "username" input
 * @param trustEveryone  optional - if "true" will allow connections from any host, if "false" the connection will be
 *                       allowed only using a valid vCenter certificate - Default: "true"
 *                       Check the: https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_java_development.4.3.html
 *                       to see how to import a certificate into Java Keystore and
 *                       https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_sg_server_certificate_Appendix.6.4.html
 *                       to see how to obtain a valid vCenter certificate
 * @param closeSession   Whether to use the flow session context to cache the Connection to the host or not. If set to
 *                       "false" it will close and remove any connection from the session context, otherwise the Connection
 *                       will be kept alive and not removed.
 *                       Valid values: "true", "false"
 *                       Default value: "true"
 * @param dataCenterName the data center name where the host system is - Example: 'DataCenter2'
 * @param hostname       the name of the target host to be queried to retrieve the supported guest OSes
 *                       - Example: 'host123.subdomain.example.com'
 * @param delimiter      the delimiter that will be used in response list - Default: ","
 * @return resultMap with String as key and value that contains returnCode of the operation, a list that contains all the
 * guest operating system descriptors supported by the host system or failure message and the exception if there is one
 */
@Action(name = "Get OS Descriptors",
        outputs = {
                @Output(Outputs.RETURN_CODE),
                @Output(Outputs.RETURN_RESULT),
                @Output(Outputs.EXCEPTION)
        },
        responses = {
                @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> getOsDescriptors(@Param(value = HOST, required = true) String host,
                                            @Param(value = PORT) String port,
                                            @Param(value = PROTOCOL) String protocol,
                                            @Param(value = USERNAME, required = true) String username,
                                            @Param(value = PASSWORD, encrypted = true) String password,
                                            @Param(value = TRUST_EVERYONE) String trustEveryone,
                                            @Param(value = CLOSE_SESSION) String closeSession,

                                            @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName,
                                            @Param(value = HOSTNAME, required = true) String hostname,

                                            @Param(value = DELIMITER) String delimiter,
                                            @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) {

    try {
        final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder()
                .withHost(host)
                .withPort(port)
                .withProtocol(protocol)
                .withUsername(username)
                .withPassword(password)
                .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE))
                .withCloseSession(defaultIfEmpty(closeSession, TRUE))
                .withGlobalSessionObject(globalSessionObject)
                .build();

        final VmInputs vmInputs = new VmInputs.VmInputsBuilder()
                .withDataCenterName(dataCenterName)
                .withHostname(hostname)
                .build();

        return new VmService().getOsDescriptors(httpInputs, vmInputs, delimiter);
    } catch (Exception ex) {
        return OutputUtilities.getFailureResultsMap(ex);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:76,代码来源:GetOSDescriptors.java

示例13: powerOffVM

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * Connects to a specified data center and powers off the virtual machine identified by the inputs provided.
 *
 * @param host               VMware host or IP - Example: "vc6.subdomain.example.com"
 * @param port               optional - the port to connect through - Examples: "443", "80" - Default: "443"
 * @param protocol           optional - the connection protocol - Valid: "http", "https" - Default: "https"
 * @param username           the VMware username use to connect
 * @param password           the password associated with "username" input
 * @param trustEveryone      optional - if "true" will allow connections from any host, if "false" the connection will
 *                           be allowed only using a valid vCenter certificate - Default: "true"
 *                           Check the: https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_java_development.4.3.html
 *                           to see how to import a certificate into Java Keystore and
 *                           https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_sg_server_certificate_Appendix.6.4.html
 *                           to see how to obtain a valid vCenter certificate
 * @param closeSession       Whether to use the flow session context to cache the Connection to the host or not. If set to
 *                           "false" it will close and remove any connection from the session context, otherwise the Connection
 *                           will be kept alive and not removed.
 *                           Valid values: "true", "false"
 *                           Default value: "true"
 * @param virtualMachineName the name of the virtual machine that will be powered off
 * @return resultMap with String as key and value that contains returnCode of the operation, success message with
 * task id of the execution or failure message and the exception if there is one
 */
@Action(name = "Power Off Virtual Machine",
        outputs = {
                @Output(Outputs.RETURN_CODE),
                @Output(Outputs.RETURN_RESULT),
                @Output(Outputs.EXCEPTION)
        },
        responses = {
                @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> powerOffVM(@Param(value = HOST, required = true) String host,
                                      @Param(value = PORT) String port,
                                      @Param(value = PROTOCOL) String protocol,
                                      @Param(value = USERNAME, required = true) String username,
                                      @Param(value = PASSWORD, encrypted = true) String password,
                                      @Param(value = TRUST_EVERYONE) String trustEveryone,
                                      @Param(value = CLOSE_SESSION) String closeSession,

                                      @Param(value = VM_NAME, required = true) String virtualMachineName,
                                      @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) {

    try {
        final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder()
                .withHost(host)
                .withPort(port)
                .withProtocol(protocol)
                .withUsername(username)
                .withPassword(password)
                .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE))
                .withCloseSession(defaultIfEmpty(closeSession, TRUE))
                .withGlobalSessionObject(globalSessionObject)
                .build();

        final VmInputs vmInputs = new VmInputs.VmInputsBuilder()
                .withVirtualMachineName(virtualMachineName)
                .build();

        return new VmService().powerOffVM(httpInputs, vmInputs);
    } catch (Exception ex) {
        return OutputUtilities.getFailureResultsMap(ex);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:68,代码来源:PowerOffVM.java

示例14: powerOnVM

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * Connects to a specified data center and powers on the virtual machine identified by the inputs provided.
 *
 * @param host               VMware host or IP - Example: "vc6.subdomain.example.com"
 * @param port               optional - the port to connect through - Examples: "443", "80" - Default: "443"
 * @param protocol           optional - the connection protocol - Valid: "http", "https" - Default: "https"
 * @param username           the VMware username use to connect
 * @param password           the password associated with "username" input
 * @param trustEveryone      optional - if "true" will allow connections from any host, if "false" the connection will
 *                           be allowed only using a valid vCenter certificate - Default: "true"
 *                           Check the: https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_java_development.4.3.html
 *                           to see how to import a certificate into Java Keystore and
 *                           https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_sg_server_certificate_Appendix.6.4.html
 *                           to see how to obtain a valid vCenter certificate
 * @param closeSession       Whether to use the flow session context to cache the Connection to the host or not. If set to
 *                           "false" it will close and remove any connection from the session context, otherwise the Connection
 *                           will be kept alive and not removed.
 *                           Valid values: "true", "false"
 *                           Default value: "true"
 * @param virtualMachineName the name of the virtual machine that will be powered on
 * @return resultMap with String as key and value that contains returnCode of the operation, success message with
 * task id of the execution or failure message and the exception if there is one
 */
@Action(name = "Power On Virtual Machine",
        outputs = {
                @Output(Outputs.RETURN_CODE),
                @Output(Outputs.RETURN_RESULT),
                @Output(Outputs.EXCEPTION)
        },
        responses = {
                @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> powerOnVM(@Param(value = HOST, required = true) String host,
                                     @Param(value = PORT) String port,
                                     @Param(value = PROTOCOL) String protocol,
                                     @Param(value = USERNAME, required = true) String username,
                                     @Param(value = PASSWORD, encrypted = true) String password,
                                     @Param(value = TRUST_EVERYONE) String trustEveryone,
                                     @Param(value = CLOSE_SESSION) String closeSession,

                                     @Param(value = VM_NAME, required = true) String virtualMachineName,
                                     @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) {

    try {
        final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder()
                .withHost(host)
                .withPort(port)
                .withProtocol(protocol)
                .withUsername(username)
                .withPassword(password)
                .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE))
                .withCloseSession(defaultIfEmpty(closeSession, TRUE))
                .withGlobalSessionObject(globalSessionObject)
                .build();

        final VmInputs vmInputs = new VmInputs.VmInputsBuilder()
                .withVirtualMachineName(virtualMachineName)
                .build();

        return new VmService().powerOnVM(httpInputs, vmInputs);
    } catch (Exception ex) {
        return OutputUtilities.getFailureResultsMap(ex);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:68,代码来源:PowerOnVM.java

示例15: getVMDetails

import com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType; //导入依赖的package包/类
/**
 * Connects to a specified data center and to retrieve details of a virtual machine identified by the inputs provided.
 *
 * @param host               VMware host or IP - Example: "vc6.subdomain.example.com"
 * @param port               optional - the port to connect through - Examples: "443", "80" - Default: "443"
 * @param protocol           optional - the connection protocol - Valid: "http", "https" - Default: "https"
 * @param username           the VMware username use to connect
 * @param password           the password associated with "username" input
 * @param trustEveryone      optional - if "true" will allow connections from any host, if "false" the connection will
 *                           be allowed only using a valid vCenter certificate - Default: "true"
 *                           Check the: https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_java_development.4.3.html
 *                           to see how to import a certificate into Java Keystore and
 *                           https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.dsg.doc_50%2Fsdk_sg_server_certificate_Appendix.6.4.html
 *                           to see how to obtain a valid vCenter certificate
 * @param closeSession       Whether to use the flow session context to cache the Connection to the host or not. If set to
 *                           "false" it will close and remove any connection from the session context, otherwise the Connection
 *                           will be kept alive and not removed.
 *                           Valid values: "true", "false"
 *                           Default value: "true"
 * @param virtualMachineName the name of the targeted virtual machine to retrieve the details for
 * @return resultMap with String as key and value that contains returnCode of the operation, a JSON formatted string
 * that contains details of the virtual machine or failure message and the exception if there is one
 */
@Action(name = "Get VM Details",
        outputs = {
                @Output(Outputs.RETURN_CODE),
                @Output(Outputs.RETURN_RESULT),
                @Output(Outputs.EXCEPTION)
        },
        responses = {
                @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE,
                        matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true)
        })
public Map<String, String> getVMDetails(@Param(value = HOST, required = true) String host,
                                        @Param(value = PORT) String port,
                                        @Param(value = PROTOCOL) String protocol,
                                        @Param(value = USERNAME, required = true) String username,
                                        @Param(value = PASSWORD, encrypted = true) String password,
                                        @Param(value = TRUST_EVERYONE) String trustEveryone,
                                        @Param(value = CLOSE_SESSION) String closeSession,

                                        @Param(value = HOSTNAME, required = true) String hostname,
                                        @Param(value = VM_NAME, required = true) String virtualMachineName,
                                        @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) {


    try {
        final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder()
                .withHost(host)
                .withPort(port)
                .withProtocol(protocol)
                .withUsername(username)
                .withPassword(password)
                .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE))
                .withCloseSession(defaultIfEmpty(closeSession, TRUE))
                .withGlobalSessionObject(globalSessionObject)
                .build();

        final VmInputs vmInputs = new VmInputs.VmInputsBuilder()
                .withHostname(hostname)
                .withVirtualMachineName(virtualMachineName)
                .build();

        return new VmService().getVMDetails(httpInputs, vmInputs);
    } catch (Exception ex) {
        return OutputUtilities.getFailureResultsMap(ex);
    }
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:71,代码来源:GetVMDetails.java


注:本文中的com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。