Skip to content

Instantly share code, notes, and snippets.

@tbarbugli
Created December 23, 2015 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbarbugli/a02a78ff7aa2886a7c13 to your computer and use it in GitHub Desktop.
Save tbarbugli/a02a78ff7aa2886a7c13 to your computer and use it in GitHub Desktop.
from cassandra.policies import DCAwareRoundRobinPolicy
from cassandra.policies import HostDistance
from IPy import IP
class LocalNetworkDCAwareRoundRobinPolicy(DCAwareRoundRobinPolicy):
def distance(self, host):
host_distance = super(LocalNetworkDCAwareRoundRobinPolicy, self).distance(host)
if IP(host.address).iptype() == 'PUBLIC':
return HostDistance.IGNORED
return host_distance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment