VMware Cloud Community
aslk5
Enthusiast
Enthusiast

can't find license in licensemanager by name

I'm trying to find my ESXi licenses by the name I give them when added to vCenter (eg. my license 1 or my license 2) but I can't find what I need in the licenseManager class. I can find the license key, the type of license (which is the name property and returns something like ESXI 6 enterprise) but not the name I called it in the list I see in vCenter.

Anyone know how to access a license by it's vcenter name?

Reply
0 Kudos
11 Replies
eoinbyrne
Expert
Expert

Looking at this class

pastedImage_0.png

It has this attribute

pastedImage_1.png

Which is an array of these

pastedImage_2.png

and the name attribute contains the name of the license. It looks like you should be able to iterate to find by name?

Reply
0 Kudos
aslk5
Enthusiast
Enthusiast

That's not the "friendly" name I'm trying to find.

licenseManager[0].name returns: VMware vSphere 6 Enterprise Plus

I want to find the license by the name I've entered in vCenter as I'm looking to find a special key based on the name that it was given when added.

Reply
0 Kudos
eoinbyrne
Expert
Expert

OK, what else have you tried for the value you need? Is it possible that it's stored in one of either the VcDynamicProperty array dynamicProperty or in the VcAnyKeyValue array properties?

The only other possibility I can think of is the VcServiceContent object collection which seems to provide a wrapper for a mixture of newer management classes and many of the existing ones accessible through VcSdkConnection

After that that value you want may not be exposed via the APIs here (unusual for the VC plugin tbh)

Reply
0 Kudos
eoinbyrne
Expert
Expert

Might be in the labels array? It's a VcKeyValue which you can iterate

Reply
0 Kudos
aslk5
Enthusiast
Enthusiast

I just do a System.log on licenseManager.licenses to see what's there.

dynamicProperty is null

properties seems to be an array that has a bunch of KeyAnyValue but I can't figure out how to access what might be stored in these .

VcServiceContent just seems to encapsulate a bunch of other objects that i can access elsewhere (one of which is licenseManager whose object is the same as I'm working with)

Reply
0 Kudos
aslk5
Enthusiast
Enthusiast

labels is also null for the licenseInfo object,

Reply
0 Kudos
eoinbyrne
Expert
Expert

Aye, labels is always null for me too. So far the only way I can reliably identify a license is by the key value (licenseKey).

For the VcKeyAnyValue you can iterate them like this

pastedImage_0.png

The commented line there --> p.key etc prints name and value. I noticed that in my case the first couple of items in that array were copies of the entire LicenseInfo object for some reason.

Sadly still no sign of the license custom name so it must not be available via the plugin. I've also checked the VC REST APIs but can't see anything there either

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

The following code seems to work in my environment. It enumerates all available licenses and prints the ones that have custom label(s).

var licmgr = mySdkConnection.licenseManager;

for each (var lic in licmgr.licenses) {

  if (lic.labels == null) continue;

  for each (var kv in lic.labels) {

    System.log("License key: " + lic.licenseKey + "  label key: " + kv.key + "  label value: " + kv.value);

  }

}

eoinbyrne
Expert
Expert

What VC version do you have there iiliev​? Perhaps it's version related? MIne is VC6.5 with vRA/vRO 7.5 (+ whatever shipped plugins came with that) & the labels member is always null for each license when I list the license content

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

VC6.0 (6.0U2, if I'm not mistaken)

vRO standalone versions 7.4 and 7.6

Reply
0 Kudos
aslk5
Enthusiast
Enthusiast

I ran your code on my license and it seems like it's just a list of features for the given license. For reference I'm on vCenter 6.7U3 and vRO 7.6.

I even tried the HTML5 fling to record vRO javascript and it returns nothing when editing the name . I'm wondering if there's a bug or a change made in 6.5+ where we can't get that user entered name of a license since it seems to work in vcenter 6.0

Reply
0 Kudos