Exemplo n.º 1
0
    def setUpClass(cls):
        cloudstackTestClient = super(TestVolumeLimits, cls).getClsTestClient()
        cls.api_client = cloudstackTestClient.getApiClient()
        cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
        # Fill services from the external config file
        cls.services = cloudstackTestClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client,
                            cloudstackTestClient.getZoneForTests())
        cls.services["mode"] = cls.zone.networktype
        cls._cleanup = []
        cls.unsupportedStorageType = False
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.api_client, storagetype='rbd'):
                cls.unsupportedStorageType = True
                return

        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.services["volume"]["zoneid"] = cls.zone.id

        try:
            cls.service_offering = ServiceOffering.create(
                cls.api_client, cls.services["service_offering"])
            cls._cleanup.append(cls.service_offering)
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Exception in setUpClass: %s" % e)
        return
    def setUpClass(cls):
        cloudstackTestClient = super(TestResizeVolume,
                                     cls).getClsTestClient()
        cls.api_client = cloudstackTestClient.getApiClient()
        cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
        # Fill services from the external config file
        cls.services = cloudstackTestClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(
            cls.api_client,
            cloudstackTestClient.getZoneForTests())
        cls.services["mode"] = cls.zone.networktype
        cls._cleanup = []
        cls.unsupportedStorageType = False
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.api_client, storagetype='rbd'):
                cls.unsupportedStorageType = True
                return
        cls.resourcetypemapping = {RESOURCE_PRIMARY_STORAGE: 10,
                                   RESOURCE_SECONDARY_STORAGE: 11}

        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.services["volume"]["zoneid"] = cls.zone.id

        try:
            cls.hypervisor = str(get_hypervisor_type(cls.api_client)).lower()

            # Creating service offering with normal config
            cls.service_offering = ServiceOffering.create(
                cls.api_client,
                cls.services["service_offering"])
            cls._cleanup.append(cls.service_offering)

            cls.services["disk_offering"]["disksize"] = 5
            cls.disk_offering_5_GB = DiskOffering.create(
                cls.api_client,
                cls.services["disk_offering"]
            )
            cls._cleanup.append(cls.disk_offering_5_GB)

            cls.services["disk_offering"]["disksize"] = 20
            cls.disk_offering_20_GB = DiskOffering.create(
                cls.api_client,
                cls.services["disk_offering"]
            )
            cls._cleanup.append(cls.disk_offering_20_GB)
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest(
                "Failure while creating disk offering: %s" %
                e)
        return
Exemplo n.º 3
0
    def setUpClass(cls):
        cls.testClient = super(TestVolumes, 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.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["virtual_machine"]["template"] = template.id
        cls.services["virtual_machine"][
            "diskofferingid"] = cls.disk_offering.id

        # Create VMs, VMs 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.volume = Volume.create(
            cls.api_client,
            cls.services["volume"],
            zoneid=cls.zone.id,
            account=cls.account.name,
            domainid=cls.account.domainid,
            diskofferingid=cls.disk_offering.id
        )
        cls._cleanup = [
            cls.service_offering,
            cls.disk_offering,
            cls.account
        ]
Exemplo n.º 4
0
    def setUpClass(cls):
        cls.testClient = super(TestDeployVmWithCustomDisk, 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.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"], custom=True)
        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

        # 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)
Exemplo n.º 5
0
    def setUpClass(cls):
        cls.testClient = super(TestVolumes, 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.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["virtual_machine"]["template"] = template.id
        cls.services["virtual_machine"][
            "diskofferingid"] = cls.disk_offering.id

        # Create VMs, VMs 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.volume = Volume.create(
            cls.api_client,
            cls.services["volume"],
            zoneid=cls.zone.id,
            account=cls.account.name,
            domainid=cls.account.domainid,
            diskofferingid=cls.disk_offering.id
        )
        cls._cleanup = [
            cls.service_offering,
            cls.disk_offering,
            cls.account
        ]
Exemplo n.º 6
0
    def setUpClass(cls):
        cloudstackTestClient = super(TestVolumeLimits,
                               cls).getClsTestClient()
        cls.api_client = cloudstackTestClient.getApiClient()
        cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
        # Fill services from the external config file
        cls.services = cloudstackTestClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests())
        cls.services["mode"] = cls.zone.networktype
        cls._cleanup = []
        cls.unsupportedStorageType = False
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.api_client, storagetype='rbd'):
                cls.unsupportedStorageType = True
                return

        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.services["volume"]["zoneid"] = cls.zone.id

        try:
            cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
            cls._cleanup.append(cls.service_offering)
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Exception in setUpClass: %s" % e)
        return
Exemplo n.º 7
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 test_06_volumes_per_project(self):
        """Test Volumes limit per project
        """
        # Validate the following
        # 1. set max no of volume per project to 1.
        # 2. Create 1 VM in this project
        # 4. Try to Create another VM in the project. It should give the user
        #    an appropriate error that Volume limit is exhausted and an alert
        #    should be generated.

        if self.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(self.apiclient, storagetype='rbd'):
                self.skipTest("RBD storage type is required for data volumes for LXC")
        self.project_1 = Project.create(
                         self.api_client,
                         self.services["project"],
                         account=self.account.name,
                         domainid=self.account.domainid
                         )
        self.cleanup.append(self.project_1)

        self.debug(
            "Updating volume resource limits for project: %s" %
                                                    self.project_1.id)
        # Set usage_vm=1 for Account 1
        update_resource_limit(
                              self.apiclient,
                              2, # Volume
                              max=1,
                              projectid=self.project_1.id
                              )

        self.debug("Deploying VM for project: %s" % self.project_1.id)
        virtual_machine_1 = VirtualMachine.create(
                                self.apiclient,
                                self.services["server"],
                                templateid=self.template.id,
                                serviceofferingid=self.service_offering.id,
                                projectid=self.project_1.id
                                )
        # Verify VM state
        self.assertEqual(
                            virtual_machine_1.state,
                            'Running',
                            "Check VM state is Running or not"
                        )

        # Exception should be raised for second volume
        with self.assertRaises(Exception):
            Volume.create(
                          self.apiclient,
                          self.services["volume"],
                          zoneid=self.zone.id,
                          diskofferingid=self.disk_offering.id,
                          projectid=self.project_1.id
                        )
        return
Exemplo n.º 9
0
    def setUpClass(cls):
        testClient = super(TestCreateVolume, 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._cleanup = []
        cls.hypervisor = testClient.getHypervisorInfo()
        cls.services['mode'] = cls.zone.networktype
        cls.invalidStoragePoolType = False
        # for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
                # RBD storage type is required for data volumes for LXC
                cls.invalidStoragePoolType = True
                return
        cls.disk_offering = DiskOffering.create(cls.apiclient,
                                                cls.services["disk_offering"])
        cls._cleanup.append(cls.disk_offering)
        cls.sparse_disk_offering = DiskOffering.create(
            cls.apiclient, cls.services["sparse_disk_offering"])
        cls._cleanup.append(cls.sparse_disk_offering)
        cls.custom_disk_offering = DiskOffering.create(
            cls.apiclient, cls.services["disk_offering"], custom=True)
        cls._cleanup.append(cls.custom_disk_offering)

        template = get_suitable_test_template(cls.apiclient, cls.zone.id,
                                              cls.services["ostype"],
                                              cls.hypervisor)
        if template == FAILED:
            assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services[
                "ostype"]

        cls.services["domainid"] = cls.domain.id
        cls.services["zoneid"] = cls.zone.id
        cls.services["template"] = template.id
        cls.services["customdiskofferingid"] = cls.custom_disk_offering.id
        cls.services["diskname"] = cls.services["volume"]["diskname"]
        # Create VMs, NAT Rules etc
        cls.account = Account.create(cls.apiclient,
                                     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.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.services["mode"])
        cls._cleanup.append(cls.virtual_machine)
    def setUpClass(cls):
        cloudstackTestClient = super(TestResizeVolume, cls).getClsTestClient()
        cls.api_client = cloudstackTestClient.getApiClient()
        cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
        # Fill services from the external config file
        cls.services = cloudstackTestClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client,
                            cloudstackTestClient.getZoneForTests())
        cls.services["mode"] = cls.zone.networktype
        cls._cleanup = []
        cls.unsupportedStorageType = False
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.api_client, storagetype='rbd'):
                cls.unsupportedStorageType = True
                return
        cls.resourcetypemapping = {
            RESOURCE_PRIMARY_STORAGE: 10,
            RESOURCE_SECONDARY_STORAGE: 11
        }

        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.services["volume"]["zoneid"] = cls.zone.id

        try:
            cls.hypervisor = str(get_hypervisor_type(cls.api_client)).lower()
            if cls.hypervisor.lower() in ['hyperv']:
                raise unittest.SkipTest(
                    "Volume resize is not supported on %s" % cls.hypervisor)
            # Creating service offering with normal config
            cls.service_offering = ServiceOffering.create(
                cls.api_client, cls.services["service_offering"])
            cls._cleanup.append(cls.service_offering)

            cls.services["disk_offering"]["disksize"] = 5
            cls.disk_offering_5_GB = DiskOffering.create(
                cls.api_client, cls.services["disk_offering"])
            cls._cleanup.append(cls.disk_offering_5_GB)

            cls.services["disk_offering"]["disksize"] = 20
            cls.disk_offering_20_GB = DiskOffering.create(
                cls.api_client, cls.services["disk_offering"])
            cls._cleanup.append(cls.disk_offering_20_GB)
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest(
                "Failure while creating disk offering: %s" % e)
        return
Exemplo n.º 11
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,
        )
Exemplo n.º 12
0
    def setUpClass(cls):
        cls.testClient = super(TestMigrateVolume, 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.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"])
        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
        cls.services["virtual_machine"]["diskofferingid"] = cls.disk_offering.id

        # Create VMs, VMs etc
        cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
        cls.small_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.small_offering.id,
            mode=cls.services["mode"],
        )
        cls._cleanup = [cls.small_offering, cls.account]
        return
Exemplo n.º 13
0
    def setUpClass(cls):
        testClient = super(TestVolumes, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls._cleanup = []
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype
        cls.hypervisor = testClient.getHypervisorInfo()
        cls.invalidStoragePoolType = False
        #for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
                # RBD storage type is required for data volumes for LXC
                cls.invalidStoragePoolType = True
                return
        cls.disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["disk_offering"]
                                    )
        cls.resized_disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["resized_disk_offering"]
                                    )
        cls.custom_resized_disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["resized_disk_offering"],
                                    custom=True
                                    )

        cls.template = get_suitable_test_template(
            cls.apiclient,
            cls.zone.id,
            cls.services["ostype"],
            cls.hypervisor
        )
        if cls.template == FAILED:
            assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"]

        cls.services["domainid"] = cls.domain.id
        cls.services["zoneid"] = cls.zone.id
        cls.services["template"] = cls.template.id
        cls.services["diskofferingid"] = cls.disk_offering.id
        cls.services['resizeddiskofferingid'] = cls.resized_disk_offering.id
        cls.services['customresizeddiskofferingid'] = cls.custom_resized_disk_offering.id

        # Create VMs, VMs 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 = VirtualMachine.create(
                                    cls.apiclient,
                                    cls.services,
                                    accountid=cls.account.name,
                                    domainid=cls.account.domainid,
                                    serviceofferingid=cls.service_offering.id,
                                    mode=cls.services["mode"]
                                )
        pools = StoragePool.list(cls.apiclient)
        # cls.assertEqual(
        #         validateList(pools)[0],
        #         PASS,
        #         "storage pool list validation failed")



        if cls.hypervisor.lower() == 'lxc' and cls.storage_pools.type.lower() != 'rbd':
            raise unittest.SkipTest("Snapshots not supported on Hyper-V or LXC")
        cls.volume = Volume.create(
                                   cls.apiclient,
                                   cls.services,
                                   account=cls.account.name,
                                   domainid=cls.account.domainid
                                   )
        cls._cleanup = [
                        cls.resized_disk_offering,
                        cls.custom_resized_disk_offering,
                        cls.service_offering,
                        cls.disk_offering,
                        cls.volume,
                        cls.account
                        ]
Exemplo n.º 14
0
    def test_03_multiple_domains_multiple_volumes(self):
        """Test primary storage counts in multiple child domains
        # Steps
        1. Create a parent domain and two sub-domains in it (also admin accounts
           of each domain)
        Repeat following steps for both the child domains
        2. Deploy VM in child domain
        3. Check if the resource count for domain is updated correctly
        4. Create multiple volumes and attach it to the VM
        5. Check if the primary storage resource count is updated correctly
        6. Delete one of the volumes and check if the primary storage resource count
           reduced by equivalent number
        7. Detach other volume and check primary storage resource count remains the same

        """
        # Setting up account and domain hierarchy

        if self.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(self.apiclient, storagetype='rbd'):
                self.skipTest(
                    "RBD storage type is required for data volumes for LXC")
        result = self.setupAccounts()
        if result[0] == FAIL:
            self.fail("Failure while setting up accounts and domains: %s" %
                      result[1])
        else:
            users = result[2]

        templatesize = (self.template.size / (1024**3))

        for domain, admin in list(users.items()):
            self.account = admin
            self.domain = domain

            apiclient = self.testClient.getUserApiClient(
                UserName=self.account.name, DomainName=self.account.domain)
            self.assertNotEqual(
                apiclient, FAILED,
                "Failed to create api client for account: %s" %
                self.account.name)

            try:
                vm = VirtualMachine.create(
                    apiclient,
                    self.services["virtual_machine"],
                    accountid=self.account.name,
                    domainid=self.account.domainid,
                    diskofferingid=self.disk_offering.id,
                    serviceofferingid=self.service_offering.id,
                    startvm=False)
                self.cleanup.append(vm)

                expectedCount = templatesize + self.disk_offering.disksize
                result = isDomainResourceCountEqualToExpectedCount(
                    self.apiclient, self.domain.id, expectedCount,
                    RESOURCE_PRIMARY_STORAGE)
                self.assertFalse(result[0], result[1])
                self.assertTrue(result[2], "Resource count does not match")

                volume1size = self.services["disk_offering"]["disksize"] = 15
                disk_offering_15_GB = DiskOffering.create(
                    self.apiclient, services=self.services["disk_offering"])
                self.cleanup.append(disk_offering_15_GB)

                volume2size = self.services["disk_offering"]["disksize"] = 20
                disk_offering_20_GB = DiskOffering.create(
                    self.apiclient, services=self.services["disk_offering"])
                self.cleanup.append(disk_offering_20_GB)

                volume_1 = Volume.create(apiclient,
                                         self.services["volume"],
                                         zoneid=self.zone.id,
                                         account=self.account.name,
                                         domainid=self.account.domainid,
                                         diskofferingid=disk_offering_15_GB.id)
                self.cleanup.append(volume_1)

                volume_2 = Volume.create(apiclient,
                                         self.services["volume"],
                                         zoneid=self.zone.id,
                                         account=self.account.name,
                                         domainid=self.account.domainid,
                                         diskofferingid=disk_offering_20_GB.id)
                self.cleanup.append(volume_2)

                vm.attach_volume(apiclient, volume=volume_1)
                self.cleanup.remove(volume_1)
                vm.attach_volume(apiclient, volume=volume_2)
                self.cleanup.remove(volume_2)

                expectedCount += volume1size + volume2size
                result = isDomainResourceCountEqualToExpectedCount(
                    self.apiclient, self.domain.id, expectedCount,
                    RESOURCE_PRIMARY_STORAGE)
                self.assertFalse(result[0], result[1])
                self.assertTrue(result[2], "Resource count does not match")

                vm.detach_volume(apiclient, volume=volume_1)
                volume_1.delete(apiclient)

                expectedCount -= volume1size
                result = isDomainResourceCountEqualToExpectedCount(
                    self.apiclient, self.domain.id, expectedCount,
                    RESOURCE_PRIMARY_STORAGE)
                self.assertFalse(result[0], result[1])
                self.assertTrue(result[2], "Resource count does not match")
            except Exception as e:
                self.fail("Failure: %s" % e)
        return
Exemplo n.º 15
0
    def setUpClass(cls):
        testClient = super(TestCreateVolume, 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.hypervisor = testClient.getHypervisorInfo()
        cls.services['mode'] = cls.zone.networktype
        #for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
                raise unittest.SkipTest("RBD storage type is required for data volumes for LXC")
        cls.disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["disk_offering"]
                                    )
        cls.sparse_disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["sparse_disk_offering"]
                                    )
        cls.custom_disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["disk_offering"],
                                    custom=True
                                    )
        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"]

        cls.services["domainid"] = cls.domain.id
        cls.services["zoneid"] = cls.zone.id
        cls.services["template"] = template.id
        cls.services["customdiskofferingid"] = cls.custom_disk_offering.id
        cls.services["diskname"] = cls.services["volume"]["diskname"]
        # 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"]
                                            )
        cls.virtual_machine = VirtualMachine.create(
                                    cls.apiclient,
                                    cls.services,
                                    accountid=cls.account.name,
                                    domainid=cls.account.domainid,
                                    serviceofferingid=cls.service_offering.id,
                                    mode=cls.services["mode"]
                                )
        cls._cleanup = [
                        cls.service_offering,
                        cls.disk_offering,
                        cls.custom_disk_offering,
                        cls.account
                        ]
Exemplo n.º 16
0
    def setUpClass(cls):
        testClient = super(TestVolumes, 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.services['mode'] = cls.zone.networktype
        cls.hypervisor = testClient.getHypervisorInfo()
        #for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
                raise unittest.SkipTest("RBD storage type is required for data volumes for LXC")
        cls.disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["disk_offering"]
                                    )
        cls.resized_disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["resized_disk_offering"]
                                    )
        cls.custom_resized_disk_offering = DiskOffering.create(
                                    cls.apiclient,
                                    cls.services["resized_disk_offering"],
                                    custom=True
                                    )

        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"]

        cls.services["domainid"] = cls.domain.id
        cls.services["zoneid"] = cls.zone.id
        cls.services["template"] = template.id
        cls.services["diskofferingid"] = cls.disk_offering.id
        cls.services['resizeddiskofferingid'] = cls.resized_disk_offering.id
        cls.services['customresizeddiskofferingid'] = cls.custom_resized_disk_offering.id

        # Create VMs, VMs 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"]
                                        )
        cls.virtual_machine = VirtualMachine.create(
                                    cls.apiclient,
                                    cls.services,
                                    accountid=cls.account.name,
                                    domainid=cls.account.domainid,
                                    serviceofferingid=cls.service_offering.id,
                                    mode=cls.services["mode"]
                                )
        pools = StoragePool.list(cls.apiclient)
        # cls.assertEqual(
        #         validateList(pools)[0],
        #         PASS,
        #         "storage pool list validation failed")



        if cls.hypervisor.lower() == 'lxc' and cls.storage_pools.type.lower() != 'rbd':
            raise unittest.SkipTest("Snapshots not supported on Hyper-V or LXC")
        cls.volume = Volume.create(
                                   cls.apiclient,
                                   cls.services,
                                   account=cls.account.name,
                                   domainid=cls.account.domainid
                                   )
        cls._cleanup = [
                        cls.resized_disk_offering,
                        cls.custom_resized_disk_offering,
                        cls.service_offering,
                        cls.disk_offering,
                        cls.volume,
                        cls.account
                        ]
    def setUpClass(cls):
        testClient = super(TestMultipleVolumeAttach, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls._cleanup = []
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype
        cls.hypervisor = testClient.getHypervisorInfo()
        cls.invalidStoragePoolType = False
        #for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
                # RBD storage type is required for data volumes for LXC
                cls.invalidStoragePoolType = True
                return

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

        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"]

        cls.services["domainid"] = cls.domain.id
        cls.services["zoneid"] = cls.zone.id
        cls.services["template"] = template.id
        cls.services["diskofferingid"] = cls.disk_offering.id

        # Create VMs, VMs etc
        cls.account = Account.create(
                            cls.apiclient,
                            cls.services["account"],
                            domainid=cls.domain.id
                            )
        cls.service_offering = ServiceOffering.create(
                                            cls.apiclient,
                                            cls.services["service_offering"]
                                        )
        cls.virtual_machine = VirtualMachine.create(
                                    cls.apiclient,
                                    cls.services,
                                    accountid=cls.account.name,
                                    domainid=cls.account.domainid,
                                    serviceofferingid=cls.service_offering.id,
                                    mode=cls.services["mode"]
                                )

        #Create volumes (data disks)
        cls.volume1 = Volume.create(
                                   cls.apiclient,
                                   cls.services,
                                   account=cls.account.name,
                                   domainid=cls.account.domainid
                                   )

        cls.volume2 = Volume.create(
                                   cls.apiclient,
                                   cls.services,
                                   account=cls.account.name,
                                   domainid=cls.account.domainid
                                   )

        cls.volume3 = Volume.create(
                                   cls.apiclient,
                                   cls.services,
                                   account=cls.account.name,
                                   domainid=cls.account.domainid
                                   )

        cls.volume4 = Volume.create(
                                   cls.apiclient,
                                   cls.services,
                                   account=cls.account.name,
                                   domainid=cls.account.domainid
                                   )
        cls._cleanup = [
                        cls.service_offering,
                        cls.disk_offering,
                        cls.account
                        ]
    def setUpClass(cls):
        testClient = super(TestPathVolume, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        # Get Zone,Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient)
        cls.testdata["mode"] = cls.zone.networktype
        cls.hypervisor = testClient.getHypervisorInfo()
        cls._cleanup = []
        cls.insuffStorage = False
        cls.unsupportedHypervisor = False

        #for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
                cls.insuffStorage   = True
                return

        cls.template = get_template(
            cls.apiclient,
            cls.zone.id,
            cls.testdata["ostype"])
        cls.testdata["template"]["ostypeid"] = cls.template.ostypeid
        if cls.template == FAILED:
            cls.fail(
                "get_template() failed to return template with description \
                %s" %
                cls.testdata["ostype"])

        try:
            cls.account = Account.create(cls.apiclient,
                                         cls.testdata["account"],
                                         domainid=cls.domain.id
                                         )
            cls._cleanup.append(cls.account)
            # createa two service offerings
            cls.service_offering_1 = ServiceOffering.create(
                cls.apiclient,
                cls.testdata["service_offerings"]["small"])
            cls._cleanup.append(cls.service_offering_1)
            # Create Disk offerings
            cls.disk_offering_1 = DiskOffering.create(
                cls.apiclient,
                cls.testdata["disk_offering"])
            cls._cleanup.append(cls.disk_offering_1)
            # check if zone wide storage is enable
            cls.list_storage = StoragePool.list(cls.apiclient,
                                                scope="ZONE"
                                                )
            if cls.list_storage:
                cls.zone_wide_storage = cls.list_storage[0]
                cls.debug(
                    "zone wide storage id is %s" %
                    cls.zone_wide_storage.id)
                cls.testdata["tags"] = "zp"
                update1 = StoragePool.update(cls.apiclient,
                                             id=cls.zone_wide_storage.id,
                                             tags=cls.testdata["tags"]
                                             )
                cls.debug(
                    "Storage %s pool tag%s" %
                    (cls.zone_wide_storage.id, update1.tags))
                cls.testdata["service_offerings"]["tags"] = "zp"
                cls.tagged_so = ServiceOffering.create(
                    cls.apiclient,
                    cls.testdata["service_offerings"])
                cls.testdata["service_offerings"]["tags"] = " "
                cls._cleanup.append(cls.tagged_so)
                # create tagged disk offerings
                cls.testdata["disk_offering"]["tags"] = "zp"
                cls.disk_offering_tagged = DiskOffering.create(
                    cls.apiclient,
                    cls.testdata["disk_offering"])
                cls._cleanup.append(cls.disk_offering_tagged)
            else:
                cls.debug("No zone wide storage found")
            # check if local storage is enable
            if cls.zone.localstorageenabled:
                cls.testdata["disk_offering"]["tags"] = " "
                cls.testdata["service_offerings"]["storagetype"] = 'local'
                cls.service_offering_2 = ServiceOffering.create(
                    cls.apiclient,
                    cls.testdata["service_offerings"])
                cls._cleanup.append(cls.service_offering_2)
                # craete a compute offering with local storage
                cls.testdata["disk_offering"]["storagetype"] = 'local'
                cls.disk_offering_local = DiskOffering.create(
                    cls.apiclient,
                    cls.testdata["disk_offering"])
                cls._cleanup.append(cls.disk_offering_local)
                cls.testdata["disk_offering"]["storagetype"] = ' '
            else:
                cls.debug("No local storage found")
            cls.userapiclient = testClient.getUserApiClient(
                UserName=cls.account.name,
                DomainName=cls.account.domain)
            # Check if login is successful with new account
            response = User.login(cls.userapiclient,
                                  username=cls.account.name,
                                  password=cls.testdata["account"]["password"]
                                  )
            assert response.sessionkey is not None
            #response should have non null value
        except Exception as e:
                cls.tearDownClass()
                raise e
        return
Exemplo n.º 19
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
        ]
Exemplo n.º 20
0
    def setUpClass(cls):
        testClient = super(TestPathVolume, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        # Get Zone,Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient)
        cls.testdata["mode"] = cls.zone.networktype
        cls.hypervisor = testClient.getHypervisorInfo()
        #for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
        if cls.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
                raise unittest.SkipTest(
                    "RBD storage type is required for data volumes for %s" %
                    cls.hypervisor.lower())

        cls.template = get_template(cls.apiclient, cls.zone.id,
                                    cls.testdata["ostype"])
        cls.testdata["template"]["ostypeid"] = cls.template.ostypeid
        if cls.template == FAILED:
            cls.fail(
                "get_template() failed to return template with description \
                %s" % cls.testdata["ostype"])
        cls._cleanup = []
        try:
            cls.account = Account.create(cls.apiclient,
                                         cls.testdata["account"],
                                         domainid=cls.domain.id)
            cls._cleanup.append(cls.account)
            # createa two service offerings
            cls.service_offering_1 = ServiceOffering.create(
                cls.apiclient, cls.testdata["service_offerings"]["small"])
            cls._cleanup.append(cls.service_offering_1)
            # Create Disk offerings
            cls.disk_offering_1 = DiskOffering.create(
                cls.apiclient, cls.testdata["disk_offering"])
            cls._cleanup.append(cls.disk_offering_1)
            # check if zone wide storage is enable
            cls.list_storage = StoragePool.list(cls.apiclient, scope="ZONE")
            if cls.list_storage:
                cls.zone_wide_storage = cls.list_storage[0]
                cls.debug("zone wide storage id is %s" %
                          cls.zone_wide_storage.id)
                cls.testdata["tags"] = "zp"
                update1 = StoragePool.update(cls.apiclient,
                                             id=cls.zone_wide_storage.id,
                                             tags=cls.testdata["tags"])
                cls.debug("Storage %s pool tag%s" %
                          (cls.zone_wide_storage.id, update1.tags))
                cls.testdata["service_offerings"]["tags"] = "zp"
                cls.tagged_so = ServiceOffering.create(
                    cls.apiclient, cls.testdata["service_offerings"])
                cls.testdata["service_offerings"]["tags"] = " "
                cls._cleanup.append(cls.tagged_so)
                # create tagged disk offerings
                cls.testdata["disk_offering"]["tags"] = "zp"
                cls.disk_offering_tagged = DiskOffering.create(
                    cls.apiclient, cls.testdata["disk_offering"])
                cls._cleanup.append(cls.disk_offering_tagged)
            else:
                cls.debug("No zone wide storage found")
            # check if local storage is enable
            if cls.zone.localstorageenabled:
                cls.testdata["disk_offering"]["tags"] = " "
                cls.testdata["service_offerings"]["storagetype"] = 'local'
                cls.service_offering_2 = ServiceOffering.create(
                    cls.apiclient, cls.testdata["service_offerings"])
                cls._cleanup.append(cls.service_offering_2)
                # craete a compute offering with local storage
                cls.testdata["disk_offering"]["storagetype"] = 'local'
                cls.disk_offering_local = DiskOffering.create(
                    cls.apiclient, cls.testdata["disk_offering"])
                cls._cleanup.append(cls.disk_offering_local)
                cls.testdata["disk_offering"]["storagetype"] = ' '
            else:
                cls.debug("No local storage found")
            cls.userapiclient = testClient.getUserApiClient(
                UserName=cls.account.name, DomainName=cls.account.domain)
            # Check if login is successful with new account
            response = User.login(cls.userapiclient,
                                  username=cls.account.name,
                                  password=cls.testdata["account"]["password"])
            assert response.sessionkey is not None
            # response should have non null value
        except Exception as e:
            cls.tearDownClass()
            raise e
        return
Exemplo n.º 21
0
    def test_03_multiple_domains_multiple_volumes(self):
        """Test primary storage counts in multiple child domains
        # Steps
        1. Create a parent domain and two sub-domains in it (also admin accounts
           of each domain)
        Repeat following steps for both the child domains
        2. Deploy VM in child domain
        3. Check if the resource count for domain is updated correctly
        4. Create multiple volumes and attach it to the VM
        5. Check if the primary storage resource count is updated correctly
        6. Delete one of the volumes and check if the primary storage resource count
           reduced by equivalent number
        7. Detach other volume and check primary storage resource count remains the same

        """
        # Setting up account and domain hierarchy

        if self.hypervisor.lower() == 'lxc':
            if not find_storage_pool_type(self.apiclient, storagetype='rbd'):
                self.skipTest("RBD storage type is required for data volumes for LXC")
        result = self.setupAccounts()
        if result[0] == FAIL:
            self.fail(
                "Failure while setting up accounts and domains: %s" %
                result[1])
        else:
            users = result[2]

        templatesize = (self.template.size / (1024 ** 3))

        for domain, admin in users.items():
            self.account = admin
            self.domain = domain

            apiclient = self.testClient.getUserApiClient(
                UserName=self.account.name,
                DomainName=self.account.domain)
            self.assertNotEqual(
                apiclient,
                FAILED,
                "Failed to create api client for account: %s" %
                self.account.name)

            try:
                vm = VirtualMachine.create(
                    apiclient,
                    self.services["virtual_machine"],
                    accountid=self.account.name,
                    domainid=self.account.domainid,
                    diskofferingid=self.disk_offering.id,
                    serviceofferingid=self.service_offering.id)

                expectedCount = templatesize + self.disk_offering.disksize
                result = isDomainResourceCountEqualToExpectedCount(
                    self.apiclient, self.domain.id,
                    expectedCount, RESOURCE_PRIMARY_STORAGE)
                self.assertFalse(result[0], result[1])
                self.assertTrue(result[2], "Resource count does not match")

                volume1size = self.services["disk_offering"]["disksize"] = 15
                disk_offering_15_GB = DiskOffering.create(
                    self.apiclient,
                    services=self.services["disk_offering"])

                self.cleanup.append(disk_offering_15_GB)

                volume2size = self.services["disk_offering"]["disksize"] = 20
                disk_offering_20_GB = DiskOffering.create(
                    self.apiclient,
                    services=self.services["disk_offering"])

                self.cleanup.append(disk_offering_20_GB)

                volume_1 = Volume.create(
                    apiclient,
                    self.services["volume"],
                    zoneid=self.zone.id,
                    account=self.account.name,
                    domainid=self.account.domainid,
                    diskofferingid=disk_offering_15_GB.id)

                volume_2 = Volume.create(
                    apiclient,
                    self.services["volume"],
                    zoneid=self.zone.id,
                    account=self.account.name,
                    domainid=self.account.domainid,
                    diskofferingid=disk_offering_20_GB.id)

                vm.attach_volume(apiclient, volume=volume_1)
                vm.attach_volume(apiclient, volume=volume_2)

                expectedCount += volume1size + volume2size
                result = isDomainResourceCountEqualToExpectedCount(
                    self.apiclient, self.domain.id,
                    expectedCount, RESOURCE_PRIMARY_STORAGE)
                self.assertFalse(result[0], result[1])
                self.assertTrue(result[2], "Resource count does not match")

                vm.detach_volume(apiclient, volume=volume_1)
                volume_1.delete(apiclient)

                expectedCount -= volume1size
                result = isDomainResourceCountEqualToExpectedCount(
                    self.apiclient, self.domain.id,
                    expectedCount, RESOURCE_PRIMARY_STORAGE)
                self.assertFalse(result[0], result[1])
                self.assertTrue(result[2], "Resource count does not match")
            except Exception as e:
                self.fail("Failure: %s" % e)
        return