def ensure_user_exists(keystone, user_name, password, email, tenant_name, check_mode):
 try:
  user = get_user(keystone, user_name)
 except KeyError:
  pass
 else:
  return (False, user.id)
 if check_mode:
  return (True, None)
 tenant = get_tenant(keystone, tenant_name)
 user = keystone.users.create(name=user_name, password=password, email=email, tenant_id=tenant.id)
 return (True, user.id)

def ensure_user_exists ( keystone , user_name , password , email , tenant_name , check_mode ) : try : user = get_user ( keystone , user_name ) except KeyError : pass else : return ( False , user . id ) if check_mode : return ( True , None ) tenant = get_tenant ( keystone , tenant_name ) user = keystone . users . create ( name = user_name , password = password , email = email , tenant_id = tenant . id ) return ( True , user . id )
check if user exists return if a new user was created .