def test_get_auth(self): auth_lines = [ """id = a1; type = InfrastructureManager; username = someuser; password = somepass """, """id = ''; type = VMRC; username = someuser; password = somepass; """ ] auth = Authentication(Authentication.read_auth_data(auth_lines)) auth_data = auth.getAuthInfoByID("a1") self.assertEqual(auth_data, [{ 'id': 'a1', 'password': "******", 'type': 'InfrastructureManager', 'username': '******' }]) auth_data = auth.getAuthInfo("VMRC") self.assertEqual(auth_data, [{ 'id': '', 'password': "******", 'type': 'VMRC', 'username': '******' }]) auth_lines = [ """id = 1a; type = InfrastructureManager; username = someuser; password = somepass """ ] with self.assertRaises(Exception) as ex: auth = Authentication(Authentication.read_auth_data(auth_lines)) self.assertEqual("Incorrect value in auth item id: 1a", str(ex.exception))
def test_inf_auth_with_token(self): im_auth = {"token": (self.gen_token())} im_auth['username'] = InfrastructureInfo.OPENID_USER_PREFIX + "micafer" im_auth['password'] = "******" # Check that a user/pass cred cannot access OpenID ones user_auth = Authentication([{ 'id': 'im', 'type': 'InfrastructureManager', 'username': im_auth['username'], 'password': im_auth['password'] }]) with self.assertRaises(Exception) as ex: IM.check_auth_data(user_auth) self.assertEqual( str(ex.exception), "Invalid username used for the InfrastructureManager.") inf = InfrastructureInfo() inf.id = "1" inf.auth = user_auth res = inf.is_authorized(user_auth) self.assertEqual(res, False) user_auth = Authentication([{ 'id': 'im', 'type': 'InfrastructureManager', 'username': im_auth['username'], 'password': im_auth['password'], 'token': im_auth['token'] }]) res = inf.is_authorized(user_auth) self.assertEqual(res, True)
def get_auth_header(): """ Get the Authentication object from the AUTHORIZATION header replacing the new line chars. """ # Initialize REST_URL global REST_URL if REST_URL is None: REST_URL = get_full_url("") auth_header = bottle.request.headers['AUTHORIZATION'] if Config.SINGLE_SITE: if auth_header.startswith("Basic "): auth_data = base64.b64decode(auth_header[6:]) user_pass = auth_data.split(":") im_auth = { "type": "InfrastructureManager", "username": user_pass[0], "password": user_pass[1] } single_site_auth = { "type": Config.SINGLE_SITE_TYPE, "host": Config.SINGLE_SITE_AUTH_HOST, "username": user_pass[0], "password": user_pass[1] } return Authentication([im_auth, single_site_auth]) elif auth_header.startswith("Bearer "): token = auth_header[7:].strip() im_auth = { "type": "InfrastructureManager", "username": "******", "token": token } if Config.SINGLE_SITE_TYPE == "OpenStack": single_site_auth = { "type": Config.SINGLE_SITE_TYPE, "host": Config.SINGLE_SITE_AUTH_HOST, "username": "******", "tenant": "oidc", "password": token } else: single_site_auth = { "type": Config.SINGLE_SITE_TYPE, "host": Config.SINGLE_SITE_AUTH_HOST, "token": token } return Authentication([im_auth, single_site_auth]) auth_data = auth_header.replace(AUTH_NEW_LINE_SEPARATOR, "\n") auth_data = auth_data.split(AUTH_LINE_SEPARATOR) return Authentication(Authentication.read_auth_data(auth_data))
def test_10_concrete(self, requests): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'azr://image-id' and disk.0.os.credentials.username = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{ 'id': 'azure', 'type': 'AzureClassic', 'subscription_id': 'user', 'public_key': 'public_key', 'private_key': 'private_key' }]) azure_cloud = self.get_azure_cloud() requests.side_effect = self.get_response concrete = azure_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_70_create_snapshot(self, sleep, getONEVersion, server_proxy): auth = Authentication([{ 'id': 'one', 'type': 'OpenNebula', 'username': '******', 'password': '******', 'host': 'server.com:2633' }]) one_cloud = self.get_one_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", one_cloud.cloud, "", "", one_cloud, 1) getONEVersion.return_value = "5.2.1" one_server = MagicMock() one_server.one.vm.disksaveas.return_value = (True, 1, 0) one_server.one.image.info.return_value = ( True, "<IMAGE><STATE>1</STATE></IMAGE>", 0) server_proxy.return_value = one_server success, new_image = one_cloud.create_snapshot(vm, 0, "image_name", True, auth) self.assertTrue(success, msg="ERROR: creating snapshot: %s" % new_image) self.assertEqual(new_image, 'one://server.com/1') self.assertEqual(one_server.one.vm.disksaveas.call_args_list, [call('user:pass', 1, 0, 'image_name', '', -1)]) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_10_concrete(self, credentials, compute_client): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'azr://image-id' and disk.0.os.credentials.username = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{'id': 'azure', 'type': 'Azure', 'subscription_id': 'subscription_id', 'username': '******', 'password': '******'}]) azure_cloud = self.get_azure_cloud() instace_type = MagicMock() instace_type.name = "instance_type1" instace_type.number_of_cores = 1 instace_type.memory_in_mb = 1024 instace_type.resource_disk_size_in_mb = 102400 instace_types = [instace_type] client = MagicMock() compute_client.return_value = client client.virtual_machine_sizes.list.return_value = instace_types concrete = azure_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_60_finalize(self, connection): auth = Authentication([{ 'id': 'fogbow', 'type': 'Kubernetes', 'host': 'http://server.com:8080' }]) kube_cloud = self.get_kube_cloud() inf = MagicMock() inf.get_next_vm_id.return_value = 1 vm = VirtualMachine(inf, "namespace/1", kube_cloud.cloud, "", "", kube_cloud) conn = MagicMock() connection.return_value = conn conn.request.side_effect = self.request conn.getresponse.side_effect = self.get_response success, _ = kube_cloud.finalize(vm, auth) self.assertTrue(success, msg="ERROR: finalizing VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue()) self.clean_log()
def test_60_finalize(self, connection): auth = Authentication([{ 'id': 'fogbow', 'type': 'FogBow', 'proxy': 'user', 'host': 'server.com:8182' }]) fogbow_cloud = self.get_fogbow_cloud() inf = MagicMock() inf.get_next_vm_id.return_value = 1 vm = VirtualMachine(inf, "1", fogbow_cloud.cloud, "", "", fogbow_cloud) conn = MagicMock() connection.return_value = conn conn.request.side_effect = self.request conn.getresponse.side_effect = self.get_response success, _ = fogbow_cloud.finalize(vm, auth) self.assertTrue(success, msg="ERROR: finalizing VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_52_reboot(self, get_driver): auth = Authentication([{ 'id': 'ost', 'type': 'OpenStack', 'username': '******', 'password': '******', 'tenant': 'tenant', 'host': 'https://server.com:5000' }]) ost_cloud = self.get_ost_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", ost_cloud.cloud, "", "", ost_cloud, 1) driver = MagicMock() get_driver.return_value = driver node = MagicMock() node.id = "1" node.state = "running" node.extra = {'flavorId': 'small'} node.public_ips = ['158.42.1.1'] node.private_ips = ['10.0.0.1'] node.driver = driver driver.ex_get_node_details.return_value = node driver.ex_hard_reboot_node.return_value = True success, _ = ost_cloud.reboot(vm, auth) self.assertTrue(success, msg="ERROR: stopping VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_55_alter(self, get_driver): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count=1 and memory.size=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'one://server.com/1' and disk.0.os.credentials.username = '******' and disk.0.os.credentials.password = '******' )""" radl = radl_parse.parse_radl(radl_data) new_radl_data = """ system test ( cpu.count>=2 and memory.size>=2048m )""" new_radl = radl_parse.parse_radl(new_radl_data) auth = Authentication([{ 'id': 'libcloud', 'type': 'LibCloud', 'username': '******', 'password': '******', 'driver': 'EC2' }]) lib_cloud = self.get_lib_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", lib_cloud.cloud, radl, radl, lib_cloud, 1) driver = MagicMock() get_driver.return_value = driver node = MagicMock() node.id = "1" node.driver = driver driver.list_nodes.return_value = [node] node_size = MagicMock() node_size.ram = 2048 node_size.price = 2 node_size.disk = 1 node_size.vcpus = 2 node_size.name = "medium" driver.list_sizes.return_value = [node_size] driver.ex_resize.return_value = True success, _ = lib_cloud.alterVM(vm, new_radl, auth) self.assertTrue(success, msg="ERROR: modifying VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_30_updateVMInfo(self, requests): radl_data = """ network net (outbound = 'yes') system test ( cpu.arch='x86_64' and cpu.count=1 and memory.size=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'docker://someimage' and disk.0.os.credentials.username = '******' and disk.0.os.credentials.password = '******' )""" radl = radl_parse.parse_radl(radl_data) radl.check() auth = Authentication([{'id': 'fogbow', 'type': 'Kubernetes', 'host': 'http://server.com:8080'}]) kube_cloud = self.get_kube_cloud() inf = MagicMock() inf.get_next_vm_id.return_value = 1 inf.id = "namespace" vm = VirtualMachine(inf, "1", kube_cloud.cloud, radl, radl, kube_cloud) requests.side_effect = self.get_response success, vm = kube_cloud.updateVMInfo(vm, auth) self.assertTrue(success, msg="ERROR: updating VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_50_start(self, get_connection): auth = Authentication([{ 'id': 'ec2', 'type': 'EC2', 'username': '******', 'password': '******' }]) ec2_cloud = self.get_ec2_cloud() inf = MagicMock() inf.get_next_vm_id.return_value = 1 vm = VirtualMachine(inf, "us-east-1;id-1", ec2_cloud.cloud, "", "", ec2_cloud) conn = MagicMock() get_connection.return_value = conn reservation = MagicMock() instance = MagicMock() instance.update.return_value = True instance.stop.return_value = True reservation.instances = [instance] conn.get_all_instances.return_value = [reservation] success, _ = ec2_cloud.start(vm, auth) self.assertTrue(success, msg="ERROR: stopping VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def _call_function(self): self._error_mesage = "Error creating disk snapshot" (inf_id, vm_id, disk_num, image_name, auto_delete, auth_data) = self.arguments return IM.InfrastructureManager.InfrastructureManager.CreateDiskSnapshot( inf_id, vm_id, disk_num, image_name, auto_delete, Authentication(auth_data))
def test_30_updateVMInfo(self, get_driver): radl_data = """ network net (outbound = 'yes') system test ( cpu.arch='x86_64' and cpu.count=1 and memory.size=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'gce://us-central1-a/centos-6' and disk.0.os.credentials.username = '******' and disk.1.size=1GB and disk.1.device='hdb' and disk.1.mount_path='/mnt/path' )""" radl = radl_parse.parse_radl(radl_data) radl.check() auth = Authentication([{ 'id': 'one', 'type': 'GCE', 'username': '******', 'password': '******', 'project': 'proj' }]) gce_cloud = self.get_gce_cloud() inf = MagicMock() inf.get_next_vm_id.return_value = 1 vm = VirtualMachine(inf, "1", gce_cloud.cloud, radl, radl, gce_cloud) driver = MagicMock() get_driver.return_value = driver node = MagicMock() zone = MagicMock() node.id = "1" node.state = "running" node.extra = {'flavorId': 'small'} node.public_ips = [] node.public_ips = ['158.42.1.1'] node.private_ips = ['10.0.0.1'] node.driver = driver zone.name = 'us-central1-a' node.extra = {'zone': zone} driver.ex_get_node.return_value = node volume = MagicMock() volume.id = "vol1" volume.attach.return_value = True volume.extra = {'status': 'READY'} driver.create_volume.return_value = volume success, vm = gce_cloud.updateVMInfo(vm, auth) self.assertTrue(success, msg="ERROR: updating VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_60_finalize(self, server_proxy): auth = Authentication([{ 'id': 'one', 'type': 'OpenNebula', 'username': '******', 'password': '******', 'host': 'server.com:2633' }]) one_cloud = self.get_one_cloud() inf = MagicMock() inf.get_next_vm_id.return_value = 1 vm = VirtualMachine(inf, "1", one_cloud.cloud, "", "", one_cloud) one_server = MagicMock() one_server.one.vm.action.return_value = (True, "", 0) server_proxy.return_value = one_server success, _ = one_cloud.finalize(vm, auth) self.assertTrue(success, msg="ERROR: finalizing VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue()) self.clean_log()
def test_10_concrete(self): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'aws://us-east-one/ami-id' and disk.0.os.credentials.username = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{ 'id': 'ec2', 'type': 'EC2', 'username': '******', 'password': '******' }]) ec2_cloud = self.get_ec2_cloud() concrete = ec2_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue()) self.clean_log()
def test_52_reboot(self, get_driver): auth = Authentication([{ 'id': 'ost', 'type': 'CloudStack', 'username': '******', 'password': '******', 'host': 'http://server.com' }]) osc_cloud = self.get_osc_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", osc_cloud.cloud, "", "", osc_cloud, 1) driver = MagicMock() get_driver.return_value = driver node = MagicMock() node.id = "1" node.state = "running" node.driver = driver driver.list_nodes.return_value = [node] node.reboot_node.return_value = True success, _ = osc_cloud.reboot(vm, auth) self.assertTrue(success, msg="ERROR: rebooting VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_30_updateVMInfo(self, requests): radl_data = """ network net (outbound = 'yes') system test ( cpu.arch='x86_64' and cpu.count=1 and memory.size=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'azr://image-id' and disk.0.os.credentials.username = '******' and disk.0.os.credentials.password = '******' )""" radl = radl_parse.parse_radl(radl_data) radl.check() auth = Authentication([{'id': 'fogbow', 'type': 'FogBow', 'token': 'user', 'host': 'server.com:8182'}]) fogbow_cloud = self.get_fogbow_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", fogbow_cloud.cloud, radl, radl, fogbow_cloud, 1) requests.side_effect = self.get_response success, vm = fogbow_cloud.updateVMInfo(vm, auth) self.assertEqual(str(vm.info.networks[0].getOutPorts()[0]), "10069:8080/tcp") self.assertEqual(str(vm.info.networks[0].getOutPorts()[1]), "10068:22/tcp") self.assertTrue(success, msg="ERROR: updating VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_20_launch(self, requests): radl_data = """ network net1 (outbound = 'yes' and outports = '8080') network net2 () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net1' and net_interface.0.dns_name = 'test' and net_interface.1.connection = 'net2' and disk.0.os.name = 'linux' and disk.0.image.url = 'docker://someimage' and disk.0.os.credentials.username = '******' and disk.1.size=1GB and disk.1.device='hdb' and disk.1.mount_path='/mnt/path' )""" radl = radl_parse.parse_radl(radl_data) radl.check() auth = Authentication([{'id': 'fogbow', 'type': 'Kubernetes', 'host': 'http://server.com:8080'}]) kube_cloud = self.get_kube_cloud() requests.side_effect = self.get_response res = kube_cloud.launch(InfrastructureInfo(), radl, radl, 1, auth) success, _ = res[0] self.assertTrue(success, msg="ERROR: launching a VM.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_20_launch(self, save_data, sleep, requests): radl_data = """ network net1 (outbound = 'yes' and outports = '8080,9000:9100') network net2 () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net1' and net_interface.0.dns_name = 'test' and net_interface.1.connection = 'net2' and disk.0.os.name = 'linux' and disk.0.image.url = 'azr://image-id' and disk.0.os.credentials.username = '******' and disk.1.size=1GB and disk.1.device='hdb' and disk.1.mount_path='/mnt/path' )""" radl = radl_parse.parse_radl(radl_data) radl.check() auth = Authentication([{'id': 'azure', 'type': 'AzureClassic', 'subscription_id': 'user', 'public_key': 'public_key', 'private_key': 'private_key'}]) azure_cloud = self.get_azure_cloud() requests.side_effect = self.get_response res = azure_cloud.launch(InfrastructureInfo(), radl, radl, 1, auth) success, _ = res[0] self.assertTrue(success, msg="ERROR: launching a VM.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_50_start(self, get_driver): auth = Authentication([{ 'id': 'libcloud', 'type': 'LibCloud', 'username': '******', 'password': '******', 'driver': 'EC2' }]) lib_cloud = self.get_lib_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", lib_cloud.cloud, "", "", lib_cloud, 1) driver = MagicMock() get_driver.return_value = driver node = MagicMock() node.id = "1" node.state = "running" node.driver = driver driver.list_nodes.return_value = [node] driver.ex_stop_node.return_value = True success, _ = lib_cloud.start(vm, auth) self.assertTrue(success, msg="ERROR: stopping VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_30_updateVMInfo(self, requests): radl_data = """ network net (outbound = 'yes') system test ( cpu.arch='x86_64' and cpu.count=1 and memory.size=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'azr://image-id' and disk.0.os.credentials.username = '******' and disk.0.os.credentials.password = '******' )""" radl = radl_parse.parse_radl(radl_data) radl.check() auth = Authentication([{'id': 'azure', 'type': 'AzureClassic', 'subscription_id': 'user', 'public_key': 'public_key', 'private_key': 'private_key'}]) azure_cloud = self.get_azure_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", azure_cloud.cloud, radl, radl, azure_cloud, 1) requests.side_effect = self.get_response success, vm = azure_cloud.updateVMInfo(vm, auth) self.assertTrue(success, msg="ERROR: updating VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_10_concrete(self): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'vsp://vspherehost/image-id' and disk.0.os.credentials.username = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{ 'id': 'vsp', 'type': 'vSphere', 'host': 'https://vspherehost', 'username': '******', 'password': '******' }]) vsphere_cloud = self.get_vsphere_cloud() concrete = vsphere_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_50_start(self, get_driver): auth = Authentication([{ 'id': 'one', 'type': 'GCE', 'username': '******', 'password': '******', 'project': 'proj' }]) gce_cloud = self.get_gce_cloud() inf = MagicMock() vm = VirtualMachine(inf, "1", gce_cloud.cloud, "", "", gce_cloud, 1) driver = MagicMock() get_driver.return_value = driver driver.ex_get_node.return_value = MagicMock() driver.ex_start_node.return_value = True success, _ = gce_cloud.start(vm, auth) self.assertTrue(success, msg="ERROR: stopping VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_80_delete_image(self, get_driver): auth = Authentication([{ 'id': 'ost', 'type': 'OpenStack', 'username': '******', 'tenant_domain_id': "tdi", 'password': '******', 'tenant': 'tenant', 'host': 'https://server.com:5000' }]) ost_cloud = self.get_ost_cloud() driver = MagicMock() driver.name = "OpenStack" get_driver.return_value = driver image = MagicMock() image.id = "image" driver.get_image.return_value = image success, msg = ost_cloud.delete_image('ost://server.com/image', auth) self.assertTrue(success, msg="ERROR: deleting image. %s" % msg) self.assertEqual(driver.delete_image.call_args_list, [call(image)]) self.assertEqual( get_driver.call_args_list[0][1]["ex_tenant_domain_id"], "tdi") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_60_finalize(self, get_keystone_uri, requests): auth = Authentication([{ 'id': 'occi', 'type': 'OCCI', 'proxy': 'proxy', 'host': 'https://server.com:11443' }]) occi_cloud = self.get_occi_cloud() inf = MagicMock() radl = RADL() radl.systems.append(system("test")) vm = VirtualMachine(inf, "1", occi_cloud.cloud, radl, radl, occi_cloud, 1) requests.side_effect = self.get_response get_keystone_uri.return_value = None, None success, _ = occi_cloud.finalize(vm, True, auth) self.assertTrue(success, msg="ERROR: finalizing VM info.") self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_10_concrete(self): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'fbw://fogbow-ubuntu' and disk.0.os.credentials.username = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{ 'id': 'fogbow', 'type': 'FogBow', 'proxy': 'user', 'host': 'server.com:8182' }]) fogbow_cloud = self.get_fogbow_cloud() concrete = fogbow_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_concrete_appdb(self, get_site_url, get_site_id): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'appdb://CESNET-MetaCloud/egi.ubuntu.16.04?fedcloud.egi.eu' and disk.0.os.credentials.username = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{ 'id': 'occi', 'type': 'OCCI', 'proxy': 'proxy', 'host': 'https://carach5.ics.muni.cz:11443' }]) occi_cloud = self.get_occi_cloud() occi_cloud.cloud.server = "carach5.ics.muni.cz" get_site_url.return_value = "https://carach5.ics.muni.cz:11443" get_site_id.return_value = "siteid" concrete = occi_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
def test_10_concrete(self): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'docker://someimage' and disk.0.os.credentials.username = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{ 'id': 'fogbow', 'type': 'Kubernetes', 'host': 'http://server.com:8080' }]) kube_cloud = self.get_kube_cloud() concrete = kube_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue()) self.clean_log()
def test_10_concrete(self): radl_data = """ network net () system test ( cpu.arch='x86_64' and cpu.count>=1 and memory.size>=512m and net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and disk.0.image.url = 'one://server.com/1' and disk.0.os.credentials.username = '******' and disk.0.os.credentials.password = '******' )""" radl = radl_parse.parse_radl(radl_data) radl_system = radl.systems[0] auth = Authentication([{ 'id': 'one', 'type': 'OpenNebula', 'username': '******', 'password': '******', 'host': 'server.com:2633' }]) one_cloud = self.get_one_cloud() concrete = one_cloud.concreteSystem(radl_system, auth) self.assertEqual(len(concrete), 1) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())