Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 176483

Is any method really invoked when using CreateTaskAction and set a TaskTypeId

$
0
0

Hi All,

 

I'm trying to create a task to invoke my own method/script and hoping it can show in the task list.

 

I add the taskInfo when register the extension like:

 

       String myPkg = "com.myCompany.myProduct.myTask";

       String myTask = myPkg + "InvokeEXE";

       Extension myExt = new Extension();

       ManagedObjectReference extManager = new ManagedObjectReference();

       extManager = serviceContent.getExtensionManager();

    

       //Create ExtensionTaskTypeInfo

       ExtensionTaskTypeInfo etti = new ExtensionTaskTypeInfo();

       etti.setTaskID(myTask);

       myExt.getTaskList().add(etti);

      

       //Create ExtensionResourceInfo

       ExtensionResourceInfo eri = new ExtensionResourceInfo();

       eri.setLocale("en");

       eri.setModule("task");

       KeyValue key1 = new KeyValue();

       key1.setKey(myTask + ".lable");

       key1.setValue("My Task Lable");

       KeyValue key2 = new KeyValue();

       key2.setKey(myTask + ".summary");

       key2.setValue("My task summary");

       eri.getData().add(key1);

       eri.getData().add(key2);

       myExt.getResourceList().add(eri);

      

       //Create Description

       Description des = new Description();

       des.setLabel("My Company Product Lable");

       des.setSummary("My Company Product Summary");

       myExt.setDescription(des);

      

       //Other

       myExt.setKey(myPkg);

       myExt.setVersion("1.0.0");

      

       //Create Client Info

       ExtensionClientInfo eci = new ExtensionClientInfo();

       Description des1 = new Description();

       des1.setLabel("My Client Info Lable");

       des1.setSummary("My Client Info Summary");

       eci.setDescription(des1);

       eci.setCompany("IBM");

       eci.setType("win32");

       eci.setVersion("1.0.0");

       eci.setUrl("http://somewhere/something.zip");

       myExt.getClient().add(eci);

      

       GregorianCalendar gcal = new GregorianCalendar();

       gcal.setTime(new Date());

       myExt.setLastHeartbeatTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal));

      

       vimPort.registerExtension(extManager, myExt);

 

And I create a custom task like:

 

      ManagedObjectReference clusterMor = new ManagedObjectReference();

      clusterMor.setType("ClusterComputeResource");

      clusterMor.setValue("domain-c23");

 

     CreateTaskAction action = new CreateTaskAction();

     action.setCancelable(true);

     action.setTaskTypeId("com.ibm.ivp.tool.InvokeEXE");

 

      GregorianCalendar gcal = new GregorianCalendar();

      gcal.add(Calendar.MINUTE, 30);

      XMLGregorianCalendar runTime = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);

      OnceTaskScheduler scheduler = new OnceTaskScheduler();

      scheduler.setRunAt(runTime);

 

     ScheduledTaskSpec scheduleSpec = new ScheduledTaskSpec();

     scheduleSpec.setName("ThisTaskName");

     scheduleSpec.setDescription("Create task to a cluster");

     scheduleSpec.setEnabled(true);

     scheduleSpec.setAction(action);

     scheduleSpec.setScheduler(scheduler);

 

 

     ManagedObjectReference scheduleMgr = new ManagedObjectReference();

     scheduleMgr = serviceContent.getScheduledTaskManager();

     ManagedObjectReference task = vimPort.createScheduledTask(scheduleMgr, clusterMor, scheduleSpec);

 

But I only got a "queued" task and nothing is invoked. So is there a method that really invoked by this task? If not, how can I do that?

 

Thanks in advance.


Viewing all articles
Browse latest Browse all 176483

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>