Monday, October 10, 2011

How to Generate VM Remote Console URL for vSphere 5 Web Client

There was a question last week on the VMTN community forums about generating a shortcut URL to a virtual machine's remote console in the new vSphere 5 Web Client. For those of you who have used the vCenter's Web Access may recall the option to generate a desktop shortcut to a particular virtual machine's remote console which includes ability to obfuscate the generated URL that could then be provided to your users.

With the updated vSphere 5 Web Client, there is not an option to generate the remote console URL but there is a link that you could manually copy and provide to your users. This of course is not ideal but after a tinkering, I was able to figure out how to generate the remote console URL for any virtual machine in the new vSphere 5 Web Client.
I also created a vSphere SDK for Perl script awhile back called generateVMRemoteConsoleURL.pl which helps users automate the URL generation for vSphere 4.x environments, it has now been updated to support vSphere 5.   

Here is an example of what a URL could look like:

https://reflex.primp-industries.com:9443/vsphere-client/vmrc/vmrc.jsp?vm=EE26E7F6-591B-4256-BD7A-402E5AC9E0A8:VirtualMachine:vm-1506

There are basically three important components to the URL:
  • Hostname of the vCenter Server - reflex.primp-industries.com
  • The vCenter instanceUUID which used to uniquely identify a vCenter Server - EE26E7F6-591B-4256-BD7A-402E5AC9E0A8
  • The MoRef ID of the virtual machine - vm-1506
Since the Web Client does not support URL customization, you only need to provide the name of a virtual machine to the generateVMRemoteConsoleURL.pl script and the URL will be generated for you.

Here is an example execution of the script:
Now you can take the URL output from the script and enter it into a supported web browser. You will then be asked to authenticate before it allows you to access the remote console of a particular virtual machine.
You can now provide links to specific virtual machines

23 comments:

  1. Hi William, thanks for that. Do you know how these URLs can be pre-authenticated or how user credentials can be passed as parameters to the URLs (so that we can integrate single sign on with external systems)?

    ReplyDelete
  2. @Ashley,

    I took a quick look but haven't been able to find a way. Using firebut, I noticed the following URL - https://reflex.primp-industries.com:9443/vsphere-client/vmrc/ticket.jsp?nonce=25e206b6-ef45-49e3-a5a0-84d9f2fc8117&_=1318485964250

    where 25e206b6-ef45-49e3-a5a0-84d9f2fc8117 is the mks ticket acquired for a particular VM and 1318485964250 is some type of counter

    You may want to file an SR to VMware to see if it's possible to per-authenticate using mks ticket

    ReplyDelete
  3. @Ashley,

    I spoke with engineering and it looks like it is not possible today to pre-auth VMRC. I've provided your feedback and this is something they can look into.

    ReplyDelete
  4. @William, thanks a lot for that. Our developers have been able to get around the issue by programatically creating a clone session and using this clone session (with some trickery) to generate an Ajax call to the console page. From the POC code I've seen, it should be OK for now until this functionality is officially supported. It gives us the benefit of stopping the users navigating off the console web page, and allowing us to integrate our single signon technologies (using a proxied vCentre logon for console access).

    ReplyDelete
    Replies
    1. @Ashley can you guide me how it can be achieve without authentication. I can manage Ajax call but could not find the way for authentication.

      Delete
  5. @Ashley, I have a doubt & I need to get in touch with you regarding that. Can I have your email id or twitter handle or FB vanity URL? My twitter & FB id is pprakash.

    Thanks,
    Prakash

    ReplyDelete
  6. William, do you know if there's an alternate URL syntax that allows the VM to be referenced by the VM name rather that the MOID?

    Yours optimistically ... Jason

    ReplyDelete
  7. @Jason,

    No I'm afraid not. A VM display name is not always unique & standardizing on something such as a MoRef ID guarantees uniqueness + readability.

    ReplyDelete
  8. Hello,
    I'm trying to get your script running but I keep getting the following error about a missing perl lib :
    Can't locate VMware/VILib.pm in @INC
    I did a search on CPAN and I couldn't find it
    According to vmware documentation, that lib is supposed to be included into the : vsphere sdk perl, I installed it but still getting the same error?
    also perl -e 'use VMware::VILib;' gives the same error, could you point me please where to get that lib ?
    //using Linux Ubuntu Desktop.

    ReplyDelete
  9. @m0ntassar, You need to install vSphere SDK for Perl or vCLI, it'll handle all the dependencies for you.

    ReplyDelete
  10. Is there any update on @Ashley's query on pre-authenticated VMRC.

    It would really helpful if you can help us on that.

    Thanks ,
    Anand

    ReplyDelete
  11. @Anand,

    As mentioned to @Ashley in Oct 26 reply, this is not possible today.

    ReplyDelete
  12. @William,

    Thanks for your prompt reply..Just like to know whether there are any api exposed to know whether web client server is running inside vcenter ?

    ReplyDelete
  13. @Anand,

    I'm not aware of any since it's separate service but you can always perform an HTTP query to https://[vc-hostname]:9443/vsphere-client and if it responds, then it's running the vSphere Web Client.

    ReplyDelete
  14. William, is there a way to provide end user access to the local resources using only the console window (like we could with the old Web Client), such as the CD/DVD-ROM, the floppy and now USB devices?

    ReplyDelete
    Replies
    1. The below shorcut works to provide the old console like from 4.x for me on 5. This should give you local resource access.

      "C:\Program Files (x86)\Common Files\VMware\VMware VMRC Plug-in\Internet Explorer\vmware-vmrc.exe" -h vsphere5:443 -M vm-400

      Delete
    2. BryanMcC, on a clean install without a previous version of the older Web client with vmware-vmrc.exe, how would you do it? Is there somewhere you are downloading a V5 verison of that plug-in? I did test it on an older 32-bit machine I've been using with versions of VMware ESX as far back as 2.5 and it works there, but not on a clean x64 Windows machine that has never downloaded the old plugin... any thoughts?

      Delete
  15. Hello William,

    I generated URL for the VM. On trying to connect to the VM using the URL(on both Firefox and IE) it is getting redirected to vSphere Web Client. Could you please help me to login to VM console. Also, I have installed client intergation tool (vmware-vmrc-win32-x86.exe)

    Thanks

    ReplyDelete
  16. Hi William,

    the script is working fine for me. Is there a posibillity to call this script from webbrowser and give the arguments like:
    http://localhost/generateVMRemoteConsoleURL.pl?vmname=VM001&vc-server=vCenter... ?

    Thank you!

    ReplyDelete
    Replies
    1. You could either run it like a CGI script, some modifications would definitely be needed or frontend the script with a custom UI. Definitely possible

      Delete
    2. Hi William,

      can you please help me with this script? I am working on it for 2 weeks now, but I am not so good in perl and I don´t get it working. Thanks in advance.

      Delete
  17. Hi William. Do you you know if it's possible to generate a URL for the summaryView of a VM, without showing the vCenter/environnment navigation pane on the left?
    Thanks

    ReplyDelete