VMware Cloud Community
houghtp
Contributor
Contributor
Jump to solution

Custom Attributes from vCenter DB

Hi,

We've ran into an issue where we had to remove all our hosts from one of our clusters and re-attach, only to find the custom fields of vm's are empty. I now realise this is as expected but I now need to repopulate the data.  We've restored a copy of our DB and having a look through i've found the fields that relate to this data in tables VPX_FIELD_DEF and VPX_FIELD_VALUE.

The table VPX_FIELD_VALUE contains the info for all the fields however it doesn't list vm names but MO_ID's.  I thought these would be easy to match up to vm's MOREF but it doesn't look like it does - I've compared them by running.

get-vm | get-view | select name,@{N="Moref";E={$_.moref.value}} | sort name

can anyone tell me what these MO_ID's refer to as I would think they must reference another table in the DB to get the VM display name?

I know this isn't Powercli specific but was hoping someone can help or point me to the best forum?

0 Kudos
1 Solution

Accepted Solutions
AureusStone
Expert
Expert
Jump to solution

Hi.  Sorry about that, I guess I didn't read your original post well. Smiley Sad

Anyway when you unregistered your hosts, you unregistered your VMs.  When you readded your hosts your VMs were given new MOREFs.

So you need to match up the IDs from your database with there actual name in the database.  If you look at the view "VPXV_VMS" you should be able to relate your customfields with the actual VM name.  Then you can export to a CSV file.  From there you can use PowerCLI to import the values.

So you should be able to get all your data from "VPXV_FIELDS" and "VPXV_VMS" or if you are using tables "VPX_FIELDS" and "VPX_VMS".

If you are good with SQL or work with DBAs this should be an easy task.  I currently do not have access to a test database, so let me know if you have any issues and I will try to work it out in my lab at home (in about 12 hours).

View solution in original post

0 Kudos
4 Replies
AureusStone
Expert
Expert
Jump to solution

I would recommend using Luc's script to copy custom attributes to a csv then exporting it.  It uses the API so it is faster then using the cmdlets.  Note this post is a bit old, so the performance difference is smaller now, but this script should work fine still.

http://www.virtu-al.net/2009/05/29/powercli-on-steroids-custom-attributes/

Otherwise there is a VMware fling for capturing your entire inventory and recovering it.  It is a fling so it is not supported and it requires Java.  This would be useful to ensure you keep your resource pools and folders etc.

http://labs.vmware.com/flings/inventorysnapshot

0 Kudos
houghtp
Contributor
Contributor
Jump to solution

Hi thanks for the reply, however the migration has already been done and the customfields lost. I'm at the stage now where i'm trying to piece them back form a DB restore, but the tables i've found that hold the info don't have a recognisable VM identifier. The colum used to identify each VM is called MO_ID but it doesn't seem to refer to the VM's MOREF as i thought it would.  If i can find out how to map this MO_ID field back to a VM I can import the custom fields with Powercli.

hope that makes sense.

0 Kudos
AureusStone
Expert
Expert
Jump to solution

Hi.  Sorry about that, I guess I didn't read your original post well. Smiley Sad

Anyway when you unregistered your hosts, you unregistered your VMs.  When you readded your hosts your VMs were given new MOREFs.

So you need to match up the IDs from your database with there actual name in the database.  If you look at the view "VPXV_VMS" you should be able to relate your customfields with the actual VM name.  Then you can export to a CSV file.  From there you can use PowerCLI to import the values.

So you should be able to get all your data from "VPXV_FIELDS" and "VPXV_VMS" or if you are using tables "VPX_FIELDS" and "VPX_VMS".

If you are good with SQL or work with DBAs this should be an easy task.  I currently do not have access to a test database, so let me know if you have any issues and I will try to work it out in my lab at home (in about 12 hours).

0 Kudos
houghtp
Contributor
Contributor
Jump to solution

thats brillaint, excactly what i was after, I didn't think to look in the views.

thanks for your help!

Paul.

0 Kudos