Merge "Use method is_ipv6_enabled from oslo.utils"
This commit is contained in:
commit
5525232a2f
manila
@ -289,35 +289,6 @@ class GenericUtilsTestCase(test.TestCase):
|
||||
self.assertFalse(result)
|
||||
timeutils.utcnow.assert_called_once_with()
|
||||
|
||||
def test_is_ipv6_configured0(self):
|
||||
fake_fd = mock.Mock()
|
||||
fake_fd.read.return_value = 'test'
|
||||
with mock.patch('six.moves.builtins.open',
|
||||
mock.Mock(return_value=fake_fd)) as open:
|
||||
self.assertTrue(utils.is_ipv6_configured())
|
||||
|
||||
open.assert_called_once_with('/proc/net/if_inet6')
|
||||
fake_fd.read.assert_called_once_with(32)
|
||||
|
||||
def test_is_ipv6_configured1(self):
|
||||
fake_fd = mock.Mock()
|
||||
fake_fd.read.return_value = ''
|
||||
with mock.patch(
|
||||
'six.moves.builtins.open', mock.Mock(return_value=fake_fd)):
|
||||
self.assertFalse(utils.is_ipv6_configured())
|
||||
|
||||
def test_is_ipv6_configured2(self):
|
||||
with mock.patch('six.moves.builtins.open',
|
||||
mock.Mock(side_effect=IOError(
|
||||
errno.ENOENT, 'Fake no such file error.'))):
|
||||
self.assertFalse(utils.is_ipv6_configured())
|
||||
|
||||
def test_is_ipv6_configured3(self):
|
||||
with mock.patch('six.moves.builtins.open',
|
||||
mock.Mock(side_effect=IOError(
|
||||
errno.EPERM, 'Fake no such file error.'))):
|
||||
self.assertRaises(IOError, utils.is_ipv6_configured)
|
||||
|
||||
def test_is_eventlet_bug105(self):
|
||||
fake_dns = mock.Mock()
|
||||
fake_dns.getaddrinfo.side_effect = socket.gaierror(errno.EBADF)
|
||||
|
@ -102,7 +102,7 @@ class TestWSGIServer(test.TestCase):
|
||||
server.stop()
|
||||
server.wait()
|
||||
|
||||
@testtools.skipIf(not utils.is_ipv6_configured(),
|
||||
@testtools.skipIf(not netutils.is_ipv6_enabled(),
|
||||
"Test requires an IPV6 configured interface")
|
||||
@testtools.skipIf(utils.is_eventlet_bug105(),
|
||||
'Eventlet bug #105 affect test results.')
|
||||
@ -212,7 +212,7 @@ class TestWSGIServer(test.TestCase):
|
||||
|
||||
server.stop()
|
||||
|
||||
@testtools.skipIf(not utils.is_ipv6_configured(),
|
||||
@testtools.skipIf(not netutils.is_ipv6_enabled(),
|
||||
"Test requires an IPV6 configured interface")
|
||||
@testtools.skipIf(utils.is_eventlet_bug105(),
|
||||
'Eventlet bug #105 affect test results.')
|
||||
|
@ -18,7 +18,6 @@
|
||||
"""Utilities and helper functions."""
|
||||
|
||||
import contextlib
|
||||
import errno
|
||||
import functools
|
||||
import inspect
|
||||
import os
|
||||
@ -270,24 +269,6 @@ def get_from_path(items, path):
|
||||
return get_from_path(results, remainder)
|
||||
|
||||
|
||||
def is_ipv6_configured():
|
||||
"""Check if system contain IPv6 capable network interface.
|
||||
|
||||
:rtype: bool
|
||||
:raises: IOError
|
||||
"""
|
||||
try:
|
||||
fd = open('/proc/net/if_inet6')
|
||||
except IOError as e:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
result = False
|
||||
else:
|
||||
result = bool(fd.read(32))
|
||||
fd.close()
|
||||
return result
|
||||
|
||||
|
||||
def is_eventlet_bug105():
|
||||
"""Check if eventlet support IPv6 addresses.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user