diff --git a/neutron/agent/metadata/config.py b/neutron/agent/metadata/config.py index 35116f2b236..addc7453187 100644 --- a/neutron/agent/metadata/config.py +++ b/neutron/agent/metadata/config.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.utils import host from oslo_config import cfg from neutron._i18n import _ -from neutron.common import utils SHARED_OPTS = [ @@ -106,7 +106,7 @@ UNIX_DOMAIN_METADATA_PROXY_OPTS = [ "'all': set metadata proxy socket mode to 0o666, to use " "otherwise.")), cfg.IntOpt('metadata_workers', - default=utils.cpu_count() // 2, + default=host.cpu_count() // 2, help=_('Number of separate worker processes for metadata ' 'server (defaults to half of the number of CPUs)')), cfg.IntOpt('metadata_backlog', diff --git a/neutron/common/utils.py b/neutron/common/utils.py index e704539b5df..547f39fee92 100644 --- a/neutron/common/utils.py +++ b/neutron/common/utils.py @@ -22,7 +22,6 @@ import decimal import errno import functools import importlib -import multiprocessing import os import os.path import random @@ -39,6 +38,7 @@ from eventlet.green import subprocess import netaddr from neutron_lib import constants as n_const from neutron_lib.utils import helpers +from neutron_lib.utils import host from oslo_concurrency import lockutils from oslo_config import cfg from oslo_db import exception as db_exc @@ -177,11 +177,12 @@ def get_dhcp_agent_device_id(network_id, host): return 'dhcp%s-%s' % (host_uuid, network_id) +@removals.remove( + message="Use cpu_count from neutron_lib.utils.host", + version="Ocata", + removal_version="Pike") def cpu_count(): - try: - return multiprocessing.cpu_count() - except NotImplementedError: - return 1 + return host.cpu_count() class exception_logger(object): diff --git a/neutron/conf/agent/l3/ha.py b/neutron/conf/agent/l3/ha.py index 95d8d215cd3..8bb539aed50 100644 --- a/neutron/conf/agent/l3/ha.py +++ b/neutron/conf/agent/l3/ha.py @@ -13,11 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.utils import host from oslo_config import cfg from neutron._i18n import _ from neutron.agent.linux import keepalived -from neutron.common import utils as common_utils OPTS = [ @@ -36,7 +36,7 @@ OPTS = [ default=2, help=_('The advertisement interval in seconds')), cfg.IntOpt('ha_keepalived_state_change_server_threads', - default=(1 + common_utils.cpu_count()) // 2, + default=(1 + host.cpu_count()) // 2, sample_default='(1 + ) / 2', min=1, help=_('Number of concurrent threads for '