Archive

Posts Tagged ‘vsphere’

vSphere 4.1 – Batteries (Client) Not Included in ESX/ESXi

July 17th, 2010 Jase No comments


vSphere 4.1 is out.

You have already upgraded VMware vCenter Server to 4.1.

You realize that you downloaded vCenter Server 4.1 and either your ESX 4.1 or ESXi 4.1 media.

ButYou didn’t download the vSphere 4.1 client.  Remember that the 4.1 client is not included in the installation of ESX or ESXi.

Now when connecting to an ESX/ESXi host with an older client, the same installer in the past would allow download of the client from the host.
This is no longer the case:

The host redirects the updater to vsphereclient.vmware.com to download the client.  This can be a long process, or a short process, depending on your connection speed, as well as proxy settings, etc.

Never fear, even though VMware didn’t bundle the client with ESX/ESXi, it is still available to download from your vCenter Server.

Or you can connect to the vCenter Server first to upgrade the vSphere client.

Either way is better than having to download the client from VMware.

Update: How to have your ESXi installation point to your vCenter download URL

From Tech Support Mode, modify clients.xml on the ESXi installation

The command is vi /usr/lib/vmware/hostd/docroot/client/clients.xml.

The format of the file looks like this:

<ConfigRoot>
<clientConnection id=”0000″>
<authdPort>902</authdPort>
<version>4</version>
<exactVersion>4.1.0</exactVersion>
<patchVersion>1.0.0</patchVersion>
<apiVersion>v4.1</apiVersion>
<downloadUrl>http://vsphereclient.vmware.com/vsphereclient/2/5/8/9/0/2/VMware-viclient-all-4.1.0-258902.exe</downloadUrl>
</clientConnection>
</ConfigRoot>

To change this, replace the <downloadURL> tag with the URL to your vCenter Server.  I replaced this line to match my download URL, my clients.xml looks like this:

<ConfigRoot>
<clientConnection id=”0000″>
<authdPort>902</authdPort>
<version>4</version>
<exactVersion>4.1.0</exactVersion>
<patchVersion>1.0.0</patchVersion>
<apiVersion>v4.1</apiVersion>
<downloadUrl>https://vcenter.jasemccarty.com/client/VMware-viclient.exe</downloadUrl>
</clientConnection>
</ConfigRoot>

Now press :w! to save the file, followed by :q! to exit vi.

Now your ESXi host will point to your vCenter server to download the vSphere client.

Categories: Virtualization Tags: , , ,

VMware vSphere 4.1 – RELEASED

July 12th, 2010 Jase No comments

VMware vSphere 4.1 has been released!

This is a release that many have been waiting for.  Virtualization.info leaked some early details a couple days ago.

Some of the features that are added include:

  • Memory Compression – compressing RAM pages rather than using disk swapping, which will improve performance (could significantly help VDI environments)
  • Storage I/O Control – VM’s with a greater need for disk resources can be given priority.
  • Network I/O Control – Can better leverage network utilization by setting QoS priorites for each flow type (iSCSI, NFS, etc)
  • DRS Host Affinity – VM movement can be more granular (great for limiting SQL VM movement, reducing SQL license requirements)
  • ESXi will have native Active Directory Integration
  • VMware vCenter Server – Will only run on 64-bit Windows.
  • vStorage API for Array Integration (VAAI) - New protocol to interface between VMware and storage arrays.  This can offload some storage tasks to the storage array natively.

The maximums have become larger

  • 3,000 VMs per cluster (increase by 2 times)
  • 1,000 hosts per vCenter server (increase by more than 3 times)
  • 10,000 VMs per vCenter (increase by more than 3 times)
  • Up to 8 vMotions in parallel when using 10GbE

Additionally, some names have changed:

  • VMotion is now vMotion
  • Storage VMotion is now Storage vMotion
  • The free ESXi package will be called vSphere Hypervisor
  • ESX & ESXi (paid version) will be discussed as the Hypervisor architectures

Well, I can’t wait to get it installed in the lab and give it a spin. Go to http://www.vmware.com/download to download it too.

Categories: Virtualization Tags: ,

Using the Data ONTAP PowerShell Toolkit to add vSphere Storage

June 9th, 2010 Jase 3 comments

Over the past year or so, I have started using PowerShell more and more.

I was really exited to see the release of the NetApp Data ONTAP PowerShell Toolkit 1.0. I say this, because I have been using the “unsupported” PoshOnTap PowerShell extensions for some NetApp management. I have to give credit where credit is due, and Glenn Sizemore has done a great job with PoshOnTap.

PowerShell is really powerful, and because more and more vendors are providing more and more modules for the management of different aspects of the enterprise. With one script, I can create a NetApp volume, export it as an NFS export, and then connect it to all of my VMware vSphere hosts.

Note: This script is meant to be run from the vSphere PowerCLI.

##########################################################
# Create-And-Add-Storage-example.ps1
# Jase McCarty 6/7/2010
# Posh Script to add a volume on a NetApp Filer
# and present it to all vSphere hosts
##########################################################

# Add the vSphere PowerCLI SnapIn and the DATA ONTAP Module
Import-module DataONTAP

# Set my variables
$vCenter = vcenter.jasemccarty.com
$Filer = netapp1.jasemccarty.com
$aggr = aggr1
$newvol = volx

# Connect to vCenter and our NetApp Filer
Connect-VIServer $vCenter
Connect-NaController $Filer

# Create a new volume
New-NaVol $newvol $aggr 500g

# Set some options for the new volume
Set-NaVolOption $newvol no_atime_update yes
Set-NaVolOption $newvol fractional_reserve 0

# Set the SnapShot Reserve to 0
Set-NaSnapshotreserve  $newvol 0
Set-NaSnapshotschedule $newvol -Weeks 0 -Days 0 -Hours 0

# Add an NFS export
Add-NaNfsExport /vol/$newvol -Persistent -ReadWrite all-hosts -NoSuid -SecurityFlavors sys,krb5

# Get all the vSphere Hosts and add the NFS export
$Hosts = Get-VMHost
ForEach ($H in $Hosts)
{
 New-Datastore -Nfs -VMHost $_.Name -NAME $newvol -Path /vol/$newvol -NfsHost $Filer;
}

**Note, this is a pretty incomplete script.  Security for the export will have to be addressed, and the Filer management IP (netapp1.jasemccarty.com) is probably not the same as the IP used for the NFS export.  This is just an example of how this can be used.

Pretty cool.  I can only imagine the Poshibilities.

PowerCLI cmdlets: Get/Set-VMGuestNetworkInterface

June 8th, 2010 Jase No comments

After my last post on Get/Set-OSCustomizationNicMapping, I started looking further at what options there were to configure network settings for guests that were “already” created.

It is one thing to be able to set the network adapter properties during the cloning process and something entirely different to do it after the fact.  Maybe a mistake was made during the cloning process.  More likely a network migration could be planned, and a completely different way of doing things would be needed.

Using Invoke-VMScript
In January, I wrote a post on how to Update VMware Windows Guest DNS and WINS through PowerCLI that uses the Invoke-VMScript cmdlet to run a batch file in Windows to set the DNS and WINS information.  For those versed with netsh, it is powerful, but there are requirements

One pretty big requirement is that the  name of the network adapter must be known.  On older VM’s, or possibly P2V’ed VM’s the network adapter name could be something like “Local Network Connection 2″, “Local Network Connection 3″, etc.  Using the above mentioned script is going to fail if the connection name is not known.  The only way around that, would be to put some logic in to determine the name to use when calling the script.  Additionally using netsh with DNS and WINS requires the addition of new values, and deletion of old values.

Another issue with the Invoke-VMScript method, is that it requires different scripts for Windows and Linux guests.

A Different Way
So I started to peruse the online docs for the current vSphere 4.0 Update 1 and found the Get/Set-VMGuestNetworkInterface cmdlets.  Just like my last post, I couldn’t really find any example scripts of anyone using it.

Here is the syntax for these cmdlets:

Get-VMGuestNetworkInterface
Syntax
Get-VMGuestNetworkInterface [[-VM] <VirtualMachine[]>] [-VMGuest <VMGuest[]>] [-Server <VIServer[]>] [-ToolsWaitSecs <Int32>] [-GuestPassword <SecureString>] [-GuestUser <String>] [-GuestCredential <PSCredential>] [-HostPassword <SecureString>] [-HostUser <String>] [-HostCredential <PSCredential>] [<CommonParameters>]

Set-VMGuestNetworkInterface
Syntax
Set-VMGuestNetworkInterface -VmGuestNetworkInterface <VMGuestNetworkInterface[]> [-WinsPolicy <DhcpPolicy>] [-Wins <String[]>] [-DnsPolicy <DhcpPolicy>] [-Dns <String[]>] [-IPPolicy <DhcpPolicy>] [[-Gateway] <Object>] [[-Netmask] <String>] [[-Ip] <IPAddress>] [-ToolsWaitSecs <Int32>] [-GuestPassword <SecureString>] [-GuestUser <String>] [-GuestCredential <PSCredential>] [-HostPassword <SecureString>] [-HostUser <String>] [-HostCredential <PSCredential>] [-WhatIf] [-Confirm] [<CommonParameters>]

One thing that struck me as odd, was that both of these commands have the following statements as part of their documentation:

… Consider that this functionality is experimental. …

and

Notes
Supported on ESX 3.5 and newer. …

So which is it? Maybe @cshanklin can address this at some point.

How Does It Really Work?
Are the Get/Set-VMGuestNetworkInterface cmdlets really that different from Invoke-VMScript? Not really, except for the fact that VMware has taken some of the guesswork out of the process.  These cmdlets actually call scripts in the Scripts folder located under the installation path of the vSphere PowerCLI.  There are separate scripts for Windows OSes and Linux OSes (currently only supported on RHEL 5).

The netsh scripting limitation I mentioned earlier (network connection name) is actually taken care of by these scripts.  Additionally these scripts can be modified/added to if desired.

There are a couple things to be aware of.

  • Set-VMGuestNetworkInterface does not work in my environment if the vNic is disconnected.
  • I could not use the vSphere PowerCLI in x64 mode to run the script.  The PowerCLI stated that I needed to use the 32bit PowerCLI instead.
  • WINS settings are not available in Linux guests.

How To Update
Now how do I go and update IP addresses on several machines (possibly those that I created in my last post)?

Here are the contents of my text file (C:\vms.csv) that contained my VM names and other settings.

basevm,datastore,vmhost,custspec,vmname,ipaddress,subnet,gateway,pdnswins,sdnswins,vlan
BASEVM,DS1,ESXi1,W2K3,VM01,192.168.0.80,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Primary
BASEVM,DS1,ESXi1,W2K3,VM02,192.168.0.81,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Primary
BASEVM,DS1,ESXi1,W2K3,VM03,192.168.0.82,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Primary
BASEVM,DS1,ESXi1,W2K3,VM04,192.168.255.83,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Secondary
BASEVM,DS1,ESXi1,W2K3,VM05,192.168.255.84,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Secondary

So I’ll modify it because I didn’t mean to use 192.168.0.x, I meant to use 192.168.1.x. And I’ll pull out the things I don’t need, like basevm, datastore, vmhost, & custspec.

vmname,ipaddress,subnet,gateway,pdnswins,sdnswins,vlan
VM01,192.168.1.80,255.255.255.0,192.168.1.1,192.168.1.199,192.168.1.198,Primary
VM02,192.168.1.81,255.255.255.0,192.168.1.1,192.168.1.199,192.168.1.198,Primary
VM03,192.168.1.82,255.255.255.0,192.168.1.1,192.168.1.199,192.168.1.198,Primary
VM04,192.168.255.83,255.255.255.0,192.168.1.1,192.168.1.199,192.168.1.198,Secondary
VM05,192.168.255.84,255.255.255.0,192.168.1.1,192.168.1.199,192.168.1.198,Secondary

Now I’ll save it as C:\vms-newip.csv.

Also, unlike the Get/Set-OSCustomizationNicMapping cmdlet, I’ll have to connect specifically to the host and the guest with appropriate credentials.  I have to do this, because credentials are required in the guest to make the change.

The Script
I’ll use the following script to update the VM’s.

##########################################################
# updateip.ps1
# Jase McCarty 6/6/2010
# Posh Script to update IP
# addresses in Virtual Machines
##########################################################

Connect-VIServer vcenter.jasemccarty.com

$HostCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter ESX host credentials", "", "")
$GuestCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter Guest credentials", "", "")

$vmlist = Import-CSV C:\vms.csv

foreach ($item in $vmlist) {

  # I like to map out my variables
  $vmname = $item.vmname
  $ipaddr = $item.ipaddress
  $subnet = $item.subnet
  $gateway = $item.gateway
  $pdnswins = $item.pdnswins
  $sdnswins = $item.sdnswins

  #Get the current interface info
  $GuestInterface = Get-VMGuestNetworkInterface -VM $vmname -HostCredential $HostCred -GuestCredential $GuestCred

  #If the IP in the VM matches, then I don't need to update
  If ($ipaddr -ne $($GuestInterface.ip)) {
      Set-VMGuestNetworkInterface  -VMGuestNetworkInterface $GuestInterface -HostCredential $HostCred -GuestCredential $GuestCred -IP $ipaddr -Netmask $subnet -Gateway $gateway -DNS $pdnswins,$sdnswins -WINS $pdnswins,$sdnswins
  }
}

As can be seen, it doesn’t take a complex script to update IP information in guests.

Keep in mind that not all of the attributes that I chose to use are required.  If desired, only the IP, DNS, WINS, etc can be updated.  My script just happens to update several of these items.  Additionally, this can be used to change a guest from a static IP address to a DHCP address as well.

Hopefully this script will help you when presented with a similar task of updating IP addresses/DNS/WINS settings.

For More Info
For more info on each of these commands, look here for the VMware documentation:

PowerCLI cmdlets: Get/Set-OSCustomizationNicMapping

June 5th, 2010 Jase No comments

At some point in the near future, I have to create several hundred new VM’s.  These VM’s will be using the same Customization Specification, but some will need to have Static IP addresses, and others will need to have DHCP addresses that are reserved based on Mac Address.

The Task
Alright, how am I going to create 400-500 VM’s with specific names and specific IP’s (with some being DHCP)?  I know there are some tools like the RCU from NetApp that will rapidly provision VM’s, but I’m not looking for 100% clones, as not all of these are going to be used for the same purpose (not using VDI here).

Customization Specifications typically can only be used once per VM when attempting to use a Static IP address.  Using DHCP, a Customization Specification can be easily reused, as it doesn’t change.  The problem is, what if I want to give each VM a Static IP.  That requirement makes it a little more difficult.

The Tool: PowerCLI
There are a couple new cmdlets in the 4.0 Update 1 release of the PowerCLI that will help accomplish this task.

  • Get-OSCustomizationNicMapping
  • Set-OSCustomizationNicMapping

Using these together in a PowerCLI script, settings like IP address (if static), DHCP, gateway, DNS & WINS settings, and Mac Address can easily be set.

The syntax for these are as follows:

Get-OSCustomizationNicMapping
SYNTAX
Get-OSCustomizationNicMapping [-Spec] <OSCustomizationSpec[]> [-Server <VIServer[]>] [<CommonParameters>]

Set-OSCustomizationNicMapping
SYNTAX
Set-OSCustomizationNicMapping -OSCustomizationNicMapping <OSCustomizationNicMapping[]> [-Position <Int32>] [-Server <VIServer[]>] [-IpMode <OSCustomizationIPMode>] [-VCApplicationArgument <String>] [[-IpAddress] <String>] [[-SubnetMask] <String>] [[-DefaultGateway] <String>] [-AlternateGateway <String>] [[-Dns] <String[]>] [-Wins <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Set-OSCustomizationNicMapping -OSCustomizationNicMapping <OSCustomizationNicMapping[]> [-NetworkAdapterMac <String>] [-Server <VIServer[]>] [-IpMode <OSCustomizationIPMode>] [-VCApplicationArgument <String>] [[-IpAddress] <String>] [[-SubnetMask] <String>] [[-DefaultGateway] <String>] [-AlternateGateway <String>] [[-Dns] <String[]>] [-Wins <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Get-Help Get/Set-OSCustomizationNicMapping -full can give you more information on each of these cmdlets.

My Script
So I put together a little script to read content from a file, set a nic mapping for the selected Customization Specification, clone the VM, and set the appropriate VLAN for the VM.

The text file proceeds with the assumption that the DNS and WINS servers are the same.  The pdnswins and sdnswins variables are used twice each, one for the primary DNS/WINS and once for the secondary DNS/WINS.  Here are the contents of my text file that contains my VM names and other settings.

basevm,datastore,vmhost,custspec,vmname,ipaddress,subnet,gateway,pdnswins,sdnswins,vlan
BASEVM,DS1,ESXi1,W2K3,VM01,192.168.0.80,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Primary
BASEVM,DS1,ESXi1,W2K3,VM02,192.168.0.81,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Primary
BASEVM,DS1,ESXi1,W2K3,VM03,192.168.0.82,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Primary
BASEVM,DS1,ESXi1,W2K3,VM04,192.168.255.83,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Secondary
BASEVM,DS1,ESXi1,W2K3,VM05,192.168.255.84,255.255.255.0,192.168.0.1,192.168.0.199,192.168.0.198,Secondary

I saved the file as C:\vms.csvEven though I named the file with a .csv extenstion, I decided to use colons rather than commas.  I did this because I wanted to send multiple DNS/WINS entries to my script, but I’ll get into that a little later. I have updated the script to use the standard comma delimiter.

The script to clone the VM’s and set their appropriate values

##########################################################
# cloneandsetip.ps1
# Jase McCarty 6/5/2010
# Posh Script to clone VM's and set appropriate
# IP addresses in Windows Virtual Machines
##########################################################
Connect-VIServer vcenter.jasemccarty.com

$vmlist = Import-CSV C:\vms.csv

foreach ($item in $vmlist) {

	# I like to map out my variables
	$basevm = $item.basevm
	$datastore = $item.datastore
	$vmhost = $item.vmhost
	$custspec = $item.custspec
	$vmname = $item.vmname
	$ipaddr = $item.ipaddress
	$subnet = $item.subnet
	$gateway = $item.gateway
	$pdns = $item.pdnswins
	$pwins = $item.pdnswins
	$sdns = $item.sdnswins
	$swins = $item.sdnswins
	$vlan = $item.vlan

	#Get the Specification and set the Nic Mapping (Apply 2 DNS/WINS if 2 are present)
	If ($Varable) {
		Get-OSCustomizationSpec $custspec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIp -IpAddress $ipaddr -SubnetMask $subnet -DefaultGateway $gateway -Dns $pdns,$sdns -Wins $pwins,$swins
	} else {
		Get-OSCustomizationSpec $custspec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIp -IpAddress $ipaddr -SubnetMask $subnet -DefaultGateway $gateway -Dns $pdns -Wins $pwins
	}

	#Clone the BaseVM with the adjusted Customization Specification
	New-VM -Name $vmname -VM $basevm -Datastore $datastore -VMHost $vmhost | Set-VM -OSCustomizationSpec $custspec -Confirm:$false

	#Set the Network Name (I often match PortGroup names with the VLAN name)
	Get-VM -Name $vmname | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $vlan -Confirm:$false

	#Remove the NicMapping (Don't like to leave things unkept)
	Get-OSCustomizationSpec $custspec | Get-OSCustomizationNicMapping | Remove-OSCustomizationNicMapping -Confirm:$false
}

Set-OSCustomizationNicMapping is very powerful.  Further examination of the documentation will show that things like setting the Mac Address and Alternate Gateway are also possible.

The Gotchas
There are a couple gotchas that I found, and you might want to be aware of.

  • The setting -PrimaryWins in the documentation does not work, use -Wins. Documentation and error messages will continue to state -PrimaryWins, but that attribute doesn’t work.
  • Multiple settings for DNS/WINS must read something like this 192.168.0.199,192.168.0.198.

    I had some difficulty passing 2 DNS/WINS entries into a single variable, so I am basically performing a check to see if a second entry is present.

In Closing
Thanks VMware for the very useful cmdlets to help make our jobs easier.

For more info on each of these commands, look here for the VMware documentation: