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


Python ConfigDict.data["cloudmesh"]["comet"]["active"]方法代码示例

本文整理汇总了Python中cloudmesh_client.common.ConfigDict.ConfigDict.data["cloudmesh"]["comet"]["active"]方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigDict.data["cloudmesh"]["comet"]["active"]方法的具体用法?Python ConfigDict.data["cloudmesh"]["comet"]["active"]怎么用?Python ConfigDict.data["cloudmesh"]["comet"]["active"]使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloudmesh_client.common.ConfigDict.ConfigDict的用法示例。


在下文中一共展示了ConfigDict.data["cloudmesh"]["comet"]["active"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_comet

# 需要导入模块: from cloudmesh_client.common.ConfigDict import ConfigDict [as 别名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import data["cloudmesh"]["comet"]["active"] [as 别名]

#.........这里部分代码省略.........
            config = ConfigDict("cloudmesh.yaml")
            # for unit testing only.
            cometConf = config["cloudmesh.comet"]
            endpoints = []
            # print (cometConf.keys())
            if "endpoints" in cometConf.keys():
                endpoints = cometConf["endpoints"].keys()
                if len(endpoints) < 1:
                    Console.error("No service endpoints available. "
                                  "Please check the config template",
                                  traceflag=False)
                    return ""
            if "username" in cometConf.keys():
                default_username = cometConf['username']
                # print (default_username)
                if 'TBD' == default_username:
                    set_default_user = \
                        input("Set a default username (RETURN to skip): ")
                    if set_default_user:
                        config.data["cloudmesh"]["comet"]["username"] = \
                            set_default_user
                        config.save()
                        Console.ok("Comet default username set!")
            if "active" in cometConf.keys():
                active_endpoint = cometConf['active']
                set_active_endpoint = \
                    input("Set the active service endpoint to use. "
                          "The availalbe endpoints are - %s [%s]: "
                          % ("/".join(endpoints),
                             active_endpoint)
                          )
                if set_active_endpoint:
                    if set_active_endpoint in endpoints:
                        config.data["cloudmesh"]["comet"]["active"] = \
                            set_active_endpoint
                        config.save()
                        Console.ok("Comet active service endpoint set!")
                    else:
                        Console.error("The provided endpoint does not match "
                                      "any available service endpoints. Try %s"
                                      % "/".join(endpoints),
                                      traceflag=False)

            if cometConf['active'] in endpoints:
                endpoint_url = cometConf["endpoints"] \
                    [cometConf['active']]["nucleus_base_url"]
                api_version = cometConf["endpoints"] \
                    [cometConf['active']]["api_version"]
                set_endpoint_url = \
                    input("Set the base url for the nucleus %s service [%s]: " \
                          % (cometConf['active'],
                             endpoint_url)
                          )
                if set_endpoint_url:
                    if set_endpoint_url != endpoint_url:
                        config.data["cloudmesh"]["comet"]["endpoints"] \
                            [cometConf['active']]["nucleus_base_url"] \
                            = set_endpoint_url
                        config.save()
                        Console.ok("Service base url set!")

                set_api_version = \
                    input("Set the api version for the nucleus %s service [%s]: " \
                          % (cometConf['active'],
                             api_version)
                          )
开发者ID:cloudmesh,项目名称:client,代码行数:70,代码来源:CometCommand.py

示例2: do_comet

# 需要导入模块: from cloudmesh_client.common.ConfigDict import ConfigDict [as 别名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import data["cloudmesh"]["comet"]["active"] [as 别名]

#.........这里部分代码省略.........
            print ("Initializing the comet configuration file...")
            config = ConfigDict("cloudmesh.yaml")
            # for unit testing only.
            cometConf = config["cloudmesh.comet"]
            endpoints = []
            # print (cometConf.keys())
            if "endpoints" in cometConf.keys():
                endpoints = cometConf["endpoints"].keys()
                if len(endpoints) < 1:
                    Console.error("No service endpoints available."\
                                  " Please check the config template")
                    return ""
            if "username" in cometConf.keys():
                default_username = cometConf['username']
                # print (default_username)
                if 'TBD' == default_username:
                    set_default_user = \
                        input("Set a default username (RETURN to skip): ")
                    if set_default_user:
                        config.data["cloudmesh"]["comet"]["username"] = \
                            set_default_user
                        config.save()
                        Console.ok("Comet default username set!")
            if "active" in cometConf.keys():
                active_endpoint = cometConf['active']
                set_active_endpoint = \
                        input("Set the active service endpoint to use. "\
                                  "The availalbe endpoints are - %s [%s]: "\
                                   % ("/".join(endpoints),
                                     active_endpoint)
                                 )
                if set_active_endpoint:
                    if set_active_endpoint in endpoints:
                        config.data["cloudmesh"]["comet"]["active"] = \
                                        set_active_endpoint
                        config.save()
                        Console.ok("Comet active service endpoint set!")
                    else:
                        Console.error("The provided endpoint does not match any "\
                                      "available service endpoints. Try %s" \
                                      % "/".join(endpoints) )

            if cometConf['active'] in endpoints:
                endpoint_url = cometConf["endpoints"]\
                               [cometConf['active']]["nucleus_base_url"]
                api_version = cometConf["endpoints"]\
                               [cometConf['active']]["api_version"]
                set_endpoint_url = \
                        input("Set the base url for the nucleus %s service [%s]: "\
                                   % (cometConf['active'],
                                      endpoint_url)
                                 )
                if set_endpoint_url:
                    if set_endpoint_url != endpoint_url:
                        config.data["cloudmesh"]["comet"]["endpoints"]\
                                    [cometConf['active']]["nucleus_base_url"]\
                                    = set_endpoint_url
                        config.save()
                        Console.ok("Service base url set!")

                set_api_version = \
                        input("Set the api version for the nucleus %s service [%s]: "\
                                   % (cometConf['active'],
                                   api_version)
                                 )
                if set_api_version:
开发者ID:sohiljain,项目名称:client,代码行数:70,代码来源:CometCommand.py


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