Merge "Replaces uuid.uuid4 with uuidutils.generate_uuid()"
This commit is contained in:
commit
e24e9a917b
|
@ -15,7 +15,6 @@
|
|||
from datetime import datetime
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import uuid
|
||||
from webob import exc
|
||||
|
||||
from karbor.api import common
|
||||
|
@ -106,7 +105,7 @@ class TriggersController(wsgi.Controller):
|
|||
trigger_property.setdefault(
|
||||
'start_time', datetime.utcnow().replace(microsecond=0))
|
||||
trigger_definition = {
|
||||
'id': str(uuid.uuid4()),
|
||||
'id': uuidutils.generate_uuid(),
|
||||
'name': trigger_name,
|
||||
'project_id': context.project_id,
|
||||
'type': trigger_type,
|
||||
|
|
|
@ -18,7 +18,6 @@ import six
|
|||
import sys
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as oslo_db_api
|
||||
|
@ -28,6 +27,7 @@ from oslo_db.sqlalchemy import session as db_session
|
|||
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy import or_
|
||||
from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.orm import RelationshipProperty
|
||||
|
@ -368,7 +368,7 @@ def _trigger_get(context, id, session=None):
|
|||
|
||||
def trigger_create(context, values):
|
||||
if not values.get('id'):
|
||||
values['id'] = str(uuid.uuid4())
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
|
||||
trigger_ref = models.Trigger()
|
||||
trigger_ref.update(values)
|
||||
|
@ -449,7 +449,7 @@ def _scheduled_operation_get(context, id, columns_to_join=[], session=None):
|
|||
|
||||
def scheduled_operation_create(context, values):
|
||||
if not values.get('id'):
|
||||
values['id'] = str(uuid.uuid4())
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
|
||||
operation_ref = models.ScheduledOperation()
|
||||
operation_ref.update(values)
|
||||
|
@ -801,7 +801,7 @@ def plan_create(context, values):
|
|||
|
||||
plan_ref = models.Plan()
|
||||
if not values.get('id'):
|
||||
values['id'] = str(uuid.uuid4())
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
plan_ref.update(values)
|
||||
|
||||
session = get_session()
|
||||
|
@ -1002,7 +1002,7 @@ def _process_plan_filters(query, filters):
|
|||
def restore_create(context, values):
|
||||
restore_ref = models.Restore()
|
||||
if not values.get('id'):
|
||||
values['id'] = str(uuid.uuid4())
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
restore_ref.update(values)
|
||||
|
||||
session = get_session()
|
||||
|
@ -1166,7 +1166,7 @@ def _process_restore_filters(query, filters):
|
|||
def operation_log_create(context, values):
|
||||
operation_log_ref = models.OperationLog()
|
||||
if not values.get('id'):
|
||||
values['id'] = str(uuid.uuid4())
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
operation_log_ref.update(values)
|
||||
|
||||
session = get_session()
|
||||
|
@ -1317,7 +1317,7 @@ def _process_operation_log_filters(query, filters):
|
|||
def checkpoint_record_create(context, values):
|
||||
checkpoint_record_ref = models.CheckpointRecord()
|
||||
if not values.get('id'):
|
||||
values['id'] = str(uuid.uuid4())
|
||||
values['id'] = uuidutils.generate_uuid()
|
||||
checkpoint_record_ref.update(values)
|
||||
|
||||
session = get_session()
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
import json
|
||||
import math
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from karbor import exception
|
||||
from karbor.i18n import _, _LE
|
||||
|
@ -23,6 +22,7 @@ from karbor.services.protection import client_factory
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_service import loopingcall
|
||||
from oslo_utils import uuidutils
|
||||
from swiftclient import ClientException
|
||||
|
||||
swift_bank_plugin_opts = [
|
||||
|
@ -70,7 +70,7 @@ class SwiftBankPlugin(BankPlugin, LeasePlugin):
|
|||
self._config.swift_bank_plugin.lease_validity_window
|
||||
|
||||
# TODO(luobin): create a uuid of this bank_plugin
|
||||
self.owner_id = str(uuid.uuid4())
|
||||
self.owner_id = uuidutils.generate_uuid()
|
||||
self.lease_expire_time = 0
|
||||
self.bank_leases_container = "leases"
|
||||
self.connection = self._setup_connection()
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_service import loopingcall
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from karbor.common import constants
|
||||
from karbor.i18n import _LE, _LI
|
||||
|
@ -42,7 +41,7 @@ class CreateStackTask(task.Task):
|
|||
self._template = template
|
||||
|
||||
def execute(self):
|
||||
stack_name = "restore_%s" % str(uuid4())
|
||||
stack_name = "restore_%s" % uuidutils.generate_uuid()
|
||||
LOG.info(_LI("creating stack, stack_name:%s"), stack_name)
|
||||
try:
|
||||
body = self._heat_client.stacks.create(
|
||||
|
|
|
@ -14,7 +14,6 @@ import eventlet
|
|||
from io import BytesIO
|
||||
import os
|
||||
from time import sleep
|
||||
from uuid import uuid4
|
||||
|
||||
from karbor.common import constants
|
||||
from karbor import exception
|
||||
|
@ -27,6 +26,7 @@ from karbor.services.protection.protection_plugins.server \
|
|||
from karbor.services.protection.restore_heat import HeatResource
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
protection_opts = [
|
||||
cfg.IntOpt('backup_image_object_size',
|
||||
|
@ -409,7 +409,7 @@ class NovaProtectionPlugin(BaseProtectionPlugin):
|
|||
networks.append({"network": network})
|
||||
properties["networks"] = networks
|
||||
|
||||
heat_resource_id = str(uuid4())
|
||||
heat_resource_id = uuidutils.generate_uuid()
|
||||
heat_server_resource = HeatResource(heat_resource_id,
|
||||
constants.SERVER_RESOURCE_TYPE)
|
||||
for key, value in properties.items():
|
||||
|
@ -431,7 +431,7 @@ class NovaProtectionPlugin(BaseProtectionPlugin):
|
|||
"instance_uuid": instance_uuid,
|
||||
"volume_id": volume_id}
|
||||
|
||||
heat_resource_id = str(uuid4())
|
||||
heat_resource_id = uuidutils.generate_uuid()
|
||||
heat_attachment_resource = HeatResource(
|
||||
heat_resource_id,
|
||||
VOLUME_ATTACHMENT_RESOURCE)
|
||||
|
@ -450,7 +450,7 @@ class NovaProtectionPlugin(BaseProtectionPlugin):
|
|||
original_server_id)
|
||||
properties = {"instance_uuid": instance_uuid,
|
||||
"floating_ip": floating_ip}
|
||||
heat_resource_id = str(uuid4())
|
||||
heat_resource_id = uuidutils.generate_uuid()
|
||||
heat_floating_resource = HeatResource(
|
||||
heat_resource_id, FLOATING_IP_ASSOCIATION)
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
# under the License.
|
||||
|
||||
import six
|
||||
from uuid import uuid4
|
||||
|
||||
from cinderclient.exceptions import NotFound
|
||||
from karbor.common import constants
|
||||
|
@ -26,6 +25,7 @@ from karbor.services.protection.restore_heat import HeatResource
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_service import loopingcall
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
|
||||
protection_opts = [
|
||||
|
@ -180,7 +180,7 @@ class CinderProtectionPlugin(BaseProtectionPlugin):
|
|||
"%s@%s" % (checkpoint.id, resource_id))
|
||||
description = kwargs.get("restore_description")
|
||||
|
||||
heat_resource_id = str(uuid4())
|
||||
heat_resource_id = uuidutils.generate_uuid()
|
||||
heat_resource = HeatResource(heat_resource_id,
|
||||
constants.VOLUME_RESOURCE_TYPE)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
import routes
|
||||
import webob
|
||||
|
@ -98,5 +98,5 @@ class TestRouter(wsgi.Router):
|
|||
|
||||
def get_fake_uuid(token=0):
|
||||
if token not in FAKE_UUIDS:
|
||||
FAKE_UUIDS[token] = str(uuid.uuid4())
|
||||
FAKE_UUIDS[token] = uuidutils.generate_uuid()
|
||||
return FAKE_UUIDS[token]
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from karbor.api.v1 import plans as plan_api
|
||||
|
@ -50,7 +50,7 @@ class ScheduledOperationApiTest(base.TestCase):
|
|||
self.req = fakes.HTTPRequest.blank('/v1/scheduled_operations')
|
||||
|
||||
trigger = self._create_trigger()
|
||||
self._plan = self._create_plan(str(uuid.uuid4()))
|
||||
self._plan = self._create_plan(uuidutils.generate_uuid())
|
||||
self.default_create_operation_param = {
|
||||
"name": "123",
|
||||
"description": "123",
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
import datetime
|
||||
import mock
|
||||
import uuid
|
||||
|
||||
from iso8601 import iso8601
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_versionedobjects import fields
|
||||
|
||||
from karbor import objects
|
||||
|
@ -37,7 +37,7 @@ class TestKarborObject(test_objects.BaseObjectsTestCase):
|
|||
super(TestKarborObject, self).setUp()
|
||||
self.obj = TestObject(
|
||||
scheduled_at=None,
|
||||
uuid=uuid.uuid4(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
text='text')
|
||||
self.obj.obj_reset_changes()
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
from collections import OrderedDict
|
||||
from copy import deepcopy
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from uuid import uuid4 as uuid
|
||||
|
||||
from karbor import exception
|
||||
from karbor.services.protection.bank_plugin import Bank
|
||||
|
@ -56,7 +56,7 @@ class _InMemoryBankPlugin(BankPlugin):
|
|||
del self._data[key]
|
||||
|
||||
def get_owner_id(self):
|
||||
return str(uuid())
|
||||
return uuidutils.generate_uuid()
|
||||
|
||||
|
||||
class _InMemoryLeasePlugin(LeasePlugin):
|
||||
|
|
Loading…
Reference in New Issue