Exemple #1
0
def _cloud_cluster_factory(whitelist_lbp, **kwargs):
    options = kwargs.copy()
    if whitelist_lbp:
        execution_profiles = options.pop('execution_profiles')

    cluster = Cluster(**options)

    if whitelist_lbp:
        cluster.profile_manager.profiles.update(execution_profiles)

        if whitelist_lbp is True:
            # applying load balancing policy as we now know the contact points
            contact_points = [random.choice(cluster.contact_points)]
        else:
            # An explicit host was specified
            contact_points = [whitelist_lbp]

        for execution_profile in cluster.profile_manager.profiles.values():
            execution_profile.load_balancing_policy = EndpointWhiteListRoundRobinPolicy(contact_points)
        cluster.endpoints_resolved = contact_points

    return cluster