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


Python AccountDriver.list_all_images方法代码示例

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


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

示例1: main

# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import list_all_images [as 别名]
def main():
    for prov in Provider.objects.filter(type__name__icontains='openstack'):
        if not prov.is_active():
            continue
        print "Importing machine membership for %s" % prov
        accounts = OSAccounts(prov)
        if not accounts:
            print "Aborting import: Could not retrieve OSAccounts driver "\
                    "for Provider %s" % prov
            continue
        admin_driver = get_admin_driver(prov)
        if not admin_driver:
            print "Aborting import: Could not retrieve admin_driver "\
                    "for Provider %s" % prov
            continue

        private_images = admin_driver.filter_machines(
                accounts.list_all_images(is_public=False),
                black_list=["eki-", "eri-", "ChromoSnapShot"])

        public_images = admin_driver.filter_machines(
                accounts.list_all_images(is_public=True),
                black_list=["eki-", "eri-", "ChromoSnapShot"])

        fix_public_images(public_images, prov, accounts)
        fix_private_images(private_images, prov, accounts)
        fix_private_images_without_repr(private_images, prov, accounts)
开发者ID:420reich,项目名称:atmosphere,代码行数:29,代码来源:import_machine_membership.py

示例2: update_membership

# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import list_all_images [as 别名]
def update_membership():
    from core.models import ApplicationMembership, Provider, ProviderMachine
    from service.accounts.openstack import AccountDriver as OSAcctDriver
    from service.accounts.eucalyptus import AccountDriver as EucaAcctDriver
    for provider in Provider.objects.all():
        if not provider.is_active():
            return []
        if provider.type.name.lower() == 'openstack':
            driver = OSAcctDriver(provider)
        else:
            logger.warn("Encountered unknown ProviderType:%s, expected"
                        " [Openstack]")
            continue
        images = driver.list_all_images()
        changes = 0
        for img in images:
            pm = ProviderMachine.objects.filter(identifier=img.id,
                                                provider=provider)
            if not pm or len(pm) > 1:
                logger.debug("pm filter is bad!")
                logger.debug(pm)
                continue
            else:
                pm = pm[0]
            app_manager = pm.application.applicationmembership_set
            if not img.is_public:
                #Lookup members
                image_members = accts.image_manager.shared_images_for(
                    image_id=img.id)
                #add machine to each member
                #(Who owns the cred:ex_project_name) in MachineMembership
                #for member in image_members:
            else:
                members = app_manager.all()
                if members:
                    logger.info("Application for PM:%s used to be private."
                                " %s Users membership has been revoked. "
                                % (img.id, len(members)))
                    changes += len(members)
                    members.delete()
                #if MachineMembership exists, remove it (No longer private)
    logger.info("Total Updates to machine membership:%s" % changes)
    return changes
开发者ID:chromabinary,项目名称:atmosphere,代码行数:45,代码来源:driver.py


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