Merge "Use get_my_ipv4 from oslo.utils"
This commit is contained in:
commit
56551e66d6
@ -28,32 +28,13 @@ stepping stone.
|
|||||||
import socket
|
import socket
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_utils import netutils
|
||||||
|
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def _get_my_ip():
|
|
||||||
"""
|
|
||||||
Returns the actual ip of the local machine.
|
|
||||||
|
|
||||||
This code figures out what source address would be used if some traffic
|
|
||||||
were to be sent out to some well known address on the Internet. In this
|
|
||||||
case, a Google DNS server is used, but the specific address does not
|
|
||||||
matter much. No traffic is actually sent.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
||||||
csock.connect(('8.8.8.8', 80))
|
|
||||||
(addr, _port) = csock.getsockname()
|
|
||||||
csock.close()
|
|
||||||
return addr
|
|
||||||
except socket.error:
|
|
||||||
return "127.0.0.1"
|
|
||||||
|
|
||||||
|
|
||||||
core_opts = [
|
core_opts = [
|
||||||
cfg.StrOpt('api_paste_config',
|
cfg.StrOpt('api_paste_config',
|
||||||
default="api-paste.ini",
|
default="api-paste.ini",
|
||||||
@ -71,7 +52,7 @@ CONF.register_cli_opts(debug_opts)
|
|||||||
|
|
||||||
global_opts = [
|
global_opts = [
|
||||||
cfg.StrOpt('my_ip',
|
cfg.StrOpt('my_ip',
|
||||||
default=_get_my_ip(),
|
default=netutils.get_my_ipv4(),
|
||||||
help='IP address of this host'),
|
help='IP address of this host'),
|
||||||
cfg.StrOpt('glance_host',
|
cfg.StrOpt('glance_host',
|
||||||
default='$my_ip',
|
default='$my_ip',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user