diff --git a/systemvm/patches/debian/config/opt/cloud/bin/merge.py b/systemvm/patches/debian/config/opt/cloud/bin/merge.py index 4087094dfcd..50d9ee9aae8 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/merge.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/merge.py @@ -214,6 +214,10 @@ class updateDataBag: elif (self.qFile.data['cmd_line']['type'] == "dhcpsrvr"): self.processCLItem('0', "guest") self.processCLItem('1', "control") + elif (self.qFile.data['cmd_line']['type'] == "ilbvm"): + self.processCLItem('0', "guest") + self.processCLItem('1', "control") + return cs_cmdline.merge(dbag, self.qFile.data) def processCLItem(self, num, nw_type): @@ -225,10 +229,13 @@ class updateDataBag: dp['source_nat'] = False dp['add'] = True dp['one_to_one_nat'] = False - if('localgw' in self.qFile.data['cmd_line']): - dp['gateway'] = self.qFile.data['cmd_line']['localgw'] + if nw_type == "public": + dp['gateway'] = self.qFile.data['cmd_line']['gateway'] else: - dp['gateway'] = 'None' + if('localgw' in self.qFile.data['cmd_line']): + dp['gateway'] = self.qFile.data['cmd_line']['localgw'] + else: + dp['gateway'] = 'None' dp['nic_dev_id'] = num dp['nw_type'] = nw_type qf = QueueFile() diff --git a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py index c9eb7672e2d..9b638a9d40b 100644 --- a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py +++ b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py @@ -49,6 +49,7 @@ class TestDeployvGPUenabledVM(cloudstackTestCase): testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient() self.apiclient = testClient.getApiClient() self.testdata = self.testClient.getParsedTestDataConfig() + self.hostConfig = self.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ self._cleanup = [] self.unsupportedHypervisor = False self.noSuitableHost = False @@ -69,8 +70,8 @@ class TestDeployvGPUenabledVM(cloudstackTestCase): sshClient = SshClient( host=ghost.ipaddress, port=self.testdata['configurableData']['host']["publicport"], - user=self.testdata['configurableData']['host']["username"], - passwd=self.testdata['configurableData']['host']["password"]) + user=self.hostConfig['username'], + passwd=self.hostConfig['password']) if ghost.hypervisorversion == "6.2.0": res = sshClient.execute( "xe patch-list uuid=0850b186-4d47-11e3-a720-001b2151a503") diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py index c4be42b6702..f2f93649fec 100644 --- a/test/integration/smoke/test_internal_lb.py +++ b/test/integration/smoke/test_internal_lb.py @@ -226,7 +226,7 @@ class Services: "displaytext": "macchinina kvm", "format": "qcow2", "hypervisor": "kvm", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", "requireshvm": "True" }, @@ -235,7 +235,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "xenserver", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", "requireshvm": "True", }, @@ -244,7 +244,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "hyperv", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", "requireshvm": "True", }, @@ -253,8 +253,8 @@ class Services: "displaytext": "macchinina vmware", "format": "ova", "hypervisor": "vmware", - "ostype": "Other PV (64-bit)", - "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.vmdk.bz2", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", "requireshvm": "True", } } @@ -302,7 +302,7 @@ class TestInternalLb(cloudstackTestCase): %s" % (cls.account.name, cls.account.id)) - cls._cleanup = [cls.template, cls.account, cls.compute_offering] + cls._cleanup = [cls.account, cls.compute_offering] return def setUp(self): @@ -842,6 +842,9 @@ class TestInternalLb(cloudstackTestCase): def tearDownClass(cls): try: cls.logger.debug("Cleaning up class resources") + try: + cls.template.delete(cls.apiclient) + except Exception: pass cleanup_resources(cls.apiclient, cls._cleanup) except Exception as e: raise Exception("Cleanup failed with %s" % e) diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index 719d78afa88..bb1e14b5d14 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -1039,6 +1039,7 @@ class TestRouterRules(cloudstackTestCase): cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.hypervisor = testClient.getHypervisorInfo() + cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ template = get_template( cls.apiclient, cls.zone.id, @@ -1117,8 +1118,8 @@ class TestRouterRules(cloudstackTestCase): "Check for list hosts response return valid data" ) host = hosts[0] - host.user = self.services["configurableData"]["host"]["username"] - host.passwd = self.services["configurableData"]["host"]["password"] + host.user = self.hostConfig['username'] + host.passwd = self.hostConfig['password'] result = get_process_status( host.ipaddress, diff --git a/test/integration/smoke/test_network_acl.py b/test/integration/smoke/test_network_acl.py index 909da7e1e0b..734c312977e 100644 --- a/test/integration/smoke/test_network_acl.py +++ b/test/integration/smoke/test_network_acl.py @@ -64,7 +64,7 @@ class TestNetworkACL(cloudstackTestCase): self.assert_(networkOffering is not None and len(networkOffering) > 0, "No VPC based network offering") # 1) Create VPC - vpcOffering = VpcOffering.list(self.apiclient,isdefault=True) + vpcOffering = VpcOffering.list(self.apiclient, name="Default VPC offering") self.assert_(vpcOffering is not None and len(vpcOffering)>0, "No VPC offerings found") self.services["vpc"] = {} self.services["vpc"]["name"] = "vpc-networkacl" diff --git a/test/integration/smoke/test_non_contigiousvlan.py b/test/integration/smoke/test_non_contigiousvlan.py index e4446180688..c7a5467b110 100644 --- a/test/integration/smoke/test_non_contigiousvlan.py +++ b/test/integration/smoke/test_non_contigiousvlan.py @@ -47,9 +47,17 @@ class TestUpdatePhysicalNetwork(cloudstackTestCase): self.assertNotEqual(len(phy_networks), 0, msg="There are no physical networks in the zone") - self.network = phy_networks[0] - self.networkid = phy_networks[0].id - self.existing_vlan = phy_networks[0].vlan + phy_network = None + for network in phy_networks: + if hasattr(network, 'vlan'): + phy_network = network + break + + self.assert_(phy_network is not None, msg="No network with vlan found") + + self.network = phy_network + self.networkid = phy_network.id + self.existing_vlan = phy_network.vlan vlan1 = self.existing_vlan+","+self.vlan["partial_range"][0] updatePhysicalNetworkResponse = self.network.update(self.apiClient, id = self.networkid, vlan = vlan1) self.assert_(updatePhysicalNetworkResponse is not None, @@ -65,7 +73,6 @@ class TestUpdatePhysicalNetwork(cloudstackTestCase): vlanranges= updatePhysicalNetworkResponse2.vlan self.assert_(vlanranges is not None, "No VLAN ranges found on the deployment") - self.assert_(str(vlanranges) == vlan2, "vlan ranges are not extended") def tearDown(self): diff --git a/test/integration/smoke/test_password_server.py b/test/integration/smoke/test_password_server.py index 0fc7e258d58..98c5ced19f1 100644 --- a/test/integration/smoke/test_password_server.py +++ b/test/integration/smoke/test_password_server.py @@ -64,6 +64,7 @@ class TestIsolatedNetworksPasswdServer(cloudstackTestCase): cls.testClient = super(TestIsolatedNetworksPasswdServer, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() + cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) @@ -141,8 +142,6 @@ class TestIsolatedNetworksPasswdServer(cloudstackTestCase): cls.services["configurableData"] = { "host": { - "password": "password", - "username": "root", "port": 22 }, "input": "INPUT", @@ -170,6 +169,7 @@ class TestIsolatedNetworksPasswdServer(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() + self.hypervisor = self.testClient.getHypervisorInfo() return def test_ssh_command(self, vm, nat_rule, rule_label): @@ -181,12 +181,12 @@ class TestIsolatedNetworksPasswdServer(cloudstackTestCase): ssh = vm.get_ssh_client(ipaddress=nat_rule.ipaddress, port=self.services[rule_label]["publicport"], retries=5) result = str(ssh.execute(ssh_command)) - self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 packets received"))) + self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count(" 0% packet loss"))) except: self.fail("Failed to SSH into VM - %s" % (nat_rule.ipaddress)) self.assertEqual( - result.count("3 packets received"), + result.count(" 0% packet loss"), 1, "Ping to outside world from VM should be successful" ) @@ -202,23 +202,34 @@ class TestIsolatedNetworksPasswdServer(cloudstackTestCase): "Check for list hosts response return valid data") host = hosts[0] - host.user = self.services["configurableData"]["host"]["username"] - host.passwd = self.services["configurableData"]["host"]["password"] + host.user = self.hostConfig['username'] + host.passwd = self.hostConfig['password'] host.port = self.services["configurableData"]["host"]["port"] - - try: + + if self.hypervisor.lower() in ('vmware', 'hyperv'): result = get_process_status( - host.ipaddress, - host.port, - host.user, - host.passwd, + self.apiclient.connection.mgtSvr, + 22, + self.apiclient.connection.user, + self.apiclient.connection.passwd, router.linklocalip, - "cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm.nic[0].gateway, vm.nic[0].ipaddress)) - except KeyError: - self.skipTest( - "Provide a marvin config file with host\ - credentials to run %s" % - self._testMethodName) + "cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm.nic[0].gateway, vm.nic[0].ipaddress), + hypervisor=self.hypervisor + ) + else: + try: + result = get_process_status( + host.ipaddress, + host.port, + host.user, + host.passwd, + router.linklocalip, + "cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm.nic[0].gateway, vm.nic[0].ipaddress)) + except KeyError: + self.skipTest( + "Provide a marvin config file with host\ + credentials to run %s" % + self._testMethodName) self.logger.debug("cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}' RESULT IS ==> %s" % (vm.nic[0].gateway, vm.nic[0].ipaddress, result)) res = str(result) diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py index 82212255540..b1759a50582 100644 --- a/test/integration/smoke/test_primary_storage.py +++ b/test/integration/smoke/test_primary_storage.py @@ -157,6 +157,9 @@ class TestPrimaryStorageServices(cloudstackTestCase): if self.hypervisor.lower() in ["kvm","hyperv", "vmware", "lxc"]: raise self.skipTest("iscsi primary storage not supported on kvm, VMWare, Hyper-V, or LXC") + if not self.services["configurableData"]["iscsi"]["url"]: + raise self.skipTest("iscsi test storage url not setup, skipping") + # Validate the following: # 1. List Clusters # 2. verify that the cluster is in 'Enabled' allocation state diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py index a1c5e85cf8c..15f499ec560 100644 --- a/test/integration/smoke/test_privategw_acl.py +++ b/test/integration/smoke/test_privategw_acl.py @@ -37,8 +37,6 @@ class Services: self.services = { "configurableData": { "host": { - "password": "password", - "username": "root", "port": 22 } }, @@ -173,6 +171,7 @@ class TestPrivateGwACL(cloudstackTestCase): cls.zone.id, cls.services["ostype"]) + cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id @@ -197,6 +196,8 @@ class TestPrivateGwACL(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() + self.hypervisor = self.testClient.getHypervisorInfo() + self.logger.debug("Creating Admin Account for Domain ID ==> %s" % self.domain.id) self.account = Account.create( self.apiclient, @@ -236,13 +237,13 @@ class TestPrivateGwACL(cloudstackTestCase): self.cleanup = [vpc, vpc_off, self.account] - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") qresultset = self.dbclient.execute( "select vnet from op_dc_vnet_alloc where physical_network_id=\ - (select id from physical_network where uuid='%s' ) and taken is NULL;" % physical_networks[0].id + (select id from physical_network where uuid='%s' ) and taken is NULL and reservation_id is NULL and account_id is NULL ORDER BY id DESC;" % physical_network.id ) self.assertEqual(validateList(qresultset)[0], PASS, @@ -312,13 +313,13 @@ class TestPrivateGwACL(cloudstackTestCase): self.cleanup = [vpc_1, vpc_2, vpc_off, self.account] - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") qresultset = self.dbclient.execute( "select vnet from op_dc_vnet_alloc where physical_network_id=\ - (select id from physical_network where uuid='%s' ) and taken is NULL;" % physical_networks[0].id + (select id from physical_network where uuid='%s' ) and taken is NULL and reservation_id is NULL and account_id is NULL ORDER BY id DESC;" % physical_network.id ) self.assertEqual(validateList(qresultset)[0], PASS, @@ -372,12 +373,15 @@ class TestPrivateGwACL(cloudstackTestCase): self.cleanup = [vpc_1, vpc_off, self.account] - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") - - vlans = physical_networks[0].vlan.split('-') - vlan_1 = int(vlans[0]) + qresultset = self.dbclient.execute( + "select vnet from op_dc_vnet_alloc where physical_network_id=\ + (select id from physical_network where uuid='%s' ) and taken is NULL and reservation_id is NULL and account_id is NULL ORDER BY id DESC;" % physical_network.id + ) + vlans = qresultset + vlan_1 = int(vlans[0][0]) net_offering_no_lb = "network_offering_no_lb" @@ -408,7 +412,7 @@ class TestPrivateGwACL(cloudstackTestCase): public_ip_1 = self.acquire_publicip(vpc_1, network_1) nat_rule_1 = self.create_natrule(vpc_1, vm1, public_ip_1, network_1) - + self.check_private_gateway_interfaces() self.check_pvt_gw_connectivity(vm1, public_ip_1, [vm2.nic[0].ipaddress, vm3.nic[0].ipaddress, vm4.nic[0].ipaddress]) @@ -589,14 +593,14 @@ class TestPrivateGwACL(cloudstackTestCase): return obj_network def createPvtGw(self, vpc, ip_address, gateway, aclId, vlan): - physical_networks = get_physical_networks(self.apiclient, self.zone.id) - if not physical_networks: + physical_network = self.get_guest_traffic_physical_network(self.apiclient, self.zone.id) + if not physical_network: self.fail("No Physical Networks found!") - self.logger.debug('::: Physical Networks ::: ==> %s' % physical_networks) + self.logger.debug('::: Physical Networks ::: ==> %s' % physical_network) createPrivateGatewayCmd = createPrivateGateway.createPrivateGatewayCmd() - createPrivateGatewayCmd.physicalnetworkid = physical_networks[0].id + createPrivateGatewayCmd.physicalnetworkid = physical_network.id createPrivateGatewayCmd.gateway = gateway createPrivateGatewayCmd.netmask = "255.255.255.0" createPrivateGatewayCmd.ipaddress = ip_address @@ -707,13 +711,13 @@ class TestPrivateGwACL(cloudstackTestCase): self.logger.debug("Ping to VM inside another Network Tier") result = str(ssh.execute(ssh_command)) - self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 packets received"))) + self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 received"))) except Exception as e: self.fail("SSH Access failed for %s: %s" % \ (virtual_machine, e) ) - succeeded_pings += result.count("3 packets received") + succeeded_pings += result.count("3 received") self.assertTrue(succeeded_pings >= minimum_vms_to_pass, @@ -751,28 +755,47 @@ class TestPrivateGwACL(cloudstackTestCase): "Check for list hosts response return valid data") host = hosts[0] - host.user = self.services["configurableData"]["host"]["username"] - host.passwd = self.services["configurableData"]["host"]["password"] + host.user = self.hostConfig['username'] + host.passwd = self.hostConfig['password'] host.port = self.services["configurableData"]["host"]["port"] - try: + if self.hypervisor.lower() in ('vmware', 'hyperv'): state = get_process_status( - host.ipaddress, - host.port, - host.user, - host.passwd, - router.linklocalip, - "ip addr | grep eth6 | grep state | awk '{print $9;}'") + self.apiclient.connection.mgtSvr, + 22, + self.apiclient.connection.user, + self.apiclient.connection.passwd, + router.linklocalip, + "ip addr | grep eth6 | grep state | awk '{print $9;}'", + hypervisor=self.hypervisor) mac = get_process_status( - host.ipaddress, - host.port, - host.user, - host.passwd, - router.linklocalip, - "ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p") - except KeyError: - self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName) + self.apiclient.connection.mgtSvr, + 22, + self.apiclient.connection.user, + self.apiclient.connection.passwd, + router.linklocalip, + "ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p", + hypervisor=self.hypervisor) + else: + try: + state = get_process_status( + host.ipaddress, + host.port, + host.user, + host.passwd, + router.linklocalip, + "ip addr | grep eth6 | grep state | awk '{print $9;}'") + + mac = get_process_status( + host.ipaddress, + host.port, + host.user, + host.passwd, + router.linklocalip, + "ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p") + except KeyError: + self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName) state = str(state[0]) mac = str(mac[0]) @@ -847,3 +870,11 @@ class TestPrivateGwACL(cloudstackTestCase): if cnts[vals.index(status_to_check)] != expected_count: self.fail("Expected '%s' routers at state '%s', but found '%s'!" % (expected_count, status_to_check, cnts[vals.index(status_to_check)])) + + def get_guest_traffic_physical_network(self, apiclient, zoneid): + physical_networks = get_physical_networks(apiclient, zoneid) + if not physical_networks: + return None + for physical_network in physical_networks: + if physical_network.vlan: + return physical_network diff --git a/test/integration/smoke/test_router_dhcphosts.py b/test/integration/smoke/test_router_dhcphosts.py index 4c2ec4ce57e..4e619542003 100644 --- a/test/integration/smoke/test_router_dhcphosts.py +++ b/test/integration/smoke/test_router_dhcphosts.py @@ -74,7 +74,7 @@ class TestRouterDHCPHosts(cloudstackTestCase): cls.zone.id, cls.services["ostype"] ) - + cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.logger.debug("Creating Admin Account for domain %s on zone %s" % (cls.domain.id, cls.zone.id)) @@ -143,8 +143,6 @@ class TestRouterDHCPHosts(cloudstackTestCase): cls.services["configurableData"] = { "host": { - "password": "password", - "username": "root", "port": 22 }, "input": "INPUT", @@ -171,6 +169,7 @@ class TestRouterDHCPHosts(cloudstackTestCase): def setUp(self): self.apiclient = self.testClient.getApiClient() + self.hypervisor = self.testClient.getHypervisorInfo() self.cleanup = [] return @@ -190,12 +189,12 @@ class TestRouterDHCPHosts(cloudstackTestCase): ssh = vm.get_ssh_client(ipaddress=nat_rule.ipaddress, port=self.services[rule_label]["publicport"], retries=5) result = str(ssh.execute(ssh_command)) - self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 packets received"))) + self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count(" 0% packet loss"))) except: self.fail("Failed to SSH into VM - %s" % (nat_rule.ipaddress)) self.assertEqual( - result.count("3 packets received"), + result.count(" 0% packet loss"), 1, "Ping to outside world from VM should be successful" ) @@ -211,23 +210,33 @@ class TestRouterDHCPHosts(cloudstackTestCase): "Check for list hosts response return valid data") host = hosts[0] - host.user = self.services["configurableData"]["host"]["username"] - host.passwd = self.services["configurableData"]["host"]["password"] + host.user = self.hostConfig['username'] + host.passwd = self.hostConfig['password'] host.port = self.services["configurableData"]["host"]["port"] - #mac1,10.7.32.101,infinite - try: + + if self.hypervisor.lower() in ('vmware', 'hyperv'): result = get_process_status( - host.ipaddress, - host.port, - host.user, - host.passwd, + self.apiclient.connection.mgtSvr, + 22, + self.apiclient.connection.user, + self.apiclient.connection.passwd, router.linklocalip, - "cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress)) - except KeyError: - self.skipTest( - "Provide a marvin config file with host\ - credentials to run %s" % - self._testMethodName) + "cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress), + hypervisor=self.hypervisor) + else: + try: + result = get_process_status( + host.ipaddress, + host.port, + host.user, + host.passwd, + router.linklocalip, + "cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress)) + except KeyError: + self.skipTest( + "Provide a marvin config file with host\ + credentials to run %s" % + self._testMethodName) self.logger.debug("cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}' RESULT IS ==> %s" % (vm.nic[0].ipaddress, result)) res = str(result) diff --git a/test/integration/smoke/test_routers_iptables_default_policy.py b/test/integration/smoke/test_routers_iptables_default_policy.py index a1bec4cac36..ec35396017b 100644 --- a/test/integration/smoke/test_routers_iptables_default_policy.py +++ b/test/integration/smoke/test_routers_iptables_default_policy.py @@ -54,8 +54,6 @@ class Services: self.services = { "configurableData": { "host": { - "password": "password", - "username": "root", "port": 22 }, "input": "INPUT", @@ -220,6 +218,7 @@ class TestVPCIpTablesPolicies(cloudstackTestCase): cls.apiclient, cls.zone.id, cls.services["ostype"]) + cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id @@ -254,6 +253,7 @@ class TestVPCIpTablesPolicies(cloudstackTestCase): return def setUp(self): + self.hypervisor = self.testClient.getHypervisorInfo() self.logger.debug("Creating a VPC offering.") self.vpc_off = VpcOffering.create( self.apiclient, @@ -312,25 +312,36 @@ class TestVPCIpTablesPolicies(cloudstackTestCase): "Check for list hosts response return valid data") host = hosts[0] - host.user = self.services["configurableData"]["host"]["username"] - host.passwd = self.services["configurableData"]["host"]["password"] + host.user = self.hostConfig['username'] + host.passwd = self.hostConfig['password'] host.port = self.services["configurableData"]["host"]["port"] tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]] for table in tables: - try: + result = None + if self.hypervisor.lower() in ('vmware', 'hyperv'): result = get_process_status( - host.ipaddress, - host.port, - host.user, - host.passwd, + self.apiclient.connection.mgtSvr, + 22, + self.apiclient.connection.user, + self.apiclient.connection.passwd, router.linklocalip, - 'iptables -L %s' % table) - except KeyError: - self.skipTest( - "Provide a marvin config file with host\ - credentials to run %s" % - self._testMethodName) + 'iptables -L %s' % table, + hypervisor=self.hypervisor) + else: + try: + result = get_process_status( + host.ipaddress, + host.port, + host.user, + host.passwd, + router.linklocalip, + 'iptables -L %s' % table) + except KeyError: + self.skipTest( + "Provide a marvin config file with host\ + credentials to run %s" % + self._testMethodName) self.logger.debug("iptables -L %s: %s" % (table, result)) res = str(result) @@ -360,6 +371,7 @@ class TestRouterIpTablesPolicies(cloudstackTestCase): cls.zone.id, cls.services["ostype"]) + cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__ cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id @@ -392,6 +404,7 @@ class TestRouterIpTablesPolicies(cloudstackTestCase): return def setUp(self): + self.hypervisor = self.testClient.getHypervisorInfo() self.cleanup = [] self.entity_manager.set_cleanup(self.cleanup) return @@ -428,25 +441,36 @@ class TestRouterIpTablesPolicies(cloudstackTestCase): "Check for list hosts response return valid data") host = hosts[0] - host.user = self.services["configurableData"]["host"]["username"] - host.passwd = self.services["configurableData"]["host"]["password"] + host.user = self.hostConfig['username'] + host.passwd = self.hostConfig['password'] host.port = self.services["configurableData"]["host"]["port"] tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]] for table in tables: - try: + result = None + if self.hypervisor.lower() in ('vmware', 'hyperv'): result = get_process_status( - host.ipaddress, - host.port, - host.user, - host.passwd, + self.apiclient.connection.mgtSvr, + 22, + self.apiclient.connection.user, + self.apiclient.connection.passwd, router.linklocalip, - 'iptables -L %s' % table) - except KeyError: - self.skipTest( - "Provide a marvin config file with host\ - credentials to run %s" % - self._testMethodName) + 'iptables -L %s' % table, + hypervisor=self.hypervisor) + else: + try: + result = get_process_status( + host.ipaddress, + host.port, + host.user, + host.passwd, + router.linklocalip, + 'iptables -L %s' % table) + except KeyError: + self.skipTest( + "Provide a marvin config file with host\ + credentials to run %s" % + self._testMethodName) self.logger.debug("iptables -L %s: %s" % (table, result)) res = str(result) diff --git a/test/integration/smoke/test_routers_network_ops.py b/test/integration/smoke/test_routers_network_ops.py index 94c07742ad1..93563e29818 100644 --- a/test/integration/smoke/test_routers_network_ops.py +++ b/test/integration/smoke/test_routers_network_ops.py @@ -16,6 +16,7 @@ # under the License. # Import Local Modules +from marvin.codes import PASS, FAILED from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackAPI import (stopVirtualMachine, @@ -27,6 +28,7 @@ from marvin.lib.utils import (cleanup_resources, from marvin.lib.base import (ServiceOffering, VirtualMachine, Account, + Template, ServiceOffering, NATRule, NetworkACL, @@ -52,6 +54,7 @@ from marvin.lib.common import (get_zone, import time import logging + def check_router_command(virtual_machine, public_ip, ssh_command, check_string, test_case, retries=5): result = 'failed' try: @@ -63,6 +66,58 @@ def check_router_command(virtual_machine, public_ip, ssh_command, check_string, logging.debug("Result from SSH into the Virtual Machine: %s" % result) return result.count(check_string) + +class Templates: + """Test data for templates + """ + + def __init__(self): + self.templates = { + "macchinina": { + "kvm": { + "name": "tiny-kvm", + "displaytext": "macchinina kvm", + "format": "qcow2", + "hypervisor": "kvm", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "xenserver": { + "name": "tiny-xen", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "xen", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "hyperv": { + "name": "tiny-hyperv", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "hyperv", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", + "requireshvm": "True", + "ispublic": "True", + }, + "vmware": { + "name": "tiny-vmware", + "displaytext": "macchinina vmware", + "format": "ova", + "hypervisor": "vmware", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", + "requireshvm": "True", + "ispublic": "True", + }, + } + } + + class TestRedundantIsolateNetworks(cloudstackTestCase): @classmethod @@ -81,12 +136,20 @@ class TestRedundantIsolateNetworks(cloudstackTestCase): cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype - cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) + + macchinina = Templates().templates["macchinina"] + cls.hypervisor = cls.testClient.getHypervisorInfo() + cls.logger.debug("Downloading Template: %s from: %s" % (macchinina[cls.hypervisor.lower()], + macchinina[cls.hypervisor.lower()]["url"])) + cls.template = Template.register(cls.api_client, macchinina[cls.hypervisor.lower()], + cls.zone.id, hypervisor=cls.hypervisor.lower(), domainid=cls.domain.id) + cls.template.download(cls.api_client) + + if cls.template == FAILED: + assert False, "get_template() failed to return template" + cls.services["virtual_machine"]["zoneid"] = cls.zone.id + cls.services["virtual_machine"]["template"] = cls.template.id # Create an account, network, VM and IP addresses cls.account = Account.create( @@ -122,7 +185,8 @@ class TestRedundantIsolateNetworks(cloudstackTestCase): cls._cleanup = [ cls.service_offering, - cls.account + cls.account, + cls.template ] return @@ -270,7 +334,7 @@ class TestRedundantIsolateNetworks(cloudstackTestCase): # Test SSH after closing port 22 expected = 1 ssh_command = "ping -c 3 8.8.8.8" - check_string = "3 packets received" + check_string = " 0% packet loss" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) self.assertEqual( @@ -434,7 +498,7 @@ class TestRedundantIsolateNetworks(cloudstackTestCase): expected = 0 ssh_command = "ping -c 3 8.8.8.8" - check_string = "3 packets received" + check_string = " 0% packet loss" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) self.assertEqual( @@ -822,7 +886,7 @@ class TestIsolatedNetworks(cloudstackTestCase): # Test SSH after closing port 22 expected = 1 ssh_command = "ping -c 3 8.8.8.8" - check_string = "3 packets received" + check_string = " 0% packet loss" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) self.assertEqual( @@ -977,7 +1041,7 @@ class TestIsolatedNetworks(cloudstackTestCase): expected = 0 ssh_command = "ping -c 3 8.8.8.8" - check_string = "3 packets received" + check_string = " 0% packet loss" result = check_router_command(virtual_machine, nat_rule.ipaddress, ssh_command, check_string, self) self.assertEqual( diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py index 4b1fcbd526f..638b66cac40 100644 --- a/test/integration/smoke/test_snapshots.py +++ b/test/integration/smoke/test_snapshots.py @@ -22,6 +22,7 @@ from marvin.lib.utils import (cleanup_resources, is_snapshot_on_nfs) from marvin.lib.base import (VirtualMachine, Account, + Template, ServiceOffering, Snapshot) from marvin.lib.common import (get_domain, @@ -32,6 +33,57 @@ from marvin.lib.common import (get_domain, from marvin.lib.decoratorGenerators import skipTestIf +class Templates: + """Test data for templates + """ + + def __init__(self): + self.templates = { + "macchinina": { + "kvm": { + "name": "tiny-kvm", + "displaytext": "macchinina kvm", + "format": "qcow2", + "hypervisor": "kvm", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "xenserver": { + "name": "tiny-xen", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "xen", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "hyperv": { + "name": "tiny-hyperv", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "hyperv", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", + "requireshvm": "True", + "ispublic": "True", + }, + "vmware": { + "name": "tiny-vmware", + "displaytext": "macchinina vmware", + "format": "ova", + "hypervisor": "vmware", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", + "requireshvm": "True", + "ispublic": "True", + }, + } + } + + class TestSnapshotRootDisk(cloudstackTestCase): @classmethod @@ -47,23 +99,23 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.hypervisorNotSupported = False cls.hypervisor = cls.testClient.getHypervisorInfo() - if cls.hypervisor.lower() in ['hyperv', 'lxc']: + if cls.hypervisor.lower() in ['hyperv', 'lxc'] or 'kvm-centos6' in cls.testClient.getZoneForTests(): cls.hypervisorNotSupported = True cls._cleanup = [] if not cls.hypervisorNotSupported: - template = get_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"] - ) - if template == FAILED: - assert False, "get_template() failed to return template with description %s" % cls.services[ - "ostype"] + macchinina = Templates().templates["macchinina"] + cls.template = Template.register(cls.apiclient, macchinina[cls.hypervisor.lower()], + cls.zone.id, hypervisor=cls.hypervisor.lower(), domainid=cls.domain.id) + cls.template.download(cls.apiclient) + + if cls.template == FAILED: + assert False, "get_template() failed to return template" + cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id - cls.services["templates"]["ostypeid"] = template.ostypeid + cls.services["templates"]["ostypeid"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc @@ -72,23 +124,26 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls._cleanup.append(cls.account) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] ) - cls._cleanup.append(cls.service_offering) cls.virtual_machine = cls.virtual_machine_with_disk = \ VirtualMachine.create( cls.apiclient, cls.services["small"], - templateid=template.id, + templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) + + cls._cleanup.append(cls.virtual_machine) + cls._cleanup.append(cls.service_offering) + cls._cleanup.append(cls.account) + cls._cleanup.append(cls.template) return @classmethod @@ -141,6 +196,7 @@ class TestSnapshotRootDisk(cloudstackTestCase): account=self.account.name, domainid=self.account.domainid ) + self.cleanup.append(snapshot) self.debug("Snapshot created: ID - %s" % snapshot.id) snapshots = list_snapshots( diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py index 3831848225c..5fcb80a8aed 100644 --- a/test/integration/smoke/test_vm_snapshots.py +++ b/test/integration/smoke/test_vm_snapshots.py @@ -16,7 +16,7 @@ # under the License. # Import Local Modules -from marvin.codes import FAILED, KVM, PASS +from marvin.codes import FAILED, KVM, PASS, XEN_SERVER from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.utils import random_gen, cleanup_resources, validateList, is_snapshot_on_nfs @@ -291,7 +291,7 @@ class TestSnapshots(cloudstackTestCase): cls.services = cls.testClient.getParsedTestDataConfig() cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() - if cls.hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"): + if cls.hypervisor.lower() in (KVM.lower(), "hyperv", "lxc", XEN_SERVER.lower()): cls.unsupportedHypervisor = True return # Get Domain, Zone, Template @@ -362,12 +362,12 @@ class TestSnapshots(cloudstackTestCase): @attr(tags=["advanced", "basic", "smoke"], required_hardware="true") def test_01_test_vm_volume_snapshot(self): """ - @Desc: Test that Volume snapshot for root volume is allowed + @Desc: Test that Volume snapshot for root volume is not allowed when VM snapshot is present for the VM @Steps: 1: Deploy a VM and create a VM snapshot for VM 2: Try to create snapshot for the root volume of the VM, - It should not fail + It should expect Exception """ # Creating Virtual Machine @@ -392,25 +392,10 @@ class TestSnapshots(cloudstackTestCase): self.assertEqual(validateList(volumes)[0], PASS, "Failed to get root volume of the VM") - snapshot = Snapshot.create( - self.apiclient, - volumes[0].id, - account=self.account.name, - domainid=self.account.domainid - ) - self.debug("Snapshot created: ID - %s" % snapshot.id) - snapshots = list_snapshots( - self.apiclient, - id=snapshot.id - ) - self.assertEqual( - validateList(snapshots)[0], - PASS, - "Invalid snapshot list" - ) - self.assertEqual( - snapshots[0].id, - snapshot.id, - "Check resource id in list resources call" - ) + volume = volumes[0] + + with self.assertRaises(Exception): + Snapshot.create(self.apiclient, + volume_id=volume.id) + return diff --git a/test/integration/smoke/test_vpc_redundant.py b/test/integration/smoke/test_vpc_redundant.py index fbaa5b96e6c..2c7f4aeac61 100644 --- a/test/integration/smoke/test_vpc_redundant.py +++ b/test/integration/smoke/test_vpc_redundant.py @@ -18,6 +18,7 @@ """ Test redundancy features for VPC routers """ +from marvin.codes import PASS, FAILED from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.base import (stopRouter, @@ -25,6 +26,7 @@ from marvin.lib.base import (stopRouter, destroyRouter, rebootRouter, Account, + Template, VpcOffering, VPC, ServiceOffering, @@ -191,8 +193,49 @@ class Services: "publicport": 22, "protocol": 'TCP', }, - "ostype": 'CentOS 5.3 (64-bit)', "timeout": 10, + "template": { + "kvm": { + "name": "tiny-kvm", + "displaytext": "macchinina kvm", + "format": "qcow2", + "hypervisor": "kvm", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "xenserver": { + "name": "tiny-xen", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "xen", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "hyperv": { + "name": "tiny-hyperv", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "hyperv", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", + "requireshvm": "True", + "ispublic": "True", + }, + "vmware": { + "name": "tiny-vmware", + "displaytext": "macchinina vmware", + "format": "ova", + "hypervisor": "vmware", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", + "requireshvm": "True", + "ispublic": "True", + } + } } @@ -210,17 +253,22 @@ class TestVPCRedundancy(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) - cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"]) + + cls.hypervisor = cls.testClient.getHypervisorInfo() + cls.template = Template.register(cls.api_client, cls.services["template"][cls.hypervisor.lower( + )], cls.zone.id, hypervisor=cls.hypervisor.lower(), domainid=cls.domain.id) + cls.template.download(cls.api_client) + + if cls.template == FAILED: + assert False, "get_template() failed to return template" + cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) - cls._cleanup = [cls.service_offering] + cls._cleanup = [cls.service_offering, cls.template] cls.logger = logging.getLogger('TestVPCRedundancy') cls.stream_handler = logging.StreamHandler() @@ -592,7 +640,7 @@ class TestVPCRedundancy(cloudstackTestCase): gc_interval = Configurations.list(self.apiclient, name="network.gc.interval") self.logger.debug("network.gc.wait is ==> %s" % gc_wait) - self.logger.debug("network.gc.interval is ==> %s" % gc_wait) + self.logger.debug("network.gc.interval is ==> %s" % gc_interval) total_sleep = 120 if gc_wait and gc_interval: @@ -695,14 +743,14 @@ class TestVPCRedundancy(cloudstackTestCase): self.logger.debug("Ping to google.com from VM") result = str(ssh.execute(ssh_command)) - self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 packets received"))) + self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count(" 0% packet loss"))) except Exception as e: self.fail("SSH Access failed for %s: %s" % \ (vmObj.get_ip(), e) ) self.assertEqual( - result.count("3 packets received"), + result.count(" 0% packet loss"), 1, "Ping to outside world from VM should be successful" ) diff --git a/test/integration/smoke/test_vpc_router_nics.py b/test/integration/smoke/test_vpc_router_nics.py index cb0734d9930..39a92144438 100644 --- a/test/integration/smoke/test_vpc_router_nics.py +++ b/test/integration/smoke/test_vpc_router_nics.py @@ -464,14 +464,14 @@ class TestVPCNics(cloudstackTestCase): self.logger.debug("Ping to google.com from VM") result = str(ssh.execute(ssh_command)) - self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("3 packets received"))) + self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count(" 0% packet loss"))) except Exception as e: self.fail("SSH Access failed for %s: %s" % \ (vmObj.get_ip(), e) ) self.assertEqual( - result.count("3 packets received"), + result.count(" 0% packet loss"), 1, "Ping to outside world from VM should be successful" ) diff --git a/test/integration/smoke/test_vpc_vpn.py b/test/integration/smoke/test_vpc_vpn.py index af74e6f18f6..966f40d4071 100644 --- a/test/integration/smoke/test_vpc_vpn.py +++ b/test/integration/smoke/test_vpc_vpn.py @@ -222,7 +222,7 @@ class Services: "displaytext": "macchinina kvm", "format": "qcow2", "hypervisor": "kvm", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", "requireshvm": "True", }, @@ -232,7 +232,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "xen", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", "requireshvm": "True", }, @@ -242,7 +242,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "hyperv", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", "requireshvm": "True", }, @@ -252,8 +252,8 @@ class Services: "displaytext": "macchinina vmware", "format": "ova", "hypervisor": "vmware", - "ostype": "Other PV (64-bit)", - "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.vmdk.bz2", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", "requireshvm": "True", } } @@ -299,7 +299,7 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase): %s" % (cls.account.name, cls.account.id)) - cls.cleanup = [cls.template, cls.account, cls.compute_offering] + cls.cleanup = [cls.account, cls.compute_offering] return @attr(tags=["advanced"], required_hardware="true") @@ -316,10 +316,11 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase): networkOffering) > 0, "No VPC based network offering") # 1) Create VPC - vpcOffering = VpcOffering.list(self.apiclient, isdefault=True) + vpcOffering = VpcOffering.list(self.apiclient, name="Default VPC offering") self.assert_(vpcOffering is not None and len( vpcOffering) > 0, "No VPC offerings found") + vpc = None try: vpc = VPC.create( apiclient=self.apiclient, @@ -434,6 +435,9 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase): try: cls.logger.debug("Cleaning up resources") + try: + cls.template.delete(cls.apiclient) + except Exception: pass cleanup_resources(cls.apiclient, cls.cleanup) except Exception, e: raise Exception("Cleanup failed with %s" % e) @@ -478,7 +482,7 @@ class TestVpcSite2SiteVpn(cloudstackTestCase): %s" % (cls.account.name, cls.account.id)) - cls.cleanup = [cls.template, cls.account, cls.compute_offering] + cls.cleanup = [cls.account, cls.compute_offering] return def _get_ssh_client(self, virtual_machine, services, retries): @@ -797,6 +801,9 @@ class TestVpcSite2SiteVpn(cloudstackTestCase): @classmethod def tearDownClass(cls): try: + try: + cls.template.delete(cls.apiclient) + except Exception: pass cleanup_resources(cls.apiclient, cls.cleanup) except Exception, e: raise Exception("Cleanup failed with %s" % e) @@ -841,7 +848,7 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase): %s" % (cls.account.name, cls.account.id)) - cls.cleanup = [cls.template, cls.account, cls.compute_offering] + cls.cleanup = [cls.account, cls.compute_offering] return def _validate_vpc_offering(self, vpc_offering): @@ -1164,6 +1171,9 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase): @classmethod def tearDownClass(cls): try: + try: + cls.template.delete(cls.apiclient) + except Exception: pass cleanup_resources(cls.apiclient, cls.cleanup) except Exception, e: raise Exception("Cleanup failed with %s" % e) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 1be0a3c209d..681619b77e2 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -1325,43 +1325,45 @@ class Template: cmd.zoneid = zoneid apiclient.deleteTemplate(cmd) - def download(self, apiclient, timeout=5, interval=60): + def download(self, apiclient, retries=300, interval=5): """Download Template""" - # Sleep to ensure template is in proper state before download - time.sleep(interval) - - while True: + while retries > -1: + time.sleep(interval) template_response = Template.list( apiclient, id=self.id, zoneid=self.zoneid, templatefilter='self' ) - if isinstance(template_response, list): + if isinstance(template_response, list): template = template_response[0] + if not hasattr(template, 'status') or not template or not template.status: + retries = retries - 1 + continue + # If template is ready, # template.status = Download Complete # Downloading - x% Downloaded # Error - Any other string - if template.status == 'Download Complete': - break + if template.status == 'Download Complete' and template.isready: + return elif 'Downloaded' in template.status: - time.sleep(interval) + retries = retries - 1 + continue elif 'Installing' not in template.status: + if retries >= 0: + retries = retries - 1 + continue raise Exception( "Error in downloading template: status - %s" % template.status) - elif timeout == 0: - break - else: - time.sleep(interval) - timeout = timeout - 1 - return + retries = retries - 1 + raise Exception("Template download failed exception") def updatePermissions(self, apiclient, **kwargs): """Updates the template permissions""" @@ -1464,11 +1466,10 @@ class Iso: apiclient.deleteIso(cmd) return - def download(self, apiclient, timeout=5, interval=60): + def download(self, apiclient, retries=300, interval=5): """Download an ISO""" # Ensuring ISO is successfully downloaded - retry = 1 - while True: + while retries > -1: time.sleep(interval) cmd = listIsos.listIsosCmd() @@ -1477,26 +1478,25 @@ class Iso: if isinstance(iso_response, list): response = iso_response[0] - # Again initialize timeout to avoid listISO failure - timeout = 5 + if not hasattr(response, 'status') or not response or not response.status: + retries = retries - 1 + continue + # Check whether download is in progress(for Ex:10% Downloaded) # or ISO is 'Successfully Installed' - if response.status == 'Successfully Installed': + if response.status == 'Successfully Installed' and response.isready: return elif 'Downloaded' not in response.status and \ 'Installing' not in response.status: - if retry == 1: - retry = retry - 1 + if retries >= 0: + retries = retries - 1 continue raise Exception( "Error In Downloading ISO: ISO Status - %s" % response.status) - - elif timeout == 0: - raise Exception("ISO download Timeout Exception") else: - timeout = timeout - 1 - return + retries = retries - 1 + raise Exception("ISO download failed exception") @classmethod def extract(cls, apiclient, id, mode, zoneid=None): diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py index 5f738f4bf91..d1b872a953a 100644 --- a/tools/marvin/marvin/lib/common.py +++ b/tools/marvin/marvin/lib/common.py @@ -1056,6 +1056,8 @@ def setNonContiguousVlanIds(apiclient, zoneid): list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid for physical_network in list_physical_networks_response: + if not hasattr(physical_network, 'vlan'): + continue vlans = xsplit(physical_network.vlan, ['-', ','])