use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class GetVMDetails method execute.
@Action(name = GET_VM_DETAILS_OPERATION_NAME, description = GET_VM_DETAILS_OPERATION_DESC, outputs = { @Output(value = RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = EXCEPTION, description = EXCEPTION_DESC), @Output(value = STATUS_CODE, description = STATUS_CODE_DESC), @Output(value = VM_NAME, description = VM_NAME_DESC), @Output(value = IP_ADDRESS, description = IP_ADDRESS_DESC), @Output(value = MAC_ADDRESS, description = MAC_ADDRESS_DESC), @Output(value = POWER_STATE, description = POWER_STATE_DESC), @Output(value = VM_DISK_UUID, description = VM_DISK_UUID_DESC), @Output(value = STORAGE_CONTAINER_UUID, description = STORAGE_CONTAINER_UUID_DESC), @Output(value = VM_LOGICAL_TIMESTAMP, description = VM_LOGICAL_TIMESTAMP_DESC), @Output(value = HOST_UUIDS, description = HOST_UUIDS_DESC) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = COMPARE_EQUAL, responseType = RESOLVED, description = SUCCESS_DESC), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = COMPARE_EQUAL, responseType = ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = HOSTNAME, required = true, description = HOSTNAME_DESC) String hostname, @Param(value = PORT, description = PORT_DESC) String port, @Param(value = USERNAME, required = true, description = USERNAME_DESC) String username, @Param(value = PASSWORD, encrypted = true, required = true, description = PASSWORD_DESC) String password, @Param(value = VM_UUID, required = true, description = VM_UUID_DESC) String vmUUID, @Param(value = INCLUDE_VM_DISK_CONFIG_INFO, description = INCLUDE_VM_DISK_CONFIG_INFO_DESC) String includeVMDiskConfigInfo, @Param(value = INCLUDE_VM_NIC_CONFIG_INFO, description = INCLUDE_VM_NIC_CONFIG_INFO_DESC) String includeVMNicConfigInfo, @Param(value = API_VERSION, description = API_VERSION_DESC) String apiVersion, @Param(value = PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost, @Param(value = PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort, @Param(value = PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true, description = PROXY_PASSWORD_DESC) String proxyPassword, @Param(value = TRUST_ALL_ROOTS, description = TRUST_ALL_ROOTS_DESC) String trustAllRoots, @Param(value = X509_HOSTNAME_VERIFIER, description = X509_DESC) String x509HostnameVerifier, @Param(value = TRUST_KEYSTORE, description = TRUST_KEYSTORE_DESC) String trustKeystore, @Param(value = TRUST_PASSWORD, encrypted = true, description = TRUST_PASSWORD_DESC) String trustPassword, @Param(value = CONNECT_TIMEOUT, description = CONNECT_TIMEOUT_DESC) String connectTimeout, @Param(value = SOCKET_TIMEOUT, description = SOCKET_TIMEOUT_DESC) String socketTimeout, @Param(value = KEEP_ALIVE, description = KEEP_ALIVE_DESC) String keepAlive, @Param(value = CONNECTIONS_MAX_PER_ROUTE, description = CONN_MAX_ROUTE_DESC) String connectionsMaxPerRoute, @Param(value = CONNECTIONS_MAX_TOTAL, description = CONN_MAX_TOTAL_DESC) String connectionsMaxTotal) {
port = defaultIfEmpty(port, DEFAULT_NUTANIX_PORT);
apiVersion = defaultIfEmpty(apiVersion, DEFAULT_API_VERSION);
proxyHost = defaultIfEmpty(proxyHost, EMPTY);
proxyPort = defaultIfEmpty(proxyPort, DEFAULT_PROXY_PORT);
proxyUsername = defaultIfEmpty(proxyUsername, EMPTY);
proxyPassword = defaultIfEmpty(proxyPassword, EMPTY);
trustAllRoots = defaultIfEmpty(trustAllRoots, BOOLEAN_FALSE);
includeVMDiskConfigInfo = defaultIfEmpty(includeVMDiskConfigInfo, BOOLEAN_TRUE);
includeVMNicConfigInfo = defaultIfEmpty(includeVMNicConfigInfo, BOOLEAN_TRUE);
x509HostnameVerifier = defaultIfEmpty(x509HostnameVerifier, STRICT);
trustKeystore = defaultIfEmpty(trustKeystore, DEFAULT_JAVA_KEYSTORE);
trustPassword = defaultIfEmpty(trustPassword, CHANGEIT);
connectTimeout = defaultIfEmpty(connectTimeout, CONNECT_TIMEOUT_CONST);
socketTimeout = defaultIfEmpty(socketTimeout, ZERO);
keepAlive = defaultIfEmpty(keepAlive, BOOLEAN_TRUE);
connectionsMaxPerRoute = defaultIfEmpty(connectionsMaxPerRoute, CONNECTIONS_MAX_PER_ROUTE_CONST);
connectionsMaxTotal = defaultIfEmpty(connectionsMaxTotal, CONNECTIONS_MAX_TOTAL_CONST);
final List<String> exceptionMessage = verifyCommonInputs(proxyPort, trustAllRoots, connectTimeout, socketTimeout, keepAlive, connectionsMaxPerRoute, connectionsMaxTotal);
if (!exceptionMessage.isEmpty()) {
return getFailureResultsMap(StringUtilities.join(exceptionMessage, NEW_LINE));
}
try {
final Map<String, String> result = getVMDetails(NutanixGetVMDetailsInputs.builder().vmUUID(vmUUID).includeVMDiskConfigInfo(includeVMDiskConfigInfo).includeVMNicConfigInfo(includeVMNicConfigInfo).commonInputs(NutanixCommonInputs.builder().hostname(hostname).port(port).username(username).password(password).apiVersion(apiVersion).proxyHost(proxyHost).proxyPort(proxyPort).proxyUsername(proxyUsername).proxyPassword(proxyPassword).trustAllRoots(trustAllRoots).x509HostnameVerifier(x509HostnameVerifier).trustKeystore(trustKeystore).trustPassword(trustPassword).connectTimeout(connectTimeout).socketTimeout(socketTimeout).keepAlive(keepAlive).connectionsMaxPerRoot(connectionsMaxPerRoute).connectionsMaxTotal(connectionsMaxTotal).build()).build());
final String returnMessage = result.get(RETURN_RESULT);
final Map<String, String> results = getOperationResults(result, returnMessage, returnMessage, returnMessage);
final int statusCode = Integer.parseInt(result.get(STATUS_CODE));
if (statusCode >= 200 && statusCode < 300) {
final String vmName = JsonPath.read(returnMessage, VM_NAME_PATH);
Configuration configuration = Configuration.defaultConfiguration().addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);
final List<String> ipAddressList = (JsonPath.using(configuration).parse(returnMessage).read(IP_ADDRESS_PATH));
if (!ipAddressList.isEmpty()) {
final String ipAddressString = join(ipAddressList.toArray(), DELIMITER);
results.put(IP_ADDRESS, ipAddressString);
} else {
results.put(IP_ADDRESS, EMPTY);
}
final List<String> MACAddressList = (JsonPath.using(configuration).parse(returnMessage).read(MAC_ADDRESS_PATH));
final String powerState = JsonPath.read(returnMessage, POWER_STATE_PATH);
final List<String> vmDiskUUID = JsonPath.read(returnMessage, VM_DISK_UUID_PATH);
final List<String> storageContainerUUID = JsonPath.read(returnMessage, STORAGE_CONTAINER_UUID_PATH);
final String vmLogicalTimestamp = JsonPath.read(returnMessage, VM_LOGICAL_TIMESTAMP_PATH).toString();
final String MACAddressString = join(MACAddressList.toArray(), DELIMITER);
results.put(MAC_ADDRESS, MACAddressString);
results.put(VM_NAME, vmName);
results.put(POWER_STATE, powerState);
final String vmDiskUUIDString = join(vmDiskUUID.toArray(), DELIMITER);
results.put(VM_DISK_UUID, vmDiskUUIDString);
final String storageContainerUUIDString = join(storageContainerUUID.toArray(), DELIMITER);
results.put(STORAGE_CONTAINER_UUID, storageContainerUUIDString);
results.put(VM_LOGICAL_TIMESTAMP, vmLogicalTimestamp);
final LinkedHashMap<String, String> affinity = (JsonPath.using(configuration).parse(returnMessage).read(AFFINITY_PATH));
if (affinity != null) {
final List<String> hostUUIDList = (JsonPath.using(configuration).parse(returnMessage).read(HOST_UUID_PATH));
final String hostUUIDString = join(hostUUIDList.toArray(), DELIMITER);
results.put(HOST_UUIDS, hostUUIDString);
} else {
results.put(HOST_UUIDS, EMPTY);
}
} else {
return getFailureResults(hostname, statusCode, returnMessage, returnMessage);
}
return results;
} catch (Exception exception) {
return getFailureResultsMap(exception);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DeleteHostGroup method deleteHostGroup.
/**
* @param host VMware host or IP.
* Example: "vc6.subdomain.example.com"
* @param port optional - the port to connect through.
* Default Value: "443"
* Examples: "443", "80"
* @param protocol optional - The connection protocol.
* Default Value: "https"
* Valid Values: "http", "https"
* @param username The VMware username used 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. 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
* Default Value: "true"
* @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 clusterName The name of the cluster from which the host group will be deleted.
* @param hostGroupName The name of the host group that will be deleted.
* @return
*/
@Action(name = "Delete DRS Host Group", 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> deleteHostGroup(@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 = HOST_GROUP_NAME, required = true) String hostGroupName, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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();
VmInputs vmInputs = new VmInputs.VmInputsBuilder().withClusterName(clusterName).withHostGroupName(hostGroupName).build();
return new ClusterComputeResourceService().deleteHostGroup(httpInputs, vmInputs);
} catch (Exception ex) {
return OutputUtilities.getFailureResultsMap(ex);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DeleteVmGroup method deleteVmGroup.
/**
* @param host VMware host or IP.
* Example: "vc6.subdomain.example.com"
* @param port optional - the port to connect through.
* Default Value: "443"
* Examples: "443", "80"
* @param protocol optional - The connection protocol.
* Default Value: "https"
* Valid Values: "http", "https"
* @param username The VMware username used 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. 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
* Default Value: "true"
* @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 clusterName The name of the cluster from which the VM group will be deleted.
* @param vmGroupName The name of the VM group that will be deleted.
* @return
*/
@Action(name = "Delete DRS VM Group", 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> deleteVmGroup(@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_GROUP_NAME, required = true) String vmGroupName, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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().withClusterName(clusterName).withVmGroupName(vmGroupName).build();
return new ClusterComputeResourceService().deleteVmGroup(httpInputs, vmInputs);
} catch (Exception ex) {
return OutputUtilities.getFailureResultsMap(ex);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class GetVmOverrides method getVmOverrides.
/**
* @param host VMware host or IP.
* Example: "vc6.subdomain.example.com"
* @param port optional - The port to connect through.
* Default Value: "443"
* Examples: "443", "80"
* @param protocol optional - The connection protocol.
* Default Value: "https"
* Valid Values: "http", "https"
* @param username The VMware username used 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 Value: "false"
* @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 hostname The name of the target host to be queried to retrieve the supported guest OSes
* Example: "host123.subdomain.example.com"
* @param virtualMachineName optional - The name of the virtual machine for which the override will be created. This input
* is mutually exclusive with virtualMachineId.
* @param virtualMachineId optional - The id of the virtual machine for which the override will be created. This input is
* mutually exclusive with virtualMachineName.
* Example: "vm-1230"
* @param clusterName The name of the cluster.
* @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 = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = 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) String virtualMachineName, @Param(value = VM_ID) String virtualMachineId, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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();
InputUtils.checkOptionalMutuallyExclusiveInputs(virtualMachineName, virtualMachineId, PROVIDE_VM_NAME_OR_ID_OR_NONE);
final VmInputs vmInputs = new VmInputs.VmInputsBuilder().withClusterName(clusterName).withHostname(hostname).withVirtualMachineName(virtualMachineName).withVirtualMachineId(virtualMachineId).build();
return OutputUtilities.getSuccessResultsMap(new ClusterComputeResourceService().getVmOverride(httpInputs, vmInputs));
} catch (Exception ex) {
return OutputUtilities.getFailureResultsMap(ex);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DeployOvfTemplateAction method deployTemplate.
/**
* @param host VMware host or IP - Example: "vc6.subdomain.example.com"
* @param username The VMware username use to connect
* @param password The password associated with "username" input
* @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 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 path Path to the .ovf or .ova file on the RAS filesystem or network to import.
* @param name Name of the newly deployed virtual machine.
* @param datacenter Datacenter of the host system or cluster.
* @param dataStore Name of dataStore to store the new virtual machine.
* - Example: "datastore2-vc6-1"
* @param hostname The name of the target host.
* - Example: "host123.subdomain.example.com"
* @param clusterName The cluster name on which the template will be deployed.
* @param resourcePool The resource pool name on the specified cluster. If not provided then the
* parent resource pool be will be used
* @param vmFolder Virtual machine's inventory folder name. This input is case sensitive.
* @param diskProvisioning Represents types of disk provisioning that can be set for the disk in the deployed OVF package.
* - Valid values: monolithicSparse, monolithicFlat, twoGbMaxExtentSparse, twoGbMaxExtentFlat, thin, thick, sparse, flat
* @param ipProtocol Specifies how the guest software gets configured with IP addresses.
* - Valid values: IPv4, IPv6
* @param ipAllocScheme The deployer / operator of a vApp, specifies what IP allocation policy should be used:
* - Valid values:
* dhcpPolicy - Specifies that DHCP must be used to allocate IP addresses to the vApp.
* fixedPolicy - The IP addresses are allocated when the vApp is deployed and
* will be kept with the server as long as it is deployed.
* transientPolicy - The IP addresses are allocated when needed, typically
* at power-on, and deallocated during power-off.
* @param localeLang The locale language in which to process the OVF. If you do not specify a value for this input,
* the default locale language of the system will be used.
* @param localeCountry The locale country in which to process the OVF. If you do not specify a value for this input,
* the default locale country of the system will be used.
* @param ovfNetworkJS A JSON array of network in the ovf template to be mapped to vm port groups. The netPortGroupJS input will
* be a complimentary array that defined the target port groups for these networks.
* - Example: ["Network 1","Network 2"].
* @param netPortGroupJS A JSON array of port groups that the ovf networks in the template will attach to. The ovfNetworkJS input
* defined the source networks in the ovf template for these portgroups.
* - Example: ["VM Network", "dvPortGroup"].
* Including the example from ovfNetworkJS input, "Network 1" will be mapped to "VM Network" and
* "Network 2" will be mapped to "dvPortGroup".
* @param ovfPropKeyJS A JSON array of property names to be configured during import of the ovf template.
* - Example: ["vami.ip0.vmName","vami.ip1.vmName"]
* @param ovfPropValueJS A JSON array of property values respective to the property names defined in ovfPropKeyJS to be applied
* during import of the ovf template.
* - Example: ["10.10.10.10","10.20.30.40"].
* Including the example from ovfPropKeyJS input, property "vami.ip0.vmName" will have value
* "10.10.10.10" and "vami.ip1.vmName" will have value "10.20.30.40".
* @param parallel If the ovf template has multiple .vmdk files, should they be uploaded in parallel?
* If true, all .vmdk files will be uploaded using separate threads.
* If false, .vmdk files will be uploaded individually. Depending on the performance characteristics
* of the network between the host and the RAS and the RAS system storage, parallel upload will be faster.
* @return
*/
@Action(name = "Deploy OVF Template", 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> deployTemplate(@Param(value = HOST, required = true) String host, @Param(value = USERNAME) String username, @Param(value = PASSWORD, encrypted = true, required = true) String password, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = PATH, required = true) String path, @Param(value = NAME, required = true) String name, @Param(value = DATACENTER, required = true) String datacenter, @Param(value = DATA_STORE, required = true) String dataStore, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = CLUSTER_NAME) String clusterName, @Param(value = RESOURCE_POOL) String resourcePool, @Param(value = VM_FOLDER) String vmFolder, @Param(value = DISK_PROVISIONING) String diskProvisioning, @Param(value = IP_PROTOCOL) String ipProtocol, @Param(value = IP_ALLOC_SCHEME) String ipAllocScheme, @Param(value = LOCALE_LANG) String localeLang, @Param(value = LOCALE_COUNTRY) String localeCountry, @Param(value = OVF_NETWORK_JS) String ovfNetworkJS, @Param(value = NET_PORT_GROUP_JS) String netPortGroupJS, @Param(value = OVF_PROP_KEY_JS) String ovfPropKeyJS, @Param(value = OVF_PROP_VALUE_JS) String ovfPropValueJS, @Param(value = PARALLEL) String parallel, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) {
try {
final Locale locale = InputUtils.getLocale(localeLang, localeCountry);
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(name).withDataCenterName(datacenter).withDataStore(dataStore).withCloneDataStore(dataStore).withFolderName(vmFolder).withLocale(locale).withClusterName(clusterName).withResourcePool(resourcePool).withIpProtocol(ipProtocol).withIpAllocScheme(ipAllocScheme).withDiskProvisioning(diskProvisioning).build();
final Map<String, String> ovfNetworkMappings = OvfUtils.getOvfMappings(ovfNetworkJS, netPortGroupJS);
final Map<String, String> ovfPropertyMappings = OvfUtils.getOvfMappings(ovfPropKeyJS, ovfPropValueJS);
new DeployOvfTemplateService(InputUtils.getBooleanInput(parallel, true)).deployOvfTemplate(httpInputs, vmInputs, path, ovfNetworkMappings, ovfPropertyMappings);
return OutputUtilities.getSuccessResultsMap(SUCCESSFULLY_DEPLOYED);
} catch (Exception ex) {
return OutputUtilities.getFailureResultsMap(ex);
}
}
Aggregations