summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2015-11-13 10:43:22 -0500
committerBrenton Leanhardt <bleanhar@redhat.com>2015-11-13 10:43:22 -0500
commit40385cc6c3ebcc6ac819d729124dab3e44d7dafa (patch)
tree01bdf3f801989fd8c648db2009715fb8b831d0a8 /roles
parent460c82e2cef0d60fe69743416627bce70663c56f (diff)
parent251dca6634e00fa58457611073ab6293468e3997 (diff)
downloadopenshift-40385cc6c3ebcc6ac819d729124dab3e44d7dafa.tar.gz
openshift-40385cc6c3ebcc6ac819d729124dab3e44d7dafa.tar.bz2
openshift-40385cc6c3ebcc6ac819d729124dab3e44d7dafa.tar.xz
openshift-40385cc6c3ebcc6ac819d729124dab3e44d7dafa.zip
Merge pull request #867 from ibotty/rm-netaddr-dep
remove netaddr dependency
Diffstat (limited to 'roles')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py21
-rw-r--r--roles/openshift_facts/tasks/main.yml3
2 files changed, 20 insertions, 4 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 2e1075aca..ae530eadd 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -24,8 +24,25 @@ import StringIO
import yaml
from distutils.util import strtobool
from distutils.version import LooseVersion
-from netaddr import IPNetwork
+import struct
+import socket
+def first_ip(network):
+ """ Return the first IPv4 address in network
+
+ Args:
+ network (str): network in CIDR format
+ Returns:
+ str: first IPv4 address
+ """
+ def atoi(addr):
+ return struct.unpack("!I", socket.inet_aton(addr))[0]
+ def itoa(addr):
+ return socket.inet_ntoa(struct.pack("!I", addr))
+
+ (address, netmask) = network.split('/')
+ netmask_i = (0xffffffff << (32 - atoi(netmask))) & 0xffffffff
+ return itoa((atoi(address) & netmask_i) + 1)
def hostname_valid(hostname):
""" Test if specified hostname should be considered valid
@@ -525,7 +542,7 @@ def set_aggregate_facts(facts):
'kubernetes.default.svc', 'kubernetes.default.svc.' + cluster_domain]
all_hostnames.update(svc_names)
internal_hostnames.update(svc_names)
- first_svc_ip = str(IPNetwork(facts['master']['portal_net'])[1])
+ first_svc_ip = first_ip(facts['master']['portal_net'])
all_hostnames.add(first_svc_ip)
internal_hostnames.add(first_svc_ip)
diff --git a/roles/openshift_facts/tasks/main.yml b/roles/openshift_facts/tasks/main.yml
index a28aa7ba2..913f0dc78 100644
--- a/roles/openshift_facts/tasks/main.yml
+++ b/roles/openshift_facts/tasks/main.yml
@@ -6,10 +6,9 @@
- ansible_version | version_compare('1.9.0', 'ne')
- ansible_version | version_compare('1.9.0.1', 'ne')
-- name: Ensure python-netaddr and PyYaml are installed
+- name: Ensure PyYaml is installed
yum: pkg={{ item }} state=installed
with_items:
- - python-netaddr
- PyYAML
- name: Gather Cluster facts