當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。