2

我正在尝试获取 vsphere 数据存储的统计信息。

虽然我能够获取主机的统计信息,但它会因数据存储而失败:

from pysphere import VIServer 

server = VIServer() 
server.connect(HOST, USER, PASSWORD) 

pm = server.get_performance_manager() 

# querying hosts - works:
entities = server.get_hosts()  # returns {entity: name}
counters = pm.get_entity_counters(entities.keys()[0])  # returns {name: id}
statistics = pm.get_entity_statistic(entities.keys()[0], counters.values()[:1])

# querying datastores - doesn't work:
entities = server.get_datastores()  # returns {entity: name}
counters = pm.get_entity_counters(entities.keys()[0])  # returns {name: id}
statistics = pm.get_entity_statistic(entities.keys()[0], counters.values()[:1])

最后一行引发以下错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-122-dbbb39ef8a75> in <module>()
----> 1 statistics = pm.get_entity_statistic(entities.keys()[0], counters.values()[:1])

.../python2.7/site-packages/pysphere/vi_performance_manager.pyc in get_entity_statistic(self, entity, counters, interval, composite)
    183 
    184             instance_name = str(stat.Id.Instance)
--> 185             stat_value = str(stat.Value[0])
    186             date_now = datetime.datetime.utcnow()
    187             statistics.append(EntityStatistics(entity, stat.Id.CounterId, cname,

.../python2.7/site-packages/pysphere/ZSI/generate/pyclass.pyc in get(self)
    146         if not callable(what):
    147             def get(self):
--> 148                 return getattr(self, what.aname)
    149 
    150             if what.maxOccurs > 1:

AttributeError: 'DynamicData_Holder' object has no attribute '_value'

pysphere 存储库似乎已经闲置了大约 3 年,除此之外,我找不到提到这个特定问题的讨论: https ://groups.google.com/forum/#!topic/pysphere/LQaF661msoQ

不幸的是,这个解决方案没有涵盖所需的统计数据,而只是当前时刻的简单统计数据。

我还发现了一个类似的错误报告,但据我所知并没有真正解决: https ://github.com/itnihao/pysphere/issues/60

任何帮助将不胜感激。

4

0 回答 0