Example #1
0
def get_builtin_template_info(apiclient, zoneid):
    """Returns hypervisor specific infor for templates"""

    list_template_response = Template.list(
        apiclient,
        templatefilter='featured',
        zoneid=zoneid,
    )

    for b_template in list_template_response:
        if b_template.templatetype == 'BUILTIN':
            break

    extract_response = Template.extract(apiclient, b_template.id,
                                        'HTTP_DOWNLOAD', zoneid)

    return extract_response.url, b_template.hypervisor, b_template.format
Example #2
0
def get_builtin_template_info(apiclient, zoneid):
    """Returns hypervisor specific infor for templates"""

    list_template_response = Template.list(
                                    apiclient,
                                    templatefilter='featured',
                                    zoneid=zoneid,
                                    )

    for b_template in list_template_response:
            if b_template.templatetype == 'BUILTIN':
                break

    extract_response = Template.extract(apiclient,
                                            b_template.id,
                                            'HTTP_DOWNLOAD',
                                            zoneid)

    return extract_response.url, b_template.hypervisor, b_template.format
    def test_03_concurrent_snapshots_create_template(self):
        """Test while parent concurrent snapshot job in progress,create
            template from completed snapshot

            1.Configure the concurrent.snapshots.threshold.perhost=3
            2.Deploy a Linux VM using default CentOS template, use small
            service offering, disk offering
            3.Perform snapshot on root disk of this newly created VMs(10 vms)
            4.while parent concurrent snapshot job in progress,create template
            from completed snapshot"""

        # Validate the following
        # a.Able to create Template from snapshots
        # b.check all snapshots jobs are running concurrently on back grounds
        # c.listSnapshots should list this newly created snapshot.

        self.debug("Create virtual machine and snapshot on ROOT disk")
        self.create_Snapshot_VM()

        self.debug("Verify whether snapshots were created properly or not?")
        self.verify_Snapshots()

        self.debug("Fetch the list of snapshots belong to account: %s" %
                                                    self.account.name)
        snapshots = self.get_Snapshots_For_Account(
                                                self.account.name,
                                                self.account.domainid)
        jobs = []
        for snapshot in snapshots:
            self.debug("Create a template from snapshot: %s" % snapshot.name)
            jobs.append(self.create_Template_from_Snapshot(snapshot))

        # Verify IO usage by submitting the concurrent jobs
        self.testClient.submitCmdsAndWait(jobs)

        self.debug("Verifying if templates are created properly or not?")
        templates = Template.list(
                            self.apiclient,
                            templatefilter=self.services["template"]["templatefilter"],
                            account=self.account.name,
                            domainid=self.account.domainid,
                            listall=True)
        self.assertNotEqual(templates,
                            None,
                            "Check if result exists in list item call")
        for template in templates:
            self.assertEqual(template.isready,
                         True,
                        "Check new template state in list templates call")

        self.debug("Test completed successfully.")
        return
Example #4
0
    def test_03_concurrent_snapshots_create_template(self):
        """Test while parent concurrent snapshot job in progress,create
            template from completed snapshot

            1.Configure the concurrent.snapshots.threshold.perhost=3
            2.Deploy a Linux VM using default CentOS template, use small
            service offering, disk offering
            3.Perform snapshot on root disk of this newly created VMs(10 vms)
            4.while parent concurrent snapshot job in progress,create template
            from completed snapshot"""

        # Validate the following
        # a.Able to create Template from snapshots
        # b.check all snapshots jobs are running concurrently on back grounds
        # c.listSnapshots should list this newly created snapshot.

        self.debug("Create virtual machine and snapshot on ROOT disk")
        self.create_Snapshot_VM()

        self.debug("Verify whether snapshots were created properly or not?")
        self.verify_Snapshots()

        self.debug("Fetch the list of snapshots belong to account: %s" %
                   self.account.name)
        snapshots = self.get_Snapshots_For_Account(self.account.name,
                                                   self.account.domainid)
        jobs = []
        for snapshot in snapshots:
            self.debug("Create a template from snapshot: %s" % snapshot.name)
            jobs.append(self.create_Template_from_Snapshot(snapshot))

        # Verify IO usage by submitting the concurrent jobs
        self.testClient.submitCmdsAndWait(jobs)

        self.debug("Verifying if templates are created properly or not?")
        templates = Template.list(
            self.apiclient,
            templatefilter=self.services["template"]["templatefilter"],
            account=self.account.name,
            domainid=self.account.domainid,
            listall=True)
        self.assertNotEqual(templates, None,
                            "Check if result exists in list item call")
        for template in templates:
            self.assertEqual(
                template.isready, True,
                "Check new template state in list templates call")

        self.debug("Test completed successfully.")
        return
    def test_03_restore_vm_with_new_template(self):
        """ Test restoring a vm with different template than the one it was created with
        """

        hosts = Host.list(self.apiclient, type="Routing", listall=True)

        host_list_validation_result = validateList(hosts)

        self.assertEqual(
            host_list_validation_result[0], PASS,
            "host list validation failed due to %s" %
            host_list_validation_result[2])

        hypervisor = host_list_validation_result[1].hypervisor

        for k, v in self.services["templates"].items():
            if k == hypervisor:
                # Register new template
                template = Template.register(self.apiclient,
                                             v,
                                             zoneid=self.zone.id,
                                             account=self.account.name,
                                             domainid=self.account.domainid)
                self.debug("Registered a template of format: %s with ID: %s" %
                           (v["format"], template.id))
                self.debug("Downloading template with ID: %s" % (template.id))
                template.download(self.apiclient)
                self.cleanup.append(template)

                # Wait for template status to be changed across
                time.sleep(self.services["sleep"])

                self.verify_template_listing(template)

                # Restore a vm with the new template.
                self.vm_with_reset.restore(self.apiclient,
                                           templateid=template.id)
                self.vm_without_reset.restore(self.apiclient,
                                              templateid=template.id)

                # Make sure the VMs now have the new template ID
                # Make sure the Ip address of the VMs haven't changed
                self.debug("Checking template id of VM with isVolatile=True")
                vms = VirtualMachine.list(self.apiclient,
                                          id=self.vm_with_reset.id,
                                          listall=True)

                vm_list_validation_result = validateList(vms)

                self.assertEqual(
                    vm_list_validation_result[0], PASS,
                    "VM list validation failed due to %s" %
                    vm_list_validation_result[2])

                vm_with_reset = vm_list_validation_result[1]

                self.assertNotEqual(
                    self.vm_with_reset.templateid, vm_with_reset.templateid,
                    "VM created with IsVolatile=True has same templateid : %s after restore"
                    % vm_with_reset.templateid)

                self.assertNotEqual(
                    self.vm_with_reset.templateid, template.id,
                    "VM created with IsVolatile=True has wrong templateid after restore Got:%s Expected: %s"
                    % (self.vm_with_reset.templateid, template.id))
                # Make sure it has the same IP after reboot
                self.assertEqual(
                    self.vm_with_reset.nic[0].ipaddress,
                    vm_with_reset.nic[0].ipaddress,
                    "VM created with IsVolatile=True doesn't have same ip after restore. Got : %s Expected : %s"
                    % (vm_with_reset.nic[0].ipaddress,
                       self.vm_with_reset.nic[0].ipaddress))

                # Check if the the root disk was not destroyed for isVolatile=False
                self.debug("Checking template id of VM with isVolatile=False")
                vms = VirtualMachine.list(self.apiclient,
                                          id=self.vm_without_reset.id,
                                          listall=True)

                vm_list_validation_result = validateList(vms)

                self.assertEqual(
                    vm_list_validation_result[0], PASS,
                    "VM list validation failed due to %s" %
                    vm_list_validation_result[2])

                vm_without_reset = vm_list_validation_result[1]

                self.assertNotEqual(
                    self.vm_without_reset.templateid,
                    vm_without_reset.templateid,
                    "VM created with IsVolatile=False has same templateid : %s after restore"
                    % vm_with_reset.templateid)

                self.assertNotEqual(
                    self.vm_without_reset.templateid, template.id,
                    "VM created with IsVolatile=False has wrong templateid after restore Got:%s Expected: %s"
                    % (self.vm_without_reset.templateid, template.id))
                # Make sure it has the same IP after reboot
                self.assertEqual(
                    self.vm_without_reset.nic[0].ipaddress,
                    vm_without_reset.nic[0].ipaddress,
                    "VM created with IsVolatile=False doesn't have same ip after restore. Got : %s Expected : %s"
                    % (vm_without_reset.nic[0].ipaddress,
                       self.vm_without_reset.nic[0].ipaddress))

            return
    def test_03_restore_vm_with_new_template(self):
        """ Test restoring a vm with different template than the one it was created with
        """

        hosts = Host.list(self.apiclient, type="Routing", listall=True)

        host_list_validation_result = validateList(hosts)

        self.assertEqual(
            host_list_validation_result[0],
            PASS,
            "host list validation failed due to %s" % host_list_validation_result[2],
        )

        hypervisor = host_list_validation_result[1].hypervisor

        for k, v in self.services["templates"].items():
            if k.lower() == hypervisor.lower():
                # Register new template
                template = Template.register(
                    self.apiclient, v, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid
                )
                self.debug("Registered a template of format: %s with ID: %s" % (v["format"], template.id))
                self.debug("Downloading template with ID: %s" % (template.id))
                template.download(self.apiclient)
                self.cleanup.append(template)

                # Wait for template status to be changed across
                time.sleep(self.services["sleep"])

                self.verify_template_listing(template)

                # Restore a vm with the new template.
                self.vm_with_reset.restore(self.apiclient, templateid=template.id)
                self.vm_without_reset.restore(self.apiclient, templateid=template.id)

                # Make sure the VMs now have the new template ID
                # Make sure the Ip address of the VMs haven't changed
                self.debug("Checking template id of VM with isVolatile=True")
                vms = VirtualMachine.list(self.apiclient, id=self.vm_with_reset.id, listall=True)

                vm_list_validation_result = validateList(vms)

                self.assertEqual(
                    vm_list_validation_result[0],
                    PASS,
                    "VM list validation failed due to %s" % vm_list_validation_result[2],
                )

                vm_with_reset = vm_list_validation_result[1]

                self.assertNotEqual(
                    self.vm_with_reset.templateid,
                    vm_with_reset.templateid,
                    "VM created with IsVolatile=True has same templateid : %s after restore" % vm_with_reset.templateid,
                )

                self.assertNotEqual(
                    self.vm_with_reset.templateid,
                    template.id,
                    "VM created with IsVolatile=True has wrong templateid after restore Got:%s Expected: %s"
                    % (self.vm_with_reset.templateid, template.id),
                )
                # Make sure it has the same IP after reboot
                self.assertEqual(
                    self.vm_with_reset.nic[0].ipaddress,
                    vm_with_reset.nic[0].ipaddress,
                    "VM created with IsVolatile=True doesn't have same ip after restore. Got : %s Expected : %s"
                    % (vm_with_reset.nic[0].ipaddress, self.vm_with_reset.nic[0].ipaddress),
                )

                # Check if the the root disk was not destroyed for isVolatile=False
                self.debug("Checking template id of VM with isVolatile=False")
                vms = VirtualMachine.list(self.apiclient, id=self.vm_without_reset.id, listall=True)

                vm_list_validation_result = validateList(vms)

                self.assertEqual(
                    vm_list_validation_result[0],
                    PASS,
                    "VM list validation failed due to %s" % vm_list_validation_result[2],
                )

                vm_without_reset = vm_list_validation_result[1]

                self.assertNotEqual(
                    self.vm_without_reset.templateid,
                    vm_without_reset.templateid,
                    "VM created with IsVolatile=False has same templateid : %s after restore"
                    % vm_with_reset.templateid,
                )

                self.assertNotEqual(
                    self.vm_without_reset.templateid,
                    template.id,
                    "VM created with IsVolatile=False has wrong templateid after restore Got:%s Expected: %s"
                    % (self.vm_without_reset.templateid, template.id),
                )
                # Make sure it has the same IP after reboot
                self.assertEqual(
                    self.vm_without_reset.nic[0].ipaddress,
                    vm_without_reset.nic[0].ipaddress,
                    "VM created with IsVolatile=False doesn't have same ip after restore. Got : %s Expected : %s"
                    % (vm_without_reset.nic[0].ipaddress, self.vm_without_reset.nic[0].ipaddress),
                )

            return