WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple

Identifying Idle vCenter Sessions

12.20.2011 by William Lam // 4 Comments

I recently received a question on how to identify idle vCenter sessions that may stem from a non-active vSphere Client or vSphere API connection. Properly managing sessions to your vCenter Server is as important as knowing who is logging in. If you exhaust the maximum number of connections, you can easily deny login access to other users and/or services that are needed to connect to vCenter Server which can lead to very bad things. In the worse case, you can even prevent administrators from logging into a new session to help terminate any stale/idle connections.

The vSphere API provides a sessionManagement manager to help you manage all sessions, including checking whether a session is still active and terminating a session. I wrote a quick vSphere SDK for Perl script called sessionManagement.pl which allows you to list all sessions for a given vCenter and terminating a a specific session. Every session has a unique sessionKey that the vCenter Server uses to track and it provides information such username, login time and last active which can be used to create an unattended script to automatically terminate sessions that have gone beyond a certain threshold.

Here is an example script output of performing the "list" operation:

Note: There maybe vCenter Plugins/Extensions that creates sessions such as CapacityIQ, those will be denoted by "vCenter Ext Session" field. These should not be terminated as it can negatively impact 3rd party applications.

Here is an example script output of terminating a specific session using the "disconnect" operation which you will need to specify sessionkey provided in the previous command:

For those of you that are interested in creating your own script to terminate idle sessions, you can use the DateTime Perl module to help with calculating the amount of idle time and comparing that to a pre-defined timeout value.

Categories // Uncategorized Tags // idle, session, vsphere sdk for perl

Ghetto webAccess for ESXi

12.12.2011 by William Lam // 14 Comments

I got the idea for this post a few months back after noticing several questions on the VMTN forums on how to enable webAccess for ESXi. With ESXi, the webAccess interface is no longer available as it was with classic ESX. After seeing the question and randomly browsing through the various flings on VMware Labs, I noticed an interesting fling called Ops Panel for ESX. Ops Panel provides a simple javascript that leverages the vSphere MOB to perform basic power operations for virtual machines and it is loaded onto the homepage of a classic ESX host remotely using Greasemonkey.

I immediately wondered if I could run the javascript directly on an ESX or ESXi host without the use of Greasemonkey. With a quick tweak of the default index.html homepage, I was able to get a simple "ghetto" webAccess running on both an ESX and ESXi host. I also ran into several bugs, one that dealt with how the power state of a virtual machines was being captured by the differences in the ESX(i) 4.0, 4.1 and 5.0 APIs and a recent fix to a CSRF (Cross-Site Request Forgery) vulnerability in ESX(i) 4.1 Update 1 that made it difficult to get Ops Panel running on more than just ESX(i) 4.0.

I reached out to the fling creator Ivan Donchev and he was kind enough to help assist me in the issues I ran into and also provided an updated version of his script to properly handle both the power state and the CSRF workaround. He recently published an update to his script a few weeks back supporting both ESX 4 and ESXi 5 but missed ESX(i) 4.1 support due to limited amount of testing. This was an easy fix and I modified the script to include support for ESX(i) 4.1 and also changed the default power off operation to a guestOS shutdown. The modified version of the script can be downloaded here.

When you browse to the homepage of your ESX(i) host using the browser, you will be prompted to login which require the same credentials as if you were to login to the host directly using the vSphere Client or vSphere MOB.

Once you have logged in, it will search for all virtual machines running on the host and generate the list of virtual machines and their respective power states.

You can then perform the appropriate power operation such as a power on, shutdown or suspend using the icons on the right. This can be really useful if you don't have access to vCenter Server, vSphere Client or SSH access to the host but just have a web browser.

To load the Ops Panel script on an ESX(i) host, you will need to do the following:

Note: These instructions are applicable for both ESX and ESXi, but with ESXi, it is important that the commands to copy both the modified index.html and Ops Panel script to docroot are executed as changes are not persisted after a reboot for ESXi hosts.

You can also add this to your kickstart file by appending the lines above in your %firstboot stanza so you automatically get Ops Panel after install. Though this will not give you a full webAccess that classic ESX did but it definitely is a useful way to quickly get to your virtual machines and perform simple power operations using a web browser.

Categories // Uncategorized Tags // ESX 4.0, ESX 4.1, ESXi 4.1, ESXi 5.0, kickstart, mob, web access

Leveraging vCD + vCO + Wavemaker Part 2

12.09.2011 by William Lam // 3 Comments

Continuing from our previous post Leveraging vCD + vCO + Wavemaker Part 1, I am now going to show you how to integrate the vCenter Orchestrator workflow we created earlier into Wavemaker to present a simple web application to an end user. If you can not wait to go through all the steps, jump to the bottom for the video of the final product.

You will need to download Wavemaker 6.4.3 RC versus the 6.3.3 GA because there is a specific UI feature that I have utilized to provide a better user experience. You will need to register for a free account to download the development builds and I have been told 6.4.3 should GA pretty soon.

Once you have downloaded Wavemaker, you will need to install it on your system and you maybe asked to perform an additional library download, just follow the instructions and you ready to create your first Wavemaker application. After the installation, go ahead and start the Wavemaker application and it will automatically launch a web browser which will be your workspace. You will need to use either Firefox or Internet Explorer, as it does not work with Chrome.

In case you get lost below or would like to just get this working right away, I have exported my project and it can be downloaded it here. You can simply import the .zip file and make the necessary changes to the project to fit your environment.

Start off by creating a new project and give your project a name and just use the default theme and then click ok.

Next, at the top screen click on "Services" and then "Web Service" since vCO is exposed as a webService API which we will import into Wavemaker.

We need to specify the URL of your vCO server, it should be in the following format:

http://vco.primp-industries.com:8280/vmware-vmo-webcontrol/webservice?WSDL

and then provide a name for your service, in the example, I named it "vCOReference".

Once the vCO service has been imported, click on "Canvas" and then "Palette". We will now add widgets for our web application. Add the following in this order: Picture (if you wish), Text, Button and Grid. It should look something like the following:

Most of these should be pretty self explanatory widgets. The Grid (dataGrid) is used to display your data result.

If you decide you would like to add a logo/banner, click on the "Source" tab at the top and then click on "Resources". Here you will be able to add any additional resources to your project such as a images.

Once you have uploaded your image, select the picture widgets in your canvas and click on "source" icon to the right side of the screen. Here you can now bind to the image you just uploaded and click "Bind", there is also a green icon on the upper right hand corner to show you whether or not the binding is the proper type.

You should see the image being displayed in the picture widget.

Now click on the Text widget in your canvas and go ahead and provide a name for the variable and also a caption which is located on the right side of the screen. In the example, I named both fields "username", you can provide a different name but be sure to keep track of the variable name as it is used later on.

If you recall earlier, I mentioned I am using a specific UI widget that requires Wavemaker 6.4.3 RC, which is the LoadingDialog widget and allows us to display a busy dialog for various events. This is just one of the many features in 6.4.3 release. Go ahead and add this to the canvas and it is under "Dialogs". We will also configure the "widgetToCover" and specify "dojoGrid1" which is just the name of our dataGrid.

Next we will need to add several variables that will call the vCO services and store our results. To add these new variables, you will click on the "Insert" option at the very top. It is also helpful to be in the "Services" tab next to "Model" to see the variables that have been created in your navigation pane.

The first variable that we will add is called "varResult", this will be a regular variable that will be used to store our results. Make sure the following properties on the right side of the screen are set:

  • name = varResult
  • type = StringData
  • isList = checked

The second variable to be created will be a "Service Variable" and will named "getResult" which will retrieve the results from vCO using the getWorkflowTokenResult API method. Make sure the following properties on the right side of the screen are set:

name = getResult
servcice = vCOReference
operation = getWorkflowTokenResult

The third variable will be a "Timer" variable which is located under "Advanced" and will be named "resultTimer". This is needed as the results are not available immediately after executing the workflow and we set a 3sec timer to then retrieve our results.

Make sure the following properties on the right side of the screen are set:

  • name = resultTimer
  • delay = 3000 (in MS, you may need to tweak this based on your env)
  • repeating = unchecked

We will also need to specify the action to trigger when the timer fires, this is defined under "Events" for the resultTimer variable. Set the onTimerFire to "getResult" Service Variable that we defined earlier. When the timer goes off, it will retrieve the results of our workflow

The fourth and final variable that we will need to add is also a "Service Variable" which will execute the workflow by calling the executeWorkflow API in vCO. We will name it "runWF". Make sure the following properties on the right side of the screen are set:

  • name = runWF
  • service = vCOReference
  • operation = executeWorkflow

Now we need to bind our parameters which will be used to provide input to the various variables and/or vCO API methods.

The first one will be the "getResult" variable and you will need to expand down to "parameters" on the right side of the screen. Here you should see three parameters which will need to be populated: password, username and workflowTokenId.

Click on "username" and then a new window will pop-up. Select "Expression" and then select "username" and provide the username that will be used to connect to vCO and ensure there are double quotes around the string and click Apply when finished.

Click on "password" and do the same exact thing and provide the password that will be used to connect to vCO and click Apply when finished.

Click on "workflowId" and instead of selecting "Expression", select "Simple" and drill down into the "runWF" Service Variable and select "id". As part of the executeWorkflow return object, a WorkflowTokenType is returned and the "id" property is what is needed for us to retrieve the results of the workflow. Click "Bind" to finish the parameter binding for this service variable.

Note: There is a green box on the upper right hand of the screen which validates the property binding type, this can be helpful when binding parameters.

After you have finished binding those three parameters, you should now see the following:

Lastly for this service variable, we will also need to create an event trigger. Select "onResult" and click on "Javascript" which will allow us to insert some javascript logic upon the result of the data.

You will now be taken to the "Source" tab and a new javascript function will automatically be created for you called "getResultResult" assuming you have followed the naming standards in the example. You will need to add the following lines of javascript to the function:

The script clears any previous output on the dataGrid and then retrieves the data which is returned as a single string and replaces all the characters we do not want. It then splits using the ";" as the delimiter and adds each entry to our dataGrid.

Once you have pasted the javascript, go ahead and click back on the "Cavnas" tab. In addition to the first even trigger, we will also set "onSuccess" to loadingDialog1.hide which will hide the busy dialog after the results are available to be displayed on the dataGrid.

Now we need to configure the event triggers for "runWF" service variable. The first is "onBeforeUpdate" and we will set that to loadingDialog1.show which will display the busy dialog while the workflow is being executing. The second will be "onResult" and that will be configured to call the "resultTimer" timer variable and retrieve our results after the workflow has been executed.

Next we will need to configure the "submit" button event and we will again create a custom javascript which will call our "runWF" service variable.

Note: This technically could have been easier to bind to the parameters of the "runWF" service variable, but I found a bug that prevented this from working. A work around was provided by Michael Kantor, a Wavemaker developer and the bug has been reported and hopefully will be fixed before the GA version of 6.4.3 is released.

You will need to add the following lines of javascript to the function:

Here you will need to substitute the username/password to your vCO server and the workflowId which can be obtained by following this blog post. The workflowInputs requires the name of the workflow input variable name and assuming you followed the previous article, you can keep the same name and "this.username.getDataValue()" will extract the string from the username text widget you added. If you changed the name of the variable, you will need to update this accordingly.

Okay, we are almost there. The last widget we need to add an event trigger to is the dataGrid and for "onClick" we will also create a new javascript.

You will need to add the following lines of javascript to the function:

This single line of javascript will open a new window when a user clicks on one of the dataGrid cells.

Now lastly, we just need to bind our dataGrid to our "varResult" variable that contains the results. Select the dataGrid widget and click on "dataSet" and bind to "varResult" and ensure you see a green icon on the upper right hand side of the window.

You can also name the column header, by default it is called "DataValue" and you can change it to "orgUrls" if you like. To do so, right click on the dataGrid and select "editColumns".

We are all done now! We just need to compile the application by click on the "Run" icon at the very top. After the application compiles, it will open a new window to your new Wavemaker application.

Here is a quick video demonstration of the application using:

Leveraging vCD + vCO + Wavemaker Part 2 from lamw on Vimeo.

So there you have it, creating your own custom web portal application using Wavemaker, vCenter Orchestrator and vCloud Director vCO Plugin! As you can see the possibilities are endless and with a little javascript knowledge, you can create any type of portal that goes beyond just VMware products!

I would like to give a big thanks to Christian Johannsen, Michael Kantor and especially Craig Conover in assisting me with creating my first Wavemaker application. These guys are truly rock stars with vCO and/or Wavemaker! For more information about Wavmeker, definitely check out documentation/examples and the Wavemaker community forums.

In addition, there are some other great examples of utilizing Wavemaker written by my colleagues:

  • Hany Michael - Eating My Own Dogfood: SpringSource + WaveMaker + vCloud APIs + Cloud Foundry + vCloud Director
  • Massimo Re Ferre - vCD Custom Portals and Backend Integrations in a Service Provider Environment

Categories // Uncategorized Tags // orchestrator, vcd, vcloud director, vCO, wavemaker

  • « Previous Page
  • 1
  • …
  • 500
  • 501
  • 502
  • 503
  • 504
  • …
  • 560
  • Next Page »

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025