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


Python default.Default类代码示例

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


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

示例1: boot

    def boot(self, cloud=None, image=None, flavor=None, key=None, arguments=None):
        """
        Boots the image on a specified cloud

        :param image: The name of the image
        :type image: str
        :param flavor: The name of the flavor
        :type flavor: str
        :param key: The name of the key
        :type key: str
        :param cloud: The name of the cloud
        :type cloud: str
        :param arguments: An array of arguments
        :type arguments: list of str
        :return: the id of the vm
        :rtype: str
        """
        if cloud is None:
            cloud = Default.get("cloud", "general")
            print("get default cloud: " + str(cloud))
        if image is None:
            image = Default.get("image", cloud)
            print("get default image ", str(image))
        if flavor is None:
            flavor = Default.get("flavor", cloud)
            print("get default flavor ", str(flavor))
        if key is None:
            key = Default.get("key", str(cloud))
            print("get default key ", str(key))

        # command_key

        print("boot an image", image, flavor, key, cloud, arguments)
        pass
开发者ID:atavism,项目名称:client,代码行数:34,代码来源:mesh.py

示例2: test_001

 def test_001(self):
     """
     delete defaults
     :return:
     """
     HEADING()
     Default.clear()
     assert Default.list() == None
开发者ID:atavism,项目名称:client,代码行数:8,代码来源:test_default.py

示例3: __init__

 def __init__(self, context):
     self.context = context
     if self.context.debug:
         print("init command refresh")
     try:
         value = Default.get_refresh()
     except:
         Default.set_refresh("off")
开发者ID:rajaramcomputers,项目名称:client,代码行数:8,代码来源:RefreshCommand.py

示例4: test_999

    def test_999(self):
        """
        clear the defaults
        :return:
        """
        HEADING()

        Default.clear()
        assert True
开发者ID:atavism,项目名称:client,代码行数:9,代码来源:test_default.py

示例5: test_005

 def test_005(self):
     """
     set default key
     :return:
     """
     HEADING()
     name = "mykey"
     Default.set_key(name)
     assert Default.get_key() == name
     self._check(name)
开发者ID:atavism,项目名称:client,代码行数:10,代码来源:test_default.py

示例6: test_004

 def test_004(self):
     """
     set default flavor
     :return:
     """
     HEADING()
     name = "myflavor"
     Default.set_flavor(name, "mycloud")
     assert Default.get_flavor("mycloud") == name
     self._check(name)
开发者ID:atavism,项目名称:client,代码行数:10,代码来源:test_default.py

示例7: test_003

 def test_003(self):
     """
     set default image
     :return:
     """
     HEADING()
     name = "myimage"
     Default.set_image(name, "mycloud")
     assert Default.get_image("mycloud") == name
     self._check(name)
开发者ID:atavism,项目名称:client,代码行数:10,代码来源:test_default.py

示例8: test_006

 def test_006(self):
     """
     set default key
     :return:
     """
     HEADING()
     name = "mygroup"
     Default.set_group(name)
     assert Default.get_group() == name
     self._check(name)
开发者ID:atavism,项目名称:client,代码行数:10,代码来源:test_default.py

示例9: test_007

 def test_007(self):
     """
     set default variable
     :return:
     """
     HEADING()
     name = "myvar"
     value = "myvalue"
     cloud = "mycloud"
     Default.set(name, value, cloud)
     assert Default.get(name, cloud) == value
     self._check(value)
开发者ID:atavism,项目名称:client,代码行数:12,代码来源:test_default.py

示例10: do_image

    def do_image(self, args, arguments):
        """
        ::

            Usage:
                image refresh [--cloud=CLOUD]
                image list [ID] [--cloud=CLOUD] [--format=FORMAT] [--refresh]

                This lists out the images present for a cloud

            Options:
               --format=FORMAT  the output format [default: table]
               --cloud=CLOUD    the cloud name
               --refresh        live data taken from the cloud

            Examples:
                cm image refresh
                cm image list
                cm image list --format=csv
                cm image list 58c9552c-8d93-42c0-9dea-5f48d90a3188 --refresh

        """
        cloud = arguments["--cloud"] or Default.get_cloud()
        if cloud is None:
            Console.error("Default cloud doesn't exist")
            return

        if arguments["refresh"] or Default.refresh():
            msg = "Refresh image for cloud {:}.".format(cloud)
            if Image.refresh(cloud):
                Console.ok("{:} ok.".format(msg))
            else:
                Console.error("{:} failed.".format(msg))
            return ""

        if arguments["list"]:
            id = arguments['ID']
            live = arguments['--refresh']
            output_format = arguments["--format"]
            if id is None:
                result = Image.list(cloud, output_format)
            else:
                result = Image.details(cloud, id, live, output_format)
            if result is None:
                Console.error("No image(s) found. Failed.")
            # Todo:
            # if database size = 0:
            #    Console.error("No images in the database, please refresh.")
            print(result)
            return ""
开发者ID:rajaramcomputers,项目名称:client,代码行数:50,代码来源:ImageCommand.py

示例11: do_check

    def do_check(self, args, arguments):
        """
        ::

            Usage:
                check --cloud=CLOUD
                check

                checks some elementary setting for cloudmesh

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

            Examples:
                cm check
                cm check --cloud=kilo

        """
        cloud = arguments["--cloud"] or Default.get_cloud()

        if cloud is None:
            Console.error("Default cloud doesn't exist")

        print(locals())

        Console.ok("{:} ok".format(cloud))

        return ""
开发者ID:rajaramcomputers,项目名称:client,代码行数:29,代码来源:CheckCommand.py

示例12: do_limits

    def do_limits(self, args, arguments):
        """
        ::

            Usage:
                limits list [--cloud=CLOUD] [--tenant=TENANT] [--format=FORMAT]

                Current list data with limits on a selected project/tenant.
                The --tenant option can be used by admin only

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

            Examples:
                cm limits list
                cm limits list --cloud=juno --format=csv

        """
        if arguments["list"]:
            cloud = arguments["--cloud"] or Default.get_cloud()

            if not cloud:
                Console.error("cloud doesn't exist")
                return ""

            output_format = arguments["--format"]
            tenant = arguments["--tenant"]
            result = Limits.list(cloud,
                                 output=output_format,
                                 tenant=tenant)
            Console.msg(result)
            return ""
开发者ID:atavism,项目名称:client,代码行数:34,代码来源:LimitsCommand.py

示例13: do_cloud

    def do_cloud(self, args, arguments):
        """
        ::

          Usage:
              cloud list [--cloud=CLOUD] [--format=FORMAT]
              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 [default: general]
             --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 deacivate 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
        """
        # pprint(arguments)
        cloud = arguments["--cloud"] or Default.get_cloud()
        output_format = arguments["--format"]
        Console.error("TODO: Command not yet implemented.")
        pass
开发者ID:atavism,项目名称:client,代码行数:60,代码来源:CloudCommand.py

示例14: do_quota

    def do_quota(self, args, arguments):
        """
        ::

            Usage:
                quota list [--cloud=CLOUD] [--tenant=TENANT] [--format=FORMAT]

                Prints quota limit on a current project/tenant

            Options:
               --format=FORMAT  the output format [default: table]
               --cloud=CLOUD    the cloud name
               --tenant=TENANT  the tenant id

            Examples:
                cm quota list
                cm quota list --cloud=india --format=csv

        """
        if arguments["list"]:
            cloud = arguments["--cloud"] or Default.get_cloud()

            if not cloud:
                Console.error("Default cloud doesn't exist")
                return
            tenant = arguments["--tenant"]
            output_format = arguments["--format"]
            list_quotas = Quota.list(cloud,
                                     tenant,
                                     output=output_format)
            Console.msg(list_quotas)
            return
开发者ID:atavism,项目名称:client,代码行数:32,代码来源:QuotaCommand.py

示例15: get_info

    def get_info(cls, cloud="kilo", name=None, output="table"):
        """
        Method to get info about a group
        :param cloud:
        :param name:
        :param output:
        :return:
        """
        try:
            cloud = cloud or Default.get("cloud")
            args = {
                "name": name,
                "cloud": cloud
            }

            # group = cls.get(name=name, cloud=cloud)
            group = cls.cm.find("group", output="object", **args).first()

            if group is not None:
                d = cls.to_dict(group)
                # Transform the dict to show multiple rows per vm
                newdict = Group.transform_dict(d)
            else:
                return None

            return dict_printer(newdict,
                                order=cls.order,
                                output=output)
        except Exception as ex:
            Console.error(ex.message, ex)
开发者ID:rajaramcomputers,项目名称:client,代码行数:30,代码来源:group.py


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