Resetting the inventory service database

When a colleague cleaned some log files which filled up the C: drive; we noticed that this caused the Inventory Service to die. Some of the vCenter user where also complaining that the “Search” function didn’t work anymore.

The location of the log files was: “C:\Program Files\VMware\Infrastructure\Inventory Service\data”

This caused the “inventory service” to get killed and remain unstartable. Because we had no backup of the database we needed to reset it. See the link below for the proper VMware article. In short here this is my summary.

Caution

This procedure can cause data loss. Perform this procedure with VMware Technical Support.

I took the guess and did it without VMware support because it wasn’t working anyway 🙂

  1. Stop the Inventory Service
  2. Remove folder: “C:\Program Files\VMware\Infrastructure\Inventory Service\data”
  3. Go to “c:\Program Files\VMware\Infrastructure\Inventory Service\scripts”
  4. “Createdb.bat” with no arguments
  5. Start “Inventory Service”
  6. Reregister the “inventory service”
  7. “cd C:\Program Files\VMware\Infrastructure\VirtualCenter Server\isregtool”
    “register-is.bat <vcenterFQDN>:443/sdk <vcenterFQDN>:10443 <vcenterFQDN>:7444/lookupservice/sdk”
  8. Restart the “Inventory Service”
com.vmware.vim.vcauthorization.impl.provider.InMemoryAuthCache] Processing unresolved entities 06F31E7F-0667-4628-A5E2-FAB1AE6B9D61
com.vmware.vim.query.server.provider.AbstractAtomPullProviderBase] Provider 06F31E7F-0667-4628-A5E2-FAB1AE6B9D61 new generation: 2102329
com.vmware.vim.vcauthorization.impl.provider.InMemoryAuthCache] Done processing feed update for 06F31E7F-0667-4628-A5E2-FAB1AE6B9D61
com.vmware.vim.vcauthorization.impl.provider.InMemoryAuthCache] Processing unresolved entities 06F31E7F-0667-4628-A5E2-FAB1AE6B9D61
com.vmware.vim.query.server.provider.AbstractAtomPullProviderBase] Provider 06F31E7F-0667-4628-A5E2-FAB1AE6B9D61 new generation: 2102330
com.vmware.vim.dataservices.federation.FederationReconfigurator] Checking/updating federation configuration
com.vmware.vim.dataservices.federation.FederationReconfigurator] No peers reachable - skipping reconfiguration

The search function will now work again 🙂

net stop vimQueryService
del C:\Program Files\VMware\Infrastructure\Inventory Service\data
C:\Program Files\VMware\Infrastructure\Inventory Service\scripts\createDB.bat
net start vimQueryService
cd C:\Program Files\VMware\Infrastructure\VirtualCenter Server\isregtool
register-is.bat vcenter.fqdn:443/sdk https://vcenter.fqdn:10443 <a href="https://wsv10372.office01.internalcorp.net:7444/lookupservice/sdk">https://vcenter.fqdn:7444/lookupservice/sdk</a>
net stop vimQueryService
net start vimQueryService

http:\\kb.vmware.com\selfservice\microsites\search.do?language=en_US&cmd=displayKC&externalId=2017370

Incorrect “Degraded status” on HP Array Controller

I tried and worked flawlessly, so for all of you with this error….go and donwload !

Fixes:

Upgrade Requirement:
Recommended – HP recommends users update to this version at their earliest convenience.


The following fixes were added to this release:

  • Smart Array Controller incorrectly reports Degraded status: Fixed issue where HP Insight Management WBEM Providers were incorrectly reporting a ‘Degraded’ status for the Smart Array Controllers. This caused VMware vSphere Management Console under Health Status category to display a ‘Warning’ Status (Yellow Exclamation) for the HP Smart Array Controllers.  HP System Insight Manager and Insight Control for vCenter and other users of the HP Insight Management WBEM Providers would also report the Smart Array Controller as ‘Degraded’.
  • Smart Array physical drive incorrectly reports OK status: Fixed issue where HP Insight Management WBEM Providers were not correctly reporting a not-OK status for a removed drive connected to a Smart Array Controller. This caused HP System Insight Manager, VMware vSphere Management Console, Insight Control for vCenter and other users of the HP Insight Management WBEM Providers to report the physical drive as OK after it was removed.
  • Server reports incorrect processor Model: Fixed issue where HP Insight Management WBEM Providers would report an incorrect Processor Model for ProLiant servers and blades. For example: “Intel(R) Family: Intel(R) Xeon(TM) 2.5GHz (x86 Family 179 Model 125 Stepping 7)”” is reported instead of the correct  “Intel(R) Family: Intel(R) Xeon(TM) 2.5GHz (x86 Family 179 Model 45 Stepping 7

>Software can be downloaded here<

 

How do snapshots work?

How do snapshots work ?

Sometimes I get some questions how snapshots actually work, luckily there are some good articles on the VMware site.
A good post about this is described on the VMware site in the link below:

http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1015180

2 nice videos about consolidating snapshots

ESXi3.x and 4.x

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1007849

ESXi5.x

http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=2003638

http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=2003638

Create multiple VM’s by cloning template

Because I needed to create multiple VM’s from a template I decided to have a look into the PowerCLI command for this.  I created a text file with pre-given names, called D:<file>.txt, for each item in this list I create a new VM according to template <template> on <vmhost> and <datastore>.  To put the VM’s in a specific location I use the “-location”. With the option “RunAsync” it fires the commands and goes to the next one instead of waiting for the first job to complete before proceeding to the next one.

foreach ($vm in (GC D:<file>.txt)){

New-VM -name $vm -Location <location> -Template <template>`
-vmhost <vmhost> -Datastore <datastore> -RunAsync
}

DL380/385 Gen8 Install ESXi4.1

Case: Missing NIC and storage drivers in our ESXi4.1 installation

First thing I noticed when the I tried to install ESXi4.1 on the Gen8 series is that our standard (VMware) image wasn’t able to install. Not by our scripted UDA and also manual failed.
With the scripted install I noticed the NIC drivers where not recognized and the hardware was unidentified which resulted in the NIC not connecting to our deployment server to grab the KS.CFG files.
The manual install failed by a missing Storage Adapter driver.

When I used the ESXi4.1 recommended image by HP with all the drivers inserted and loaded, the installation went fine. After the installation I used

esxcfg-scsidevs –l
esxcfg-nics –l

To see what hardware was exactly in the machine.

NIC: Broadcom NetXtreme BCM5719
Storage Array: HP System Array P420I
With this information I found the drivers on the HP site.
Driver: vmware-esx-drivers-scsi-hpsa-400.4.1.0-26OEM.x86_64
Driver : vmware-esx-drivers-net-tg3-400.3.123b.v40.1-1vmw.2.17.00000.x86_64

So ? How do we add this to our PXE deployment?
ESXi4.1 has a sort of local hardware database file with all components and vendors which are supported, and a list of which hardware uses what drivers.
Located in /etc/vmware the files are PCI.IDS and SIMPLE.MAP

PCI.IDS
In this file the hardware database is located, it’s a flat file. If the device ID is recognized during boot, ESX will give the corresponding name to it and it’s later used to load the correct drivers. Luckily I had 2 systems. One system I installed with the HP OEM VMware image, the other was my texting machine. I simply pulled the PCI.IDS file from the HP OEM server and saved it locally for later use.
In our case we are missing the HP Smart Array P420i

Example of PCI.IDS

103c Hewlett-Packard Company
323b Smart Array P222
103c 3350 Smart Array P222
103c 3351 Smart Array P420
103c 3352 Smart Array P421
103c 3353 Smart Array P822
103c 3354 Smart Array P420i
103c 3355 Smart Array P220i
103c 3356 Smart Array P721m

SIMPLE.MAP
This file represents a list of device ID’s and which driver modules they need to load. I also needed to add the correct drivers and modules here. Also in this case I just copied the simple.map file.
Example:
103c:323b 103c:3354 storage hpsa
The first explains the PCI device ID, the second category (storage) the last module is the driver that is loaded (hpsa).

So wrap up. Now the hardware devices can be recognized and the right drivers can be loaded. Too bad we still have older drivers in our image and need to update them first.

Logging in to the HP CD installed servers I figured out which driver versions are needed.

vmkload_mod -l|egrep "tg3|hpsa"
tg3 4 176
hpsa 2 76
~ # vmkload_mod -s hpsa|grep Version
Version: Version 4.1.0-26OEM, Build: 00000, Interface: ddi_9_1 Built on: Jan 19 2012
~ # vmkload_mod -s tg3|grep Version
Version: Version 3.123b.v40.1, Build: 00000, Interface: 9.0, Built on: Apr 3 2012

So now we now which drivers and versions are used to control the hardware.
Creating Custom Image

To inject drivers we can use the VMWare provided vibddi tool on a Linux/CentOS machine.
– Install vibddi

rpm -ivh vmware-esx-vibddi-.i386.rpm

– Installation instructions

Copy image file and extract
– Copy the original ISO using WINSCP to /opt/vmware/vibddi/iso

– Mount the original image:

Mount /var/public/smbmount/esx41iso/VMware-VMvisor-Installer-4.1.0.Update3-custom.iso /var/public/www/esx41i/ESXi41U3Cust –t= iso9660 (rw,loop=/dev/loop1)

– Copy the original imagedd.bz2 to a temporary folder /imagebuild/

cp /var/public/www/esx41i/ESXi41U3Cust/imagedd.bz2 /imagebuild[text]
[text]
total 405929
-r-xr-xr-x 1 root root 11225 Nov 6 22:36 a.z
-r-xr-xr-x 1 root root 2048 Nov 6 22:40 boot000.cat
-r-xr-xr-x 1 root root 2048 Nov 7 15:24 boot.cat
-r-xr-xr-x 1 root root 1162824 Nov 6 22:36 cimstg.tgz
-r-xr-xr-x 1 root root 15283377 Nov 6 22:36 cim.vgz
-r-xr-xr-x 1 root root 7306598 Nov 6 22:36 ienviron.vgz
-r-xr-xr-x 1 root root 312820483 Nov 7 15:14 imagedd.bz2
-r-xr-xr-x 1 root root 67 Nov 7 15:16 imagedd.md5
-r-xr-xr-x 1 root root 971501 Nov 6 22:40 install.vgz
-r-xr-xr-x 1 root root 12241 Nov 6 22:36 isolinux.bin
-r-xr-xr-x 1 root root 298 Nov 6 22:36 isolinux.cfg
-r-xr-xr-x 1 root root 47404 Nov 6 22:36 mboot.c32
-r-xr-xr-x 1 root root 51020 Nov 6 22:36 menu.c32
-r-xr-xr-x 1 root root 2593205 Nov 6 22:36 open_sou.txt
-r-xr-xr-x 1 root root 2156 Nov 6 22:36 readme.txt
-r-xr-xr-x 1 root root 72786024 Nov 6 22:36 sys.vgz
-r-xr-xr-x 1 root root 41155 Nov 6 22:36 tboot.gz
-r-xr-xr-x 1 root root 48339 Nov 6 22:36 vmkboot.gz
-r-xr-xr-x 1 root root 2489796 Nov 6 22:36 vmkernel.gz
-r-xr-xr-x 1 root root 34816 Nov 7 15:23 vmware_v.iso

– Now unzip the imagefile you copied

cd /imagebuild
bunzip2 imagedd.bz2

Adding VIB’s / offline bundles to the image
– Use VIBDDI to see which items are already in the image.

Vibddi –i imagedd –q

– Example:

< oem-vmware-esx-drivers-net-vxge (400.2.0.28.21239-1OEM) >
< oem-vmware-esx-drivers-scsi-3w-9xxx (400.2.26.08.036vm40-1OEM) >
< vmware-esx-firmware (4.1.0-3.26.800380) >
< CMPI-1.0 >
< VMW_CMPI_CPP-1.0.5 >
< vmkapi_1_1_0_0 >
< vmknexus1kvapi-3-26 >
< vmkepsecapi_1.0.0.0 >
< vmkvsepapi_2.0.0.0 >
< DriverAPI-9.0 >
< DriverAPI-9.1 >
< vmkuservsepapi_2.0.0.0 >
< vmware-esx-tools-light (4.1.0-3.26.800380) >

– Now we are going to inject the correct drivers , I downloaded and copied them to /bundles

vibddi -i /imagebuild/imagedd -v cross_oem-vmware-esx-drivers-scsi-hpvsa_400.4.1.0-22OEM.vib
Setting up configuration for esxupdate
This may take a few seconds…

– Repeat this for the other drivers. When you finished use the -q switch again to see if the correct drivers are injected. Now you see that they’re added.


vibddi -i /imagebuild/imagedd –q
< oem-vmware-esx-drivers-net-vxge (400.2.0.28.21239-1OEM) >
< oem-vmware-esx-drivers-scsi-3w-9xxx (400.2.26.08.036vm40-1OEM) >
< vmware-esx-drivers-net-tg3 (400.3.123b.v40.1-1vmw.2.17.00000) >
< vmware-esx-drivers-scsi-qla2xxx (400.841.k1.42.1-1vmw.2.17.00000) >
< vmware-esx-firmware (4.1.0-3.26.800380) >
< CMPI-1.0 >
< VMW_CMPI_CPP-1.0.5 >
< vmkapi_1_1_0_0 >
< vmknexus1kvapi-3-26 >
< vmkepsecapi_1.0.0.0 >
< vmkvsepapi_2.0.0.0 >
< DriverAPI-9.0 >
< DriverAPI-9.1 >
< vmkuservsepapi_2.0.0.0 >
< vmware-esx-tools-light (4.1.0-3.26.800380) >

Custom driver modules
– Download or extract the .o files from the offline bundles/vib files. Luckily I could capture them from the HP VMware OEM CD-ROM.
– The files we need are tg3.o and hpsa.o.
– Go back to your temp directory where your CD image is mounted and mount imagedd

mount imagedd /mnt -o loop,rw,offset=4210688
cd /mnt

total 91368
-rwxr-xr-x 1 root root 11225 Nov 6 22:21 a.z
-rwxr-xr-x 1 root root 128 Nov 6 22:21 boot.cfg
-rwxr-xr-x 1 root root 48339 Nov 6 22:21 b.z
-rwxr-xr-x 1 root root 1162824 Nov 6 22:21 cimstg.tgz
-rwxr-xr-x 1 root root 15283377 Nov 6 22:21 c.z
-rwxr-xr-x 1 root root 2489796 Nov 6 22:21 k.z
-rwxr-xr-x 1 root root 137 Nov 6 22:21 license.tgz
-rwxr-xr-x 1 root root 754246 Nov 6 22:21 m.z
-rwxr-xr-x 1 root root 950084 Nov 6 22:21 oem.tgz
-rwxr-xr-x 1 root root 3862 Nov 6 22:21 pkgdb.tgz
-rwxr-xr-x 1 root root 72786024 Nov 6 22:21 s.z
-rwxr-xr-x 1 root root 41155 Nov 6 22:21 tboot.gz
-rwxr-xr-x 1 root root 2030 Nov 6 22:21 vibddi

– Extract the oem.tgz file and copy the simple.map, pci.ids and .o files in the right directories.
tar xvzf oem.tgz

1) /usr/lib/vmware/vmkmod
Kopieer in deze map de .o files
2) /etc/vmware/
Kopieer naar deze map de sample.map en pci.ids bestanden

– Recreate oem.tgz

tar cvzf oem.tgz ./*

– Copy the oem.tgz back to imagedd

cp oem.tgz /mnt

– Unmount the imagedd

umount /mnt/imaged

– Recompress imagedd file

bzip2 /tmp/imagedd/imagedd

– Check the MD5 checksum and replace it with the checksum in the file : imagedd.md5

md5sum imaged.bz2

Create new ISO

cd /tmp/iso

mkisofs -o VMware-VMvisor-Installer-4.1.0.update1-348481.x86_64_customdriver.iso -b isolinux.bin -c BOOT.CAT-no-emul-boot -boot-load-size 4 -boot-info-table ./

You now have an image that is ready to install with, when you use a manual install.

PXE Boot
As we use PXE here, I added the image, rebooted and….FAIL!

WTH! Oh right…I forgot that the boot image needs the correct drives too, else the NIC can’t connect to the share..

To simply add the drivers to the PXE image I created another OEM.tgz file with the drivers needed for the PXE boot.

– I created a new folder /oem
– I then created the following folders in /oem
1) /usr/lib/vmware/vmkmod
2) /etc/vmware

In the first folder we put the .o files (drivers) and in the second folder the simple.map and pci.ids
Create a a new oem.tgz file to send with the PXE installation.

cd /tmp/oem/
tar –zcf /tmp/oem/oem.tgz etc lib sbin usr var

Copy the oem.tgz file to the location where the PXE files are loaded. In our case this is

/var/public/tftproot

Now add the –oem.tgz to your kernel options command line and you’re ready to fire up !

Good luck and have fun!

Retrieve WWPN from datastore

As our storage admins frequently request the exact disk ID so we know we are talking about the same disk. I found it annoying and hard to gather them from the GUI and copy paste them. So I decided to create a function for this which I called “get-serial” just to easily grab the WWPN.


function Get-serial {
<#
.SYNOPSIS
Retreives the canonical name from a datastore
.DESCRIPTION
Retreive the LUN ID to match with your storage admin
.NOTES
Author: Patrick Heijmann
.EXAMPLE
get-serial "ESXCL001_P01"
.EXAMPLE
get-serial ESXCL001_P01
.EXAMPLE
get-serial -datastore ESXCL001
.EXAMPLE
get-cluster|get-datastore|get-vmhost|get-serial
.PARAMETER Datastore
Specifies the datastore to query
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Which datastore would you like to target?')]
[Alias('host')]
[ValidateLength(3,30)]
[string[]]$datastore
)

begin {
Write-Verbose "Starting to find the datastore you entered"
}

process {
$details = Get-Datastore|?{$_.name -eq $Datastore}|?{$_.type -eq "vmfs"}|get-view
if (!$details){
Write-Output "No valid datastore specified";Write-Verbose "Datastore not found enter a valid datastore name"
}
else {
$serial = ($details.info.vmfs.Extent|select diskname).diskname -replace "naa."
Write-Verbose "Done with $datastore and $serial"
$out =" " |select @{N="Datastore";E={($datastore)}}, @{N="Serial";E={($serial)}}
Write-Output $out
}
}
}

PowerCLI function Change-Mac

As we needed to change a lot of MAC addresses because we needed to move a lot of VM’s to another vCenter. I created a function to change the MAC-Address of a VM trough PowerCLI.
Because the address is based on the vCenter ID we had some troubles in the past with SCCM and double MAC Addresses so we needed to take this opportunity to fix it to be compliant with the vCenter ID.

function Change-Mac{
<#
.SYNOPSIS
Generates a new Mac-Address based on the existing vCenter ID
.DESCRIPTION
This function creates a new MAC Address while the NIC
configuration is maintained
.NOTES
Source: The Interwebz
Authors: Me, Myself and I
.PARAMETER VM
Specify the virtual machine to change the MAC Address from
.EXAMPLE
PS> Change-Mac -VM VM001
.EXAMPLE
PS> (GC import.txt)|change-mac
#>
Param (
[Parameter(
Valuefrompipeline = $true,
ParameterSetName = "VM",
Mandatory = $true,
HelpMessage = "Enter VM name")]
[String[]]$VM)

process
{
foreach ($vmnic in $VM){
$objState = Get-VM $vmnic | Select-Object PowerState}
If ($objState -match "off")
{
$thisAdapter = Get-NetworkAdapter -Vm $vmnic
foreach ($nic in $thisAdapter)
{
$nic.ExtensionData.AddressType = "Generated"
$nic.ExtensionData.MacAddress = ""
}
Set-NetworkAdapter $thisAdapter -confirm:$false
Write-Host -ForegroundColor Green $vmnic "succesfully edited"
}
else
{
Write-Host -ForegroundColor red $vm "is not powered off, please turn off!"
}
}
}

Windows Boot Configuration Data

Administrative privileges are required to use BCDEdit to modify BCD.

Boot Configuration Data (BCD) files provide a store that is used to describe boot applications and boot application settings. The objects and elements in the store effectively replace Boot.ini.
/timeout Specifies the time to wait, in seconds, before the boot manager selects the default entry.

Example
Set the timeout to 5 seconds.

bcdedit /timeout 5

Where is my PowerShell Profile ?

I was looking where to import functions in to the default Powershell profile.
The file with the custom functions is named : Microsoft.PowerShell_profile.ps1
Put your custom scripts in here and it will load as soon as your powershell session starts.

You also can use $profile to see where your personal profile is located.

It can be found at the locations:

32-bit “C:\Windows\SysWOW64\WindowsPowerShell\v1.0”
64-bit “C:\Windows\System32\WindowsPowerShell\v1.0”

 

 

1 4 5 6 7 8