# Path: oslo_utils/netutils.py
# LOG = logging.getLogger(__name__)
# _IS_IPV6_ENABLED = None
#             _IS_IPV6_ENABLED = disabled == "0"
#             _IS_IPV6_ENABLED = False
#     LOCALHOST = '127.0.0.1'
# def parse_host_port(address, default_port=None):
# def is_valid_ipv4(address, strict=None):
# def is_valid_ipv6(address):
# def is_valid_cidr(address):
# def is_valid_ipv6_cidr(address):
# def get_ipv6_addr_by_EUI64(prefix, mac):
# def get_mac_addr_by_ipv6(ipv6, dialect=netaddr.mac_unix_expanded):
# def is_ipv6_enabled():
# def escape_ipv6(address):
# def is_valid_ip(address):
# def is_valid_mac(address):
# def _is_int_in_range(value, start, end):
# def is_valid_port(port):
# def is_valid_icmp_type(type):
# def is_valid_icmp_code(code):
# def get_my_ipv4():
# def _get_my_ipv4_address():
#     def params(self, collapse=True):
# def urlsplit(url, scheme='', allow_fragments=True):
# def set_tcp_keepalive(sock, tcp_keepalive=True,
#                       tcp_keepidle=None,
#                       tcp_keepalive_interval=None,
#                       tcp_keepalive_count=None):
# class _ModifiedSplitResult(parse.SplitResult):


import contextlib
import io
import socket
import netaddr
import netifaces
from unittest import mock
from oslotest import base as test_base
from oslo_utils import netutils
        self.assertEqual({}, result.params())

        test_url = "http://localhost?"
        result = netutils.urlsplit(test_url)
        self.assertEqual({}, result.params())

    def test_set_tcp_keepalive(self):
        mock_sock = mock.Mock()
        netutils.set_tcp_keepalive(mock_sock, True, 100, 10, 5)
        calls = [
            mock.call.setsockopt(socket.SOL_SOCKET,
                                 socket.SO_KEEPALIVE, True),
        ]
        if hasattr(socket, 'TCP_KEEPIDLE'):
            calls += [
                mock.call.setsockopt(socket.IPPROTO_TCP,
                                     socket.TCP_KEEPIDLE, 100)
            ]
        if hasattr(socket, 'TCP_KEEPINTVL'):
            calls += [
                mock.call.setsockopt(socket.IPPROTO_TCP,
                                     socket.TCP_KEEPINTVL, 10),
            ]
        if hasattr(socket, 'TCP_KEEPCNT'):
            calls += [
                mock.call.setsockopt(socket.IPPROTO_TCP,
                                     socket.TCP_KEEPCNT, 5)
            ]
        mock_sock.assert_has_calls(calls)


# Path: oslo_utils/netutils.py
# LOG = logging.getLogger(__name__)
# _IS_IPV6_ENABLED = None
#             _IS_IPV6_ENABLED = disabled == "0"
#             _IS_IPV6_ENABLED = False
#     LOCALHOST = '127.0.0.1'
# def parse_host_port(address, default_port=None):
# def is_valid_ipv4(address, strict=None):
# def is_valid_ipv6(address):
# def is_valid_cidr(address):
# def is_valid_ipv6_cidr(address):
# def get_ipv6_addr_by_EUI64(prefix, mac):
# def get_mac_addr_by_ipv6(ipv6, dialect=netaddr.mac_unix_expanded):
# def is_ipv6_enabled():
# def escape_ipv6(address):
# def is_valid_ip(address):
# def is_valid_mac(address):
# def _is_int_in_range(value, start, end):
# def is_valid_port(port):
# def is_valid_icmp_type(type):
# def is_valid_icmp_code(code):
# def get_my_ipv4():
# def _get_my_ipv4_address():
#     def params(self, collapse=True):
# def urlsplit(url, scheme='', allow_fragments=True):
# def set_tcp_keepalive(sock, tcp_keepalive=True,
#                       tcp_keepidle=None,
#                       tcp_keepalive_interval=None,
#                       tcp_keepalive_count=None):
# class _ModifiedSplitResult(parse.SplitResult):


# Path: oslo_utils/tests/test_netutils.py
import contextlib
import io
import socket
import netaddr
import netifaces
from unittest import mock
from oslotest import base as test_base
from oslo_utils import netutils

        self.assertEqual({}, result.params())

        test_url = "http://localhost?"
        result = netutils.urlsplit(test_url)
        self.assertEqual({}, result.params())

    def test_set_tcp_keepalive(self):
        mock_sock = mock.Mock()
        netutils.set_tcp_keepalive(mock_sock, True, 100, 10, 5)
        calls = [
            mock.call.setsockopt(socket.SOL_SOCKET,
                                 socket.SO_KEEPALIVE, True),
        ]
        if hasattr(socket, 'TCP_KEEPIDLE'):
            calls += [
                mock.call.setsockopt(socket.IPPROTO_TCP,
                                     socket.TCP_KEEPIDLE, 100)
            ]
        if hasattr(socket, 'TCP_KEEPINTVL'):
            calls += [
                mock.call.setsockopt(socket.IPPROTO_TCP,
                                     socket.TCP_KEEPINTVL, 10),
            ]
        if hasattr(socket, 'TCP_KEEPCNT'):
            calls += [
                mock.call.setsockopt(socket.IPPROTO_TCP,
                                     socket.TCP_KEEPCNT, 5)
            ]
        mock_sock.assert_has_calls(calls)


        mock_sock.reset_mock()