Exemplo n.º 1
0
    def setUpClass(cls):
        cls.testClient = super(TestMaxProjectNetworks, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = Services().services
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.domain = get_domain(cls.api_client)
        cls.services['mode'] = cls.zone.networktype
        cls.template = get_template(
                            cls.api_client,
                            cls.zone.id,
                            cls.services["ostype"]
                            )
        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"]
                                            )
        cls.network_offering = NetworkOffering.create(
                                            cls.api_client,
                                            cls.services["network_offering"],
                                            conservemode=True
                                            )
        # Enable Network offering
        cls.network_offering.update(cls.api_client, state='Enabled')

        cls._cleanup = [
                        cls.service_offering,
                        cls.network_offering
                        ]
        return
    def setUpClass(cls):
        try:
            cls._cleanup = []
            cls.testClient = super(TestTemplates, cls).getClsTestClient()
            cls.api_client = cls.testClient.getApiClient()
            cls.services = cls.testClient.getParsedTestDataConfig()
            # Get Domain, Zone, Template
            cls.domain = get_domain(cls.api_client)
            cls.zone = get_zone(
                cls.api_client,
                cls.testClient.getZoneForTests())
            cls.template = get_template(
                cls.api_client,
                cls.zone.id,
                cls.services["ostype"]
            )
            cls.hypervisor = cls.testClient.getHypervisorInfo()
            cls.services['mode'] = cls.zone.networktype

            builtin_info = get_builtin_template_info(cls.api_client, cls.zone.id)
            cls.services["privatetemplate"]["url"] = builtin_info[0]
            cls.services["privatetemplate"]["hypervisor"] = builtin_info[1]
            cls.services["privatetemplate"]["format"] = builtin_info[2]
        except Exception as e:
            cls.tearDownClass()
            raise Exception("Warning: Exception in setup : %s" % e)
        return
Exemplo n.º 3
0
    def setUp(self):
        self.testdata = TestData().testdata
        self.apiclient = self.testClient.getApiClient()

        # Get Zone, Domain and Default Built-in template
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.testdata["mode"] = self.zone.networktype
        self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])

        #create a user account
        self.account = Account.create(
            self.apiclient,
            self.testdata["account"],
            domainid=self.domain.id
        )
        #create a service offering
        self.service_offering = ServiceOffering.create(
            self.apiclient,
            self.testdata["service_offering"]["small"]
        )
        #build cleanup list
        self.cleanup = [
            self.service_offering,
            self.account
        ]
    def setUpClass(cls):
        testClient = super(TestSameVMName, 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, testClient.getZoneForTests())

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

        cls._cleanup = []

        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
        try:
            cls.skiptest = False

            if cls.hypervisor.lower() not in ['vmware']:
                cls.skiptest = True

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

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

            cls.userapiclient_2 = testClient.getUserApiClient(
                UserName=cls.account_2.name,
                DomainName=cls.account_2.domain
            )
           # Create Service offering
            cls.service_offering = ServiceOffering.create(
                cls.apiclient,
                cls.testdata["service_offering"],
            )

            cls._cleanup = [
                cls.account_1,
                cls.account_2,
                cls.service_offering,
            ]
        except Exception as e:
            cls.tearDownClass()
            raise e
        return
    def setUpClass(cls):
        testClient = super(TestConcurrentSnapshotLimit, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.hypervisor = cls.testClient.getHypervisorInfo()

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

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

        cls._cleanup = []
        cls.supportedHypervisor = True

        if cls.hypervisor.lower() in [
                "hyperv",
                "lxc"]:
            cls.supportedHypervisor = False
            return

        # Create Service offering
        cls.service_offering = ServiceOffering.create(
            cls.apiclient,
            cls.testdata["service_offering"],
        )
        cls._cleanup.append(cls.service_offering)
        return
Exemplo n.º 6
0
    def setUpClass(cls):
        cls.testClient = super(TestVPC, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
        cls.unsupportedHypervisor = False
        if cls.hypervisor.lower() == 'hyperv':
            cls._cleanup = []
            cls.unsupportedHypervisor = True
            return
        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.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.services["service_offering"]
        )
        cls.vpc_off = VpcOffering.create(
            cls.api_client,
            cls.services["vpc_offering"]
        )
        cls.vpc_off.update(cls.api_client, state='Enabled')
        cls._cleanup = [
            cls.service_offering,
        ]
        return
    def setUpClass(cls):

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

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.pod = get_pod(
            cls.api_client,
            zone_id=cls.zone.id
        )
        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['lxc']:
            raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.services["service_offering"],
            offerha=True
        )
        cls._cleanup = [
            cls.service_offering,
        ]
        return
    def setUpClass(cls):
        # We want to fail quicker if it's failure
        socket.setdefaulttimeout(60)

        cls.testClient = super(TestVPCNetworkPFRules, 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.template = get_template(
                                    cls.api_client,
                                    cls.zone.id,
                                    cls.services["ostype"]
                                    )
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
                                                        cls.api_client,
                                                        cls.services["service_offering"]
                                                        )
        cls._cleanup = [cls.service_offering]
        return
Exemplo n.º 9
0
    def setUpClass(cls):

        cls.testClient = super(TestAffinityRules, 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.template = get_template(
                                    cls.api_client,
                                    cls.zone.id,
                                    cls.services["ostype"]
                            )

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"],
                                            offerha=True
                                            )

        cls.account = Account.create(
                                     cls.api_client,
                                     cls.services["account"],
                                     domainid=cls.domain.id
                                     )
        cls._cleanup = [cls.account]
        return
Exemplo n.º 10
0
 def setUpClass(cls):
     try:
         cls._cleanup = []
         cls.testClient = super(TestIsos, cls).getClsTestClient()
         cls.api_client = cls.testClient.getApiClient()
         cls.services = cls.testClient.getParsedTestDataConfig()
         # Get Domain, Zone, Template
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
                             cls.services["ostype"]
                             )
         cls.hypervisor = cls.testClient.getHypervisorInfo()
         cls.services['mode'] = cls.zone.networktype
         cls.account = Account.create(
                             cls.api_client,
                             cls.services["account"],
                             domainid=cls.domain.id
                             )
         # Getting authentication for user in newly created Account
         cls.user = cls.account.user[0]
         cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
         cls._cleanup.append(cls.account)
     except Exception as e:
         cls.tearDownClass()
         raise Exception("Warning: Exception in setup : %s" % e)
     return
    def setUpClass(cls):
        cloudstackTestClient = super(TestProjectsVolumeLimits,
                               cls).getClsTestClient()
        cls.api_client = cloudstackTestClient.getApiClient()
        # 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.template = get_template(
                            cls.api_client,
                            cls.zone.id,
                            cls.services["ostype"]
                            )

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["volume"]["zoneid"] = cls.zone.id
        cls._cleanup = []
        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):
        testClient = super(TestDeployVmWithUserData, cls).getClsTestClient()
        cls.apiClient = testClient.getApiClient() 
        cls.services = testClient.getParsedTestDataConfig()

        cls.zone = get_zone(cls.apiClient, testClient.getZoneForTests())
        if cls.zone.localstorageenabled:
            #For devcloud since localstroage is enabled
            cls.services["service_offerings"]["storagetype"] = "local"
        cls.service_offering = ServiceOffering.create(
            cls.apiClient,
            cls.services["service_offerings"]
        )
        cls.account = Account.create(cls.apiClient, services=cls.services["account"])
        cls.cleanup = [cls.account]
        cls.template = get_template(
            cls.apiClient,
            cls.zone.id,
            cls.services["ostype"]
        )

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

        cls.debug("Successfully created account: %s, id: \
                   %s" % (cls.account.name,\
                          cls.account.id))


        # Generate userdata of 2500 bytes. This is larger than the 2048 bytes limit.
        # CS however allows for upto 4K bytes in the code. So this must succeed.
        # Overall, the query length must not exceed 4K, for then the json decoder
        # will fail this operation at the marvin client side itcls.
        user_data = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500))
        cls.services["virtual_machine"]["userdata"] = user_data
Exemplo n.º 13
0
    def setUpClass(cls):
        cls.testClient = super(TestCreateTemplate, 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() in ['lxc']:
            raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"]
                                            )
        cls.account = Account.create(
                            cls.api_client,
                            cls.services["account"],
                            domainid=cls.domain.id
                            )
        cls.services["account"] = cls.account.name

        cls._cleanup = [
                        cls.account,
                        cls.service_offering
                        ]
        return
Exemplo n.º 14
0
    def setUpClass(cls):
        cls.testClient = super(TestMemoryLimits, 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.template = get_template(
                            cls.api_client,
                            cls.zone.id,
                            cls.services["ostype"]
                            )

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"]
                                            )

        cls._cleanup = [cls.service_offering, ]
        return
Exemplo n.º 15
0
    def setUpClass(cls):
        cls.testClient = super(TestCreateSnapshot, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['hyperv', 'lxc']:
            raise unittest.SkipTest("Snapshots feature is not supported on %s" % cls.hypervisor.lower())
        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.template = get_template(
                            cls.api_client,
                            cls.zone.id,
                            cls.services["ostype"]
                            )

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        # Create VMs, NAT Rules etc
        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"]
                                            )
        cls._cleanup = [
                        cls.service_offering,
                        ]
        return
Exemplo n.º 16
0
    def setUpClass(cls):
        cls.testClient = super(TestHAProxyStickyness, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()

        cls.services = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())

        cls.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"]
        )

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["service_offering"]["name"] = "Medium Instance"
        cls.services["service_offering"]["cpuspeed"] = "1024"
        cls.services["service_offering"]["memory"] = "1024"
        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.services["service_offering"]
        )
        cls._cleanup = [cls.service_offering, ]
        return
Exemplo n.º 17
0
    def setUpClass(cls):
        # We want to fail quicker if it's failure
        socket.setdefaulttimeout(60)

        cls.testClient = super(TestVPCRedundancy, 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.template = get_template(
            cls.api_client,
            cls.zone.id,
            cls.services["ostype"])
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.services["service_offering"])
        cls._cleanup = [cls.service_offering]

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

        return
Exemplo n.º 18
0
    def setUp(self):
        self.apiclient = self.testClient.getApiClient()

        self.testdata = self.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and Default Built-in template
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.testdata["mode"] = self.zone.networktype
        self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])

        if self.template == FAILED:
            self.fail("get_template() failed to return template with description %s" % self.testdata["ostype"])

        #create a user account
        self.account = Account.create(
            self.apiclient,
            self.testdata["account"],
            domainid=self.domain.id
        )
        #create a service offering
        self.service_offering = ServiceOffering.create(
            self.apiclient,
            self.testdata["service_offerings"]["small"]
        )
        #build cleanup list
        self.cleanup = [
            self.service_offering,
            self.account
        ]
Exemplo n.º 19
0
    def setUpClass(cls):

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

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.template = get_template(
                                    cls.api_client,
                                    cls.zone.id,
                                    cls.services["ostype"]
                            )

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"],
                                            offerha=True
                                            )

        cls.account = Account.create(
                                     cls.api_client,
                                     cls.services["account"],
                                     domainid=cls.domain.id
                                     )
        cls._cleanup = [cls.account]
        return
    def setUpClass(cls):
        cls.testClient = super(TestRedundantRouterNetworkCleanups, 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.template = get_template(
                            cls.api_client,
                            cls.zone.id,
                            cls.services["ostype"]
                            )
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id

        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"]
                                            )
        cls.network_offering = NetworkOffering.create(
                                            cls.api_client,
                                            cls.services["network_offering"],
                                            conservemode=True
                                            )
        # Enable Network offering
        cls.network_offering.update(cls.api_client, state='Enabled')

        cls._cleanup = [
                        cls.service_offering,
                        cls.network_offering,
                        ]
        return
    def setUpClass(cls):
        cloudstackTestClient = super(TestSecondaryStorageLimits, 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.hypervisor = cloudstackTestClient.getHypervisorInfo()

        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
        cls._cleanup = []
        try:
            cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
            if cls.service_offering == FAILED:
                raise Exception("Creating service offering failed")
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Exception in setup class: %s" % e)
        return
Exemplo n.º 22
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.º 23
0
 def setUp(self):
     self.apiclient = self.testClient.getApiClient()
     self.hypervisor = self.testClient.getHypervisorInfo()
     self.cleanup = []
     self.services = self.testClient.getParsedTestDataConfig()
     self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
     return
    def setUp(self):
        self.testdata = TestData().testdata
        self.apiclient = self.testClient.getApiClient()
        self.hypervisor = self.testClient.getHypervisorInfo()

        # Get Zone, Domain and Default Built-in template
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.testdata["mode"] = self.zone.networktype
        self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])
        if self.template == FAILED:
            assert False, "get_template() failed to return template "
#       for testing with specific template
#        self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"], templatetype='USER', services = {"template":'31f52a4d-5681-43f7-8651-ad4aaf823618'})
        

        #create a user account
        self.account = Account.create(
            self.apiclient,
            self.testdata["account"],
            domainid=self.domain.id
        )
        #create a service offering
        self.service_offering = ServiceOffering.create(
            self.apiclient,
            self.testdata["service_offering"]["small"]
        )
        #build cleanup list
        self.cleanup = [
            self.service_offering,
            self.account
        ]
Exemplo n.º 25
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.services["mode"] = cls.zone.networktype
        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.º 26
0
    def setUp(self):
        self.services = self.testClient.getParsedTestDataConfig()
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()
        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.services['mode'] = self.zone.networktype
        self.services["domainid"] = self.domain.id
        self.services["iso2"]["zoneid"] = self.zone.id

        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            domainid=self.domain.id
        )
        # Finding the OsTypeId from Ostype
        ostypes = list_os_types(
            self.apiclient,
            description=self.services["ostype"]
        )
        if not isinstance(ostypes, list):
            raise unittest.SkipTest("OSTypeId for given description not found")

        self.services["iso1"]["ostypeid"] = ostypes[0].id
        self.services["iso2"]["ostypeid"] = ostypes[0].id
        self.services["ostypeid"] = ostypes[0].id

        self.cleanup = [self.account]
        return
Exemplo n.º 27
0
    def setUpClass(cls):
        cls.testClient = super(TestCreateTemplate, 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.services["virtual_machine"]["zoneid"] = cls.zone.id

        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"]
                                            )
        cls.account = Account.create(
                            cls.api_client,
                            cls.services["account"],
                            domainid=cls.domain.id
                            )
        cls.services["account"] = cls.account.name

        cls._cleanup = [
                        cls.account,
                        cls.service_offering
                        ]
        return
Exemplo n.º 28
0
    def setUpClass(cls):
        cls.testClient = super(TestMultipleChildDomains, cls).getClsTestClient()
        cls.api_client = cls.testClient.getApiClient()
        cls.testdata = cls.testClient.getParsedTestDataConfig()

        #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.testdata["mode"] = cls.zone.networktype

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

        # Create service, disk offerings  etc
        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.testdata["service_offering_multiple_cores"]
        )
        cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id

        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.testdata["service_offering_multiple_cores"]
                                            )
        cls._cleanup = []
        return
Exemplo n.º 29
0
    def setUpClass(cls):
        cls.testClient = super(TestCreateTemplate, 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.unsupportedHypervisor = False
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['lxc']:
            cls.unsupportedHypervisor = True
            return
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.services["service_offering"]
        )
        cls._cleanup.append(cls.service_offering)
        cls.account = Account.create(
            cls.api_client,
            cls.services["account"],
            domainid=cls.domain.id
        )
        cls._cleanup.append(cls.account)
        cls.services["account"] = cls.account.name
        return
Exemplo n.º 30
0
    def setUpClass(cls):

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

        cls.services = Services().services
        # Get Zone, Domain and templates
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.domain = get_domain(cls.api_client)

        cls.services['mode'] = cls.zone.networktype

        template = get_template(
                            cls.api_client,
                            cls.zone.id,
                            cls.services["ostype"]
                            )
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.account = Account.create(
                            cls.api_client,
                            cls.services["account"],
                            domainid=cls.domain.id
                            )

        cls.services["account"] = cls.account.name
        cls.service_offering = ServiceOffering.create(
                                            cls.api_client,
                                            cls.services["service_offering"],
                                        )

        # create virtual machine
        cls.virtual_machine = VirtualMachine.create(
                                    cls.api_client,
                                    cls.services["virtual_machine"],
                                    templateid=template.id,
                                    accountid=cls.account.name,
                                    domainid=cls.account.domainid,
                                    serviceofferingid=cls.service_offering.id,
                                    )
        #Stop virtual machine
        cls.virtual_machine.stop(cls.api_client)

        #Wait before server has be successfully stopped
        time.sleep(30)
        list_volume = Volume.list(
                                   cls.api_client,
                                   virtualmachineid=cls.virtual_machine.id,
                                   type='ROOT',
                                   listall=True
                                   )
        try:
            if isinstance(list_volume, list):
                cls.volume = list_volume[0]
        except Exception as e:
            raise Exception("Warning: Exception during setup : %s" % e)

        cls._cleanup = [
                        cls.service_offering,
                        cls.account,
                        ]
Exemplo n.º 31
0
    def setUpClass(cls):
        testClient = super(TestCopyDeleteTemplate, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls._cleanup = []
        cls.services = testClient.getParsedTestDataConfig()
        cls.unsupportedHypervisor = False
        cls.hypervisor = testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['lxc']:
            # Template creation from root volume is not supported in LXC
            cls.unsupportedHypervisor = True
            return

        # 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
        try:
            cls.disk_offering = DiskOffering.create(
                cls.apiclient, cls.services["disk_offering"])
            cls._cleanup.append(cls.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["template"]["ostypeid"] = template.ostypeid
            cls.services["template_2"]["ostypeid"] = template.ostypeid
            cls.services["ostypeid"] = template.ostypeid

            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["volume"]["diskoffering"] = cls.disk_offering.id
            cls.services["volume"]["zoneid"] = cls.zone.id
            cls.services["sourcezoneid"] = cls.zone.id
            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._cleanup.append(cls.service_offering)
            #create virtual machine
            cls.virtual_machine = VirtualMachine.create(
                cls.apiclient,
                cls.services["virtual_machine"],
                templateid=template.id,
                accountid=cls.account.name,
                domainid=cls.account.domainid,
                serviceofferingid=cls.service_offering.id,
                mode=cls.services["mode"])
            #Stop virtual machine
            cls.virtual_machine.stop(cls.apiclient)

            list_volume = Volume.list(cls.apiclient,
                                      virtualmachineid=cls.virtual_machine.id,
                                      type='ROOT',
                                      listall=True)

            cls.volume = list_volume[0]
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Exception in setUpClass: %s" % e)
        return
Exemplo n.º 32
0
    def setUpClass(cls):

        testClient = super(TestTemplates, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls._cleanup = []
        cls.services = testClient.getParsedTestDataConfig()
        cls.unsupportedHypervisor = False
        cls.hypervisor = testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ['lxc']:
            # Template creation from root volume is not supported in LXC
            cls.unsupportedHypervisor = True
            return

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype
        #populate second zone id for iso copy
        cls.zones = Zone.list(cls.apiclient)
        if not isinstance(cls.zones, list):
            raise Exception("Failed to find zones.")

        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["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["volume"]["diskoffering"] = cls.disk_offering.id
        cls.services["volume"]["zoneid"] = cls.zone.id
        cls.services["template_2"]["zoneid"] = cls.zone.id
        cls.services["sourcezoneid"] = cls.zone.id

        cls.services["template"]["ostypeid"] = template.ostypeid
        cls.services["template_2"]["ostypeid"] = template.ostypeid
        cls.services["ostypeid"] = template.ostypeid
        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     admin=True,
                                     domainid=cls.domain.id)
        cls.user = Account.create(cls.apiclient,
                                  cls.services["account"],
                                  domainid=cls.domain.id)
        cls.service_offering = ServiceOffering.create(
            cls.apiclient, cls.services["service_offerings"]["tiny"])
        #create virtual machine
        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.services["mode"])
        #Stop virtual machine
        cls.virtual_machine.stop(cls.apiclient)

        list_volume = Volume.list(cls.apiclient,
                                  virtualmachineid=cls.virtual_machine.id,
                                  type='ROOT',
                                  listall=True)
        try:
            cls.volume = list_volume[0]
        except Exception as e:
            raise Exception(
                "Exception: Unable to find root volume foe VM: %s - %s" %
                (cls.virtual_machine.id, e))

        #Create templates for Edit, Delete & update permissions testcases
        cls.template_1 = Template.create(cls.apiclient,
                                         cls.services["template"],
                                         cls.volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)
        cls.template_2 = Template.create(cls.apiclient,
                                         cls.services["template_2"],
                                         cls.volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)
        cls._cleanup = [
            cls.service_offering, cls.disk_offering, cls.account, cls.user
        ]
Exemplo n.º 33
0
    def setUpClass(cls):
        testClient = super(TestPublicIP, 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
        # Create Accounts & networks
        cls.account = Account.create(
            cls.apiclient,
            cls.services["account"],
            admin=True,
            domainid=cls.domain.id
        )

        cls.user = Account.create(
            cls.apiclient,
            cls.services["account"],
            domainid=cls.domain.id
        )
        cls.services["network"]["zoneid"] = cls.zone.id

        cls.network_offering = NetworkOffering.create(
            cls.apiclient,
            cls.services["network_offering"],
        )
        # Enable Network offering
        cls.network_offering.update(cls.apiclient, state='Enabled')

        cls.services["network"]["networkoffering"] = cls.network_offering.id
        cls.account_network = Network.create(
            cls.apiclient,
            cls.services["network"],
            cls.account.name,
            cls.account.domainid
        )
        cls.user_network = Network.create(
            cls.apiclient,
            cls.services["network"],
            cls.user.name,
            cls.user.domainid
        )

        # Create Source NAT IP addresses
        PublicIPAddress.create(
            cls.apiclient,
            cls.account.name,
            cls.zone.id,
            cls.account.domainid
        )
        PublicIPAddress.create(
            cls.apiclient,
            cls.user.name,
            cls.zone.id,
            cls.user.domainid
        )
        cls._cleanup = [
            cls.account_network,
            cls.user_network,
            cls.account,
            cls.user,
            cls.network_offering
        ]
        return
Exemplo n.º 34
0
    def setUp(self):

        self.apiclient = self.testClient.getApiClient()
        self.services = self.testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.hypervisor = self.testClient.getHypervisorInfo()
        template = get_test_template(
            self.apiclient,
            self.zone.id,
            self.hypervisor
        )
        self.services["virtual_machine"]["zoneid"] = self.zone.id

        # Create an account, network, VM and IP addresses
        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            admin=True,
            domainid=self.domain.id
        )
        self.service_offering = ServiceOffering.create(
            self.apiclient,
            self.services["service_offerings"]["tiny"]
        )
        self.vm_1 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id
        )

        src_nat_ip_addrs = list_publicIP(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid
        )

        try:
            src_nat_ip_addr = src_nat_ip_addrs[0]
        except Exception as e:
            self.fail("SSH failed for VM with IP: %s %s" %
                      (src_nat_ip_addr.ipaddress, e))

        self.lb_rule = LoadBalancerRule.create(
            self.apiclient,
            self.services["lbrule"],
            src_nat_ip_addr.id,
            self.account.name
        )
        self.lb_rule.assign(self.apiclient, [self.vm_1])

        self.nat_rule = NATRule.create(
            self.apiclient,
            self.vm_1,
            self.services["natrule"],
            src_nat_ip_addr.id
        )
        self.cleanup = []
        return
Exemplo n.º 35
0
    def setUpClass(cls):
        # Set up API client
        testclient = super(TestVMSnapshots, cls).getClsTestClient()
        cls.apiClient = testclient.getApiClient()

        cls.testdata = TestData().testdata

        # Set up XenAPI connection
        host_ip = "https://" + \
                  list_hosts(cls.apiClient, clusterid=cls.testdata[TestData.clusterId], name="XenServer-6.5-1")[0].ipaddress

        cls.xen_session = XenAPI.Session(host_ip)

        xenserver = cls.testdata[TestData.xenServer]

        cls.xen_session.xenapi.login_with_password(xenserver[TestData.username], xenserver[TestData.password])

        # Set up SolidFire connection
        cls.sf_client = sf_api.SolidFireAPI(endpoint_dict=cls.testdata[TestData.solidFire])

        # Get Resources from Cloud Infrastructure
        cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId])
        template = get_template(cls.apiClient, cls.zone.id, template_name=cls.testdata[TestData.templateName])
        cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId])

        # Create test account
        cls.account = Account.create(
            cls.apiClient,
            cls.testdata[TestData.account],
            admin=1
        )

        # Set up connection to make customized API calls
        user = User.create(
            cls.apiClient,
            cls.testdata[TestData.user],
            account=cls.account.name,
            domainid=cls.domain.id
        )

        url = cls.testdata[TestData.url]

        api_url = "http://" + url + ":8080/client/api"
        userkeys = User.registerUserKeys(cls.apiClient, user.id)

        cls.cs_api = SignedAPICall.CloudStack(api_url, userkeys.apikey, userkeys.secretkey)

        primarystorage = cls.testdata[TestData.primaryStorage]

        cls.primary_storage = StoragePool.create(
            cls.apiClient,
            primarystorage,
            scope=primarystorage[TestData.scope],
            zoneid=cls.zone.id,
            provider=primarystorage[TestData.provider],
            tags=primarystorage[TestData.tags],
            capacityiops=primarystorage[TestData.capacityIops],
            capacitybytes=primarystorage[TestData.capacityBytes],
            hypervisor=primarystorage[TestData.hypervisor]
        )

        compute_offering = ServiceOffering.create(
            cls.apiClient,
            cls.testdata[TestData.computeOffering]
        )

        cls.disk_offering = DiskOffering.create(
            cls.apiClient,
            cls.testdata[TestData.diskOffering]
        )

        # Create VM and volume for tests
        cls.virtual_machine = VirtualMachine.create(
            cls.apiClient,
            cls.testdata[TestData.virtualMachine],
            accountid=cls.account.name,
            zoneid=cls.zone.id,
            serviceofferingid=compute_offering.id,
            templateid=template.id,
            domainid=cls.domain.id,
            startvm=True
        )

        cls._cleanup = [
            cls.virtual_machine,
            compute_offering,
            cls.disk_offering,
            user,
            cls.account
        ]
    def setUpClass(cls):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        # We want to fail quicker if it's failure
        socket.setdefaulttimeout(60)

        cls.testClient = super(TestRouterIpTablesPolicies,
                               cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()

        cls.services = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.template = get_template(cls.apiclient, cls.zone.id)
        cls.services["vpc"]["cidr"] = '10.1.1.1/16'
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id
        cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected",
                         cls.network_offering.name)

        cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     admin=True,
                                     domainid=cls.domain.id)
        cls.vpc1 = VPC.create(cls.apiclient,
                              cls.services['vpcs']['vpc1'],
                              vpcofferingid=cls.vpc_offering.id,
                              zoneid=cls.zone.id,
                              domainid=cls.domain.id,
                              account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name,
                         cls.vpc1.cidr)

        cls.network1 = Network.create(
            cls.apiclient,
            cls.services['networks']['network1'],
            networkofferingid=cls.network_offering.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc1.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s",
                         cls.network1.name, cls.network1.cidr,
                         cls.network1.gateway)

        cls.service_offering = get_default_virtual_machine_offering(
            cls.apiclient)

        cls.entity_manager = EntityManager(cls.apiclient, cls.services,
                                           cls.service_offering, cls.account,
                                           cls.zone, cls.network1, cls.logger)

        cls._cleanup = [cls.account]
        return
Exemplo n.º 37
0
    def setUpClass(cls):
        cls.testClient = super(TestDeployVMFromISOWithUefi,
                               cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()

        cls.hypervisor = cls.testClient.getHypervisorInfo()

        if cls.hypervisor != 'kvm':
            raise unittest.SkipTest(
                "Those tests can be run only for KVM hypervisor")

        cls.testdata = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())

        hosts = list_hosts(cls.apiclient, zoneid=cls.zone.id, type="Routing")

        if not cls.isUefiEnabledOnAtLeastOnHost(hosts):
            raise unittest.SkipTest("At least one host should support UEFI")

        cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][
            0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__

        # Create service, disk offerings  etc
        cls.service_offering = ServiceOffering.create(
            cls.apiclient, cls.testdata["service_offering"])

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

        cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id
        cls.testdata["iso1"]["zoneid"] = cls.zone.id
        cls.testdata["iso3"]["zoneid"] = cls.zone.id
        cls.account = Account.create(cls.apiclient,
                                     cls.testdata["account"],
                                     domainid=cls.domain.id)
        cls._cleanup = [cls.account, cls.service_offering, cls.disk_offering]

        cls.centos_iso = Iso.create(cls.apiclient,
                                    cls.testdata["iso1"],
                                    account=cls.account.name,
                                    domainid=cls.account.domainid,
                                    zoneid=cls.zone.id)
        try:
            # Download the ISO
            cls.centos_iso.download(cls.apiclient)
        except Exception as e:
            raise Exception("Exception while downloading ISO %s: %s" %
                            (cls.centos_iso.id, e))

        cls.windows_iso = Iso.create(cls.apiclient,
                                     cls.testdata["iso3"],
                                     account=cls.account.name,
                                     domainid=cls.account.domainid,
                                     zoneid=cls.zone.id)
        try:
            # Download the ISO
            cls.windows_iso.download(cls.apiclient)
        except Exception as e:
            raise Exception("Exception while downloading ISO %s: %s" %
                            (cls.windows_iso.id, e))

        return
    def setUp(self):
        self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"]
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()
        if self.noSuitableHost or self.unsupportedHypervisor:
            self.hypervisor = get_hypervisor_type(self.apiclient)
            if self.hypervisor.lower() not in ["vmware"]:
                self.skipTest(
                    "Skipping test because suitable hypervisor/host not\
        	            present")
            self.testdata = self.testClient.getParsedTestDataConfig()

        self.cleanup = []

        # Get Zone, Domain and Default Built-in template
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        # Creating Account
        self.account = Account.create(self.apiclient,
                                      self.testdata["account"],
                                      domainid=self.domain.id)

        if self.hypervisor.lower() in ["xenserver"]:

            # Before running this test for Xen Server, register a windows template with ostype as
            # 'Windows 7 (32-bit)'
            self.template = get_template(self.apiclient, self.zone.id,
                                         self.testdata["ostype"])
            self.cleanup.append(self.template)

            self.testdata["mode"] = self.zone.networktype

            if self.template == FAILED:
                assert False, "get_template() failed to return template with description %s" % self.testdata[
                    "ostype"]

            self.testdata["small"]["zoneid"] = self.zone.id
            self.testdata["small"]["template"] = self.template.id

            self.testdata["service_offerings"]["vgpu260qwin"][
                "serviceofferingdetails"] = [{
                    'pciDevice':
                    'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'
                }, {
                    'vgpuType': 'GRID K120Q'
                }]
            # create a service offering
            self.service_offering = ServiceOffering.create(
                self.apiclient,
                self.testdata["service_offerings"]["vgpu260qwin"],
            )
            self.cleanup.append(self.service_offering)

        elif self.hypervisor.lower() in ["vmware"]:
            self.testdata["isolated_network"]["zoneid"] = self.zone.id

            self.userapiclient = self.testClient.getUserApiClient(
                UserName=self.account.name, DomainName=self.account.domain)
            self.service_offering = ServiceOffering.create(
                self.apiclient, self.testdata["service_offering"])

            # Create Shared Network Offering
            self.isolated_network_offering = NetworkOffering.create(
                self.apiclient, self.testdata["isolated_network_offering"])
            # Enable Isolated Network offering
            self.isolated_network_offering.update(self.apiclient,
                                                  state='Enabled')

            # Register a private template in the account with nic adapter vmxnet3
            # Also add required 3D GPU details for enabling it
            self.template = Template.register(
                self.userapiclient,
                self.testdata["configurableData"]["vmxnet3template"],
                zoneid=self.zone.id,
                account=self.account.name,
                domainid=self.account.domainid,
                details=[{
                    "mks.enable3d": "true",
                    "mks.use3dRenderer": "automatic",
                    "svga.autodetect": "false",
                    "svga.vramSize": "131072"
                }])
Exemplo n.º 39
0
    def setUpClass(cls):
        testClient = super(TestScaleVm, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][
            0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__
        cls._cleanup = []
        cls.unsupportedHypervisor = False
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        if cls.hypervisor.lower() in ('kvm', 'hyperv', 'lxc'):
            cls.unsupportedHypervisor = True
            return

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

        if cls.hypervisor.lower() in ['simulator', 'vmware']:
            cls.template = get_template(cls.apiclient, cls.zone.id,
                                        cls.services["ostype"])
            if cls.template == FAILED:
                assert False, "get_template() failed to return template\
                        with description %s" % cls.services["ostype"]
            cls.template = Template.update(cls.template,
                                           cls.apiclient,
                                           isdynamicallyscalable='true')
        else:
            cls.template = Template.register(cls.apiclient,
                                             cls.services["CentOS7template"],
                                             zoneid=cls.zone.id)
            cls._cleanup.append(cls.template)
            cls.template.download(cls.apiclient)
            time.sleep(60)

        # Set Zones and disk offerings
        cls.services["small"]["zoneid"] = cls.zone.id
        cls.services["small"]["template"] = cls.template.id

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

        cls.small_offering = ServiceOffering.create(
            cls.apiclient, cls.services["service_offerings"]["small"])
        cls._cleanup.append(cls.small_offering)

        cls.big_offering = ServiceOffering.create(
            cls.apiclient, cls.services["service_offerings"]["big"])
        cls._cleanup.append(cls.big_offering)

        Configurations.update(cls.apiclient,
                              name="enable.dynamic.scale.vm",
                              value="true")

        cls.small_offering_dynamic_scaling_disabled = ServiceOffering.create(
            cls.apiclient,
            cls.services["service_offerings"]["small"],
            dynamicscalingenabled=False)

        cls.big_offering_dynamic_scaling_disabled = ServiceOffering.create(
            cls.apiclient,
            cls.services["service_offerings"]["small"],
            dynamicscalingenabled=False)

        # create a virtual machine
        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.small_offering.id,
            mode=cls.services["mode"])

        # create a virtual machine which cannot be dynamically scalable
        cls.virtual_machine_with_service_offering_dynamic_scaling_disabled = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.small_offering_dynamic_scaling_disabled.id,
            mode=cls.services["mode"])

        # create a virtual machine which cannot be dynamically scalable
        cls.virtual_machine_not_dynamically_scalable = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.small_offering.id,
            mode=cls.services["mode"],
            dynamicscalingenabled=False)

        cls._cleanup = [
            cls.small_offering, cls.big_offering,
            cls.small_offering_dynamic_scaling_disabled,
            cls.big_offering_dynamic_scaling_disabled, cls.account
        ]
Exemplo n.º 40
0
    def setUpClass(cls):
        testClient = super(TestVmSnapshot, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls._cleanup = []
        cls.unsupportedHypervisor = False
        cls.hypervisor = testClient.getHypervisorInfo()
        if cls.hypervisor.lower() != "kvm":
            cls.unsupportedHypervisor = True
            return

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

        hosts = Host.list(cls.apiclient,
                          zoneid=cls.zone.id,
                          type='Routing',
                          hypervisor='KVM')

        pools = StoragePool.list(cls.apiclient, zoneid=cls.zone.id)

        for pool in pools:
            if pool.type == "NetworkFilesystem" or pool.type == "Filesystem":
                raise unittest.SkipTest(
                    "Storage-based snapshots functionality is not supported for NFS/Local primary storage"
                )

        for host in hosts:
            if host.details['Host.OS'] in ['CentOS']:
                raise unittest.SkipTest(
                    "The standard `qemu-kvm` which is the default for CentOS does not support the new functionality. It has to be installed `qemu-kvm-ev`"
                )

        Configurations.update(cls.apiclient,
                              name="kvm.vmstoragesnapshot.enabled",
                              value="true")
        #The version of CentOS has to be supported
        templ = {
            "name": "CentOS8",
            "displaytext": "CentOS 8",
            "format": "QCOW2",
            "url":
            "http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.qcow2.bz2",
            "ispublic": "True",
            "isextractable": "True",
            "hypervisor": cls.hypervisor,
            "zoneid": cls.zone.id,
            "ostype": "CentOS 8",
            "directdownload": True,
        }

        template = Template.register(cls.apiclient,
                                     templ,
                                     zoneid=cls.zone.id,
                                     hypervisor=cls.hypervisor)
        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.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     domainid=cls.domain.id)
        cls._cleanup.append(cls.account)

        service_offerings_nfs = {
            "name": "nfs",
            "displaytext": "nfs",
            "cpunumber": 1,
            "cpuspeed": 500,
            "memory": 512,
            "storagetype": "shared",
            "customizediops": False,
        }

        cls.service_offering = ServiceOffering.create(
            cls.apiclient,
            service_offerings_nfs,
        )

        cls._cleanup.append(cls.service_offering)

        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services,
            zoneid=cls.zone.id,
            templateid=template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.zone.networktype,
            hypervisor=cls.hypervisor,
            rootdisksize=20,
        )
        cls.random_data_0 = random_gen(size=100)
        cls.test_dir = "/tmp"
        cls.random_data = "random.data"
        return
    def setUpClass(cls):

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

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

        cls.services = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.api_client)
        cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
        cls.services['mode'] = cls.zone.networktype
        cls.template = get_template(cls.api_client, cls.zone.id,
                                    cls.services["ostype"])
        cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][
            0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        cls.logger.debug("Creating Admin Account for domain %s on zone %s" %
                         (cls.domain.id, cls.zone.id))
        # Create an account, network, VM and IP addresses
        cls.account = Account.create(cls.api_client,
                                     cls.services["account"],
                                     admin=True,
                                     domainid=cls.domain.id)

        cls.logger.debug("Creating Service Offering on zone %s" %
                         (cls.zone.id))
        cls.service_offering = ServiceOffering.create(
            cls.api_client, cls.services["service_offering"])

        cls.services["isolated_network_offering"]["egress_policy"] = "true"

        cls.logger.debug("Creating Network Offering on zone %s" %
                         (cls.zone.id))
        cls.network_offering = NetworkOffering.create(
            cls.api_client,
            cls.services["isolated_network_offering"],
            conservemode=True)

        cls.network_offering.update(cls.api_client, state='Enabled')

        cls.logger.debug("Creating Network for Account %s using offering %s" %
                         (cls.account.name, cls.network_offering.id))
        cls.network = Network.create(cls.api_client,
                                     cls.services["network"],
                                     accountid=cls.account.name,
                                     domainid=cls.account.domainid,
                                     networkofferingid=cls.network_offering.id,
                                     zoneid=cls.zone.id)

        cls.logger.debug(
            "Creating VM1 for Account %s using offering %s with IP 10.1.1.50" %
            (cls.account.name, cls.service_offering.id))
        cls.vm_1 = VirtualMachine.create(
            cls.api_client,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.domain.id,
            serviceofferingid=cls.service_offering.id,
            networkids=[str(cls.network.id)],
            ipaddress="10.1.1.50")

        cls.logger.debug(
            "Creating VM2 for Account %s using offering %s with IP 10.1.1.51" %
            (cls.account.name, cls.service_offering.id))
        cls.vm_2 = VirtualMachine.create(
            cls.api_client,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.domain.id,
            serviceofferingid=cls.service_offering.id,
            networkids=[str(cls.network.id)],
            ipaddress="10.1.1.51")

        cls.services["natrule1"] = {
            "privateport": 22,
            "publicport": 222,
            "protocol": "TCP"
        }

        cls.services["natrule2"] = {
            "privateport": 22,
            "publicport": 223,
            "protocol": "TCP"
        }

        cls.services["configurableData"] = {
            "host": {
                "port": 22
            },
            "input": "INPUT",
            "forward": "FORWARD"
        }

        cls._cleanup = [
            cls.vm_2, cls.network, cls.network_offering, cls.service_offering,
            cls.account
        ]

        return
Exemplo n.º 42
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.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_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.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 = [
                        cls.service_offering,
                        cls.disk_offering,
                        cls.custom_disk_offering,
                        cls.account
                        ]
Exemplo n.º 43
0
    def setUpClass(cls):
        cls._cleanup = []
        cls.testClient = super(TestBrocadeVcs, 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.template = get_template(cls.api_client, cls.zone.id,
                                    cls.services["ostype"])
        try:
            cls.brocadeDeviceData = cls.config.__dict__[
                "brocadeDeviceData"].__dict__
            assert cls.brocadeDeviceData[
                "ipaddress"], "ipaddress of brocade device\
                    not present in config file"

            assert cls.brocadeDeviceData[
                "username"], "username of brocade device\
                    not present in config file"

        except Exception as e:
            raise unittest.SkipTest("Exception occured while reading\
                    brocade device data from config file: %s" % e)
        try:
            """ Adds Brocade device and enables NS provider"""
            cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
            cmd.zoneid = cls.zone.id
            physical_networks = cls.api_client.listPhysicalNetworks(cmd)
            if isinstance(physical_networks, list):
                physical_network = physical_networks[0]
            cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
            cmd.name = 'BrocadeVcs'
            cmd.physicalnetworkid = physical_network.id
            nw_service_providers = cls.api_client.listNetworkServiceProviders(
                cmd)

            if isinstance(nw_service_providers, list):
                brocade_provider = nw_service_providers[0]
            else:
                cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
                cmd1.name = 'BrocadeVcs'
                cmd1.physicalnetworkid = physical_network.id
                brocade_provider = cls.api_client.addNetworkServiceProvider(
                    cmd1)

            cmd2 = addBrocadeVcsDevice.addBrocadeVcsDeviceCmd()
            cmd2.physicalnetworkid = physical_network.id
            cmd2.username = cls.brocadeDeviceData["username"]
            cmd2.password = cls.brocadeDeviceData["password"]
            cmd2.hostname = cls.brocadeDeviceData["ipaddress"]
            cls.brocade = cls.api_client.addBrocadeVcsDevice(cmd2)

            if brocade_provider.state != 'Enabled':
                cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd(
                )
                cmd.id = brocade_provider.id
                cmd.state = 'Enabled'
                cls.api_client.updateNetworkServiceProvider(cmd)

            cls.network_offering = NetworkOffering.create(
                cls.api_client,
                cls.services["network_offering"],
                conservemode=True)
            cls._cleanup.append(cls.network_offering)

            # Enable Network offering
            cls.network_offering.update(cls.api_client, state='Enabled')
            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["virtual_machine"]["template"] = cls.template.id
            cls.service_offering = ServiceOffering.create(
                cls.api_client, cls.services["service_offering"])
            cls._cleanup.append(cls.service_offering)
        except Exception as e:
            cls.tearDownClass()
            raise Exception("Warning: Exception in setUpClass: %s" % e)
        return
Exemplo n.º 44
0
    def setUpClass(cls):
        cls.logger = logging.getLogger('TestDeployVirtioSCSIVM')
        cls.stream_handler = logging.StreamHandler()
        cls.logger.setLevel(logging.DEBUG)
        cls.logger.addHandler(cls.stream_handler)

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

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

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.pod = get_pod(cls.apiclient, cls.zone.id)
        cls.services['mode'] = cls.zone.networktype
        cls._cleanup = []
        if cls.hypervisor.lower() not in ['kvm']:
            cls.hypervisorNotSupported = True
            return
        kvmvirtioscsi = Templates().templates["kvmvirtioscsi"]
        cls.template = Template.register(cls.apiclient,
                                         kvmvirtioscsi[cls.hypervisor.lower()],
                                         cls.zone.id,
                                         hypervisor=cls.hypervisor.lower(),
                                         domainid=cls.domain.id)
        cls.template.download(cls.apiclient)

        if cls.template == FAILED:
            assert False, "get_template() failed to return template"

        cls.services["domainid"] = cls.domain.id
        cls.services["small"]["zoneid"] = cls.zone.id
        cls.services["zoneid"] = cls.zone.id
        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     domainid=cls.domain.id)

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

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

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

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

        cls.vmhost = hosts[0]

        password = cls.virtual_machine.resetPassword(cls.apiclient)
        cls.virtual_machine.username = "******"
        cls.virtual_machine.password = password
        cls._cleanup = [
            cls.template, cls.service_offering, cls.sparse_disk_offering,
            cls.account
        ]
Exemplo n.º 45
0
    def setUp(self):
        self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"]
        self.apiclient = self.testClient.getApiClient()
        self.dbclient = self.testClient.getDbConnection()
        if self.noSuitableHost or self.unsupportedHypervisor:
            self.hypervisor = get_hypervisor_type(self.apiclient)
            if self.hypervisor.lower() not in ["vmware"]:
                self.skipTest(
                    "Skipping test because suitable hypervisor/host not\
        	            present")
            self.testdata = self.testClient.getParsedTestDataConfig()

        # Get Zone, Domain and Default Built-in template
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())

        # Before running this test for Xen Server, register a windows template with ostype as
        # 'Windows 7 (32-bit)'
        self.template = get_template(self.apiclient, self.zone.id,
                                     self.testdata["ostype"])

        # create a user account
        self.account = Account.create(self.apiclient,
                                      self.testdata["account"],
                                      domainid=self.domain.id)
        self.cleanup = []

        if self.hypervisor.lower() in ["xenserver"]:
            self.testdata["mode"] = self.zone.networktype

            if self.template == FAILED:
                assert False, "get_template() failed to return template with description %s" % self.testdata[
                    "ostype"]

            self.testdata["small"]["zoneid"] = self.zone.id
            self.testdata["small"]["template"] = self.template.id

            self.testdata["service_offerings"]["vgpu260qwin"][
                "serviceofferingdetails"] = [{
                    'pciDevice':
                    'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'
                }, {
                    'vgpuType': 'GRID K120Q'
                }]
            # create a service offering
            self.service_offering = ServiceOffering.create(
                self.apiclient,
                self.testdata["service_offerings"]["vgpu260qwin"],
            )
            # build cleanup list
            self.cleanup = [self.service_offering, self.account]
        elif self.hypervisor.lower() in ["vmware"]:
            self.testdata["isolated_network"]["zoneid"] = self.zone.id
            self.userapiclient = self.testClient.getUserApiClient(
                UserName=self.account.name, DomainName=self.account.domain)
            self.service_offering = ServiceOffering.create(
                self.apiclient, self.testdata["service_offering"])
            self.cleanup.append(self.service_offering)

            # Create Shared Network Offering
            self.isolated_network_offering = NetworkOffering.create(
                self.apiclient, self.testdata["isolated_network_offering"])
            self.cleanup.append(self.isolated_network_offering)
            # Enable Isolated Network offering
            self.isolated_network_offering.update(self.apiclient,
                                                  state='Enabled')
Exemplo n.º 46
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
                        ]
    def setUpClass(cls):
        testClient = super(TestAdvancedZoneStoppedVM, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.hypervisor = testClient.getHypervisorInfo()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient)
        cls._cleanup = []

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

            # If local storage is enabled, alter the offerings to use
            # localstorage
            if cls.zone.localstorageenable:
                cls.testdata["service_offering"]["storagetype"] = 'local'

            # Create 2 service offerings with different values for
            # for cpunumber, cpuspeed, and memory

            cls.testdata["service_offering"]["cpunumber"] = 1
            cls.testdata["service_offering"]["cpuspeed"] = 128
            cls.testdata["service_offering"]["memory"] = 256

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

            cls.testdata["service_offering"]["cpunumber"] = 2

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

            # Create isolated network offering
            cls.isolated_network_offering = CreateEnabledNetworkOffering(
                cls.apiclient, cls.testdata["isolated_network_offering"])
            cls._cleanup.append(cls.isolated_network_offering)

            cls.networkid = None
            if str(cls.zone.networktype).lower() == "advanced":
                cls.network = Network.create(
                    cls.apiclient,
                    cls.testdata["isolated_network"],
                    networkofferingid=cls.isolated_network_offering.id,
                    accountid=cls.account.name,
                    domainid=cls.account.domainid,
                    zoneid=cls.zone.id)
                cls.networkid = cls.network.id

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

            template = get_template(cls.apiclient, cls.zone.id,
                                    cls.testdata["ostype"])
            cls.defaultTemplateId = template.id
            # Set Zones and disk offerings

            # Check that we are able to login to the created account
            respose = User.login(cls.apiclient,
                                 username=cls.account.name,
                                 password=cls.testdata["account"]["password"])

            assert respose.sessionkey is not None, \
                "Login to the CloudStack should be successful\
                            response shall have non Null key"

        except Exception as e:
            cls.tearDownClass()
            raise e
        return
Exemplo n.º 48
0
    def setUpClass(cls):
        # Set up API client
        testclient = super(TestLinstorVolumes, cls).getClsTestClient()

        cls.apiClient = testclient.getApiClient()
        cls.configData = testclient.getParsedTestDataConfig()
        cls.dbConnection = testclient.getDbConnection()
        cls.testdata = TestData().testdata

        # Get Resources from Cloud Infrastructure
        cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId])
        cls.cluster = list_clusters(cls.apiClient)[0]
        cls.template = get_template(cls.apiClient, cls.zone.id, hypervisor=TestData.hypervisor_type)
        cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId])

        # Create test account
        cls.account = Account.create(
            cls.apiClient,
            cls.testdata["account"],
            admin=1
        )

        # Set up connection to make customized API calls
        cls.user = User.create(
            cls.apiClient,
            cls.testdata["user"],
            account=cls.account.name,
            domainid=cls.domain.id
        )

        primarystorage = cls.testdata[TestData.primaryStorage]

        cls.primary_storage = StoragePool.create(
            cls.apiClient,
            primarystorage,
            scope=primarystorage[TestData.scope],
            zoneid=cls.zone.id,
            provider=primarystorage[TestData.provider],
            tags=primarystorage[TestData.tags],
            hypervisor=primarystorage[TestData.hypervisor]
        )

        cls.compute_offering = ServiceOffering.create(
            cls.apiClient,
            cls.testdata[TestData.computeOffering]
        )

        cls.disk_offering = DiskOffering.create(
            cls.apiClient,
            cls.testdata[TestData.diskOffering]
        )

        if cls.testdata[TestData.migrationTests]:
            primarystorage_sameinst = cls.testdata[TestData.primaryStorageSameInstance]
            cls.primary_storage_same_inst = StoragePool.create(
                cls.apiClient,
                primarystorage_sameinst,
                scope=primarystorage_sameinst[TestData.scope],
                zoneid=cls.zone.id,
                provider=primarystorage_sameinst[TestData.provider],
                tags=primarystorage_sameinst[TestData.tags],
                hypervisor=primarystorage_sameinst[TestData.hypervisor]
            )

            primarystorage_distinctinst = cls.testdata[TestData.primaryStorageDistinctInstance]
            cls.primary_storage_distinct_inst = StoragePool.create(
                cls.apiClient,
                primarystorage_distinctinst,
                scope=primarystorage_distinctinst[TestData.scope],
                zoneid=cls.zone.id,
                provider=primarystorage_distinctinst[TestData.provider],
                tags=primarystorage_distinctinst[TestData.tags],
                hypervisor=primarystorage_distinctinst[TestData.hypervisor]
            )

            cls.disk_offering_same_inst = DiskOffering.create(
                cls.apiClient,
                cls.testdata[TestData.diskOfferingSameInstance]
            )

            cls.disk_offering_distinct_inst = DiskOffering.create(
                cls.apiClient,
                cls.testdata[TestData.diskOfferingDistinctInstance]
            )

        # Create VM and volume for tests
        cls.virtual_machine = VirtualMachine.create(
            cls.apiClient,
            cls.testdata[TestData.virtualMachine],
            accountid=cls.account.name,
            zoneid=cls.zone.id,
            serviceofferingid=cls.compute_offering.id,
            templateid=cls.template.id,
            domainid=cls.domain.id,
            startvm=False
        )

        TestLinstorVolumes._start_vm(cls.virtual_machine)

        cls.volume = Volume.create(
            cls.apiClient,
            cls.testdata[TestData.volume_1],
            account=cls.account.name,
            domainid=cls.domain.id,
            zoneid=cls.zone.id,
            diskofferingid=cls.disk_offering.id
        )

        # Resources that are to be destroyed
        cls._cleanup = [
            cls.volume,
            cls.virtual_machine,
            cls.compute_offering,
            cls.disk_offering,
            cls.user,
            cls.account
        ]
Exemplo n.º 49
0
    def setUpClass(cls):
        testClient = super(TestListIdsParams, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls.hypervisor = testClient.getHypervisorInfo()
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())

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

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

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

        cls.services["template"]["ostypeid"] = template.ostypeid
        cls.services["template_2"]["ostypeid"] = template.ostypeid
        cls.services["ostypeid"] = template.ostypeid
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["mode"] = cls.zone.networktype

        #Create 3 VMs
        cls.virtual_machine_1 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.services["mode"])
        cls.virtual_machine_2 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.services["mode"])
        cls.virtual_machine_3 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.services["mode"])

        #        Take 3 VM1 Snapshots
        #        PLEASE UNCOMMENT ONCE VM SNAPSHOT DELAY BUG AFTER VM CREATION IS FIXED
        #        cls.vmsnapshot_1 = VmSnapshot.create(
        #                                cls.apiclient,
        #                                cls.virtual_machine_1.id
        #                            )
        #        cls.vmsnapshot_2 = VmSnapshot.create(
        #                                cls.apiclient,
        #                                cls.virtual_machine_1.id
        #                            )
        #        cls.vmsnapshot_3 = VmSnapshot.create(
        #                                cls.apiclient,
        #                                cls.virtual_machine_1.id
        #                            )

        #Stop VMs
        cls.virtual_machine_1.stop(cls.apiclient)
        cls.virtual_machine_2.stop(cls.apiclient)
        cls.virtual_machine_3.stop(cls.apiclient)

        #Get ROOT volumes of 3 VMs
        vm1RootVolumeResponse = Volume.list(
            cls.apiclient,
            virtualmachineid=cls.virtual_machine_1.id,
            type='ROOT',
            listall=True)
        vm2RootVolumeResponse = Volume.list(
            cls.apiclient,
            virtualmachineid=cls.virtual_machine_2.id,
            type='ROOT',
            listall=True)
        vm3RootVolumeResponse = Volume.list(
            cls.apiclient,
            virtualmachineid=cls.virtual_machine_3.id,
            type='ROOT',
            listall=True)
        cls.vm1_root_volume = vm1RootVolumeResponse[0]
        cls.vm2_root_volume = vm2RootVolumeResponse[0]
        cls.vm3_root_volume = vm3RootVolumeResponse[0]

        #Take 3 snapshots of VM2's ROOT volume
        cls.snapshot_1 = Snapshot.create(cls.apiclient,
                                         cls.vm2_root_volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)
        cls.snapshot_2 = Snapshot.create(cls.apiclient,
                                         cls.vm2_root_volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)
        cls.snapshot_3 = Snapshot.create(cls.apiclient,
                                         cls.vm2_root_volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)

        #Create 3 templates
        cls.template_1 = Template.create(cls.apiclient,
                                         cls.services["template"],
                                         cls.vm3_root_volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)
        cls.template_2 = Template.create(cls.apiclient,
                                         cls.services["template_2"],
                                         cls.vm3_root_volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)
        cls.template_3 = Template.create(cls.apiclient,
                                         cls.services["template_2"],
                                         cls.vm3_root_volume.id,
                                         account=cls.account.name,
                                         domainid=cls.account.domainid)

        cls._cleanup = [
            cls.snapshot_3, cls.snapshot_2, cls.snapshot_1, cls.account,
            cls.disk_offering, cls.service_offering
        ]
Exemplo n.º 50
0
    def setUpClass(cls):
        try:
            cls._cleanup = []
            cls.testClient = super(TestSnapshots, cls).getClsTestClient()
            cls.api_client = cls.testClient.getApiClient()
            cls.services = cls.testClient.getParsedTestDataConfig()
            cls.hypervisor = cls.testClient.getHypervisorInfo()
            # Get Domain, Zone, Template
            cls.domain = get_domain(cls.api_client)
            cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
            cls.template = get_template(
                                cls.api_client,
                                cls.zone.id,
                                cls.services["ostype"]
                                )
            if cls.zone.localstorageenabled:
                cls.storagetype = 'local'
                cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
                cls.services["disk_offering"]["storagetype"] = 'local'
            else:
                cls.storagetype = 'shared'
                cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared'
                cls.services["disk_offering"]["storagetype"] = 'shared'

            cls.services['mode'] = cls.zone.networktype
            cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor
            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
            cls.services["virtual_machine"]["template"] = cls.template.id
            cls.services["custom_volume"]["zoneid"] = cls.zone.id
            # Creating Disk offering, Service Offering and Account
            cls.disk_offering = DiskOffering.create(
                                        cls.api_client,
                                        cls.services["disk_offering"]
                                        )
            cls._cleanup.append(cls.disk_offering)
            cls.service_offering = ServiceOffering.create(
                                                cls.api_client,
                                                cls.services["service_offerings"]["tiny"]
                                                )
            cls._cleanup.append(cls.service_offering)
            cls.account = Account.create(
                                cls.api_client,
                                cls.services["account"],
                                domainid=cls.domain.id
                                )
            # Getting authentication for user in newly created Account
            cls.user = cls.account.user[0]
            cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
            cls._cleanup.append(cls.account)
            # Creating Virtual Machine
            cls.virtual_machine = VirtualMachine.create(
                                        cls.userapiclient,
                                        cls.services["virtual_machine"],
                                        accountid=cls.account.name,
                                        domainid=cls.account.domainid,
                                        serviceofferingid=cls.service_offering.id,
                                    )
        except Exception as e:
            cls.tearDownClass()
            raise Exception("Warning: Exception in setup : %s" % e)
        return
    def setUpClass(cls):
        # Set up API client
        testclient = super(TestManagedClusteredFilesystems,
                           cls).getClsTestClient()

        cls.apiClient = testclient.getApiClient()
        cls.configData = testclient.getParsedTestDataConfig()
        cls.dbConnection = testclient.getDbConnection()

        cls.testdata = TestData().testdata

        sf_util.set_supports_resign(True, cls.dbConnection)

        cls._connect_to_hypervisor()

        # Set up SolidFire connection
        solidfire = cls.testdata[TestData.solidFire]

        cls.sfe = ElementFactory.create(solidfire[TestData.mvip],
                                        solidfire[TestData.username],
                                        solidfire[TestData.password])

        # Get Resources from Cloud Infrastructure
        cls.zone = get_zone(cls.apiClient,
                            zone_id=cls.testdata[TestData.zoneId])
        cls.template = get_template(cls.apiClient,
                                    cls.zone.id,
                                    hypervisor=TestData.hypervisor_type)
        cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId])

        # Create test account
        cls.account = Account.create(cls.apiClient,
                                     cls.testdata["account"],
                                     admin=1)

        # Set up connection to make customized API calls
        cls.user = User.create(cls.apiClient,
                               cls.testdata["user"],
                               account=cls.account.name,
                               domainid=cls.domain.id)

        url = cls.testdata[TestData.url]

        api_url = "http://" + url + ":8080/client/api"
        userkeys = User.registerUserKeys(cls.apiClient, cls.user.id)

        cls.cs_api = SignedAPICall.CloudStack(api_url, userkeys.apikey,
                                              userkeys.secretkey)

        primarystorage = cls.testdata[TestData.primaryStorage]

        cls.primary_storage = StoragePool.create(
            cls.apiClient,
            primarystorage,
            scope=primarystorage[TestData.scope],
            zoneid=cls.zone.id,
            provider=primarystorage[TestData.provider],
            tags=primarystorage[TestData.tags],
            capacityiops=primarystorage[TestData.capacityIops],
            capacitybytes=primarystorage[TestData.capacityBytes],
            hypervisor=primarystorage[TestData.hypervisor])

        cls.compute_offering = ServiceOffering.create(
            cls.apiClient, cls.testdata[TestData.computeOffering])

        # Resources that are to be destroyed
        cls._cleanup = [cls.compute_offering, cls.user, cls.account]
Exemplo n.º 52
0
    def setUpClass(cls):
        test_case = super(TestNiciraContoller, cls)

        test_client    = test_case.getClsTestClient()
        cls.config     = test_case.getClsConfig()
        cls.api_client = test_client.getApiClient()

        cls.physical_networks = cls.config.zones[0].physical_networks
        cls.nicira_hosts      = cls.config.niciraNvp.hosts

        cls.physical_network_id = cls.get_nicira_enabled_physical_network_id(cls.physical_networks)

        cls.network_offerring_services = {
            'name':              'NiciraEnabledNetwork',
            'displaytext':       'NiciraEnabledNetwork',
            'guestiptype':       'Isolated',
            'supportedservices': 'SourceNat,Firewall,PortForwarding,Connectivity',
            'traffictype':       'GUEST',
            'availability':      'Optional',
            'serviceProviderList': {
                    'SourceNat':      'VirtualRouter',
                    'Firewall':       'VirtualRouter',
                    'PortForwarding': 'VirtualRouter',
                    'Connectivity':   'NiciraNvp'
            }
        }

        cls.network_offering = NetworkOffering.create(cls.api_client, cls.network_offerring_services)
        cls.network_offering.update(cls.api_client, state='Enabled')

        cls.nicira_credentials = {
            'username': '******',
            'password': '******'
        }

        cls.nicira_master_controller = cls.determine_master_controller(
            cls.nicira_hosts,
            cls.nicira_credentials
        )

        cls.transport_zone_uuid = cls.get_transport_zone_from_controller(
            cls.nicira_master_controller,
            cls.nicira_credentials
        )

        cls.domain = get_domain(cls.api_client)
        cls.zone   = get_zone(cls.api_client, test_client.getZoneForTests())

        template = get_template(
            cls.api_client,
            cls.zone.id
        )
        if template == FAILED:
            raise Exception("get_template() failed to return template with description %s" % cls.services['ostype'])

        cls.vm_services = {
            'mode': cls.zone.networktype,
            'small': {
                'zoneid':      cls.zone.id,
                'template':    template.id,
                'displayname': 'testserver',
                'username':    cls.config.zones[0].pods[0].clusters[0].hosts[0].username,
                'password':    cls.config.zones[0].pods[0].clusters[0].hosts[0].password,
                'ssh_port':    22,
                'hypervisor':  cls.config.zones[0].pods[0].clusters[0].hypervisor,
                'privateport': 22,
                'publicport':  22,
                'protocol':    'TCP',
            },
            'service_offerings': {
                'tiny': {
                    'name':        'Tiny Instance',
                    'displaytext': 'Tiny Instance',
                    'cpunumber':   1,
                    'cpuspeed':    100,
                    'memory':      64,
                }
            }
        }

        if cls.zone.localstorageenabled == True:
            cls.vm_services['service_offerings']['tiny']['storagetype'] = 'local'

        cls.service_offering = ServiceOffering.create(
            cls.api_client,
            cls.vm_services['service_offerings']['tiny']
        )

        cls.cleanup = [
            cls.network_offering,
            cls.service_offering
        ]
Exemplo n.º 53
0
    def setUpClass(cls):
        cls.testClient = super(TestKubernetesCluster, cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()
        cls.services = cls.testClient.getParsedTestDataConfig()
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
        cls.cks_template_name_key = "cloud.kubernetes.cluster.template.name." + cls.hypervisor.lower(
        )

        cls.setup_failed = False

        cls.initial_configuration_cks_enabled = Configurations.list(
            cls.apiclient, name="cloud.kubernetes.service.enabled")[0].value
        if cls.initial_configuration_cks_enabled not in ["true", True]:
            cls.debug(
                "Enabling CloudStack Kubernetes Service plugin and restarting management server"
            )
            Configurations.update(cls.apiclient,
                                  "cloud.kubernetes.service.enabled", "true")
            cls.restartServer()

        cls.cks_template = None
        cls.initial_configuration_cks_template_name = None
        cls.cks_service_offering = None

        cls.kubernetes_version_ids = []
        if cls.setup_failed == False:
            try:
                cls.kuberetes_version_1 = cls.addKubernetesSupportedVersion(
                    '1.14.9',
                    'http://staging.yadav.xyz/cks/binaries-iso/setup-1.14.9.iso'
                )
                cls.kubernetes_version_ids.append(cls.kuberetes_version_1.id)
            except Exception as e:
                cls.setup_failed = True
                cls.debug(
                    "Failed to get Kubernetes version ISO in ready state, http://staging.yadav.xyz/cks/binaries-iso/setup-1.14.9.iso, %s"
                    % e)
        if cls.setup_failed == False:
            try:
                cls.kuberetes_version_2 = cls.addKubernetesSupportedVersion(
                    '1.15.0',
                    'http://staging.yadav.xyz/cks/binaries-iso/setup-1.15.0.iso'
                )
                cls.kubernetes_version_ids.append(cls.kuberetes_version_2.id)
            except Exception as e:
                cls.setup_failed = True
                cls.debug(
                    "Failed to get Kubernetes version ISO in ready state, http://staging.yadav.xyz/cks/binaries-iso/setup-1.15.0.iso, %s"
                    % e)
        if cls.setup_failed == False:
            try:
                cls.kuberetes_version_3 = cls.addKubernetesSupportedVersion(
                    '1.16.0',
                    'http://staging.yadav.xyz/cks/binaries-iso/setup-1.16.0.iso'
                )
                cls.kubernetes_version_ids.append(cls.kuberetes_version_3.id)
            except Exception as e:
                cls.setup_failed = True
                cls.debug(
                    "Failed to get Kubernetes version ISO in ready state, http://staging.yadav.xyz/cks/binaries-iso/setup-1.16.0.is, %s"
                    % e)
        if cls.setup_failed == False:
            try:
                cls.kuberetes_version_4 = cls.addKubernetesSupportedVersion(
                    '1.16.3',
                    'http://staging.yadav.xyz/cks/binaries-iso/setup-1.16.3.iso'
                )
                cls.kubernetes_version_ids.append(cls.kuberetes_version_4.id)
            except Exception as e:
                cls.setup_failed = True
                cls.debug(
                    "Failed to get Kubernetes version ISO in ready state, http://staging.yadav.xyz/cks/binaries-iso/setup-1.16.3.is, %s"
                    % e)

        cks_template_data = {
            "name": "Kubernetes-Service-Template",
            "displaytext": "Kubernetes-Service-Template",
            "format": "qcow2",
            "hypervisor": "kvm",
            "ostype": "CoreOS",
            "url":
            "http://staging.yadav.xyz/cks/templates/coreos_production_cloudstack_image-kvm.qcow2.bz2",
            "ispublic": "True",
            "isextractable": "True"
        }
        # "http://dl.openvm.eu/cloudstack/coreos/x86_64/coreos_production_cloudstack_image-kvm.qcow2.bz2"
        cks_template_data_details = []
        if cls.hypervisor.lower() == "vmware":
            cks_template_data[
                "url"] = "http://staging.yadav.xyz/cks/templates/coreos_production_cloudstack_image-vmware.ova"  # "http://dl.openvm.eu/cloudstack/coreos/x86_64/coreos_production_cloudstack_image-vmware.ova"
            cks_template_data["format"] = "OVA"
            cks_template_data_details = [{
                "keyboard": "us",
                "nicAdapter": "Vmxnet3",
                "rootDiskController": "pvscsi"
            }]
        elif cls.hypervisor.lower() == "xenserver":
            cks_template_data[
                "url"] = "http://staging.yadav.xyz/cks/templates/coreos_production_cloudstack_image-xen.vhd.bz2"  # "http://dl.openvm.eu/cloudstack/coreos/x86_64/coreos_production_cloudstack_image-xen.vhd.bz2"
            cks_template_data["format"] = "VHD"
        elif cls.hypervisor.lower() == "kvm":
            cks_template_data["requireshvm"] = "True"
        if cls.setup_failed == False:
            cls.cks_template = Template.register(
                cls.apiclient,
                cks_template_data,
                zoneid=cls.zone.id,
                hypervisor=cls.hypervisor,
                details=cks_template_data_details)
            cls.debug("Waiting for CKS template with ID %s to be ready" %
                      cls.cks_template.id)
            try:
                cls.waitForTemplateReadyState(cls.cks_template.id)
            except Exception as e:
                cls.setup_failed = True
                cls.debug(
                    "Failed to get CKS template in ready state, {}, {}".format(
                        cks_template_data["url"], e))

            cls.initial_configuration_cks_template_name = Configurations.list(
                cls.apiclient, name=cls.cks_template_name_key)[0].value
            Configurations.update(cls.apiclient, cls.cks_template_name_key,
                                  cls.cks_template.name)

        cks_offering_data = {
            "name": "CKS-Instance",
            "displaytext": "CKS Instance",
            "cpunumber": 2,
            "cpuspeed": 1000,
            "memory": 2048,
        }
        cks_offering_data[
            "name"] = cks_offering_data["name"] + '-' + random_gen()
        if cls.setup_failed == False:
            cls.cks_service_offering = ServiceOffering.create(
                cls.apiclient, cks_offering_data)

        cls._cleanup = []
        if cls.cks_template != None:
            cls._cleanup.append(cls.cks_template)
        if cls.cks_service_offering != None:
            cls._cleanup.append(cls.cks_service_offering)
        return
Exemplo n.º 54
0
    def setUpClass(cls):

        cls.testClient = super(TestTemplates, 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
        #populate second zone id for iso copy
        cmd = listZones.listZonesCmd()
        zones = cls.api_client.listZones(cmd)
        if not isinstance(zones, list):
            raise Exception("Failed to find zones.")
        if len(zones) >= 2:
            cls.services["destzoneid"] = zones[1].id

        template = get_template(cls.api_client, cls.zone.id,
                                cls.services["ostype"])
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls._cleanup = []
        try:
            cls.account = Account.create(cls.api_client,
                                         cls.services["account"],
                                         domainid=cls.domain.id)
            cls._cleanup.append(cls.account)

            cls.services["account"] = cls.account.name
            cls.service_offering = ServiceOffering.create(
                cls.api_client, cls.services["service_offering"])
            cls._cleanup.append(cls.service_offering)

            # create virtual machine
            cls.virtual_machine = VirtualMachine.create(
                cls.api_client,
                cls.services["virtual_machine"],
                templateid=template.id,
                accountid=cls.account.name,
                domainid=cls.account.domainid,
                serviceofferingid=cls.service_offering.id,
            )
            #Stop virtual machine
            cls.virtual_machine.stop(cls.api_client)

            timeout = cls.services["timeout"]

            while True:
                list_volume = Volume.list(
                    cls.api_client,
                    virtualmachineid=cls.virtual_machine.id,
                    type='ROOT',
                    listall=True)
                if isinstance(list_volume, list):
                    break
                elif timeout == 0:
                    raise Exception("List volumes failed.")

                time.sleep(5)
                timeout = timeout - 1

            cls.volume = list_volume[0]

            #Create template from volume
            cls.template = Template.create(cls.api_client,
                                           cls.services["template"],
                                           cls.volume.id)
        except Exception as e:
            cls.tearDownClass()
            raise unittest.SkipTest("Failure in setUpClass: %s" % e)
Exemplo n.º 55
0
    def setUp(self):
        self.testdata = self.testClient.getParsedTestDataConfig()
        self.apiclient = self.testClient.getApiClient()

        # Get Zone, Domain and Default Built-in template
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())

        self.testdata["mode"] = self.zone.networktype
        self.template = get_template(self.apiclient, self.zone.id,
                                     self.testdata["ostype"])

        self.hosts = []
        suitablecluster = None
        clusters = Cluster.list(self.apiclient)
        self.assertTrue(isinstance(clusters, list) and len(clusters) > 0,
                        msg="No clusters found")
        for cluster in clusters:
            self.hosts = Host.list(self.apiclient,
                                   clusterid=cluster.id,
                                   type='Routing')
            if isinstance(self.hosts, list) and len(self.hosts) >= 2:
                suitablecluster = cluster
                break
        self.assertTrue(
            isinstance(self.hosts, list) and len(self.hosts) >= 2,
            msg="Atleast 2 hosts required in cluster for VM HA test")
        #update host tags
        for host in self.hosts:
            Host.update(self.apiclient,
                        id=host.id,
                        hosttags=self.testdata["service_offerings"]["hasmall"]
                        ["hosttags"])

        #create a user account
        self.account = Account.create(self.apiclient,
                                      self.testdata["account"],
                                      domainid=self.domain.id)
        #create a service offering
        self.service_offering = ServiceOffering.create(
            self.apiclient, self.testdata["service_offerings"]["hasmall"])
        #deploy ha vm
        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.testdata["virtual_machine"],
            accountid=self.account.name,
            zoneid=self.zone.id,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            templateid=self.template.id)
        list_vms = VirtualMachine.list(self.apiclient,
                                       id=self.virtual_machine.id)
        self.debug(
            "Verify listVirtualMachines response for virtual machine: %s"\
            % self.virtual_machine.id
        )
        self.assertTrue(isinstance(list_vms, list) and len(list_vms) == 1,
                        msg="List VM response was empty")
        self.virtual_machine = list_vms[0]

        self.mock_checkhealth = SimulatorMock.create(
            apiclient=self.apiclient,
            command="CheckHealthCommand",
            zoneid=suitablecluster.zoneid,
            podid=suitablecluster.podid,
            clusterid=suitablecluster.id,
            hostid=self.virtual_machine.hostid,
            value="result:fail")
        self.mock_ping = SimulatorMock.create(
            apiclient=self.apiclient,
            command="PingCommand",
            zoneid=suitablecluster.zoneid,
            podid=suitablecluster.podid,
            clusterid=suitablecluster.id,
            hostid=self.virtual_machine.hostid,
            value="result:fail")
        self.mock_checkvirtualmachine = SimulatorMock.create(
            apiclient=self.apiclient,
            command="CheckVirtualMachineCommand",
            zoneid=suitablecluster.zoneid,
            podid=suitablecluster.podid,
            clusterid=suitablecluster.id,
            hostid=self.virtual_machine.hostid,
            value="result:fail")
        self.mock_pingtest = SimulatorMock.create(
            apiclient=self.apiclient,
            command="PingTestCommand",
            zoneid=suitablecluster.zoneid,
            podid=suitablecluster.podid,
            value="result:fail")
        self.mock_checkonhost_list = []
        for host in self.hosts:
            if host.id != self.virtual_machine.hostid:
                self.mock_checkonhost_list.append(
                    SimulatorMock.create(apiclient=self.apiclient,
                                         command="CheckOnHostCommand",
                                         zoneid=suitablecluster.zoneid,
                                         podid=suitablecluster.podid,
                                         clusterid=suitablecluster.id,
                                         hostid=host.id,
                                         value="result:fail"))
        #build cleanup list
        self.cleanup = [
            self.service_offering, self.account, self.mock_checkhealth,
            self.mock_ping, self.mock_checkvirtualmachine, self.mock_pingtest
        ]
        self.cleanup = self.cleanup + self.mock_checkonhost_list
Exemplo n.º 56
0
    def setUp(self):
        self.apiclient = self.testClient.getApiClient()
        self.services = self.testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.hypervisor = self.testClient.getHypervisorInfo()
        template = get_test_template(
            self.apiclient,
            self.zone.id,
            self.hypervisor
        )
        self.services["virtual_machine"]["zoneid"] = self.zone.id

        # Create an account, network, VM, Port forwarding rule, LB rules
        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            admin=True,
            domainid=self.domain.id
        )

        self.service_offering = ServiceOffering.create(
            self.apiclient,
            self.services["service_offerings"]["tiny"]
        )

        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id
        )

        self.ip_address = PublicIPAddress.create(
            self.apiclient,
            self.account.name,
            self.zone.id,
            self.account.domainid
        )

        ip_addrs = list_publicIP(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid,
            issourcenat=False
        )
        try:
            self.ip_addr = ip_addrs[0]
        except Exception as e:
            raise Exception(
                "Failed: During acquiring source NAT for account: %s, :%s" %
                (self.account.name, e))

        self.nat_rule = NATRule.create(
            self.apiclient,
            self.virtual_machine,
            self.services["natrule"],
            self.ip_addr.id
        )
        self.lb_rule = LoadBalancerRule.create(
            self.apiclient,
            self.services["lbrule"],
            self.ip_addr.id,
            accountid=self.account.name
        )
        self.cleanup = [
            self.virtual_machine,
            self.account
        ]
        return
    def setUpClass(cls):
        testClient = super(TestXDCCPInterop, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()
        cls.hypervisor = cls.testClient.getHypervisorInfo()
        # 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

        hosts = list_hosts(cls.apiclient, type="Routing")

        if hosts is None:
            raise unittest.SkipTest(
                "There are no hypervisor's available.Check list hosts response"
            )
        for hypervisorhost in hosts:
            if hypervisorhost.hypervisor == "XenServer":
                cls.uploadtemplateformat = "VHD"
                break
            elif hypervisorhost.hypervisor == "VMware":
                cls.uploadtemplateformat = "OVA"
                break
            elif hypervisorhost.hypervisor == "KVM":
                cls.uploadtemplateformat = "KVM"
            break

        if cls.uploadtemplateformat == "KVM":
            raise unittest.SkipTest("Interop is not supported on KVM")

        cls.uploadurl = cls.services["interop"][
            cls.uploadtemplateformat]["url"]

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

        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     domainid=cls.domain.id,
                                     admin=False)
        cls.debug(cls.account.id)

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

        cls.template = get_windows_template(cls.apiclient,
                                            cls.zone.id,
                                            ostype_desc="Windows 8 (64-bit)")
        #cls.template = get_windows_template(cls.apiclient, cls.zone.id ,ostype_desc="Windows Server 2012 (64-bit)")

        if cls.template == FAILED:
            if "http://pleaseupdateURL/" in cls.uploadurl:
                raise unittest.SkipTest(
                    "Check Test Data file if it has the valid template URL")
            cls.template = Template.register(
                cls.apiclient,
                cls.services["interop"][cls.uploadtemplateformat],
                zoneid=cls.zone.id,
                domainid=cls.account.domainid,
                account=cls.account.name)
            timeout = cls.services["vgpu"]["timeout"]

            while True:
                time.sleep(cls.services["vgpu"]["sleep"])
                list_template_response = Template.list(
                    cls.apiclient,
                    templatefilter=cls.services["templatefilter"],
                    id=cls.template.id)
                if (isinstance(list_template_response, list)) is not True:
                    raise unittest.SkipTest(
                        "Check list template api response returns a valid list"
                    )

                if len(list_template_response) is None:
                    raise unittest.SkipTest(
                        "Check template registered is in List Templates")

                template_response = list_template_response[0]
                if template_response.isready:
                    break

                if timeout == 0:
                    raise unittest.SkipTest(
                        "Failed to download template(ID: %s). " %
                        template_response.id)

                timeout = timeout - 1
        cls.volume = []

        # Set Zones and disk offerings
        cls.services["small"]["zoneid"] = cls.zone.id
        cls.services["small"]["template"] = cls.template.id

        user_data = ''.join(
            random.choice(string.ascii_uppercase + string.digits)
            for x in range(2500))
        cls.services["virtual_machine"]["userdata"] = user_data

        #        cls.services["large"]["zoneid"] = cls.zone.id
        #        cls.services["large"]["template"] = cls.template.id

        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            mode=cls.services['mode'],
            startvm="false")
        cls.user_api_client = cls.testClient.getUserApiClient(
            UserName=cls.account.name, DomainName=cls.account.domain)

        cls.cleanup = [cls.service_offering, cls.account]
Exemplo n.º 58
0
    def setUpClass(cls):
        testClient = super(TestVMLifeCycle, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

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

        #if local storage is enabled, alter the offerings to use localstorage
        #this step is needed for devcloud
        if cls.zone.localstorageenabled == True:
            cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
            cls.services["service_offerings"]["small"]["storagetype"] = 'local'
            cls.services["service_offerings"]["medium"][
                "storagetype"] = 'local'

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

        # Set Zones and disk offerings
        cls.services["small"]["zoneid"] = cls.zone.id
        cls.services["small"]["template"] = template.id

        cls.services["medium"]["zoneid"] = cls.zone.id
        cls.services["medium"]["template"] = template.id
        cls.services["iso1"]["zoneid"] = cls.zone.id

        # Create VMs, NAT Rules etc
        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     domainid=domain.id)

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

        cls.medium_offering = ServiceOffering.create(
            cls.apiclient, cls.services["service_offerings"]["medium"])
        #create small and large virtual machines
        cls.small_virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.small_offering.id,
            mode=cls.services["mode"])
        cls.medium_virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["medium"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.medium_offering.id,
            mode=cls.services["mode"])
        cls.virtual_machine = VirtualMachine.create(
            cls.apiclient,
            cls.services["small"],
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.small_offering.id,
            mode=cls.services["mode"])
        cls._cleanup = [cls.small_offering, cls.medium_offering, cls.account]
    def setUpClass(cls):
        testClient = super(TestConcurrentSnapshots, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.hypervisor = cls.testClient.getHypervisorInfo()

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

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

        cls._cleanup = []
        cls.vm_pool = []
        cls.snapshotSupported = True

        if cls.hypervisor.lower() in ["hyperv", "lxc"]:
            cls.snapshotSupported = False
            return

        # Set sleep time as per Snapshot Recurring Policy - HOURLY
        cls.sleep_time_for_hourly_policy = 60 * 60 * 1

        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__

        try:

            # Create an account
            cls.account = Account.create(
                cls.apiclient,
                cls.testdata["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.testdata["service_offering"],
            )
            cls._cleanup.append(cls.service_offering)

            for i in range(4):
                cls.vm = VirtualMachine.create(
                    cls.apiclient,
                    cls.testdata["small"],
                    templateid=cls.template.id,
                    accountid=cls.account.name,
                    domainid=cls.account.domainid,
                    serviceofferingid=cls.service_offering.id,
                    zoneid=cls.zone.id,
                    mode=cls.zone.networktype
                )

                cls.vm_pool.append(cls.vm)
                cls._cleanup.append(cls.vm)

            cls.checksum_pool = []
            cls.root_pool = []
            cls.snapshot_pool = []
            cls.rec_policy_pool = []
            for vm in cls.vm_pool:
                root_volumes = list_volumes(
                    cls.apiclient,
                    virtualmachineid=vm.id,
                    type='ROOT',
                    listall=True
                )

                checksum_root = createChecksum(
                    cls.testdata,
                    vm,
                    root_volumes[0],
                    "rootdiskdevice")

                cls.checksum_pool.append(checksum_root)
                cls.root_pool.append(root_volumes[0])
            try:
                cls.pools = StoragePool.list(cls.apiclient, zoneid=cls.zone.id)
            except Exception as e:
                raise unittest.SkipTest(e)

        except Exception as e:
            cls.tearDownClass()
            raise e
        return
Exemplo n.º 60
0
    def setUp(self):

        self.apiclient = self.testClient.getApiClient()
        self.services = self.testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        self.hypervisor = self.testClient.getHypervisorInfo()
        template = get_test_template(
            self.apiclient,
            self.zone.id,
            self.hypervisor
        )
        if template == FAILED:
            self.fail("get_test_template() failed to return template")

        self.services["virtual_machine"]["zoneid"] = self.zone.id

        # Create an account, network, VM and IP addresses
        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            admin=True,
            domainid=self.domain.id
        )
        self.service_offering = ServiceOffering.create(
            self.apiclient,
            self.services["service_offerings"]["tiny"]
        )
        self.vm_1 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id
        )

        # Wait for VM to come up
        time.sleep(120)

        src_nat_ip_addrs = list_publicIP(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid
        )
        try:
            src_nat_ip_addr = src_nat_ip_addrs[0]
        except Exception as e:
            raise Exception(
                "Warning: Exception during fetching source NAT: %s" %
                e)

        self.public_ip = PublicIPAddress.create(
            self.apiclient,
            self.vm_1.account,
            self.vm_1.zoneid,
            self.vm_1.domainid,
            self.services["virtual_machine"]
        )
        # Open up firewall port for SSH
        FireWallRule.create(
            self.apiclient,
            ipaddressid=self.public_ip.ipaddress.id,
            protocol=self.services["lbrule"]["protocol"],
            cidrlist=['0.0.0.0/0'],
            startport=self.services["lbrule"]["publicport"],
            endport=self.services["lbrule"]["publicport"]
        )

        lb_rule = LoadBalancerRule.create(
            self.apiclient,
            self.services["lbrule"],
            src_nat_ip_addr.id,
            self.account.name
        )
        lb_rule.assign(self.apiclient, [self.vm_1])
        self.nat_rule = NATRule.create(
            self.apiclient,
            self.vm_1,
            self.services["natrule"],
            ipaddressid=self.public_ip.ipaddress.id
        )
        self.cleanup = [self.nat_rule,
                        lb_rule,
                        self.vm_1,
                        self.service_offering,
                        self.account,
                        ]
        return