Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.core
Commits
6d7769d4
Commit
6d7769d4
authored
Dec 12, 2016
by
Philip ABBET
Browse files
Fix the host ip address determination
parent
224ac477
Pipeline
#5781
failed with stage
in 3 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/core/agent.py
100644 → 100755
View file @
6d7769d4
...
...
@@ -45,15 +45,6 @@ from . import dock
from
.
import
baseformat
def
get_network_ip_address
(
host_address
):
'''Returns the most sensible network IP address given a host address'''
import
socket
import
difflib
possible_addresses
=
socket
.
gethostbyname_ex
(
socket
.
gethostname
())[
2
]
return
difflib
.
get_close_matches
(
host_address
,
possible_addresses
,
cutoff
=
0
)[
0
]
class
Server
(
gevent
.
Greenlet
):
'''A 0MQ server for our communication with the user process'''
...
...
@@ -69,7 +60,7 @@ class Server(gevent.Greenlet):
self
.
context
=
zmq
.
Context
()
self
.
socket
=
self
.
context
.
socket
(
zmq
.
PAIR
)
self
.
address
=
'tcp://'
+
get_network_ip_address
(
host_address
)
self
.
address
=
'tcp://'
+
host_address
port
=
self
.
socket
.
bind_to_random_port
(
self
.
address
)
self
.
address
+=
':%d'
%
port
logger
.
debug
(
"zmq server bound to `%s'"
,
self
.
address
)
...
...
beat/core/dock.py
100644 → 100755
View file @
6d7769d4
...
...
@@ -39,6 +39,7 @@ import six
import
docker
import
requests
import
simplejson
import
socket
from
.
import
stats
...
...
@@ -107,8 +108,9 @@ class Host(object):
@
property
def
ip
(
self
):
'''The IP address of the docker host'''
return
'127.0.0.1'
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
.
connect
((
'8.8.8.8'
,
0
))
# connecting to a UDP address doesn't send packets
return
s
.
getsockname
()[
0
]
def
_discover_environments
(
self
,
raise_on_errors
=
True
):
...
...
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