import socket
from oslo_config import cfg
+from oslo_utils import netutils
from cinder.i18n import _
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 = [
cfg.StrOpt('api_paste_config',
default="api-paste.ini",
global_opts = [
cfg.StrOpt('my_ip',
- default=_get_my_ip(),
+ default=netutils.get_my_ipv4(),
help='IP address of this host'),
cfg.StrOpt('glance_host',
default='$my_ip',