VMware Cloud Community
Munster99
Enthusiast
Enthusiast

Help required with the vSphere Web Services SDK

Hello Everyone

I know this 'might' have been already asked, but I need to help as I’m having major problems understanding this. So, if someone can point me in the right direction, that would be greatly appreciated.

I am 'competent' (to a certain extent) Smiley Wink in PowerCLI and feel comfortable creating functions, scripts and even use the Get-View Cmdlet in a load of my scripts to improve performance. Where my knowledge seems to be lacking, is understanding how to use the vSphere Web Services SDK to step up to the 'next' level in my PowerCLI scripting. I have read some of the literature pertaining to the SDK but where I am having problems is actually, implementing it practically. So for example how I go from trying to find a 'property' say, to getting to the correct object to give me the relevant information I require. Kinda hard to explain but it might make a bit more sense if I were to use an example:

So here goes ...... Say for example I am looking for the 'TOTALSLOTS' in a cluster. I do a search in the API (All properties) and it gives me the following property situated in the ClusterDasFailoverLevelAdvancedRuntimeInfoSlotInfo data object.

pastedImage_3.png

Now if you read the ‘totalslots’ property it says ‘See SlotInfo’. You go to the ‘SlotInfo’ property which is of type ClusterDasFailoverLevelAdvancedRuntimeInfoSlotInfo . So my understanding would be that if I could get a ‘SlotInfo’ data object I could get to the total slots property.  ?!?!?!?

So when I look at that object it comes back with the following:

pastedImage_4.png

Now what this tells me is that it’s a property of the previous object (which I know) but what I do not know is where to go from here. ?!??

If anyone can point me in the right direction that would be extremely helpful. I just need some assistance for that ‘Eureka’ moment and hopefully I’ll be fine after that :smileycool:

As always many thanks in advance Smiley Happy

Munster

Tags (1)
Reply
0 Kudos
36 Replies
LucD
Leadership
Leadership

You have to follow the trail back to find out where the object comes from.

  • ClusterDasFailoverLevelAdvancedRuntimeInfoSlotInfo is a property in ClusterDasFailoverLevelAdvancedRuntimeInfo
  • ClusterDasFailoverLevelAdvancedRuntimeInfo extends ClusterDasAdvancedRuntimeInfo
  • ClusterDasAdvancedRuntimeInfo is returned by RetrieveDasAdvancedRuntimeInfo
  • RetrieveDasAdvancedRuntimeInfo is a method on a ClusterComputeResource object
  • ClusterComputeResource is the object that is available under the ExtensionData property of a cluster object returned by Get-Cluster

To access the you can do

$clusterName = 'MyCluster'

$cluster = Get-Cluster -Name $clusterName

$info = $cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo()

$info


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

WOW ! Thanks Luc I'm slowly getting it but I can get to the object via PowerCLI but how does one go abouts getting the Totalslots Value. I mean when i run the following code as you mentioned I get the following:

C:\> $cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() | format-table -autosize

DasHostInfo      VmcpSupported      HeartbeatDatastoreInfo

-----------             -------------                ----------------------

                                                          {VMware.Vim.DasHeartbeatDatastoreInfo, VMware.Vim.DasHeartbeatDatastoreInfo}

I understand this is the MANAGED OBJECT. Now having followed the 'object' trail I was wondering where I go from here ??? :smileycry:

Munster

Reply
0 Kudos
LucD
Leadership
Leadership

Once you have the object, you can extract/query the properties in that object, just like you would with a regular .Net object.

For example like this

$clusterName = 'MyCluster'

$cluster = Get-Cluster -Name $clusterName

$info = $cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo()

$info | Select -ExpandProperty TotalSlots


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

This is where I'm getting confused because those properties do not exist here ??!?? All I am getting is the following:

C:\> $cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() | gm

   TypeName: VMware.Vim.ClusterDasAdvancedRuntimeInfo

Name                   MemberType Definition

----                   ---------- ----------

Equals                 Method     bool Equals(System.Object obj)

GetHashCode            Method     int GetHashCode()

GetType                Method     type GetType()

ToString               Method     string ToString()

DasHostInfo            Property   VMware.Vim.ClusterDasHostInfo DasHostInfo {get;set;}

HeartbeatDatastoreInfo Property   VMware.Vim.DasHeartbeatDatastoreInfo[] HeartbeatDatastoreInfo {get;set;}

VmcpSupported          Property   VMware.Vim.ClusterDasAdvancedRuntimeInfoVmcpCapabilityInfo VmcpSupported {get;set;}

Am I doing something wrong ??!?

Reply
0 Kudos
LucD
Leadership
Leadership

It looks as if you are only getting part of the output.

totalslots.png


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

Reply
0 Kudos
LucD
Leadership
Leadership

But wait a minute, the missing properties will only be there if you have the cluster configured with a "failover level admission control policy."

Could it be that you have not activated that on that cluster ?


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

This is REALLY wierd ??!?

The typename you are showing is ClusterDasFailoverLevelAdvancedRuntimeInfo, however my typename is showing as ClusterDasAdvancedRuntimeInfo.

I don't how that is ??!? Because all I did was what you mentioned .....

$cluster = get-view -ViewType computerresource -Filter @{'Name'='cluster1'}

($cluster.RetrieveDasAdvancedRuntimeInfo()).gettype().name = ClusterDasAdvancedRuntimeInfo


(Its not because i'm running Powercli v6 is it ???)

Reply
0 Kudos
LucD
Leadership
Leadership

I'm also running PowerCLI v6, so it can't be that.

But that confirms my previous remark, the ClusterDasFailoverLevelAdvancedRuntimeInfo object is an extension of the ClusterDasAdvancedRuntimeInfo object.

But you only get that "for a cluster that has been configured with a failover level admission control policy"

Is that activated on your cluster ?


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

I think you mean the following ?

C:\> $cluster.Configuration.DasConfig

Enabled                    : True

VmMonitoring               : vmMonitoringDisabled

HostMonitoring             : enabled

VmComponentProtecting      :

FailoverLevel              :

AdmissionControlPolicy     : VMware.Vim.ClusterFailoverResourcesAdmissionControlPolicy

AdmissionControlEnabled    : True

DefaultVmSettings          : VMware.Vim.ClusterDasVmSettings

Option                     :

HeartbeatDatastore         :

HBDatastoreCandidatePolicy : allFeasibleDsWithUserPreference

LinkedView                 :

C:\> $cluster.Configuration.DasConfig.AdmissionControlPolicy | ft -au

CpuFailoverResourcesPercent MemoryFailoverResourcesPercent

--------------------------- ------------------------------

                         15                             15

Reply
0 Kudos
LucD
Leadership
Leadership

Yes, that should be it.

But then I don't immediately see why you don't get the object.

These objects were introduced in vSphere 4, so that shouldn't be the issue either


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

OK so this is what I have installed

C:\> Get-PowerCLIVersion

PowerCLI Version

----------------

   VMware vSphere PowerCLI 6.0 Release 1 build 2548067

---------------

Component Versions

---------------

   VMWare AutoDeploy PowerCLI Component 6.0 build 2358282

   VMWare ImageBuilder PowerCLI Component 6.0 build 2358282

   VMware License PowerCLI Component 6.0 build 2315846

   VMware vSphere PowerCLI Component 6.0 build 2548068

And when I create my Get-View Variable and use both the following values I still get the same results ?!??!

$ClusView = Get-view -ViewType ComputeResource -filter @{'Name'='cluster'}

$ClusView2 = Get-view -ViewType ClusterComputeResource -filter @{'Name'='cluster'}

C:\> $ClusView2.RetrieveDasAdvancedRuntimeInfo() | ft -au

DasHostInfo VmcpSupported HeartbeatDatastoreInfo

----------- ------------- ----------------------

                          {VMware.Vim.DasHeartbeatDatastoreInfo, VMware.Vim.DasHeartbeatDatastoreInfo}

C:\> $ClusView.RetrieveDasAdvancedRuntimeInfo() | ft -au

DasHostInfo VmcpSupported HeartbeatDatastoreInfo

----------- ------------- ----------------------

                          {VMware.Vim.DasHeartbeatDatastoreInfo, VMware.Vim.DasHeartbeatDatastoreInfo}

So, I thought it might be because I was using the incorrect ViewTypes but I still get teh same results !?!?!?!?

Any ideas ?

Reply
0 Kudos
LucD
Leadership
Leadership

I suspect your Get-View filter is returning 2 objects.

Can you check if $ClusView and $ClusView2 contain more than 1 object ?


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

I thought that might be a possibility But i've checked and it is reporting only one object back.

$ClusView = Get-View -ViewType ClusterComputeResource -Filter @{'Name'='^(clustername)$'}

I've done this with and without the '^' & '$' but there is only one object coming back.

Reply
0 Kudos
LucD
Leadership
Leadership

Ok, I did some further tests, and I can only reproduce what you are seeing when I disable HA on the cluster.


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

Hey Luc

I don't know whats going on but its still not working ??!?!?! What i tried was the following:

These are the results i keep getting ?!??!??

1 - Tried it as normal

C:\> $ClusViewb4 = get-view -ViewType clustercomputeresource -Filter @{'name'='Cluster1'}

C:\> ($ClusViewb4.RetrieveDasAdvancedRuntimeInfo()).gettype().name

ClusterDasAdvancedRuntimeInfo

2 - Disabled HA then tried it

C:\> $ClusViewafter = get-view -ViewType clustercomputeresource -Filter @{'name'='Cluster1'}

C:\> ($ClusViewafter.RetrieveDasAdvancedRuntimeInfo()).gettype().name

ClusterDasAdvancedRuntimeInfo

3 - Re-enabled HA and tried it again

C:\> $ClusVieworig = get-view -ViewType clustercomputeresource -Filter @{'name'='Cluster1'}

C:\> ($ClusVieworig.RetrieveDasAdvancedRuntimeInfo()).gettype().name

ClusterDasAdvancedRuntimeInfo

Am I doing something wrong here ?!?!? Smiley Sad

Munster

Reply
0 Kudos
LucD
Leadership
Leadership

You're only displaying the object type, did you actually look at the content of the returned object ?

Remember ClusterDasFailoverLevelAdvancedRuntimeInfo is an extension of ClusterDasAdvancedRuntimeInfo


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

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

Yes and in all the three scenarios I get the following:

C:\> $ClusVieworig.RetrieveDasAdvancedRuntimeInfo() | ft -au

DasHostInfo      VmcpSupported      HeartbeatDatastoreInfo

-----------             -------------                ----------------------

                                                     {VMware.Vim.DasHeartbeatDatastoreInfo, VMware.Vim.DasHeartbeatDatastoreInfo}

C:\> $ClusVieworig.RetrieveDasAdvancedRuntimeInfo() | sel -ExpandProperty HeartbeatDatastoreInfo | ft -au

Datastore                                 Hosts                                                                                                                 LinkedView

---------                                      -----                                                                                                                     ----------

Datastore-datastore-672609       {HostSystem-host-191275, HostSystem-host-191539, HostSystem-host-191738}

Datastore-datastore-3055           {HostSystem-host-191275, HostSystem-host-191539, HostSystem-host-191738}

??

Reply
0 Kudos
Munster99
Enthusiast
Enthusiast

Any ideas ?????

I've tried this on two other vCenters we have and that 'RetrieveDasAdvancedRuntimeInfo' method comes back with the following objects:

   TypeName: VMware.Vim.ClusterDasAdvancedRuntimeInfo

Name                             MemberType           Definition

----                                  ----------                   ----------

Equals                          Method                    bool Equals(System.Object obj)

GetHashCode                Method                    int GetHashCode()

GetType                        Method                    type GetType()

ToString                        Method                    string ToString()

DasHostInfo                  Property                   VMware.Vim.ClusterDasHostInfo DasHostInfo {get;set;}

HeartbeatDatastoreInfo   Property                  VMware.Vim.DasHeartbeatDatastoreInfo[] HeartbeatDatastoreInfo {get;set;}

VmcpSupported             Property                  VMware.Vim.ClusterDasAdvancedRuntimeInfoVmcpCapabilityInfo VmcpSupported {get;set;}

Reply
0 Kudos
LucD
Leadership
Leadership

I tried all possible variations, and I can only seem to reproduce what you are seeing when I disable HA in the cluster.

Btw, in which vSphere version are you doing this ?

I tested in vSphere 5.5


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

Reply
0 Kudos