From 5690bdea80a750c5e325e7498af451e6720e4b06 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 23 Jan 2015 22:35:43 +0100 Subject: [PATCH] Use uuidutils from oslo.utils Change-Id: I6313ad1d3da1a8e9efeab5d4f336e6f43f7a9857 --- cinder/api/contrib/volume_manage.py | 2 +- cinder/api/contrib/volume_type_access.py | 2 +- cinder/api/v1/volumes.py | 2 +- cinder/api/v2/volumes.py | 2 +- cinder/cmd/manage.py | 2 +- cinder/db/sqlalchemy/api.py | 2 +- cinder/openstack/common/uuidutils.py | 39 ------------------- cinder/scheduler/filters/affinity_filter.py | 3 +- .../filters/instance_locality_filter.py | 3 +- cinder/tests/scheduler/fakes.py | 2 +- cinder/tests/test_cmd.py | 4 +- cinder/tests/test_db_api.py | 2 +- cinder/tests/test_vmware_vmdk.py | 20 +++++----- cinder/volume/api.py | 2 +- cinder/volume/drivers/vmware/vmdk.py | 2 +- cinder/volume/manager.py | 2 +- openstack-common.conf | 1 - 17 files changed, 25 insertions(+), 67 deletions(-) delete mode 100644 cinder/openstack/common/uuidutils.py diff --git a/cinder/api/contrib/volume_manage.py b/cinder/api/contrib/volume_manage.py index 47039bdd3..30ed18fd8 100644 --- a/cinder/api/contrib/volume_manage.py +++ b/cinder/api/contrib/volume_manage.py @@ -13,6 +13,7 @@ # under the License. from oslo_config import cfg +from oslo_utils import uuidutils from webob import exc from cinder.api import extensions @@ -22,7 +23,6 @@ from cinder.api.v2 import volumes from cinder import exception from cinder.i18n import _ from cinder.openstack.common import log as logging -from cinder.openstack.common import uuidutils from cinder import utils from cinder import volume as cinder_volume from cinder.volume import volume_types diff --git a/cinder/api/contrib/volume_type_access.py b/cinder/api/contrib/volume_type_access.py index 50f6131f2..b91672f39 100644 --- a/cinder/api/contrib/volume_type_access.py +++ b/cinder/api/contrib/volume_type_access.py @@ -13,6 +13,7 @@ """The volume type access extension.""" +from oslo_utils import uuidutils import six import webob @@ -21,7 +22,6 @@ from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.i18n import _ -from cinder.openstack.common import uuidutils from cinder.volume import volume_types diff --git a/cinder/api/v1/volumes.py b/cinder/api/v1/volumes.py index a7bbda7f3..723395cbc 100644 --- a/cinder/api/v1/volumes.py +++ b/cinder/api/v1/volumes.py @@ -17,6 +17,7 @@ import ast +from oslo_utils import uuidutils import webob from webob import exc @@ -26,7 +27,6 @@ from cinder.api import xmlutil from cinder import exception from cinder.i18n import _, _LI from cinder.openstack.common import log as logging -from cinder.openstack.common import uuidutils from cinder import utils from cinder import volume as cinder_volume from cinder.volume import utils as volume_utils diff --git a/cinder/api/v2/volumes.py b/cinder/api/v2/volumes.py index de31de3c4..0844e7acb 100644 --- a/cinder/api/v2/volumes.py +++ b/cinder/api/v2/volumes.py @@ -18,6 +18,7 @@ import ast +from oslo_utils import uuidutils import webob from webob import exc @@ -30,7 +31,6 @@ from cinder import exception from cinder.i18n import _, _LI from cinder.image import glance from cinder.openstack.common import log as logging -from cinder.openstack.common import uuidutils from cinder import utils from cinder import volume as cinder_volume from cinder.volume import utils as volume_utils diff --git a/cinder/cmd/manage.py b/cinder/cmd/manage.py index e11ffd364..d423b074c 100644 --- a/cinder/cmd/manage.py +++ b/cinder/cmd/manage.py @@ -64,6 +64,7 @@ warnings.simplefilter('once', DeprecationWarning) from oslo import messaging from oslo_config import cfg from oslo_db.sqlalchemy import migration +from oslo_utils import uuidutils from cinder import i18n i18n.enable_lazy() @@ -76,7 +77,6 @@ from cinder.db import migration as db_migration from cinder.db.sqlalchemy import api as db_api from cinder.i18n import _ from cinder.openstack.common import log as logging -from cinder.openstack.common import uuidutils from cinder import rpc from cinder import utils from cinder import version diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index d21ba7478..2d607a902 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -31,6 +31,7 @@ from oslo_db import exception as db_exc from oslo_db import options from oslo_db.sqlalchemy import session as db_session from oslo_utils import timeutils +from oslo_utils import uuidutils import osprofiler.sqlalchemy import six import sqlalchemy @@ -46,7 +47,6 @@ from cinder.db.sqlalchemy import models from cinder import exception from cinder.i18n import _, _LW from cinder.openstack.common import log as logging -from cinder.openstack.common import uuidutils CONF = cfg.CONF diff --git a/cinder/openstack/common/uuidutils.py b/cinder/openstack/common/uuidutils.py deleted file mode 100644 index 7608acb94..000000000 --- a/cinder/openstack/common/uuidutils.py +++ /dev/null @@ -1,39 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright (c) 2012 Intel Corporation. -# All Rights Reserved. -# -# 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. - -""" -UUID related utilities and helper functions. -""" - -import uuid - - -def generate_uuid(): - return str(uuid.uuid4()) - - -def is_uuid_like(val): - """Returns validation of a value as a UUID. - - For our purposes, a UUID is a canonical form string: - aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa - - """ - try: - return str(uuid.UUID(val)) == val - except (TypeError, ValueError, AttributeError): - return False diff --git a/cinder/scheduler/filters/affinity_filter.py b/cinder/scheduler/filters/affinity_filter.py index 64f3c04d6..68906d068 100644 --- a/cinder/scheduler/filters/affinity_filter.py +++ b/cinder/scheduler/filters/affinity_filter.py @@ -13,11 +13,10 @@ # 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. - +from oslo_utils import uuidutils from cinder.openstack.common import log as logging from cinder.openstack.common.scheduler import filters -from cinder.openstack.common import uuidutils from cinder.volume import api as volume LOG = logging.getLogger(__name__) diff --git a/cinder/scheduler/filters/instance_locality_filter.py b/cinder/scheduler/filters/instance_locality_filter.py index 3f0cc10c4..2730e14ec 100644 --- a/cinder/scheduler/filters/instance_locality_filter.py +++ b/cinder/scheduler/filters/instance_locality_filter.py @@ -12,14 +12,13 @@ # 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. - +from oslo_utils import uuidutils from cinder.compute import nova from cinder import exception from cinder.i18n import _, _LW from cinder.openstack.common import log as logging from cinder.openstack.common.scheduler import filters -from cinder.openstack.common import uuidutils from cinder.volume import utils as volume_utils diff --git a/cinder/tests/scheduler/fakes.py b/cinder/tests/scheduler/fakes.py index 35e5337c7..8bda883c3 100644 --- a/cinder/tests/scheduler/fakes.py +++ b/cinder/tests/scheduler/fakes.py @@ -17,8 +17,8 @@ Fakes For Scheduler tests. """ from oslo_utils import timeutils +from oslo_utils import uuidutils -from cinder.openstack.common import uuidutils from cinder.scheduler import filter_scheduler from cinder.scheduler import host_manager diff --git a/cinder/tests/test_cmd.py b/cinder/tests/test_cmd.py index d62b52210..368374592 100644 --- a/cinder/tests/test_cmd.py +++ b/cinder/tests/test_cmd.py @@ -312,7 +312,7 @@ class TestCinderManageCmd(test.TestCase): def tearDown(self): super(TestCinderManageCmd, self).tearDown() - @mock.patch('cinder.openstack.common.uuidutils.is_uuid_like') + @mock.patch('oslo_utils.uuidutils.is_uuid_like') def test_param2id(self, is_uuid_like): mock_object_id = mock.MagicMock() is_uuid_like.return_value = True @@ -321,7 +321,7 @@ class TestCinderManageCmd(test.TestCase): self.assertEqual(mock_object_id, object_id) is_uuid_like.assert_called_once_with(mock_object_id) - @mock.patch('cinder.openstack.common.uuidutils.is_uuid_like') + @mock.patch('oslo_utils.uuidutils.is_uuid_like') def test_param2id_int_string(self, is_uuid_like): object_id_str = '10' is_uuid_like.return_value = False diff --git a/cinder/tests/test_db_api.py b/cinder/tests/test_db_api.py index bffeb1202..aad3a352d 100644 --- a/cinder/tests/test_db_api.py +++ b/cinder/tests/test_db_api.py @@ -17,11 +17,11 @@ import datetime from oslo_config import cfg +from oslo_utils import uuidutils from cinder import context from cinder import db from cinder import exception -from cinder.openstack.common import uuidutils from cinder.quota import ReservableResource from cinder import test diff --git a/cinder/tests/test_vmware_vmdk.py b/cinder/tests/test_vmware_vmdk.py index 942355e7f..eac4f5d28 100644 --- a/cinder/tests/test_vmware_vmdk.py +++ b/cinder/tests/test_vmware_vmdk.py @@ -959,7 +959,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): image_service, fake_image_id) @mock.patch.object(VMDK_DRIVER, '_extend_vmdk_virtual_disk') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, '_select_ds_for_volume') @mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, @@ -1424,7 +1424,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): m.VerifyAll() @mock.patch.object(VMDK_DRIVER, '_delete_temp_backing') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, '_get_volume_group_folder') @mock.patch('cinder.volume.volume_types.get_volume_type_extra_specs') @mock.patch.object(VMDK_DRIVER, 'volumeops') @@ -1645,7 +1645,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): @mock.patch.object(vmware_images, 'download_stream_optimized_disk') @mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch.object(VMDK_DRIVER, '_temporary_file') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, '_create_backing_in_inventory') @mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'session') @@ -1701,7 +1701,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): @mock.patch.object(VMDK_DRIVER, '_restore_backing') @mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch.object(VMDK_DRIVER, '_temporary_file') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, 'volumeops') def test_restore_backup(self, vops, generate_uuid, temporary_file, file_open, restore_backing, extend_volume): @@ -1770,7 +1770,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase): @mock.patch.object(VMDK_DRIVER, '_select_ds_for_volume') @mock.patch.object(VMDK_DRIVER, '_create_backing_from_stream_optimized_file') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') def test_restore_backing( self, generate_uuid, create_backing, select_ds, get_disk_type, vops, delete_temp_backing): @@ -2518,7 +2518,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase): self._test_extend_vmdk_virtual_disk(volume_ops) @mock.patch.object(VMDK_DRIVER, '_extend_vmdk_virtual_disk') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, '_select_ds_for_volume') @mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, @@ -2589,7 +2589,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase): fetch_optimized_image) @mock.patch.object(VMDK_DRIVER, '_delete_temp_backing') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, '_get_volume_group_folder') @mock.patch('cinder.volume.volume_types.get_volume_type_extra_specs') @mock.patch.object(VMDK_DRIVER, 'volumeops') @@ -2613,7 +2613,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase): @mock.patch.object(vmware_images, 'download_stream_optimized_disk') @mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch.object(VMDK_DRIVER, '_temporary_file') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, '_create_backing_in_inventory') @mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'session') @@ -2626,7 +2626,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase): @mock.patch.object(VMDK_DRIVER, '_restore_backing') @mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch.object(VMDK_DRIVER, '_temporary_file') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') @mock.patch.object(VMDK_DRIVER, 'volumeops') def test_restore_backup(self, vops, generate_uuid, temporary_file, file_open, restore_backing, extend_volume): @@ -2640,7 +2640,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase): @mock.patch.object(VMDK_DRIVER, '_select_ds_for_volume') @mock.patch.object(VMDK_DRIVER, '_create_backing_from_stream_optimized_file') - @mock.patch('cinder.openstack.common.uuidutils.generate_uuid') + @mock.patch('oslo_utils.uuidutils.generate_uuid') def test_restore_backing( self, generate_uuid, create_backing, select_ds, get_disk_type, vops, delete_temp_backing): diff --git a/cinder/volume/api.py b/cinder/volume/api.py index 39987bc79..dd7cd8ed1 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -26,6 +26,7 @@ import functools from oslo_config import cfg from oslo_utils import excutils from oslo_utils import timeutils +from oslo_utils import uuidutils import six from cinder import context @@ -36,7 +37,6 @@ from cinder.i18n import _, _LE from cinder.image import glance from cinder import keymgr from cinder.openstack.common import log as logging -from cinder.openstack.common import uuidutils import cinder.policy from cinder import quota from cinder import quota_utils diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index 31daa1c2b..cbffd2a53 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -30,12 +30,12 @@ import tempfile from oslo_config import cfg from oslo_utils import excutils from oslo_utils import units +from oslo_utils import uuidutils from cinder import exception from cinder.i18n import _, _LE, _LI, _LW from cinder.openstack.common import fileutils from cinder.openstack.common import log as logging -from cinder.openstack.common import uuidutils from cinder.volume import driver from cinder.volume.drivers.vmware import api from cinder.volume.drivers.vmware import datastore as hub diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 4c3c31b93..37bfd3450 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -45,6 +45,7 @@ from oslo_serialization import jsonutils from oslo_utils import excutils from oslo_utils import importutils from oslo_utils import timeutils +from oslo_utils import uuidutils from osprofiler import profiler from cinder import compute @@ -56,7 +57,6 @@ from cinder.image import glance from cinder import manager from cinder.openstack.common import log as logging from cinder.openstack.common import periodic_task -from cinder.openstack.common import uuidutils from cinder import quota from cinder import utils from cinder.volume.configuration import Configuration diff --git a/openstack-common.conf b/openstack-common.conf index ddda2dc76..df8f28e40 100644 --- a/openstack-common.conf +++ b/openstack-common.conf @@ -20,7 +20,6 @@ module=scheduler.filters module=scheduler.weights module=service module=strutils -module=uuidutils module=versionutils # The base module to hold the copy of openstack.common -- 2.45.2