Move global service networking opts to new module
The my_ip, host and use_ipv6 options are used all over the codebase and they're pretty well related to each other. Create a new netconf module for them to live in. There are now no options registered globally in nova.config! blueprint: scope-config-opts Change-Id: Ifde37839ae6f38e6bf99dff1e80b8e25fd68ed25
This commit is contained in:
parent
562b5a452d
commit
7cb17d63f1
@ -47,7 +47,7 @@ from nova.openstack.common import rpc
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('network_manager', 'nova.service')
|
||||
LOG = logging.getLogger('nova.dhcpbridge')
|
||||
|
||||
|
@ -71,7 +71,7 @@ ec2_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(ec2_opts)
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
CONF.import_opt('vpn_key_suffix', 'nova.cloudpipe.pipelib')
|
||||
CONF.import_opt('internal_service_availability_zone',
|
||||
'nova.availability_zones')
|
||||
|
@ -38,7 +38,6 @@ cell_state_manager_opts = [
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('name', 'nova.cells.opts', group='cells')
|
||||
#CONF.import_opt('capabilities', 'nova.cells.opts', group='cells')
|
||||
CONF.register_opts(cell_state_manager_opts, group='cells')
|
||||
|
@ -174,11 +174,9 @@ CONF.register_opts(timeout_opts)
|
||||
CONF.register_opts(running_deleted_opts)
|
||||
CONF.import_opt('allow_resize_to_same_host', 'nova.compute.api')
|
||||
CONF.import_opt('console_topic', 'nova.console.rpcapi')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
CONF.import_opt('network_manager', 'nova.service')
|
||||
CONF.import_opt('reclaim_instance_interval', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
|
||||
QUOTAS = quota.QUOTAS
|
||||
|
||||
|
@ -33,7 +33,7 @@ from nova import utils
|
||||
from nova.virt import driver
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -17,51 +17,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import socket
|
||||
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import rpc
|
||||
|
||||
|
||||
def _get_my_ip():
|
||||
"""
|
||||
Returns the actual ip of the local machine.
|
||||
|
||||
This code figures out what source address would be used if some traffic
|
||||
were to be sent out to some well known address on the Internet. In this
|
||||
case, a Google DNS server is used, but the specific address does not
|
||||
matter much. No traffic is actually sent.
|
||||
"""
|
||||
try:
|
||||
csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
csock.connect(('8.8.8.8', 80))
|
||||
(addr, port) = csock.getsockname()
|
||||
csock.close()
|
||||
return addr
|
||||
except socket.error:
|
||||
return "127.0.0.1"
|
||||
|
||||
|
||||
global_opts = [
|
||||
cfg.StrOpt('my_ip',
|
||||
default=_get_my_ip(),
|
||||
help='ip address of this host'),
|
||||
cfg.StrOpt('host',
|
||||
default=socket.getfqdn(),
|
||||
help='Name of this node. This can be an opaque identifier. '
|
||||
'It is not necessarily a hostname, FQDN, or IP address. '
|
||||
'However, the node name must be valid within '
|
||||
'an AMQP key, and if using ZeroMQ, a valid '
|
||||
'hostname, FQDN, or IP address'),
|
||||
cfg.BoolOpt('use_ipv6',
|
||||
default=False,
|
||||
help='use ipv6'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(global_opts)
|
||||
|
||||
|
||||
def parse_args(argv, default_config_files=None):
|
||||
rpc.set_defaults(control_exchange='nova')
|
||||
cfg.CONF(argv[1:],
|
||||
|
@ -51,7 +51,7 @@ xvp_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(xvp_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(glance_opts)
|
||||
CONF.import_opt('auth_strategy', 'nova.api.auth')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
def generate_glance_url():
|
||||
|
@ -68,7 +68,7 @@ s3_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(s3_opts)
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
class S3ImageService(object):
|
||||
|
@ -75,7 +75,7 @@ periodic_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(periodic_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_INTERVAL = 60.0
|
||||
|
62
nova/netconf.py
Normal file
62
nova/netconf.py
Normal file
@ -0,0 +1,62 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2010 United States Government as represented by the
|
||||
# Administrator of the National Aeronautics and Space Administration.
|
||||
# All Rights Reserved.
|
||||
# Copyright 2012 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import socket
|
||||
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
def _get_my_ip():
|
||||
"""
|
||||
Returns the actual ip of the local machine.
|
||||
|
||||
This code figures out what source address would be used if some traffic
|
||||
were to be sent out to some well known address on the Internet. In this
|
||||
case, a Google DNS server is used, but the specific address does not
|
||||
matter much. No traffic is actually sent.
|
||||
"""
|
||||
try:
|
||||
csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
csock.connect(('8.8.8.8', 80))
|
||||
(addr, port) = csock.getsockname()
|
||||
csock.close()
|
||||
return addr
|
||||
except socket.error:
|
||||
return "127.0.0.1"
|
||||
|
||||
|
||||
netconf_opts = [
|
||||
cfg.StrOpt('my_ip',
|
||||
default=_get_my_ip(),
|
||||
help='ip address of this host'),
|
||||
cfg.StrOpt('host',
|
||||
default=socket.getfqdn(),
|
||||
help='Name of this node. This can be an opaque identifier. '
|
||||
'It is not necessarily a hostname, FQDN, or IP address. '
|
||||
'However, the node name must be valid within '
|
||||
'an AMQP key, and if using ZeroMQ, a valid '
|
||||
'hostname, FQDN, or IP address'),
|
||||
cfg.BoolOpt('use_ipv6',
|
||||
default=False,
|
||||
help='use ipv6'),
|
||||
]
|
||||
|
||||
CONF.register_opts(netconf_opts)
|
@ -95,9 +95,9 @@ linux_net_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(linux_net_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
# NOTE(vish): Iptables supports chain names of up to 28 characters, and we
|
||||
|
@ -196,8 +196,8 @@ network_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(network_opts)
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
class RPCAllocateFixedIP(object):
|
||||
|
@ -112,7 +112,7 @@ service_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(service_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
|
||||
|
||||
class SignalExit(SystemExit):
|
||||
|
@ -40,7 +40,7 @@ from nova import volume
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_driver', 'nova.virt.driver')
|
||||
CONF.import_opt('default_instance_type', 'nova.compute.instance_types')
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ from nova import volume
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_driver', 'nova.virt.driver')
|
||||
CONF.import_opt('default_instance_type', 'nova.compute.instance_types')
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
HOST = "testhost"
|
||||
|
@ -32,7 +32,6 @@ from nova.tests.api.openstack import fakes
|
||||
from nova.tests import matchers
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('osapi_compute_extension', 'nova.config')
|
||||
|
||||
NS = "{http://docs.openstack.org/common/api/v1.0}"
|
||||
ATOMNS = "{http://www.w3.org/2005/Atom}"
|
||||
|
@ -151,7 +151,7 @@ def stub_out_instance_quota(stubs, allowed, quota, resource='instances'):
|
||||
def stub_out_networking(stubs):
|
||||
def get_my_ip():
|
||||
return '127.0.0.1'
|
||||
stubs.Set(nova.config, '_get_my_ip', get_my_ip)
|
||||
stubs.Set(nova.netconf, '_get_my_ip', get_my_ip)
|
||||
|
||||
|
||||
def stub_out_compute_api_snapshot(stubs):
|
||||
|
@ -24,7 +24,6 @@ from nova.tests.cells import fakes
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('name', 'nova.cells.opts', group='cells')
|
||||
CONF.import_opt('allowed_rpc_exception_modules',
|
||||
'nova.openstack.common.rpc')
|
||||
|
@ -71,7 +71,7 @@ QUOTAS = quota.QUOTAS
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_manager', 'nova.service')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('live_migration_retry_count', 'nova.compute.manager')
|
||||
|
||||
|
||||
|
@ -25,6 +25,7 @@ from nova import paths
|
||||
from nova.tests.utils import cleanup_dns_managers
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
CONF.import_opt('scheduler_driver', 'nova.scheduler.manager')
|
||||
CONF.import_opt('fake_network', 'nova.network.manager')
|
||||
CONF.import_opt('network_size', 'nova.network.manager')
|
||||
|
@ -31,7 +31,7 @@ from nova.virt.libvirt import config as libvirt_config
|
||||
|
||||
HOST = "testhost"
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
|
||||
|
||||
class FakeIptablesFirewallDriver(object):
|
||||
|
@ -22,7 +22,6 @@ from nova.openstack.common.log import logging
|
||||
from nova.tests.integrated import integrated_helpers
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('osapi_compute_extension', 'nova.config')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ from nova import test
|
||||
from nova.tests.scheduler import fakes
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
class TestFilter(filters.BaseHostFilter):
|
||||
|
@ -38,7 +38,7 @@ from nova.virt.libvirt import utils as virtutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_manager', 'nova.service')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
@ -73,8 +73,8 @@ libvirt_driver.libvirt = libvirt
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('compute_manager', 'nova.service')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
CONF.import_opt('base_dir_name', 'nova.virt.libvirt.imagecache')
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -60,7 +60,7 @@ CONF = cfg.CONF
|
||||
CONF.import_opt('compute_manager', 'nova.service')
|
||||
CONF.import_opt('network_manager', 'nova.service')
|
||||
CONF.import_opt('compute_driver', 'nova.virt.driver')
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('default_availability_zone', 'nova.availability_zones')
|
||||
|
||||
IMAGE_MACHINE = '1'
|
||||
|
@ -23,7 +23,7 @@ from nova.network import minidns
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
|
||||
|
||||
def get_test_admin_context():
|
||||
|
@ -74,6 +74,7 @@ baremetal_group = cfg.OptGroup(name='baremetal',
|
||||
CONF = cfg.CONF
|
||||
CONF.register_group(baremetal_group)
|
||||
CONF.register_opts(opts, baremetal_group)
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
|
||||
DEFAULT_FIREWALL_DRIVER = "%s.%s" % (
|
||||
firewall.__name__,
|
||||
|
@ -70,7 +70,7 @@ baremetal_group = cfg.OptGroup(name='baremetal',
|
||||
CONF = cfg.CONF
|
||||
CONF.register_group(baremetal_group)
|
||||
CONF.register_opts(pxe_opts, baremetal_group)
|
||||
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
|
||||
CHEETAH = None
|
||||
|
||||
|
@ -45,6 +45,8 @@ CONF = cfg.CONF
|
||||
CONF.register_group(baremetal_group)
|
||||
CONF.register_opts(opts, baremetal_group)
|
||||
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
CONF.import_opt('libvirt_volume_drivers', 'nova.virt.libvirt.driver')
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -41,7 +41,7 @@ firewall_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(firewall_opts)
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
|
||||
|
||||
def load_driver(default, *args, **kwargs):
|
||||
|
@ -33,7 +33,7 @@ if sys.platform == 'win32':
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
class BaseVolumeUtils(object):
|
||||
|
@ -45,7 +45,7 @@ hyper_volumeops_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(hyper_volumeops_opts)
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
class VolumeOps(baseops.BaseOps):
|
||||
|
@ -190,8 +190,8 @@ libvirt_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(libvirt_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('my_ip', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
CONF.import_opt('default_ephemeral_format', 'nova.virt.driver')
|
||||
CONF.import_opt('use_cow_images', 'nova.virt.driver')
|
||||
CONF.import_opt('live_migration_retry_count', 'nova.compute.manager')
|
||||
|
@ -27,7 +27,7 @@ import nova.virt.firewall as base_firewall
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
|
||||
try:
|
||||
import libvirt
|
||||
|
@ -72,7 +72,7 @@ imagecache_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(imagecache_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('instances_path', 'nova.compute.manager')
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ libvirt_vif_opts = [
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(libvirt_vif_opts)
|
||||
CONF.import_opt('libvirt_type', 'nova.virt.libvirt.driver')
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
|
||||
LINUX_DEV_LEN = 14
|
||||
|
||||
|
@ -26,7 +26,7 @@ import netaddr
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
CONF.import_opt('injected_network_template', 'nova.virt.disk.api')
|
||||
|
||||
Template = None
|
||||
|
@ -117,7 +117,7 @@ xenapi_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(xenapi_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
|
||||
|
||||
class XenAPIDriver(driver.ComputeDriver):
|
||||
|
@ -39,7 +39,7 @@ xenapi_pool_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(xenapi_pool_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
|
||||
|
||||
class ResourcePool(object):
|
||||
|
@ -126,7 +126,7 @@ CONF.register_opts(xenapi_vm_utils_opts)
|
||||
CONF.import_opt('default_ephemeral_format', 'nova.virt.driver')
|
||||
CONF.import_opt('use_cow_images', 'nova.virt.driver')
|
||||
CONF.import_opt('glance_num_retries', 'nova.image.glance')
|
||||
CONF.import_opt('use_ipv6', 'nova.config')
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
|
||||
XENAPI_POWER_STATE = {
|
||||
'Halted': power_state.SHUTDOWN,
|
||||
|
@ -63,7 +63,7 @@ xenapi_vmops_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(xenapi_vmops_opts)
|
||||
CONF.import_opt('host', 'nova.config')
|
||||
CONF.import_opt('host', 'nova.netconf')
|
||||
CONF.import_opt('vncserver_proxyclient_address', 'nova.vnc')
|
||||
|
||||
DEFAULT_FIREWALL_DRIVER = "%s.%s" % (
|
||||
|
Loading…
Reference in New Issue
Block a user