def test_03_project_counts_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count = project_list[0].cputotal

        expected_resource_count = int(self.services["service_offering"]["cpunumber"])

        self.assertEqual(resource_count, expected_resource_count,
                         "Resource count should match with the expected resource count")

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_delete = project_list[0].cputotal
        self.assertEqual(resource_count_after_delete, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
        return
    def test_02_project_counts_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count = project_list[0].cputotal

        expected_resource_count = int(self.services["service_offering"]["cpunumber"])

        self.assertEqual(
            resource_count, expected_resource_count, "Resource count should match with the expected resource count"
        )

        host = find_suitable_host(self.apiclient, self.vm)
        self.debug("Migrating instance: %s to host: %s" % (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count_after_migrate = project_list[0].cputotal

        self.assertEqual(
            resource_count, resource_count_after_migrate, "Resource count should be same after migrating the instance"
        )
        return
Example #3
0
    def test_01_project_vmlifecycle_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project to a new host
        # 4. Resource count should list properly
        # 5. Start VM of an accounts added to the project to a new host
        # 6. Resource count should list properly

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal

        self.debug(resource_count)

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_stop = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_stop,
            "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_start = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_start,
            "Resource count should be same after starting the instance")
        return
Example #4
0
    def test_03_project_vmlifecycle_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project
        # 4. Resource count should list as 0 after destroying the instance

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        # Wait for expunge interval to cleanup Memory
        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count_after_delete = project_list[0].memorytotal
        self.assertEqual(
            resource_count_after_delete, 0, "Resource count for %s should be 0" % get_resource_type(resource_id=9)
        )  # RAM
        return
Example #5
0
    def test_02_project_vmlifecycle_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        host = findSuitableHostForMigration(self.apiclient, self.vm.id)
        if host is None:
            self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
        self.debug("Migrating instance: %s to host: %s" % (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list, list, "List Projects should return a valid response")
        resource_count_after_migrate = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_migrate, "Resource count should be same after migrating the instance"
        )
        return
Example #6
0
    def test_01_project_counts_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project.
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].cputotal

        expected_resource_count = int(
            self.services["service_offering"]["cpunumber"])

        self.assertEqual(
            resource_count, expected_resource_count,
            "Resource count should match with the expected resource count")

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_stop = project_list[0].cputotal

        self.assertEqual(
            resource_count, resource_count_after_stop,
            "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_start = project_list[0].cputotal

        self.assertEqual(
            resource_count, resource_count_after_start,
            "Resource count should be same after starting the instance")
        return
    def test_01_project_vmlifecycle_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project to a new host
        # 4. Resource count should list properly
        # 5. Start VM of an accounts added to the project to a new host
        # 6. Resource count should list properly

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count = project_list[0].memorytotal

        self.debug(resource_count)

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_stop = project_list[0].memorytotal

        self.assertEqual(resource_count, resource_count_after_stop,
                         "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" % self.project.name)
        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_start = project_list[0].memorytotal

        self.assertEqual(resource_count, resource_count_after_start,
                         "Resource count should be same after starting the instance")
        return
    def test_01_project_counts_start_stop_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Stop VM of an accounts added to the project.
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count = project_list[0].cputotal

        expected_resource_count = int(self.services["service_offering"]["cpunumber"])

        self.assertEqual(resource_count, expected_resource_count,
                         "Resource count should match with the expected resource count")

        self.debug("Stopping instance: %s" % self.vm.name)
        try:
            self.vm.stop(self.apiclient)
        except Exception as e:
            self.fail("Failed to stop instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_stop = project_list[0].cputotal

        self.assertEqual(resource_count, resource_count_after_stop,
                         "Resource count should be same after stopping the instance")

        self.debug("Starting instance: %s" % self.vm.name)
        try:
            self.vm.start(self.apiclient)
        except Exception as e:
            self.fail("Failed to start instance: %s" % e)

        project_list = Project.list(self.apiclient, id=self.project.id, listall=True)
        self.assertIsInstance(project_list,
                              list,
                              "List Projects should return a valid response"
                              )
        resource_count_after_start = project_list[0].cputotal

        self.assertEqual(resource_count, resource_count_after_start,
                         "Resource count should be same after starting the instance")
        return
    def setupProjectAccounts(self):

        self.debug("Creating a domain under: %s" % self.domain.name)
        self.domain = Domain.create(self.apiclient,
                                        services=self.services["domain"],
                                        parentdomainid=self.domain.id)
        self.admin = Account.create(
                            self.apiclient,
                            self.services["account"],
                            admin=True,
                            domainid=self.domain.id
                            )

        # Create project as a domain admin
        self.project = Project.create(self.apiclient,
                                 self.services["project"],
                                 account=self.admin.name,
                                 domainid=self.admin.domainid)
        # Cleanup created project at end of test
        self.cleanup.append(self.project)
        self.cleanup.append(self.admin)
        self.cleanup.append(self.domain)
        self.debug("Created project with domain admin with name: %s" %
                                                        self.project.name)

        projects = Project.list(self.apiclient, id=self.project.id,
                                listall=True)

        self.assertEqual(isinstance(projects, list), True,
                        "Check for a valid list projects response")
        project = projects[0]
        self.assertEqual(project.name, self.project.name,
                        "Check project name from list response")
        return
Example #10
0
    def setupProjectAccounts(self):

        self.debug("Creating a domain under: %s" % self.domain.name)
        self.domain = Domain.create(self.apiclient,
                                    services=self.services["domain"],
                                    parentdomainid=self.domain.id)
        self.admin = Account.create(self.apiclient,
                                    self.services["account"],
                                    admin=True,
                                    domainid=self.domain.id)

        # Create project as a domain admin
        self.project = Project.create(self.apiclient,
                                      self.services["project"],
                                      account=self.admin.name,
                                      domainid=self.admin.domainid)
        # Cleanup created project at end of test
        self.cleanup.append(self.project)
        self.cleanup.append(self.admin)
        self.cleanup.append(self.domain)
        self.debug("Created project with domain admin with name: %s" %
                   self.project.name)

        projects = Project.list(self.apiclient,
                                id=self.project.id,
                                listall=True)

        self.assertEqual(isinstance(projects, list), True,
                         "Check for a valid list projects response")
        project = projects[0]
        self.assertEqual(project.name, self.project.name,
                         "Check project name from list response")
        return
Example #11
0
    def test_02_project_counts_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].cputotal

        expected_resource_count = int(
            self.services["service_offering"]["cpunumber"])

        self.assertEqual(
            resource_count, expected_resource_count,
            "Resource count should match with the expected resource count")

        host = find_suitable_host(self.apiclient, self.vm)
        self.debug("Migrating instance: %s to host: %s" %
                   (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_migrate = project_list[0].cputotal

        self.assertEqual(
            resource_count, resource_count_after_migrate,
            "Resource count should be same after migrating the instance")
        return
Example #12
0
    def test_03_project_vmlifecycle_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project
        # 4. Resource count should list as 0 after destroying the instance

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        # Wait for expunge interval to cleanup Memory
        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_delete = project_list[0].memorytotal
        self.assertEqual(resource_count_after_delete, 0,
                         "Resource count for %s should be 0" %
                         get_resource_type(resource_id=9))  #RAM
        return
Example #13
0
    def test_02_project_vmlifecycle_migrate_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Migrate VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.debug(project_list)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].memorytotal
        self.debug(resource_count)

        host = find_suitable_host(self.apiclient, self.vm)
        self.debug("Migrating instance: %s to host: %s" %
                   (self.vm.name, host.name))
        try:
            self.vm.migrate(self.apiclient, host.id)
        except Exception as e:
            self.fail("Failed to migrate instance: %s" % e)

        self.debug("Checking memory resource count for project: %s" %
                   self.project.name)
        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_migrate = project_list[0].memorytotal

        self.assertEqual(
            resource_count, resource_count_after_migrate,
            "Resource count should be same after migrating the instance")
        return
Example #14
0
    def test_03_project_counts_delete_instance(self):

        # Validate the following
        # 1. Assign account to projects and verify the resource updates
        # 2. Deploy VM with the accounts added to the project
        # 3. Destroy VM of an accounts added to the project to a new host
        # 4. Resource count should list properly.

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count = project_list[0].cputotal

        expected_resource_count = int(
            self.services["service_offering"]["cpunumber"])

        self.assertEqual(
            resource_count, expected_resource_count,
            "Resource count should match with the expected resource count")

        self.debug("Destroying instance: %s" % self.vm.name)
        try:
            self.vm.delete(self.apiclient)
        except Exception as e:
            self.fail("Failed to delete instance: %s" % e)

        project_list = Project.list(self.apiclient,
                                    id=self.project.id,
                                    listall=True)
        self.assertIsInstance(project_list, list,
                              "List Projects should return a valid response")
        resource_count_after_delete = project_list[0].cputotal
        self.assertEqual(resource_count_after_delete, 0,
                         "Resource count for %s should be 0" %
                         get_resource_type(resource_id=8))  #CPU
        return