vedaniks
Contributor
Contributor

Unable to clone ticket using /api/ui/vcenter/session/clone-ticket

Jump to solution

Hello,

I am following this guide to delegate session authority to the plug-in server.

On the plug-in UI, I got the sessionToken using app.getSessioninfo() method.

When I try to get the session_clone_ticket using REST API endpoint /api/ui/vcenter/session/clone-ticket, I get the following error:

[401] Something went wrong. Check the server logs for more information

Which logs should I check? Can someone please help me debug why I am getting this error.

My POST request looks like this:

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"vc-guid\": \"223b94f2-af15-4613-5d1a-a278b19abc09\"\r\n}");
Request request = new Request.Builder()
  .url("https://vc-fqdn/api/ui/vcenter/session/clone-ticket")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Accept", "application/json")
  .addHeader("vmware-api-session-id", "\"vmw-sid:[issuer:e7b5f32e-3b70-4668-9b52-b3bd17075008,version:2,value:bdMkwgnaXutxYpTWdvYdV1SJuXxVF8AFiOJh+v/E2/s=]\"")
  .build();
Response response = client.newCall(request).execute();

 

Note: I have also tried using only value from sessionToken bdMkwgnaXutxYpTWdvYdV1SJuXxVF8AFiOJh+v/E2/s= as vmware-api-session-id, but still got the same error.

Thanks in advance!

1 Solution

Accepted Solutions
harsha219
Contributor
Contributor

The call worked. I think you missed the body in your POST call.

Include the following body

{"vc_guid": "223b94f2-af15-4613-5d1a-a278b19abc09"}

View solution in original post

0 Kudos
6 Replies
stoevm
VMware Employee
VMware Employee

Hi vedaniks 

The whole result returned from the getSessionInfo should be used as shown in the code snippet.

Logs should be available in the /storage/log/vmware/vsphere-ui/logs/vsphere_client_virgo.log.

Please locate the error log why 401 is thrown and post it.

Thanks,
Martin

0 Kudos
harsha219
Contributor
Contributor

The call worked. I think you missed the body in your POST call.

Include the following body

{"vc_guid": "223b94f2-af15-4613-5d1a-a278b19abc09"}
0 Kudos
vedaniks
Contributor
Contributor

Thanks for this. It was the issue in my API call. I had used vc-guid [hyphen] instead of vc_guid [underscore]

Do you know if we can fetch the vc_guid in the global plugin page using htmlclientsdk? [see attached image]

I know that on object page we get the vc_guid from URL like "VirtualMachine:vm-15:f17d2a70-9cfa-49ee-b5ec-2bd080beb123/summary". But, I want to fetch vc_guid from global plugin page.

Thanks in advance!

0 Kudos
stoevm
VMware Employee
VMware Employee

Hi vedaniks,

On a global view you can not fetch the vc_guid, because there are corner cases where this results in an undefined behavior. For example one remote plugin instance registered on multiple vCenters. At this point there will be multiple guids for that global view.

The idea for remote plugins is to have the guids of the registered vCenters configured during plugin installation, for example in a conf file or through some REST endpoints. 

This way the plugin will know to which vCenters it is supposed to be talking to and the plugin UI will not be required to retrieve such information. This is the case for global views since there is no object and the plugin ( if it wants to retrieve info from the vCenters) can do it through the configured vCenter guids (thumbprints and so on...) .

For a context object it is important to retrieve the object and the guid since you want(in most cases) to show information relevant only for that vCenter ( and object ).

harsha219
Contributor
Contributor

After obtaining the "session_clone_ticket", I'm trying to clone the ticket using sessionmanager.cloneticket() but it fails throwing "Unauthenticated" error. What am I doing wrong?

0 Kudos
amarinov
VMware Employee
VMware Employee

Hi @harsha219,

Are you using the SessionManager.cloneSession() API or the SessionManager.acquireCloneTicket() API of the vSphere Management SDK after obtaining the session clone ticket?

Thanks,
Aleksandar

0 Kudos