Thursday, March 29, 2012

VMware ESXi 5.0 installer doesn't always show LUN 0

If you have ESXi hosts which have hit or are close to hitting the VMware path limit maximum (2048 paths per host), it is possible that the LUN (Logical Unit Number) you want to use for boot (LUN 0) will not be listed by the ESXi installer. This affected me because I incorrectly assumed that LUN 0 had to be enumerated.

In reality, LUNs will enumerate in any order the storage system feels like responding in. From my experience, this is non-deterministic. LUN 0 may be enumerated first, or last, or in the middle. And just because a subset of LUNs is enumerated once, does not mean that the same subset will be enumerated next time!

This issue is more likely to impact you if you have many paths per LUN. The solution is to either:

  1. Reduce the amount of LUNs you have through LUN consolidation. Have fewer, larger LUNs. Take advantage of increased LUN size maximums.
  2. Change to an internal boot device. SD card boot, or internal disks.
  3. Start splitting clusters. Redistribute which LUNs get presented to which hosts.

Monday, March 26, 2012

How to find where a function is defined in Eclipse

To find where a function is defined in Eclipse, right-click on your function then click Declarations > Workspace.

Tuesday, March 13, 2012

How to upgrade VMware vCenter from 4.1 to 5.0

Upgrading VMware vCenter from 4.1 to 5.0 is a breeze. I’m writing this documentation because some of you out there will be given the tedious task of documenting the upgrade process. Don’t bother: just copy and paste the contents of this post into your internal documentation and spend the time you would have spent doing something you enjoy, like walking a dog or eating a cake or whatever it is that people do when they’re not working with VMware (I wouldn’t know!)

I’m assuming you know how to download VMware vCenter. If not, I don’t blame you: the VMware Download Center is confusing. I’ll have another post detailing how to download vCenter if you’ve got a license, and how to download a 60 day evaluation.

Okay! Start by extracting the contents of the vCenter download to a folder on your vCenter server. Once you’ve done this, run autorun.exe.

Windows Explorer viewing vCenter source media

The installer appears! Wow, look at all the wonderful VMware products you can install! You can install core vSphere components including

  • vCenter Server
  • vSphere Client
  • VMware vSphere Web Client (Server)
  • VMware vSphere Update Manager

You can also install the Support Tools like

  • VMware ESXi Dump Collector
  • VMware Syslog Collector
  • VMware Auto Deploy
  • VMware vSphere Authentication Proxy
  • vCenter Host Agent Pre-Upgrade Checker

Why am I listing these out? Because these are optional components and won’t be installed automatically. Why did I tell you that? Because every VMware Certified Professional should know *hint hint*.

Anyway, let’s install vCenter Server. That’s what we’re here for.

VMware vSphere 5.0 installer

Select your language. English (United States) is good, but you only get the real power of ESX if you select German.

VMware vCenter Server - InstallShield Wizard

Wow, a splash screen! VMware products are covered by one or more patents. Maybe two or three. Or four.

VMware vCenter Server 5.0 splash screen

The InstallShield Wizard is loading the Windows Installer, because nobody outside of Microsoft can package an application correctly.

VMware vCenter Server - InstallShield - Configuring Windows Installer

The vCenter installer welcomes you. Please remove your passports from your passport holders and open them to the first page.

VMware vCenter Server Installer - Welcome screen

If the message “An earlier version of vCenter Server is already installed on this computer and will be upgraded to vCenter Server 5.0” appears, the installer will perform an upgrade. If this message does not appear, you’re probably logged into your company’s file server and installing vCenter on it will get you fired.

VMware vCenter Server Installer - Welcome screen

If you’re really bored, you can look up the patents that VMware holds on the US Patent and Trademark Office website. Some of them are quite interesting and were ground breaking at the time. Check out patent 6,397,242 (Virtualization system including a virtual machine monitor for a computer with a segmented architecture). What ideas were you trying to understand in 1998? Devine, Buginon and Rosenblum were ahead of their time.

If you’re not bored, click Next to continue.

VMware vCenter Server Installer - End-User Patent Agreement

License agreement. If you look closely, there’s a clause in there about having to drink any paint within a three metre radius of you. It will be a very painful experience and you won’t want to install vCenter again for another three months.

If this is okay with you, click I agree to the terms in the license agreement then click Next to continue.

VMware vCenter Server Installer - License Agreement

Please enter your information and enter a license key. If you don’t have a license key, that’s ok: you’ll install vCenter in evaluation mode. Evaluation mode is 60 days. That’s something you might need to know.

VMware vCenter Server Installer - Customer Information

If you’re performing an upgrade, you’ve already got a System DSN created. If you use Windows Authentication, the database username and database password boxes will be greyed out. If you use native SQL authentication, please e-mail your DBA so they can tell you why you shouldn’t use native SQL authentication.

Click Next to continue.

VMware vCenter Server Installer - Database Options

if you use VMware Update Manager (VUM), you’ll be warned that it won’t work after vCenter is upgraded. Keep this in mind.

VMware vCenter Server Installer - VUM warning

You’ve got two options: upgrading your existing vCenter database or making a new one.

If you’re going to upgrade and haven’t taken a backup of your vCenter database and SSL certificates, you have rocks in your head. You need both items backed up to rollback from an unsuccessful installation.

If you want to start again with a brand new vCenter database, that’s fine too.

VMware vCenter Server Installer - Database Upgrade Warning

Each ESX host has a vCenter agent installed. This agent allows vCenter to communicate with the ESX host. If this agent is not installed, not started, or is a version older than your vCenter server, the ESX host will appear as disconnected.

The installer is asking you whether you want vCenter to automatically upgrade the vCenter agent on all the hosts it manages. If you select this option, you’ll see a bunch of ‘Upgrading vCenter agent’ tasks when you first log into vCenter. If you don’t upgrade the agent, all your ESX hosts will appear as disconnected and you’ll need to reconnect them again.

I recommend picking Automatic.

VMware vCenter Server Installer - vCenter Agent Upgrade

Enter the account name that vCenter will use to run. If you’re lazy and don’t use service accounts, you can use the SYSTEM account (by checking the Use SYSTEM account checkbox). Come on, use service accounts! They’re more secure and only take a minute to create!

If you want to use a service account, I hope you logged in to the server with it! If you have, the account name field is prepopulated and you can’t change it. Enter the account password and the Fully Qualified Domain Name (FQDN) of your server then click Next.

VMware vCenter Server Installer - vCenter Server Service

If you get the error message “Failed to verify the Windows account, either username or password is incorrect.”, you probably made a typo and need to practice using a keyboard more.

VMware vCenter Server Installer - Failed to verify the Windows account, either username or password is incorrect

If vCenter cannot resolve your FQDN, you’ll get the error message “The Fully Qualified Domain Name cannot be resolved. If you continue the installation, some features may not work correctly. For detailed requirements, see the vSphere Installation and Setup guide.” This error message also appears if you have multiple network interfaces on your server (you can safely ignore it).

VMware vCenter Server Installer - The Fully Qualified Domain Name cannot be resolved. If you continue the installation, some features might not work correctly. For detailed requirements, see the vSphere Installation and Setup guide.

You can install VMware anywhere you like. The default folder is C:\Program Files\VMware\Infrastructure\, but you can change the folder to any other drive without fear of strange side effects (I’m looking at you, Eclipse!)

VMware vCenter Server Installer - Destination Folder

Ports ports ports. Don’t change these unless you like introducing unneeded complexity into the environment (maybe you’re some sort of consultant). If you’re sitting a VMware exam, you should probably know these! Click Next

VMware vCenter Server Installer - Configure Ports

…for more ports! Seriously, don’t change these. Just click Next.

VMware vCenter Server Installer - Configure Ports for Inventory Service

vCenter Server is a piece of crap written in Java. Don’t give me dirty looks, I’m just saying what every VCP is thinking. Sometimes it’s hard to believe the same company that made ESX also made vCenter.

Pick the inventory size most suited to your environment so vCenter won’t perform worse than it already does, then click Next.

VMware vCenter Server Installer - vCenter Server JVM Memory

Wow, you’re ready to install! WAIT! There’s one more question! Do you want to increase the amount of ephemeral ports you have? (Hint: You do, and I recommend it. Even if you use a Cisco Nexus 1000V).

Every switch (physical and virtual) has a fixed number of ports. Take a look at the $9 Netgear switch underneath your desk that smells like feet: it will probably have four ports on it labelled 1 to 4. vSwitches are similar: even though they’re virtual, they have a fixed amount of ports too (a lot more than physical switches though!) This option increases the amount of ports you have. There’s no reason you shouldn’t select this option.

Once you’ve digested this, click Install to upgrade vCenter.

VMware vCenter Server Installer - Ready to Install the Program

The first step of upgrading vCenter is upgrading the database! There’s no turning back now!

If you have a reasonably sized database, upgrading can take up to 15 minutes. If your database is 60gb in size, it can take several hours. Don’t press Cancel unless you feel like doing a database restore.

VMware vCenter Server Installer - Installing VMware vCenter Server

The vCenter Server installer will open this command window to take you out of your comfort zone. Nothing actually appears in it.

VMware vCenter Server Installer - vCenter-Server\dbuupgrade\bin\dbuHelper.exe empty command window

If you’ve been good, the installation will have completed successfully.

VMware vCenter Server Installer - Installation Completed

Good work! Now you can update your resume detailing your extensive VMware 4 to VMware 5 upgrade experience.

Wednesday, March 7, 2012

Using PowerCLI to find total space consumed by a VM

Say you have a VM named burger and you want to know the total disk space used by a VM in PowerCLI.

Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum


Count    : 2
Average  :
Sum      : 157286400
Maximum  :
Minimum  :
Property : CapacityKB

The Sum value contains the total amount of kilobytes consumed by all disks connected to the VM. But what if you just want the value of Sum?

Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum | Select-Object Sum
Sum
---
157286400
Still good, but what if you want just the number?

(Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum).sum
157286400

That's the correct amount of kilobytes, but how can I convert that into gigabytes? Easy! Divide it by 1048576 (1024 multiplied by 1024)

(Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum).sum/(1024*1024)
150


What if you want to add some text after the string?
((Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum).sum/(1024*1024)).ToString() + " gigabytes consumed"
150 gigabytes consumed

That was easy! Now, let's see all the errors you could have made along the way.

((Get-VM burger | Get-HardDisk | Measure-Object -Property
CapacityKB -Sum).sum/(1024*1024)) + " gigabytes consumed"
Cannot convert value "gigabytes consumed" to type "System.Double". Error: "Input string was not in a correct format."
At line:1 char:102
+ ((Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB
-Sum).sum/(1024*1024)) + <<<<  "gigabytes consumed"
    + CategoryInfo          : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException

This error is caused by trying to add two incompatible values. Let's separate this command into a blue and green segments.

((Get-VM burger | Get-HardDisk | Measure-Object -Property
CapacityKB -Sum).sum/(1024*1024)) + " gigabytes consumed"


This blue code produces a number of type System.Double. We can verify this by using the Get-Members cmdlet.

((Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum).sum/(1024*1024)) | Get-Member


   TypeName: System.Double


Name        MemberType Definition
----        ---------- ----------
CompareTo   Method     int CompareTo(System.Object value), int CompareTo(dou...
Equals      Method     bool Equals(System.Object obj), bool Equals(double obj)
GetHashCode Method     int GetHashCode()
GetType     Method     type GetType()
GetTypeCode Method     System.TypeCode GetTypeCode()
ToString    Method     string ToString(), string ToString(string format), st...


Now let's evaluate the second part of the command. +"gigabytes consumed" is a System.String object. This is obvious (it's in inverted commas), but you can pipe it into the Get-Member cmdlet if you want to check.

The reason why you received the error message Cannot convert value "gigabytes consumed" to type "System.Double is because PowerShell tries to cast (convert) the second operand (a string) in to the type of the first operand (a double). You can't convert the string "gigabytes consumed" into a bunch of numbers, but you can do the reverse! Let's pick up the +"gigabytes consumed: " bit of code and drop it at the beginning.


"gigabytes consumed: " + ((Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum).sum/(1024*1024))
gigabytes consumed: 150

Awesome, it works! PowerShell casted the results of the double into a string. But what if we don't want the string before the value? We can use the .ToString() function to cast the double into a string.


(Get-VM burger | Get-HardDisk | Measure-Object -Property C
apacityKB -Sum).sum/(1024*1024).ToString() + " gigabytes consumed"
Cannot convert value "gigabytes consumed" to type "System.Double". Error: "Input string was not in a correct format."
At line:1 char:111
+ (Get-VM burger | Get-HardDisk | Measure-Object -Property CapacityKB -Sum).sum/(1024*1024).ToString() + <<<<  "gigabytes consumed"
    + CategoryInfo          : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException

WHAT?! We used ToString()! Why did it throw a casting error? Oh, wait, I only casted the (1024*1024) part. I need to evaluate the entire blue code block then cast to a string.

((Get-VM burger | Get-HardDisk | Measure-Object -Property
CapacityKB -Sum).sum/(1024*1024)).ToString() + " gigabytes consumed"
150 gigabytes consumed

That's better. And that's it!