Archive

Author Archive

Run esxcli Command in a Web Browser: Another ESXi Hack

December 8th, 2013 2 comments

In my recent consulting projects, I really got into a lot of scripting either command lines or Python with ESXi management. As I mentioned the hidden HTML formatter in esxcli command, you may have speculated what could the usage. The answer is simple: Web. But it’s not quite clear how it can be used. That’s where my curiosity started.

Categories: Virtualization Tags: , ,

Lab Automation Made Easy for Training and Testing with VMware Tools for Nested ESXi

December 4th, 2013 No comments

For those who run ESXi on a virtual machine, it’s a great news that VMware has released VMware Tools for nested ESXi as a fling in VMware Labs. Why? With the VMware Tools, you can get guest OS (really the ESXi here) information, like the IP address directly. It may sounds trivial as you can see the IP address from the virtual machine console of a virtualized ESXi. But for automation, it’s pretty hacky to get it programatically. Some people may wonder, “why not run commands via SSH?” It’s true that it’s easy to get the IP by running esxcli command, but you have to get IP first before running the command. With the VMware Tools, you can easily get the IP from vSphere Java API as would with any other normal virtual machines. Even more, you can also run commands like vim-cmd/esxcli in the virtual ESXi via APIs.

Hidden esxcli Command Output Formats You Probably Don’t Know

December 3rd, 2013 No comments

Besides the vim-cmd command I covered earlier, there is another powerful set of commands in ESXi – esxcli. As you can find from the help of the command, it covers 10 namespaces and drills down several layers down. The typical operations with the namespaces are get, set, and list. If you are familiar with REST API, you can think of the bottom level namespaces are resources.

Categories: Virtualization Tags: , ,

Powerful Hacks With ESXi vim-cmd Command, Together With Shell Commands

December 1st, 2013 10 comments

If you have read my previous article on the vim-cmd, you may have realized how handy it is, especially when it comes to manage virtual machines. There is however a pretty challenging problem to use it – for most commands for a virtual machine, it requires vmid which is an integer that uniquely identifies the virtual machine in the context of an ESXi server. It’s like primary key in SQL database to locate a record (virtual machine instance) in a table (virtual machine type). For people who are familiar with vSphere APIs, the vmid is the same as the value of ManagedObjectReference value of a virtual machine in ESXi. Because most administrators who use commands are not necessarily familiar with vSphere API, it doesn’t help much.

Categories: Virtualization Tags: , , ,

vSphere Support Bundle: How to Collect Anything You Want From ESXi, Not Just Logs

November 25th, 2013 No comments

vSphere Client and vSphere Web Client allow administrators to download system logs from different ESXi hosts with choices of predefined groups of information like System, Storage, Network, UserWorld, etc. Under each group, there could be multiple types. For example, under the UserWorld, there are HostAgent and ProcessInformation.

Categories: Virtualization Tags: , , ,

Hacking ESXi For SSH Login Without Password

November 22nd, 2013 4 comments

As a powerful virtualization server, ESXi has a built-in SSH server even though it’s not enabled by default. That is what most system adminstrators use to remotely run commands there. ESXi also has a built-in SSH client so that you can ssh to other servers from ESXi. To use SSH as either server or client, you need to open up firewall. You can use vSphere Client to do it ( on host’s Configuration tab, check out the Security Profile in Software section), or simple with command line as follows.

Categories: Virtualization Tags: , ,

Hacking VMware Private Python API for vSphere with a Quick Sample

November 21st, 2013 7 comments

It’s not a secret that VMware has a private Python API or so called Python binding for vSphere API. If you haven’t heard about it before, no worry. Here is a link to Hostd General Architecture. Somehow it’s not publicly released as a product for customers or partners. Over the years, I only heard a big bank uses it for internal IT automation. But it’s super easy to get it if you want – it’s part of every ESXi installation. Just check it out at /lib/python26-visor.zip if you SSH to your ESXi box. Update: in ESXi 5.5, look at the /lib/python2.6/site-packages.

Categories: vSphere API Tags: , ,

Dummy Virtual Machine For Dummies: How To Create Hundreds of Them with Several Lines of Scripts

November 20th, 2013 No comments

As I introduced in the article on vim-cmd commands, you can use a very simple command as follows to create a new virtual machine. Alternatively, you can ignore the path after the datastore and provide only datastore name (The [ and ] are still needed).

# vim-cmd vmsvc/createdummyvm testVM “[datastore1] testVM/testVM.vmx"

Other than the name and configuration file path in data store, there is no additional information provided such as the size of the disk, memory capacity, etc. Normally, you have to go through a wizard of several pages to create a new virtual machine.

Building Linux Virtual Machine Templates: Tips and Checklist

November 18th, 2013 2 comments

While preparing for my home lab, I have created several virtual machine templates. Here are a few tips I found useful to smoothen the process and make your virtual machine templates easy to be deployed than otherwise.

Install VMware Tools
As you may have known, VMware Tools brings many features to the table, for example,

Significantly faster graphics performance and Windows Aero on operating systems that support Aero
Copying and pasting text, graphics, and files between the virtual machine and the host or client desktop
Improved mouse performance
Synchronization of the clock in the virtual machine with the clock on the host or client desktop
Scripting that helps automate guest operating system operations

Wait, it does not even mention APIs. For Guest APIs in vSphere 5.0 and later to work, you must have VMware Tools installed in your virtual machines.

Agent VM, ESX Agent Manager API, and vijava Support

November 17th, 2013 1 comment

To understand the ESX Agent Manager API, we have to first explain the Agent, which is essentially Agent Virtual Machine. The agent virtual machine can be hardware drivers for your ESXi server, or simply software, i.e, virus scan, that should be deployed on each ESXi. They could have been designed and installed directly on ESXi via VIB, but it would increase the risk of destablizing ESXi due to access to lower level APIs of ESXi. To lower the risk, the driver VM idea came up – if the driver VM crashes the ESXi is still solid even though some service may be affected.

SSH in Python: A Quick Working Sample

November 14th, 2013 4 comments

In one of my recent consulting projects, I had to use SSH from Python. After a little research, I ended up with using the paramiko package as library.

Installing Libraries

To download the paramiko package, just check out this link. What I downloaded was paramiko-1.12.0.tar.gz. After it’s uncompressed with 7-Zip to a temparary directory, just issue the following command and the needed library got installed into the site-packages directory.

1c43cb052923d7a6edb9b65b4c763fca031

VMware ESXi vim-cmd Command: A Quick Tutorial

November 11th, 2013 24 comments

Command lines are very important for system administrors when it comes to automation. Although GUIs are more likely (not always as I’ve seen too many bad ones) to be more intuitive and easier to get started with, sooner or later administrators will use command lines more for better productivity. Check out DoubleCloud ICE if you want the best of both GUI and command lines.

Categories: Virtualization Tags: , , ,

Tools That Enhance PuTTY Experience

November 3rd, 2013 1 comment

PuTTY is a very popular tool on Windows for connecting to remote server using SSH. As I used it a lot recently, I tried several tools that enhance the user experience. You may be interested in them too.

Desert Color Theme to Better Highlight Information

My experience with PuTTY has been pretty good except that the default color scheme does not highlight key information well, for example, the dark blue color for directory names on black background makes it hard for my eyes.

Categories: Applications & Tools Tags: ,

How to Monitor New Changes of Log File with Java

October 30th, 2013 1 comment

If you have a log file that you want to monitor the incremental changes, you can use the following simple code. Whatever new log entries written to the log will be quickly picked up and printed out to console. It does not interfere with the application that writes the log file. To test the code, you can use any text editor to append more entries to the end of log file (don’t forget to save it).

Categories: Software Development Tags: ,

How to Run Maven Based Java Application From Command Line

October 28th, 2013 2 comments

It’s pretty straight forward to run Maven based projects in NetBeans IDE. For some projects that involve console related capabilities, you have to run it from OS console. One example is projects that use the JANSI APIs for colorful console output (see my last post for a sample). If you run the code within IDE, you won’t see the colors as would in a console.

Categories: Software Development Tags: , , ,

Writing Colorful Console Output in Java

October 20th, 2013 No comments

Almost all of the Java console application I had seen were boring black background and white fonts on Windows. This can be changed using a small Java library called Jansi which is open sourced under Apache 2.0. The download link can be found at its project home. The source code is also available on Github here.

Categories: Software Development Tags: ,

Synology NAS: Configure Static IP Addresses, Link Aggregation

October 15th, 2013 1 comment

As mentioned in early article on Jumbo frame, I bought a Synology Diskstation 1513+ NAS server and really like it. The NAS server comes with very rich features that I have just explored partially. One of my favorite features is its GUI which is Web based but feels like a desktop using the Ext Javascript framework. Besides basic functionalities, it also has appstore kind of extensibility. For example, you can install cloud storage to have your own dropbox without exposing your data on public cloud. I haven’t got time to explore all these yet, but will try them later.

Parsing Command Line in Java

October 10th, 2013 2 comments

If you develop a command line tool, you would probably need to parse options and arguments. In Java, you can use Apache Commons CLI to handle the parsing. Since I don’t write much command line program, I don’t need these tools. While reading vCO API sample, I found one command line tool called args4j which is written by Kohsuke Kawaguchi who had created the famous Hudson/Jenkins server.

How to Add Copyright Notice in JavaDoc

October 8th, 2013 1 comment

While using Netbeans IDE to generate Javadoc for a Maven project, I noticed the generated pages has a default copyright notice at the bottom of every page, say “Copyright 2013. All Rights Reserved.” Because it’s default, it does not show the name of copyright owner. To change it, I found it’s not really straight-forward, therefore it may be worthwhile to share it.

What’s New in VMware vSphere 5.5: Management APIs

September 30th, 2013 No comments

After downloading the vSphere 5.5 SDK GA release last week, I started to look into the API reference immediately. Because I am pretty familiar with previous versions of vSphere APIs already, I just jumped directly into the “New and Changed Managed Object Elements in 5.5” page (there is a link on the home page of API Reference) as I had to work on the open source vijava API 5.5 which was released as beta last Friday.

Categories: vSphere API Tags: ,