VMware {code} Community
RakeshBandari
Contributor
Contributor

create a task vsphere sdk

Hi all ,

We are working on the vSphere plugin and currently got stuck with creating a tasks in the vSphere webclients recent tasks.

we need to add a task to the recent tasks tab for any operation we do on the plugin we are developing .

My code looks like this :

    UserSession userSession = _userSessionService.getUserSession();
        ServerInfo[] sinfo = userSession.serversInfo;
        String sessionCookie = sinfo[0].sessionCookie;
        String serviceUrl = sinfo[0].serviceUrl;
        ServiceContent serviceContent = getServiceContent(sinfo[0].serviceGuid);
       
        ManagedObjectReference extensionReference = serviceContent.getExtensionManager(); 
         _taskMgrReference = serviceContent.getTaskManager();
         _vimPort.createTask(extensionReference, _taskMgrReference, "Rakesh", "Bandari", true, "Administrator", "TestFault");

    UserSession userSession = _userSessionService.getUserSession();
    ServerInfo[] sinfo = userSession.serversInfo;
    String sessionCookie = sinfo[0].sessionCookie;
    String serviceUrl = sinfo[0].serviceUrl;
    ServiceContent serviceContent = getServiceContent(sinfo[0].serviceGuid);
       
    ManagedObjectReference extensionReference = serviceContent.getExtensionManager(); 
    _taskMgrReference = serviceContent.getTaskManager();
   _vimPort.createTask(extensionReference,_taskMgrReference,"Rakesh","Bandari",true,"Administrator","TestFault");

 

this code doesn't work for me .Can some one please let me know how can i create a cutom task in the vPsphere plugin .

 

Thanks,

RakeshBandari

Reply
0 Kudos
2 Replies
joshames
Enthusiast
Enthusiast

First off, there is no way anyone can fix your code because you gave so little so there is no telling what your variables relate to.  Additionally, the createtask method is depricated in vmware.vim.dll 5.5.  But assuming you want to do this anyway, you use:

TaskManager.CreateTask(ManagedObjectReference, string (tasktypeID), string (initiatedby), bool (cancelable), string (parentTaskKey - Not Required));

With the variables you put into the create task method, there is no way you are using the correct ones.  Task Type ID is a specific set of strings and you can look at current tasks in your vCenter to see what the options are.

 

What is it exactly that you are trying to do??? Maybe there is a better way...

 

Josh

Reply
0 Kudos
joshames
Enthusiast
Enthusiast

First off, there is no way anyone can fix your code because you gave so little so there is no telling what your variables relate to.  Additionally, the createtask method is depricated in vmware.vim.dll 5.5.  But assuming you want to do this anyway, you use:

TaskManager.CreateTask(ManagedObjectReference, string (tasktypeID), string (initiatedby), bool (cancelable), string (parentTaskKey - Not Required));

With the variables you put into the create task method, there is no way you are using the correct ones.  Task Type ID is a specific set of strings and you can look at current tasks in your vCenter to see what the options are.

 

What is it exactly that you are trying to do??? Maybe there is a better way...

 

Josh

Reply
0 Kudos