コード例 #1
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"])

        #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"])
        #create first 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)
        #mock to simulate volume creation failure
        self.mock_volume_failure = SimulatorMock.create(
            apiclient=self.apiclient, command="CopyCommand", count=6)
        #build cleanup list
        self.cleanup = [
            self.service_offering, self.account, self.mock_volume_failure
        ]
コード例 #2
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"])

        #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"]
        )
        #create first 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)
        #mock to simulate vm start failure
        self.mock_start_failure = SimulatorMock.create(
            apiclient=self.apiclient,
            command="StartCommand",
            count=6)
        #build cleanup list
        self.cleanup = [
            self.service_offering,
            self.account,
            self.mock_start_failure
        ]
コード例 #3
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
コード例 #4
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.assertEqual(validateList(self.hosts)[0], PASS, "hosts list validation failed")
        if len(self.hosts) < 2:
            self.skipTest("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
コード例 #5
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"])

        hosts = Host.list(self.apiclient, type='Routing')
        self.assertTrue(isinstance(hosts, list) and len(hosts) > 0,
                        msg="No hosts found")
        self.host = hosts[0]
        #update host tags
        Host.update(self.apiclient,
                    id=self.host.id,
                    hosttags=self.testdata["service_offerings"]["taggedsmall"]
                    ["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"]["taggedsmall"])
        #deploy vms
        self.vm1 = VirtualMachine.create(
            self.apiclient,
            self.testdata["small"],
            accountid=self.account.name,
            zoneid=self.zone.id,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            templateid=self.template.id)
        self.vm2 = VirtualMachine.create(
            self.apiclient,
            self.testdata["small"],
            accountid=self.account.name,
            zoneid=self.zone.id,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            templateid=self.template.id)
        self.vm3 = VirtualMachine.create(
            self.apiclient,
            self.testdata["small"],
            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,
            ids=[self.vm1.id, self.vm2.id, self.vm3.id],
            listAll=True)
        self.assertTrue(isinstance(list_vms, list) and len(list_vms) == 3,
                        msg="List VM response is empty")
        clusters = Cluster.list(self.apiclient, id=self.host.clusterid)
        self.assertTrue(isinstance(clusters, list) and len(clusters) > 0,
                        msg="Cluster not found")

        json_response = '{"com.cloud.agent.api.PingRoutingWithNwGroupsCommand":{"newGroupStates":{},"newStates":{},"_hostVmStateReport":{"%s":{"state":"PowerOn","host":"%s"},"%s":{"state":"PowerOff","host":"%s"}},"_gatewayAccessible":true,"_vnetAccessible":true,"hostType":"Routing","hostId":0,"contextMap":{},"wait":0}}'
        json_response = json_response % (self.vm1.instancename, self.host.name,
                                         self.vm2.instancename, self.host.name)

        #create a mock to simulate vm1 as power-on, vm2 as power-off and vm3 as missing
        self.mock_ping = SimulatorMock.create(
            apiclient=self.apiclient,
            command="PingRoutingWithNwGroupsCommand",
            zoneid=self.zone.id,
            podid=clusters[0].podid,
            clusterid=clusters[0].id,
            hostid=self.host.id,
            value='',
            jsonresponse=json_response,
            method='POST')

        #build cleanup list
        self.cleanup = [self.service_offering, self.account, self.mock_ping]
コード例 #6
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"])

        hosts = Host.list(self.apiclient, type="Routing")
        self.assertTrue(isinstance(hosts, list) and len(hosts) > 0, msg="No hosts found")
        self.host = hosts[0]
        # update host tags
        Host.update(
            self.apiclient, id=self.host.id, hosttags=self.testdata["service_offerings"]["taggedsmall"]["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"]["taggedsmall"]
        )
        # deploy vms
        self.vm1 = VirtualMachine.create(
            self.apiclient,
            self.testdata["small"],
            accountid=self.account.name,
            zoneid=self.zone.id,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            templateid=self.template.id,
        )
        self.vm2 = VirtualMachine.create(
            self.apiclient,
            self.testdata["small"],
            accountid=self.account.name,
            zoneid=self.zone.id,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            templateid=self.template.id,
        )
        self.vm3 = VirtualMachine.create(
            self.apiclient,
            self.testdata["small"],
            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, ids=[self.vm1.id, self.vm2.id, self.vm3.id], listAll=True)
        self.assertTrue(isinstance(list_vms, list) and len(list_vms) == 3, msg="List VM response is empty")
        clusters = Cluster.list(self.apiclient, id=self.host.clusterid)
        self.assertTrue(isinstance(clusters, list) and len(clusters) > 0, msg="Cluster not found")

        json_response = '{"com.cloud.agent.api.PingRoutingWithNwGroupsCommand":{"newGroupStates":{},"newStates":{},"_hostVmStateReport":{"%s":{"state":"PowerOn","host":"%s"},"%s":{"state":"PowerOff","host":"%s"}},"_gatewayAccessible":true,"_vnetAccessible":true,"hostType":"Routing","hostId":0,"contextMap":{},"wait":0}}'
        json_response = json_response % (self.vm1.instancename, self.host.name, self.vm2.instancename, self.host.name)

        # create a mock to simulate vm1 as power-on, vm2 as power-off and vm3 as missing
        self.mock_ping = SimulatorMock.create(
            apiclient=self.apiclient,
            command="PingRoutingWithNwGroupsCommand",
            zoneid=self.zone.id,
            podid=clusters[0].podid,
            clusterid=clusters[0].id,
            hostid=self.host.id,
            value="",
            jsonresponse=json_response,
            method="POST",
        )

        # build cleanup list
        self.cleanup = [self.service_offering, self.account, self.mock_ping]