@logging.log_task_wrapper(LOG.info, _("Enter context: `swift_objects`"))
    def setup(self):
        threads = self.config["resource_management_workers"]

        containers_per_tenant = self.config["containers_per_tenant"]
        containers_num = len(self.context["tenants"]) * containers_per_tenant
        LOG.debug("Creating %d containers using %d threads." % (containers_num,
                                                                threads))
        containers_count = len(self._create_containers(self.context,
                                                       containers_per_tenant,
                                                       threads))
        if containers_count != containers_num:
            raise exceptions.ContextSetupFailure(
                ctx_name=self.get_name(),
                msg=_("Failed to create the requested number of containers, "
                      "expected %(expected)s but got %(actual)s.")
                % {"expected": containers_num, "actual": containers_count})

        objects_per_container = self.config["objects_per_container"]
        objects_num = containers_num * objects_per_container
        LOG.debug("Creating %d objects using %d threads." % (objects_num,
                                                             threads))
        objects_count = len(self._create_objects(self.context,
                                                 objects_per_container,
                                                 self.config["object_size"],
                                                 threads))
        if objects_count != objects_num:
            raise exceptions.ContextSetupFailure(
                ctx_name=self.get_name(),
                msg=_("Failed to create the requested number of objects, "
                      "expected %(expected)s but got %(actual)s.")
                % {"expected": objects_num, "actual": objects_count})
Create containers and objects, using the broker pattern.
dataset/ETHPy150Open openstack/rally/rally/plugins/openstack/context/swift/objects.py/SwiftObjectGenerator.setup