VMware Cloud Community
StephenMoll
Expert
Expert

Tagging or marking VM templates with unique identifier

We are developing some automation to manage the import and deployment of VM templates.

The team working on the scripts to do this have stumbled on a problem which appears to be a long running issue...

When an OVF is imported into the system, we have a requirement to uniquely mark the template created so that it can be positively matched to the import file and media it came from from. VMs are managed through a process that allocates a unique numerical identifier when the OVF is created. The import of the OVF into vSphere is working fine.

They then intended to create a Tag holding the UID and assigning it to the template. However they are getting problems creating the tag category :

15:12:51 - INFO 28/05/2020 15:12:51 New-TagCategory vSphere single sign-on failed for connection '/VIServer=vsphere.local\administrator@{VCSA IP address}:443/'. Future operations which require single sign-on on this connection will fail. The underlying cause was: The profile for the user is a temporary profile.

This looks to me like a Windows problem, and Google searches suggests that Tag operations in PowerCLI have been plagued with this sort of problem for some time.

Is there a way to correct or work around this?

If not are there any other suggestions for how to label or apply the UID to the template?

My thoughts are that maybe something with "Custom Attributes" or if there was a way to directly manipulate the VMTX file and store the UID there.

0 Kudos
11 Replies
LucD
Leadership
Leadership

You might want to have a look at PowerCLI 11.x gives "Get-Tag vSphere single sign-on failed for connection Future operations which r...

Especially the last reply on that thread.

Are you using PowerCLI 12.0 or an earlier version?

For storing a UUID: since you are apparently importing an OVF, do you create that OVF in-house?

If yes, why not add an OVF property to hold the UUID?
That will stay with the VM after it is deployed from the OVF afaik


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
StephenMoll
Expert
Expert

Thanks Luc I'll feed that back.

I did wonder about custom parameters in OVF files and whether or not they get processed when imported into vSphere. I couldn't convince myself that this would work. So you're understanding is that all key/values pairs in an OVF get imported into a Template's VMTX file and hence into any VMs deployed from that template?

0 Kudos
LucD
Leadership
Leadership

I'm not sure if the OVF properties survive the VM to Template conversion.

I would need to test that.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

I just did a quick test, and the vApp options are kept in a template and are propagated to all VMs deployed from that template.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
StephenMoll
Expert
Expert

Sorry, I'm not quite sure I'm getting that.

I can't work out if there is a way to add a parameter to a template after import of the OVF. In particular by using PowerCLI.

We are considering just appending the UID to the Template Name. That is how the ID arrives with us anyway, appended to the OVF filename, i.e. "{VM Name}_{UID}.ovf"

If the UID could be stored within the OVF file that could be useful.

Alternatively, if the UID can be extracted from the OVF file name and added to the Template as some sort of parameter that would be good too.

0 Kudos
LucD
Leadership
Leadership

I'm not sure how you create the OVA package, but you can define properties for an OVA.

Then when you import the OVA to a VM, you provide values for those properties.

These properties stay with the Template when you convert the VM to a Template.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
StephenMoll
Expert
Expert

Ah! OK! have to think on that one.

We have some control over the way OVFs are defined and generated, but delivery of these has already started, so to make a change to the requirements for delivery now might be a challenge.

The import of the OVFs into the system however is our own process, so that might be the best place to embed the information we want.

0 Kudos
LucD
Leadership
Leadership

I'm afraid you can't add properties when you import the OVF.

Then a Tag or a Custom Attribute would be the next best bet.


Or eventually the name, but that has drawbacks because the TemplateName is not propagated to the VMs you deploy from that Template.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
StephenMoll
Expert
Expert

I was playing with Custom Attributes on Templates and I struggling to make sense of it at first.

Eventually I worked it out, and decided it is a decidedly cack-handed design! Maybe there is reasoning behind it.

I went into the vSphere Client and created a custom attribute "UID" with the value "1234567890".

In PowerCLI this gets stored under ExtensionData as a list of "AvailableField" which gives you the key number, then there is list of "Value" which gives "Key","Value" pairs. Why this couldn't have been a hash-table I don't know.

How would I go about created a AttributeName, Value pair from PowerCLI? Do I create the "AvailableField" first which gives me a Key number and then assign the Value to the Key in the Values list?

As for Tags, we don't think that works which is why I'm here. Looks like it was broken since v6.5.

0 Kudos
LucD
Leadership
Leadership

You don't have to use the ExtensionData for Custom Attributes.

There are the New-CustomAttribute and Set-CustomAttribute cmdlets.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

Tags do work, I use them all the time in 6.5 and 7.0.

But there is obviously something in your setup that is causing an issue.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos