Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
981e23fd
Commit
981e23fd
authored
Nov 12, 2018
by
Alain Takoudjou
Committed by
Rafael Monnerat
Nov 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos node boot: check that node can ping master_url hostname instead of google hostname
parent
520df163
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
17 deletions
+54
-17
slapos/cli/boot.py
slapos/cli/boot.py
+54
-17
No files found.
slapos/cli/boot.py
View file @
981e23fd
...
@@ -28,6 +28,8 @@
...
@@ -28,6 +28,8 @@
##############################################################################
##############################################################################
import
subprocess
import
subprocess
import
socket
import
urlparse
from
time
import
sleep
from
time
import
sleep
import
glob
import
glob
import
os
import
os
...
@@ -94,6 +96,47 @@ def _ping6(hostname):
...
@@ -94,6 +96,47 @@ def _ping6(hostname):
print
"[BOOT] [ERROR] IPv6 network unreachable..."
print
"[BOOT] [ERROR] IPv6 network unreachable..."
return
0
return
0
def
_test_ping
(
hostname
):
is_ready
=
_ping
(
hostname
)
while
is_ready
==
0
:
sleep
(
5
)
is_ready
=
_ping
(
hostname
)
def
_test_ping6
(
hostname
):
is_ready
=
_ping6
(
hostname
)
while
is_ready
==
0
:
sleep
(
5
)
is_ready
=
_ping6
(
hostname
)
def
_test_ping6_and_ping4
(
hostname
):
is_ready
=
_ping6
(
hostname
)
while
is_ready
==
0
:
sleep
(
5
)
# Try ping on ipv4
is_ready
=
_ping
(
hostname
)
if
is_ready
==
0
:
# try ping on ipv6
is_ready
=
_ping6
(
hostname
)
def
_is_ipv4_address
(
address
):
try
:
socket
.
inet_pton
(
socket
.
AF_INET
,
address
)
except
AttributeError
:
# no inet_pton here, sorry
try
:
socket
.
inet_aton
(
address
)
except
socket
.
error
:
return
False
except
socket
.
error
:
# not a valid address
return
False
return
True
def
_is_ipv6_address
(
address
):
try
:
socket
.
inet_pton
(
socket
.
AF_INET6
,
address
)
except
socket
.
error
:
return
False
return
True
class
BootCommand
(
ConfigCommand
):
class
BootCommand
(
ConfigCommand
):
"""
"""
Test network and invoke simple format and bang (Use on Linux startup)
Test network and invoke simple format and bang (Use on Linux startup)
...
@@ -111,23 +154,17 @@ class BootCommand(ConfigCommand):
...
@@ -111,23 +154,17 @@ class BootCommand(ConfigCommand):
def
take_action
(
self
,
args
):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
configp
=
self
.
fetch_config
(
args
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
ipv6_host
=
ipv4_host
=
"slap.vifib.com"
master_url
=
urlparse
.
urlparse
(
configp
.
get
(
'slapos'
,
'master_url'
))
if
configp
.
has_option
(
'slapformat'
,
'ipv6_test_hostname'
):
master_hostname
=
master_url
.
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
(
ipv4_host
)
# Make sure ipv6 is working
# Check that node can ping master
is_ready
=
_ping6
(
ipv6_host
)
if
_is_ipv4_address
(
master_hostname
):
while
is_ready
==
0
:
_test_ping
(
master_hostname
)
sleep
(
5
)
elif
_is_ipv6_address
(
master_hostname
):
is_ready
=
_ping6
(
ipv6_host
)
_test_ping6
(
master_hostname
)
else
:
# hostname
_test_ping6_and_ping4
(
master_hostname
)
app
=
SlapOSApp
()
app
=
SlapOSApp
()
# Make sure slapos node format returns ok
# Make sure slapos node format returns ok
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment