Query vRAM

After the Cloud Infrastructure Launch Forum event from July 12th 2011, it seemed that the new licensing model attracted more blog posts and tweets than the 140 new features in vSphere 5.

As one could imagine, one of the most heard questions was, what will I need to pay in the new licensing model. As a pro-active measure, I decided to write a short script that would tell me what vRAM entitlement my current vSphere 4 licenses would offer me.

Update August 4th 2011 08:30: VMware updated the vRAM calculation specifications. See the VMware vSphereβ„’ 5.0 Licensing, Pricing and Packaging White Paper.

Update July 13th 2011 14:45: Apparently you have a vRAM pool per license type. I updated the script.

The script

Annotations

Line 3-7:Β  The vRAM entitlement per type of license is stored in a hash tab.

Line 6: The script doesn’t take into account that the Advanced licenses will be converted to Enterprise.

Line 16: Note, the current version of the script only uses allocated licenses to calculate your vRAM entitlement. If you happen to have unallocated licenses, they will currently not be reflected in your vRAM entitlement.

Line 17: The script uses the QueryAssignedLicenses method. Unfortunately this only works for vSphere 4.1 and higher.

Line 22: Calculate the amount of configured RAM for the guests. This will give the potential maximum vRAM you could need.

Line 23: Calculate the amount of RAM used by powered on guests

Sample run

Just call the function: Get-vRAMInfo.

It will produce something like this.

If your vRAMUsed amount turns out to be higher than your vRAMEntitled amount, you will have to acquire extra licenses.

In my test environment I don’t need additional licenses πŸ˜†

47 Comments

    Marc

    Can I run this against ESXi host or do I need Vcenter?

    Thanks

      LucD

      @Marc, I’m afraid the script is intended to be run against vCenter.

    Korey Klier

    I’m admitted new to Powershell. I’m having a bit of trouble with this function. I’ve connected to my vcenter(v4.1), I’ve sourced the Powershell script, but I am receiving several errors.

    Get-View : Cannot validate argument on parameter ‘Id’. The argument is null or
    empty. Supply an argument that is not null or empty and then try the command ag
    ain.
    At C:\cdns\bin\Get-vRamInfo.ps1:13 char:27
    + $licAssignMgr = Get-View <<<< $licMgr.LicenseAssignmentManager
    + CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
    idationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
    ation.Commands.DotNetInterop.GetVIView

    You cannot call a method on a null-valued expression.
    At C:\cdns\bin\Get-vRamInfo.ps1:18 char:47
    + $lic = $licAssignMgr.QueryAssignedLicenses <<<< ($_.Extensiondata.MoRef.V
    alue)
    + CategoryInfo : InvalidOperation: (QueryAssignedLicenses:String)
    [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Cannot index into a null array.
    At C:\cdns\bin\Get-vRamInfo.ps1:19 char:21
    + $licType = $lic[ <<<< 0].AssignedLicense.EditionKey
    + CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

    I'm sure I'm missing something.

      LucD

      @Korey, let’s start from the beginning.
      Did you connect to the vCenter before running the script ?

      Connect-VIServer -Server MyVC

    Aaron

    I’ve just installed the PowerCLI (VMware-PowerCLI-4.1.1-332441). Unfortunately when I run your script nothing at all is happening. Any ideas?

      LucD

      @Aaron, are you running this against a vSphere 4.1 installation ?
      Unfortunately the script will not work for pre-4.1 versions.

    wuffers

    Please take the time to fill out this vSphere 5 migration survey:
    https://wuffers.net/2011/07/18/vsphere-5-migration-survey

    We need more data! Will be posting results in the VMTN thread: https://communities.vmware.com/thread/320877.

    Andreas Peetz

    Hi Luc,
    very good job!
    I’d only like the script to take into account not only the currently assigned CPU licenses, but also the unassigned ones, because they would also add up to the vRAM entitlements with vSphere 5.
    – Andreas

      LucD

      @Andreas, that is a good suggestion.
      I’ll try to incorporate that in a new version.

    Kerrod Wells

    Thanks for making this available. A quick upgrade to our PowerCLI and it worked perfectly.

    Thankfully no new licenses needed for us at this stage.

    cwjking

    Well,

    I guess currently we are about 106 pCPU – with 1928 GB of vRam. By upgrading our licenses we are at 5088 GB of Entitled vRAM (All ent + shop). We planned on migrating/consolidating our clusters to only 42 CPU’s total which would put us right at 2016 if we did it after migrating. This means we would have to purchase more licenses for future capacity. But if we upgraded all our licenses (which wont happen) we wouldn’t have to worry about a thing. So in the long run it doesn’t really affect shops and there is also not a lot of information on prior vsphere 4 updating cost. I am under the impressions we negotiated our licenses to vSphere 4 prior but just have completed the upgrade. Either way we are going to have to be more tactical to not put ourselves in a bind.

    Chad King

    I would love to post mine to show how much this licensing model is going to screw us over but obviously we aren’t all 4.1 like some people ;). I already had a colleague say to me on the phone “I have to budget for 40 more licenses for our p2v for the rest of our environment is going to have to wait, we weren’t scaling out, we were scaling up” – Sadly, for some folks they are going to look else where especially in businesses where low cost is important like logistics. I will post mine but I am sure ours will probably fall into the vmware sweet spot – lol.

    Chad King

    too bad its just for 4.1 – that kind of sucks imo.

    We have a very diverse environment even some host on 3.5 still. Anyways, I am sure we wont be paying more but this def changes the name of the game for us because we gage on capacity not vRAM.

    Justin

    Hi all… I started a thread here in the hop that people will post the results.

    https://communities.vmware.com/thread/321065

    OfficeGlen

    For some reason I my vSphere 4 Standard licenses are reporting as the edition type “esxFull” instead of esxStandard

    To fix I added the follow line to the $vRAMtab array:
    “esxFull”=24;

    Without that line my vRAMEntitled amount for vSphere Standard was not displaying a value.

      LucD

      @OfficeGlen, thanks for the info. I updated the table.
      As you can imagine I don’t have all the license types present in my test environment πŸ™‚

      If some of the other licensekeys are not correct, please let me know!

    fletch00

    Thanks for writing this

    Seems to imply you can make more efficient use of your entitlement by ratcheting down the unused memory allocation per VM
    (Therefore a script to show the most overallocated VMs in terms of memory would logically be next!?)

      LucD

      @Fletch00, that will be indeed the logical follow-up post πŸ™‚

    John Dias

    @John K
    Same here and I’m running build 332441

      LucD

      @John, did you run the script against a pre-4.1 vCenter ?
      For pre-4.1 the current script will not work due to the differences in the LicenseManager methods in the API.

    Wayne

    @LucD

    We’re using vSphere 4.0 u2

      LucD

      That’s the reason, pre 4.1 the vSphere License Manager is different.
      The call the script makes to collect the license information will not return anything.
      Let me check if I can script pre 4.1 support for the script.

      LucD

      The current script only will work for vSphere 4.1 and higher. The reason is that the QueryAssignedLicenses method doesn’t work for earlier vSphere versions πŸ™

    Wayne

    @LucD
    I’m getting the same results as Benjamin. I’ve ran connect-viserver and I’m using snapin version:
    VMWare vSphere PowerCLI 4.1 U1 build 332441

    Ideas?

      LucD

      I tested the script against in a vSphere 4.1U1 environment.
      Are you perhaps using another version ?

    John K

    @LucD

    Weird, I’m getting no result either even when adding ‘connect-viserver myvc’ to the script

    Andy

    What kind of results are you seeing – is the new model going to hurt or help you

      LucD

      @Andy, in our environment we are covered, no need to acquire extra licenses.
      But as it was mentioned in other fora and tweets, it all depends (size of your VMs, type of licenses you currently have, your VM density per processor…).
      I’m sure the last word about this hasn’t been said yet πŸ™‚

    Benjamin

    Are you using only the powercli snap-in? I run this and no output at all, just returns to the command line.

      LucD

      @Benjamin, the script only uses the (latest) PowerCLI snapin.
      And you have to have made the connection to the vCenter before calling the function.

      Connect-VIServer -Server myVC

    Dan Hayward

    Awesome script as usual Luc, like the update, certainly makes things a little more clarified πŸ™‚

    Troy Clavell

    Good Stuff!!

    Gabrie van Zanten

    Hi Luc and Hugo,

    Great scripts. But since you’re querying the VMs anyway, maybe also query how much RAM on average they really use. So it will tell me that the VM I gave 6GB only uses 4GB. And that I can save 2GB on that VM.

    Gabrie

    Duncan

    Great script Luc,

    It would be good if people could post the results.

    Duncan

      LucD

      Thanks Duncan, that is indeed a good idea and would provide some actual input to the theoretical discussion that is going on since yesterday.

    Josh_Atwell

    “Increasing the Pooled vRAM Capacity
    If necessary, the easiest way to expand pooled vRAM capacity
    is to add more vSphere CPU licenses of the same edition to
    the vRAM pool. Alternatively, customers can upgrade all CPU
    licenses in the vRAM pool to a vSphere edition with a higher
    base vRAM entitlement.”

    I do not see where it says one way or another if you are able to have multiple vRAM pools on the same vCenter server or Linked vCenter Servers. They imply that if you have a vCenter server or linked vCenter servers they work as a single vRAM pool/entitlement. But also give indication based on management of pools that it is vCenter server specific.

    It does seem reasonable however that you could have multiple vCenter servers at different licensing levels.

    “As long as the total consumed
    vRAM across all virtual machines managed by a VMware vCenter
    instance or multiple linked VMware vCenter instances is less or
    equal to the total available vRAM, vSphere is correctly licensed.”

    In conclusion I’d say it goes as follows:
    1. Each vCenter server has one level of licensing and that vCenter server has it’s own vRAM pool.
    2. If you have multiple vCenter servers linked then you can share memory between the vRAM pools to come up with your total vRAM entitlement.
    3. You can add a license on any of your linked vCenter servers to increase your overall vRAM entitlement but my gut tells me that could let people cheat on feature differences between versions.

    If this is the case then management of this will be a nightmare without some really good tools.

      LucD

      @Josh, that was my interpretation as well at first, but the majority of the commenters seem to agree that there is a vRAM pool per license type.
      Perhaps VMware will release a clarification statement in the coming hours/days.

    Rob Upham

    @LucD
    Hi Luc … The other folks are correct – check the last paragraph on Page 7 of the PDF:
    “Note that all hosts in a vRAM pool must be licensed with the same vSphere edition or, in other terms, vRAM entitlements are pooled by vSphere Edition. It is possible to manage mixed environments of hosts licensed with different vSphere Editions from the same
    vCenter, however this will create multiple vRAM pools. vRAM capacity can only be shared among servers licensed with the same vSphere Edition.”

      LucD

      Rob/Mark/Dan/Didier, thanks for the confirmation.
      I updated the script, it now returns the vRAM pool information per license type.
      At least I learned something today πŸ™‚

    Mark

    Luc,

    Based on the FAQ in https://www.vmware.com/files/pdf/vsphere_pricing.pdf the vRAM pools are by edition so it is not one global pool but actually 5.

    Dan Hayward

    @LucD

    Hello again πŸ™‚

    It’s in the Q&A bit at the end, as well as other places:

    Q: What is the available pooled vRAM capacity of my environment?
    A: Available pooled vRAM is equal to the sum total of vRAM entitlements for all vSphere licenses of a single edition, managed by a single instance of VMware vCenter Server or by multiple instances of VMware vCenter Server in Linked Mode.

    Dan

    PiroNet

    @LucD Indeed you cannot mix different license types…

    Dan Hayward

    @LucD

    Hey Luc,
    Licenses have to be of the same type, you can’t pool “standard” with “enterprise plus” from what I’ve read.
    Also, it appears vRAMused should not exceed vRAMEntitled rather than vRAMConfigured as the licensing documents say that “when a VM is powered on, the vRAM configured counts against the vRAM entitlement”…

    Dan

      LucD

      @Dan, thanks for the vRAMUsed remark. That was indeed a typo in the last paragraph. It’s corrected.
      On the vRAM pooling principle, I’m not sure that you can’t mix license types in the calculation of the vRAM pool. I have reread the white paper, but can’t find where it says this explicitely. Please correct me if I’m wrong, this is new for all of us I assume πŸ˜‰

    Rynardt Spies

    Cool!

    Awesome job. I’ll bookmark this!

    Thanks

    Hugo Peeters

    Hey Luc!
    Great minds think alike πŸ˜‰
    https://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/
    I like how you use the license manager in stead of the actual pCpu count. One thing I added though, is show how many additional licenses you’d need if you are over your vRAM entitlement.
    Grtz,
    Hugo

      LucD

      Lol. Giving the number of required licenses is indeed a great feature, but I deliberately left that out, because I think that the pooled vRAM concept, offers the possibility to acquire extra licenses to increase the total vRAM, not necessarily of the same type.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.