예제 #1
0
def cleanup_default_tenants(context):
    """ Cleans up a previously created default tenants. """
    print "### Cleaning up tenants ###"
    admin = context.getAdministrationService()
    enterprises = admin.listEnterprises(Predicates.not(EnterprisePredicates.name("Abiquo")))
    for enterprise in enterprises:
        # This will remove the enterprise and all users (if none of them is a Cloud Admin)
        print "Removing enterprise %s and all users..." % enterprise.getName()
        enterprise.delete()
예제 #2
0
파일: tenants.py 프로젝트: abelboldu/kahuna
def cleanup_default_tenants(config, context):
    """ Cleans up a previously created default tenants """
    log.info("### Cleaning up tenants ###")
    admin = context.getAdministrationService()
    enterprises = admin.listEnterprises(
            Predicates.not(EnterprisePredicates.name("Abiquo")))
    for enterprise in enterprises:
        # This will remove the enterprise and all users
        # (if none of them is a Cloud Admin)
        log.info("Removing enterprise %s and all users..."  \
                % enterprise.getName())
        enterprise.delete()

    rolefilter = Predicates.not(Predicates.or(
        RolePredicates.name("CLOUD_ADMIN"),
        RolePredicates.name("ENTERPRISE_ADMIN"),
        RolePredicates.name("USER")))
    roles = admin.listRoles(rolefilter)
    # This will remove all non default roles
    for role in roles:
        log.info("Removing role %s..." % role.getName())
        role.delete()