Skip to content

Commit

Permalink
Merge pull request #1346 from grycap/devel
Browse files Browse the repository at this point in the history
Fix: #1343 and #1347
  • Loading branch information
micafer authored Mar 23, 2022
2 parents 4aa53a4 + deef33b commit f607564
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions IM/AppDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def appdb_call(path):
resp = requests.request("GET", AppDB.APPDB_URL + path, verify=False)
if resp.status_code == 200:
resp.text.replace('\n', '')
return xmltodict.parse(resp.text)
res = xmltodict.parse(resp.text)
return res['appdb:appdb'] if 'appdb:appdb' in res else res
else:
return None

Expand All @@ -48,7 +49,7 @@ def get_site_id(site_name, stype="occi"):
"""
data = AppDB.appdb_call('/rest/1.0/sites')
if data:
for site in data['appdb:appdb']['appdb:site']:
for site in data['appdb:site']:
if site_name.lower() == site['@name'].lower() and site['@infrastructure'] == "Production":
if isinstance(site['site:service'], list):
services = site['site:service']
Expand All @@ -71,13 +72,13 @@ def get_site_url(site_id, stype="occi"):
site_url = None
if data:
if stype == "openstack":
if 'provider:url' in data['appdb:appdb']['virtualization:provider']:
site_url = data['appdb:appdb']['virtualization:provider']['provider:url']
if 'provider:url' in data['virtualization:provider']:
site_url = data['virtualization:provider']['provider:url']
url = urlparse(site_url)
site_url = "%s://%s" % url[0:2]
else:
if 'provider:endpoint_url' in data['appdb:appdb']['virtualization:provider']:
site_url = data['appdb:appdb']['virtualization:provider']["provider:endpoint_url"]
if 'provider:endpoint_url' in data['virtualization:provider']:
site_url = data['virtualization:provider']["provider:endpoint_url"]

return site_url

Expand All @@ -89,8 +90,8 @@ def get_image_id(site_id, image_name, vo_name):
images = []
data = AppDB.appdb_call('/rest/1.0/va_providers/%s' % site_id)
if data:
if 'provider:image' in data['appdb:appdb']['virtualization:provider']:
for image in data['appdb:appdb']['virtualization:provider']['provider:image']:
if 'provider:image' in data['virtualization:provider']:
for image in data['virtualization:provider']['provider:image']:
if (image['@appcname'] == image_name and (not vo_name or image['@voname'] == vo_name)):
image_basename = os.path.basename(image['@va_provider_image_id'])
images.append((image_basename, image['@vmiversion']))
Expand Down Expand Up @@ -121,7 +122,7 @@ def _get_site_name(site_host, stype="occi"):
"""
data = AppDB.appdb_call('/rest/1.0/sites')
if data:
for site in data['appdb:appdb']['appdb:site']:
for site in data['appdb:site']:
if site['@infrastructure'] == "Production" and 'site:service' in site:
if isinstance(site['site:service'], list):
services = site['site:service']
Expand Down Expand Up @@ -193,8 +194,8 @@ def get_image_id_from_uri(site_id, image_mp_uri):

data = AppDB.appdb_call('/rest/1.0/va_providers/%s' % site_id)
if data:
if 'provider:image' in data['appdb:appdb']['virtualization:provider']:
for image in data['appdb:appdb']['virtualization:provider']['provider:image']:
if 'provider:image' in data['virtualization:provider']:
for image in data['virtualization:provider']['provider:image']:
if image['@mp_uri'] == image_mp_uri:
image_basename = os.path.basename(image['@va_provider_image_id'])
parts = image_basename.split("#")
Expand Down
2 changes: 1 addition & 1 deletion IM/CloudInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_cloud_list(auth_data):
cloud_item.extra['tenant'] = auth['tenant']
elif 'type' in auth and auth['type'] == "EGI":
if 'vo' in auth and auth['vo']:
cloud_item.extra["vo"] = 'vo'
cloud_item.extra["vo"] = auth['vo']

res.append(cloud_item)

Expand Down

0 comments on commit f607564

Please sign in to comment.