ssbangal
Contributor
Contributor

Error retrieving Custom Attribute for Virtual Machine

Jump to solution

Hi,

I have created a custom attribute TestAtt for Virtual Machines using the vSphere client. Attached is the screenshot of the configuration.

Now I need to retrieve this value programatically in my plug-in, which I am developing using c#. Below is the code snippet of the same. For some reason the below call fails saying that the attribute is not found.Even when I used the DoesCustomizationSpecExists, i get false. I do not get exception.

Am I doing this in the right way?

CustomizationSpecItem customProperty = new CustomizationSpecItem();

customProperty = VIM_SERVICE.GetCustomizationSpec(SERVICE_CONTENT.customizationSpecManager, "TestAtt");

Regards,

Sudhir

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager

You're using the wrong managed object to retrieve the custom fields. The customizationManager is used to deal with customizing the guestOS using either Linux Quick Prep or Windows Sysprep.

What you'll want to use is customFieldManager - Here is a vSphere SDK for Perl script that shows you how -

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
2 Replies
lamw
Community Manager
Community Manager

You're using the wrong managed object to retrieve the custom fields. The customizationManager is used to deal with customizing the guestOS using either Linux Quick Prep or Windows Sysprep.

What you'll want to use is customFieldManager - Here is a vSphere SDK for Perl script that shows you how -

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
ssbangal
Contributor
Contributor

Hi William,

Appreciate your response. With your help, I am now able to get all the details of custom fields using the customFieldsManager object.

Then I am using the "customValue" property of the VirtualMachine to get the actual value by mapping the "key" field.

Thanks for your help.

FYI...I have marked your response as the "correct answer".

Regards,

Sudhir

0 Kudos