def get_tenants(keystone_client): logger.debug("Getting tenants...") dic_tenants = {} tenants = os_utils.get_tenants(keystone_client) if not (tenants is None or len(tenants) == 0): for tenant in tenants: dic_tenants.update({getattr(tenant, 'id'): getattr(tenant, 'name')}) return {'tenants': dic_tenants}
def get_tenants(keystone_client): logger.debug("Getting tenants...") dic_tenants = {} tenants = os_utils.get_tenants(keystone_client) if not (tenants is None or len(tenants) == 0): for tenant in tenants: dic_tenants.update( {getattr(tenant, 'id'): getattr(tenant, 'name')}) return {'tenants': dic_tenants}
def remove_tenants(keystone_client, default_tenants): logger.info("Removing Tenants...") tenants = os_utils.get_tenants(keystone_client) if tenants is None: logger.debug("There are no tenants in the deployment. ") return for tenant in tenants: tenant_name = getattr(tenant, 'name') tenant_id = getattr(tenant, 'id') logger.debug("'%s', ID=%s " % (tenant_name, tenant_id)) if tenant_id not in default_tenants: logger.debug(" Removing '%s'..." % tenant_name) if os_utils.delete_tenant(keystone_client, tenant_id): logger.debug(" > Done!") else: logger.error("There has been a problem removing the " "tenant '%s'(%s)..." % (tenant_name, tenant_id)) else: logger.debug(" > this is a default tenant and will " "NOT be deleted.")