neutron-lib: use cpu_count

Make use of cpu_count from neutron-lib utilities

Change-Id: I297417eb48e868b3d7e7e06060c8d7bce44d4589
This commit is contained in:
Gary Kotton 2016-10-10 06:21:05 -07:00
parent 2ad5208854
commit 45517be392
3 changed files with 10 additions and 9 deletions

View File

@ -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',

View File

@ -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):

View File

@ -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 + <num_of_cpus>) / 2',
min=1,
help=_('Number of concurrent threads for '