Beispiel #1
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 #2
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 #3
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(TestHypervisorCapabilities, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.domain = get_domain(cls.apiclient)

        cls.hypervisor = cls.testClient.getHypervisorInfo()
        # Get Zone, Domain and templates

        cls.notSupported = True
        cls._cleanup = []
        cls.hosts = Host.list(cls.apiclient,
                              zoneid=cls.zone.id,
                              type='Routing')
        if isinstance(cls.hosts, list) and len(cls.hosts) > 0:
            cls.host = cls.hosts[0]
            cls.notSupported = False

        cls.hypervisorversion = "default"
        if hasattr(cls.host, 'hypervisorversion'):
            cls.hypervisorversion = cls.host.hypervisorversion

        if cls.notSupported == False:
            cls.notSupported = True
            cmdList = listHypervisorCapabilities.listHypervisorCapabilitiesCmd(
            )
            cmdList.hypervisor = cls.hypervisor
            capabilities = cls.apiclient.listHypervisorCapabilities(cmdList)
            for capability in capabilities:
                if capability.hypervisorversion == cls.hypervisorversion:
                    cls.hostCapability = capability
                    cls.notSupported = False
                    break

            if cls.notSupported == True:
                cls.hypervisorversion = "default"
                for capability in capabilities:
                    if capability.hypervisorversion == cls.hypervisorversion:
                        cls.hostCapability = capability
                        cls.notSupported = False
                        break

        if cls.notSupported == False:
            cls.template = get_template(cls.apiclient, cls.zone.id,
                                        cls.services["ostype"])

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

            # Create user api client of the account
            cls.userapiclient = testClient.getUserApiClient(
                UserName=cls.account.name, DomainName=cls.account.domain)
            # Create Service offering
            cls.service_offering = ServiceOffering.create(
                cls.apiclient,
                cls.services["service_offering"],
                hosttags="host1")
            cls._cleanup.append(cls.service_offering)

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

        return
 def listHostHypervisorCapabilities(self, id, hypervisor=None):
     cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
     cmd.id = id
     return self.apiclient.listHypervisorCapabilities(cmd)
Beispiel #6
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 #7
0
    def test_check_hypervisor_max_limit_effect(self):
        """ Test hypervisor max limits effect

        # 1. Read exsiting count of VM's on the host including SSVM and VR
                and modify maxguestcount accordingly
        # 2. Deploy a VM
        # 2. Try to deploy another vm
        # 3. Verify that second VM
                deployment fails (2 SSVMs 1 VR VM and 1 deployed VM)
        """

        hostList = Host.list(self.apiclient,
                             zoneid=self.zone.id,
                             type="Routing")
        event_validation_result = validateList(hostList)
        self.assertEqual(
            event_validation_result[0], PASS,
            "host list validation failed due to %s" %
            event_validation_result[2])

        self.host = Host(hostList[0])
        Host.update(self.apiclient, id=self.host.id, hosttags="host1")

        # Step 1
        # List VM's , SSVM's and VR on selected host
        listVm = list_virtual_machines(self.apiclient, hostid=self.host.id)

        listssvm = list_ssvms(self.apiclient, hostid=self.host.id)

        listvr = list_routers(self.apiclient, hostid=self.host.id)

        newValue = 1
        if listVm is not None:
            newValue = len(listVm) + newValue

        if listssvm is not None:
            newValue = len(listssvm) + newValue

        if listvr is not None:
            newValue = len(listvr) + newValue

        qresultset = self.dbclient.execute(
            "select hypervisor_version from host where uuid='%s'" %
            self.host.id)

        event_validation_result = validateList(qresultset)
        self.assertEqual(
            event_validation_result[0], PASS,
            "event list validation failed due to %s" %
            event_validation_result[2])

        cmdList = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
        cmdList.hypervisor = self.hypervisor
        config = self.apiclient.listHypervisorCapabilities(cmdList)

        for host in config:
            if host.hypervisorversion == qresultset[0][0]:
                self.hostCapId = host.id
                self.originalLimit = host.maxguestslimit
                break
        else:
            self.skipTest("No hypervisor capabilities found for %s \
                    with version %s" % (self.hypervisor, qresultset[0][0]))

        cmdUpdate = updateHypervisorCapabilities.\
            updateHypervisorCapabilitiesCmd()
        cmdUpdate.id = self.hostCapId
        cmdUpdate.maxguestslimit = newValue
        self.apiclient.updateHypervisorCapabilities(cmdUpdate)

        # Step 2
        vm = VirtualMachine.create(
            self.userapiclient,
            self.testdata["small"],
            templateid=self.template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            zoneid=self.zone.id,
        )

        self.cleanup.append(vm)
        # Step 3
        with self.assertRaises(Exception):
            VirtualMachine.create(
                self.userapiclient,
                self.testdata["small"],
                templateid=self.template.id,
                accountid=self.account.name,
                domainid=self.account.domainid,
                serviceofferingid=self.service_offering.id,
                zoneid=self.zone.id,
            )
    def test_check_hypervisor_max_limit_effect(self):
        """ Test hypervisor max limits effect

        # 1. Read exsiting count of VM's on the host including SSVM and VR
                and modify maxguestcount accordingly
        # 2. Deploy a VM
        # 2. Try to deploy another vm
        # 3. Verify that second VM
                deployment fails (2 SSVMs 1 VR VM and 1 deployed VM)
        """

        hostList = Host.list(
            self.apiclient,
            zoneid=self.zone.id,
            type="Routing")
        event_validation_result = validateList(hostList)
        self.assertEqual(
            event_validation_result[0],
            PASS,
            "host list validation failed due to %s" %
            event_validation_result[2])

        self.host = Host(hostList[0])
        Host.update(self.apiclient, id=self.host.id, hosttags="host1")

        # Step 1
        # List VM's , SSVM's and VR on selected host
        listVm = list_virtual_machines(self.apiclient,
                                       hostid=self.host.id)

        listssvm = list_ssvms(self.apiclient,
                              hostid=self.host.id)

        listvr = list_routers(self.apiclient,
                              hostid=self.host.id)

        newValue = 1
        if listVm is not None:
            newValue = len(listVm) + newValue

        if listssvm is not None:
            newValue = len(listssvm) + newValue

        if listvr is not None:
            newValue = len(listvr) + newValue

        qresultset = self.dbclient.execute(
            "select hypervisor_version from host where uuid='%s'" %
            self.host.id)

        event_validation_result = validateList(qresultset)
        self.assertEqual(
            event_validation_result[0],
            PASS,
            "event list validation failed due to %s" %
            event_validation_result[2])

        cmdList = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
        cmdList.hypervisor = self.hypervisor
        config = self.apiclient.listHypervisorCapabilities(cmdList)

        for host in config:
            if host.hypervisorversion == qresultset[0][0]:
                self.hostCapId = host.id
                self.originalLimit = host.maxguestslimit
                break
        else:
            self.skipTest("No hypervisor capabilities found for %s \
                    with version %s" % (self.hypervisor, qresultset[0][0]))

        cmdUpdate = updateHypervisorCapabilities.\
            updateHypervisorCapabilitiesCmd()
        cmdUpdate.id = self.hostCapId
        cmdUpdate.maxguestslimit = newValue
        self.apiclient.updateHypervisorCapabilities(cmdUpdate)

        # Step 2
        vm = VirtualMachine.create(
            self.userapiclient,
            self.testdata["small"],
            templateid=self.template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            zoneid=self.zone.id,
        )

        self.cleanup.append(vm)
        # Step 3
        with self.assertRaises(Exception):
            VirtualMachine.create(
                self.userapiclient,
                self.testdata["small"],
                templateid=self.template.id,
                accountid=self.account.name,
                domainid=self.account.domainid,
                serviceofferingid=self.service_offering.id,
                zoneid=self.zone.id,
            )