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
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:
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
If you find this information useful, please award points for "correct" or "helpful".
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:
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
If you find this information useful, please award points for "correct" or "helpful".
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