Skip to content

Commit

Permalink
Merge pull request #604 from grycap/devel
Browse files Browse the repository at this point in the history
Fix error
  • Loading branch information
micafer authored Dec 13, 2024
2 parents c432d6c + 6a6b47a commit f3c8c6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def home():

# Force to get the user credentials to cache them
scheduler.add_job(func=utils.get_cache_creds, trigger='date', run_date=datetime.datetime.now(),
misfire_grace_time=20, args=[cred, get_cred_id()], id='get_cache_creds')
misfire_grace_time=20, args=[cred, session['userid'], get_cred_id()], id='get_cache_creds')

# if there are any next url, redirect to it
if "next" in session and session["next"]:
Expand Down Expand Up @@ -503,7 +503,7 @@ def showinfrastructures():
app.logger.exception("Error getting vm info: %s" % ex)
radl_json = []
try:
creds = utils.get_cache_creds(cred, get_cred_id())
creds = utils.get_cache_creds(cred, session['userid'], get_cred_id())
except Exception as ex:
app.logger.exception("Error getting user credentials: %s" % ex)
creds = []
Expand Down Expand Up @@ -773,7 +773,7 @@ def configure():
app.logger.debug("Template: " + json.dumps(toscaInfo[selected_tosca]))

try:
creds = utils.get_cache_creds(cred, get_cred_id(), 1)
creds = utils.get_cache_creds(cred, session['userid'], get_cred_id(), 1)
except Exception as ex:
flash("Error getting user credentials: %s" % ex, "error")
creds = []
Expand Down Expand Up @@ -1127,7 +1127,7 @@ def manage_creds():
creds = {}

try:
creds = utils.get_cache_creds(cred, get_cred_id())
creds = utils.get_cache_creds(cred, session['userid'], get_cred_id())
# Get the project_id in case it has changed
utils.get_project_ids(creds)
except Exception as e:
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def write_creds():
# Get project_id to save it to de DB
utils.get_project_ids([creds])
# delete cached credentials
utils.clear_cache_creds(get_cred_id())
utils.clear_cache_creds(session['userid'])
cred.write_creds(creds["id"], get_cred_id(), creds, cred_id in [None, ''])
if val_res == 0:
flash("Credentials successfully written!", 'success')
Expand All @@ -1200,7 +1200,7 @@ def delete_creds():
cred_id = request.args.get('cred_id', "")
try:
# delete cached credentials
utils.clear_cache_creds(get_cred_id())
utils.clear_cache_creds(session['userid'])
cred.delete_cred(cred_id, get_cred_id())
flash("Credentials successfully deleted!", 'success')
except Exception as ex:
Expand All @@ -1219,7 +1219,7 @@ def enable_creds():
if val_res == 2:
flash(val_msg, 'warning')
# delete cached credentials
utils.clear_cache_creds(get_cred_id())
utils.clear_cache_creds(session['userid'])
cred.enable_cred(cred_id, get_cred_id(), enable)
except Exception as ex:
flash("Error updating credentials %s!" % ex, 'error')
Expand Down
4 changes: 2 additions & 2 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,10 @@ def merge_templates(template, new_template):
return template


def get_cache_creds(cred, userid, enabled=None):
def get_cache_creds(cred, userid, creduserid, enabled=None):
global CREDS_CACHE
if userid not in CREDS_CACHE:
CREDS_CACHE[userid] = cred.get_creds(userid)
CREDS_CACHE[userid] = cred.get_creds(creduserid)

res = []
for cred in CREDS_CACHE[userid]:
Expand Down

0 comments on commit f3c8c6d

Please sign in to comment.