Skip to content

Commit

Permalink
add get_vm_detail method
Browse files Browse the repository at this point in the history
  • Loading branch information
Arne Hilmann authored and Arne Hilmann committed Apr 5, 2016
1 parent 8367f1c commit 2726323
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/python/sunstone_rest_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ def get_vm_by_id(self, id):
if vm["ID"] == id:
return vm

def get_vm_detail(self, id, detail):
detail2toplevel = {"log": "vm_log"}
toplevel = detail2toplevel.get(detail)
if toplevel:
return self._fetch("/vm/%s/%s" % (id, detail)).get(toplevel)
return self._fetch("/vm/%s/%s" % (id, detail))

def get_multiple_vms_by_name(self, name):
for vm in self.fetch_vms():
if vm["NAME"] == name:
Expand Down Expand Up @@ -150,4 +157,8 @@ def find_csrftoken(html):

if __name__ == "__main__":
client = RestClient("http://localhost:9869").login("oneadmin", "opennebula")
print(client.fetch_hosts())
# print(client.fetch_hosts())

print(client.get_vm_by_id(38))
print("-" * 40)
print(client.get_vm_detail(38, "log"))

0 comments on commit 2726323

Please sign in to comment.