dnaeon / py-vpoller

Distributed vSphere API Proxy
Other
83 stars 31 forks source link

VSAN Cluster health get. #278

Open k05054 opened 3 years ago

k05054 commented 3 years ago

Hi ! I'm trying to get vsan health status from object vim.cluster.VsanVcClusterHealthSystem. I used method vsan.health.get as an example and tried to write a new method i called cluster.vsan.health.get But when i tried to test it i got an error: {"msg": "Task cluster.vsan.health.get failed", "traceback": "Traceback (most recent call last):\n File \"build/bdist.linux-x86_64/egg/vpoller/task/decorators.py\", line 55, in wrapper\n result = fn(*args, **kwargs)\n File \"build/bdist.linux-x86_64/egg/vpoller/vsphere/tasks.py\", line 3053, in cluster_vsan_health_get\n status = pyVmomi.vim.cluster.VsanVcClusterHealthSystem.VsanQueryVcClusterHealthSummary(\n File \"/usr/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\", line 263, in __getattr__\n raise AttributeError(attr)\nAttributeError: VsanVcClusterHealthSystem\n", "success": 1} I can see that the problem is in VsanVcClusterHealthSystem, but i don't have any idea about a reason. Can anyone point me where did i made a misstake ? Code is in here ->cluster.vsan.health.get.txt

dnaeon commented 3 years ago

Hey,

I'm not on the computer at the moment, so cannot test your code.

Here are a few pointers -- make sure that you get the Managed Object reference for the cluster (incude_mors=True).

Once you get the cluster you need to use the cluster object, which is stored in the obj key of the result.

Make sure to check the documentation for ClusterComputeResource managed object and ClusterConfigurationEx data object, which provides various properties for quering vsan status.

https://code.vmware.com/apis/968/vsphere

The code would roughly speaking have to do the following.

  1. Get the cluster object along with the configurationEx property.
  2. Return selected properties from cluster_obj.configurationEx.vsanConfigInfo.

Hope this helps.

On Mon, Dec 28, 2020, 12:08 k05054 notifications@github.com wrote:

Hi ! I'm trying to get vsan health status from object vim.cluster.VsanVcClusterHealthSystem. I used method vsan.health.get as an example and tried to write a new method i called cluster.vsan.health.get But when i tried to test it i got an error: {"msg": "Task cluster.vsan.health.get failed", "traceback": "Traceback (most recent call last):\n File \"build/bdist.linux-x86_64/egg/vpoller/task/decorators.py\", line 55, in wrapper\n result = fn(*args, **kwargs)\n File \"build/bdist.linux-x86_64/egg/vpoller/vsphere/tasks.py\", line 3053, in cluster_vsan_health_get\n status = pyVmomi.vim.cluster.VsanVcClusterHealthSystem.VsanQueryVcClusterHealthSummary(\n File \"/usr/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py\", line 263, in getattr\n raise AttributeError(attr)\nAttributeError: VsanVcClusterHealthSystem\n", "success": 1} I'm new to python and programming, but i see that the problem is in VsanVcClusterHealthSystem, but i don't have any idea about a reason. Can anyone point me where did i made a misstake ? Code is in here ->cluster.vsan.health.get.txt https://github.com/dnaeon/py-vpoller/files/5746758/cluster.vsan.health.get.txt

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dnaeon/py-vpoller/issues/278, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB3JC2KPUHBEZW6ZQ3TP2TSXBKINANCNFSM4VL2U2YA .

k05054 commented 3 years ago

@dnaeon Reading the link you provided really helped a lot. First of all i checked ClusterComputeResource and ClusterConfigurationEx but there is no data about VSAN cluster health. Then i tried to go back to vim.cluster.VsanVcClusterHealthSystem and didn't find anything about it using the link you provided.

So i carefully read info about this managed object here and understood that i used wrong methods. You see, i was trying to poll vim.cluster.VsanVcClusterHealthSystem but it seems we can't poll this managed object directly. As i understand now i need special access via MOID vsan-cluster-health-system.

So the code i provided is not full. First of all i need to gain access via moid and then poll this managed object. So now the question is: Is the vPoller capable to work with moids ?

PS I found the example of query VSAN health status over here, maybe it would be helpful.

dnaeon commented 3 years ago

Ah, I see what you want to collect now.

The sample code you've provided uses the Python vSAN SDK, which is not included as part of pyVmomi.

https://code.vmware.com/web/sdk/7.0%20U1/vsan-python

In order to get this working you need to first have the Python vSAN SDK installed, which then you can use from within vPoller.

Here's an article I've written in the past, which describes how to package it and have it distributed.

http://dnaeon.github.io/packaging-the-vsan-sdk-for-python/

Since the vSAN SDK is not on PyPI I cannot list it as a dependency, and I'm also not willing to publish this myself, as this is an upstream VMware library, so if you want to use it you should package it yourself and probably have vPoller running along with it, but probably I will not merge this in the project, without permissions from VMware to first have the PyPI package available for vSAN.

k05054 commented 3 years ago

@dnaeon I think i got it now. I'll try to make package and run some tests today evening. Many thanks to you.

k05054 commented 3 years ago

Hi, @dnaeon ! Sorry for the delay. I made some tests and it was a fail. I can't understand, if i want to add vsan pollig as vPoller method i need to change some code in vconnector too right ? Can you put me to the right direction ?

dnaeon commented 3 years ago

Hi,

Too busy these days at work, so cannot promise anything if I'll be able to assist you much with this one.

If you could provide some summary of what you did and what didn't went well that would be helpful.

On Tue, Jan 26, 2021, 15:20 k05054 notifications@github.com wrote:

Hi, @dnaeon https://github.com/dnaeon ! Sorry for the delay. I made some tests and it was a fail. I can't understand, if i want to add vsan pollig as vPoller method i need to change some code in vconnector too right ? Can you put me to the right direction ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dnaeon/py-vpoller/issues/278#issuecomment-767536242, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB3JC4P7UIBBGJ366ZRBFTS326R3ANCNFSM4VL2U2YA .