Exemple #1
0
    def _live_migrate(self, server, target_host, block_migration=False,
                      disk_over_commit=False, skip_host_check=False):
        """Run live migration of the given server.

        :param server: Server object
        :param target_host: Specifies the target compute node to migrate
        :param block_migration: Specifies the migration type
        :param disk_over_commit: Specifies whether to overcommit migrated
                                 instance or not
        :param skip_host_check: Specifies whether to verify the targeted host
                                availability
        """
        server_admin = self.admin_clients("nova").servers.get(server.id)
        host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
        server_admin.live_migrate(target_host,
                                  block_migration=block_migration,
                                  disk_over_commit=disk_over_commit)
        bench_utils.wait_for(
            server,
            is_ready=bench_utils.resource_is("ACTIVE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_live_migrate_timeout,
            check_interval=(
                CONF.benchmark.nova_server_live_migrate_poll_interval)
        )
        server_admin = self.admin_clients("nova").servers.get(server.id)
        if (host_pre_migrate == getattr(server_admin, "OS-EXT-SRV-ATTR:host")
                and not skip_host_check):
            raise exceptions.LiveMigrateException(
                "Migration complete but instance did not change host: %s" %
                host_pre_migrate)
Exemple #2
0
    def _migrate(self, server, skip_host_check=False):
        """Run migration of the given server.

        :param server: Server object
        :param skip_host_check: Specifies whether to verify the targeted host
                                availability
        """
        server_admin = self.admin_clients("nova").servers.get(server.id)
        host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
        server_admin.migrate()
        bench_utils.wait_for(
            server,
            is_ready=bench_utils.resource_is("VERIFY_RESIZE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_migrate_timeout,
            check_interval=(
                CONF.benchmark.nova_server_migrate_poll_interval)
        )
        if not skip_host_check:
            server_admin = self.admin_clients("nova").servers.get(server.id)
            host_after_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
            if host_pre_migrate == host_after_migrate:
                raise exceptions.MigrateException(
                    "Migration complete but instance did not change host: %s" %
                    host_pre_migrate)
Exemple #3
0
 def _wait_active(self, cluster_object):
     bench_utils.wait_for(
         resource=cluster_object,
         is_ready=self._is_cluster_active,
         update_resource=self._update_cluster,
         timeout=CONF.benchmark.cluster_create_timeout,
         check_interval=CONF.benchmark.cluster_check_interval)
Exemple #4
0
    def _live_migrate(self, server, target_host, block_migration=False,
                      disk_over_commit=False, skip_host_check=False):
        """Run live migration of the given server.

        :param server: Server object
        :param target_host: Specifies the target compute node to migrate
        :param block_migration: Specifies the migration type
        :param disk_over_commit: Specifies whether to overcommit migrated
                                 instance or not
        :param skip_host_check: Specifies whether to verify the targeted host
                                availability
        """
        server_admin = self.admin_clients("nova").servers.get(server.id)
        host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
        server_admin.live_migrate(target_host,
                                  block_migration=block_migration,
                                  disk_over_commit=disk_over_commit)
        bench_utils.wait_for(
            server,
            is_ready=bench_utils.resource_is("ACTIVE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_live_migrate_timeout,
            check_interval=(
                CONF.benchmark.nova_server_live_migrate_poll_interval)
        )
        server_admin = self.admin_clients("nova").servers.get(server.id)
        if (host_pre_migrate == getattr(server_admin, "OS-EXT-SRV-ATTR:host")
                and not skip_host_check):
            raise exceptions.LiveMigrateException(
                "Migration complete but instance did not change host: %s" %
                host_pre_migrate)
Exemple #5
0
    def _migrate(self, server, skip_host_check=False):
        """Run migration of the given server.

        :param server: Server object
        :param skip_host_check: Specifies whether to verify the targeted host
                                availability
        """
        server_admin = self.admin_clients("nova").servers.get(server.id)
        host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
        server_admin.migrate()
        bench_utils.wait_for(
            server,
            is_ready=bench_utils.resource_is("VERIFY_RESIZE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_migrate_timeout,
            check_interval=(
                CONF.benchmark.nova_server_migrate_poll_interval)
        )
        if not skip_host_check:
            server_admin = self.admin_clients("nova").servers.get(server.id)
            host_after_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
            if host_pre_migrate == host_after_migrate:
                raise exceptions.MigrateException(
                    "Migration complete but instance did not change host: %s" %
                    host_pre_migrate)
Exemple #6
0
    def test_wait_for(self):

        def get_fake_checker_delayed(**delay):
            deadline = datetime.datetime.now() + datetime.timedelta(**delay)
            return lambda obj: datetime.datetime.now() > deadline

        def fake_checker_false(obj):
            return False

        def fake_updater(obj):
            return obj

        resource = object()
        fake_checker_delayed = get_fake_checker_delayed(seconds=0.3)

        loaded_resource = utils.wait_for(resource, fake_checker_delayed,
                                         fake_updater, 1, 0.2)
        self.assertEqual(loaded_resource, resource)

        loaded_resource = utils.wait_for(resource, fake_checker_delayed,
                                         None, 1, 0.2)
        self.assertEqual(loaded_resource, resource)

        self.assertRaises(exceptions.TimeoutException, utils.wait_for,
                          object(), fake_checker_false, fake_updater, 0.3, 0.1)
Exemple #7
0
 def _resize(self, server, flavor):
     server.resize(flavor)
     bench_utils.wait_for(
         server,
         is_ready=bench_utils.resource_is("VERIFY_RESIZE"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_timeout,
         check_interval=CONF.benchmark.nova_server_resize_poll_interval)
Exemple #8
0
 def _wait_for_ping(self, server_ip):
     server_ip = netaddr.IPAddress(server_ip)
     bench_utils.wait_for(
         server_ip,
         is_ready=bench_utils.resource_is(ICMP_UP_STATUS,
                                          self._ping_ip_address),
         timeout=120
     )
Exemple #9
0
def _wait_for_list_size(mgr, sizes=[0], timeout=10, check_interval=1):
    bench_utils.wait_for(
        mgr,
        is_ready=bench_utils.manager_list_size(sizes),
        update_resource=None,
        timeout=timeout,
        check_interval=check_interval,
    )
Exemple #10
0
    def _wait_finish_of_deploy(self, environment):

        bench_utils.wait_for(
            environment, is_ready=bench_utils.resource_is("READY"),
            update_resource=bench_utils.get_from_manager(),
            timeout=1200.0,
            check_interval=5.0
        )
Exemple #11
0
 def _wait_active(self, cluster_object):
     bench_utils.wait_for(
         resource=cluster_object,
         ready_statuses=["active"],
         failure_statuses=["error"],
         update_resource=self._update_cluster,
         timeout=CONF.benchmark.cluster_create_timeout,
         check_interval=CONF.benchmark.cluster_check_interval)
Exemple #12
0
 def _resize(self, server, flavor):
     server.resize(flavor)
     bench_utils.wait_for(
         server,
         is_ready=bench_utils.resource_is("VERIFY_RESIZE"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_timeout,
         check_interval=CONF.benchmark.nova_server_resize_poll_interval
     )
Exemple #13
0
 def _do_server_reboot(self, server, reboottype):
     server.reboot(reboot_type=reboottype)
     time.sleep(CONF.benchmark.nova_server_reboot_prepoll_delay)
     bench_utils.wait_for(
         server, is_ready=bench_utils.resource_is("ACTIVE"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_reboot_timeout,
         check_interval=CONF.benchmark.nova_server_reboot_poll_interval
     )
Exemple #14
0
 def _resize_revert(self, server):
     server.revert_resize()
     bench_utils.wait_for(
         server,
         is_ready=bench_utils.resource_is("ACTIVE"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_revert_timeout,
         check_interval=(
             CONF.benchmark.nova_server_resize_revert_poll_interval))
Exemple #15
0
 def _resize_confirm(self, server, status="ACTIVE"):
     server.confirm_resize()
     bench_utils.wait_for(
         server,
         is_ready=bench_utils.resource_is(status),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_confirm_timeout,
         check_interval=(
             CONF.benchmark.nova_server_resize_confirm_poll_interval))
Exemple #16
0
    def setup(self):
        ready_tenants = set()
        wait_dict = dict()

        for user in self.context.get("users", []):
            tenant_id = user["tenant_id"]
            if tenant_id not in ready_tenants:
                ready_tenants.add(tenant_id)

                clients = osclients.Clients(user["endpoint"])

                image_id = self.context["sahara_images"][tenant_id]

                neutron_net = self.config.get("neutron_net")
                if not neutron_net:
                    # Skipping fixed network config
                    neutron_net_id = None
                else:
                    network_cfg = {"name": neutron_net}
                    neutron_net_id = (types.NeutronNetworkResourceType
                                      .transform(clients, network_cfg))

                floating_ip_pool = self.config.get("floating_ip_pool")
                if not floating_ip_pool:
                    # Skipping floating network config
                    floating_ip_pool_id = None
                else:
                    network_cfg = {"name": floating_ip_pool}
                    floating_ip_pool_id = (types.NeutronNetworkResourceType
                                           .transform(clients, network_cfg))

                cluster = utils.SaharaScenario(
                    context=self.context, clients=clients)._launch_cluster(
                        plugin_name=self.config["plugin_name"],
                        hadoop_version=self.config["hadoop_version"],
                        flavor_id=self.config["flavor_id"],
                        node_count=self.config["node_count"],
                        image_id=image_id,
                        floating_ip_pool=floating_ip_pool_id,
                        neutron_net_id=neutron_net_id,
                        volumes_per_node=self.config.get("volumes_per_node"),
                        volumes_size=self.config.get("volumes_size", 1),
                        node_configs=self.config.get("node_configs"),
                        cluster_configs=self.config.get("cluster_configs"),
                        wait_active=False)

                self.context["sahara_clusters"][tenant_id] = cluster.id

                # Need to save the client instance to poll for active status
                wait_dict[cluster] = clients.sahara()

        bench_utils.wait_for(
            resource=wait_dict,
            update_resource=self.update_clusters_dict,
            is_ready=self.all_clusters_active,
            timeout=CONF.benchmark.cluster_create_timeout,
            check_interval=CONF.benchmark.cluster_check_interval)
Exemple #17
0
 def _do_server_reboot(self, server, reboottype):
     server.reboot(reboot_type=reboottype)
     time.sleep(CONF.benchmark.nova_server_reboot_prepoll_delay)
     bench_utils.wait_for(
         server, is_ready=bench_utils.resource_is("ACTIVE"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_reboot_timeout,
         check_interval=CONF.benchmark.nova_server_reboot_poll_interval
     )
Exemple #18
0
    def _delete_cluster(self, cluster):
        """Delete cluster.

        :param cluster: cluster to delete
        """
        self.clients("sahara").clusters.delete(cluster.id)

        bench_utils.wait_for(resource=cluster.id,
                             is_ready=self._is_cluster_deleted)
Exemple #19
0
 def _resize_confirm(self, server):
     server.confirm_resize()
     bench_utils.wait_for(
         server,
         is_ready=bench_utils.resource_is("ACTIVE"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_confirm_timeout,
         check_interval=(
             CONF.benchmark.nova_server_resize_confirm_poll_interval)
     )
Exemple #20
0
    def test_exit_instantly(self, mock_sleep):
        res = {"status": "ready"}
        upd = mock.MagicMock(return_value=res)

        utils.wait_for(resource=res,
                       ready_statuses=["ready"],
                       update_resource=upd)

        upd.assert_called_once_with(res)
        self.assertFalse(mock_sleep.called)
Exemple #21
0
 def _resize_revert(self, server, status="ACTIVE"):
     server.revert_resize()
     bench_utils.wait_for(
         server,
         is_ready=bench_utils.resource_is(status),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_revert_timeout,
         check_interval=(
             CONF.benchmark.nova_server_resize_revert_poll_interval)
     )
Exemple #22
0
 def _detach_volume(self, server, volume):
     server_id = server.id
     volume_id = volume.id
     self.clients("nova").volumes.delete_server_volume(server_id, volume_id)
     bench_utils.wait_for(
         volume,
         is_ready=bench_utils.resource_is("available"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_detach_volume_timeout,
         check_interval=CONF.benchmark.nova_detach_volume_poll_interval)
Exemple #23
0
    def _delete_cluster(self, cluster):
        """Calls a Cluster delete by id and waits for complete deletion.

        :param cluster: The Cluster to be deleted
        :return:
        """

        self.clients("sahara").clusters.delete(cluster.id)

        bench_utils.wait_for(resource=cluster.id,
                             is_ready=self._is_cluster_deleted)
    def _delete_cluster(self, cluster):
        """Calls a Cluster delete by id and waits for complete deletion.

        :param cluster: The Cluster to be deleted
        :return:
        """

        self.clients("sahara").clusters.delete(cluster.id)

        bench_utils.wait_for(resource=cluster.id,
                             is_ready=self._is_cluster_deleted)
Exemple #25
0
def _wait_for_list_statuses(mgr, statuses, list_query=None,
                            timeout=10, check_interval=1):
    list_query = list_query or {}

    def _list_statuses(mgr):
        for resource in mgr.list(**list_query):
            if resource.status not in statuses:
                return False
        return True

    bench_utils.wait_for(mgr, is_ready=_list_statuses, update_resource=None,
                         timeout=timeout, check_interval=check_interval)
Exemple #26
0
 def _attach_volume(self, server, volume, device=None):
     server_id = server.id
     volume_id = volume.id
     self.clients("nova").volumes.create_server_volume(
         server_id, volume_id, device)
     bench_utils.wait_for(
         volume,
         is_ready=bench_utils.resource_is("in-use"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_revert_timeout,
         check_interval=(
             CONF.benchmark.nova_server_resize_revert_poll_interval))
Exemple #27
0
def _wait_for_list_statuses(mgr, statuses, list_query=None, timeout=10, check_interval=1):
    list_query = list_query or {}

    def _list_statuses(mgr):
        for resource in mgr.list(**list_query):
            if resource.status not in statuses:
                return False
        return True

    bench_utils.wait_for(
        mgr, is_ready=_list_statuses, update_resource=None, timeout=timeout, check_interval=check_interval
    )
Exemple #28
0
    def _delete_cluster(self, cluster):
        """Delete cluster.

        :param cluster: cluster to delete
        """
        self.clients("sahara").clusters.delete(cluster.id)

        bench_utils.wait_for(
            resource=cluster.id,
            timeout=CONF.benchmark.cluster_delete_timeout,
            check_interval=CONF.benchmark.cluster_check_interval,
            is_ready=self._is_cluster_deleted)
Exemple #29
0
 def _detach_volume(self, server, volume):
     server_id = server.id
     volume_id = volume.id
     self.clients("nova").volumes.delete_server_volume(server_id,
                                                       volume_id)
     bench_utils.wait_for(
         volume,
         is_ready=bench_utils.resource_is("available"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_detach_volume_timeout,
         check_interval=CONF.benchmark.nova_detach_volume_poll_interval
     )
Exemple #30
0
    def _delete_cluster(self, cluster):
        """Delete cluster.

        :param cluster: cluster to delete
        """
        self.clients("sahara").clusters.delete(cluster.id)

        bench_utils.wait_for(
            resource=cluster.id,
            timeout=CONF.benchmark.cluster_delete_timeout,
            check_interval=CONF.benchmark.cluster_check_interval,
            is_ready=self._is_cluster_deleted)
Exemple #31
0
    def _suspend_stack(self, stack):
        """Suspend given stack.

        :param stack: stack that needs to be suspended
        """

        self.clients("heat").actions.suspend(stack.id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("SUSPEND_COMPLETE"),
            update_resource=bench_utils.get_from_manager(["SUSPEND_FAILED"]),
            timeout=CONF.benchmark.heat_stack_suspend_timeout,
            check_interval=CONF.benchmark.heat_stack_suspend_poll_interval)
Exemple #32
0
    def _restore_stack(self, stack, snapshot_id):
        """Restores stack from given snapshot.

        :param stack: stack that will be restored from snapshot
        :param snapshot_id: id of given snapshot
        """
        self.clients("heat").stacks.restore(stack.id, snapshot_id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("RESTORE_COMPLETE"),
            update_resource=bench_utils.get_from_manager(["RESTORE_FAILED"]),
            timeout=CONF.benchmark.heat_stack_restore_timeout,
            check_interval=CONF.benchmark.heat_stack_restore_poll_interval)
Exemple #33
0
    def _deploy_environment(self, environment, session):
        """Deploy environment.

        :param environment: Environment instance
        :param session: Session instance
        """
        self.clients("murano").sessions.deploy(environment.id, session.id)
        bench_utils.wait_for(
            environment,
            is_ready=bench_utils.resource_is("READY"),
            update_resource=bench_utils.get_from_manager(["DEPLOY FAILURE"]),
            timeout=CONF.benchmark.deploy_environment_timeout,
            check_interval=CONF.benchmark.deploy_environment_check_interval)
Exemple #34
0
    def _dissociate_floating_ip(self, server, address):
        """Remove floating IP from an instance

        :param server: The :class:`Server` to add an IP to.
        :param address: The ip address or FloatingIP to remove
        """
        server.remove_floating_ip(address)
        bench_utils.wait_for(server,
                             is_ready=self.check_ip_address(address,
                                                            must_exist=False),
                             update_resource=bench_utils.get_from_manager())
        # Update server data
        server.addresses = server.manager.get(server.id).addresses
        def run(self):
            job_execution = self.clients("sahara").job_executions.create(
                job_id=job_id,
                cluster_id=cluster_id,
                input_id=input_id,
                output_id=output_id,
                configs=configs)

            bench_utils.wait_for(
                resource=job_execution.id,
                is_ready=self._job_execution_is_finished,
                timeout=CONF.benchmark.job_execution_timeout,
                check_interval=CONF.benchmark.job_check_interval)
Exemple #36
0
        def run(self):
            job_execution = self.clients("sahara").job_executions.create(
                job_id=job_id,
                cluster_id=cluster_id,
                input_id=input_id,
                output_id=output_id,
                configs=configs)

            bench_utils.wait_for(
                resource=job_execution.id,
                is_ready=self._job_execution_is_finished,
                timeout=CONF.benchmark.job_execution_timeout,
                check_interval=CONF.benchmark.job_check_interval)
Exemple #37
0
    def _resume_stack(self, stack):
        """Resume given stack.

        :param stack: stack that needs to be resumed
        """

        self.clients("heat").actions.resume(stack.id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("RESUME_COMPLETE"),
            update_resource=bench_utils.get_from_manager(["RESUME_FAILED"]),
            timeout=CONF.benchmark.heat_stack_resume_timeout,
            check_interval=CONF.benchmark.heat_stack_resume_poll_interval)
Exemple #38
0
    def _dissociate_floating_ip(self, server, address):
        """Remove floating IP from an instance

        :param server: The :class:`Server` to add an IP to.
        :param address: The ip address or FloatingIP to remove
        """
        server.remove_floating_ip(address)
        bench_utils.wait_for(
            server,
            is_ready=self.check_ip_address(address, must_exist=False),
            update_resource=bench_utils.get_from_manager()
        )
        # Update server data
        server.addresses = server.manager.get(server.id).addresses
Exemple #39
0
    def _associate_floating_ip(self, server, address, fixed_address=None):
        """Add floating IP to an instance

        :param server: The :class:`Server` to add an IP to.
        :param address: The ip address or FloatingIP to add to the instance
        :param fixed_address: The fixedIP address the FloatingIP is to be
               associated with (optional)
        """
        server.add_floating_ip(address, fixed_address=fixed_address)
        bench_utils.wait_for(server,
                             is_ready=self.check_ip_address(address),
                             update_resource=bench_utils.get_from_manager())
        # Update server data
        server.addresses = server.manager.get(server.id).addresses
Exemple #40
0
    def _check_stack(self, stack):
        """Check given stack.

        Check the stack and stack resources.

        :param stack: stack that needs to be checked
        """
        self.clients("heat").actions.check(stack.id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("CHECK_COMPLETE"),
            update_resource=bench_utils.get_from_manager(["CHECK_FAILED"]),
            timeout=CONF.benchmark.heat_stack_check_timeout,
            check_interval=CONF.benchmark.heat_stack_check_poll_interval)
Exemple #41
0
 def _attach_volume(self, server, volume, device=None):
     server_id = server.id
     volume_id = volume.id
     self.clients("nova").volumes.create_server_volume(server_id,
                                                       volume_id,
                                                       device)
     bench_utils.wait_for(
         volume,
         is_ready=bench_utils.resource_is("in-use"),
         update_resource=bench_utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_revert_timeout,
         check_interval=(
             CONF.benchmark.nova_server_resize_revert_poll_interval)
     )
Exemple #42
0
    def _snapshot_stack(self, stack):
        """Creates a snapshot for given stack.

        :param stack: stack that will be used as base for snapshot
        :returns snapshot created for given stack
        """
        snapshot = self.clients("heat").stacks.snapshot(stack.id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("SNAPSHOT_COMPLETE"),
            update_resource=bench_utils.get_from_manager(["SNAPSHOT_FAILED"]),
            timeout=CONF.benchmark.heat_stack_snapshot_timeout,
            check_interval=CONF.benchmark.heat_stack_snapshot_poll_interval)
        return snapshot
Exemple #43
0
    def _check_stack(self, stack):
        """Check given stack.

        Check the stack and stack resources.

        :param stack: stack that needs to be checked
        """
        self.clients("heat").actions.check(stack.id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("CHECK_COMPLETE"),
            update_resource=bench_utils.get_from_manager(["CHECK_FAILED"]),
            timeout=CONF.benchmark.heat_stack_check_timeout,
            check_interval=CONF.benchmark.heat_stack_check_poll_interval)
Exemple #44
0
    def _suspend_stack(self, stack):
        """Suspend given stack.

        :param stack: stack that needs to be suspended
        """

        self.clients("heat").actions.suspend(stack.id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("SUSPEND_COMPLETE"),
            update_resource=bench_utils.get_from_manager(
                ["SUSPEND_FAILED"]),
            timeout=CONF.benchmark.heat_stack_suspend_timeout,
            check_interval=CONF.benchmark.heat_stack_suspend_poll_interval)
Exemple #45
0
    def _resume_stack(self, stack):
        """Resume given stack.

        :param stack: stack that needs to be resumed
        """

        self.clients("heat").actions.resume(stack.id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("RESUME_COMPLETE"),
            update_resource=bench_utils.get_from_manager(
                ["RESUME_FAILED"]),
            timeout=CONF.benchmark.heat_stack_resume_timeout,
            check_interval=CONF.benchmark.heat_stack_resume_poll_interval)
Exemple #46
0
    def _deploy_environment(self, environment, session):
        """Deploy environment.

        :param environment: Environment instance
        :param session: Session instance
        """
        self.clients("murano").sessions.deploy(environment.id,
                                               session.id)
        bench_utils.wait_for(
            environment, is_ready=bench_utils.resource_is("READY"),
            update_resource=bench_utils.get_from_manager(["DEPLOY FAILURE"]),
            timeout=CONF.benchmark.deploy_environment_timeout,
            check_interval=CONF.benchmark.deploy_environment_check_interval
        )
Exemple #47
0
    def _start_server(self, server):
        """Start the given server.

        A start will be issued for the given server upon which time
        this method will wait for it to become ACTIVE.

        :param server: The server to start and wait to become ACTIVE.
        """
        server.start()
        bench_utils.wait_for(
            server, is_ready=bench_utils.resource_is("ACTIVE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_start_timeout,
            check_interval=CONF.benchmark.nova_server_start_poll_interval
        )
Exemple #48
0
    def _restore_stack(self, stack, snapshot_id):
        """Restores stack from given snapshot.

        :param stack: stack that will be restored from snapshot
        :param snapshot_id: id of given snapshot
        """
        self.clients("heat").stacks.restore(stack.id, snapshot_id)
        bench_utils.wait_for(
            stack,
            is_ready=bench_utils.resource_is("RESTORE_COMPLETE"),
            update_resource=bench_utils.get_from_manager(
                ["RESTORE_FAILED"]),
            timeout=CONF.benchmark.heat_stack_restore_timeout,
            check_interval=CONF.benchmark.heat_stack_restore_poll_interval
        )
Exemple #49
0
    def _unrescue_server(self, server):
        """Unrescue the given server.

        Returns when the server is unrescue and waits to become ACTIVE

        :param server: Server object
        """
        server.unrescue()
        time.sleep(CONF.benchmark.nova_server_unrescue_prepoll_delay)
        bench_utils.wait_for(
            server, is_ready=bench_utils.resource_is("ACTIVE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_unrescue_timeout,
            check_interval=CONF.benchmark.nova_server_unrescue_poll_interval
        )
Exemple #50
0
    def _rebuild_server(self, server, image, **kwargs):
        """Rebuild a server with a new image.

        :param server: The server to rebuild.
        :param image: The new image to rebuild the server with.
        :param kwargs: Optional additional arguments to pass to the rebuild
        """
        server.rebuild(image, **kwargs)
        time.sleep(CONF.benchmark.nova_server_rebuild_prepoll_delay)
        bench_utils.wait_for(
            server,
            is_ready=bench_utils.resource_is("ACTIVE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_rebuild_timeout,
            check_interval=CONF.benchmark.nova_server_rebuild_poll_interval)
Exemple #51
0
    def _start_server(self, server):
        """Start the given server.

        A start will be issued for the given server upon which time
        this method will wait for it to become ACTIVE.

        :param server: The server to start and wait to become ACTIVE.
        """
        server.start()
        bench_utils.wait_for(
            server, is_ready=bench_utils.resource_is("ACTIVE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_start_timeout,
            check_interval=CONF.benchmark.nova_server_start_poll_interval
        )
Exemple #52
0
    def _stop_server(self, server):
        """Stop the given server.

        Issues a stop on the given server and waits for the server
        to become SHUTOFF.

        :param server: The server to stop.
        """
        server.stop()
        bench_utils.wait_for(
            server, is_ready=bench_utils.resource_is("SHUTOFF"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_stop_timeout,
            check_interval=CONF.benchmark.nova_server_stop_poll_interval
        )
Exemple #53
0
    def _unshelve_server(self, server):
        """Unshelve the given server.

        Returns when the server is unshelved and is in the "ACTIVE" state.

        :param server: Server object
        """
        server.unshelve()
        time.sleep(CONF.benchmark.nova_server_unshelve_prepoll_delay)
        bench_utils.wait_for(
            server, is_ready=bench_utils.resource_is("ACTIVE"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_unshelve_timeout,
            check_interval=CONF.benchmark.nova_server_unshelve_poll_interval
        )
Exemple #54
0
    def _stop_server(self, server):
        """Stop the given server.

        Issues a stop on the given server and waits for the server
        to become SHUTOFF.

        :param server: The server to stop.
        """
        server.stop()
        bench_utils.wait_for(
            server, is_ready=bench_utils.resource_is("SHUTOFF"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_stop_timeout,
            check_interval=CONF.benchmark.nova_server_stop_poll_interval
        )
    def _create_stack(self, stack_name, template=None):
        """Create a new stack.

        :param stack_name: string. Name for created stack.
        :param template: optional parameter. Template with stack description.

        returns: object of stack
        """
        template = template or self.default_template

        kw = {
            "stack_name": stack_name,
            "disable_rollback": True,
            "parameters": {},
            "template": template,
            "files": {},
            "environment": {}
        }

        # heat client returns body instead manager object, so we should
        # get manager object using stack_id
        stack_id = self.clients("heat").stacks.create(**kw)["stack"]["id"]
        stack = self.clients("heat").stacks.get(stack_id)

        time.sleep(CONF.benchmark.heat_stack_create_prepoll_delay)

        stack = bench_utils.wait_for(
            stack,
            is_ready=heat_resource_is("CREATE_COMPLETE"),
            update_resource=bench_utils.get_from_manager(["CREATE_FAILED"]),
            timeout=CONF.benchmark.heat_stack_create_timeout,
            check_interval=CONF.benchmark.heat_stack_create_poll_interval)

        return stack
Exemple #56
0
    def _suspend_server(self, server):
        """Suspends the given server.

        Returns when the server is actually suspended and is in the "Suspended"
        state.

        :param server: Server object
        """
        server.suspend()
        time.sleep(CONF.benchmark.nova_server_suspend_prepoll_delay)
        bench_utils.wait_for(
            server, is_ready=bench_utils.resource_is("SUSPENDED"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_suspend_timeout,
            check_interval=CONF.benchmark.nova_server_suspend_poll_interval
        )
Exemple #57
0
    def _create_volume(self, size, **kwargs):
        """create one volume.

        Returns when the volume is actually created and is in the "Available"
        state.

        :param size: int be size of volume in GB
        :param **kwargs: Other optional parameters to initialize the volume

        :returns: Created volume object
        """
        kwargs["display_name"] = kwargs.get("display_name",
                                            self._generate_random_name())
        volume = self.clients("cinder").volumes.create(size, **kwargs)
        # NOTE(msdubov): It is reasonable to wait 5 secs before starting to
        #                check whether the volume is ready => less API calls.
        time.sleep(CONF.benchmark.cinder_volume_create_prepoll_delay)
        volume = bench_utils.wait_for(
            volume,
            is_ready=bench_utils.resource_is("available"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.cinder_volume_create_timeout,
            check_interval=CONF.benchmark.cinder_volume_create_poll_interval
        )
        return volume
Exemple #58
0
    def _create_snapshot(self, volume_id, force=False, **kwargs):
        """Create one snapshot.

        Returns when the snapshot is actually created and is in the "Available"
        state.

        :param volume_id: volume uuid for creating snapshot
        :param force: flag to indicate whether to snapshot a volume even if
                      it's attached to an instance
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created snapshot object
        """
        kwargs["display_name"] = kwargs.get("display_name",
                                            self._generate_random_name())
        kwargs["force"] = force
        snapshot = self.clients("cinder").volume_snapshots.create(volume_id,
                                                                  **kwargs)
        time.sleep(CONF.benchmark.cinder_volume_create_prepoll_delay)
        snapshot = bench_utils.wait_for(
            snapshot,
            is_ready=bench_utils.resource_is("available"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.cinder_volume_create_timeout,
            check_interval=CONF.benchmark.cinder_volume_create_poll_interval
        )
        return snapshot
Exemple #59
0
    def _create_image(self, image_name, container_format,
                      image_url, disk_format, **kwargs):
        """Create a new image.

        :param image_name: String used to name the image
        :param container_format: Container format of image.
        Acceptable formats: ami, ari, aki, bare, and ovf.
        :param image_url: URL for download image
        :param disk_format: Disk format of image. Acceptable formats:
        ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso.
        :param **kwargs:  optional parameters to create image

        returns: object of image
        """
        image = self.clients("glance").images.create(
                                        name=image_name,
                                        copy_from=image_url,
                                        container_format=container_format,
                                        disk_format=disk_format,
                                        **kwargs)
        time.sleep(CONF.benchmark.glance_image_create_prepoll_delay)
        image = bench_utils.wait_for(
            image,
            is_ready=bench_utils.resource_is("active"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.glance_image_create_timeout,
            check_interval=CONF.benchmark.glance_image_create_poll_interval)
        return image