Skip to content

Commit

Permalink
Merge pull request #523 from grycap/devel
Browse files Browse the repository at this point in the history
Do not get appdb vos
  • Loading branch information
micafer authored Mar 12, 2024
2 parents a216053 + 7aaa3ed commit 29d9d91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 51 deletions.
22 changes: 9 additions & 13 deletions app/appdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from urllib.parse import urlparse

APPDB_URL = "https://appdb.egi.eu"
VO_LIST = []
APPDB_TIMEOUT = 10


Expand All @@ -45,18 +44,15 @@ def appdb_call(path, retries=3, url=APPDB_URL, timeout=APPDB_TIMEOUT):


def get_vo_list():
global VO_LIST
if not VO_LIST:
vos = []
data = appdb_call('/rest/1.0/vos')
if data:
if isinstance(data['vo:vo'], list):
for vo in data['vo:vo']:
vos.append(vo['@name'])
else:
vos.append(data['vo:vo']['@name'])
VO_LIST = vos
return VO_LIST
vos = []
data = appdb_call('/rest/1.0/vos')
if data:
if isinstance(data['vo:vo'], list):
for vo in data['vo:vo']:
vos.append(vo['@name'])
else:
vos.append(data['vo:vo']['@name'])
return vos


def _get_services(vo=None):
Expand Down
42 changes: 4 additions & 38 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
LAST_UPDATE = 0
PORT_SPECT_TYPES = ["PortSpec", "tosca.datatypes.network.PortSpec", "tosca.datatypes.indigo.network.PortSpec"]

VO_LIST = []
VO_LAST_UPDATE = 0


def _getStaticSitesInfo(force=False):
# Remove cache if force is True
Expand Down Expand Up @@ -104,15 +101,6 @@ def getStaticSites(vo=None, force=False):
return res


def getStaticVOs():
res = []
for site in _getStaticSitesInfo():
if "vos" in site and site["vos"]:
res.extend(list(site["vos"].keys()))

return list(set(res))


def get_site_info(cred_id, cred, userid):
domain = None
res_site = {}
Expand Down Expand Up @@ -152,7 +140,9 @@ def getCachedSiteList(force=False):
now = int(time.time())
if force or not SITE_LIST or now - LAST_UPDATE > g.settings.appdb_cache_timeout:
try:
SITE_LIST = appdb.get_sites()
sites = appdb.get_sites()
if sites:
SITE_LIST = appdb.get_sites()
# in case of error do not update time
LAST_UPDATE = now
except Exception as ex:
Expand Down Expand Up @@ -790,32 +780,8 @@ def get_project_ids(creds):
return creds


def getCachedVOList():
global VO_LIST
global VO_LAST_UPDATE

now = int(time.time())
if not VO_LIST or now - VO_LAST_UPDATE > g.settings.appdb_cache_timeout:
try:
VO_LIST = appdb.get_vo_list()
# in case of error do not update time
VO_LAST_UPDATE = now
except Exception as ex:
flash("Error retrieving VO list from AppDB: %s" % ex, 'warning')

return VO_LIST


def getVOs(session):
vos = getStaticVOs()
vos.extend(getCachedVOList())
vos = list(set(vos))
vos.sort()
if "vos" in session and session["vos"]:
vos = [vo for vo in vos if vo in session["vos"]]
elif not g.settings.debug_oidc_token:
vos = []
return vos
return session["vos"] if "vos" in session and session["vos"] else []


def get_site_info_from_radl(radl, creds):
Expand Down

0 comments on commit 29d9d91

Please sign in to comment.