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


Python CloudProvider.list方法代码示例

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


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

示例1: test_002

# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list [as 别名]
    def test_002(self):
        """ test flavor list :return:  """
        HEADING()

        from pprint import pprint

        cloud = "chameleon-ec2"
        provider = CloudProvider(cloud).provider

        # print (provider, type(provider))

        # r = provider.list_flavor(cloud)
        # pprint(r)

        kind = 'flavor'

        r = provider.list(kind, cloud)
        pprint(r)

        assert 't2.small' in str(r)

        r = provider.list_flavor(cloud)
        pprint(r)

        assert 't2.small' in str(r)

        r = provider.provider.list_sizes(cloud)
        pprint(r)

        assert 't2.small' in str(r)
开发者ID:arpiagariu,项目名称:client,代码行数:32,代码来源:test_libcloud_api.py

示例2: test_001

# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list [as 别名]
    def test_001(self):
        """test image list :return: """
        HEADING()

        from pprint import pprint

        cloud = "chameleon-ec2"
        provider = CloudProvider(cloud).provider

        print(provider, type(provider))

        # pprint (provider.__dict__)
        # pprint (dir(provider))

        # r = provider.list_flavor(cloud)
        # pprint(r)

        for kind in ["image"]:  # ["image", "vm", "flavor", "key"]: # , "flavor", "vm", "limits", "quota"]:
            r = provider.list(kind, cloud)
            pprint(r)

        assert True
开发者ID:arpiagariu,项目名称:client,代码行数:24,代码来源:test_libcloud_api.py

示例3: refresh

# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list [as 别名]
    def refresh(cls, kind, name, **kwargs):
        """
        This method refreshes the local database
        with the live cloud details
        :param kind:
        :param name:
        :param kwargs:
        :return:
        """

        try:
            # print(cloudname)
            # get the user
            # TODO: Confirm user

            # user = cls.user
            purge = kwargs.get("purge", True)

            if kind in ["flavor", "image", "vm"]:

                # get provider for specific cloud
                provider = CloudProvider(name).provider

                elements = cls.find(category=name, kind=kind, output='dict')

                current_elements = {}
                if elements:
                    for element in elements:
                        current_elements[element["name"]] = element

                    # pprint(current_elements)

                # if purge:
                #     cls.clear(kind=kind, category=name)

                elements = provider.list(kind, name)

                for element in list(elements.values()):
                    element["uuid"] = element['id']
                    element['type'] = 'string'
                    element["category"] = name

                    # element["user"] = user
                    element["kind"] = kind
                    element["provider"] = provider.cloud_type
                    if current_elements is not None:
                        for index in current_elements:
                            current = current_elements[index]
                            for attribute in ["username", "image", "flavor", "group"]:
                                if attribute in current and current[attribute] is not None:
                                    element[attribute] = current[attribute]
                    # print ("CCC", index, element["name"], element["flavor"])
                    cls.add(element)

                return True

            elif kind in ["batchjob"]:

                # provider = BatchProvider(name).provider
                # provider = BatchProvider(name)

                from cloudmesh_client.cloud.hpc.BatchProvider import BatchProvider
                provider = BatchProvider(name)

                vms = provider.list_job(name)
                for job in list(vms.values()):
                    job[u'uuid'] = job['id']
                    job[u'type'] = 'string'
                    job[u'category'] = name
                    # job[u'user'] = user

                    cls.add(job)
                    cls.save()
                return True

            elif kind not in ["secgroup"]:
                Console.error("refresh not supported for this kind: {}".format(kind))

        except Exception as ex:
            Console.error("Problem with secgroup")
            return False
开发者ID:arpiagariu,项目名称:client,代码行数:83,代码来源:CloudmeshDatabase.py


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