Remove oslo uuidutils.generate_uuid from heat code

`uuidutils.generate_uuid' is going to be removed from oslo, so we need
to remove the call from heat code.

Change-Id: Iba9f86d8b8ec5ebaf4e80e6b729e372816bd5723
Partial-Bug: #1253497
This commit is contained in:
JUN JIE NAN 2013-12-07 21:30:16 +08:00
parent a2da560ad5
commit 4c03395feb
19 changed files with 97 additions and 57 deletions

View File

@ -12,12 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from heat.common import template_format
from heat.engine import parser
from heat.engine import environment
from heat.engine import resource
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import utils
@ -94,7 +94,7 @@ class CloudDBInstanceTest(HeatTestCase):
environment.Environment({'InstanceName': 'Test',
'FlavorRef': '1GB',
'VolumeSize': '30'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
if inject_property_error:
# database name given in users list is not a valid database

View File

@ -11,6 +11,7 @@
# under the License.
import copy
import uuid
import mox
import paramiko
@ -23,7 +24,6 @@ from heat.common import exception
from heat.engine import parser
from heat.engine import resource
from heat.engine import scheduler
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import utils
@ -91,7 +91,7 @@ class RackspaceCloudServerTest(HeatTestCase):
template = parser.Template(t)
stack = parser.Stack(utils.dummy_context(), stack_name, template,
{},
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
return (t, stack)
def _mock_ssh_sftp(self, exit_code=0):

View File

@ -11,13 +11,13 @@
# under the License.
import copy
import uuid
from heat.engine import environment
from heat.common import template_format
from heat.engine import parser
from heat.engine import resource
from heat.engine import scheduler
from heat.openstack.common import uuidutils
from heat.tests import common
from heat.tests import utils
@ -106,7 +106,7 @@ class RackspaceDnsTest(common.HeatTestCase):
stack_name,
template,
environment.Environment({'name': 'test'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
instance = cloud_dns.CloudDns(
'%s_name' % name,

View File

@ -13,18 +13,19 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from heat.openstack.common import local
from heat.common import exception
from heat.common import policy
from heat.common import wsgi
from heat.openstack.common import context
from heat.openstack.common import importutils
from heat.openstack.common import uuidutils
from heat.db import api as db_api
def generate_request_id():
return 'req-' + uuidutils.generate_uuid()
return 'req-' + str(uuid.uuid4())
class RequestContext(context.RequestContext):

View File

@ -12,8 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import sqlalchemy
from heat.openstack.common import uuidutils
def upgrade(migrate_engine):
@ -22,7 +23,7 @@ def upgrade(migrate_engine):
resource = sqlalchemy.Table('resource', meta, autoload=True)
resource.c.id.alter(sqlalchemy.String(36), primary_key=True,
default=uuidutils.generate_uuid)
default=lambda: str(uuid.uuid4()))
def downgrade(migrate_engine):

View File

@ -12,9 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import sqlalchemy
from migrate.versioning import util as migrate_util
from heat.openstack.common import uuidutils
from heat.openstack.common.gettextutils import _
@ -23,7 +25,7 @@ def upgrade(migrate_engine):
event = sqlalchemy.Table('event', meta, autoload=True)
event.c.id.alter(type=sqlalchemy.String(36), primary_key=True,
default=uuidutils.generate_uuid)
default=lambda: str(uuid.uuid4()))
def downgrade(migrate_engine):

View File

@ -0,0 +1,35 @@
# 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.
import sqlalchemy
import uuid
def upgrade(migrate_engine):
meta = sqlalchemy.MetaData(bind=migrate_engine)
stack = sqlalchemy.Table('stack', meta, autoload=True)
stack.c.id.alter(type=sqlalchemy.String(36), primary_key=True,
default=lambda: str(uuid.uuid4()))
event = sqlalchemy.Table('event', meta, autoload=True)
event.c.id.alter(type=sqlalchemy.String(36), primary_key=True,
default=lambda: str(uuid.uuid4()))
resource = sqlalchemy.Table('resource', meta, autoload=True)
resource.c.id.alter(type=sqlalchemy.String(36), primary_key=True,
default=lambda: str(uuid.uuid4()))
def downgrade(migrate_engine):
# since uuid.uuid4() works so no need to do downgrade
pass

View File

@ -15,16 +15,16 @@
SQLAlchemy models for heat data.
"""
import sqlalchemy
import uuid
import sqlalchemy
from sqlalchemy.dialects import mysql
from sqlalchemy.orm import relationship, backref
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import types
from json import dumps
from json import loads
from heat.openstack.common import uuidutils
from heat.openstack.common import timeutils
from heat.openstack.common.db.sqlalchemy import models
from heat.openstack.common.db.sqlalchemy import session
@ -122,7 +122,7 @@ class Stack(BASE, HeatBase, SoftDelete):
__tablename__ = 'stack'
id = sqlalchemy.Column(sqlalchemy.String(36), primary_key=True,
default=uuidutils.generate_uuid)
default=lambda: str(uuid.uuid4()))
name = sqlalchemy.Column(sqlalchemy.String(255))
raw_template_id = sqlalchemy.Column(
sqlalchemy.Integer,
@ -209,7 +209,7 @@ class Resource(BASE, HeatBase):
id = sqlalchemy.Column(sqlalchemy.String(36),
primary_key=True,
default=uuidutils.generate_uuid)
default=lambda: str(uuid.uuid4()))
action = sqlalchemy.Column('action', sqlalchemy.String(255))
status = sqlalchemy.Column('status', sqlalchemy.String(255))
name = sqlalchemy.Column('name', sqlalchemy.String(255), nullable=True)

View File

@ -12,12 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import heat.engine.api as api
from heat.engine import parser
from heat.engine import resource
from heat.engine.event import Event
from heat.common.identifier import EventIdentifier
from heat.openstack.common import uuidutils
from heat.rpc import api as rpc_api
from heat.tests.common import HeatTestCase
from heat.tests import generic_resource as generic_rsrc
@ -96,7 +98,7 @@ class FormatTest(HeatTestCase):
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
self.stack = parser.Stack(utils.dummy_context(), 'test_stack',
template, stack_id=uuidutils.generate_uuid())
template, stack_id=str(uuid.uuid4()))
def _dummy_event(self, event_id):
resource = self.stack['generic1']

View File

@ -13,6 +13,7 @@
# under the License.
import copy
import uuid
import mox
@ -70,7 +71,7 @@ class InstancesTest(HeatTestCase):
template = parser.Template(t)
stack = parser.Stack(utils.dummy_context(), stack_name, template,
environment.Environment({'KeyName': 'test'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
return (t, stack)
def _setup_test_instance(self, return_server, name, image_id=None,

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from heat.engine import environment
from heat.tests.v1_1 import fakes
@ -21,7 +22,6 @@ from heat.engine.resources import nova_utils
from heat.common import template_format
from heat.engine import parser
from heat.engine import scheduler
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import utils
@ -159,7 +159,7 @@ class instancesTest(HeatTestCase):
'SubnetId': '4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861'}
stack = parser.Stack(utils.dummy_context(), stack_name, template,
environment.Environment(kwargs),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
instance = instances.Instance('%s_name' % name,
@ -205,7 +205,7 @@ class instancesTest(HeatTestCase):
'SubnetId': '4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861'}
stack = parser.Stack(utils.dummy_context(), stack_name, template,
environment.Environment(kwargs),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'

View File

@ -12,13 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from heat.common import exception
from heat.common import template_format
from heat.engine import environment
from heat.engine import parser
from heat.engine import scheduler
from heat.engine.resources import os_database
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
@ -99,7 +100,7 @@ class OSDBInstanceTest(HeatTestCase):
stack_name,
template,
environment.Environment({'name': 'test'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
instance = os_database.OSDBInstance(
'%s_name' % name,

View File

@ -13,6 +13,7 @@
# under the License.
import os
import uuid
import json
from heat.common import exception
@ -27,8 +28,6 @@ from heat.engine import resources
from heat.engine import scheduler
from heat.engine.resources import template_resource
from heat.openstack.common import uuidutils
from heat.tests import generic_resource as generic_rsrc
from heat.tests.common import HeatTestCase
from heat.tests import utils
@ -119,7 +118,7 @@ class ProviderTemplateTest(HeatTestCase):
{'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}, files=files), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
map_prop_val = {
"key1": "val1",
@ -177,7 +176,7 @@ class ProviderTemplateTest(HeatTestCase):
{'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}, files=files), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
json_snippet = {
"Type": "DummyResource",
@ -209,7 +208,7 @@ class ProviderTemplateTest(HeatTestCase):
{'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}, files=files), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
temp_res = template_resource.TemplateResource('test_t_res',
json_snippet, stack)
@ -244,7 +243,7 @@ class ProviderTemplateTest(HeatTestCase):
{'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}, files=files), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
temp_res = template_resource.TemplateResource('test_t_res',
json_snippet, stack)
@ -274,7 +273,7 @@ class ProviderTemplateTest(HeatTestCase):
{'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}, files=files), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
temp_res = template_resource.TemplateResource('test_t_res',
json_snippet, stack)
@ -306,7 +305,7 @@ class ProviderTemplateTest(HeatTestCase):
{'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}, files=files), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
temp_res = template_resource.TemplateResource('test_t_res',
json_snippet, stack)
@ -339,7 +338,7 @@ class ProviderTemplateTest(HeatTestCase):
{'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}, files=files), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
temp_res = template_resource.TemplateResource('test_t_res',
json_snippet, stack)
@ -389,7 +388,7 @@ class ProviderTemplateTest(HeatTestCase):
}
}
stack = parser.Stack(None, 'test_stack', parser.Template({}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
templ_resource = resource.Resource("test_templ_resource", json_snippet,
stack)
self.m.VerifyAll()
@ -412,7 +411,7 @@ class ProviderTemplateTest(HeatTestCase):
{'Test::Frodo': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
minimal_temp = json.dumps({'Parameters': {}, 'Resources': {}})
self.m.StubOutWithMock(urlfetch, "get")
@ -436,7 +435,7 @@ class ProviderTemplateTest(HeatTestCase):
{'Test::Flippy': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
temp_res = template_resource.TemplateResource('test_t_res',
{"Type": 'Test::Flippy'},
@ -456,7 +455,7 @@ class ProviderTemplateTest(HeatTestCase):
{'Test::Frodo': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
self.m.StubOutWithMock(urlfetch, "get")
urlfetch.get(test_templ_name,
@ -482,7 +481,7 @@ class ProviderTemplateTest(HeatTestCase):
{'Test::Flippy': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
self.m.StubOutWithMock(urlfetch, "get")
urlfetch.get(test_templ_name,
@ -507,7 +506,7 @@ class ProviderTemplateTest(HeatTestCase):
{'Test::Flippy': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
self.m.ReplayAll()

View File

@ -13,6 +13,7 @@
# under the License.
import itertools
import uuid
import testscenarios
@ -23,7 +24,6 @@ from heat.engine import resource
from heat.engine import scheduler
from heat.engine import template
from heat.engine import environment
from heat.openstack.common import uuidutils
import heat.db.api as db_api
from heat.tests import generic_resource as generic_rsrc
@ -48,7 +48,7 @@ class ResourceTest(HeatTestCase):
self.stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template({}), env=env,
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
def test_get_class_ok(self):
cls = resource.get_class('GenericResourceType')

View File

@ -13,7 +13,7 @@
# under the License.
import copy
import uuid
import mox
from heat.engine import environment
@ -66,7 +66,7 @@ class ServersTest(HeatTestCase):
template = parser.Template(t)
stack = parser.Stack(utils.dummy_context(), stack_name, template,
environment.Environment({'key_name': 'test'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
return (t, stack)
def _setup_test_server(self, return_server, name, image_id=None,

View File

@ -11,7 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import copy
import uuid
import mox
from heat.engine import environment
@ -21,7 +23,6 @@ from heat.engine.resources import nova_utils
from heat.common import template_format
from heat.engine import parser
from heat.engine import scheduler
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import utils
@ -134,7 +135,7 @@ class ServerTagsTest(HeatTestCase):
template = parser.Template(t)
stack = parser.Stack(utils.dummy_context(), stack_name, template,
environment.Environment({'KeyName': 'test'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
t['Resources']['WebServer']['Properties']['Tags'] = intags
instance = instances.Instance(stack_name,
@ -210,7 +211,7 @@ class ServerTagsTest(HeatTestCase):
template = parser.Template(t)
stack = parser.Stack(utils.dummy_context(), stack_name, template,
environment.Environment({'KeyName': 'test'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
t['Resources']['WebServer']['Properties']['Tags'] = intags
@ -258,7 +259,7 @@ class ServerTagsTest(HeatTestCase):
template = parser.Template(t)
stack = parser.Stack(utils.dummy_context(), stack_name, template,
environment.Environment({'KeyName': 'test'}),
stack_id=uuidutils.generate_uuid())
stack_id=str(uuid.uuid4()))
t['Resources']['WebServer']['Properties']['Tags'] += intags
# create the launch configuration

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from datetime import datetime
from datetime import timedelta
@ -19,7 +20,6 @@ from json import dumps
import mock
import mox
from heat.db.sqlalchemy import api as db_api
from heat.engine import environment
from heat.tests.v1_1 import fakes
@ -31,7 +31,6 @@ from heat.engine.resources import instance as instances
from heat.engine import parser
from heat.engine import scheduler
from heat.openstack.common import timeutils
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import utils
@ -63,7 +62,7 @@ wp_template = '''
}
'''
UUIDs = (UUID1, UUID2, UUID3) = sorted([uuidutils.generate_uuid()
UUIDs = (UUID1, UUID2, UUID3) = sorted([str(uuid.uuid4())
for x in range(3)])
@ -99,7 +98,7 @@ class SqlAlchemyTest(HeatTestCase):
def _setup_test_stack(self, stack_name, stack_id=None):
t = template_format.parse(wp_template)
template = parser.Template(t)
stack_id = stack_id or uuidutils.generate_uuid()
stack_id = stack_id or str(uuid.uuid4())
stack = parser.Stack(self.ctx, stack_name, template,
environment.Environment({'KeyName': 'test'}))
with utils.UUIDStub(stack_id):

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import mox
from heat.common import template_format
@ -23,7 +23,6 @@ from heat.engine import resource
from heat.engine import scheduler
from heat.engine import stack_resource
from heat.engine import template
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import generic_resource as generic_rsrc
from heat.tests import utils
@ -95,7 +94,7 @@ class StackResourceTest(HeatTestCase):
t = parser.Template({template.RESOURCES:
{"provider_resource": ws_res_snippet}})
self.parent_stack = parser.Stack(utils.dummy_context(), 'test_stack',
t, stack_id=uuidutils.generate_uuid())
t, stack_id=str(uuid.uuid4()))
self.parent_resource = MyStackResource('test',
ws_res_snippet,
self.parent_stack)

View File

@ -14,12 +14,11 @@
import datetime
import time
import uuid
import json
from oslo.config import cfg
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import fakes
from heat.tests import utils
@ -106,7 +105,7 @@ class WaitConditionTest(HeatTestCase):
# Stub out the stack ID so we have a known value
if stack_id is None:
stack_id = uuidutils.generate_uuid()
stack_id = str(uuid.uuid4())
self.stack_id = stack_id
with utils.UUIDStub(self.stack_id):