VMware Cloud Community
oschroeder8
Contributor
Contributor
Jump to solution

Licensing a vCenter 6 instance via PowerCLI 6

When installing vCenter 5.5 on Windows I was able to supply the license key as a parameter to license the vCenter instance at install time like so:

VMware-vcserver.exe /q /s /w /L1033 /v" /qr LICENSEKEY=xxxxx-xxxxx-xxxxx-xxxxx-xxxxx DB_SERVER_TYPE=Bundled FORMAT_DB=1 SSO_ADMIN_PASSWORD=$SSO_ADM_PASS LS_URL=$LSURL IS_URL=$ISURL VC_ADMIN_USER=Administrators VC_ADMIN_IS_GROUP_VPXD_TXT=True /L*v c:\temp\vcinstall.log"

I tried with the vCenter 6 installer and providing the license key as part of the install parameters did not work.

So I have read various articles and was able to add the license to the vCenter's License Manager. It now shows up correctly.

But this command does not work anymore:

$vCenterLicenseAssignmentManager.UpdateAssignedLicense($vCenterUuid, $vCenterLicenseKey, $vCenterDisplayName)

UpdateAssignedLicense has been deprecated.


I tried this (after finding the V1 hint until the patch for this is released):


$LicenseDataManager = Get-LicenseDataManager -Server $VIServer

$licenseData = New-Object Vmware.VimAutomation.License.Types.V1.LicenseData

$licenseKeyEntry = New-Object Vmware.VimAutomation.License.Types.V1.LicenseKeyEntry

$licenseKeyEntry.TypeId = "vmware-vsphere"

$licenseKeyEntry.LicenseKey = $vCenter6LicenseKey

$licenseData.LicenseKeys += $licenseKeyEntry

$licenseDataManager.UpdateAssociatedLicenseData($vCenterUuid, $licenseData)

But this fails as the TypeID of the license does not seem to be right. Where can I get the correct TypeID for a vCenter license? I guess the TypeId I am using identifies the license as an ESXi license?

Am I one the right track otherwise? Is there an easier way of doing this?

1 Solution

Accepted Solutions
ccalvetTCC
Enthusiast
Enthusiast
Jump to solution

Hi,

I managed to assign a new license to a vCenter 6.0 with the API method "UpdateAssignedLicense" even if it is deprecated.

$vCenter6License = "Replace by a valid vCenter 6 License"

$MyVC = connect-viserver "YourVC"

$LicenseManager = get-view ($MyVC.ExtensionData.content.LicenseManager)

$LicenseManager.AddLicense($vCenter6License,$null)

$LicenseAssignmentManager = get-view ($LicenseManager.licenseAssignmentManager)

$LicenseAssignmentManager.UpdateAssignedLicense($MyVC.InstanceUuid,$vCenter6License,$Null)

Tested with:

vCenter Appliance Version 6.0 Build 2559267

PowerCLI 6.0 Release 2

Support has provided me some information regarding “cis.license.management.SystemManagementService”

but I will wait to have more details before posting the result.

They have also mentioned this:

Customer can still use the old LicenseAssignmentManager methods (which are documented as deprecated in API reference guide).

This is why I gave a try to the "UpdateAssignedLicense".

Note the URL in the previous link i have provided was wrong. This is the correct one:

vSphere 6.0 Documentation Center

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC

View solution in original post

11 Replies
Craig_Baltzer
Expert
Expert
Jump to solution

Have you tried using EditionKey instead of TypeID? When querying the installed licenses I don't see a TypeID property but I do see EditionKey that is different between ESXi and vCenter licenses. The vCenter edition key is "vc.standard.instance"

Reply
0 Kudos
oschroeder8
Contributor
Contributor
Jump to solution

I tried that but EditionKey is not a valid property for the LicenseKeyEntry object.

PS C:\temp> $licenseKeyEntry.EditionKey = "vc.standard.instance"

The property 'EditionKey' cannot be found on this object. Verify that the property exists and can be set.

At line:1 char:1

+ $licenseKeyEntry.EditionKey = "vc.standard.instance"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : PropertyAssignmentException

Reply
0 Kudos
Craig_Baltzer
Expert
Expert
Jump to solution

Have a look at the posting by Brian Graf over at Adding License Keys to vCenter with PowerCLI | Brian Graf's Virtualization Blog

I've cut out the code below which works in our lab environment in PowerCLI 6...

# Assumes you're already connected to the vCenter server where the license should be added


$LicKey = "xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"

$VcLicMgr=$DefaultVIServer

$LicMgr = Get-View $VcLicMgr

$AddLic= Get-View $LicMgr.Content.LicenseManager

$AddLic.AddLicense($LicKey,$null)

Reply
0 Kudos
oschroeder8
Contributor
Contributor
Jump to solution

Yeah, read that article and that part works perfectly. But that just adds the license to the pool of licenses but doesn't actually assign it to the vCenter server. I can see the license but haven't been able to associate it with vCenter. The usage counter remains 0 for that license. As mentioned above, I tried assigning the license to the vCenter instance referenced by its UUID:

$vCenterLicenseAssignmentManager.UpdateAssignedLicense($vCenterUuid, $vCenterLicenseKey, $vCenterDisplayName)


But that did not work as the UpdateAssignedLicense method has been removed from the License Assignment Manager. So I tried exploring the bulk assignment route but am stuck on the TypeID which I cannot find a reference for as to what the valid TypeIDs are. The only example that I have been able to find references a license for vSphere servers.

Reply
0 Kudos
Craig_Baltzer
Expert
Expert
Jump to solution

Gotcha, understand what you're chasing now. Can you get anything from Onyx to see what the web client is doing when it does the license assignment, or is it just all "private API" flagged stuff?

oschroeder8
Contributor
Contributor
Jump to solution

Didn't know about Onyx so I spent some time trying to get that working. Unfortunately it breaks vCenter's web client. Supposedly the requirement is vSphere Web Client Version 6.0.0 Build 2559277. But I can only download later versions from the VMware site. (Even 6.0.0b is a higher version than what is required.)

Anyone have a working installation of Onyx on vCenter 6 and could capture the PowerCLI for assigning a vCenter 6 license to an asset?

Reply
0 Kudos
ccalvetTCC
Enthusiast
Enthusiast
Jump to solution

Interesting topic.

I did not manage to find a solution neither.

However it seems directly linked to:

https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.LicenseAssignmentMana...

UpdateAssignedLicense

Deprecated. As of vSphere API 6.0 use cis.license.management.SystemManagementService

This is probably linked to the move of the “licensing service” to the platform service controller introduced with vSphere 6.0

I have looked for more information regarding cis.license.management.SystemManagementService without any success.

Consequently, i have opened a case with VMware to ask for some clarification, and how we can access via API this “cis.license.management.SystemManagementService”

When I will get an answer from VMware support I will post it here

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC
ccalvetTCC
Enthusiast
Enthusiast
Jump to solution

Hi,

I managed to assign a new license to a vCenter 6.0 with the API method "UpdateAssignedLicense" even if it is deprecated.

$vCenter6License = "Replace by a valid vCenter 6 License"

$MyVC = connect-viserver "YourVC"

$LicenseManager = get-view ($MyVC.ExtensionData.content.LicenseManager)

$LicenseManager.AddLicense($vCenter6License,$null)

$LicenseAssignmentManager = get-view ($LicenseManager.licenseAssignmentManager)

$LicenseAssignmentManager.UpdateAssignedLicense($MyVC.InstanceUuid,$vCenter6License,$Null)

Tested with:

vCenter Appliance Version 6.0 Build 2559267

PowerCLI 6.0 Release 2

Support has provided me some information regarding “cis.license.management.SystemManagementService”

but I will wait to have more details before posting the result.

They have also mentioned this:

Customer can still use the old LicenseAssignmentManager methods (which are documented as deprecated in API reference guide).

This is why I gave a try to the "UpdateAssignedLicense".

Note the URL in the previous link i have provided was wrong. This is the correct one:

vSphere 6.0 Documentation Center

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC
oschroeder8
Contributor
Contributor
Jump to solution

Christophe,

Thank you for investigating this a bit further. I had opened up a ticket with VMware myself but due to a missing SDK support entitlement they were not able to assist me with this.

I can see that your example varies a little bit from what I tried before. I did not actually see the UpdateAssignedLicense method when doing my testing, but I did not use Get-View to create the $LicenseAssignmentManager object which I think is what might have done the trick.

In either case this solved my issue of not being able to license vCenter.

I would very much love to get more data on the “cis.license.management.SystemManagementService” method of managing licenses as that seems to be the way to go in the future. But for now this works for me and I have marked your response as the answer. Thank you very much again.

Reply
0 Kudos
ccalvetTCC
Enthusiast
Enthusiast
Jump to solution

Answer from VMware support

[Customer] Are the following API "CIS API for 2016" public and documented?

Or as the name suggest, they will be available in 2016 ?

[VMware]The mentioned API is not yet made public or documented. For the moment you can assure the customer that they can continue using the old one, since it will be there for at least two major releases.

Blog: http://thecrazyconsultant.com/ | Twitter: @ccalvetTCC
Reply
0 Kudos
roman79
Enthusiast
Enthusiast
Jump to solution

If someone needs more advanced solution, there is a blog post that covers this topic - http://thatcouldbeaproblem.com/?p=934.

Reply
0 Kudos