def setUpClass(cls):

        cls.testClient = super(TestVMPlacement, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(
                          cls.api_client,
                          zone_id=cls.zone.id)
        cls.template = get_template(
                                    cls.api_client,
                                    cls.zone.id,
                                    cls.services["ostype"]
                            )
        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"],
                                            offerha=True
                                            )
        cls._cleanup = [
                        cls.service_offering,
                        ]
        return
    def setUpClass(cls):
        cls.testClient = super(TestUploadDirectDownloadCertificates,
                               cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.dbclient = cls.testClient.getDbConnection()
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services = cls.testClient.getParsedTestDataConfig()

        cls._cleanup = []
        cls.hypervisorNotSupported = False
        if cls.hypervisor.lower() not in ['kvm', 'lxc']:
            cls.hypervisorNotSupported = True

        if not cls.hypervisorNotSupported:
            cls.certificates = {
                "expired":
                "MIIDSTCCAjECFDi8s70TWFhwVN9cj67RJoAF99c8MA0GCSqGSIb3DQEBCwUAMGExCzAJBgNVBAYTAkNTMQswCQYDVQQIDAJDUzELMAkGA1UEBwwCQ1MxCzAJBgNVBAoMAkNTMQswCQYDVQQLDAJDUzELMAkGA1UEAwwCQ1MxETAPBgkqhkiG9w0BCQEWAkNTMB4XDTE5MDQyNDE1NTQxM1oXDTE5MDQyMjE1NTQxM1owYTELMAkGA1UEBhMCQ1MxCzAJBgNVBAgMAkNTMQswCQYDVQQHDAJDUzELMAkGA1UECgwCQ1MxCzAJBgNVBAsMAkNTMQswCQYDVQQDDAJDUzERMA8GCSqGSIb3DQEJARYCQ1MwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrLS0XDBgqOvtoaI0TIxLropp1qdu8n2IQ1MPwo9NzCXvygjocLA6l/NkDSK/2zbS3RX9mSRFEHdPLCy5R3lMvcuWjnMbfUhsdo8aJajuDAS+wVt3ZJTtCL42hHwXhT+rnc/Go3lbq/4jz2W9hHXdM5V7h7w6M30IrL26biSJp01FcdEXglz9O+TwRr5akF1trhIbfhP8Nx/P9q62tyRVeiecXO+yskEqtrdftmVOzyYsv66aV3+a407zZusnX2oPP2r+5XILNp7XZCuJKAJpJkToQMDaJ5S+3A8SAvN3CjqjhYkF0sK9SIKC3+8wTWnyqE5Um/3r+mbdfAVxDCxqZAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAG/R9sJ2pFbu35MliIJIhWkwP7FeP/7gYCNvOXFt6vVGXmcOwuw9WGBxsmsGESQRB4+NnJFjyGQ1Ck+ps5XRRMizyvq6bCQxVuC5M+vYS4J0q8YoL0RJ20pN9iwTsosZjSEKmfUlVgsufqCG2nyusV71LSaQU6f/bylJcJkKwGUhThExh+PVLZ66H5cF4/SzuK6WzWnj5p6+YX8TP+qPUkXN1mapgVKfVMo6mqLsH+eLKH+zqdy5ZZ5znNSbJFgHufYbEFlutTaxHEvKNMEgMCFkFGiyPwRuD6oaPnZFquJLh/mBZOLogpxVD5v20AcUTANtbXSlPaqOnEQFcbiVCb8=",
                "invalid":
                "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "valid":
                "MIIDSzCCAjMCFDa0LoW+1O8/cEwCI0nIqfl8c1TLMA0GCSqGSIb3DQEBCwUAMGExCzAJBgNVBAYTAkNTMQswCQYDVQQIDAJDUzELMAkGA1UEBwwCQ1MxCzAJBgNVBAoMAkNTMQswCQYDVQQLDAJDUzELMAkGA1UEAwwCQ1MxETAPBgkqhkiG9w0BCQEWAkNTMCAXDTE5MDQyNDE1NTIzNVoYDzIwOTgwOTE1MTU1MjM1WjBhMQswCQYDVQQGEwJDUzELMAkGA1UECAwCQ1MxCzAJBgNVBAcMAkNTMQswCQYDVQQKDAJDUzELMAkGA1UECwwCQ1MxCzAJBgNVBAMMAkNTMREwDwYJKoZIhvcNAQkBFgJDUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKstLRcMGCo6+2hojRMjEuuimnWp27yfYhDUw/Cj03MJe/KCOhwsDqX82QNIr/bNtLdFf2ZJEUQd08sLLlHeUy9y5aOcxt9SGx2jxolqO4MBL7BW3dklO0IvjaEfBeFP6udz8ajeVur/iPPZb2Edd0zlXuHvDozfQisvbpuJImnTUVx0ReCXP075PBGvlqQXW2uEht+E/w3H8/2rra3JFV6J5xc77KyQSq2t1+2ZU7PJiy/rppXf5rjTvNm6ydfag8/av7lcgs2ntdkK4koAmkmROhAwNonlL7cDxIC83cKOqOFiQXSwr1IgoLf7zBNafKoTlSb/ev6Zt18BXEMLGpkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAVS5uWZRz2m3yx7EUQm47RTMW5WMXU4pI8D+N5WZ9xubYOqtU3r2OAYpfL/QO8iT7jcqNYGoDqe8ZjEaNvfxiTG8cOI6TSXhKBG6hjSaSFQSHOZ5mfstM36y/3ENFh6JCJ2ao1rgWSbfDRyAaHuvt6aCkaV6zRq2OMEgoJqZSgwxLQO230xa2hYgKXOePMVZyHFA2oKJtSOc3jCke9Y8zDUwm0McGdMRBD8tVB0rcaOqQ0PlDLjB9sQuhhLu8vjdgbznmPbUmMG7JN0yhT1eJbIX5ImXyh0DoTwiaGcYwW6SqYodjXACsC37xaQXAPYBiaAs4iI80TJSx1DVFO1LV0g=="
            }

        return
    def setUpClass(cls):

        cls.testClient = super(TestHighAvailability, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(
            cls.api_client,
            zone_id=cls.zone.id
        )
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['lxc']:
            raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
        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"],
            offerha=True
        )
        cls._cleanup = [
            cls.service_offering,
        ]
        return
    def setUpClass(cls):

        cls.testClient = super(TestVMPlacement, cls).getClsTestClient()
        if cls.testClient.getHypervisorInfo().lower() != "vmware":
            raise unittest.SkipTest("VMWare tests only valid on VMWare hypervisor")
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(
                          cls.api_client,
                          zone_id=cls.zone.id)
        cls.template = get_template(
                                    cls.api_client,
                                    cls.zone.id,
                                    cls.services["ostype"]
                            )
        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"],
                                            offerha=True
                                            )
        cls._cleanup = [
                        cls.service_offering,
                        ]
        return
Beispiel #5
0
    def setUpClass(cls):

        cls.testClient = super(TestHighAvailability, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, zone_id=cls.zone.id)
        cls.template = get_template(cls.api_client, cls.zone.id,
                                    cls.services["ostype"])
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['lxc']:
            raise unittest.SkipTest(
                "Template creation from root volume is not supported in LXC")
        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"], offerha=True)
        cls._cleanup = [
            cls.service_offering,
        ]
        return
Beispiel #6
0
    def setUpClass(cls):
        testClient = super(TestSnapshotRootDisk, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype

        cls.hypervisorNotSupported = False
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in [
                'hyperv', 'lxc'
        ] or 'kvm-centos6' in cls.testClient.getZoneForTests():
            cls.hypervisorNotSupported = True

        cls._cleanup = []
        if not cls.hypervisorNotSupported:
            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"] = cls.template.ostypeid
            cls.services["zoneid"] = cls.zone.id

            # Create VMs, NAT Rules etc
            cls.account = Account.create(cls.apiclient,
                                         cls.services["account"],
                                         domainid=cls.domain.id)
            cls.service_offering = ServiceOffering.create(
                cls.apiclient, cls.services["service_offerings"]["tiny"])
            cls.virtual_machine = cls.virtual_machine_with_disk = \
                VirtualMachine.create(
                    cls.apiclient,
                    cls.services["small"],
                    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.service_offering)
            cls._cleanup.append(cls.account)
            cls._cleanup.append(cls.template)
        return
Beispiel #7
0
    def setUpClass(cls):
        testClient = super(TestSnapshotRootDisk, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype

        cls.hypervisorNotSupported = False
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['hyperv', 'lxc'] or 'kvm-centos6' in cls.testClient.getZoneForTests():
            cls.hypervisorNotSupported = True

        cls._cleanup = []
        if not cls.hypervisorNotSupported:
            cls.template = get_test_template(cls.apiclient, cls.zone.id, cls.hypervisor)
            if cls.template == FAILED:
                assert False, "get_test_template() failed to return template"

            cls.services["domainid"] = cls.domain.id
            cls.services["small"]["zoneid"] = cls.zone.id
            cls.services["templates"]["ostypeid"] = cls.template.ostypeid
            cls.services["zoneid"] = cls.zone.id

            # Create VMs, NAT Rules etc
            cls.account = Account.create(
                cls.apiclient,
                cls.services["account"],
                domainid=cls.domain.id
            )
            cls.service_offering = ServiceOffering.create(
                cls.apiclient,
                cls.services["service_offerings"]["tiny"]
            )
            cls.disk_offering = DiskOffering.create(
                cls.apiclient,
                cls.services["disk_offering"]
            )
            cls.virtual_machine = cls.virtual_machine_with_disk = \
                VirtualMachine.create(
                    cls.apiclient,
                    cls.services["small"],
                    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.service_offering)
            cls._cleanup.append(cls.account)
            cls._cleanup.append(cls.disk_offering)
        return
Beispiel #8
0
    def setUpClass(cls):
        cls.testClient = super(TestAttachVolumeISO, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.api_client, storagetype='rbd'):
                raise unittest.SkipTest(
                    "RBD storage type is required for data volumes for LXC")
        cls.disk_offering = DiskOffering.create(cls.api_client,
                                                cls.services["disk_offering"])
        template = get_template(cls.api_client, cls.zone.id,
                                cls.services["ostype"])
        cls.services["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["iso"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = template.id
        # get max data volumes limit based on the hypervisor type and version
        listHost = Host.list(
            cls.api_client,
            type='Routing',
            zoneid=cls.zone.id,
            podid=cls.pod.id,
        )
        ver = listHost[0].hypervisorversion
        hv = listHost[0].hypervisor
        cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
        cmd.hypervisor = hv
        res = cls.api_client.listHypervisorCapabilities(cmd)
        cls.debug('Hypervisor Capabilities: {}'.format(res))
        for i in range(len(res)):
            if res[i].hypervisorversion == ver:
                break
        cls.max_data_volumes = int(res[i].maxdatavolumeslimit)
        cls.debug('max data volumes:{}'.format(cls.max_data_volumes))
        cls.services["volume"]["max"] = cls.max_data_volumes
        # Create VMs, NAT Rules etc
        cls.account = Account.create(cls.api_client,
                                     cls.services["account"],
                                     domainid=cls.domain.id)

        cls.service_offering = ServiceOffering.create(
            cls.api_client, cls.services["service_offering"])
        cls.virtual_machine = VirtualMachine.create(
            cls.api_client,
            cls.services["virtual_machine"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
        )
        cls._cleanup = [cls.service_offering, cls.disk_offering, cls.account]
Beispiel #9
0
    def test_10_list_volumes(self):
        """
        # Validate the following
        #
        # 1. List Root Volume and waits until it has the newly introduced attributes
        #
        # 2. Verifies return attributes has values different from none, when instance is running
        #
        """

        list_vm = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)[0]

        host = Host.list(
            self.apiclient,
            type='Routing',
            id=list_vm.hostid
        )[0]
        list_pods = get_pod(self.apiclient, self.zone.id, host.podid)

        root_volume = self.wait_for_attributes_and_return_root_vol()

        self.assertTrue(hasattr(root_volume, "utilization"))
        self.assertTrue(root_volume.utilization is not None)

        self.assertTrue(hasattr(root_volume, "virtualsize"))
        self.assertTrue(root_volume.virtualsize is not None)

        self.assertTrue(hasattr(root_volume, "physicalsize"))
        self.assertTrue(root_volume.physicalsize is not None)

        self.assertTrue(hasattr(root_volume, "vmname"))
        self.assertEqual(root_volume.vmname, list_vm.name)

        self.assertTrue(hasattr(root_volume, "clustername"))
        self.assertTrue(root_volume.clustername is not None)

        self.assertTrue(hasattr(root_volume, "clusterid"))
        self.assertTrue(root_volume.clusterid is not None)

        self.assertTrue(hasattr(root_volume, "storageid"))
        self.assertTrue(root_volume.storageid is not None)

        self.assertTrue(hasattr(root_volume, "storage"))
        self.assertTrue(root_volume.storage is not None)

        self.assertTrue(hasattr(root_volume, "zoneid"))
        self.assertEqual(root_volume.zoneid, self.zone.id)

        self.assertTrue(hasattr(root_volume, "zonename"))
        self.assertEqual(root_volume.zonename, self.zone.name)

        self.assertTrue(hasattr(root_volume, "podid"))
        self.assertEqual(root_volume.podid, list_pods.id)

        self.assertTrue(hasattr(root_volume, "podname"))
        self.assertEqual(root_volume.podname, list_pods.name)
Beispiel #10
0
    def setUpClass(cls):
        cls.testClient = super(TestAttachDetachVolume, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype
        cls._cleanup = []
        cls.unsupportedStorageType = False
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.disk_offering = DiskOffering.create(cls.api_client,
                                                cls.services["disk_offering"])
        cls._cleanup.append(cls.disk_offering)
        template = get_template(cls.api_client, cls.zone.id,
                                cls.services["ostype"])
        cls.services["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = template.id
        # get max data volumes limit based on the hypervisor type and version
        listHost = Host.list(
            cls.api_client,
            type='Routing',
            zoneid=cls.zone.id,
            podid=cls.pod.id,
        )
        ver = listHost[0].hypervisorversion
        hv = listHost[0].hypervisor
        cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
        cmd.hypervisor = hv  # cls.services["virtual_machine"]["hypervisor"]
        res = cls.api_client.listHypervisorCapabilities(cmd)
        cls.debug('Hypervisor Capabilities: {}'.format(res))
        for i in range(len(res)):
            if res[i].hypervisorversion == ver:
                break
        cls.max_data_volumes = int(res[i].maxdatavolumeslimit)
        cls.debug('max data volumes:{}'.format(cls.max_data_volumes))
        cls.services["volume"]["max"] = cls.max_data_volumes
        # Create VMs, NAT Rules etc
        cls.account = Account.create(cls.api_client,
                                     cls.services["account"],
                                     domainid=cls.domain.id)
        cls._cleanup.append(cls.account)

        cls.service_offering = ServiceOffering.create(
            cls.api_client, cls.services["service_offering"])
        cls._cleanup.append(cls.service_offering)
        cls.virtual_machine = VirtualMachine.create(
            cls.api_client,
            cls.services["virtual_machine"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
        )
Beispiel #11
0
    def test_10_list_volumes(self):

        # Validate the following
        #
        # 1. List Root Volume and waits until it has the newly introduced attributes
        #
        # 2. Verifies return attributes has values different from none, when instance is running
        #

        list_vm = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)[0]

        host = Host.list(
            self.apiclient,
            type='Routing',
            id=list_vm.hostid
        )[0]
        list_pods = get_pod(self.apiclient, self.zone.id, host.podid)

        root_volume = self.wait_for_attributes_and_return_root_vol()

        self.assertTrue(hasattr(root_volume, "utilization"))
        self.assertTrue(root_volume.utilization is not None)

        self.assertTrue(hasattr(root_volume, "virtualsize"))
        self.assertTrue(root_volume.virtualsize is not None)

        self.assertTrue(hasattr(root_volume, "physicalsize"))
        self.assertTrue(root_volume.physicalsize is not None)

        self.assertTrue(hasattr(root_volume, "vmname"))
        self.assertEqual(root_volume.vmname, list_vm.name)

        self.assertTrue(hasattr(root_volume, "clustername"))
        self.assertTrue(root_volume.clustername is not None)

        self.assertTrue(hasattr(root_volume, "clusterid"))
        self.assertTrue(root_volume.clusterid is not None)

        self.assertTrue(hasattr(root_volume, "storageid"))
        self.assertTrue(root_volume.storageid is not None)

        self.assertTrue(hasattr(root_volume, "storage"))
        self.assertTrue(root_volume.storage is not None)

        self.assertTrue(hasattr(root_volume, "zoneid"))
        self.assertEqual(root_volume.zoneid, self.zone.id)

        self.assertTrue(hasattr(root_volume, "zonename"))
        self.assertEqual(root_volume.zonename, self.zone.name)

        self.assertTrue(hasattr(root_volume, "podid"))
        self.assertEqual(root_volume.podid, list_pods.id)

        self.assertTrue(hasattr(root_volume, "podname"))
        self.assertEqual(root_volume.podname, list_pods.name)
Beispiel #12
0
    def setUpClass(cls):
        cls.testClient = super(TestHosts, cls).getClsTestClient()
        cls.testdata = cls.testClient.getParsedTestDataConfig()
        cls.apiclient = cls.testClient.getApiClient()
        cls.dbclient = cls.testClient.getDbConnection()
        cls._cleanup = []

        # get zone, domain etc
        cls.zone = Zone(get_zone(cls.apiclient, cls.testClient.getZoneForTests()).__dict__)
        cls.domain = get_domain(cls.apiclient)
        cls.pod = get_pod(cls.apiclient, cls.zone.id)

        cls.logger = logging.getLogger('TestHosts')
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

        cls.storage_pool_db_id = None
        # list hosts
        hosts = list_hosts(cls.apiclient, type="Routing")
        i = 0
        while (i < len(hosts)):
            host_id = hosts[i].id
            cls.logger.debug("Trying host id : %s" % host_id)
            host_db_id = cls.dbclient.execute(
                "select id from host where uuid='%s';" %
                host_id)

            if host_db_id and host_db_id[0]:
                cls.logger.debug("found host db id : %s" % host_db_id)
                storage_pool_db_id = cls.dbclient.execute(
                    "select id from storage_pool where id='%s' and removed is null;" %
                    host_db_id[0][0])

                if storage_pool_db_id and storage_pool_db_id[0]:
                    cls.logger.debug("Found storage_pool_db_id  : %s" % storage_pool_db_id[0][0])
                    capacity_state = cls.dbclient.execute(
                        "select count(capacity_state) from op_host_capacity where host_id='%s' and capacity_type in (0,1,3) and capacity_state = 'Enabled'" %
                        host_db_id[0][0])

                    if capacity_state and capacity_state[0]:
                        cls.logger.debug("Check capacity count  : %s" % capacity_state[0][0])

                        if capacity_state[0][0] == 3:
                            cls.logger.debug("found host id : %s, can be used for this test" % host_id)
                            cls.my_host_id = host_id
                            cls.host_db_id = host_db_id
                            cls.storage_pool_db_id = storage_pool_db_id
                            break
            if not cls.storage_pool_db_id:
                i = i + 1


        if cls.storage_pool_db_id is None:
            raise unittest.SkipTest("There is no host and storage pool available in the setup to run this test")
Beispiel #13
0
 def setUp(self):
     self.logger = logging.getLogger('TestHM')
     self.stream_handler = logging.StreamHandler()
     self.logger.setLevel(logging.DEBUG)
     self.logger.addHandler(self.stream_handler)
     self.apiclient = self.testClient.getApiClient()
     self.hypervisor = self.testClient.getHypervisorInfo()
     self.dbclient = self.testClient.getDbConnection()
     self.services = self.testClient.getParsedTestDataConfig()
     self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
     self.pod = get_pod(self.apiclient, self.zone.id)
     self.cleanup = []
    def setUpClass(cls):
        cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.services["zoneid"] = cls.zone.id
        cls._cleanup = []
        return
    def setUpClass(cls):
        cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.services["zoneid"] = cls.zone.id
        cls._cleanup = []
        return
    def setUpClass(cls):
        cls.testClient = super(TestHosts, cls).getClsTestClient()
        cls.testdata = cls.testClient.getParsedTestDataConfig()
        cls.apiclient = cls.testClient.getApiClient()
        cls.dbclient = cls.testClient.getDbConnection()
        cls._cleanup = []

        # get zone, domain etc
        cls.zone = Zone(get_zone(cls.apiclient, cls.testClient.getZoneForTests()).__dict__)
        cls.domain = get_domain(cls.apiclient)
        cls.pod = get_pod(cls.apiclient, cls.zone.id)

        cls.logger = logging.getLogger("TestHosts")
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

        cls.storage_pool_db_id = None
        # list hosts
        hosts = list_hosts(cls.apiclient, type="Routing")
        i = 0
        while i < len(hosts):
            host_id = hosts[i].id
            cls.logger.debug("Trying host id : %s" % host_id)
            host_db_id = cls.dbclient.execute("select id from host where uuid='%s';" % host_id)

            if host_db_id and host_db_id[0]:
                cls.logger.debug("found host db id : %s" % host_db_id)
                storage_pool_db_id = cls.dbclient.execute(
                    "select id from storage_pool where id='%s' and removed is null;" % host_db_id[0][0]
                )

                if storage_pool_db_id and storage_pool_db_id[0]:
                    cls.logger.debug("Found storage_pool_db_id  : %s" % storage_pool_db_id[0][0])
                    capacity_state = cls.dbclient.execute(
                        "select count(capacity_state) from op_host_capacity where host_id='%s' and capacity_type in (0,1,3) and capacity_state = 'Enabled'"
                        % host_db_id[0][0]
                    )

                    if capacity_state and capacity_state[0]:
                        cls.logger.debug("Check capacity count  : %s" % capacity_state[0][0])

                        if capacity_state[0][0] == 3:
                            cls.logger.debug("found host id : %s, can be used for this test" % host_id)
                            cls.my_host_id = host_id
                            cls.host_db_id = host_db_id
                            cls.storage_pool_db_id = storage_pool_db_id
                            break
            if not cls.storage_pool_db_id:
                i = i + 1

        if cls.storage_pool_db_id is None:
            raise unittest.SkipTest("There is no host and storage pool available in the setup to run this test")
Beispiel #17
0
    def setUpClass(cls):
        try:
            cls._cleanup = []
            cls.testClient = super(Test42xBugsMgmtSvr, cls).getClsTestClient()
            cls.apiClient = cls.api_client = cls.testClient.getApiClient()
            cls.services = cls.testClient.getParsedTestDataConfig()
            cls.hypervisor = cls.testClient.getHypervisorInfo()
            # Get Domain, Zone, Template
            cls.domain = get_domain(cls.api_client)
            cls.zone = get_zone(cls.api_client,
                                cls.testClient.getZoneForTests())
            cls.pod = get_pod(cls.apiClient, zone_id=cls.zone.id)
            cls.template = get_template(
                cls.api_client,
                cls.zone.id,
                cls.services["ostype"]
            )

            cls.services['mode'] = cls.zone.networktype
            cls.services["hypervisor"] = cls.testClient.getHypervisorInfo()
            # Creating Disk offering, Service Offering and Account
            cls.service_offering = ServiceOffering.create(
                cls.apiClient,
                cls.services["service_offerings"]
            )
            cls.account = Account.create(
                cls.api_client,
                cls.services["account"],
                domainid=cls.domain.id
            )
            # Create account
            cls.account_2 = Account.create(
                cls.api_client,
                cls.services["account2"],
                domainid=cls.domain.id
            )

            # Getting authentication for user in newly created Account
            cls.user = cls.account.user[0]
            cls.userapiclient = cls.testClient.getUserApiClient(
                cls.user.username,
                cls.domain.name
            )
            # add objects created in setUpCls to the _cleanup list
            cls._cleanup = [cls.account,
                            cls.account_2,
                            cls.service_offering]

        except Exception as e:
            cls.tearDownClass()
            raise Exception("Warning: Exception in setup : %s" % e)
        return
    def setUpClass(cls):
        cls.testClient = super(TestHostMaintenanceAgents,
                               cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.dbclient = cls.testClient.getDbConnection()
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services = cls.testClient.getParsedTestDataConfig()

        cls.logger = logging.getLogger('TestHMAgents')
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

        cls._cleanup = []
        cls.hypervisorNotSupported = False
        if cls.hypervisor.lower() not in ['kvm', 'lxc']:
            cls.hypervisorNotSupported = True

        if not cls.hypervisorNotSupported:
            cls.initialsshvalue = cls.is_ssh_enabled()

            cls.template = get_suitable_test_template(cls.apiclient,
                                                      cls.zone.id, None,
                                                      cls.hypervisor)
            if cls.template == FAILED:
                assert False, "get_suitable_test_template() failed to return template"

            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["virtual_machine"]["template"] = cls.template.id
            cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor
            cls.service_offering = ServiceOffering.create(
                cls.apiclient, cls.services["service_offerings"]["tiny"])
            cls._cleanup.append(cls.service_offering)
            cls.network_offering = NetworkOffering.create(
                cls.apiclient,
                cls.services["l2-network_offering"],
            )
            cls.network_offering.update(cls.apiclient, state='Enabled')
            cls.services["network"][
                "networkoffering"] = cls.network_offering.id
            cls.l2_network = Network.create(
                cls.apiclient,
                cls.services["l2-network"],
                zoneid=cls.zone.id,
                networkofferingid=cls.network_offering.id)
            cls._cleanup.append(cls.l2_network)
            cls._cleanup.append(cls.network_offering)

        cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][
            0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__
Beispiel #19
0
    def setUpClass(cls):
        try:
            cls._cleanup = []
            cls.testClient = super(Test42xBugsMgmtSvr, cls).getClsTestClient()
            cls.apiClient = cls.api_client = cls.testClient.getApiClient()
            cls.services = cls.testClient.getParsedTestDataConfig()
            cls.hypervisor = cls.testClient.getHypervisorInfo()
            # Get Domain, Zone, Template
            cls.domain = get_domain(cls.api_client)
            cls.zone = get_zone(cls.api_client,
                                cls.testClient.getZoneForTests())
            cls.pod = get_pod(cls.apiClient, zone_id=cls.zone.id)
            cls.template = get_template(
                cls.api_client,
                cls.zone.id,
                cls.services["ostype"]
            )

            cls.services['mode'] = cls.zone.networktype
            cls.services["hypervisor"] = cls.testClient.getHypervisorInfo()
            # Creating Disk offering, Service Offering and Account
            cls.service_offering = ServiceOffering.create(
                cls.apiClient,
                cls.services["service_offerings"]["tiny"]
            )
            cls.account = Account.create(
                cls.api_client,
                cls.services["account"],
                domainid=cls.domain.id
            )
            # Create account
            cls.account_2 = Account.create(
                cls.api_client,
                cls.services["account2"],
                domainid=cls.domain.id
            )

            # Getting authentication for user in newly created Account
            cls.user = cls.account.user[0]
            cls.userapiclient = cls.testClient.getUserApiClient(
                cls.user.username,
                cls.domain.name
            )
            # add objects created in setUpCls to the _cleanup list
            cls._cleanup = [cls.account,
                            cls.account_2,
                            cls.service_offering]

        except Exception as e:
            cls.tearDownClass()
            raise Exception("Warning: Exception in setup : %s" % e)
        return
Beispiel #20
0
    def setUpClass(cls):
        cls.testClient = super(TestAttachVolumeISO, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.services["mode"] = cls.zone.networktype
        cls._cleanup = []
        cls.unsupportedStorageType = False
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() == "lxc":
            if not find_storage_pool_type(cls.api_client, storagetype="rbd"):
                cls.unsupportedStorageType = True
                return
        cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"])
        cls._cleanup.append(cls.disk_offering)
        template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
        cls.services["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["iso"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = template.id
        # get max data volumes limit based on the hypervisor type and version
        listHost = Host.list(cls.api_client, type="Routing", zoneid=cls.zone.id, podid=cls.pod.id)
        ver = listHost[0].hypervisorversion
        hv = listHost[0].hypervisor
        cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
        cmd.hypervisor = hv
        res = cls.api_client.listHypervisorCapabilities(cmd)
        cls.debug("Hypervisor Capabilities: {}".format(res))
        for i in range(len(res)):
            if res[i].hypervisorversion == ver:
                break
        cls.max_data_volumes = int(res[i].maxdatavolumeslimit)
        cls.debug("max data volumes:{}".format(cls.max_data_volumes))
        cls.services["volume"]["max"] = cls.max_data_volumes
        # Create VMs, NAT Rules etc
        cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
        cls._cleanup.append(cls.account)

        cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
        cls._cleanup.append(cls.service_offering)
        cls.virtual_machine = VirtualMachine.create(
            cls.api_client,
            cls.services["virtual_machine"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
        )
    def setUpClass(cls):
        testClient = super(TestDisableEnableHost, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.hypervisor = cls.testClient.getHypervisorInfo()

        cls.snapshotSupported = True

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, zone_id=cls.zone.id)

        hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing")
        clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid)
        cls.host = Host(hostList[0].__dict__)
        cls.cluster = Cluster(clusterList[0].__dict__)

        cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"])

        cls._cleanup = []
        cls.disabledHosts = []

        try:
            cls.service_offering = ServiceOffering.create(cls.apiclient, cls.testdata["service_offering"])
            cls._cleanup.append(cls.service_offering)

            cls.disk_offering = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
            cls._cleanup.append(cls.disk_offering)

            # Create an account
            cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id)
            cls._cleanup.append(cls.account)

            # Create root admin account

            cls.admin_account = Account.create(cls.apiclient, cls.testdata["account2"], admin=True)
            cls._cleanup.append(cls.admin_account)

            # Create user api client of the account
            cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain)

        except Exception as e:
            cls.tearDownClass()
            raise e
        return
    def setUpClass(cls):
        cls.testClient = super(TestDirectDownloadTemplates,
                               cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.dbclient = cls.testClient.getDbConnection()
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services = cls.testClient.getParsedTestDataConfig()

        cls._cleanup = []
        cls.hypervisorNotSupported = False
        if cls.hypervisor.lower() not in ['kvm', 'lxc']:
            cls.hypervisorNotSupported = True

        if not cls.hypervisorNotSupported:
            cls.services["test_templates"]["kvm"]["directdownload"] = "true"
            cls.template = Template.register(
                cls.apiclient,
                cls.services["test_templates"]["kvm"],
                zoneid=cls.zone.id,
                hypervisor=cls.hypervisor)
            cls._cleanup.append(cls.template)

            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["virtual_machine"]["template"] = cls.template.id
            cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor
            cls.service_offering = ServiceOffering.create(
                cls.apiclient, cls.services["service_offerings"]["tiny"])
            cls._cleanup.append(cls.service_offering)
            cls.network_offering = NetworkOffering.create(
                cls.apiclient,
                cls.services["l2-network_offering"],
            )
            cls.network_offering.update(cls.apiclient, state='Enabled')
            cls.services["network"][
                "networkoffering"] = cls.network_offering.id
            cls.l2_network = Network.create(
                cls.apiclient,
                cls.services["l2-network"],
                zoneid=cls.zone.id,
                networkofferingid=cls.network_offering.id)
            cls._cleanup.append(cls.l2_network)
            cls._cleanup.append(cls.network_offering)
        return
    def setUpClass(cls):
        cls.testClient = super(TestHosts, cls).getClsTestClient()
        cls.testdata = cls.testClient.getParsedTestDataConfig()
        cls.apiclient = cls.testClient.getApiClient()
        cls.dbclient = cls.testClient.getDbConnection()
        cls._cleanup = []

        #get zone, domain etc
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.domain = get_domain(cls.apiclient)
        cls.pod = get_pod(cls.apiclient, cls.zone.id)

        # list hosts
        hosts = list_hosts(cls.apiclient)
        if len(hosts) > 0 :
                            cls.my_host_id = hosts[0].id
                            cls.host_db_id = cls.dbclient.execute("select id from host where uuid='%s';" % cls.my_host_id)
                            cls.my_cluster_id = hosts[0].clusterid
        else :
            raise unittest.SkipTest("There is no host available in the setup")
    def setUpClass(cls):
        cls.testClient = super(TestHosts, cls).getClsTestClient()
        cls.testdata = cls.testClient.getParsedTestDataConfig()
        cls.apiclient = cls.testClient.getApiClient()
        cls.dbclient = cls.testClient.getDbConnection()
        cls._cleanup = []

        #get zone, domain etc
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.domain = get_domain(cls.apiclient)
        cls.pod = get_pod(cls.apiclient, cls.zone.id)

        # list hosts
        hosts = list_hosts(cls.apiclient)
        if len(hosts) > 0:
            cls.my_host_id = hosts[0].id
            cls.host_db_id = cls.dbclient.execute(
                "select id from host where uuid='%s';" % cls.my_host_id)
            cls.my_cluster_id = hosts[0].clusterid
        else:
            raise unittest.SkipTest("There is no host available in the setup")
Beispiel #25
0
    def setUpClass(cls):
        cls.logger = logging.getLogger('TestDeployVirtioSCSIVM')
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

        testClient = super(TestDeployVirtioSCSIVM, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = cls.testClient.getParsedTestDataConfig()

        cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][
            0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__
        cls.hypervisorNotSupported = False
        cls.hypervisor = testClient.getHypervisorInfo()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype
        cls._cleanup = []
        if cls.hypervisor.lower() not in ['kvm']:
            cls.hypervisorNotSupported = True
            return
        kvmvirtioscsi = Templates().templates["kvmvirtioscsi"]
        cls.template = Template.register(cls.apiclient,
                                         kvmvirtioscsi[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["zoneid"] = cls.zone.id
        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     domainid=cls.domain.id)

        cls.service_offering = ServiceOffering.create(
            cls.apiclient, cls.services["service_offerings"]["small"])

        cls.sparse_disk_offering = DiskOffering.create(
            cls.apiclient, cls.services["sparse_disk_offering"])

        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            zoneid=cls.zone.id,
            serviceofferingid=cls.service_offering.id,
            diskofferingid=cls.sparse_disk_offering.id,
            mode=cls.zone.networktype)

        hosts = Host.list(cls.apiclient, id=cls.virtual_machine.hostid)
        if len(hosts) != 1:
            assert False, "Could not find host with id " + cls.virtual_machine.hostid

        cls.vmhost = hosts[0]

        password = cls.virtual_machine.resetPassword(cls.apiclient)
        cls.virtual_machine.username = "******"
        cls.virtual_machine.password = password
        cls._cleanup = [
            cls.template, cls.service_offering, cls.sparse_disk_offering,
            cls.account
        ]
    def setUpClass(cls):
        cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.dbclient = cls.testClient.getDbConnection()

        cls.testdata = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.testdata['mode'] = cls.zone.networktype
        cls.testdata["domainid"] = cls.domain.id
        cls.testdata["zoneid"] = cls.zone.id
        cls.account = Account.create(cls.api_client,
                                     cls.testdata["account"],
                                     domainid=cls.domain.id)
        cls.testdata["account"] = cls.account.name
        cls.disk_offering = DiskOffering.create(cls.api_client,
                                                cls.testdata["disk_offering"])
        cls.service_offering = ServiceOffering.create(
            cls.api_client, cls.testdata["service_offering"])
        cls.template = get_template(cls.api_client, cls.zone.id,
                                    cls.testdata["ostype"])
        cls.testdata["diskoffering"] = cls.disk_offering.id
        cls.dc_id = cls.dbclient.execute(
            "select id from data_center where uuid = '%s';" %
            str(cls.testdata["zoneid"]))
        cls.dc_id = cls.dc_id[0][0]
        cls.ids = cls.dbclient.execute(
            "select id from user_ip_address where allocated is null and data_center_id = '%s';"
            % str(cls.dc_id))
        cls.id_list = []
        for i in range(len(cls.ids)):
            cls.id_list.append(cls.ids[i][0])
        # Check if VR is already present in the setup
        vr_list = Router.list(cls.api_client, listall='true')
        cls.debug("vr list {}".format(vr_list))
        if isinstance(vr_list, list) and len(vr_list) > 0:
            cls.debug("VR is running in the setup")
            cls.vr_state = True
        else:
            cls.debug("VR is not present in the setup")
            cls.vr_state = False
            cls.id_list = cls.id_list[:-2]
        for id in cls.id_list:
            cls.dbclient.execute(
                "update user_ip_address set allocated=now() where id = '%s';" %
                str(id))
        # create new vlan ip range
        # Before creating ip range check the zone's network type
        if cls.zone.networktype.lower() == 'basic':
            cls.new_vlan = cls.createNewVlanRange()
        else:
            raise unittest.SkipTest(
                "These tests can be run only on basic zone.\
                        So skipping the tests")
        # Deploy vm in existing subnet if VR is not present
        if cls.vr_state is False:
            cls.vm_res = VirtualMachine.create(
                cls.api_client,
                cls.testdata["small"],
                templateid=cls.template.id,
                accountid=cls.account.name,
                domainid=cls.testdata["domainid"],
                zoneid=cls.testdata["zoneid"],
                serviceofferingid=cls.service_offering.id,
                mode=cls.testdata["mode"],
            )
        cls._cleanup = [
            cls.new_vlan,
            cls.account,
        ]
        return
    def setUpClass(cls):
        cls.logger = logging.getLogger('TestDeployVirtioSCSIVM')
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

        testClient = super(TestDeployVirtioSCSIVM, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = cls.testClient.getParsedTestDataConfig()

        cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__
        cls.hypervisorNotSupported = False
        cls.hypervisor = testClient.getHypervisorInfo()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype
        if cls.hypervisor.lower() not in ['kvm']:
            cls.hypervisorNotSupported = True
            return
        kvmvirtioscsi = Templates().templates["kvmvirtioscsi"]
        cls.template = Template.register(
            cls.apiclient,
            kvmvirtioscsi[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["zoneid"] = cls.zone.id
        cls.account = Account.create(
            cls.apiclient,
            cls.services["account"],
            domainid=cls.domain.id
        )

        cls.service_offering = ServiceOffering.create(
            cls.apiclient,
            cls.services["service_offerings"]["small"]
        )

        cls.sparse_disk_offering = DiskOffering.create(
            cls.apiclient,
            cls.services["sparse_disk_offering"]
        )

        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            zoneid=cls.zone.id,
            serviceofferingid=cls.service_offering.id,
            diskofferingid=cls.sparse_disk_offering.id,
            mode=cls.zone.networktype
        )

        hosts = Host.list(cls.apiclient, id=cls.virtual_machine.hostid)
        if len(hosts) != 1:
            assert False, "Could not find host with id " + cls.virtual_machine.hostid

        cls.vmhost = hosts[0]

        # Stop VM to reset password
        cls.virtual_machine.stop(cls.apiclient)

        password = cls.virtual_machine.resetPassword(cls.apiclient)
        cls.virtual_machine.username = "******"
        cls.virtual_machine.password = password

        # Start VM after password reset
        cls.virtual_machine.start(cls.apiclient)

        cls.cleanup = [
            cls.template,
            cls.service_offering,
            cls.sparse_disk_offering,
            cls.account
        ]
    def setUpClass(cls):
        cls.testClient = super(TestDirectDownloadTemplates, cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.dbclient = cls.testClient.getDbConnection()
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services = cls.testClient.getParsedTestDataConfig()

        cls._cleanup = []
        cls.hypervisorSupported = False
        cls.nfsStorageFound = False
        cls.localStorageFound = False
        cls.sharedMountPointFound = False

        if cls.hypervisor.lower() in ['kvm', 'lxc']:
            cls.hypervisorSupported = True

        if cls.hypervisorSupported:
            cls.services["test_templates"]["kvm"]["directdownload"] = "true"
            cls.template = Template.register(cls.apiclient, cls.services["test_templates"]["kvm"],
                              zoneid=cls.zone.id, hypervisor=cls.hypervisor)
            cls._cleanup.append(cls.template)

            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["virtual_machine"]["template"] = cls.template.id
            cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor
            cls.service_offering = ServiceOffering.create(
                cls.apiclient,
                cls.services["service_offerings"]["tiny"]
            )
            cls._cleanup.append(cls.service_offering)
            cls.network_offering = NetworkOffering.create(
                cls.apiclient,
                cls.services["l2-network_offering"],
            )
            cls.network_offering.update(cls.apiclient, state='Enabled')
            cls.services["network"]["networkoffering"] = cls.network_offering.id
            cls.l2_network = Network.create(
                cls.apiclient,
                cls.services["l2-network"],
                zoneid=cls.zone.id,
                networkofferingid=cls.network_offering.id
            )
            cls._cleanup.append(cls.l2_network)
            cls._cleanup.append(cls.network_offering)

            storage_pools = StoragePool.list(
                cls.apiclient,
                zoneid=cls.zone.id
            )
            for pool in storage_pools:
                if not cls.nfsStorageFound and pool.type == "NetworkFilesystem":
                    cls.nfsStorageFound = True
                    cls.nfsPoolId = pool.id
                elif not cls.localStorageFound and pool.type == "Filesystem":
                    cls.localStorageFound = True
                    cls.localPoolId = pool.id
                elif not cls.sharedMountPointFound and pool.type == "SharedMountPoint":
                    cls.sharedMountPointFound = True
                    cls.sharedPoolId = pool.id

        cls.nfsKvmNotAvailable = not cls.hypervisorSupported or not cls.nfsStorageFound
        cls.localStorageKvmNotAvailable = not cls.hypervisorSupported or not cls.localStorageFound
        cls.sharedMountPointKvmNotAvailable = not cls.hypervisorSupported or not cls.sharedMountPointFound
        return
Beispiel #29
0
    def setUpClass(cls):
        cls.testClient = super(TestAttachVolumeISO, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.api_client, storagetype='rbd'):
                raise unittest.SkipTest("RBD storage type is required for data volumes for LXC")
        cls.disk_offering = DiskOffering.create(
            cls.api_client,
            cls.services["disk_offering"]
        )
        template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )
        cls.services["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["iso"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = template.id
        # get max data volumes limit based on the hypervisor type and version
        listHost = Host.list(
            cls.api_client,
            type='Routing',
            zoneid=cls.zone.id,
            podid=cls.pod.id,
        )
        ver = listHost[0].hypervisorversion
        hv = listHost[0].hypervisor
        cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
        cmd.hypervisor = hv
        res = cls.api_client.listHypervisorCapabilities(cmd)
        cls.debug('Hypervisor Capabilities: {}'.format(res))
        for i in range(len(res)):
            if res[i].hypervisorversion == ver:
                break
        cls.max_data_volumes = int(res[i].maxdatavolumeslimit)
        cls.debug('max data volumes:{}'.format(cls.max_data_volumes))
        cls.services["volume"]["max"] = cls.max_data_volumes
        # Create VMs, NAT Rules etc
        cls.account = Account.create(
            cls.api_client,
            cls.services["account"],
            domainid=cls.domain.id
        )

        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.services["service_offering"]
        )
        cls.virtual_machine = VirtualMachine.create(
            cls.api_client,
            cls.services["virtual_machine"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
        )
        cls._cleanup = [
            cls.service_offering,
            cls.disk_offering,
            cls.account
        ]
    def setUpClass(cls):
        cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.dbclient = cls.testClient.getDbConnection()

        cls.testdata = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(cls.api_client, cls.zone.id)
        cls.testdata['mode'] = cls.zone.networktype
        cls.testdata["domainid"] = cls.domain.id
        cls.testdata["zoneid"] = cls.zone.id
        cls.account = Account.create(
            cls.api_client,
            cls.testdata["account"],
            domainid=cls.domain.id
        )
        cls.testdata["account"] = cls.account.name
        cls.disk_offering = DiskOffering.create(
            cls.api_client,
            cls.testdata["disk_offering"]
        )
        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.testdata["service_offering"]
        )
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.testdata["ostype"]
        )
        cls.testdata["diskoffering"] = cls.disk_offering.id
        cls.dc_id = cls.dbclient.execute(
            "select id from data_center where uuid = '%s';" % str(
                cls.testdata["zoneid"]))
        cls.dc_id = cls.dc_id[0][0]
        cls.ids = cls.dbclient.execute(
            "select id from user_ip_address where allocated is null and data_center_id = '%s';" % str(
                cls.dc_id))
        cls.id_list = []
        for i in range(len(cls.ids)):
            cls.id_list.append(cls.ids[i][0])
        # Check if VR is already present in the setup
        vr_list = Router.list(cls.api_client, listall='true')
        cls.debug("vr list {}".format(vr_list))
        if isinstance(vr_list, list) and len(vr_list) > 0:
            cls.debug("VR is running in the setup")
            cls.vr_state = True
        else:
            cls.debug("VR is not present in the setup")
            cls.vr_state = False
            cls.id_list = cls.id_list[:-2]
        for id in cls.id_list:
            cls.dbclient.execute(
                "update user_ip_address set allocated=now() where id = '%s';" %
                str(id))
        # create new vlan ip range
        # Before creating ip range check the zone's network type
        if cls.zone.networktype.lower() == 'basic':
            cls.new_vlan = cls.createNewVlanRange()
        else:
            raise unittest.SkipTest(
                "These tests can be run only on basic zone.\
                        So skipping the tests")
        # Deploy vm in existing subnet if VR is not present
        if cls.vr_state is False:
            cls.vm_res = VirtualMachine.create(
                cls.api_client,
                cls.testdata["server_without_disk"],
                templateid=cls.template.id,
                accountid=cls.account.name,
                domainid=cls.testdata["domainid"],
                zoneid=cls.testdata["zoneid"],
                serviceofferingid=cls.service_offering.id,
                mode=cls.testdata["mode"],
            )
        cls._cleanup = [
            cls.new_vlan,
            cls.account,
        ]
        return