Skip to content

Commit

Permalink
v0.2.23: Prioritize eth interfaces when choosing ipcontroller IPs to …
Browse files Browse the repository at this point in the history
…make better choices on clusters with multiple IPs: bcbio/bcbio-nextgen#416
  • Loading branch information
chapmanb committed May 16, 2014
1 parent 4c41cdc commit 4046760
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions cluster_helper/cluster.py
Expand Up @@ -86,9 +86,14 @@ def _get_public_ip(self):
Adjusts _load_ips_netifaces from IPython.utils.localinterfaces. Changes
submitted upstream so we can remove this when incorporated into released IPython.
Prioritizes a set of common interfaces to try and make better decisions
when choosing from multiple choices.
"""
public_ips = []
standard_ips = []
priority_ips = []
vm_ifaces = set(["docker0", "virbr0", "lxcbr0"]) # VM/container interfaces we do not want
priority_ifaces = ("eth",) # Interfaces we prefer to get IPs from

# list of iface names, 'lo0', 'eth0', etc.
for iface in netifaces.interfaces():
Expand All @@ -100,10 +105,11 @@ def _get_public_ip(self):
if not addr:
continue
if not (iface.startswith('lo') or addr.startswith('127.')):
public_ips.append(addr)
# pick first valid address for each interface to avoid double bound addresses
break
public_ips = uniq_stable(public_ips)
if iface.startswith(priority_ifaces):
priority_ips.append(addr)
else:
standard_ips.append(addr)
public_ips = uniq_stable(standard_ips + priority_ips)
return public_ips[-1]

def save_connection_dict(self, fname, cdict):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages

setup(name = "ipython-cluster-helper",
version = "0.2.22",
version = "0.2.23",
author = "Rory Kirchner",
author_email = "rory.kirchner@gmail.com",
description = "Simplify IPython cluster start up and use for multiple schedulers.",
Expand Down

0 comments on commit 4046760

Please sign in to comment.