How to retrieve Hyper-V GUID

Отвечено How to retrieve Hyper-V GUID

  • Sunday, May 13, 2012 2:46 PM
     
     

    Hi,

    Does it exist a HyperVisor unique GUID as it exists for Hyper-V VM ?

    Is this Unique ID retrievable by WMI API or whatever  (I need to get it from a software running on the HyperVisor) ?

    Does it mean that if the host migrate to another cluster  this ID is kept ?

    Thanks for help.

    Regards,

All Replies

  • Monday, May 14, 2012 2:17 AM
     
     

    each virtual machine has a GUID, you can get it use a script. check the following blog.

    http://blogs.technet.com/b/m2/archive/2008/07/04/how-to-get-the-bios-guid-from-a-hyper-v-vm.aspx

  • Monday, May 14, 2012 3:15 PM
    Moderator
     
     

    Each hypervisor has a guid as well, as does each vNIC, each cluster, each cluster application, etc.

    As with other hypervisors each device in the virtual world has a GUID.  All accessible using WMI (powershell as well in Win8).

    These are not exposed in the GUI.

    In a cluster the VM has a cluster application GUID that is unique to the cluster object.  This is different from the VM GUID.  Each node in the cluster has a clusder node GUID, this is different from the hypervisor GUID.

    If you want just the virualization GUIDs then you stay in the virtualization namespace of WMI.

    By the way - there are multiple ways to 'migrate' a VM - in some cases the VM GUID is sticky, in other scenarios it is not.  So you have to be very specific about your migration scenarios.

    Migration with clustering has two options for example - Live Migration, and just migration of a non-running VM.  The results can be different. There is also how SCVMM does migration - it has multiple types as well - and if you don't develop to SCVMM, but rather to Hyper-V using WMI you will also see different results with each type.  You would have to test each type to see.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.


  • Tuesday, May 15, 2012 7:13 PM
     
     

    Hi,

    Very useful infos , Brian . Thx a lot.
    What I want to do is to build a tree describing following levels : cluster , hypervisor and VM ; I try to determine how to  give to each item at each level an UniqueIdent.
    So, I"ll be able to describe in this tree the links betwwen these UniqueIdents. I want these UniqueIdents as less as possible change by configuration changes ( Vm migrations , nodes migrating from a cluster to another, adding a non-clusterized node in an existing cluster.)
    If I"ll understand your explanations :
    - VMGUID and Hypervisor GUID are retrievable from the Hyeprvisor by using WMI API (as you say in the virtualization namespace of WMI); am I right ? 
    - VMGUID "may" be unvariable under some restrictions related to migration types; am I right ? 

    Regarding HyperVisor GUID, what's up regarding both cases I mentioned earlier (migration to another cluster , inegration in an existing cluster) ? It's may be better to use HyperVisor GUID than cluster Node GUID ( Hypervisor GUID should be cluster independant)?

    Does it exist a cluster GUID ? If yes, how may I retrieve it ? Ideal , in my case , would be to get it from a node belonging to this cluster, as a kind of NodegetParent().

    Hope this clarify a little bit what I want to do.

    Thanks in advance for help.

    Regards,

    Jean-Pierre


  • Tuesday, May 15, 2012 9:36 PM
    Moderator
     
     

    So, this is where this gets messy.

    You have two deployment models today (the two big thing you need to accomidate):

    1. standalone Hyper-V
    2. Clustered Hyper-V

    Combine that with two VM types:

    1. High Availability (managed by Failover Clustering)
    2. non-HA (not managed by Failover Clustering)

    Toss these in a pot and stir.  As clustered hosts can support both HA and non-HA VMs.  And a standalone can only support non-HA VMs.  HA is required to be turned on to support Live Migration.

    Now - in the WMI of an HA VM you will find it cluster application GUID, a reference to the VM GUID, and a reference to the cluster node.  From the Cluster node you find a reference to the hypervisor GUID.

    In the WMI Cluster namespace you have the cluster entities (the things that the Cluster Service cares about) - Nodes, HA Applications, the Cluster.

    In the Virtualization WMI namespace you have the virtualization entities that the hypervisor cares about - VMs, virtual devices, linkages to physical devices, hosts.

    Clustering gives you references to virtualization.  Virtualization does not give you references to clustering.  (this gets better with Win8 BTW)

    Any cluster node can tell you the cluster it is a member of - but the namespace is not intuitive.  So it makes it hard to find, but it is there.

    XenServer has the same model, I don't know about VMware - Hyper-V and XenServer both use the DMTF CIM model in the virtualization space.  It is the Clustering WMI space that is a bit unique.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.


  • Wednesday, May 16, 2012 8:09 PM
     
     

    Hi,

    Thanks for your useful clarifications.

    I did some investigations :

    A) By issuing Get-WmiObject -Namespace root\virtualization -class msvm_computersystem command , I'am able to get VM  GUID but nothing for Hosting "Caption : Computer System" , I was expecting hypervisor GUID, I got the host name (H1 in my case) :


    __GENUS                       : 2

    __CLASS                       : Msvm_ComputerSystem

    __SUPERCLASS                  : CIM_ComputerSystem

    __DYNASTY                     : CIM_ManagedElement

    __RELPATH                     : Msvm_ComputerSystem.CreationClassName="Msvm_ComputerSystem",Name="H1"

    __PROPERTY_COUNT              : 29

    __DERIVATION                  : {CIM_ComputerSystem, CIM_System, CIM_EnabledLogicalElement, CIM_LogicalElement...}

    __SERVER                      : H1

    __NAMESPACE                   : root\virtualization

    __PATH                        : \\H1\root\virtualization:Msvm_ComputerSystem.CreationClassName="Msvm_ComputerSystem",Name="H1"

    AssignedNumaNodeList          :

    Caption                       : Hosting Computer System

    CreationClassName             : Msvm_ComputerSystem

    Dedicated                     :

    Description                   : Microsoft Hosting Computer System

    ElementName                   : H1

    EnabledDefault                : 2

    EnabledState                  : 2

    HealthState                   : 5

    IdentifyingDescriptions       :

    InstallDate                   :

    Name                          : H1

    NameFormat                    :

    OnTimeInMilliseconds          :

    OperationalStatus             : {2}

    OtherDedicatedDescriptions    :

    OtherEnabledState             :

    OtherIdentifyingInfo          :

    PowerManagementCapabilities   :

    PrimaryOwnerContact           :

    PrimaryOwnerName              :

    ProcessID                     :

    RequestedState                : 12

    ResetCapability               : 1

    Roles                         :

    Status                        :

    StatusDescriptions            : {OK}

    TimeOfLastConfigurationChange :
    .....

    Did I misunderstand something ?

    B)  MSCluster_ClusterToNode class provides follwing infos:

    MSCluster_Cluster REF Antecedent;

    MSCluster_Node REF Dependent;

    It may be possible by following these links to retrieve Cluster_Cluster and Cluster_Node classes; am I right?

    1) The MSCluster_Cluster class is a dynamic WMI class that represents a cluster.

    Is the property "Name" of this class the Cluster GUID or only the name of the cluster ?
    (so it will change if Cluster is renamed)

     

    2) The MSCluster_Node class is a dynamic WMI class that represents a cluster.

    a) Is the property "Name" of this class  MSCluster_Node  a GUID of the node ?

    It will change if this node moves to another cluster ( if it's possible)

     


    ..From the Cluster node you find a reference to the hypervisor GUID....


    b) Is the property  "OtherIdentifyingInfo" a way to retrieve the hypervisor GUID of this cluster node ?

    Thanks for help.

    Regards,

    J.P.



    • Edited by ribeauville Wednesday, May 16, 2012 8:12 PM
    •  
  • Wednesday, May 16, 2012 9:07 PM
    Moderator
     
     Answered

    You are getting there.  So this is CIM.  If you are not already familiar with CIM then you need to check that.

    The GUID is represented in different ways - some places you will find it on the object itself but not on a referring object.  So you have to walk the referring object.

    BTW - this is so much easier with Win8 as it is all more CIM like and some objects are proper references to other objects.

    It has been some time since I was in the Cluster space and I would have to poke around.

    The last time i did anything with this was here:

    http://itproctology.blogspot.com/2011/12/modifying-hyper-v-server-settings-with.html

    http://itproctology.blogspot.com/2011/12/changing-vm-vnic-mac-from-dynamic-to.html

    http://itproctology.blogspot.com/2011/11/hyper-v-wmi-association-null-returns.html


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

    • Marked As Answer by ribeauville Friday, June 22, 2012 7:44 PM
    •