Why are my VM’s custom attributes not backed up? Work around with PowerCLI

This posting is for those that might want to backup a VM on one vCenter and restore it in another vCenter, but seeing that the custom attributes are not copied over. For now, this is a workaround. Moving forward, VMware is deprecating custom attributes in favor of tags. For tagging, it makes sense because if you’re searching for a particular VM, that’s how you do it, but custom attributes are key-valued pairs. I’m not sure how that makes sense with tags.

First off, you will need PowerShell and PowerCLI both installed on your machine. You can do this from any Windows host that can talk to vCenter. If you’re using Windows 7 or above, you should not need to download PowerShell, but you can download it here if necessary: http://www.microsoft.com/en-us/download/details.aspx?id=34595. You can get the VMware PowerCLI here: https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI501. There’s an access restriction in PowerShell by default that will not allow PowerCLI commands to run if it’s turned on. The installer will ask if you want to turn it off – you can have the installer do it for you. After it’s all installed, you can move onto the next step.

The first thing we need to do is to authenticate against vCenter. You can do this with:
We’ll need to find out what the custom attributes are. You can get them by running:
Connect-VIServer -user -pass for example:
Connect-VIServer 10.5.10.204 -user domain\administrator -pass P@SSw0RD!

Before we do any backup, we need to find out what the custom attributes are. You can do this by running
$vm=get-vm

If you want to read the custom fields, you can type:
$vm.Customfields

You can output those custom fields into a file or whatever you want. When you want to write those field back into a VM, you would do it this way:

After registering the VM, you can run this to assign the new vm:
$newvm = get-vm

Then loop through the custom fields and set them
foreach ($field in $vm.Customfields) {set-annotation -Entity $newvm -customattribute $field.Key -Value $field.Value }

This should set the custom fields that you will need.

if vCenter Server Heartbeat or Neverfail Heartbeat failover appears to be not working or taking a long time …

The main symptom of this problem would be that the vCenter Server Heartbeat console or Neverfail Management Client console would show that the services had failed over, but if you were to try to ping it, it wouldn’t respond.
Logically, there there are some hypotheses you could come up with:

1) Network packet filter isn’t revealed on the active server, so we can’t connect to it.
2) Something wrong w/ the service.
3) The console is wrong and on the backend, nothing failed over.

These would be all wrong.

What we found was that it was an issue with ARP caching on the switches. Because the VM or host abruptly fell off the network, the switches hadn’t expired the ARP entries and that they were stale. You would think that it would be fixed in a minute after the ARP entries expired, but I guess the chain could take a little longer.

Probably the best way to troubleshoot this would be to get on a host on the same network segment and try a ping. If that fails, you could run “arp -a” and check to see if you indeed have the right mac address of the host you want to connect to. If not, you could probably log into the switch to delete the entry or you can create a task to run the command during switchover:

“C:\Program Files\VMware\VMware vCenter Server Heartbeat\R2\bin>nfpktfltr.exe arp”

You should then see the switchover happen without the long delay.

OPS1 – VMware Management app for the iPhone – Fantastic!

I’ve been using this app for quite some time, but haven’t found the time to write about it.

If you use an iPhone or iPad and manage a vSphere environment, you’ll want this app. You can get it here: OPS1 – VMware and Amazon AWS Cloud Management for …

It’s made by a company called Spragos based out of Santa Clara, CA. You can find their website here: http://www.spragos.com.

It’s pretty awesome that I could manage my vSphere hosts and VMs without having to power on the laptop. Since I’m on a Mac, I don’t enjoy bringing up the vSphere thick client and even the web client takes quite some time to load. Most of the time, I just need to power on or off a VM or shutdown a host anyways. This app has allowed for me to do these things without having to power on my laptop or even if I’m on the laptop, I don’t need to start up Fusion for the client and I’m loving it.

Here are some screen shots. You can configure a single or multiple hosts – connect to vCenter or an ESX host directly. It will also cache credentials. Since I’m not necessarily in a super secure environment (my home lab), I don’t care much about security. I hate having to type my password in over and over just to log in or even my user name for that matter.

After logging in, here’s my home screen. From here, I usually head over to Virtual Machines or Hosts, depending on what I want to do.

IMG_2026

I’m I’m interested in what’s going on overall, I would navigate to Status. Here, I could see at a high level that everyone’s going just fine with my host.

IMG_2032

It’s not always this way though – see, it pulls events and alarms from Corporate Event Planners.

IMG_2400-1

If you go into VMs, you can see a nice list of the VMs:

IMG_2027

Then, you can drill into the properties of the VM and see what’s going on, make changes, power on or off, etc

IMG_2029

IMG_2028

If a VM was suddenly unresponsive for some reason, maybe the CPU stats could give you a clue as to what was going on. In my case, I just had a couple of spikes.

IMG_2030

I think you get my point. It’s a great app! Download it free and try it yourself. I honestly feel that the value of the free version is well worth the measly $10 for upgrading to the Enterprise version. It’s probably saved me hours of time if you aggregate the couple of minutes it takes to start up the mac, start up fusion, start up the vSphere client and then logging into the ESX or vCenter server.

Here’s a few other screenshots just for eye candy’s sake.

How to fix networking after cloning an Ubuntu 8 VM

Stolen from: http://weblog.jamisbuck.org/2008/8/15/cloning-ubuntu-hardy-image-in-vmware-fusion

* “sudo hostname blah”, to set the hostname. This doesn’t change it permanently, so you’ll also want to:
* “sudo vim /etc/hostname”. Change the contents of the file to the hostname you want. Then:
* “sudo vim /etc/hosts”. Replace all mentions of the old hostname with the new hostname.
* “sudo vim /etc/udev/rules.d/70-persistent-net.rules”. There will be two entries in this file. The first points eth0 at the old MAC address, and the second points eth1 at the new. Go ahead and delete the first entry, and change “eth1” to “eth0” in the second (and now only) entry.
* “sudo shutdown -r now” to restart your virtual machine.

HOW TO move ESX hosts between clusters without maintenance mode

I’ve done this a number of times and never had a problem, but this may not be a good idea.

The steps are to:

1. Right click and disconnect the ESX host from vCenter.
2. Right click and remove the host you just disconnected from vCenter (may hang VC temporarily in the minute rangeor operation may time out) re-log back into VC, once you are able to it host should be gone from the cluster.
3. Re-add to VC under new cluster

HOW TO force VirtualCenter to load after SQL Server on the same system

http://support.microsoft.com/kb/193888

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<Service name>

<Service name> = vpxd for VirtualCenter
modify the DependOnService key and add MSSQLSERVER