Permalink
Browse files

Make CentralAgent read_* consistent.

  • Loading branch information...
CyrilPeponnet committed Mar 18, 2016
1 parent e0c1cc9 commit 3abc65ee9848dc392f2346b3c7b50c4c2e5cf400
Showing with 13 additions and 5 deletions.
  1. +13 −5 ArchipelAgent/archipel-central-agent/archipelcentral/archipelCentralAgent.py
@@ -518,7 +518,7 @@ def iq_unregister_vms(self,iq):
reply = build_error_iq(self, ex, iq, ARCHIPEL_ERROR_CODE_CENTRALAGENT)
return reply
def read_hypervisors(self, columns, where_statement):
def read_hypervisors(self, columns="*", where_statement=None):
"""
Reads list of hypervisors in central db.
"""
@@ -528,10 +528,18 @@ def read_hypervisors(self, columns, where_statement):
rows = self.database.select(read_statement)
ret = []
for row in rows:
ret.append({"jid":row[0], "last_seen":row[1], "status":row[2]})
if columns == "*":
ret.append({"jid":row[0], "last_seen":row[1], "status":row[2]})
else:
res = {}
i = 0
for col in columns.split(","):
res[col] = row[i]
i += 1
ret.append(res)
return ret
def read_vms(self, columns, where_statement):
def read_vms(self, columns="*", where_statement=None):
"""
Read list of vms in central db.
"""
@@ -547,8 +555,8 @@ def read_vms(self, columns, where_statement):
res = {}
i = 0
for col in columns.split(","):
res[col]=row[i]
i+=1
res[col] = row[i]
i += 1
ret.append(res)
return ret

0 comments on commit 3abc65e

Please sign in to comment.