Skip to content

Commit 54d684d

Browse files
committed
Adapt code to the new fedcloud info
1 parent 318a95d commit 54d684d

File tree

6 files changed

+26
-39
lines changed

6 files changed

+26
-39
lines changed

IM/InfrastructureManager.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from IM.VMRC import VMRC
3030
from IM.AppDBIS import AppDBIS
3131
from IM.AppDB import AppDB
32+
from IM.FedcloudInfo import FedcloudInfo
3233
from IM.CloudInfo import CloudInfo
3334
from IM.auth import Authentication
3435
from IM.recipe import Recipe
@@ -434,7 +435,7 @@ def systems_with_iis(sel_inf, radl, auth):
434435
host = None
435436
if 'host' in appdbis_elem:
436437
host = appdbis_elem['host']
437-
appdbis_list.append(AppDBIS(host))
438+
appdbis_list.append(FedcloudInfo)
438439

439440
systems_with_vmrc = {}
440441
for system_id in set([d.id for d in radl.deploys if d.vm_number > 0]):
@@ -1488,17 +1489,14 @@ def gen_auth_from_appdb(auth):
14881489
vo = appdbis_auth[0]["vo"]
14891490
# To avoid connecting with AppDBIS again
14901491
del appdbis_auth[0]["vo"]
1491-
if "host" in appdbis_auth[0]:
1492-
appdbis = AppDBIS(appdbis_auth[0]["host"])
1493-
else:
1494-
appdbis = AppDBIS()
1495-
InfrastructureManager.logger.debug("Getting auth data from AppDBIS")
1496-
code, sites = appdbis.get_sites_supporting_vo(vo)
1497-
if code == 200:
1498-
for site_name, site_url, project_id in sites:
1499-
auth_site = {"id": site_name, "host": site_url, "type": "OpenStack",
1492+
InfrastructureManager.logger.debug("Getting auth data from Fedcloud IS")
1493+
sites = FedcloudInfo.get_sites_supporting_vo(vo)
1494+
if sites:
1495+
for site in sites:
1496+
site_name, site_url, project_id in sites:
1497+
auth_site = {"id": site["name"], "host": site["url"], "type": "OpenStack",
15001498
"username": "egi.eu", "tenant": "openid", "auth_version": "3.x_oidc_access_token",
1501-
"domain": project_id, "password": appdbis_auth[0]["token"], "vo": vo}
1499+
"domain": site["project_id"], "password": appdbis_auth[0]["token"], "vo": vo}
15021500
auth.auth_list.append(auth_site)
15031501
else:
15041502
InfrastructureManager.logger.error("Error getting auth data from AppDBIS: %s" % sites)
@@ -1514,13 +1512,13 @@ def translate_egi_to_ost(auth):
15141512
ost_auth = {'id': auth_item['id'], 'type': 'OpenStack', 'username': 'egi.eu', 'tenant': 'openid',
15151513
'password': auth_item['token'], 'auth_version': '3.x_oidc_access_token',
15161514
'vo': auth_item['vo']}
1517-
site_id = AppDB.get_site_id(auth_item["host"], stype="openstack")
1518-
site_url = AppDB.get_site_url(site_id)
1515+
site_name = auth_item["host"]
1516+
site_url = FedcloudInfo.get_site_url(site_name)
15191517
if not site_url:
1520-
InfrastructureManager.logger.error("Site name '%s' not found at AppDB." % auth_item['host'])
1518+
InfrastructureManager.logger.error("Site name '%s' not found at fedcloud IS." % site_name)
15211519
continue
15221520
ost_auth['host'] = site_url
1523-
projects = AppDB.get_project_ids(site_id)
1521+
projects = FedcloudInfo.get_project_ids(site_name)
15241522
# If the VO does not appear in the project IDs
15251523
if auth_item['vo'] in projects:
15261524
ost_auth['domain'] = projects[auth_item['vo']]
@@ -1831,11 +1829,7 @@ def GetCloudImageList(cloud_id, auth, filters=None):
18311829
auth = InfrastructureManager.check_auth_data(auth)
18321830
appdbis_auth = auth.getAuthInfo("AppDBIS")
18331831
if appdbis_auth and "token" in appdbis_auth[0] and cloud_id == appdbis_auth[0]['id']:
1834-
if "host" in appdbis_auth[0]:
1835-
appdbis = AppDBIS(appdbis_auth[0]["host"])
1836-
else:
1837-
appdbis = AppDBIS()
1838-
return appdbis.list_images(filters)
1832+
return FedcloudInfo.list_images(filters)
18391833
else:
18401834
return InfrastructureManager._get_cloud_conn(cloud_id, auth).list_images(auth, filters)
18411835

IM/connectors/OCCI.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,10 @@ def concrete_system(self, radl_system, str_url, auth_data):
149149
# The url has this format: appdb://UPV-GRyCAP/egi.docker.ubuntu.16.04?fedcloud.egi.eu
150150
# Get the Site url from the AppDB
151151
site_name = url[1]
152-
site_id = AppDB.get_site_id(site_name)
153-
if not site_id:
154-
self.log_error("No site ID returned from EGI AppDB for site: %s." % site_name)
152+
site_url = FedcloudIS.get_site_url(site_name)
153+
if not site_url:
154+
self.log_error("No site returned from EGI Fedcloud IS for site: %s." % site_name)
155155
return None
156-
site_url = AppDB.get_site_url(site_id)
157156

158157
if ((protocol in ['https', 'http'] and url[2] and url[0] + "://" + url[1] == cloud_url) or
159158
(protocol == "appdb" and site_url.startswith(cloud_url))):
@@ -782,8 +781,7 @@ def launch(self, inf, radl, requested_radl, num_vm, auth_data):
782781
site_name = url[1]
783782
image_name = url[2][1:]
784783
vo_name = url[4]
785-
site_id = AppDB.get_site_id(site_name)
786-
os_tpl = AppDB.get_image_id(site_id, image_name, vo_name)
784+
os_tpl = AppDB.get_image_id(site_name, image_name, vo_name)
787785
else:
788786
# Get the Image ID from the last part of the path
789787
os_tpl = os.path.basename(url[2])

IM/connectors/OpenStack.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from urllib.parse import urlparse
4848
from IM.VirtualMachine import VirtualMachine
4949
from radl.radl import Feature
50-
from IM.AppDB import AppDB
50+
from IM.FedcloudInfo import FedcloudInfo
5151
from IM import get_ex_error
5252

5353

@@ -360,7 +360,7 @@ def concrete_system(self, radl_system, str_url, auth_data):
360360
src_host = url[1].split(':')[0]
361361

362362
if protocol == "appdb":
363-
site_url, image_id, msg = AppDB.get_image_data(str_url, "openstack", site=self.cloud.server)
363+
site_url, image_id, msg = FedcloudInfo.get_image_data(str_url, "openstack", site=self.cloud.server)
364364
if not image_id or not site_url:
365365
self.log_error(msg)
366366
return None
@@ -1327,7 +1327,7 @@ def launch(self, inf, radl, requested_radl, num_vm, auth_data):
13271327
image_url = system.getValue("disk.0.image.url")
13281328
if urlparse(image_url)[0] == "appdb":
13291329
vo = self.get_vo_name(auth_data)
1330-
_, image_id, msg = AppDB.get_image_data(image_url, "openstack", vo, site=self.cloud.server)
1330+
_, image_id, msg = FedcloudInfo.get_image_data(image_url, "openstack", vo, site=self.cloud.server)
13311331
if not image_id:
13321332
self.log_error(msg)
13331333
raise CloudConnectorException("Error in appdb image: %s" % msg)

test/unit/connectors/OCCI.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ def test_concrete(self):
8282
self.assertEqual(len(concrete), 1)
8383
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
8484

85-
@patch('IM.AppDB.AppDB.get_site_id')
8685
@patch('IM.AppDB.AppDB.get_site_url')
87-
def test_concrete_appdb(self, get_site_url, get_site_id):
86+
def test_concrete_appdb(self, get_site_url):
8887
radl_data = """
8988
network net ()
9089
system test (
@@ -106,7 +105,6 @@ def test_concrete_appdb(self, get_site_url, get_site_id):
106105
occi_cloud.cloud.server = "carach5.ics.muni.cz"
107106

108107
get_site_url.return_value = "https://carach5.ics.muni.cz:11443"
109-
get_site_id.return_value = "siteid"
110108
concrete = occi_cloud.concreteSystem(radl_system, auth)
111109
self.assertEqual(len(concrete), 1)
112110
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

test/unit/connectors/OpenStack.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,10 @@ def test_10_concrete(self, get_driver):
127127
self.assertEqual(concrete[0].getValue("instance_type"), "g.small")
128128
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
129129

130-
@patch('IM.AppDB.AppDB.get_site_id')
131-
@patch('IM.AppDB.AppDB.get_site_url')
132-
@patch('IM.AppDB.AppDB.get_image_id')
130+
@patch('IM.FedcloudInfo.FedcloudInfo.get_site_url')
131+
@patch('IM.FedcloudInfo.FedcloudInfo.get_image_id')
133132
@patch('libcloud.compute.drivers.openstack.OpenStackNodeDriver')
134-
def test_15_concrete_appdb(self, get_driver, get_image_id, get_site_url, get_site_id):
133+
def test_15_concrete_appdb(self, get_driver, get_image_id, get_site_url):
135134
radl_data = """
136135
network net ()
137136
system test (
@@ -164,7 +163,6 @@ def test_15_concrete_appdb(self, get_driver, get_image_id, get_site_url, get_sit
164163
driver.list_sizes.return_value = [node_size]
165164

166165
get_site_url.return_value = "https://server.com:5000"
167-
get_site_id.return_value = "8016G0"
168166
get_image_id.return_value = "imageid1"
169167
concrete = ost_cloud.concreteSystem(radl_system, auth)
170168
self.assertEqual(len(concrete), 1)
@@ -185,7 +183,7 @@ def create_node(self, **kwargs):
185183

186184
@patch('libcloud.compute.drivers.openstack.OpenStackNodeDriver')
187185
@patch('IM.InfrastructureList.InfrastructureList.save_data')
188-
@patch('IM.AppDB.AppDB.get_image_data')
186+
@patch('IM.FedcloudInfo.FedcloudInfo.get_image_data')
189187
def test_20_launch(self, get_image_data, save_data, get_driver):
190188
radl_data = """
191189
description desc (name = 'SimpleRADL')

test/unit/test_im_logic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,6 @@ def test_search_vm(self, dummycc):
15041504

15051505
@patch('IM.InfrastructureManager.AppDB')
15061506
def test_translate_egi_to_ost(self, appdb):
1507-
appdb.get_site_id.return_value = 'site_id'
15081507
appdb.get_site_url.return_value = 'https://ostsite.com:5000'
15091508
appdb.get_project_ids.return_value = {'vo_name': 'projectid'}
15101509

0 commit comments

Comments
 (0)