Archive

Archive for March, 2011

VMWare SRM – real life disaster (Japan Tsunami)

March 31st, 2011 No comments

Christopher Wells is an IT professional working in Japan – most recently, he was there when the Earthquake / Tsunami and now Nuclear issues appeared.

As part of the recovery for these disasters, he actually had to invoke SRM and has posted about it here:

http://blog.christopherwells.com/english/2011/3/23/real-life-dr-bc-with-vmware-srm.html

This is a good post, demonstrating real world use and value of SRM – so it is worth the read. – though not the real point of this post.

I have actually been thinking about this disaster a lot lately, and can not imagine what people over there are going through – last I read . there are still tens of thousand of people missing – I can not imagine the pain. Even worse, people are basically running ‘Kamikaze’ missions trying to cool the Fukushima plant!

I can do little to help and I know this is off topic for my blog – but please consider doing a small fundraiser and donating to one of the many charities collecting for the disaster fund.

Charity navigator has compiled a list – that will allow you to figure out which charity is best to donate to – please consider donating a few pounds / dollars etc:

Donating to Japan relief funds

http://www.charitynavigator.org/index.cfm?bay=content.view&cpid=1221

Charities Providing Relief Rating Commitment To Use All Designated Funds For Japan
American Jewish Joint Distribution Committee 4 stars
Yes
AmeriCares 4 stars
Yes
Architecture for Humanity 4 stars
Yes
Brother’s Brother Foundation 4 stars
Yes
Catholic Medical Mission Board 4 stars
No
Direct Relief International 4 stars
Yes
Doctors Without Borders, USA 4 stars
No
Food for the Hungry 4 stars
Yes
International Rescue Committee 4 stars
Yes
Matthew 25: Ministries 4 stars
Yes
Medical Teams International 4 stars
No
National Disaster Search Dog Foundation 4 stars
No
Operation Blessing International 4 stars
No
Relief International 4 stars
Yes
Save the Children 4 stars
Yes
Stop Hunger Now 4 stars
No
United States Fund for UNICEF 4 stars
No
World Vision 4 stars
No
American Red Cross 3 stars
No
GlobalGiving 3 stars
Yes
International Medical Corps 3 stars
No
Mercy Corps 3 stars
Yes
Operation USA 3 stars
No
Samaritan’s Purse 3 stars
No
ShelterBox USA 3 stars
No

 

Post a comment and proof of your donation on here and I will match the highest donation (up to a value of £200)

 

Categories: Uncategorized Tags:

Using regular expressions to parse files in PowerShell – Script of the Day

March 28th, 2011 No comments

How often do you find yourself needing to identify a string in a file somewhere.

For example, you have a log file, or a config file and you know it contains an IP address, but you do not want to manually trawl through this file (or even worse . . these files)

Regular expressions are pretty handy, as you can use them to identify (and edit) strings of text pretty simply. thik of it as a Replace function on steroids.

Here are some examples:
http://www.regular-expressions.info/quickstart.html

Anyway, back to our original question – we’d like to find an IP address in a file.

The first thing of course is to get hold of the text in our file – we’ll drop it into an array, so we can do a line by line comparison..

 
$var = @(Get-Content .\Access*.log)

Next, we need to create a Regex string pattern, which we will use as reference when we query out text – there are plenty examples available on the web (e.g. http://www.regular-expressions.info/examples.html) – but we just need one to find IP addresses:

 
$regex = [regex] "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"

Lastly, we simply need to return a list of elements in our array, where the array matches the REGEX search string – again simple:

 
$regex.matches($var) | Select-Object -unique -property "Value"

so the full bit of code:

 
$var = @()
$var = Get-Content .\Access*.log
$regex = [regex] "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
$regex.matches($var) | `Select-Object -unique -property "Value"

Value
-----
206.13.132.82

Upgrading ESXi without VUM / From the Cli

March 24th, 2011 No comments

It seems that VMWare are getting rid of VUM (I assume something new will be released soon to replace it), so more and more people are going to need to manage ESXi upgrades from the command line.
I suspect that the people that will be most affected by this are people running the free version of ESXi.

Anyway, here is a quick how to, for ESXi upgrades.

First enable ssh access to the ESXi4.0 box. – (more info here)

At the ESXi console:
1. alt-f1
2. Type unsupported (You will not see your typing)
3. root pw
4. vi /etc/inetd.conf
5. uncomment the 2 ssh lines, i.e delete the “#” preceding the ssh config lines (esc x to delete a character in vi)
6. :wq to save the changes in vi and quit the vi editor
7. services.sh restart (if necessary reboot the ESXi box if ssh still does not work)

If you are running ESX4.1, follow this guide to enable SSH access to ESXi4.1 Host
(again at the console)

1.Press F2 to Customize System Settings
2.Navigate to Troubleshooting Options
3.Select ‘Enable remote Tech support (SSH)

Note – you can also adjust the tech support timeout here – so you could limit how long tech support stays enabled for.

Next, you will need to download your upgrade bundle from VMWare –

You now have 2 Options,

Run the installation – Option 1 – from a webserver
If you are able to store the upgrade bundle on a webserver, you could do the following:
Place the file upgrade-from-ESXi4.0-to-4.1.0-0.0.260247-release.zip at the root directory of your web server.
I use Apache Tomcat 7.0 on Windows XP to host the file upgrade-from-ESXi4.0-to-4.1.0-0.0.260247-release.zip
Ensure the Windows Firewall allows access from external hosts to your web server (In the case of Apache Tomcat, I had to open port 8080)
VMotion all the VMs off of you host, or Shut down all VMs, and put the host into maintenance mode.
SSH to your ESXi4.0 box and at the CLI type:
esxupdate –bundle http://ipaddress:8080/upgrade-from-ESXi4.0-to-4.1.0-0.0.260247-release.zip update (Of course this value will change dependent on your filename)
The zip file will be downloaded from your web server and installed. Reboot the ESXi server when prompted.

Run the installation – Option 2 – from a local instance of the upgrade bundle
If you do not have a web server handy, you could copy the bundle locally on the ESXi host. – or even on a shared datastore accessed by multiple ESXi hosts if you have shared storage.
Using FastSCP(my preference, but any SCP style tool will work e.g. WinSCP) – Copy the upgrade bundle to the ESXi host(or shared store)
VMotion all the VMs off of you host, or Shut down all VMs, and put the host into maintenance mode.
SSH to the host (I use putty, but any SSH tool will work)
From the command line of the host, execute the command: esxupdate –bundle /vmfs/volumes/<datastorename>/<myfolder>/upgrade-from-ESXi4.0-to-4.1.0-0.0.260247-release.zip update
The zip file will be extracted and installed

Reboot the host
Reboot the host when done. Once that’s complete, take the host back out of maintenance mode, and power on the virtual machines.
You’ll possibly have new VMtools available, so upgrade these.

If your host refuses to start up and you are having issues, you should be able to revert to your previous installation by hitting Shift-R as the host boots up.

Categories: VMWare Tags: ,

Finding VMs with disks on multiple different datastores – Script of the Day

March 23rd, 2011 No comments

I was looking at a VM on one of our hosts and noticed the rather odd configuration showed that the VM had 2 disks provisioned (not unusual), and that the 2 disks had been presented on different storage (very unusual for non clustered VMs in our environment)

I figured, the easiest way to identify all of the VMs that are using VMDKs on multiple different datastores was PowerCli.

The result – just a one liner.

PS:7 >get-vm | ?{$_.DatastoreIdList.count -gt 1}

Name                 PowerState Num CPUs Memory (MB)
----                 ---------- -------- -----------
labserver001     PoweredOn  1        8192
labserver 17a         PoweredOn  2        1280
labserver21        PoweredOn  1        8192
labserver17b         PoweredOn  2        1152

Powershell – (Get-virtual).info – RSS Capture with Powershell through a proxy

March 22nd, 2011 No comments

a little geekery . . .

As the blog is called ‘Get-Virtual’  . .I figure we may as well have a cmdlet / function to allow us to actually get the content of get-virtual . . . so I quickly put together an RSS reader to capture the RSS feed for the blog and export it to a GridView

The function is not entirely useless, as it will demonstrate 6 new things
1 – Using Powershell to get info from the web
2 – Accessing the web from Powershell through a proxy
3 – Authenticating through the proxy using Powershell
4 – Reading an RSS feed using Powershell
5 – Exporting a Powershell object to a GridView
6 – Reading / Parsing XML using Powershell

Exporting the info captured into a GridView makes it easy to filter the data and view what the latest posts etc are.

I have hashed a little ‘replace’ code out in the script as several of the older Get-virtual.info posts had special characters that get misinterpreted . . so you could remove the hashes to clean this up if you really wanted.

here is the code:

function get-virtual 
	([string]$proxyserver = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"  | %{$_.ProxyServer}),
	[switch]$auth, 
	$proxycred)
	{	$proxy = new-object System.Net.WebProxy $proxyserver
		If ($auth)
			{if (!$proxycred) 
			{$proxycred = Get-Credential}
			$proxy.credentials = $proxycred.GetNetworkCredential()
			}
		$WebClient = New-Object System.Net.WebClient
		$webclient.proxy = $proxy
		$WebClient = Get-WebClient
        $blog =  1$Webclient.DownloadString("http://feeds.feedburner.com/PsCget-virtualinfo")
		$obj = @() # New-Object psobject
		for ($i=1; $i -le $blog.rss.channel.item.count; $i = $i + 1)
		{
		$rep = "" | select "Title", "Link", "Creator", "Date"
		$rep."Title" = ($blog.rss.channel.item[$i].title)#.toString().replace("`â`€`“","-").replace("`â`€`˜","`"").replace("`â`€`™","`"")
		$rep."Link" = ($blog.rss.channel.item[$i].Link)#.toString().replace("`%e2`%80`%98","`'").replace("`%e2`%80`%99","`'").replace("","")
		$rep."Creator" = $blog.rss.channel.item[$i].Creator
		$rep."Date" = $blog.rss.channel.item[$i].PubDate
		$Obj += $Rep
		}
		$obj | Out-GridView -Title "Get-Virtual.info Fat(ish) client"
		return $obj
	}

	

and here is the result:

How to Migrate and Convert Physical RDMs

March 21st, 2011 No comments

Ken Gottleib, the Principle Virtualization Consultant at Winchester Systems, Inc. USA recently posted the following very useful bit of info over on the VMWare communities site.

I quickly dropped him a note and asked for permission to duplicate his work, as I have had this same issue before and never documented the process properly.

“This is what you need to do, fully explained the way each and every post should be. You must power the VM down to do this, there is no way to do it live. Period

1) log into ESX console as root
2) navigate to your virtual machine folder: /vmfs/volumes/vmfs-volume-freindlyname/vm-folder/
3) locate the pointer file for your disk, this is not the -rdmp file, this is the servername_1.vmdk, it is only a few KBs, inside it does nothing but point to the actual disk file, which in this case will be the servername_1-rdmp.vmdk. It is this servername_1-rdmp.vmdk file that maps IO to the actual lun which is always represented by ESX as something like vml.xxxxxxxxxxxxxxx and can be viewed in /vmfs/devices/disks/

The source you are looking to migrate (with this method it is actually a copy which is good, because the source is always left intact) can be a virtual disk, virtual rdm, or physical rrdm, it doesnt’ matter, you will always use the servername_x.vmdk file as the source in the command string you are about to see… but before I continune, if you want to migrate from physical compatibility mode lun to a new physical compatibility mode lun, be sure to have provisioned the lun so ESX can see it. If you are to convert the physical mode RDM to virtual RDM, the same applies. If you are to convert it to virtual disk, just be sure you have a vmfs volume with enough space to accomodate the new disk.

4) here it is:
To migrate and convert physical RDM to virtual disk:
vmkfstools -i servername_1.vmdk /vmfs/volumes/vm folder/servername-newdisk_1.vmdk
To migrate and convert physica RDM to virtual RDM, there are two methods
– in vi client edit VM settings of powered down VM, remove rdmp mapped disk, then re-add a new hard disk selecting the same disk only be sure to select virtual as the mode, you will log in and see all of your data and mount points are unchanged.
– from the ESX prompt in the virtual machine folder on the VMFS volume:
vmkfstools -i servername_1.vmdk -d rdm:/vmfs/devices/disks/vml.xxxxxxxxxxxxxxxxxxxxxxxx /vmfs/volumes/vm folder/servername_1-rdm.vmdk
To migrate physica RDM to a new physical RDM:
vmkfstools -i servername_1.vmdk -d rdmp:/vmfs/devices/disks/vml.xxxxxxxxxxxxxxxxxxxx /vmfs/volumes/vm folder/servername_1-rdmp.vmdk

Command strings EXPLAINED:
vmkfstools -i is the import \ clone command
the servername_x.vmdk is the source, the x will stand for the order of the device, in my example I use 1 which means this is the second disk on the VM. the first disk file is servername.vmdk, this is typically always the system disk.
the -d is the disk type for the destination you are converting to
the rdm(p) is part of the disk type telling the destination disk what the raw disk mode is, virtual or physical (the p means physical obviously)
the /vmfs/volumes/vm folder/servername_1-rdm.vmdk tells us the location of where to store the raw disks mapping file, I have chosen to put it in the virtual machine folder as you can see, you can put it on any vmfs file system, I like to keep things neat and clean.

Figuring out which vml.xxxxxxxxxxxxxxx is tricky.. I the ls-lh command on the /vmfs/devices/disks/ directory to list the unfriendly volume names out and figure out which one is mine by the LUN size, there are other ways to do this, there is a VMware KB article that describes other ways to dump out this information. and in some cases, depending, there may be a partition involved and it would look like vml.xxxxxxxxxxxxxxxx:1 or :2 or whatever.. vmware’s KB references it as vml.xxxxxxxxxxxx:p
you can also use vmhbax:x:x: in the string as such: /vmfs/devices/disks/vmhbax:x:x:p to represent the raw LUN
check out this article, it has what you need, but not everything.. the example they use for the disk is naa.xxxxxxxxxxxxxxxxx and I believe this is because there is different storage in use then I have… SO, be sure to navigate to /vmfs/devices/disks/ to see how vmware lists out the disks as the storage presents them
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=3443266

Hope you find this useful, don’t let anyone tell you that you can’t migrate a physical RDM. Its bogus information. This is how its done.”

Categories: VMWare Tags:

Identifying SAN disk usage using WMI – Powershell – Script of the Day

March 11th, 2011 No comments

So I was commissioned with identifying the amount of actual disk space used by a bunch of Microsoft Servers that were attached to various SANs on our network. Unfortunately, despite us having a rather expensive vendor supplied product for doing this reporting, the vendor product(s) is/are dependent on agents running on the servers to actually report back what the performance stats look like.

I fugured that the information must be accessible via WMI so I set about trying to identify something that identified disks as being remote / SAN attached.

I had a crack using several different WMI classes, thinking that I may need to tie the results from a hardware based query to identify physical disks, against the results of something like the win32_logicaldisk class – but was drawing a blank.

to identify similarities / differences betwen hosts I decided to just spit our the results of the Disk / Volume classes for a handful of hosts

I tried the following classes:
win32_logicaldisk
win32_DiskDrive
Win32_Volume

After interrogating a few hosts (some SAN attached, some not . I noticed a similarity in the device IDs returned in the following class win32_Volume.

you see all of our servers are set to have local disk for the C: and CDROM for the Z: (so I had a control group)
Executing the following however . . against a LONG list of server seemed to always return C: and Z: with device IDs in the format:

\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-806e6f6e6963}\

Now I have looked around for an explanation as to why all the Local Disks and Local CD Roms appear with tat number at the end, but I can find no confirmation – but I figured I’d simply create a PowerShell script using this snippet of info to generate the report I require.

First of all, the wmi query that I would need :
gwmi -ComputerName <servername> -class win32_volume | select deviceid, driveletter

Now all I need to do is contruct a method to repeat the above and churn out a nice Excel style report to show disk utilisation . .

Here is the result



Function get-sandisks ([string]$InputFilename,[string]$OutputFilename)
{
$servers = gc $InputFilename

$MyObj = @()
# Cycle through the servers in the file
foreach ($server in $servers)
{Write-Host $server -ForegroundColor Green
# first test if we can ping the server (quicker than trying WMI straight away)
If (Test-Connection $server -Count 1)
{
if (Get-WmiObject -ComputerName $server Win32_LogicalDisk -ea 0)
{$disks = gwmi -ComputerName $server -class win32_volume | ?{$_.driveletter} #| ?{$_.deviceid -notmatch "806e6f6e6963"} #| select deviceid, driveletter
If ($disks)
{foreach ($disk in $disks)
{
$rep = "" | select "Server Name", "Drive Letter", "Disk Space", "Used Space", "Free Space", "DeviceID", "Type"
$Rep."Server Name" = $server
$Rep."Drive Letter" = $disk."driveletter"
$Rep."Disk Space" = $disk | %{$_.Capacity}
$Rep."Free Space" = $disk | %{$_.Freespace}
$Rep."Used Space" = $Rep."Disk Space" - $Rep."Free Space"
If ($disk.deviceid -notmatch "806e6f6e6963"){$rep.Type = "SAN"}
Else
{$Rep.Type = "Local"}
$Rep."DeviceID" = $disk | %{$_.deviceID}
Write-Host $rep
$MyObj += $Rep
$rep = $null
}
}
}
Else
{
$rep = "" | select "Server Name", "Drive Letter", "Disk Space", "Used Space", "Free Space", "DeviceID", "Type"
$Rep."Server Name" = $server
$Rep."Drive Letter" = "WMI"
Write-Host $rep "WMI" -ForegroundColor Yellow
$MyObj += $Rep
$rep = $null
}
}
Else
{              $rep = "" | select "Server Name", "Drive Letter", "Disk Space", "Used Space", "Free Space", "DeviceID", "Type"
$Rep."Server Name" = $server
$Rep."Drive Letter" = "PING"
Write-Host $rep "PING" -ForegroundColor Yellow
$MyObj += $Rep
$rep = $null
}
}
$MyObj | sort | Export-Csv -Path $OutputFilename -NoTypeInformation
}

While I appreciate that this is  not 100% accurate, I simply wanted to report on space that is in use by the SAN and is no local disk, so the result is fit for my purpose.

Copying data to/from a VM datastore using PowerCli – Script of the Day

March 8th, 2011 No comments

Ever needed to copy data from your local machine to a VMware datastore . .and not felt like messing around with winSCP / FastSCP, the Datastore browser etc?

PowerCli / PowerShell lets you create a new PSProvider item for your datastore, which in turn lets you copy data using the normal Copy-Item syntax. (though using Copy-DatastoreItem instead)

So, if you have a Datastore in your ESX environment called ‘Datatstore1’ and you want to copy an iso from your C:\ISO directory, it would be as simple as

PS: >new-PSDrive -location (get-datastore 7523_local) -name myds -PSProvider VimDatastore -Root '\'
Name           Used (GB)     Free (GB) Provider      Root                                               CurrentLocation
----           ---------     --------- --------      ----                                               ---------------
myds                                   VimDatastore  \lonlab001@443\Prod\7523_local
PS: >Copy-DatastoreItem -item C:\ISO\install.iso -Destination myds:\ISOS\Myiso.iso -force

Also, as the drive is now a normal PSProvider path, normal commands like get-childitem work like they do on a local drive

PS: >gci myds:
   Datastore path: [7523_local]

            LastWriteTime            Type       Length Name
            -------------            ----       ------ ----
     21/04/2010     07:40          Folder              esxconsole-4bcdbd...
     08/03/2011     16:31          Folder              ISOS

Genius,

Of course this gives you full access to all of the datat on your datastores directly form a PowerCli session, so you can run any sort of reports / inventories etc that you may need. Happy days . .

‘Upgrading’ from ESX to ESXi – a multipart series – Part 2b – Installation – ESX Deployment Appliance (EDA)

March 4th, 2011 No comments

Intro

Tools

Part 2 -Installation Options

Part 2a – V-PXESERVER

Part2b – ESX Deployment Appliance

‘Upgrading’ from ESX to ESXi – a multipart series – Part 2a – Installation – V-PXEServer

ESX Deployment Appliance (0.90 in Marketplace, but 0.95 available at: http://virtuall.eu/downloads/ – this got updated from 0.94 while I was typing this page up)

Setting up of this is quite simple.

You can find a video of the process here:

  1. Download from either Appliance store, or above link
  2. Extract contents of Zip file locally
  3. If you want to run this on ESX / ESXi, you’ll need to convert the vmdk from workstation to ESX / ESXi.

3.1.    Copy contents of zip to a Datastore  (Use WinSCP, or Veeam FastSCP or similar)

3.2.    Using Putty, I connected to an ESX host that has access to the Datastore that the files are stored on and browsed to the Folder path /vmfs/volumes/<datastore>/EDA

3.3.    import  the vmdk from workstation to ESX format file using vmkfstools

3.3.1.   vmkfstools –I ./Eda-v0.94.vmdk ./Eda-v0.94_new.vmdk (Interestingly, this changed the size from 407MB to 1048MB ?

3.4.    Next, I renamed the original vmdk to Eda-v0.94.vmdk.old, and the new one to Eda-v0.94.vmdk

3.4.1.    mv ./Eda-v0.94.vmdk ./Eda-v0.94.vmdk.old

3.4.2.   mv ./Eda-v0.94_new.vmdk ./Eda-v0.94.vmdk

  1. For 0.94 To import the host to VC was now as simple as right clicking the .vmx file using the datastore browser / local browser and selecting ‘import’ then following the wizard. (I know I could have done this from the command line, I was lazy) (If you’d gotten a version that had an OVF file, you’d simply need ti use the ‘Import OVF’ wizard for this) – 0.94 has been configured as an OVF(appliance) , so you can import it the same way all appliances are imported.
  2. The 0.94  VM started with a NIC, but no CDRom (which we’ll need) – I therefore added a CD-ROM so I can attach ISO etc later. As the Vm was imported form Workstation on the ESX installation, we are unable to edit the NIC settings, so I also removed the existing NIC and added a new NIC. (no problems if running on workstation)
  3. Start the appliance
  4. Click on reconfigure to edit the network settings (this will be the IP for the appliance and the web URL you’ll use to do further configuration) – Fill in you information and click on OK to save the settings.
  5. Now you can logon to the EDA to configure the boot options
    Open Internet explorer on a host that has access to the VLAN that you configured the EDA on  and go to the site (The IP address that you configured above)
    Credentials are u: root – pw : root
  6. Once you have loaded the webpage, you’ll need to mount the ISO for the version of ESX(i) that you will be trying to deploy (Select the Appliance VM, edit the CDRom settings and select ‘local ISO’ and connect the ISO for the version of ESX(i) that you are going to install
  7. Once the CD is mounted to your appliance, at the top of the screen on the WebPage, select ‘Import PXE BootFiles” – watch the screen and make sure it deploys successfully. (at this point I had a few problems as my CD was not recognised) – I selected the ‘Patch’ option form a browser, then in the ‘Execute command’ box typed “ln -s /dev/sr0 /dev/scd0” – this mounted the CD. (You could also on the EDA appliance hit Alt-F2, then authenticate and do it from there after login – the ‘CD not Mounted’ message should change to ESXi CD mounted)
  8. A successful import looks like this :
  9. At this point I decided that I was going to use the EDA as a DHCP server, so configured a DHCP scope by clicking on the ‘configure DHCP server’  – clicking on this returns a relatively standard text based DHCP config file. What was pretty cool is that it allowed us to specify reservations ( you’d have to duplicate and uncomment the block that starts with #host fantasia {
  10. Once you have configured your DHCP options, select save, then Restart dhcpd – If you do not save, or you specify invalid config, the DHCP server will not start, e.g. I first time round specified a range that was not valid for any of the NICs presented to my server and it failed. (You need to save the config before restarting the DHCP to commit your changes)
  11. If you now boot a host to PXE, you will be prompted to do one of 3 things:

15.1.   Specify a hostname (this will be the hostname that you have prestaged – we’ll do this shortly)

15.2.   Boot Local (boot the current OS on the host)

15.3.   Run a manual installation.

  1. As the objective of this exercise is zero / limited touch installation, we are going configure / prestage settings for a host.

16.1.   Using the webrowser connected to the EDA appliance, click on the ‘New Host’ button

16.2.   This will create a new entry on your menu screen

If you were to PXE boot a host to your EDA now, you’ll see this host appear.

So if you type the hostname at the boot menu screen, EDA will go ahead and configure that host for you. – At this point we have a flat installation, with the VMKernel port configured and the host named as per our specified config – We have also been able to specify the IP for this host.  Host installation time is again about 4 minutes, but at present requires manual intervention. We know from previous experience that we can reduce the number of key presses required by modifying the install.tgz file in the ISO : http://www.get-virtual.info/2011/03/04/modifying-an-esxi-iso-to-reduce-the-number-of-keypresses-required-for-build/

While we are looking at this appliance. We can see that the beautifully (simple is beautiful as far as I am concerned when it comes to techie interfaces) has several additional options available, so let’s explore what we can get out of the enhancements.

  1. Firstly (from the above screen grab of the full web interface), we can see a ‘General ESX host settings’ tab. This pretty much speaks for itself – we can specify the Netmask / gateway / nameserver / licenseserver (older ESX hosts) ksdevice(in case we want to drop kickstart files), an latered root password (obfuscated of course) and a timezone – that’s a bunch of nagging keypresses.
  2. Even better, on the right, we have a block called ‘Post Installation Commands’ – what this basically does is allows us to build some scripts to execute at the end of our source build going down. For example, we may choose to configure our NTP servers or create a user. To do this, we simply select ‘Configure NTP’ from the dropdown and click the ‘ADD Button’ – the base code is generated and copied into the text box beneath – all that we need to do is edit the bits that are added below (Generally, it will be strings like XXXXX, or YYYYY that need to be modified)  –  A little vCli knowledge would be handy here as you can append any addition changes that you would like added, simply by modifying the text in the box. All you will need is in here: http://www.vmware.com/pdf/vsphere4/r41/vsp4_41_vcli_inst_script.pdf – though the generated script blocks on the appliance should be enough.
  3. If you have a large cluster you’d like to deploy, you can go ahead an configure most things here (vSwitches, Portgroups . . in fact with it being vCli, you could really do the full configuration for your host up front in the postbuild script here and just let rip whenever you are ready to go)
  4. I added several config settings on the rights and then dropped a PXE boot build on a new ESXi server and was surprised, even astonished at how smoothly the build went.
  5. One thing that bugged me was that if I was enabling a PXE server on my network, I would want it to wait at a PXe prompt for no more than seconds before booting to the default OS. Fixing this was pretty simple. All you need to do is on the EDA, hit ALT-F2 – you’ll need to authenticate (root:root) and then then you’ll be at the linux shell. Cd to ‘/var/lib/tftpboot/pxelinux.cfg’ you will be able to edit a file called ‘default’ –  nano is not available on this appliance, so use ‘vi default’ – a cheat sheet for vi is available at http://www.lagmonster.org/docs/vi.html
  6. Simply edit the timeout value to what you need (it appears that the values are 10ths of a second – so timeout 100 = 10 seconds)  – again, you can make all manner of changes to this if you like (most of the PXE config is in /var/lib/tftpboot) – as it is just one of the basic linux boot disks, just have a look here: http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project Ideas include adding your own logo, adding additional boot option, possibly some integration with other systems etc – maybe even (if you really felt like it) some Mac Address detection that allows for a stateless installation for each host at boot time – meaning that you could simply change the Mac Address on the appliance for a new ESX host and lay that image on a new host, if an old one failed? Or even a forced install on any host that has no drives configured?

Conclusion:

On the whole this is another superb piece of work by the VMware community

Ease of setup : Extremely quick and easy to setup (it did take me longer than the V-PXESERVER to get going first time round, due to the CDROM not mounting properly, but the support (based on a simple thread on the VMware communities is excellent) and the tool is in constant development (bug fixed version 0.95 was released while I was working on this)

Watch out as you will be dropping a PXE server on a VLAN and hosts will boot to this PXE server if they are set to boot from network first – though it does come with a 30 seconds timeout configured (which you can amend if you like)

Ease of ESXi deployment :  As with V-PXESERVER, some key strokes are required on ESXi host to specify install location etc, but this can be avoided by using the instruction I have posted before)

Deployment time : 4 minutes per ESXi host (without modifying ISO) – provided you are there for the key presses

Modified ISO :  About 3 minutes per ESXi host, but you’ll need to replace upgrade the install.tgz file each time you upgrade your ISO.

Likes :

  • I like the fact that postbuild options can be handled as part of the scripts that get imported, but unfortunately it seems that the appliance is still using ESX syntax, assumptions so post build functions are going to need some manual tweaking
  • Mounting an ISO and keeping it mounted for builds is nice and simple
  • ESXi gets deployed in about 4 minutes (network depending) once the tool is configured and can have a fair amount of customisation pre-done
  • Excellent support on the VMware communities

Dislike:

  • Being able to create custom postbuild scripts is awesome – but not all my ESX hosts are in the same location / cluster etc – it would be nice to be able to store a customisation with each ‘new host’ that is unique to that host – modifying postinstallation tasks seems to edit all ks files for all hosts that I have created (or it could just be me being stupid) – I will persist and possibly post a comment on the VMware community thread.

Other than the fact that it is Linux based (so difficult to PowerCli from), this is a superb tool! Great work

Categories: VMWare Tags:

Modifying an ESXi ISO to reduce the number of keypresses required for build

March 4th, 2011 No comments

Modifying an ESXi ISO to reduce the number of keypresses required for build

There are several tools available for quickly deploying ESX / ESXi ( I am reviewing these in my ESX to ESXi ‘Upgrade’ series.

But the vanilla config for each of these still requires a coule of manual key presses – ting is, do we really need a welcome screen and a second confirmation of everything we do? Assume for example I have 20 ESX hosts, ready to build, but networking is not yet in place because as usual the Networks team are dragging their heels . .so I decide to take the 20 boxes and drop ESXi on them. I am happy (in this case) to ISO boot them, but do not want to click ‘Next -> Next -> Next  -> Next -> finish’ (If I wanted to do that I would have installed Windows?

Anyway, the way to modify this is to crack open the python script that VMware uses for installation.

  1. First of all, we are installing from an ISO, so let’s crack open the ISO (the easiest way to do this is just mount it to a VM. As it is Linux based, I figure a Linux VM is best) – A quick tip here – it is always handy to keep a linux based VM around for general maintenance. I use the VMware browser appliance which is simply an Ubuntu Linux workstation http://www.vmware.com/appliances/directory/80 – anyway, mount your ESXi  ISO and open it up
  2. The content looks like this:  If I were a gambling man I’d guess that we need to modify the install.tgz file?
  3. OK, so as we are doing this from within Ubuntu, we could simply double click the file and extract it, but I am going to assume that you may only have a shell from your Linux (or you’re using something like Cygwin) – so let’s open a terminal shell.
  4. Once we have opened a Terminal shell, we’d like to get access to our CDRom (mounted ISO), so we type ‘mount’ to show mounted objetcs. (on the Browser appliance a CDROM appears as : /media/cdrom)
  5. If we go ‘cd /media/cdrom’ and type ‘ls’ the list of files on the CDRom appears (including of course our install.tgz file)
  6. OK, we need to create a work area in which to edit this file so let’s create a temp location ‘mkdir /tmp/install’
  7. Next we need to extract the install.tgz file so that we can edit it ‘tar –C /tmp/install –xzvf /media/cdrom/install.tgz’
  8. If we now browse to the /tmp/install folder we can view a series of extracted files and folders. We need to edit the file called ThinESXInstall.py, we can do this using nano or vi, but it is currectly read only. To change the permissions on the file we type ’chmod 777 /tmp/install/usr/lib/vmware/installer/ThinESXInstall.py’
  9. We’ll use nano. In the terminal session, type :’nano /tmp/install/usr/lib/vmware/installer/ThinESXInstall.py’
  10. About 20 lines into the file you will find a class called ‘ThinESXInstall’, we need to edit the steps in this section.
  11. We know that we do not want to see a welcome screen, we do not want to be prompted for license details, we do not want to be prompted to confirm anything, and we don’t need to know when the installation is complete(the host of course will have an OS on to show us this?), so we can edit the Steps fields as follows:
    1.  Steps = [ WelcomeStep, LicenseStep, TargetSelectionStep, ConfirmStep, \
       WriteStep, PostConfigStep, CompleteStep, RebootStep ] -should become
    2. Steps = [ TargetSelectionStep, \
  12.  WriteStep, PostConfigStep, RebootStep ]
  13. Once you have edited this as you like, simply hit CTRL – X and when prompted select ‘y’, then save the file back to the original location.
  14. We now need to rebuild the install.tgz – at the terminal shell we type ‘cd /tmp/install’ then  ‘tar –czvf /tmp/install.tgz *’ – this will create a new tarball at /tmp/install.tgz.  YOU HAVE DONE THIS IN THE TEMP DIRECTORY – IT WILL BE DELETED AT REBOOT!
  15. We now have a modified install.tgz that simply needs to be replaced in our ISO.
  16. We can copy this Install.tgz file up to a network location (or from our Linux host) using something like WinSCP. As the file is only 21k in size, I simply connect a virtual floppy to the Browser appliance and copy the file to there, then mount it to a windows VM on my network (If your appliance is already on the network, just copy it using the network)
  17. Using your favourite ISO editor (Google UltraIso 9.3 PC Users readers) simply replace the old install.tgz file with your new one. If you now boot from the ISO (or even use it with one of the various PXE server solutions out there (UDA / EDA / V-PXESEERVER etc) – you will suddenly have a bunch fewer prompts at boot.
  18. Mounting this using something like V-PXESERVER, or EDA now returns a 1 button build from PXE (Select storage)
  19. Happy days . . enjoy!
Categories: VMWare Tags: