Merge "neutron-lib: use cpu_count"
This commit is contained in:
commit
b944fe4f4e
@ -12,10 +12,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from neutron_lib.utils import host
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from neutron._i18n import _
|
from neutron._i18n import _
|
||||||
from neutron.common import utils
|
|
||||||
|
|
||||||
|
|
||||||
SHARED_OPTS = [
|
SHARED_OPTS = [
|
||||||
@ -106,7 +106,7 @@ UNIX_DOMAIN_METADATA_PROXY_OPTS = [
|
|||||||
"'all': set metadata proxy socket mode to 0o666, to use "
|
"'all': set metadata proxy socket mode to 0o666, to use "
|
||||||
"otherwise.")),
|
"otherwise.")),
|
||||||
cfg.IntOpt('metadata_workers',
|
cfg.IntOpt('metadata_workers',
|
||||||
default=utils.cpu_count() // 2,
|
default=host.cpu_count() // 2,
|
||||||
help=_('Number of separate worker processes for metadata '
|
help=_('Number of separate worker processes for metadata '
|
||||||
'server (defaults to half of the number of CPUs)')),
|
'server (defaults to half of the number of CPUs)')),
|
||||||
cfg.IntOpt('metadata_backlog',
|
cfg.IntOpt('metadata_backlog',
|
||||||
|
@ -22,7 +22,6 @@ import decimal
|
|||||||
import errno
|
import errno
|
||||||
import functools
|
import functools
|
||||||
import importlib
|
import importlib
|
||||||
import multiprocessing
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import random
|
import random
|
||||||
@ -39,6 +38,7 @@ from eventlet.green import subprocess
|
|||||||
import netaddr
|
import netaddr
|
||||||
from neutron_lib import constants as n_const
|
from neutron_lib import constants as n_const
|
||||||
from neutron_lib.utils import helpers
|
from neutron_lib.utils import helpers
|
||||||
|
from neutron_lib.utils import host
|
||||||
from oslo_concurrency import lockutils
|
from oslo_concurrency import lockutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db import exception as db_exc
|
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)
|
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():
|
def cpu_count():
|
||||||
try:
|
return host.cpu_count()
|
||||||
return multiprocessing.cpu_count()
|
|
||||||
except NotImplementedError:
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
class exception_logger(object):
|
class exception_logger(object):
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from neutron_lib.utils import host
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from neutron._i18n import _
|
from neutron._i18n import _
|
||||||
from neutron.agent.linux import keepalived
|
from neutron.agent.linux import keepalived
|
||||||
from neutron.common import utils as common_utils
|
|
||||||
|
|
||||||
|
|
||||||
OPTS = [
|
OPTS = [
|
||||||
@ -36,7 +36,7 @@ OPTS = [
|
|||||||
default=2,
|
default=2,
|
||||||
help=_('The advertisement interval in seconds')),
|
help=_('The advertisement interval in seconds')),
|
||||||
cfg.IntOpt('ha_keepalived_state_change_server_threads',
|
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',
|
sample_default='(1 + <num_of_cpus>) / 2',
|
||||||
min=1,
|
min=1,
|
||||||
help=_('Number of concurrent threads for '
|
help=_('Number of concurrent threads for '
|
||||||
|
Loading…
Reference in New Issue
Block a user