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


Python CloudProvider.activate方法代码示例

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


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

示例1: do_cloud

# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import activate [as 别名]
    def do_cloud(self, args, arguments):
        """
        ::

          Usage:
              cloud list [--cloud=CLOUD] [--format=FORMAT]
              cloud logon CLOUD
              cloud logout CLOUD
              cloud activate CLOUD
              cloud deactivate CLOUD
              cloud info CLOUD

          managing the admins test test test test

          Arguments:
            KEY    the name of the admin
            VALUE  the value to set the key to

          Options:
             --cloud=CLOUD    the name of the cloud
             --format=FORMAT  the output format [default: table]

          Description:
             Cloudmesh contains a cloudmesh.yaml file that contains
             templates for multiple clouds that you may or may not have
             access to. Hence it is useful to activate and deactivate clouds
             you like to use in other commands.

             To activate a cloud a user can simply use the activate
             command followed by the name of the cloud to be
             activated. To find out which clouds are available you can
             use the list command that will provide you with some
             basic information. As default it will print a table. Thus
             the commands::

               cloud activate india
               cloud deactivate aws

             Will result in

                +----------------------+--------+-------------------+
                | Cloud name           | Active | Type              |
                +----------------------+--------+-------------------+
                | india                | True   | Openstack         |
                +----------------------+--------+-------------------+
                | aws                  | False  | AWS               |
                +----------------------+--------+-------------------+

             To get ore information about the cloud you can use the command

                cloud info CLOUD

             It will call internally also the command uses in register

          See also:
             register
        """

        cloudname = arguments["--cloud"] or Default.cloud

        if arguments["logon"]:
            cloudname = arguments["CLOUD"]
            provider = CloudProvider(cloudname).provider
            provider.logon(cloudname)
            Console.ok("Logged into cloud: " + cloudname)

        elif arguments["logout"]:
            cloudname = arguments["CLOUD"]
            provider = CloudProvider(cloudname).provider
            provider.logout(cloudname)
            Console.ok("Logged out of cloud: " + cloudname)

        elif arguments["activate"]:
            cloudname = arguments["CLOUD"]
            provider = CloudProvider(cloudname).provider
            provider.activate(cloudname)
            Console.ok("Activated cloud: " + cloudname)

        elif arguments["deactivate"]:
            cloudname = arguments["CLOUD"]
            provider = CloudProvider(cloudname).provider
            provider.deactivate(cloudname)
            Console.ok("Deactivated cloud: " + cloudname)

        elif arguments["list"]:
            provider = CloudProvider(cloudname).provider
            clouds = provider.list_clouds()
            default = Default.cloud
            active = ConfigDict("cloudmesh.yaml")["cloudmesh"]["active"]
            key = Default.key

            def yes(state):
                if state:
                    return "*"
                else:
                    return " "

            for index in clouds:
                cloud = clouds[index]
                cloud["active"] = yes(cloud["cloud"] in active)
#.........这里部分代码省略.........
开发者ID:ashwinir20,项目名称:client,代码行数:103,代码来源:CloudCommand.py


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