I suppose easy is relative.
One of the comments to the post I made about touch free ESXi installs asked about testing without having to reboot and wait for the install process to load, and fail, to determine what went wrong. I did this testing by switching to a different console and using the Python interactive shell to load the same modules VMware uses, call their methods, and simply look at the values returned. By reading their code I was able to determine what the dialogs (the prompts presented to the admin during the install process) return, and the simply return that without the dialog occurring.
From the install screen you can switch to a different console (Alt+F1, if I recall correctly), and then access a command line (you may need to use the “unsupported” trick to get the command line).
The install process is actually quite interesting. VMware is booting, via ISOLINUX, into a full ESXi environment (instead of the standard ESXi yellow and black, they display the install dialogs), asking you which disk you want to use, then formatting that disk with VMFS and copying a virutal machine to the new VMFS volume. They then configure the boot partition to start the ESX kernel and start the ESXi management virtual machine. It’s rather interesting (well, to me) what they are able to accomplish because of the power and flexibility having such a small hypervisor affords them. Not to mention the sheer genius of using their own hypervisor to perform the install of itself…simplicity!
Well, enough fanboyism. From the command line you can do one of two things:
- Create a python script: Use vi to write a python script that imports the modules and functionality that you will need and then execute it to see the results
- Use the python “shell” from the command line: By executing
pythonyou will be in a python “environment” where you can import modules, create variables and execute methods (if you have written python before, this is the normal “interactive” mode…it is very similar to PowerShell’s standard command line). It is extremely helpful to have a second computer where you have VMware’s scripts available as a reference for modules to load and code to try.
I’m not near my development environment at the moment, so I can’t test any code, but here is an example of what could be tried to list the disks available:
ash_prompt -> cd /usr/lib/vmware/installer/ThinESX
ash_prompt -> python
>>> from Core.TargetEnumeration import TargetEnumeration
>>> from Core.TargetFilter import NotPredicate, RACVirtualMediaFilter
>>> from Dialogs.DeviceSelectionDialog import GetDiskTypeFromLun
>>> from Dialogs.DeviceSelectionDialog import HumanReadableSize
>>> targets = TargetEnumeration(NotPredicate(RACVirtualMediaFilter))
>>> for target in targets:
>>> print "Name: %s, Size: %s, Type: %s" % (target.GetName(), HumanReadableSize(target.GetSize()), GetDiskTypeFromLun(target))
>>> print targets.GetConsoleDevice()
This should give you a full list of the disks and some basic information about them. You can get an idea of what can be retrieved about the disks by looking in the
DeviceSelectionDialog.py file, which can be found in
/usr/lib/vmware/installer/ThinESX/Dialogs from the CLI or by unpacking the
install.tgz file found on the install media and looking in the same location.
I’m not terribly familiar with Python’s reflection/introspection capabilities, but a better Python developer than I may be able to use it to determine the full list of methods and properties that are available from the disk objects.
So, compared to making a change, rebooting, then waiting to see what happens, I suppose that hand editing Python is easier. Of course, that’s relative to your opinion of Python.