From 1f10a9944654b6154caf92390d2d69151ed2aac9 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 23 Jul 2024 10:30:12 +0200 Subject: [PATCH] Return nice error in case of AppDB site:service --- IM/AppDB.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IM/AppDB.py b/IM/AppDB.py index d496efb1..32d9b038 100644 --- a/IM/AppDB.py +++ b/IM/AppDB.py @@ -50,7 +50,9 @@ def get_site_id(site_name, stype="occi"): data = AppDB.appdb_call('/rest/1.0/sites') if data: for site in data['appdb:site']: - if site_name.lower() == site['@name'].lower() and site['@infrastructure'] == "Production": + if (site_name.lower() == site['@name'].lower() and + site['@infrastructure'] == "Production" and + 'site:service' in site): if isinstance(site['site:service'], list): services = site['site:service'] else: @@ -68,6 +70,8 @@ def get_site_url(site_id, stype="occi"): """ Get the site url from the site ID """ + if not site_id: + return None data = AppDB.appdb_call('/rest/1.0/va_providers/%s' % site_id) site_url = None if data: