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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
slapos.core
Commits
4036a800
Commit
4036a800
authored
Nov 16, 2018
by
Alain Takoudjou
Committed by
Rafael Monnerat
Nov 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use netaddr module
parent
9c1c065c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
24 deletions
+6
-24
slapos/cli/boot.py
slapos/cli/boot.py
+6
-24
No files found.
slapos/cli/boot.py
View file @
4036a800
...
...
@@ -28,11 +28,12 @@
##############################################################################
import
subprocess
import
socket
import
netaddr
import
urlparse
from
time
import
sleep
import
glob
import
os
from
netaddr
import
valid_ipv4
,
valid_ipv6
from
slapos.cli.command
import
must_be_root
from
slapos.cli.entry
import
SlapOSApp
from
slapos.cli.config
import
ConfigCommand
...
...
@@ -108,7 +109,7 @@ def _test_ping6(hostname):
sleep
(
5
)
is_ready
=
_ping6
(
hostname
)
def
_
test_ping6_and_ping4
(
hostname
):
def
_
ping_hostname
(
hostname
):
is_ready
=
_ping6
(
hostname
)
while
is_ready
==
0
:
sleep
(
5
)
...
...
@@ -118,25 +119,6 @@ def _test_ping6_and_ping4(hostname):
# 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
):
"""
Test network and invoke simple format and bang (Use on Linux startup)
...
...
@@ -158,13 +140,13 @@ class BootCommand(ConfigCommand):
master_hostname
=
master_url
.
hostname
# Check that node can ping master
if
_is_ipv4_address
(
master_hostname
):
if
valid_ipv4
(
master_hostname
):
_test_ping
(
master_hostname
)
elif
_is_ipv6_address
(
master_hostname
):
elif
valid_ipv6
(
master_hostname
):
_test_ping6
(
master_hostname
)
else
:
# hostname
_
test_ping6_and_ping4
(
master_hostname
)
_
ping_hostname
(
master_hostname
)
app
=
SlapOSApp
()
# 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