Skip to content

Commit

Permalink
Revert "Implements #283"
Browse files Browse the repository at this point in the history
This reverts commit b067f0d.
  • Loading branch information
micafer committed Mar 13, 2024
1 parent 5a9dd76 commit ed647a5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 211 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Create the `config.json` file (see the [example](app/config-sample.json)) settin
| ANALYTICS_TAG | Google Analytic Tag | N | "" |
| STATIC_SITES | List of static sites added to the AppDB ones ([{"name": "static_site_name", "url": "static_site_url", "id": "static_id", "vos": {"vo": "stprojectid"}}]) | N | [] |
| STATIC_SITES_URL | URL of a JSON file with the list of static sites added to the AppDB ones | N | "" |
| SITES_CACHE_TIMEOUT | AppDB cache TTL | N | 3600 |
| APPDB_CACHE_TIMEOUT | AppDB cache TTL | N | 3600 |
| CHECK_TOSCA_CHANGES_TIME | Interval to look for changes in TOSCA templates | N | 120 |
| VAULT_URL | Vault service URL to store Cloud credentials | N | None |

Expand Down
11 changes: 5 additions & 6 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
from app.im import InfrastructureManager
from app.ssh_key import SSHKey
from app.ott import OneTimeTokenData
from app import utils, db
from app import appdb as sitesInfo
from app import utils, appdb, db
from app.vault_info import VaultInfo
from oauthlib.oauth2.rfc6749.errors import InvalidTokenError, TokenExpiredError, InvalidGrantError
from werkzeug.exceptions import Forbidden
Expand Down Expand Up @@ -778,8 +777,8 @@ def getsites(vo=None):
for site_name, site in static_sites.items():
res += '<option name="selectedSite" value=%s>%s</option>' % (site['url'], site_name)

sites = utils.getSiteInfoProvider().get_sites(vo)
for site_name, site in sites.items():
appdb_sites = appdb.get_sites(vo)
for site_name, site in appdb_sites.items():
# avoid site duplication
if site_name not in static_sites:
if site["state"]:
Expand Down Expand Up @@ -808,7 +807,7 @@ def getimages(cred_id=None):

else:
site, _, vo = utils.get_site_info(cred_id, cred, get_cred_id())
for image_name, image_id in utils.getSiteInfoProvider().get_images(site['id'], vo):
for image_name, image_id in appdb.get_images(site['id'], vo):
res += '<option name="selectedImage" value=%s>%s</option>' % (image_id, image_name)
return res

Expand Down Expand Up @@ -1540,7 +1539,7 @@ def handle_csrf_error(e):
# Reload internally the site cache
@scheduler.task('interval', id='reload_sites', seconds=5)
def reload_sites():
scheduler.modify_job('reload_sites', trigger='interval', seconds=settings.sites_cache_timeout - 30)
scheduler.modify_job('reload_sites', trigger='interval', seconds=settings.appdb_cache_timeout - 30)
with app.app_context():
app.logger.debug('Reload Site List.')
g.settings = settings
Expand Down
2 changes: 1 addition & 1 deletion app/config-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"MOTOMO_INFO": {"url": "", "siteid": ""},
"STATIC_SITES": [{"name": "static_site_name", "url": "static_site_url", "id": "static_id", "vos": {"vo": "stprojectid"}, "api_version": "1.1"}],
"STATIC_SITES_URL": "",
"SITES_CACHE_TIMEOUT": 3600,
"APPDB_CACHE_TIMEOUT": 3600,
"CHECK_TOSCA_CHANGES_TIME": 120,
"IM_TIMEOUT": 60,
"VAULT_URL": "",
Expand Down
84 changes: 0 additions & 84 deletions app/egi_catch_all.py

This file was deleted.

3 changes: 1 addition & 2 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, config):
self.motomo_info = config.get('MOTOMO_INFO')
self.static_sites = config.get('STATIC_SITES', [])
self.static_sites_url = config.get('STATIC_SITES_URL', "")
self.sites_cache_timeout = config.get('SITES_CACHE_TIMEOUT', 3600)
self.appdb_cache_timeout = config.get('APPDB_CACHE_TIMEOUT', 3600)
self.debug_oidc_token = config.get('DEBUG_OIDC_TOKEN', None)
self.imTimeout = config.get('IM_TIMEOUT', 60)
self.checkToscaChangesTime = config.get('CHECK_TOSCA_CHANGES_TIME', 120)
Expand All @@ -52,4 +52,3 @@ def __init__(self, config):
self.vos_user_role = config.get('VOS_USER_ROLE')
self.enable_external_vault = config.get('ENABLE_EXTERNAL_VAULT', False)
self.hide_tosca_tags = config.get('HIDE_TOSCA_TAGS', [])
self.site_info_provider = config.get('SITE_INFO_PROVIDER', 'AppDB')
103 changes: 0 additions & 103 deletions app/tests/test_egi_catch_all.py

This file was deleted.

18 changes: 4 additions & 14 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from requests.packages.urllib3.exceptions import InsecureRequestWarning

from app import appdb
from app import egi_catch_all

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
urllib3.disable_warnings(InsecureRequestWarning)
Expand Down Expand Up @@ -74,13 +73,6 @@ def _getStaticSitesInfo(force=False):
return []


def getSiteInfoProvider():
if g.settings.site_info_provider == "AppDB":
return appdb
elif g.settings.site_info_provider == "EGI Catch All":
return egi_catch_all


def getCachedProjectIDs(site_id):
res = {}
for site in getCachedSiteList().values():
Expand All @@ -89,7 +81,7 @@ def getCachedProjectIDs(site_id):
site["vos"] = {}
if "vos_updated" not in site or not site["vos_updated"]:
try:
site["vos"].update(getSiteInfoProvider().get_project_ids(site_id))
site["vos"].update(appdb.get_project_ids(site_id))
site["vos_updated"] = True
except Exception as ex:
print("Error loading project IDs from AppDB: %s" % ex, file=sys.stderr)
Expand All @@ -105,8 +97,6 @@ def getStaticSites(vo=None, force=False):
if vo is None or ("vos" in site and site["vos"] and vo in site["vos"]):
res[site["name"]] = site
site["state"] = ""
if g.settings.site_info_provider == "EGI Catch All":
site["id"] = site["name"]

return res

Expand Down Expand Up @@ -148,11 +138,11 @@ def getCachedSiteList(force=False):
global LAST_UPDATE

now = int(time.time())
if force or not SITE_LIST or now - LAST_UPDATE > g.settings.sites_cache_timeout:
if force or not SITE_LIST or now - LAST_UPDATE > g.settings.appdb_cache_timeout:
try:
sites = getSiteInfoProvider().get_sites()
sites = appdb.get_sites()
if sites:
SITE_LIST = getSiteInfoProvider().get_sites()
SITE_LIST = appdb.get_sites()
# in case of error do not update time
LAST_UPDATE = now
except Exception as ex:
Expand Down

0 comments on commit ed647a5

Please sign in to comment.