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


Python AccountDriver.parse_identity方法代码示例

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


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

示例1: main

# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import parse_identity [as 别名]
def main():
    """
    Using the keyname and public_key defined in settings
    Ensure that the keypair has been distributed to every identity on the
    provider.
    It is essential that all users carry the same keypair to allow Deployment
    access
    """
    keyname = settings.ATMOSPHERE_KEYPAIR_NAME
    with open(settings.ATMOSPHERE_KEYPAIR_FILE, 'r') as pub_key_file:
        public_key = pub_key_file.read()
    print "Adding keypair: %s Contents: %s" % (keyname, public_key)
    os_providers = Provider.objects.filter(type__name="OpenStack")
    for prov in os_providers:
        count = 0
        identities = Identity.objects.filter(provider=prov)
        os_accounts = OSAccountDriver(prov)
        for ident in identities:
            creds = os_accounts.parse_identity(ident)
            try:
                (keypair, created) = os_accounts.get_or_create_keypair(
                    creds['username'], creds['password'], creds['tenant_name'],
                    keyname, public_key)
            except Unauthorized, exc:
                print "Could not create keypair for %s. Error message: %s"\
                        % (creds['username'], exc.message)
            if created:
                print "Created keypair %s for user %s"\
                        % (keypair, creds['username'])
                count += 1
        print 'Keypairs added for %s accounts on %s' % (count, prov)
开发者ID:Angelfirenze,项目名称:atmosphere,代码行数:33,代码来源:update_keypairs.py


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