コード例 #1
0
    def test_03_scale_vm(self):
        """Test scale virtual machine which is not dynamically scalable to a service offering. Scaling operation should fail.
        """
        # Validate the following
        # Scale up the vm which is not dynamically scalable and see if scaling operation fails

        #        VirtualMachine should be updated to tell cloudstack
        #        it has PV tools
        #        available and successfully scaled. We will only mock
        #        that behaviour
        #        here but it is not expected in production since the VM
        #        scaling is not
        #        guaranteed until tools are installed, vm rebooted

        # If hypervisor is Vmware, then check if
        # the vmware tools are installed and the process is running
        # Vmware tools are necessary for scale VM operation
        if self.hypervisor.lower() == "vmware":
            sshClient = self.virtual_machine_not_dynamically_scalable.get_ssh_client(
            )
            result = str(
                sshClient.execute("service vmware-tools status")).lower()
            self.debug("and result is: %s" % result)
            if not "running" in result:
                self.skipTest("Skipping scale VM operation because\
                    VMware tools are not installed on the VM")

        list_vm_response = VirtualMachine.list(
            self.apiclient,
            id=self.virtual_machine_not_dynamically_scalable.id)
        self.assertEqual(isinstance(list_vm_response, list), True,
                         "Check list response returns a valid list")
        self.assertNotEqual(list_vm_response, None,
                            "Check virtual machine is in listVirtualMachines")
        vm_response = list_vm_response[0]
        self.assertEqual(vm_response.id,
                         self.virtual_machine_not_dynamically_scalable.id,
                         "Check virtual machine ID of scaled VM")
        self.assertEqual(vm_response.isdynamicallyscalable, False,
                         "Check if VM is not dynamically scalable")

        self.debug(
            "Scaling VM-ID: %s to service offering: %s for which dynamic scaling is enabled and VM state %s"
            % (self.virtual_machine_not_dynamically_scalable.id,
               self.big_offering.id, self.virtual_machine.state))

        cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
        cmd.serviceofferingid = self.big_offering.id
        cmd.id = self.virtual_machine_not_dynamically_scalable.id

        try:
            self.apiclient.scaleVirtualMachine(cmd)
        except Exception as e:
            if "LicenceRestriction" in str(e):
                self.skipTest("Your XenServer License does not allow scaling")
            else:
                pass
        else:
            self.fail("Expected an exception to be thrown, failing")

        return
コード例 #2
0
    def test_01_scale_vm(self):
        """Test scale virtual machine
        """
        # Validate the following
        # Scale up the vm and see if it scales to the new svc offering and is
        # finally in running state

        #        VirtualMachine should be updated to tell cloudstack
        #        it has PV tools
        #        available and successfully scaled. We will only mock
        #        that behaviour
        #        here but it is not expected in production since the VM
        #        scaling is not
        #        guaranteed until tools are installed, vm rebooted

        # If hypervisor is Vmware, then check if
        # the vmware tools are installed and the process is running
        # Vmware tools are necessary for scale VM operation
        if self.hypervisor.lower() == "vmware":
            sshClient = self.virtual_machine.get_ssh_client()
            result = str(
                sshClient.execute("service vmware-tools status")).lower()
            self.debug("and result is: %s" % result)
            if not "running" in result:
                self.skipTest("Skipping scale VM operation because\
                    VMware tools are not installed on the VM")
        if self.hypervisor.lower() != 'simulator':
            hostid = self.virtual_machine.hostid
            host = Host.list(self.apiclient,
                             zoneid=self.zone.id,
                             hostid=hostid,
                             type='Routing')[0]

            try:
                username = self.hostConfig["username"]
                password = self.hostConfig["password"]
                ssh_client = self.get_ssh_client(host.ipaddress, username,
                                                 password)
                res = ssh_client.execute(
                    "hostnamectl | grep 'Operating System' | cut -d':' -f2")
            except Exception as e:
                pass

            if 'XenServer' in res[0]:
                self.skipTest(
                    "Skipping test for XenServer as it's License does not allow scaling"
                )

        self.virtual_machine.update(self.apiclient,
                                    isdynamicallyscalable='true')

        self.debug("Scaling VM-ID: %s to service offering: %s and state %s" %
                   (self.virtual_machine.id, self.big_offering.id,
                    self.virtual_machine.state))

        cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
        cmd.serviceofferingid = self.big_offering.id
        cmd.id = self.virtual_machine.id

        try:
            self.apiclient.scaleVirtualMachine(cmd)
        except Exception as e:
            if "LicenceRestriction" in str(e):
                self.skipTest("Your XenServer License does not allow scaling")
            else:
                self.fail("Scaling failed with the following exception: " +
                          str(e))

        list_vm_response = VirtualMachine.list(self.apiclient,
                                               id=self.virtual_machine.id)
        self.assertEqual(isinstance(list_vm_response, list), True,
                         "Check list response returns a valid list")

        self.assertNotEqual(list_vm_response, None,
                            "Check virtual machine is in listVirtualMachines")

        vm_response = list_vm_response[0]
        self.assertEqual(vm_response.id, self.virtual_machine.id,
                         "Check virtual machine ID of scaled VM")

        self.debug(
            "Scaling VM-ID: %s from service offering: %s to new service\
                    offering %s and the response says %s" %
            (self.virtual_machine.id, self.virtual_machine.serviceofferingid,
             self.big_offering.id, vm_response.serviceofferingid))
        self.assertEqual(vm_response.serviceofferingid, self.big_offering.id,
                         "Check service offering of the VM")

        self.assertEqual(vm_response.state, 'Running', "Check the state of VM")
        return
コード例 #3
0
    def test_02_scale_vm_without_hypervisor_specifics(self):
        # Validate the following
        # Scale up the vm and see if it scales to the new svc offering and is
        # finally in running state

        #        VirtualMachine should be updated to tell cloudstack
        #        it has PV tools
        #        available and successfully scaled. We will only mock
        #        that behaviour
        #        here but it is not expected in production since the VM
        #        scaling is not
        #        guaranteed until tools are installed, vm rebooted

        self.virtual_machine.update(
            self.apiclient,
            isdynamicallyscalable='true')

        self.debug("Scaling VM-ID: %s to service offering: %s and state %s" % (
            self.virtual_machine.id,
            self.big_offering.id,
            self.virtual_machine.state
        ))

        cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
        cmd.serviceofferingid = self.big_offering.id
        cmd.id = self.virtual_machine.id
        self.apiclient.scaleVirtualMachine(cmd)

        list_vm_response = VirtualMachine.list(
            self.apiclient,
            id=self.virtual_machine.id
        )
        self.assertEqual(
            isinstance(list_vm_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.assertNotEqual(
            list_vm_response,
            None,
            "Check virtual machine is in listVirtualMachines"
        )

        vm_response = list_vm_response[0]
        self.assertEqual(
            vm_response.id,
            self.virtual_machine.id,
            "Check virtual machine ID of scaled VM"
        )

        self.debug(
            "Scaling VM-ID: %s from service offering: %s to new service\
                    offering %s and the response says %s" %
            (self.virtual_machine.id,
             self.virtual_machine.serviceofferingid,
             self.big_offering.id,
             vm_response.serviceofferingid))
        self.assertEqual(
            vm_response.serviceofferingid,
            self.big_offering.id,
            "Check service offering of the VM"
        )

        self.assertEqual(
            vm_response.state,
            'Running',
            "Check the state of VM"
        )
        return
コード例 #4
0
    def test_01_scale_vm(self):
        """Test scale virtual machine
        """
        # Validate the following
        # Scale up the vm and see if it scales to the new svc offering and is
        # finally in running state

        #        VirtualMachine should be updated to tell cloudstack
        #        it has PV tools
        #        available and successfully scaled. We will only mock
        #        that behaviour
        #        here but it is not expected in production since the VM
        #        scaling is not
        #        guaranteed until tools are installed, vm rebooted

        # If hypervisor is Vmware, then check if
        # the vmware tools are installed and the process is running
        # Vmware tools are necessary for scale VM operation
        if self.hypervisor.lower() == "vmware":
            sshClient = self.virtual_machine.get_ssh_client()
            result = str(
                sshClient.execute("service vmware-tools status")).lower()
            self.debug("and result is: %s" % result)
            if not "running" in result:
                self.skipTest("Skipping scale VM operation because\
                    VMware tools are not installed on the VM")

        self.virtual_machine.update(self.apiclient,
                                    isdynamicallyscalable='true')

        self.debug("Scaling VM-ID: %s to service offering: %s and state %s" %
                   (self.virtual_machine.id, self.big_offering.id,
                    self.virtual_machine.state))

        cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
        cmd.serviceofferingid = self.big_offering.id
        cmd.id = self.virtual_machine.id
        self.apiclient.scaleVirtualMachine(cmd)

        list_vm_response = VirtualMachine.list(self.apiclient,
                                               id=self.virtual_machine.id)
        self.assertEqual(isinstance(list_vm_response, list), True,
                         "Check list response returns a valid list")

        self.assertNotEqual(list_vm_response, None,
                            "Check virtual machine is in listVirtualMachines")

        vm_response = list_vm_response[0]
        self.assertEqual(vm_response.id, self.virtual_machine.id,
                         "Check virtual machine ID of scaled VM")

        self.debug(
            "Scaling VM-ID: %s from service offering: %s to new service\
                    offering %s and the response says %s" %
            (self.virtual_machine.id, self.virtual_machine.serviceofferingid,
             self.big_offering.id, vm_response.serviceofferingid))
        self.assertEqual(vm_response.serviceofferingid, self.big_offering.id,
                         "Check service offering of the VM")

        self.assertEqual(vm_response.state, 'Running', "Check the state of VM")
        return
コード例 #5
0
    def test_01_scale_vm(self):
        """Test scale virtual machine
        """
        # Validate the following
        # Scale up the vm and see if it scales to the new svc offering and is
        # finally in running state

        #        VirtualMachine should be updated to tell cloudstack
        #        it has PV tools
        #        available and successfully scaled. We will only mock
        #        that behaviour
        #        here but it is not expected in production since the VM
        #        scaling is not
        #        guaranteed until tools are installed, vm rebooted

        # If hypervisor is Vmware, then check if
        # the vmware tools are installed and the process is running
        # Vmware tools are necessary for scale VM operation
        if self.hypervisor.lower() == "vmware":
            sshClient = self.virtual_machine.get_ssh_client()
            result = str(
                sshClient.execute("service vmware-tools status")).lower()
            self.debug("and result is: %s" % result)
            if not "running" in result:
                self.skipTest("Skipping scale VM operation because\
                    VMware tools are not installed on the VM")

        self.virtual_machine.update(
            self.apiclient,
            isdynamicallyscalable='true')

        self.debug("Scaling VM-ID: %s to service offering: %s and state %s" % (
            self.virtual_machine.id,
            self.big_offering.id,
            self.virtual_machine.state
        ))

        cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
        cmd.serviceofferingid = self.big_offering.id
        cmd.id = self.virtual_machine.id
        self.apiclient.scaleVirtualMachine(cmd)

        list_vm_response = VirtualMachine.list(
            self.apiclient,
            id=self.virtual_machine.id
        )
        self.assertEqual(
            isinstance(list_vm_response, list),
            True,
            "Check list response returns a valid list"
        )

        self.assertNotEqual(
            list_vm_response,
            None,
            "Check virtual machine is in listVirtualMachines"
        )

        vm_response = list_vm_response[0]
        self.assertEqual(
            vm_response.id,
            self.virtual_machine.id,
            "Check virtual machine ID of scaled VM"
        )

        self.debug(
            "Scaling VM-ID: %s from service offering: %s to new service\
                    offering %s and the response says %s" %
            (self.virtual_machine.id,
             self.virtual_machine.serviceofferingid,
             self.big_offering.id,
             vm_response.serviceofferingid))
        self.assertEqual(
            vm_response.serviceofferingid,
            self.big_offering.id,
            "Check service offering of the VM"
        )

        self.assertEqual(
            vm_response.state,
            'Running',
            "Check the state of VM"
        )
        return