Skip to main content

PowerCLI: Counting physical CPUs in a vSphere Host

We recently needed to calculate the number of physical CPUs in use by hosts running Windows VMs in order to work out how many Windows Server 2008 Data Center Edition licenses we require.

Data Center (DC) edition permits you to run as many Windows Server VMs as you like on a host which has the DC license. You don’t actually need to install the Datacenter software, so you can use this license on a host running vSphere or Xen (as well as Hyper-V).

Not all of our hosts need a DC license as some don’t run any Windows VMs, and other run a smaller number where it’s cheaper either to use an Enterprise license (up to 4 VMs) or license VMs individually. To mark which hosts need a DC license, I create a Custom Attribute called “DC SPLA” for all hosts, with values of “Yes”,”No”, or “?” (where it wasn’t clear what license was appropriate).

I then created a small PowerCLI script which dumps out a CSV file containing all hosts which were possible DC license uses (those which were marked “Yes” or “?”), along with the number of physical CPUs in each host.

It’s a short script and isn’t particularly special but I’m posting it anyway.

  1. $vcentername = "myvcentername.net"
  2. $outputfile = "c:\users\myname\Desktop\cpucount.csv"
  3.  
  4. Connect-VIServer $vcentername
  5.  
  6. get-vmhost | ForEach-Object { 
  7.  if ((Get-annotation -Entity $_ -CustomAttribute "DC SPLA" | select -ExpandProperty value ) -ne "No")
  8.  {
  9.  New-Object -TypeName PSobject -Property @{
  10.   HostName = $_.name 
  11.   CpuCount = (Get-View $_.ID).Hardware.CpuInfo.NumCpuPackages
  12.   	}| Select-Object Hostname,CpuCount
  13.  }
  14. } | export-csv -Path $outputfile 
  15.  
  16. Disconnect-VIServer $vcentername -Confirm:$false

iPhoto mangles GPS EXIF data, even from an iPhone 3G

A while ago I started geo-tagging some of my photos (basically, adding GPS location data to the EXIF data in the image files).

I did the geo-tagging using the excellent HoudahGeo. Because of a limitation in iPhoto, you have to geo-tag your pictures before importing them into the iPhoto library, as it won’t re-read or change the location info it stores in the library database.

After importing to iPhoto, I would edit the photos and then upload them using Connected Flow‘s superb FlickrExport (the beta versions support uploading of location co-ordinates).

I found that, for some photos, the resulting location on the maps in Flickr was incorrect. More specifically, they were the wrong side of the Greenwich Meridian.

Further investigation showed that HoudahGeo and FlickrExport (and Flickr) were all blameless.
If I tagged a photo, examined it in OS X’s Preview the location showed correctly. If I imported the photo into iPhoto, the co-ordinates still showed up fine. When I exported the photo, using the File Export option, and examined the result in Preview, the location had changed.

This image demonstrates the issue, giving the correct co-ordinates before import into iPhoto, the correct co-ordinates inside iPhoto, but the wrong co-ordinates when subsequently exported from iPhoto using FlickrExport or File Export.

There’s a discussion about the problem in a Flickr group from a year or so ago, so I certainly wasn’t the first person to notice it.

I reported the problem to Apple, along with a link to the above image on 30th May.

On Friday, I was fortunate enough to receive a shiny new iPhone 3G. The phone has a built-in GPS (strictly speaking, a-GPS) and will geo-tag photos taken with the camera. The same switching of co-ordinates persists if you put the images through iPhoto, and quite a lot of other people have started to take notice, including a MacWorld article so I’m hoping Apple will finally fix this issue.

A work around if using FlickrExport is to re-tag all your pictures in FlickrExport before exporting them to Flickr, or if using HoudahGeo, to re-tag them after they’ve been edited and exported from iPhoto.

I don’t know whether Aperture has the same problem.

UPDATE: iPhoto 7.1.4 released 23rd July 2008 seems to fix the problem