We have customised ESX builds, put some additional components as part of our installation process and we wish to include our build number or tag the host. So as to be able to identify which build it is running and be able to query inventory via VI Client or toolkit and take actions.
Es. Which servers running myCustomBuild 5.1 don't have portgroup x
So we put a custom field myCustomBuild and populate the field. However, this is lost whenever host is removed from VC and added again (for tshoot purposes)
We do put myCustomBuild tag in ESX file system when we build it. Is there a way this information can be populated in VI db and visible through VI Client and be able to query through VITK.
Thanks.
H
Can you explain what you mean with "put myCustomBuild tag in ESX file system" ?
Is that a file in the file system of the COS ? Or is that a file in a datastore connected to that ESX server ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Its the COS. What I meant was -- similar to the field EsxVersion and EsxBuild, can I create a custom field/annotation on the host and populate my value (our own build versioning info) and should be able to see that value in VI Client or by VITK.
This way I will be able to perform actions on selected hosts having the custom field
Net net, I wish to create a new field say myBuild with value 5.1.a
The custom fields are kept in the VC db.
When you remove a host and add it later back, it's not the same host as far as the VC is concerned.
The added host gets a new internal host-id and that explains why the custom field values are gone.
Mind they are still there in the VC db but connected to the "old" host-id.
The only clean way of doing is to export/import the custom fields.
To write them to a CSV file you could do (before you remove the host)
(Get-VMHost <ESX-hostname>).CustomFields.GetEnumerator() | Export-Csv "C:\Cust.csv" -NoTypeInformation
To set the custom field(s) back after you added the host you can do
Import-Csv "C:\Cust.csv" | %{Set-CustomField -Entity (Get-VMHost <ESX-hostname>) -Name $_.Key -Value $_.Value}
You could of course also run the export script for all your ESX servers on a regular basis and then, after you re-add a host, you could add the custom field(s) for that specific host back.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just thinking where on esx server are the settings file stored that contains smtp/config/misc advanced settings etc. These are visible from VI Client as well as VITK... Vi Client > Host > Configuration > Advanced Configuration
So If you can guide me to the settings file on cos file system, then perhaps it can be edited during setup/build and will retain myCustomValue. Is this possible ?
I'm not sure I understand which "Advanced Configuration" you mean ?
Is it the "Advanced Settings" under Host/Configuration in the VIC ?
If yes, know these are also stored in the VC db and will be gone when you remove/add a host.
What you could do is to create a file, for example under the /usr/local directory in the COS and write the content of your custom field in there.
But this would require you to use something like the plink.exe utility (from the PuTTY suite) to set up a connection to the COS (provided sude is configured correctly on the COS).
The actual configuration files of the COS can be overwritten by ESX patches and you have no guarantee that your text will stay in there.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am thinking to use firewall outgoing port as myCustomValue which will resemble myCustomBuildVersion, and this is readable from VC and stays if host is added or removed to VC. I know crude, but works for me
Edit Custom Attributes and Annotations for a Virtual Machine or Host
You can use custom attributes to associate your own information with the resources in vCenter Server.
After you create the attributes, set their values on each virtual machine or managed host, as appropriate. The values are stored with vCenter Server. You can then use the new attributes to filter information about your virtual machines and managed hosts. If you no longer need the custom attribute, remove it. A custom attribute is always a string.
You can also add annotations to a virtual machine to add a description or other comments about the virtual machine or host.
You can set custom attributes for a virtual machine or host from the object’s Summary tab. You can also define Global attributes, which are not specific to a particular type of managed object, from the Custom Attributes dialog box.
Note
You can add annotations when connected to either a vCenter Server system or to any host, but you can only define attributes when connected to a vCenter Server system.
Required privileges:
■ Global.Manage Custom Properties
■ Global.Set Custom Properties
Procedure
1 In the vSphere Client, display the object (virtual machine or host) in the inventory.
2 Select the object and click the Summary tab.
3 In the Annotations box, click the Edit link.
The Edit Custom Attributes dialog box appears.
4 To add an attribute:
a Click Add.
b In the Name text box, type the name of the attribute.
c In the Type drop-down menu, select the attribute type.
d In the Value text box, type the value to give to the attribute for the selected object.
e Click OK.
After you define an attribute on a single virtual machine or host, it is available to all objects of that type in the inventory. However, the value you specify is applied only to the selected object.
5 (Optional) To edit the value of an attribute that is already defined, click the Value field for that attribute and enter the new value.
6 (Optional) To add annotations, enter text in the Notes text box.
7 Click OK.
Related concepts
Setting Custom Attributes
Thank you for the detailed writeup, appreciate it.
Problem is that when an esx host is removed from virtual center and readded to VC, esx server identification changes and VC cannot associate previously set custom attributes to this re-added esx server.
Any more help ?
Now that ESXi is embedded, and does not have a console, what could be our options of writing a custom value on COS OS File System and then be able to retrive that from VI SDK/PowerCLI