VMware Cloud Community
ChrisROI
Enthusiast
Enthusiast

finding and using Object Property

Hi,

 

often, I face the same problem:

I have a Data Object type or Property an dont know, where to find it, to bring it on screen/report.

I look it up on the API website, find it but dont know how to retrieve it.

 

For example: https://developer.vmware.com/apis/1192/vsphere

I go to API website, choose "all properties" and search for "TotalSlots". That gives me a complex result:

  • Data Object - ClusterDasFailoverLevelAdvancedRuntimeInfo(vim.cluster.DasFailoverLevelAdvancedRuntimeInfo)
  • Extends: ClusterDasAdvancedRuntimeInfo 
  • Properties inherited from ClusterDasAdvancedRuntimeInfo
    dasHostInfo, heartbeatDatastoreInfo, vmcpSupported

Now, what I try to do is, searching with powercli for that properties... Often I cant find them, because the sturcture is too complex.

 

So at this point, what should I do?

 

Thank you in advance

 

 

 

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership

You could recurse through the object, i.e. dig deeper when the property is not a basic type.


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

Reply
0 Kudos
ChrisROI
Enthusiast
Enthusiast

Hi Luc,

what do you mean by dig deeper?

What is the best way to dig deeper? I think i missed the correct method to do this.

Should i use some special editor, that provides some lists about the properties automatically (if there is one, currently using PS ISE)? Or should I search via powershell? Should I browse the api website? I like the website, but in some cases, I cant find the correct way... For example in: https://developer.vmware.com/apis/1192/vsphere

"Properties inherited from: ClusterDasAdvancedRuntimeInfo
dasHostInfo, heartbeatDatastoreInfo, vmcpSupported"

 

$Cluster = Get-Cluster

$Cluster.ExtensionData.RetrieveDasAdvancedRuntimeInfo() | select *

There is no information like shown on the website:

"slotInfo", "hostSlots" and so on...

 

And this information:

"vim.cluster.DasFailoverLevelAdvancedRuntimeInfo"

what can I do with this?

 

Greetings

Chris

 

 

 

 

 

 

 

Reply
0 Kudos
LucD
Leadership
Leadership

As I said, when the type of a property is not a basic type (int, string, ...) you have to click on the type to descend further in the nested objects.

The same when the object has an Extended By entry, click on that type.
In your example, you will find the additional properties (slotinfo, ...) in there (in this case ClusterDasFailoverLevelAdvancedRuntimeInfo).

To do this programmatically is matter of searching
- all the DLLs to find the types/classes they define

- check the members of each type/class

- if a member is not a basic type, use the typename to dive deeper into the nested properties

I did have some code to do that, let me see if I can dig it up





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

ChrisROI
Enthusiast
Enthusiast

Thanks LucD,

 

that would be great!

 

Greetings

Chris

Reply
0 Kudos
ChrisROI
Enthusiast
Enthusiast

Hi Luc,

 

with reference to your last post:

 

"I did have some code to do that, let me see if I can dig it up"

 

have you found that script?

 

Greetings and thank you in advance

Chris

Reply
0 Kudos
LucD
Leadership
Leadership

I'm afraid not (yet), was busy with other stuff.


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

Reply
0 Kudos