how to extract values from <bound method Server.diagnostics of <Server: ubuntu12_6>>?

泄露秘密 提交于 2020-01-03 05:41:27

问题


I'm using novaclient.v1_1 to get list of instances and trying to extract diagnostics of each server instance.

code i've written

instances = nova.servers.list()
  for i in instances:
    val_list = i.diagnostics
    print val_list

so here i got output like this

<bound method Server.diagnostics of <Server: ubuntu12_6>>
<bound method Server.diagnostics of <Server: ubuntu12_4>>
<bound method Server.diagnostics of <Server: ubuntu12_3>>
<bound method Server.diagnostics of <Server: ubuntu12_1>>

so how can i get full diagnostics information of each server instance?? how to extract tap interface info from this object?


回答1:


As the output says, diagnostics is a method. That means you need to call it!

instances = nova.servers.list()
  for i in instances:
    val_list = i.diagnostics()     # <---- Add parenthesis here
    print val_list


来源:https://stackoverflow.com/questions/23441003/how-to-extract-values-from-bound-method-server-diagnostics-of-server-ubuntu12

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!