From e30c75bae00e0d04e81200bb29920a0b0f1010f9 Mon Sep 17 00:00:00 2001 From: Esra Celik Date: Fri, 12 Feb 2016 15:42:52 +0200 Subject: [PATCH] Removal of unnecessary `import_opt`s for centralized config options Importing nova.conf module is enough when using centralized config options. import_opt(, ) functions are not necessary. Blueprint centralize-config-options Change-Id: I1c23b042dfdc6b9e77cba3c1ddf31adbfa892877 --- nova/api/openstack/compute/baremetal_nodes.py | 15 --------------- .../compute/legacy_v2/contrib/baremetal_nodes.py | 15 --------------- nova/compute/manager.py | 2 -- nova/scheduler/filters/metrics_filter.py | 7 ++----- nova/tests/unit/image/fake.py | 5 ++--- nova/tests/unit/scheduler/test_host_manager.py | 6 ++---- nova/tests/unit/test_test.py | 5 ++--- nova/virt/libvirt/driver.py | 7 ------- nova/virt/libvirt/imagebackend.py | 6 ------ 9 files changed, 8 insertions(+), 60 deletions(-) diff --git a/nova/api/openstack/compute/baremetal_nodes.py b/nova/api/openstack/compute/baremetal_nodes.py index faef487f1ad8..0f625710ef35 100644 --- a/nova/api/openstack/compute/baremetal_nodes.py +++ b/nova/api/openstack/compute/baremetal_nodes.py @@ -39,21 +39,6 @@ node_ext_fields = ['uuid', 'task_state', 'updated_at', 'pxe_config_path'] interface_fields = ['id', 'address', 'datapath_id', 'port_no'] CONF = nova.conf.CONF -CONF.import_opt('api_version', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('api_endpoint', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('admin_username', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('admin_password', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('admin_tenant_name', - 'nova.virt.ironic.driver', - group='ironic') def _check_ironic_client_enabled(): diff --git a/nova/api/openstack/compute/legacy_v2/contrib/baremetal_nodes.py b/nova/api/openstack/compute/legacy_v2/contrib/baremetal_nodes.py index ad1fda835078..6033c53f0317 100644 --- a/nova/api/openstack/compute/legacy_v2/contrib/baremetal_nodes.py +++ b/nova/api/openstack/compute/legacy_v2/contrib/baremetal_nodes.py @@ -36,21 +36,6 @@ node_ext_fields = ['uuid', 'task_state', 'updated_at', 'pxe_config_path'] interface_fields = ['id', 'address', 'datapath_id', 'port_no'] CONF = nova.conf.CONF -CONF.import_opt('api_version', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('api_endpoint', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('admin_username', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('admin_password', - 'nova.virt.ironic.driver', - group='ironic') -CONF.import_opt('admin_tenant_name', - 'nova.virt.ironic.driver', - group='ironic') def _check_ironic_client_enabled(): diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 89f1295e895d..0558e88e29b2 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -273,8 +273,6 @@ CONF.import_opt('html5_proxy_base_url', 'nova.rdp', group='rdp') CONF.import_opt('enabled', 'nova.mks', group='mks') CONF.import_opt('mksproxy_base_url', 'nova.mks', group='mks') CONF.import_opt('destroy_after_evacuate', 'nova.utils', group='workarounds') -CONF.import_opt('scheduler_tracks_instance_changes', - 'nova.scheduler.host_manager') LOG = logging.getLogger(__name__) diff --git a/nova/scheduler/filters/metrics_filter.py b/nova/scheduler/filters/metrics_filter.py index 94104bedd9d5..352b6e66c2aa 100644 --- a/nova/scheduler/filters/metrics_filter.py +++ b/nova/scheduler/filters/metrics_filter.py @@ -13,18 +13,15 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log as logging +import nova.conf from nova.scheduler import filters from nova.scheduler import utils LOG = logging.getLogger(__name__) -CONF = cfg.CONF -CONF.import_opt('weight_setting', - 'nova.scheduler.weights.metrics', - group='metrics') +CONF = nova.conf.CONF class MetricsFilter(filters.BaseHostFilter): diff --git a/nova/tests/unit/image/fake.py b/nova/tests/unit/image/fake.py index 8044cb9cc431..ebe624ab5415 100644 --- a/nova/tests/unit/image/fake.py +++ b/nova/tests/unit/image/fake.py @@ -20,14 +20,13 @@ import copy import datetime import uuid -from oslo_config import cfg from oslo_log import log as logging from nova.compute import arch +import nova.conf from nova import exception -CONF = cfg.CONF -CONF.import_opt('null_kernel', 'nova.compute.api') +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) AUTO_DISK_CONFIG_ENABLED_IMAGE_UUID = '70a599e0-31e7-49b7-b260-868f441e862b' diff --git a/nova/tests/unit/scheduler/test_host_manager.py b/nova/tests/unit/scheduler/test_host_manager.py index a043d8e08151..9f5744992e18 100644 --- a/nova/tests/unit/scheduler/test_host_manager.py +++ b/nova/tests/unit/scheduler/test_host_manager.py @@ -20,7 +20,6 @@ import collections import datetime import mock -from oslo_config import cfg from oslo_serialization import jsonutils from oslo_utils import versionutils import six @@ -28,6 +27,7 @@ import six import nova from nova.compute import task_states from nova.compute import vm_states +import nova.conf from nova import exception from nova import objects from nova.objects import base as obj_base @@ -41,9 +41,7 @@ from nova.tests.unit import matchers from nova.tests.unit.scheduler import fakes from nova.tests import uuidsentinel as uuids -CONF = cfg.CONF -CONF.import_opt('scheduler_tracks_instance_changes', - 'nova.scheduler.host_manager') +CONF = nova.conf.CONF class FakeFilterClass1(filters.BaseHostFilter): diff --git a/nova/tests/unit/test_test.py b/nova/tests/unit/test_test.py index 20b62e9c8e54..4862242389ff 100644 --- a/nova/tests/unit/test_test.py +++ b/nova/tests/unit/test_test.py @@ -16,19 +16,18 @@ """Tests for the testing base code.""" -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging import six +import nova.conf from nova import rpc from nova import test from nova.tests import fixtures LOG = logging.getLogger(__name__) -CONF = cfg.CONF -CONF.import_opt('use_local', 'nova.conductor.api', group='conductor') +CONF = nova.conf.CONF class IsolationTestCase(test.TestCase): diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index a4b301288dfb..02126e662dc1 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -314,15 +314,8 @@ CONF = nova.conf.CONF CONF.register_opts(libvirt_opts, 'libvirt') CONF.import_opt('host', 'nova.netconf') CONF.import_opt('my_ip', 'nova.netconf') -CONF.import_opt('enabled', 'nova.compute.api', - group='ephemeral_storage_encryption') -CONF.import_opt('cipher', 'nova.compute.api', - group='ephemeral_storage_encryption') -CONF.import_opt('key_size', 'nova.compute.api', - group='ephemeral_storage_encryption') CONF.import_opt('live_migration_retry_count', 'nova.compute.manager') CONF.import_opt('server_proxyclient_address', 'nova.spice', group='spice') -CONF.import_opt('vcpu_pin_set', 'nova.conf.virt') CONF.import_opt('hw_disk_discard', 'nova.virt.libvirt.imagebackend', group='libvirt') CONF.import_group('workarounds', 'nova.utils') diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py index b5ca2ae2ca4b..a7566624a92d 100644 --- a/nova/virt/libvirt/imagebackend.py +++ b/nova/virt/libvirt/imagebackend.py @@ -74,12 +74,6 @@ __imagebackend_opts = [ CONF = nova.conf.CONF CONF.register_opts(__imagebackend_opts, 'libvirt') CONF.import_opt('image_cache_subdirectory_name', 'nova.virt.imagecache') -CONF.import_opt('enabled', 'nova.compute.api', - group='ephemeral_storage_encryption') -CONF.import_opt('cipher', 'nova.compute.api', - group='ephemeral_storage_encryption') -CONF.import_opt('key_size', 'nova.compute.api', - group='ephemeral_storage_encryption') CONF.import_opt('rbd_user', 'nova.virt.libvirt.volume.net', group='libvirt') CONF.import_opt('rbd_secret_uuid', 'nova.virt.libvirt.volume.net', group='libvirt')