emscroger
Contributor
Contributor

My Tasks - vCenter user vs SSO user


I've implemented custom tasks to track creation of objects in my plugin.  However, the tasks do not show up using 'My Tasks', but they do show up if I choose 'All Tasks'.   It appears the user I'm setting for the Task initiatedBy field is not correct.  


When I create the task, I am getting the username from the UserSession object, yet this user is not matching the user for My Tasks.  What is the recommended username to use in the initiatedBy field so My Tasks show up correctly.  I read in another forum to use the vCenter user instead of the SSO username. 


Thanks,


E

0 Kudos
15 Replies
laurentsd
VMware Employee
VMware Employee

What is the initiator value displayed in All Tasks for the tasks you created?

0 Kudos
emscroger
Contributor
Contributor

Sorry it has been so long.   I'd like to follow up on this issue.

The task initiator field shows user "CORP\\myuser".  When I created the task, I set the initiatedBy parameter to the username from the current user session, in this case the value is "myuser@corp.nexgenstorage.com".

How do I get the vCenter username correctly, instead of the SSO user? 

0 Kudos
emscroger
Contributor
Contributor

Any ideas?  I can get my registered Tasks to show up if I choose, "All User's Tasks", but no "My Tasks".   How do I set the vCenter user in the initiated by field so my custom task shows up in "My Tasks".

E

0 Kudos
Peter_Ivanov
VMware Employee
VMware Employee

Hi E,

Few questions that will help me better understand and help you:

  • Which version of the SDK/Web Client are you using?
  • Are you creating a Flex or HTML plugin?
  • Do you have a Java service part of your plugin?
  • Can you give more details on the workflow? Are those tasks initiated by some user action?

I imagine the following scenario:

1) the user clicks a "New" button that opens a dialog or wizard

2) the user clicks completes the dialog/wizard

3) a request is sent to the plugin backend

4) you send some request to your server that performs the action and posts tasks to VC

If this is the case, then you should do the following:

- on step 3 you should be able to get the user name from the UserSessionService in the backed. At this point, since you are in the context of a UI call, the user session service will return you the currently logged user name

- on step 4 your should pass the username to your server

- your server can set the TaskReasonUser#username to that user

- alternatively if the creation of objects consists of several tasks you might want to create a parent task (with the correct username) and multiple child tasks

0 Kudos
emscroger
Contributor
Contributor

I am using the 5.5.1/6.0 vSphere web client SDKs.  This is an HTML plugin with a Java service layer implementation. 

The general workflow is as follows:

1.  User submit request from UI layer to my custom Java service layer to create a datastore, passing in a host name.

2.  The service implementation gets the managed object reference for the HostSystem.

3.  The service gets a handle on the TaskManager from service content.

4.  Next the service gets the UserSession from the UserSessionService, and returns the username.

5.  The service sets the username in the initiatedBy field when creating the custom task.

I then try to monitor the progress using the Recent Tasks with My Tasks. My new custom task does not show up under My Tasks.  It does show up under all users tasks.

Other forum users have recommended I use the vCenter user and not the SSO user.  I assume this "IS" the vCenter user.  What is missing?

Thanks,

E

0 Kudos
Peter_Ivanov
VMware Employee
VMware Employee

Hi E,

1.  User submit request from UI layer to my custom Java service layer to create a datastore, passing in a host name.

You should pass ServerObjectRef (or objectId) and not just the host name.

4.  Next the service gets the UserSession from the UserSessionService, and returns the username.

Can you tell me what exactly the UserSessionService returns as username?

I tried with the SDL samples and it returns exactly the username that I used during login (e.g. administrator@vsphere.local).

I then try to monitor the progress using the Recent Tasks with My Tasks.

Might sound stupid, but did you refresh the UI (the global refresh button before the username)?

Recent tasks are not "live". They are refreshed on some interval of time.

0 Kudos
Peter_Ivanov
VMware Employee
VMware Employee

Another interesting observation.

I did the following:

1. I created a folder using the UI.

2. Then I opened the VC Managed Object Browser (https://vc_ip/mob).

3. Navigate to https://vc_ip/mob/?moid=TaskManager

4. from the recentTask property open the most recent task

5. select the info, then reason property

The username is VSPHERE.LOCAL\Adimistrator while the UserSessionService returned Administrator@VSPHERE.LOCAL.

So I think its just the format of the username. Please try changing the format of the username before setting it to the task reason.

0 Kudos
emscroger
Contributor
Contributor

I am passing the object ref as you mentioned.  In this case, the user is the vsphere admin, "VSPHERE.LOCAL\\Administrator". 

As you mentioned, the Recent Tasks are freshed intermittently.  To force them to refresh, I selected the drop down menu, 'My Tasks', and the Recent Tasks refreshed.

The tasks appear to be updating now, but only after refreshing manually.  If that is the case, our plugin's tasks appear to be working, although the tasks don't seem to update unless I manually refresh.  Go figure.

0 Kudos
emscroger
Contributor
Contributor

Also, when call createTask, I am not setting initiatedBy anymore since this parameter is optional.  VSphere seems to do the right thing this way. 

0 Kudos
Peter_Ivanov
VMware Employee
VMware Employee

If I understand you correctly the problem turned out to be a UI refresh issue, right?

0 Kudos
emscroger
Contributor
Contributor

The main issue is the Recent Tasks view does not refresh automatically.   I still have to manually select 'My Tasks' more than once to see my tasks update.   Also, I noticed if I do not set the current session username in the optional initiatedBy parameter when creating the custom task, then the tasks show up as expected.  If I do set the username, the tasks usually do not show up at all.  Go figure.

0 Kudos
Peter_Ivanov
VMware Employee
VMware Employee

Also, I noticed if I do not set the current session username in the optional initiatedBy parameter when creating the custom task, then the tasks show up as expected.


What does the recent tasks UI show as 'Initiated by' when you don't set the parameter?


0 Kudos
emscroger
Contributor
Contributor

The initiated by field shows 'VSPHERE.LOCAL\\Administrator' as expected.   So I leave this optional parameter blank now.

0 Kudos
Peter_Ivanov
VMware Employee
VMware Employee

I have found this topic in the forum that should help you:

https://communities.vmware.com/message/2333688#2333688

It explains how to refresh the task pane.

0 Kudos
emscroger
Contributor
Contributor

This particular solution doesn't apply for me.  I'm using the HTML bridge and no Flex mediator classes.  My task runs in the Java service layer.  Also, it appears that that solution only refreshes the Recent Tasks view upon completion.  I would like to refresh the view periodically as individual steps complete.  Thanks anyway.

0 Kudos