Commit 96a7e7d5 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

slapos.cli.boot: allow custom hostname for network test, default is slap.vifib.com

parent c7ebe964
......@@ -25,6 +25,10 @@ tap_base_name = slaptap
ipv4_local_network = 10.0.0.0/16
# Change to true if you want slapos to use local-only IPv6
use_unique_local_address = False
# IPv6 host to ping6 while testing network
ipv6_test_hostname = slap.vifib.com
# IPv4 host to ping while testing network
ipv4_test_hostname = slap.vifib.com
# to enable, change to [firewall]
[disabled-firewall]
......
......@@ -64,13 +64,13 @@ def _runFormat(app):
return 0
return 1
def _ping():
def _ping(hostname):
"""
Ping a hostname
"""
print "[BOOT] Invoking ping to ipv4 network..."
p = subprocess.Popen(
["ping", "-c", "2", "www.google.com"],
["ping", "-c", "2", hostname],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode == 0:
......@@ -79,13 +79,13 @@ def _ping():
print "[BOOT] [ERROR] IPv4 network unreachable..."
return 0
def _ping6():
def _ping6(hostname):
"""
Ping an ipv6 address
"""
print "[BOOT] Invoking ping to ipv6 network..."
p = subprocess.Popen(
["ping6", "-c", "2", "ipv6.google.com"],
["ping6", "-c", "2", hostname],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode == 0:
......@@ -110,15 +110,21 @@ class BootCommand(ConfigCommand):
@must_be_root
def take_action(self, args):
configp = self.fetch_config(args)
# Make sure ipv4 is working
instance_root = configp.get('slapos','instance_root')
is_ready = _ping()
ipv6_host = ipv4_host = "slap.vifib.com"
if configp.has_option('slapformat','ipv6_test_hostname'):
ipv6_host = configp.get('slapformat','ipv6_test_hostname')
if configp.has_option('slapformat','ipv4_test_hostname'):
ipv4_host = configp.get('slapformat','ipv4_test_hostname')
# Make sure ipv4 is working
is_ready = _ping(ipv4_host)
while is_ready == 0:
sleep(5)
is_ready = _ping()
# Make sure ipv6 is working
is_ready = _ping6()
is_ready = _ping6(ipv6_host)
while is_ready == 0:
sleep(5)
is_ready = _ping6()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment