当前位置: 首页>>代码示例>>Python>>正文


Python envutils.get_global函数代码示例

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


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

示例1: test_task

 def test_task(self):
     cfg = {
         "Dummy.dummy_random_fail_in_atomic": [
             {
                 "runner": {
                     "type": "constant",
                     "times": 100,
                     "concurrency": 5
                 }
             }
         ]
     }
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(cfg)
         output = self.rally(("task start --task %(task_file)s "
                              "--deployment %(deployment_id)s") %
                             {"task_file": config.filename,
                              "deployment_id": deployment_id})
         result = re.search(
             r"(?P<uuid>[0-9a-f\-]{36}): started", output)
         uuid = result.group("uuid")
         self.rally("use task --uuid %s" % uuid)
         current_task = envutils.get_global("RALLY_TASK")
         self.assertEqual(uuid, current_task)
开发者ID:akalambu,项目名称:rally,代码行数:25,代码来源:test_cli_use.py

示例2: test_use

 def test_use(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(self._get_sample_task_config())
         output = rally(("task start --task %(task_file)s "
                         "--deployment %(deployment_id)s") %
                        {"task_file": config.filename,
                         "deployment_id": deployment_id})
         result = re.search(
             r"(?P<uuid>[0-9a-f\-]{36}): started", output)
         uuid = result.group("uuid")
         rally("task use --task %s" % uuid)
         current_task = envutils.get_global("RALLY_TASK")
         self.assertEqual(uuid, current_task)
开发者ID:tiagoapr,项目名称:rally,代码行数:15,代码来源:test_cli_task.py

示例3: show_verifier

    def show_verifier(self, api, verifier_id=None):
        """Show detailed information about a verifier."""

        verifier = api.verifier.get(verifier_id=verifier_id)
        fields = ["UUID", "Status", "Created at", "Updated at", "Active",
                  "Name", "Description", "Type", "Platform", "Source",
                  "Version", "System-wide", "Extra settings", "Location",
                  "Venv location"]
        used_verifier = envutils.get_global(envutils.ENV_VERIFIER)
        formatters = {
            "Created at": lambda v: v["created_at"].replace("T", " "),
            "Updated at": lambda v: v["updated_at"].replace("T", " "),
            "Active": lambda v: u"\u2714"
                                if v["uuid"] == used_verifier else None,
            "Extra settings": lambda v: (json.dumps(v["extra_settings"],
                                                    indent=4)
                                         if v["extra_settings"] else None),
            "Location": lambda v: self._get_location((v["uuid"]), "repo")
        }
        if not verifier["system_wide"]:
            formatters["Venv location"] = lambda v: self._get_location(
                v["uuid"], ".venv")
        cliutils.print_dict(verifier, fields=fields, formatters=formatters,
                            normalize_field_names=True, print_header=False,
                            table_label="Verifier")
        print("Attention! All you do in the verifier repository or verifier "
              "virtual environment, you do it at your own risk!")
开发者ID:andreykurilin,项目名称:rally,代码行数:27,代码来源:verify.py

示例4: test_deployment

 def test_deployment(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = self._get_deployment_uuid(output)
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("use deployment --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
开发者ID:akalambu,项目名称:rally,代码行数:9,代码来源:test_cli_use.py

示例5: test_use

 def test_use(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = re.search(r"Using deployment: (?P<uuid>[0-9a-f\-]{36})",
                          output).group("uuid")
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("deployment use --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
开发者ID:akalambu,项目名称:rally,代码行数:10,代码来源:test_cli_deployment.py

示例6: test_validate_is_invalid

 def test_validate_is_invalid(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
     cfg = {"invalid": "config"}
     config = utils.TaskConfig(cfg)
     self.assertRaises(utils.RallyCliError,
                       rally,
                       ("task validate --task %(task_file)s "
                        "--deployment %(deployment_id)s") %
                       {"task_file": config.filename,
                        "deployment_id": deployment_id})
开发者ID:tiagoapr,项目名称:rally,代码行数:12,代码来源:test_cli_task.py

示例7: _test_start_abort_on_sla_failure

 def _test_start_abort_on_sla_failure(self, cfg, times):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(cfg)
         rally(("task start --task %(task_file)s "
                "--deployment %(deployment_id)s --abort-on-sla-failure") %
               {"task_file": config.filename,
                "deployment_id": deployment_id})
         results = json.loads(rally("task results"))
     iterations_completed = len(results[0]["result"])
     self.assertTrue(iterations_completed < times)
开发者ID:tiagoapr,项目名称:rally,代码行数:12,代码来源:test_cli_task.py

示例8: test_start

 def test_start(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         cfg = self._get_sample_task_config()
         config = utils.TaskConfig(cfg)
         output = rally(("task start --task %(task_file)s "
                         "--deployment %(deployment_id)s") %
                        {"task_file": config.filename,
                         "deployment_id": deployment_id})
     result = re.search(
         r"(?P<task_id>[0-9a-f\-]{36}): started", output)
     self.assertIsNotNone(result)
开发者ID:tiagoapr,项目名称:rally,代码行数:13,代码来源:test_cli_task.py

示例9: launch_verification_once

def launch_verification_once(launch_parameters):
    """Launch verification and show results in different formats."""
    results = call_rally("verify start %s" % launch_parameters)
    results["uuid"] = envutils.get_global(envutils.ENV_VERIFICATION)
    results["result_in_html"] = call_rally("verify results",
                                           output_type="html")
    results["result_in_json"] = call_rally("verify results",
                                           output_type="json")
    results["show"] = call_rally("verify show")
    results["show_detailed"] = call_rally("verify show --detailed")
    # NOTE(andreykurilin): we need to clean verification uuid from global
    # environment to be able to load it next time(for another verification).
    envutils.clear_global(envutils.ENV_VERIFICATION)
    return results
开发者ID:gluke77,项目名称:rally,代码行数:14,代码来源:rally_verify.py

示例10: setup

def setup(): 
    if CONF.profile:
        profile = CONF.profile
    else:
        profile = envutils.get_global("RALLY_PROFILE")
        if profile == None:
            profile = PROFILE_OPENSTACK
            
    if not profile in PROFILE_ALL_LIST:
        raise InvalidArgumentsException("Unknown profile %s" % profile)
    
    fileutils.update_globals_file("RALLY_PROFILE", profile)
    
    print("Using profile: %s" % profile)    
开发者ID:huikang,项目名称:rally,代码行数:14,代码来源:profile.py

示例11: list

    def list(self, api, deployment_list=None):
        """List existing deployments."""

        headers = ["uuid", "created_at", "name", "status", "active"]
        current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
        deployment_list = deployment_list or api.deployment.list()

        table_rows = []
        if deployment_list:
            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deployment else "*")
                table_rows.append(utils.Struct(**dict(zip(headers, r))))
            cliutils.print_list(table_rows, headers,
                                sortby_index=headers.index("created_at"))
        else:
            print("There are no deployments. To create a new deployment, use:"
                  "\nrally deployment create")
开发者ID:jacobwagner,项目名称:rally,代码行数:18,代码来源:deployment.py

示例12: list

 def list(self, api, to_json=False):
     """List existing environments."""
     envs = env_mgr.EnvManager.list()
     if to_json:
         print(json.dumps([env.cached_data for env in envs], indent=2))
     elif not envs:
         print(self.MSG_NO_ENVS)
     else:
         cur_env = envutils.get_global(envutils.ENV_ENV)
         table = prettytable.PrettyTable()
         fields = ["uuid", "name", "status", "created_at", "description"]
         table.field_names = fields + ["default"]
         for env in envs:
             row = [env.cached_data[f] for f in fields]
             row.append(cur_env == env.cached_data["uuid"] and "*" or "")
             table.add_row(row)
         table.sortby = "created_at"
         table.reversesort = True
         table.align = "l"
         print(table.get_string())
开发者ID:jacobwagner,项目名称:rally,代码行数:20,代码来源:env.py

示例13: list_verifiers

    def list_verifiers(self, api, status=None):
        """List all verifiers."""

        verifiers = api.verifier.list(status=status)
        if verifiers:
            fields = ["UUID", "Name", "Type", "Platform", "Created at",
                      "Updated at", "Status", "Version", "System-wide",
                      "Active"]
            cv = envutils.get_global(envutils.ENV_VERIFIER)
            formatters = {
                "Created at": lambda v: v["created_at"],
                "Updated at": lambda v: v["updated_at"],
                "Active": lambda v: u"\u2714" if v["uuid"] == cv else "",
            }
            cliutils.print_list(verifiers, fields, formatters=formatters,
                                normalize_field_names=True, sortby_index=4)
        elif status:
            print("There are no verifiers with status '%s'." % status)
        else:
            print("There are no verifiers. You can create verifier, using "
                  "command `rally verify create-verifier`.")
开发者ID:andreykurilin,项目名称:rally,代码行数:21,代码来源:verify.py

示例14: test_get_task_id_with_none

 def test_get_task_id_with_none(self, mock_load_env_file):
     self.assertIsNone(envutils.get_global("RALLY_TASK"))
     mock_load_env_file.assert_called_once_with(os.path.expanduser(
         "~/.rally/globals"))
开发者ID:gwdg,项目名称:rally,代码行数:4,代码来源:test_envutils.py

示例15: test_get_task_id_in_env

 def test_get_task_id_in_env(self):
     self.assertEqual("my_task_id", envutils.get_global(envutils.ENV_TASK))
开发者ID:gwdg,项目名称:rally,代码行数:2,代码来源:test_envutils.py


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