Ejemplo n.º 1
0
    def setUp(self):

        self.apiClient = self.testClient.getApiClient()
        self.acct = createAccount.createAccountCmd()
        self.acct.accounttype = 0
        self.acct.firstname = self.services[
            "configurableData"]["ldap_account"]["firstname"]
        self.acct.lastname = self.services[
            "configurableData"]["ldap_account"]["lastname"]
        self.acct.password = self.services[
            "configurableData"]["ldap_account"]["password"]
        self.acct.username = self.services[
            "configurableData"]["ldap_account"]["username"]
        self.acct.email = self.services[
            "configurableData"]["ldap_account"]["email"]
        self.acct.account = self.services[
            "configurableData"]["ldap_account"]["username"]
        self.acct.domainid = 1

        if self.acct.firstname == ""or self.acct.lastname == "" or self.acct.password == "" or self.acct.username == ""\
                or self.services["configurableData"]["ldap_configuration"]["ldapUsername"] == "" or \
                self.acct.account == "" or \
                self.services["configurableData"]["ldap_configuration"]["ldapPassword"] == "":

            self.debug("Please rerun the test by providing values in ldap configuration user details")
            self.skipTest("Please rerun the test by providing proper values in configuration file")

        else:
            self.delflag = 1
            self.acctRes = self.apiClient.createAccount(self.acct)
        self.assertEquals(self.delflag,  1, "LDAP account details are not provided,please check the configuration")
        return
Ejemplo n.º 2
0
    def create_account(cls,
                       apiclient,
                       services,
                       accounttype=None,
                       domainid=None,
                       roleid=None):
        """Creates an account"""
        cmd = createAccount.createAccountCmd()

        # 0 - User, 1 - Root Admin, 2 - Domain Admin
        if accounttype:
            cmd.accounttype = accounttype
        else:
            cmd.accounttype = 1

        cmd.email = services["email"]
        cmd.firstname = services["firstname"]
        cmd.lastname = services["lastname"]

        cmd.password = services["password"]
        username = services["username"]
        # Limit account username to 99 chars to avoid failure
        # 6 chars start string + 85 chars apiclientid + 6 chars random string + 2 chars joining hyphen string = 99
        username = username[:6]
        apiclientid = apiclient.id[-85:] if len(
            apiclient.id) > 85 else apiclient.id
        cmd.username = "******".join([username, random_gen(id=apiclientid, size=6)])

        if "accountUUID" in services:
            cmd.accountid = "-".join([services["accountUUID"], random_gen()])

        if "userUUID" in services:
            cmd.userid = "-".join([services["userUUID"], random_gen()])

        if domainid:
            cmd.domainid = domainid

        if roleid:
            cmd.roleid = roleid

        account = apiclient.createAccount(cmd)

        return Account(account.__dict__)
Ejemplo n.º 3
0
    def setUp(self):

        self.apiClient = self.testClient.getApiClient()
        self.acct = createAccount.createAccountCmd()
        self.acct.accounttype = 0
        self.acct.firstname = self.services["configurableData"][
            "ldap_account"]["firstname"]
        self.acct.lastname = self.services["configurableData"]["ldap_account"][
            "lastname"]
        self.acct.password = self.services["configurableData"]["ldap_account"][
            "password"]
        self.acct.username = self.services["configurableData"]["ldap_account"][
            "username"]
        self.acct.email = self.services["configurableData"]["ldap_account"][
            "email"]
        self.acct.account = self.services["configurableData"]["ldap_account"][
            "username"]
        self.acct.domainid = 1

        if self.acct.firstname == ""or self.acct.lastname == "" or self.acct.password == "" or self.acct.username == ""\
                or self.services["configurableData"]["ldap_configuration"]["ldapUsername"] == "" or \
                self.acct.account == "" or \
                self.services["configurableData"]["ldap_configuration"]["ldapPassword"] == "":

            self.debug(
                "Please rerun the test by providing values in ldap configuration user details"
            )
            self.skipTest(
                "Please rerun the test by providing proper values in configuration file"
            )

        else:
            self.delflag = 1
            self.acctRes = self.apiClient.createAccount(self.acct)
        self.assertEquals(
            self.delflag, 1,
            "LDAP account details are not provided,please check the configuration"
        )
        return
Ejemplo n.º 4
0
    def setUp(self):

        self.apiClient = self.testClient.getApiClient()

        self.acct = createAccount.createAccountCmd()
        self.acct.accounttype = 0
        self.acct.firstname = self.services["configurableData"][
            "ldap_account"]["firstname"]
        self.acct.lastname = self.services["configurableData"]["ldap_account"][
            "lastname"]
        self.acct.password = self.services["configurableData"]["ldap_account"][
            "password"]
        self.acct.username = self.services["configurableData"]["ldap_account"][
            "username"]
        self.acct.email = self.services["configurableData"]["ldap_account"][
            "email"]
        self.acct.account = self.services["configurableData"]["ldap_account"][
            "username"]
        self.acct.domainid = 1

        self.acctRes = self.apiClient.createAccount(self.acct)

        return
Ejemplo n.º 5
0
    def setUp(self):

        self.apiClient = self.testClient.getApiClient()

        self.acct = createAccount.createAccountCmd()
        self.acct.accounttype = 0
        self.acct.firstname = self.services[
            "configurableData"]["ldap_account"]["firstname"]
        self.acct.lastname = self.services[
            "configurableData"]["ldap_account"]["lastname"]
        self.acct.password = self.services[
            "configurableData"]["ldap_account"]["password"]
        self.acct.username = self.services[
            "configurableData"]["ldap_account"]["username"]
        self.acct.email = self.services[
            "configurableData"]["ldap_account"]["email"]
        self.acct.account = self.services[
            "configurableData"]["ldap_account"]["username"]
        self.acct.domainid = 1

        self.acctRes = self.apiClient.createAccount(self.acct)

        return
Ejemplo n.º 6
0
    def setUpClass(cls):
        cls.spapi = spapi.Api.fromConfig(multiCluster=True)

        testClient = super(TestStoragePool, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.userapiclient = testClient.getUserApiClient(
            UserName="******", DomainName="ROOT")
        cls.unsupportedHypervisor = False
        cls.hypervisor = testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ("hyperv", "lxc"):
            cls.unsupportedHypervisor = True
            return

        cls.services = testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = None

        zones = list_zones(cls.apiclient)

        for z in zones:
            if z.internaldns1 == cls.getClsConfig().mgtSvr[0].mgtSvrIp:
                cls.zone = z

        storpool_primary_storage = {
            "name": "ssd",
            "zoneid": cls.zone.id,
            "url": "ssd",
            "scope": "zone",
            "capacitybytes": 4500000,
            "capacityiops": 155466464221111121,
            "hypervisor": "kvm",
            "provider": "StorPool",
            "tags": "ssd"
        }

        storpool_service_offerings = {
            "name": "ssd",
            "displaytext": "SP_CO_2 (Min IOPS = 10,000; Max IOPS = 15,000)",
            "cpunumber": 1,
            "cpuspeed": 500,
            "memory": 512,
            "storagetype": "shared",
            "customizediops": False,
            "hypervisorsnapshotreserve": 200,
            "tags": "ssd"
        }

        storage_pool = list_storage_pools(cls.apiclient, name='ssd')

        service_offerings = list_service_offering(cls.apiclient, name='ssd')

        disk_offerings = list_disk_offering(cls.apiclient, name="Small")

        cls.disk_offerings = disk_offerings[0]
        if storage_pool is None:
            storage_pool = StoragePool.create(cls.apiclient,
                                              storpool_primary_storage)
        else:
            storage_pool = storage_pool[0]
        cls.storage_pool = storage_pool
        cls.debug(pprint.pformat(storage_pool))
        if service_offerings is None:
            service_offerings = ServiceOffering.create(
                cls.apiclient, storpool_service_offerings)
        else:
            service_offerings = service_offerings[0]

        template = get_template(cls.apiclient, cls.zone.id, account="system")

        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["small"]["zoneid"] = cls.zone.id
        cls.services["templates"]["ostypeid"] = template.ostypeid
        cls.services["zoneid"] = cls.zone.id

        cls.service_offering = service_offerings

        user = list_users(cls.apiclient,
                          account='StorPoolUser',
                          domainid=cls.domain.id)
        account = list_accounts(cls.apiclient, id=user[0].accountid)
        if account is None:
            role = Role.list(cls.apiclient, name='User')
            cmd = createAccount.createAccountCmd()
            cmd.email = '*****@*****.**'
            cmd.firstname = 'StorPoolUser'
            cmd.lastname = 'StorPoolUser'

            cmd.password = '******'
            cmd.username = '******'
            cmd.roleid = role[0].id
            account = cls.apiclient.createAccount(cmd)
        else:
            account = account[0]

        cls.account = account

        #         cls.tmp_files = []
        #         cls.keypair = SSHKeyPair.create(
        #                                     cls.apiclient,
        #                                     name=random_gen() + ".pem",
        #                                     account=cls.account.name,
        #                                     domainid=cls.account.domainid)
        #
        #         keyPairFilePath = tempfile.gettempdir() + os.sep + cls.keypair.name
        #         # Clenaup at end of execution
        #         cls.tmp_files.append(keyPairFilePath)
        #
        #         cls.debug("File path: %s" % keyPairFilePath)
        #
        #         f = open(keyPairFilePath, "w+")
        #         f.write(cls.keypair.privatekey)
        #         f.close()
        #
        #         os.system("chmod 400 " + keyPairFilePath)
        #
        #         cls.keyPairFilePath = keyPairFilePath

        cls.volume_1 = Volume.create(
            cls.userapiclient,
            {"diskname": "StorPoolDisk-1"},
            zoneid=cls.zone.id,
            diskofferingid=cls.disk_offerings.id,
        )
        cls.volume_2 = Volume.create(
            cls.userapiclient,
            {"diskname": "StorPoolDisk-2"},
            zoneid=cls.zone.id,
            diskofferingid=cls.disk_offerings.id,
        )
        cls.volume = Volume.create(
            cls.userapiclient,
            {"diskname": "StorPoolDisk-3"},
            zoneid=cls.zone.id,
            diskofferingid=cls.disk_offerings.id,
        )
        cls.virtual_machine = VirtualMachine.create(
            cls.userapiclient,
            {"name": "StorPool-%s" % uuid.uuid4()},
            zoneid=cls.zone.id,
            templateid=template.id,
            serviceofferingid=cls.service_offering.id,
            hypervisor=cls.hypervisor,
            rootdisksize=10,
        )
        cls.virtual_machine2 = VirtualMachine.create(
            cls.userapiclient,
            {"name": "StorPool-%s" % uuid.uuid4()},
            zoneid=cls.zone.id,
            templateid=template.id,
            serviceofferingid=cls.service_offering.id,
            hypervisor=cls.hypervisor,
            rootdisksize=10,
        )
        cls.template = template
        cls.random_data_0 = random_gen(size=100)
        cls.test_dir = "/tmp"
        cls.random_data = "random.data"
        cls._cleanup = []
        cls._cleanup.append(cls.virtual_machine)
        cls._cleanup.append(cls.virtual_machine2)
        cls._cleanup.append(cls.volume_1)
        cls._cleanup.append(cls.volume_2)
        cls._cleanup.append(cls.volume)
        return