• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python i18n._函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中rally.common.i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _load_img

 def _load_img(self):
     cirros_url = ("%s/%s/%s" %
                   (CONF.image.cirros_base_url,
                    CONF.image.cirros_version,
                    CONF.image.cirros_image))
     try:
         response = requests.get(cirros_url, stream=True)
     except requests.ConnectionError as err:
         msg = _("Error on downloading cirros image, possibly"
                 " no connection to Internet with message %s") % str(err)
         raise TempestConfigCreationFailure(msg)
     if response.status_code == 200:
         with open(self.img_path + ".tmp", "wb") as img_file:
             for chunk in response.iter_content(chunk_size=1024):
                 if chunk:   # filter out keep-alive new chunks
                     img_file.write(chunk)
                     img_file.flush()
         os.rename(self.img_path + ".tmp", self.img_path)
     else:
         if response.status_code == 404:
             msg = _("Error on downloading cirros image, possibly"
                     "invalid cirros_version or cirros_image in rally.conf")
         else:
             msg = _("Error on downloading cirros image, "
                     "HTTP error code %s") % response.getcode()
         raise TempestConfigCreationFailure(msg)
开发者ID:NeCTAR-RC,项目名称:rally,代码行数:26,代码来源:config.py


示例2: required_openstack

def required_openstack(config, clients, deployment, admin=False, users=False):
    """Validator that requires OpenStack admin or (and) users.

    This allows us to create 4 kind of benchmarks:
    1) not OpenStack related (validator is not specified)
    2) requires OpenStack admin
    3) requires OpenStack admin + users
    4) requires OpenStack users

    :param admin: requires OpenStack admin
    :param users: requires OpenStack users
    """

    if not (admin or users):
        return ValidationResult(
            False, _("You should specify admin=True or users=True or both."))

    if deployment["admin"] and deployment["users"]:
        return ValidationResult(True)

    if deployment["admin"]:
        if users and not config.get("context", {}).get("users"):
            return ValidationResult(False,
                                    _("You should specify 'users' context"))
        return ValidationResult(True)

    if deployment["users"] and admin:
        return ValidationResult(False, _("Admin credentials required"))
开发者ID:akalambu,项目名称:rally,代码行数:28,代码来源:validation.py


示例3: details

 def details(self):
     strs = [_("Action: '%s'. %.2fs <= %.2fs") %
             (atom, self.avg_by_action[atom], val)
             for atom, val in self.criterion_items]
     head = _("Average duration of one iteration for atomic actions:")
     end = _("Status: %s") % self.status()
     return "\n".join([head] + strs + [end])
开发者ID:GibeomOh,项目名称:rally,代码行数:7,代码来源:max_average_duration_per_atomic.py


示例4: _check_tempest_tree_existence

 def _check_tempest_tree_existence(verifier):
     if not os.path.exists(verifier.path()):
         msg = _("Tempest tree for "
                 "deployment '%s' not found! ") % verifier.deployment
         LOG.error(
             msg + _("Use `rally verify install` for Tempest installation"))
         raise exceptions.NotFoundException(message=msg)
开发者ID:alinbalutoiu,项目名称:rally,代码行数:7,代码来源:api.py


示例5: create

    def create(self, name, fromenv=False, filename=None, do_use=False):
        """Create new deployment.

        This command will create a new deployment record in rally
        database. In the case of ExistingCloud deployment engine it
        will use the cloud represented in the configuration. If the
        cloud doesn't exist, Rally can deploy a new one for you with
        Devstack or Fuel. Different deployment engines exist for these
        cases.

        If you use the ExistingCloud deployment engine you can pass
        a deployment config by environment variables with ``--fromenv``:

            OS_USERNAME
            OS_PASSWORD
            OS_AUTH_URL
            OS_TENANT_NAME
            OS_ENDPOINT_TYPE or OS_INTERFACE
            OS_ENDPOINT
            OS_REGION_NAME
            OS_CACERT
            OS_INSECURE

        All other deployment engines need more complex configuration
        data, so it should be stored in a configuration file.

        You can use physical servers, LXC containers, KVM virtual
        machines or virtual machines in OpenStack for deploying the
        cloud. Except physical servers, Rally can create cluster nodes
        for you. Interaction with virtualization software, OpenStack
        cloud or physical servers is provided by server providers.

        :param fromenv: boolean, read environment instead of config file
        :param filename: path to the configuration file
        :param name: name of the deployment
        """

        if fromenv:
            config = {"type": "ExistingCloud"}
            config.update(envutils.get_creds_from_env_vars())
        else:
            if not filename:
                print("Either --filename or --fromenv is required.")
                return(1)
            filename = os.path.expanduser(filename)
            with open(filename, "rb") as deploy_file:
                config = yaml.safe_load(deploy_file.read())

        try:
            deployment = api.Deployment.create(config, name)
        except jsonschema.ValidationError:
            print(_("Config schema validation error: %s.") % sys.exc_info()[1])
            return(1)
        except exceptions.DeploymentNameExists:
            print(_("Error: %s") % sys.exc_info()[1])
            return(1)

        self.list(deployment_list=[deployment])
        if do_use:
            self.use(deployment["uuid"])
开发者ID:GibeomOh,项目名称:rally,代码行数:60,代码来源:deployment.py


示例6: show

    def show(self, verification=None, sort_by="name", detailed=False):
        """Display results table of a verification.

        :param verification: UUID of a verification
        :param sort_by: Sort results by 'name' or 'duration'
        :param detailed: Display detailed errors of failed tests
        """
        try:
            verification = api.Verification.get(verification)
            tests = verification.get_results()
        except exceptions.NotFoundException as e:
            print(six.text_type(e))
            return 1

        print(_("Total results of verification:\n"))
        total_fields = ["UUID", "Deployment UUID", "Set name", "Tests", "Failures", "Created at", "Status"]
        cliutils.print_list([verification], fields=total_fields)

        print(_("\nTests:\n"))
        fields = ["name", "time", "status"]

        results = tests["test_cases"]
        values = [utils.Struct(**results[test_name]) for test_name in results]
        sortby_index = ("name", "duration").index(sort_by)
        cliutils.print_list(values, fields, sortby_index=sortby_index)

        if detailed:
            for test in six.itervalues(tests["test_cases"]):
                if test["status"] == "fail":
                    header = cliutils.make_header(
                        "FAIL: %(name)s\n" "Time: %(time)s" % {"name": test["name"], "time": test["time"]}
                    )
                    formatted_test = "%(header)s%(log)s\n" % {"header": header, "log": test["traceback"]}
                    print(formatted_test)
开发者ID:turmalinow,项目名称:rally,代码行数:34,代码来源:verify.py


示例7: _install_venv

    def _install_venv(self):
        path_to_venv = self.path(".venv")

        if not os.path.isdir(path_to_venv):
            LOG.debug("No virtual environment for Tempest found.")
            LOG.info(_("Installing the virtual environment for Tempest."))
            LOG.debug("Virtual environment directory: %s" % path_to_venv)
            try:
                check_output(["virtualenv", "-p", sys.executable, ".venv"],
                             cwd=self.path())
                # NOTE(kun): Using develop mode installation is for run
                #            multiple tempest instance. However, dependency
                #            from tempest(os-testr) has issues here, before
                #            https://review.openstack.org/#/c/207691/ being
                #            merged, we have to install dependency manually and
                #            run setup.py with -N(install package without
                #            dependency)
                check_output([self.venv_wrapper, "pip", "install", "-r",
                              "requirements.txt", "-r",
                              "test-requirements.txt"], cwd=self.path())
                check_output([self.venv_wrapper, "pip", "install",
                              "-e", "./"], cwd=self.path())
            except subprocess.CalledProcessError:
                if os.path.exists(self.path(".venv")):
                    shutil.rmtree(self.path(".venv"))
                raise TempestSetupFailure(_("failed to install virtualenv"))
开发者ID:tyzhnenko,项目名称:rally,代码行数:26,代码来源:tempest.py


示例8: start

    def start(self, deployment=None, set_name="", regex=None,
              tests_file=None, tempest_config=None, xfails_file=None,
              do_use=True, system_wide=False, concur=0):
        """Start verification (run Tempest tests).

        :param deployment: UUID or name of a deployment
        :param set_name: Name of a Tempest test set
        :param regex: Regular expression of test
        :param tests_file: Path to a file with a list of Tempest tests
        :param tempest_config: User specified Tempest config file location
        :param xfails_file: Path to a file in YAML format with a list of
                            Tempest tests that are expected to fail
        :param do_use: Use new task as default for future operations
        :param system_wide: Whether or not to create a virtual env when
                            installing Tempest; whether or not to use
                            the local env instead of the Tempest virtual
                            env when running the tests
        :param concur: How many processes to use to run Tempest tests.
                       The default value (0) auto-detects CPU count
        """
        msg = _("Arguments '%s' and '%s' are not compatible. "
                "You can use only one of the mentioned arguments.")
        if regex and set_name:
            print(msg % ("regex", "set"))
            return 1
        if tests_file and set_name:
            print(msg % ("tests_file", "set"))
            return 1
        if tests_file and regex:
            print(msg % ("tests_file", "regex"))
            return 1

        if not (regex or set_name or tests_file):
            set_name = "full"

        if set_name and set_name not in AVAILABLE_SETS:
            print(_("Tempest test set '%s' not found "
                    "in available test sets. Available sets are %s.")
                  % (set_name, ", ".join(AVAILABLE_SETS)))
            return 1

        if tests_file and not os.path.exists(tests_file):
            print(_("File '%s' not found.") % tests_file)
            return 1

        expected_failures = None
        if xfails_file:
            if os.path.exists(xfails_file):
                with open(os.path.abspath(xfails_file), "rb") as f:
                    expected_failures = yaml.load(f)
            else:
                print(_("File '%s' not found.") % xfails_file)
                return 1

        verification = api.Verification.verify(
            deployment, set_name=set_name, regex=regex, tests_file=tests_file,
            tempest_config=tempest_config, expected_failures=expected_failures,
            system_wide=system_wide, concur=concur)
        if do_use:
            self.use(verification["uuid"])
开发者ID:huikang,项目名称:rally,代码行数:60,代码来源:verify.py


示例9: _install_venv

    def _install_venv(self):
        path_to_venv = self.path(".venv")

        if not os.path.isdir(path_to_venv):
            print("No virtual environment found...Install the virtualenv.")
            LOG.debug("Virtual environment directory: %s" % path_to_venv)
            required_vers = (2, 7)
            if sys.version_info[:2] != required_vers:
                # NOTE(andreykurilin): let's try to find a suitable python
                # interpreter for Tempest
                python_interpreter = costilius.get_interpreter(required_vers)
                if not python_interpreter:
                    raise exceptions.IncompatiblePythonVersion(
                        version=sys.version, required_version=required_vers)
                LOG.info(
                    _("Tempest requires Python %(required)s, '%(found)s' was "
                      "found in your system and it will be used for installing"
                      " virtual environment.") % {"required": required_vers,
                                                  "found": python_interpreter})
            else:
                python_interpreter = sys.executable
            try:
                check_output("%s ./tools/install_venv.py" % python_interpreter,
                             shell=True, cwd=self.path())
                check_output("%s python setup.py install" % self.venv_wrapper,
                             shell=True, cwd=self.path())
            except subprocess.CalledProcessError:
                if os.path.exists(self.path(".venv")):
                    shutil.rmtree(self.path(".venv"))
                raise TempestSetupFailure(_("failed to install virtualenv"))
开发者ID:NeCTAR-RC,项目名称:rally,代码行数:30,代码来源:tempest.py


示例10: _delete_single_resource

    def _delete_single_resource(self, resource):
        """Safe resource deletion with retries and timeouts.

        Send request to delete resource, in case of failures repeat it few
        times. After that pull status of resource until it's deleted.

        Writes in LOG warning with UUID of resource that wasn't deleted

        :param resource: instance of resource manager initiated with resource
                         that should be deleted.
        """

        msg_kw = {
            "uuid": resource.id(),
            "name": resource.name() or "",
            "service": resource._service,
            "resource": resource._resource,
        }

        LOG.debug("Deleting %(service)s %(resource)s object %(name)s (%(uuid)s)" % msg_kw)

        try:
            rutils.retry(resource._max_attempts, resource.delete)
        except Exception as e:
            msg_kw["reason"] = e
            LOG.warning(
                _(
                    "Resource deletion failed, max retries exceeded for "
                    "%(service)s.%(resource)s: %(uuid)s. Reason: %(reason)s"
                )
                % msg_kw
            )
            if logging.is_debug():
                LOG.exception(e)
        else:
            started = time.time()
            failures_count = 0
            while time.time() - started < resource._timeout:
                try:
                    if resource.is_deleted():
                        return
                except Exception as e:
                    LOG.warning(
                        _("Seems like %s.%s.is_deleted(self) method is broken " "It shouldn't raise any exceptions.")
                        % (resource.__module__, type(resource).__name__)
                    )
                    LOG.exception(e)

                    # NOTE(boris-42): Avoid LOG spamming in case of bad
                    #                 is_deleted() method
                    failures_count += 1
                    if failures_count > resource._max_attempts:
                        break

                finally:
                    time.sleep(resource._interval)

            LOG.warning(
                _("Resource deletion failed, timeout occurred for " "%(service)s.%(resource)s: %(uuid)s.") % msg_kw
            )
开发者ID:GibeomOh,项目名称:rally,代码行数:60,代码来源:manager.py


示例11: get_image_uuid

    def get_image_uuid(self):
        """Get image uuid. Download image if necessary."""

        image_uuid = self.config["image"].get("uuid", None)
        if image_uuid:
            return image_uuid
        else:
            if not self.glance:
                raise exceptions.InvalidConfigException(
                    "If glance is not available in the service catalog"
                    " obtained by the openstack server provider, then"
                    " images cannot be uploaded so the uuid of an"
                    " existing image must be specified in the"
                    " deployment config."
                )

        for image in self.glance.images.list():
            if image.checksum == self.config["image"]["checksum"]:
                LOG.info(_("Found image with appropriate checksum. Using it."))
                return image.id

        LOG.info(_("Downloading new image %s") % self.config["image"]["url"])
        image = self.glance.images.create(
            name=self.config["image"]["name"],
            copy_from=self.config["image"]["url"],
            disk_format=self.config["image"]["format"],
            container_format="bare")
        image.get()

        if image.checksum != self.config["image"]["checksum"]:
            raise exceptions.ChecksumMismatch(url=self.config["image"]["url"])

        return image.id
开发者ID:Pigueiras,项目名称:rally,代码行数:33,代码来源:openstack.py


示例12: create

    def create(self, name, filename, do_use=False):
        """Create new deployment.

        This command will create a new deployment record in rally ovs
        database.


        """

        filename = os.path.expanduser(filename)
        print("file:" + filename)

        with open(filename, "rb") as deploy_file:
            config = yaml.safe_load(deploy_file.read())

        try:
            deployment = api.Deployment.create(config, name)
        except jsonschema.ValidationError:
            print(_("Config schema validation error: %s.") % sys.exc_info()[1])
            return(1)
        except exceptions.DeploymentNameExists:
            print(_("Error: %s") % sys.exc_info()[1])
            return(1)

        self.list(deployment_list=[deployment])
        if do_use:
            self.use(deployment["uuid"])
开发者ID:flavio-fernandes,项目名称:ovn-scale-test,代码行数:27,代码来源:deployment.py


示例13: setup

    def setup(self):
        # FIXME(andreykurilin): move all checks to validate method.

        # do not use admin, if we have users...
        user = random.choice(self.context.get("users",
                                              [self.context["admin"]]))
        clients = osclients.Clients(user["endpoint"])
        services = clients.services()
        for client_name, conf in six.iteritems(self.config):
            if "service_type" in conf and conf["service_type"] not in services:
                raise exceptions.ValidationError(_(
                    "There is no service with '%s' type in your environment.")
                    % conf["service_type"])
            elif "service_name" in conf:
                if conf["service_name"] not in services.values():
                    raise exceptions.ValidationError(
                        _("There is no '%s' service in your environment") %
                        conf["service_name"])

                service_types = [
                    key for key in services
                    if services[key] == conf["service_name"]]

                if len(service_types) > 1:
                    # NOTE(andreykurilin): does it possible??
                    raise exceptions.ValidationError(
                        _("There are several services with name '%s'. Try to "
                          "specify service_type property instead.") %
                        conf["service_name"])
                self.context["config"]["api_versions"][client_name][
                    "service_type"] = service_types[0]
开发者ID:hayderimran7,项目名称:rally,代码行数:31,代码来源:api_versions.py


示例14: _download_image

def _download_image(image_path, image=None):
    if image:
        LOG.debug("Downloading image '%s' "
                  "from Glance to %s" % (image.name, image_path))
        with open(image_path, "wb") as image_file:
            for chunk in image.data():
                image_file.write(chunk)
    else:
        LOG.debug("Downloading image from %s "
                  "to %s" % (CONF.tempest.img_url, image_path))
        try:
            response = requests.get(CONF.tempest.img_url, stream=True)
        except requests.ConnectionError as err:
            msg = _("Failed to download image. "
                    "Possibly there is no connection to Internet. "
                    "Error: %s.") % (str(err) or "unknown")
            raise exceptions.TempestConfigCreationFailure(msg)

        if response.status_code == 200:
            with open(image_path, "wb") as image_file:
                for chunk in response.iter_content(chunk_size=1024):
                    if chunk:   # filter out keep-alive new chunks
                        image_file.write(chunk)
                        image_file.flush()
        else:
            if response.status_code == 404:
                msg = _("Failed to download image. Image was not found.")
            else:
                msg = _("Failed to download image. "
                        "HTTP error code %d.") % response.status_code
            raise exceptions.TempestConfigCreationFailure(msg)

    LOG.debug("The image has been successfully downloaded!")
开发者ID:sebrandon1,项目名称:rally,代码行数:33,代码来源:config.py


示例15: _get_validated_image

def _get_validated_image(config, clients, param_name):
    image_context = config.get("context", {}).get("images", {})
    image_args = config.get("args", {}).get(param_name)
    image_ctx_name = image_context.get("image_name")

    if not image_args:
        msg = _("Parameter %s is not specified.") % param_name
        return (ValidationResult(False, msg), None)
    if "image_name" in image_context:
        # NOTE(rvasilets) check string is "exactly equal to" a regex
        # or image name from context equal to image name from args
        if "regex" in image_args:
            match = re.match(image_args.get("regex"), image_ctx_name)
        if image_ctx_name == image_args.get("name") or (
                "regex" in image_args and match):
            image = {
                "size": image_context.get("min_disk", 0),
                "min_ram": image_context.get("min_ram", 0),
                "min_disk": image_context.get("min_disk", 0)
            }
            return (ValidationResult(True), image)
    try:
        image_id = types.ImageResourceType.transform(
            clients=clients, resource_config=image_args)
        image = clients.glance().images.get(image=image_id).to_dict()
        return (ValidationResult(True), image)
    except (glance_exc.HTTPNotFound, exceptions.InvalidScenarioArgument):
        message = _("Image '%s' not found") % image_args
        return (ValidationResult(False, message), None)
开发者ID:akalambu,项目名称:rally,代码行数:29,代码来源:validation.py


示例16: install_plugin

    def install_plugin(self):
        """Install Tempest plugin for local Tempest repo."""
        LOG.info(_("Installing Tempest plugin from %s for "
                   "deployment: %s") % (self.plugin_source, self.deployment))

        version = self.plugin_version or "master"
        egg = re.sub("\.git$", "",
                     os.path.basename(self.plugin_source.strip("/")))
        cmd = ["pip", "install", "--no-deps",
               "--src", self.path("plugins/system-wide"), "-e",
               "git+{0}@{1}#egg={2}".format(self.plugin_source, version, egg)]
        # Very often Tempest plugins are inside projects and requirements
        # for plugins are listed in the test-requirements.txt file.
        test_reqs_path = self.path("plugins/system-wide/"
                                   "%s/test-requirements.txt" % egg)
        if not self._system_wide:
            cmd.remove("--no-deps")
            cmd.remove(self.path("plugins/system-wide"))
            cmd.insert(0, self.path("tools/with_venv.sh"))
            cmd.insert(4, self.path("plugins"))
            test_reqs_path = self.path("plugins/"
                                       "%s/test-requirements.txt" % egg)
        check_output(cmd, cwd=self.path())

        if os.path.exists(test_reqs_path):
            cmd = ["pip", "install", "-r", test_reqs_path]
            if not self._system_wide:
                cmd.insert(0, self.path("tools/with_venv.sh"))
            check_output(cmd, cwd=self.path())

        LOG.info(_("Tempest plugin has been successfully installed!"))
开发者ID:alinbalutoiu,项目名称:rally,代码行数:31,代码来源:tempest.py


示例17: install

    def install(self):
        """Creates local Tempest repo and virtualenv for deployment."""
        if not self.is_installed():
            LOG.info(_("Tempest is not installed "
                       "for deployment: %s") % self.deployment)
            LOG.info(_("Installing Tempest "
                       "for deployment: %s") % self.deployment)
            try:
                if not os.path.exists(self.path()):
                    if not self._is_git_repo(self.base_repo):
                        self._clone()
                    shutil.copytree(self.base_repo, self.path())

                if self.version:
                    check_output(["git", "checkout", self.version],
                                 cwd=self.path())

                if not self._system_wide:
                    self._install_venv()

                self._initialize_testr()
            except subprocess.CalledProcessError as e:
                self.uninstall()
                raise TempestSetupFailure("Failed cmd: '%s'" % e.cmd)
            else:
                LOG.info(_("Tempest has been successfully installed!"))
        else:
            LOG.info(_("Tempest is already installed."))
开发者ID:obutenko,项目名称:rally,代码行数:28,代码来源:tempest.py


示例18: setup

    def setup(self):
        # FIXME(andreykurilin): move all checks to validate method.

        # use admin only when `service_name` is presented
        admin_clients = osclients.Clients(
            self.context.get("admin", {}).get("credential"))
        clients = osclients.Clients(random.choice(
            self.context["users"])["credential"])
        services = clients.keystone().service_catalog.get_endpoints()
        services_from_admin = None
        for client_name, conf in six.iteritems(self.config):
            if "service_type" in conf and conf["service_type"] not in services:
                raise exceptions.ValidationError(_(
                    "There is no service with '%s' type in your environment.")
                    % conf["service_type"])
            elif "service_name" in conf:
                if not self.context.get("admin", {}).get("credential"):
                    raise exceptions.BenchmarkSetupFailure(_(
                        "Setting 'service_name' is allowed only for 'admin' "
                        "user."))
                if not services_from_admin:
                    services_from_admin = dict(
                        [(s.name, s.type)
                         for s in admin_clients.keystone().services.list()])
                if conf["service_name"] not in services_from_admin:
                    raise exceptions.ValidationError(
                        _("There is no '%s' service in your environment") %
                        conf["service_name"])

                self.context["config"]["api_versions"][client_name][
                    "service_type"] = services_from_admin[conf["service_name"]]
开发者ID:gluke77,项目名称:rally,代码行数:31,代码来源:api_versions.py


示例19: _download_cirros_image

    def _download_cirros_image(self):
        img_path = os.path.join(self.data_dir, IMAGE_NAME)
        if os.path.isfile(img_path):
            return

        try:
            response = requests.get(CONF.image.cirros_img_url, stream=True)
        except requests.ConnectionError as err:
            msg = _("Failed to download CirrOS image. "
                    "Possibly there is no connection to Internet. "
                    "Error: %s.") % (str(err) or "unknown")
            raise exceptions.TempestConfigCreationFailure(msg)

        if response.status_code == 200:
            with open(img_path + ".tmp", "wb") as img_file:
                for chunk in response.iter_content(chunk_size=1024):
                    if chunk:   # filter out keep-alive new chunks
                        img_file.write(chunk)
                        img_file.flush()
            os.rename(img_path + ".tmp", img_path)
        else:
            if response.status_code == 404:
                msg = _("Failed to download CirrOS image. "
                        "Image was not found.")
            else:
                msg = _("Failed to download CirrOS image. "
                        "HTTP error code %d.") % response.status_code
            raise exceptions.TempestConfigCreationFailure(msg)
开发者ID:nikolay-fedotov,项目名称:rally,代码行数:28,代码来源:config.py


示例20: required_api_versions

def required_api_versions(config, clients, deployment, component, versions):
    """Validator checks component API versions."""
    versions = [str(v) for v in versions]
    versions_str = ", ".join(versions)
    msg = _("Task was designed to be used with %(component)s "
            "V%(version)s, but V%(found_version)s is "
            "selected.")
    if component == "keystone":
        if "2.0" not in versions and hasattr(clients.keystone(), "tenants"):
            return ValidationResult(False, msg % {"component": component,
                                                  "version": versions_str,
                                                  "found_version": "2.0"})
        if "3" not in versions and hasattr(clients.keystone(), "projects"):
            return ValidationResult(False, msg % {"component": component,
                                                  "version": versions_str,
                                                  "found_version": "3"})
    else:
        used_version = config.get("context", {}).get("api_versions", {}).get(
            component, {}).get("version",
                               getattr(clients, component).choose_version())
        if not used_version:
            return ValidationResult(
                False, _("Unable to determine the API version."))
        if str(used_version) not in versions:
            return ValidationResult(
                False, msg % {"component": component,
                              "version": versions_str,
                              "found_version": used_version})
开发者ID:gluke77,项目名称:rally,代码行数:28,代码来源:validation.py



注:本文中的rally.common.i18n._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python log.getLogger函数代码示例发布时间:2022-05-26
下一篇:
Python fileutils.update_globals_file函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap