Hi
How to pass VM name to Workflow using JavaSDK? I tried passing VM name as parameter, but it is getting failed with error " 400 1 error(s) found: [ { Virtual machine to power off - This field is required. } ]" .
find below code..
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URL;
import com.vmware.o11n.sdk.rest.client.DefaultVcoSessionFactory;
import com.vmware.o11n.sdk.rest.client.VcoSession;
import com.vmware.o11n.sdk.rest.client.VcoSessionFactory;
import com.vmware.o11n.sdk.rest.client.authentication.Authentication;
import com.vmware.o11n.sdk.rest.client.services.ExecutionContextBuilder;
import com.vmware.o11n.sdk.rest.client.services.ExecutionService;
import com.vmware.o11n.sdk.rest.client.services.ParameterExtractor;
import com.vmware.o11n.sdk.rest.client.services.PresentationService;
import com.vmware.o11n.sdk.rest.client.services.WorkflowService;
import com.vmware.o11n.sdk.rest.client.stubs.ExecutionContext;
import com.vmware.o11n.sdk.rest.client.stubs.Parameter;
import com.vmware.o11n.sdk.rest.client.stubs.Presentation;
import com.vmware.o11n.sdk.rest.client.stubs.PresentationExecution;
import com.vmware.o11n.sdk.rest.client.stubs.Workflow;
import com.vmware.o11n.sdk.rest.client.stubs.WorkflowExecution;
import com.vmware.o11n.sdk.rest.client.stubs.WorkflowExecutionState;
import com.vmware.o11n.sdk.rest.client.stubs.Workflow.InputParameters;
public class ConnectVCO
{
public static void main(String args[])
{
try{
VcoSession session = DefaultVcoSessionFactory.newSsoSession(new URI("https://Win2K8:8281/api/"), new URI("https://SSOServer:7444/ims/STSService"), 300000,"user", "pass");
//create the services
WorkflowService workflowService = new WorkflowService(session);
ExecutionService executionService = new ExecutionService(session);
//find a workflow by ID
Workflow workflow = workflowService.getWorkflow("e6820263-366a-487c-be29-1cxdc23db7e5"); //Workflow to "Power off virtual machine and wait"
//create an ExecutionContext from the user's input
ExecutionContext context = new ExecutionContextBuilder().addParam("vm","testVCOCust").build();
//run the workflow
WorkflowExecution execution = executionService.execute(workflow, context);
execution = executionService.awaitState(execution, 500, 10, WorkflowExecutionState.CANCELED, WorkflowExecutionState.FAILED, WorkflowExecutionState.COMPLETED);
String nameParamValue = new ParameterExtractor().fromTheOutputOf(execution).extractString("name");
System.out.println("workflow was executed with 'name' input set to" + nameParamValue);
//wait for the workflow to reach the user interaction state, checking every 500 milliseconds
//execution = executionService.awaitState(execution, 500, 10, WorkflowExecutionState.CANCELED, WorkflowExecutionState.FAILED, WorkflowExecutionState.COMPLETED);
//String nameParamValue = new ParameterExtractor().fromTheOutputOf(execution).extractString("name");
//System.out.println("workflow was executed with 'name' input set to"+nameParamValue);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
If someone can help??