Skip to content

Commit

Permalink
Make CentralAgent read_* consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilPeponnet committed Mar 18, 2016
1 parent e0c1cc9 commit 3abc65e
Showing 1 changed file with 13 additions and 5 deletions.
Expand Up @@ -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.
"""
Expand All @@ -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.
"""
Expand All @@ -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

Expand Down

0 comments on commit 3abc65e

Please sign in to comment.