Skip to content

Commit

Permalink
Improve adding fip to loopback function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekaterina Chernova committed Sep 11, 2018
1 parent df5c9f3 commit 42e3efc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions kqueen/engines/openstack_kubespray.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,20 @@ def _add_fip_to_lo(self, resources):
"""
cmd_fmt = (
"sudo /bin/sh -c 'cat > /etc/rc.local <<EOF\n"
"/sbin/ip addr add %s/32 dev lo\n"
"/sbin/ip addr add %s/32 scope host dev lo\n"
"EOF'"
)
for master in resources["masters"]:
ip = master["fip"]
host = "@".join((self.ssh_username, ip))
ssh_cmd = ("ssh", host) + self.ssh_common_args
subprocess.check_call(ssh_cmd + (cmd_fmt % ip, ))
subprocess.check_call(ssh_cmd + ("sudo /bin/sh /etc/rc.local", ))
try:
subprocess.check_call(ssh_cmd + (cmd_fmt % ip, ))
subprocess.check_call(ssh_cmd + ("sudo /bin/sh /etc/rc.local", ))
except subprocess.CalledProcessError as e:
raise RuntimeError("Enable to add a loopback "
"to make localhost accessible by floating IP. "
"The reason is: {}".format(e))

def scale(self, resources):
inventory = self._generate_inventory(resources)
Expand Down

0 comments on commit 42e3efc

Please sign in to comment.