Use uuidutils from oslo.utils

Change-Id: I6313ad1d3da1a8e9efeab5d4f336e6f43f7a9857
This commit is contained in:
Julien Danjou 2015-01-23 22:35:43 +01:00
parent 8e241a4ffe
commit 5690bdea80
17 changed files with 25 additions and 67 deletions

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import uuidutils
from webob import exc from webob import exc
from cinder.api import extensions from cinder.api import extensions
@ -22,7 +23,6 @@ from cinder.api.v2 import volumes
from cinder import exception from cinder import exception
from cinder.i18n import _ from cinder.i18n import _
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import utils from cinder import utils
from cinder import volume as cinder_volume from cinder import volume as cinder_volume
from cinder.volume import volume_types from cinder.volume import volume_types

View File

@ -13,6 +13,7 @@
"""The volume type access extension.""" """The volume type access extension."""
from oslo_utils import uuidutils
import six import six
import webob import webob
@ -21,7 +22,6 @@ from cinder.api.openstack import wsgi
from cinder.api import xmlutil from cinder.api import xmlutil
from cinder import exception from cinder import exception
from cinder.i18n import _ from cinder.i18n import _
from cinder.openstack.common import uuidutils
from cinder.volume import volume_types from cinder.volume import volume_types

View File

@ -17,6 +17,7 @@
import ast import ast
from oslo_utils import uuidutils
import webob import webob
from webob import exc from webob import exc
@ -26,7 +27,6 @@ from cinder.api import xmlutil
from cinder import exception from cinder import exception
from cinder.i18n import _, _LI from cinder.i18n import _, _LI
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import utils from cinder import utils
from cinder import volume as cinder_volume from cinder import volume as cinder_volume
from cinder.volume import utils as volume_utils from cinder.volume import utils as volume_utils

View File

@ -18,6 +18,7 @@
import ast import ast
from oslo_utils import uuidutils
import webob import webob
from webob import exc from webob import exc
@ -30,7 +31,6 @@ from cinder import exception
from cinder.i18n import _, _LI from cinder.i18n import _, _LI
from cinder.image import glance from cinder.image import glance
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import utils from cinder import utils
from cinder import volume as cinder_volume from cinder import volume as cinder_volume
from cinder.volume import utils as volume_utils from cinder.volume import utils as volume_utils

View File

@ -64,6 +64,7 @@ warnings.simplefilter('once', DeprecationWarning)
from oslo import messaging from oslo import messaging
from oslo_config import cfg from oslo_config import cfg
from oslo_db.sqlalchemy import migration from oslo_db.sqlalchemy import migration
from oslo_utils import uuidutils
from cinder import i18n from cinder import i18n
i18n.enable_lazy() 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.db.sqlalchemy import api as db_api
from cinder.i18n import _ from cinder.i18n import _
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder import rpc from cinder import rpc
from cinder import utils from cinder import utils
from cinder import version from cinder import version

View File

@ -31,6 +31,7 @@ from oslo_db import exception as db_exc
from oslo_db import options from oslo_db import options
from oslo_db.sqlalchemy import session as db_session from oslo_db.sqlalchemy import session as db_session
from oslo_utils import timeutils from oslo_utils import timeutils
from oslo_utils import uuidutils
import osprofiler.sqlalchemy import osprofiler.sqlalchemy
import six import six
import sqlalchemy import sqlalchemy
@ -46,7 +47,6 @@ from cinder.db.sqlalchemy import models
from cinder import exception from cinder import exception
from cinder.i18n import _, _LW from cinder.i18n import _, _LW
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -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

View File

@ -13,11 +13,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from oslo_utils import uuidutils
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters from cinder.openstack.common.scheduler import filters
from cinder.openstack.common import uuidutils
from cinder.volume import api as volume from cinder.volume import api as volume
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,14 +12,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from oslo_utils import uuidutils
from cinder.compute import nova from cinder.compute import nova
from cinder import exception from cinder import exception
from cinder.i18n import _, _LW from cinder.i18n import _, _LW
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters from cinder.openstack.common.scheduler import filters
from cinder.openstack.common import uuidutils
from cinder.volume import utils as volume_utils from cinder.volume import utils as volume_utils

View File

@ -17,8 +17,8 @@ Fakes For Scheduler tests.
""" """
from oslo_utils import timeutils 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 filter_scheduler
from cinder.scheduler import host_manager from cinder.scheduler import host_manager

View File

@ -312,7 +312,7 @@ class TestCinderManageCmd(test.TestCase):
def tearDown(self): def tearDown(self):
super(TestCinderManageCmd, self).tearDown() 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): def test_param2id(self, is_uuid_like):
mock_object_id = mock.MagicMock() mock_object_id = mock.MagicMock()
is_uuid_like.return_value = True is_uuid_like.return_value = True
@ -321,7 +321,7 @@ class TestCinderManageCmd(test.TestCase):
self.assertEqual(mock_object_id, object_id) self.assertEqual(mock_object_id, object_id)
is_uuid_like.assert_called_once_with(mock_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): def test_param2id_int_string(self, is_uuid_like):
object_id_str = '10' object_id_str = '10'
is_uuid_like.return_value = False is_uuid_like.return_value = False

View File

@ -17,11 +17,11 @@
import datetime import datetime
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import uuidutils
from cinder import context from cinder import context
from cinder import db from cinder import db
from cinder import exception from cinder import exception
from cinder.openstack.common import uuidutils
from cinder.quota import ReservableResource from cinder.quota import ReservableResource
from cinder import test from cinder import test

View File

@ -959,7 +959,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
image_service, fake_image_id) image_service, fake_image_id)
@mock.patch.object(VMDK_DRIVER, '_extend_vmdk_virtual_disk') @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, '_select_ds_for_volume')
@mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'volumeops')
@mock.patch.object(VMDK_DRIVER, @mock.patch.object(VMDK_DRIVER,
@ -1424,7 +1424,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
m.VerifyAll() m.VerifyAll()
@mock.patch.object(VMDK_DRIVER, '_delete_temp_backing') @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.object(VMDK_DRIVER, '_get_volume_group_folder')
@mock.patch('cinder.volume.volume_types.get_volume_type_extra_specs') @mock.patch('cinder.volume.volume_types.get_volume_type_extra_specs')
@mock.patch.object(VMDK_DRIVER, 'volumeops') @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.object(vmware_images, 'download_stream_optimized_disk')
@mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch('cinder.openstack.common.fileutils.file_open')
@mock.patch.object(VMDK_DRIVER, '_temporary_file') @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, '_create_backing_in_inventory')
@mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'volumeops')
@mock.patch.object(VMDK_DRIVER, 'session') @mock.patch.object(VMDK_DRIVER, 'session')
@ -1701,7 +1701,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
@mock.patch.object(VMDK_DRIVER, '_restore_backing') @mock.patch.object(VMDK_DRIVER, '_restore_backing')
@mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch('cinder.openstack.common.fileutils.file_open')
@mock.patch.object(VMDK_DRIVER, '_temporary_file') @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') @mock.patch.object(VMDK_DRIVER, 'volumeops')
def test_restore_backup(self, vops, generate_uuid, temporary_file, def test_restore_backup(self, vops, generate_uuid, temporary_file,
file_open, restore_backing, extend_volume): 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, '_select_ds_for_volume')
@mock.patch.object(VMDK_DRIVER, @mock.patch.object(VMDK_DRIVER,
'_create_backing_from_stream_optimized_file') '_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( def test_restore_backing(
self, generate_uuid, create_backing, select_ds, get_disk_type, self, generate_uuid, create_backing, select_ds, get_disk_type,
vops, delete_temp_backing): vops, delete_temp_backing):
@ -2518,7 +2518,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
self._test_extend_vmdk_virtual_disk(volume_ops) self._test_extend_vmdk_virtual_disk(volume_ops)
@mock.patch.object(VMDK_DRIVER, '_extend_vmdk_virtual_disk') @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, '_select_ds_for_volume')
@mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'volumeops')
@mock.patch.object(VMDK_DRIVER, @mock.patch.object(VMDK_DRIVER,
@ -2589,7 +2589,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
fetch_optimized_image) fetch_optimized_image)
@mock.patch.object(VMDK_DRIVER, '_delete_temp_backing') @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.object(VMDK_DRIVER, '_get_volume_group_folder')
@mock.patch('cinder.volume.volume_types.get_volume_type_extra_specs') @mock.patch('cinder.volume.volume_types.get_volume_type_extra_specs')
@mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'volumeops')
@ -2613,7 +2613,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
@mock.patch.object(vmware_images, 'download_stream_optimized_disk') @mock.patch.object(vmware_images, 'download_stream_optimized_disk')
@mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch('cinder.openstack.common.fileutils.file_open')
@mock.patch.object(VMDK_DRIVER, '_temporary_file') @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, '_create_backing_in_inventory')
@mock.patch.object(VMDK_DRIVER, 'volumeops') @mock.patch.object(VMDK_DRIVER, 'volumeops')
@mock.patch.object(VMDK_DRIVER, 'session') @mock.patch.object(VMDK_DRIVER, 'session')
@ -2626,7 +2626,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
@mock.patch.object(VMDK_DRIVER, '_restore_backing') @mock.patch.object(VMDK_DRIVER, '_restore_backing')
@mock.patch('cinder.openstack.common.fileutils.file_open') @mock.patch('cinder.openstack.common.fileutils.file_open')
@mock.patch.object(VMDK_DRIVER, '_temporary_file') @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') @mock.patch.object(VMDK_DRIVER, 'volumeops')
def test_restore_backup(self, vops, generate_uuid, temporary_file, def test_restore_backup(self, vops, generate_uuid, temporary_file,
file_open, restore_backing, extend_volume): 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, '_select_ds_for_volume')
@mock.patch.object(VMDK_DRIVER, @mock.patch.object(VMDK_DRIVER,
'_create_backing_from_stream_optimized_file') '_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( def test_restore_backing(
self, generate_uuid, create_backing, select_ds, get_disk_type, self, generate_uuid, create_backing, select_ds, get_disk_type,
vops, delete_temp_backing): vops, delete_temp_backing):

View File

@ -26,6 +26,7 @@ import functools
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import excutils from oslo_utils import excutils
from oslo_utils import timeutils from oslo_utils import timeutils
from oslo_utils import uuidutils
import six import six
from cinder import context from cinder import context
@ -36,7 +37,6 @@ from cinder.i18n import _, _LE
from cinder.image import glance from cinder.image import glance
from cinder import keymgr from cinder import keymgr
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
import cinder.policy import cinder.policy
from cinder import quota from cinder import quota
from cinder import quota_utils from cinder import quota_utils

View File

@ -30,12 +30,12 @@ import tempfile
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import excutils from oslo_utils import excutils
from oslo_utils import units from oslo_utils import units
from oslo_utils import uuidutils
from cinder import exception from cinder import exception
from cinder.i18n import _, _LE, _LI, _LW from cinder.i18n import _, _LE, _LI, _LW
from cinder.openstack.common import fileutils from cinder.openstack.common import fileutils
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils
from cinder.volume import driver from cinder.volume import driver
from cinder.volume.drivers.vmware import api from cinder.volume.drivers.vmware import api
from cinder.volume.drivers.vmware import datastore as hub from cinder.volume.drivers.vmware import datastore as hub

View File

@ -45,6 +45,7 @@ from oslo_serialization import jsonutils
from oslo_utils import excutils from oslo_utils import excutils
from oslo_utils import importutils from oslo_utils import importutils
from oslo_utils import timeutils from oslo_utils import timeutils
from oslo_utils import uuidutils
from osprofiler import profiler from osprofiler import profiler
from cinder import compute from cinder import compute
@ -56,7 +57,6 @@ from cinder.image import glance
from cinder import manager from cinder import manager
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import periodic_task from cinder.openstack.common import periodic_task
from cinder.openstack.common import uuidutils
from cinder import quota from cinder import quota
from cinder import utils from cinder import utils
from cinder.volume.configuration import Configuration from cinder.volume.configuration import Configuration

View File

@ -20,7 +20,6 @@ module=scheduler.filters
module=scheduler.weights module=scheduler.weights
module=service module=service
module=strutils module=strutils
module=uuidutils
module=versionutils module=versionutils
# The base module to hold the copy of openstack.common # The base module to hold the copy of openstack.common