本文整理汇总了Python中pysphere.VIServer._get_object_properties_bulk方法的典型用法代码示例。如果您正苦于以下问题:Python VIServer._get_object_properties_bulk方法的具体用法?Python VIServer._get_object_properties_bulk怎么用?Python VIServer._get_object_properties_bulk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysphere.VIServer
的用法示例。
在下文中一共展示了VIServer._get_object_properties_bulk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enumerate
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import _get_object_properties_bulk [as 别名]
output.append( '{"{#ID}":"%s", "{#NAME}":"%s"}' % (mof, name) )
print '{ "data":['
for i, v in enumerate( output ):
if i < len(output)-1:
print v+','
else:
print v
print ' ]}'
if mode == 'time':
#output time difference in zabbix_sender format:
#<hostname> <key> <timestamp> <value>
#vcenter vmware.host.timediff[host-1249] 1373876039 -1
for x in server._get_object_properties_bulk( hosts.keys(), {'HostSystem':['configManager.dateTimeSystem']} ) :
try:
host_id = x.Obj
host_name = hosts[x.Obj]
hostDateTimeSystem = x.PropSet[0].Val #can throw AttributeError
''' call vSphere SDK HostDateTimeSystem.QueryDateTime() method '''
dtReqClass = VI.QueryDateTimeRequestMsg()
dtReq = dtReqClass.new__this(hostDateTimeSystem)
dtReq.set_attribute_type(hostDateTimeSystem.get_attribute_type())
dtReqClass.set_element__this(dtReq)
timestamp = int(time.time()) #save local time at SDK call to compare with remote host
res2 = server._proxy.QueryDateTime(dtReqClass)
res = res2._returnval #get remote ESXi host time as time.struct_time tuple in a local timezone