Skip to content

Commit

Permalink
Add auth data to DB
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Sep 18, 2023
1 parent 9ef9e8f commit 34c2aff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 4 additions & 6 deletions IM/InfrastructureInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,14 @@ def deserialize(str_data):
return newinf

@staticmethod
def deserialize_auth(str_data):
def deserialize_auth(inf_id, deleted, str_data):
"""
Only Loads auth data
"""
newinf = InfrastructureInfo()
dic = json.loads(str_data)
newinf.deleted = dic['deleted']
newinf.id = dic['id']
if dic['auth']:
newinf.auth = Authentication.deserialize(dic['auth'])
newinf.deleted = deleted
newinf.id = inf_id
newinf.auth = Authentication.deserialize(str_data)
return newinf

def destroy_vms(self, auth):
Expand Down
7 changes: 4 additions & 3 deletions IM/InfrastructureList.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def _get_data_from_db(db_url, inf_id=None, auth=None):
if db.db_type == DataBase.MONGO:
res = db.find("inf_list", {"deleted": 0}, {data_field: True, "deleted": True}, [('_id', -1)])
else:
res = db.select("select " + data_field + ",deleted from inf_list where deleted = 0 order by rowid desc")
res = db.select("select " + data_field + ",deleted from inf_list where deleted = 0"
" order by rowid desc")
if len(res) > 0:
for elem in res:
if db.db_type == DataBase.MONGO:
Expand Down Expand Up @@ -285,8 +286,8 @@ def _get_inf_ids_from_db(auth=None, get_all=False):
if db.connect():
inf_list = []
if db.db_type == DataBase.MONGO:
filter = InfrastructureList._gen_filter_from_auth(auth, get_all)
res = db.find("inf_list", filter, {"id": True}, [('id', -1)])
filt = InfrastructureList._gen_filter_from_auth(auth, get_all)
res = db.find("inf_list", filt, {"id": True}, [('id', -1)])
else:
where = InfrastructureList._gen_where_from_auth(auth, get_all)
res = db.select("select id from inf_list %s order by rowid desc" % where)
Expand Down

0 comments on commit 34c2aff

Please sign in to comment.