Skip to content

Commit 741f163

Browse files
committed
Switch to the oslo_utils.fileutils
fileutils is graduated in the oslo.utils library. Remove old implementation of the read_cached_file function in the nova.utils and move from the fileutils the read_cached_file and delete_cached_file functions to the nova.utils module and the unit tests for these functions. Implements: blueprint graduate-fileutils[1] [1] https://blueprints.launchpad.net/oslo-incubator/+spec/graduate-fileutils Depends-On: I51ba9076e1fbc16145ee2311f47b7768c16dcb20 (requirements) Change-Id: I849f1c74ec811dbe82ba6270569a008a49eab465
1 parent 0d696ad commit 741f163

26 files changed

+112
-234
lines changed

nova/api/openstack/compute/contrib/cloudpipe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Connect your vlan to the world."""
1616

1717
from oslo_config import cfg
18+
from oslo_utils import fileutils
1819
from oslo_utils import timeutils
1920
from webob import exc
2021

@@ -26,7 +27,6 @@
2627
from nova import exception
2728
from nova.i18n import _
2829
from nova import network
29-
from nova.openstack.common import fileutils
3030
from nova import utils
3131

3232
CONF = cfg.CONF

nova/api/openstack/compute/plugins/v3/cloudpipe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Connect your vlan to the world."""
1616

1717
from oslo_config import cfg
18+
from oslo_utils import fileutils
1819
from oslo_utils import timeutils
1920
from webob import exc
2021

@@ -30,7 +31,6 @@
3031
from nova.i18n import _
3132
from nova import network
3233
from nova import objects
33-
from nova.openstack.common import fileutils
3434
from nova import utils
3535

3636
CONF = cfg.CONF

nova/cells/state.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from nova import exception
3737
from nova.i18n import _LE
3838
from nova import objects
39-
from nova.openstack.common import fileutils
4039
from nova import rpc
4140
from nova import utils
4241

@@ -484,8 +483,8 @@ def _cell_data_sync(self, force=False):
484483
:param force: If True, cell status will be updated regardless
485484
of whether it's time to do so.
486485
"""
487-
reloaded, data = fileutils.read_cached_file(self.cells_config_path,
488-
force_reload=force)
486+
reloaded, data = utils.read_cached_file(self.cells_config_path,
487+
force_reload=force)
489488

490489
if reloaded:
491490
LOG.debug("Updating cell cache from config file.")

nova/cloudpipe/pipelib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
from oslo_config import cfg
2828
from oslo_log import log as logging
29+
from oslo_utils import fileutils
2930

3031
from nova import compute
3132
from nova.compute import flavors
3233
from nova import crypto
3334
from nova import db
3435
from nova import exception
3536
from nova.i18n import _
36-
from nova.openstack.common import fileutils
3737
from nova import paths
3838
from nova import utils
3939

nova/crypto.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from oslo_config import cfg
3333
from oslo_log import log as logging
3434
from oslo_utils import excutils
35+
from oslo_utils import fileutils
3536
from oslo_utils import timeutils
3637
import paramiko
3738
from pyasn1.codec.der import encoder as der_encoder
@@ -42,7 +43,6 @@
4243
from nova import db
4344
from nova import exception
4445
from nova.i18n import _, _LE
45-
from nova.openstack.common import fileutils
4646
from nova import paths
4747
from nova import utils
4848

nova/network/linux_net.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
from oslo_log import log as logging
3030
from oslo_serialization import jsonutils
3131
from oslo_utils import excutils
32+
from oslo_utils import fileutils
3233
from oslo_utils import importutils
3334
from oslo_utils import timeutils
3435
import six
3536

3637
from nova import exception
3738
from nova.i18n import _, _LE, _LW
3839
from nova import objects
39-
from nova.openstack.common import fileutils
4040
from nova import paths
4141
from nova.pci import utils as pci_utils
4242
from nova import utils

nova/objectstore/s3server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
from oslo_config import cfg
4242
from oslo_log import log as logging
4343
from oslo_log import versionutils
44+
from oslo_utils import fileutils
4445
import routes
4546
import six
4647
import webob
4748

4849
from nova.i18n import _LW
49-
from nova.openstack.common import fileutils
5050
from nova import paths
5151
from nova import utils
5252
from nova import wsgi

nova/openstack/common/fileutils.py

-149
This file was deleted.

nova/openstack/common/policy.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@
101101
import six.moves.urllib.parse as urlparse
102102
import six.moves.urllib.request as urlrequest
103103

104-
from nova.openstack.common import fileutils
105104
from nova.openstack.common._i18n import _, _LE
106-
105+
from nova import utils
107106

108107
policy_opts = [
109108
cfg.StrOpt('policy_file',
@@ -248,7 +247,7 @@ def set_rules(self, rules, overwrite=True, use_conf=False):
248247
def clear(self):
249248
"""Clears Enforcer rules, policy's cache and policy's path."""
250249
self.set_rules({})
251-
fileutils.delete_cached_file(self.policy_path)
250+
utils.delete_cached_file(self.policy_path)
252251
self.default_rule = None
253252
self.policy_path = None
254253

@@ -287,7 +286,7 @@ def _walk_through_policy_directory(path, func, *args):
287286
func(os.path.join(path, policy_file), *args)
288287

289288
def _load_policy_file(self, path, force_reload, overwrite=True):
290-
reloaded, data = fileutils.read_cached_file(
289+
reloaded, data = utils.read_cached_file(
291290
path, force_reload=force_reload)
292291
if reloaded or not self.rules or not overwrite:
293292
rules = Rules.load_json(data, self.default_rule)

nova/tests/unit/cells/test_cells_state_manager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
from nova.db.sqlalchemy import models
2929
from nova import exception
3030
from nova import objects
31-
from nova.openstack.common import fileutils
3231
from nova import test
32+
from nova import utils
3333

3434
FAKE_COMPUTES = [
3535
('host1', 1024, 100, 0, 0),
@@ -114,7 +114,7 @@ def test_cells_config_not_found(self):
114114
self.assertEqual(['no_such_file_exists.conf'], e.config_files)
115115

116116
@mock.patch.object(cfg.ConfigOpts, 'find_file')
117-
@mock.patch.object(fileutils, 'read_cached_file')
117+
@mock.patch.object(utils, 'read_cached_file')
118118
def test_filemanager_returned(self, mock_read_cached_file, mock_find_file):
119119
mock_find_file.return_value = "/etc/nova/cells.json"
120120
mock_read_cached_file.return_value = (False, six.StringIO({}))

nova/tests/unit/network/test_linux_net.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from oslo_config import cfg
2626
from oslo_log import log as logging
2727
from oslo_serialization import jsonutils
28+
from oslo_utils import fileutils
2829
from oslo_utils import timeutils
2930

3031
from nova import context
@@ -33,7 +34,6 @@
3334
from nova.network import driver
3435
from nova.network import linux_net
3536
from nova import objects
36-
from nova.openstack.common import fileutils
3737
from nova import test
3838
from nova import utils
3939

nova/tests/unit/test_configdrive2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import mock
2121
from mox3 import mox
2222
from oslo_config import cfg
23+
from oslo_utils import fileutils
2324

2425
from nova import context
25-
from nova.openstack.common import fileutils
2626
from nova import test
2727
from nova.tests.unit import fake_instance
2828
from nova import utils

0 commit comments

Comments
 (0)