Merge "Use oslo_utils.uuidutils support"
This commit is contained in:
commit
1740f79a0a
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import uuidutils
|
||||
import wsme
|
||||
from wsme import types as wtypes
|
||||
|
||||
|
@ -66,7 +67,7 @@ class UuidType(wtypes.UserType):
|
|||
|
||||
@staticmethod
|
||||
def validate(value):
|
||||
if not utils.is_uuid_like(value):
|
||||
if not uuidutils.is_uuid_like(value):
|
||||
raise exception.InvalidUUID(uuid=value)
|
||||
return value
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import jsonpatch
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
import pecan
|
||||
import wsme
|
||||
|
||||
|
@ -92,7 +93,7 @@ def get_resource(resource, resource_ident):
|
|||
"""
|
||||
resource = getattr(objects, resource)
|
||||
|
||||
if utils.is_uuid_like(resource_ident):
|
||||
if uuidutils.is_uuid_like(resource_ident):
|
||||
return resource.get_by_uuid(pecan.request.context, resource_ident)
|
||||
|
||||
return resource.get_by_name(pecan.request.context, resource_ident)
|
||||
|
@ -109,7 +110,7 @@ def get_openstack_resource(manager, resource_ident, resource_type):
|
|||
:raises: ResourceNotFound if the openstack resource is not exist.
|
||||
Conflict if multi openstack resources have same name.
|
||||
"""
|
||||
if utils.is_uuid_like(resource_ident):
|
||||
if uuidutils.is_uuid_like(resource_ident):
|
||||
resource_data = manager.get(resource_ident)
|
||||
else:
|
||||
filters = {'name': resource_ident}
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
import decorator
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
import pecan
|
||||
|
||||
from magnum.api import utils as api_utils
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils
|
||||
from magnum.i18n import _
|
||||
from magnum import objects
|
||||
|
||||
|
@ -71,7 +71,7 @@ def enforce_bay_types(*bay_types):
|
|||
bay = objects.Bay.get_by_uuid(pecan.request.context, obj.bay_uuid)
|
||||
else:
|
||||
bay_ident = args[2]
|
||||
if utils.is_uuid_like(bay_ident):
|
||||
if uuidutils.is_uuid_like(bay_ident):
|
||||
bay = objects.Bay.get_by_uuid(pecan.request.context, bay_ident)
|
||||
else:
|
||||
bay = objects.Bay.get_by_name(pecan.request.context, bay_ident)
|
||||
|
|
|
@ -18,8 +18,8 @@ from docker import client
|
|||
from docker import tls
|
||||
from docker.utils import utils
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.conductor.handlers.common import cert_manager
|
||||
from magnum.conductor import utils as conductor_utils
|
||||
from magnum import objects
|
||||
|
@ -78,7 +78,7 @@ def is_docker_api_version_atleast(docker, version):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def docker_for_container(context, container):
|
||||
if magnum_utils.is_uuid_like(container):
|
||||
if uuidutils.is_uuid_like(container):
|
||||
container = objects.Container.get_by_uuid(context, container)
|
||||
bay = conductor_utils.retrieve_bay(context, container.bay_uuid)
|
||||
with docker_for_bay(context, bay) as docker:
|
||||
|
|
|
@ -26,7 +26,6 @@ import random
|
|||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
import netaddr
|
||||
from oslo_concurrency import processutils
|
||||
|
@ -471,23 +470,6 @@ def safe_rstrip(value, chars=None):
|
|||
return value.rstrip(chars) or value
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
def mount(src, dest, *args):
|
||||
"""Mounts a device/image file on specified location.
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
from k8sclient.client import rest
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import k8s_manifest
|
||||
from magnum.common import utils
|
||||
from magnum.conductor import k8s_api as k8s
|
||||
from magnum.conductor import utils as conductor_utils
|
||||
from magnum import objects
|
||||
|
@ -72,7 +72,7 @@ class Handler(object):
|
|||
LOG.debug("service_update %s", service_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(service_ident):
|
||||
if uuidutils.is_uuid_like(service_ident):
|
||||
service = objects.Service.get_by_uuid(context,
|
||||
service_ident,
|
||||
bay.uuid,
|
||||
|
@ -120,7 +120,7 @@ class Handler(object):
|
|||
LOG.debug("service_delete %s", service_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(service_ident):
|
||||
if uuidutils.is_uuid_like(service_ident):
|
||||
service = objects.Service.get_by_uuid(context, service_ident,
|
||||
bay.uuid, self.k8s_api)
|
||||
service_name = service.name
|
||||
|
@ -141,7 +141,7 @@ class Handler(object):
|
|||
LOG.debug("service_show %s", service_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(service_ident):
|
||||
if uuidutils.is_uuid_like(service_ident):
|
||||
service = objects.Service.get_by_uuid(context, service_ident,
|
||||
bay.uuid, self.k8s_api)
|
||||
else:
|
||||
|
@ -220,7 +220,7 @@ class Handler(object):
|
|||
LOG.debug("pod_update %s", pod_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(pod_ident):
|
||||
if uuidutils.is_uuid_like(pod_ident):
|
||||
pod = objects.Pod.get_by_uuid(context, pod_ident,
|
||||
bay.uuid, self.k8s_api)
|
||||
else:
|
||||
|
@ -256,7 +256,7 @@ class Handler(object):
|
|||
LOG.debug("pod_delete %s", pod_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(pod_ident):
|
||||
if uuidutils.is_uuid_like(pod_ident):
|
||||
pod = objects.Pod.get_by_uuid(context, pod_ident,
|
||||
bay.uuid, self.k8s_api)
|
||||
pod_name = pod.name
|
||||
|
@ -276,7 +276,7 @@ class Handler(object):
|
|||
LOG.debug("pod_show %s", pod_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(pod_ident):
|
||||
if uuidutils.is_uuid_like(pod_ident):
|
||||
pod = objects.Pod.get_by_uuid(context, pod_ident,
|
||||
bay.uuid, self.k8s_api)
|
||||
else:
|
||||
|
@ -345,7 +345,7 @@ class Handler(object):
|
|||
LOG.debug("rc_update %s", rc_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(rc_ident):
|
||||
if uuidutils.is_uuid_like(rc_ident):
|
||||
rc = objects.ReplicationController.get_by_uuid(context, rc_ident,
|
||||
bay.uuid,
|
||||
self.k8s_api)
|
||||
|
@ -379,7 +379,7 @@ class Handler(object):
|
|||
LOG.debug("rc_delete %s", rc_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(rc_ident):
|
||||
if uuidutils.is_uuid_like(rc_ident):
|
||||
rc = objects.ReplicationController.get_by_uuid(context, rc_ident,
|
||||
bay.uuid,
|
||||
self.k8s_api)
|
||||
|
@ -402,7 +402,7 @@ class Handler(object):
|
|||
LOG.debug("rc_show %s", rc_ident)
|
||||
bay = conductor_utils.retrieve_bay(context, bay_ident)
|
||||
self.k8s_api = k8s.create_k8s_api(context, bay)
|
||||
if utils.is_uuid_like(rc_ident):
|
||||
if uuidutils.is_uuid_like(rc_ident):
|
||||
rc = objects.ReplicationController.get_by_uuid(context, rc_ident,
|
||||
bay.uuid,
|
||||
self.k8s_api)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from pycadf import cadftaxonomy as taxonomy
|
||||
from pycadf import cadftype
|
||||
from pycadf import eventfactory
|
||||
|
@ -19,13 +20,12 @@ from pycadf import resource
|
|||
|
||||
from magnum.common import clients
|
||||
from magnum.common import rpc
|
||||
from magnum.common import utils
|
||||
from magnum.objects import bay
|
||||
from magnum.objects import baymodel
|
||||
|
||||
|
||||
def retrieve_bay(context, bay_ident):
|
||||
if not utils.is_uuid_like(bay_ident):
|
||||
if not uuidutils.is_uuid_like(bay_ident):
|
||||
return bay.Bay.get_by_name(context, bay_ident)
|
||||
else:
|
||||
return bay.Bay.get_by_uuid(context, bay_ident)
|
||||
|
@ -36,7 +36,7 @@ def retrieve_baymodel(context, bay):
|
|||
|
||||
|
||||
def retrieve_bay_uuid(context, bay_ident):
|
||||
if not utils.is_uuid_like(bay_ident):
|
||||
if not uuidutils.is_uuid_like(bay_ident):
|
||||
bay_obj = bay.Bay.get_by_name(context, bay_ident)
|
||||
return bay_obj.uuid
|
||||
else:
|
||||
|
|
|
@ -71,7 +71,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'uuid': utils.generate_uuid(),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'name': 'example',
|
||||
'type': 'virt'
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'uuid': utils.generate_uuid(),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'name': 'example',
|
||||
'type': 'virt'
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'uuid': utils.generate_uuid(),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'name': 'example',
|
||||
'type': 'virt'
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'uuid': utils.generate_uuid(),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'name': 'example',
|
||||
'type': 'virt'
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'uuid': utils.generate_uuid(),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'name': 'example',
|
||||
'type': 'virt'
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'uuid': utils.generate_uuid(),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'name': 'example',
|
||||
'images': '["myimage"]'
|
||||
}
|
||||
|
@ -542,7 +542,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'uuid': utils.generate_uuid(),
|
||||
'uuid': uuidutils.generate_uuid(),
|
||||
'name': 'example',
|
||||
'ca_cert': 'AAA...',
|
||||
'certificate': 'BBB...',
|
||||
|
@ -682,7 +682,7 @@ class Connection(object):
|
|||
::
|
||||
|
||||
{
|
||||
'id': utils.generate_uuid(),
|
||||
'id': uuidutils.generate_uuid(),
|
||||
'project_id': 'fake_project',
|
||||
'resource': 'fake_resource',
|
||||
'hard_limit': 'fake_hardlimit',
|
||||
|
|
|
@ -19,6 +19,7 @@ from oslo_db import exception as db_exc
|
|||
from oslo_db.sqlalchemy import session as db_session
|
||||
from oslo_db.sqlalchemy import utils as db_utils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy.orm.exc import MultipleResultsFound
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
|
@ -79,7 +80,7 @@ def add_identity_filter(query, value):
|
|||
"""
|
||||
if utils.is_int_like(value):
|
||||
return query.filter_by(id=value)
|
||||
elif utils.is_uuid_like(value):
|
||||
elif uuidutils.is_uuid_like(value):
|
||||
return query.filter_by(uuid=value)
|
||||
else:
|
||||
raise exception.InvalidIdentity(identity=value)
|
||||
|
@ -149,7 +150,7 @@ class Connection(api.Connection):
|
|||
def create_bay(self, values):
|
||||
# ensure defaults are present for new bays
|
||||
if not values.get('uuid'):
|
||||
values['uuid'] = utils.generate_uuid()
|
||||
values['uuid'] = uuidutils.generate_uuid()
|
||||
|
||||
bay = models.Bay()
|
||||
bay.update(values)
|
||||
|
@ -279,7 +280,7 @@ class Connection(api.Connection):
|
|||
def create_baymodel(self, values):
|
||||
# ensure defaults are present for new baymodels
|
||||
if not values.get('uuid'):
|
||||
values['uuid'] = utils.generate_uuid()
|
||||
values['uuid'] = uuidutils.generate_uuid()
|
||||
|
||||
baymodel = models.BayModel()
|
||||
baymodel.update(values)
|
||||
|
@ -402,7 +403,7 @@ class Connection(api.Connection):
|
|||
def create_container(self, values):
|
||||
# ensure defaults are present for new containers
|
||||
if not values.get('uuid'):
|
||||
values['uuid'] = utils.generate_uuid()
|
||||
values['uuid'] = uuidutils.generate_uuid()
|
||||
|
||||
container = models.Container()
|
||||
container.update(values)
|
||||
|
@ -500,7 +501,7 @@ class Connection(api.Connection):
|
|||
def create_pod(self, values):
|
||||
# ensure defaults are present for new pods
|
||||
if not values.get('uuid'):
|
||||
values['uuid'] = utils.generate_uuid()
|
||||
values['uuid'] = uuidutils.generate_uuid()
|
||||
|
||||
pod = models.Pod()
|
||||
pod.update(values)
|
||||
|
@ -597,7 +598,7 @@ class Connection(api.Connection):
|
|||
def create_service(self, values):
|
||||
# ensure defaults are present for new services
|
||||
if not values.get('uuid'):
|
||||
values['uuid'] = utils.generate_uuid()
|
||||
values['uuid'] = uuidutils.generate_uuid()
|
||||
|
||||
service = models.Service()
|
||||
service.update(values)
|
||||
|
@ -694,7 +695,7 @@ class Connection(api.Connection):
|
|||
def create_rc(self, values):
|
||||
# ensure defaults are present for new ReplicationController
|
||||
if not values.get('uuid'):
|
||||
values['uuid'] = utils.generate_uuid()
|
||||
values['uuid'] = uuidutils.generate_uuid()
|
||||
|
||||
rc = models.ReplicationController()
|
||||
rc.update(values)
|
||||
|
@ -767,7 +768,7 @@ class Connection(api.Connection):
|
|||
def create_x509keypair(self, values):
|
||||
# ensure defaults are present for new x509keypairs
|
||||
if not values.get('uuid'):
|
||||
values['uuid'] = utils.generate_uuid()
|
||||
values['uuid'] = uuidutils.generate_uuid()
|
||||
|
||||
x509keypair = models.X509KeyPair()
|
||||
x509keypair.update(values)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_versionedobjects import fields
|
||||
|
||||
from magnum.common import exception
|
||||
|
@ -96,7 +97,7 @@ class Bay(base.MagnumPersistentObject, base.MagnumObject,
|
|||
"""
|
||||
if utils.is_int_like(bay_id):
|
||||
return cls.get_by_id(context, bay_id)
|
||||
elif utils.is_uuid_like(bay_id):
|
||||
elif uuidutils.is_uuid_like(bay_id):
|
||||
return cls.get_by_uuid(context, bay_id)
|
||||
else:
|
||||
raise exception.InvalidIdentity(identity=bay_id)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_versionedobjects import fields
|
||||
|
||||
from magnum.common import exception
|
||||
|
@ -93,7 +94,7 @@ class BayModel(base.MagnumPersistentObject, base.MagnumObject,
|
|||
"""
|
||||
if utils.is_int_like(baymodel_id):
|
||||
return cls.get_by_id(context, baymodel_id)
|
||||
elif utils.is_uuid_like(baymodel_id):
|
||||
elif uuidutils.is_uuid_like(baymodel_id):
|
||||
return cls.get_by_uuid(context, baymodel_id)
|
||||
else:
|
||||
raise exception.InvalidIdentity(identity=baymodel_id)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_versionedobjects import fields
|
||||
|
||||
from magnum.common import exception
|
||||
|
@ -66,7 +67,7 @@ class X509KeyPair(base.MagnumPersistentObject, base.MagnumObject,
|
|||
"""
|
||||
if utils.is_int_like(x509keypair_id):
|
||||
return cls.get_by_id(context, x509keypair_id)
|
||||
elif utils.is_uuid_like(x509keypair_id):
|
||||
elif uuidutils.is_uuid_like(x509keypair_id):
|
||||
return cls.get_by_uuid(context, x509keypair_id)
|
||||
else:
|
||||
raise exception.InvalidIdentity(identity=x509keypair_id)
|
||||
|
|
|
@ -15,12 +15,12 @@ import datetime
|
|||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from magnum.api import attr_validator
|
||||
from magnum.api.controllers.v1 import bay as api_bay
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils
|
||||
from magnum.conductor import api as rpcapi
|
||||
from magnum import objects
|
||||
from magnum.tests import base
|
||||
|
@ -92,9 +92,9 @@ class TestListBay(api_base.FunctionalTest):
|
|||
|
||||
def test_get_one_by_name_multiple_bay(self):
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/bays/test_bay', expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -104,7 +104,7 @@ class TestListBay(api_base.FunctionalTest):
|
|||
bay_list = []
|
||||
for id_ in range(4):
|
||||
bay = obj_utils.create_test_bay(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
bay_list.append(bay)
|
||||
|
||||
response = self.get_json('/bays?limit=3&marker=%s'
|
||||
|
@ -122,7 +122,7 @@ class TestListBay(api_base.FunctionalTest):
|
|||
bay_list = []
|
||||
for id_ in range(4):
|
||||
bay = obj_utils.create_test_bay(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
bay_list.append(bay)
|
||||
|
||||
response = self.get_json('/bays/detail?limit=3&marker=%s'
|
||||
|
@ -141,7 +141,7 @@ class TestListBay(api_base.FunctionalTest):
|
|||
bm_list = []
|
||||
for id_ in range(5):
|
||||
bay = obj_utils.create_test_bay(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
bm_list.append(bay.uuid)
|
||||
response = self.get_json('/bays')
|
||||
self.assertEqual(len(bm_list), len(response['bays']))
|
||||
|
@ -149,7 +149,7 @@ class TestListBay(api_base.FunctionalTest):
|
|||
self.assertEqual(sorted(bm_list), sorted(uuids))
|
||||
|
||||
def test_links(self):
|
||||
uuid = utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
obj_utils.create_test_bay(self.context, id=1, uuid=uuid)
|
||||
response = self.get_json('/bays/%s' % uuid)
|
||||
self.assertIn('links', response.keys())
|
||||
|
@ -162,7 +162,7 @@ class TestListBay(api_base.FunctionalTest):
|
|||
def test_collection_links(self):
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_bay(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/bays/?limit=3')
|
||||
self.assertEqual(3, len(response['bays']))
|
||||
|
||||
|
@ -173,7 +173,7 @@ class TestListBay(api_base.FunctionalTest):
|
|||
cfg.CONF.set_override('max_limit', 3, 'api')
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_bay(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/bays')
|
||||
self.assertEqual(3, len(response['bays']))
|
||||
|
||||
|
@ -256,8 +256,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertEqual(404, response.status_code)
|
||||
|
||||
def test_replace_baymodel_id_failed(self):
|
||||
baymodel = obj_utils.create_test_baymodel(self.context,
|
||||
uuid=utils.generate_uuid())
|
||||
baymodel = obj_utils.create_test_baymodel(
|
||||
self.context,
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/baymodel_id',
|
||||
'value': baymodel.uuid,
|
||||
|
@ -273,9 +274,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
mock_utcnow.return_value = test_time
|
||||
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
|
||||
response = self.patch_json('/bays/test_bay',
|
||||
[{'path': '/name', 'value': 'test_bay',
|
||||
|
@ -287,7 +288,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
def test_replace_non_existent_baymodel_id(self):
|
||||
response = self.patch_json('/bays/%s' % self.bay.uuid,
|
||||
[{'path': '/baymodel_id',
|
||||
'value': utils.generate_uuid(),
|
||||
'value': uuidutils.generate_uuid(),
|
||||
'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -304,7 +305,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['errors'])
|
||||
|
||||
def test_replace_non_existent_bay(self):
|
||||
response = self.patch_json('/bays/%s' % utils.generate_uuid(),
|
||||
response = self.patch_json('/bays/%s' % uuidutils.generate_uuid(),
|
||||
[{'path': '/name',
|
||||
'value': 'bay_example_B',
|
||||
'op': 'replace'}],
|
||||
|
@ -445,7 +446,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(201, response.status_int)
|
||||
self.assertEqual(bdict['name'], response.json['name'])
|
||||
self.assertTrue(utils.is_uuid_like(response.json['uuid']))
|
||||
self.assertTrue(uuidutils.is_uuid_like(response.json['uuid']))
|
||||
|
||||
def test_create_bay_no_baymodel_id(self):
|
||||
bdict = apiutils.bay_post_data()
|
||||
|
@ -455,7 +456,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(400, response.status_int)
|
||||
|
||||
def test_create_bay_with_non_existent_baymodel_id(self):
|
||||
bdict = apiutils.bay_post_data(baymodel_id=utils.generate_uuid())
|
||||
bdict = apiutils.bay_post_data(baymodel_id=uuidutils.generate_uuid())
|
||||
response = self.post_json('/bays', bdict, expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
|
@ -640,7 +641,7 @@ class TestDelete(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['errors'])
|
||||
|
||||
def test_delete_bay_not_found(self):
|
||||
uuid = utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
response = self.delete('/bays/%s' % uuid, expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -677,9 +678,9 @@ class TestDelete(api_base.FunctionalTest):
|
|||
|
||||
def test_delete_multiple_bay_by_name(self):
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.delete('/bays/test_bay', expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -714,7 +715,7 @@ class TestBayPolicyEnforcement(api_base.FunctionalTest):
|
|||
def test_policy_disallow_detail(self):
|
||||
self._common_policy_check(
|
||||
"bay:detail", self.get_json,
|
||||
'/bays/%s/detail' % utils.generate_uuid(),
|
||||
'/bays/%s/detail' % uuidutils.generate_uuid(),
|
||||
expect_errors=True)
|
||||
|
||||
def test_policy_disallow_update(self):
|
||||
|
|
|
@ -15,6 +15,7 @@ import datetime
|
|||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from webtest.app import AppError
|
||||
from wsme import types as wtypes
|
||||
|
@ -23,7 +24,6 @@ from magnum.api import attr_validator
|
|||
from magnum.api.controllers.v1 import baymodel as api_baymodel
|
||||
from magnum.common import exception
|
||||
from magnum.common import policy as magnum_policy
|
||||
from magnum.common import utils
|
||||
from magnum.tests import base
|
||||
from magnum.tests.unit.api import base as api_base
|
||||
from magnum.tests.unit.api import utils as apiutils
|
||||
|
@ -85,10 +85,10 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
def test_get_one_by_name_multiple_baymodel(self):
|
||||
obj_utils.create_test_baymodel(
|
||||
self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_baymodel(
|
||||
self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json(
|
||||
'/baymodels/test_baymodel',
|
||||
expect_errors=True)
|
||||
|
@ -101,7 +101,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
for id_ in range(4):
|
||||
baymodel = obj_utils.create_test_baymodel(
|
||||
self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
bm_list.append(baymodel)
|
||||
|
||||
response = self.get_json('/baymodels?limit=3&marker=%s'
|
||||
|
@ -121,7 +121,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
for id_ in range(4):
|
||||
baymodel = obj_utils.create_test_baymodel(
|
||||
self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
bm_list.append(baymodel)
|
||||
|
||||
response = self.get_json('/baymodels/detail?limit=3&marker=%s'
|
||||
|
@ -142,7 +142,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
for id_ in range(5):
|
||||
baymodel = obj_utils.create_test_baymodel(
|
||||
self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
bm_list.append(baymodel.uuid)
|
||||
response = self.get_json('/baymodels')
|
||||
self.assertEqual(len(bm_list), len(response['baymodels']))
|
||||
|
@ -150,7 +150,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
self.assertEqual(sorted(bm_list), sorted(uuids))
|
||||
|
||||
def test_links(self):
|
||||
uuid = utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
obj_utils.create_test_baymodel(self.context, id=1, uuid=uuid)
|
||||
response = self.get_json('/baymodels/%s' % uuid)
|
||||
self.assertIn('links', response.keys())
|
||||
|
@ -163,7 +163,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
def test_collection_links(self):
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_baymodel(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/baymodels/?limit=3')
|
||||
self.assertEqual(3, len(response['baymodels']))
|
||||
|
||||
|
@ -174,7 +174,7 @@ class TestListBayModel(api_base.FunctionalTest):
|
|||
cfg.CONF.set_override('max_limit', 3, 'api')
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_baymodel(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/baymodels')
|
||||
self.assertEqual(3, len(response['baymodels']))
|
||||
|
||||
|
@ -207,7 +207,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||
)
|
||||
|
||||
def test_update_not_found(self):
|
||||
uuid = utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
response = self.patch_json('/baymodels/%s' % uuid,
|
||||
[{'path': '/name',
|
||||
'value': 'bay_model_example_B',
|
||||
|
@ -367,8 +367,9 @@ class TestPatch(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['errors'])
|
||||
|
||||
def test_remove_singular(self):
|
||||
baymodel = obj_utils.create_test_baymodel(self.context,
|
||||
uuid=utils.generate_uuid())
|
||||
baymodel = obj_utils.create_test_baymodel(
|
||||
self.context,
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/baymodels/%s' % baymodel.uuid)
|
||||
self.assertIsNotNone(response['dns_nameserver'])
|
||||
|
||||
|
@ -615,7 +616,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
response.json['image_id'])
|
||||
cc_mock.assert_called_once_with(mock.ANY)
|
||||
self.assertNotIn('id', cc_mock.call_args[0][0])
|
||||
self.assertTrue(utils.is_uuid_like(response.json['uuid']))
|
||||
self.assertTrue(uuidutils.is_uuid_like(response.json['uuid']))
|
||||
|
||||
def test_create_baymodel_with_network_driver(self):
|
||||
baymodel_dict = {'coe': 'kubernetes', 'network_driver': 'flannel'}
|
||||
|
@ -875,7 +876,7 @@ class TestDelete(api_base.FunctionalTest):
|
|||
self.assertIn(baymodel.uuid, response.json['errors'][0]['detail'])
|
||||
|
||||
def test_delete_baymodel_not_found(self):
|
||||
uuid = utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
response = self.delete('/baymodels/%s' % uuid, expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -895,9 +896,9 @@ class TestDelete(api_base.FunctionalTest):
|
|||
|
||||
def test_delete_multiple_baymodel_by_name(self):
|
||||
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_baymodel(self.context, name='test_baymodel',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.delete('/baymodels/test_baymodel', expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -930,13 +931,14 @@ class TestBayModelPolicyEnforcement(api_base.FunctionalTest):
|
|||
def test_policy_disallow_detail(self):
|
||||
self._common_policy_check(
|
||||
"baymodel:detail", self.get_json,
|
||||
'/baymodels/%s/detail' % utils.generate_uuid(),
|
||||
'/baymodels/%s/detail' % uuidutils.generate_uuid(),
|
||||
expect_errors=True)
|
||||
|
||||
def test_policy_disallow_update(self):
|
||||
baymodel = obj_utils.create_test_baymodel(self.context,
|
||||
name='example_A',
|
||||
uuid=utils.generate_uuid())
|
||||
baymodel = obj_utils.create_test_baymodel(
|
||||
self.context,
|
||||
name='example_A',
|
||||
uuid=uuidutils.generate_uuid())
|
||||
self._common_policy_check(
|
||||
"baymodel:update", self.patch_json,
|
||||
'/baymodels/%s' % baymodel.name,
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from magnum.api.controllers.v1 import certificate as api_cert
|
||||
from magnum.common import utils
|
||||
from magnum.tests import base
|
||||
from magnum.tests.unit.api import base as api_base
|
||||
from magnum.tests.unit.api import utils as api_utils
|
||||
|
@ -82,9 +82,9 @@ class TestGetCertificate(api_base.FunctionalTest):
|
|||
|
||||
def test_get_one_by_name_multiple_bay(self):
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_bay(self.context, name='test_bay',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
|
||||
response = self.get_json('/certificates/test_bay',
|
||||
expect_errors=True)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# 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
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
@ -41,7 +42,7 @@ class TestUuidType(base.FunctionalTest):
|
|||
|
||||
def test_valid_uuid(self):
|
||||
test_uuid = '1a1a1a1a-2b2b-3c3c-4d4d-5e5e5e5e5e5e'
|
||||
with mock.patch.object(utils, 'is_uuid_like') as uuid_mock:
|
||||
with mock.patch.object(uuidutils, 'is_uuid_like') as uuid_mock:
|
||||
types.UuidType.validate(test_uuid)
|
||||
uuid_mock.assert_called_once_with(test_uuid)
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
import jsonpatch
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
import wsme
|
||||
|
||||
from magnum.api import utils
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as common_utils
|
||||
from magnum.tests.unit.api import base
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ class TestApiUtils(base.FunctionalTest):
|
|||
mock_request):
|
||||
mock_bay = mock.MagicMock
|
||||
mock_get_by_uuid.return_value = mock_bay
|
||||
uuid = common_utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
|
||||
returned_bay = utils.get_resource('Bay', uuid)
|
||||
|
||||
|
@ -88,7 +88,7 @@ class TestApiUtils(base.FunctionalTest):
|
|||
'fake-name')
|
||||
self.assertEqual(mock_bay, returned_bay)
|
||||
|
||||
@mock.patch.object(common_utils, 'is_uuid_like', return_value=True)
|
||||
@mock.patch.object(uuidutils, 'is_uuid_like', return_value=True)
|
||||
def test_get_openstack_resource_by_uuid(self, fake_is_uuid_like):
|
||||
fake_manager = mock.MagicMock()
|
||||
fake_manager.get.return_value = 'fake_resource_data'
|
||||
|
@ -97,7 +97,7 @@ class TestApiUtils(base.FunctionalTest):
|
|||
'fake_resource_type')
|
||||
self.assertEqual('fake_resource_data', resource_data)
|
||||
|
||||
@mock.patch.object(common_utils, 'is_uuid_like', return_value=False)
|
||||
@mock.patch.object(uuidutils, 'is_uuid_like', return_value=False)
|
||||
def test_get_openstack_resource_by_name(self, fake_is_uuid_like):
|
||||
fake_manager = mock.MagicMock()
|
||||
fake_manager.list.return_value = ['fake_resource_data']
|
||||
|
@ -106,7 +106,7 @@ class TestApiUtils(base.FunctionalTest):
|
|||
'fake_resource_type')
|
||||
self.assertEqual('fake_resource_data', resource_data)
|
||||
|
||||
@mock.patch.object(common_utils, 'is_uuid_like', return_value=False)
|
||||
@mock.patch.object(uuidutils, 'is_uuid_like', return_value=False)
|
||||
def test_get_openstack_resource_non_exist(self, fake_is_uuid_like):
|
||||
fake_manager = mock.MagicMock()
|
||||
fake_manager.list.return_value = []
|
||||
|
@ -114,7 +114,7 @@ class TestApiUtils(base.FunctionalTest):
|
|||
utils.get_openstack_resource,
|
||||
fake_manager, 'fake_resource', 'fake_resource_type')
|
||||
|
||||
@mock.patch.object(common_utils, 'is_uuid_like', return_value=False)
|
||||
@mock.patch.object(uuidutils, 'is_uuid_like', return_value=False)
|
||||
def test_get_openstack_resource_multi_exist(self, fake_is_uuid_like):
|
||||
fake_manager = mock.MagicMock()
|
||||
fake_manager.list.return_value = ['fake_resource_data1',
|
||||
|
|
|
@ -17,10 +17,10 @@ import datetime
|
|||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from magnum.api.controllers.v1 import x509keypair as api_x509keypair
|
||||
from magnum.common import utils
|
||||
from magnum.conductor import api as rpcapi
|
||||
from magnum import objects
|
||||
from magnum.tests import base
|
||||
|
@ -85,10 +85,10 @@ class TestListX509KeyPair(api_base.FunctionalTest):
|
|||
def test_get_one_by_name_multiple_x509keypair(self):
|
||||
obj_utils.create_test_x509keypair(self.context,
|
||||
name='test_x509keypair',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_x509keypair(self.context,
|
||||
name='test_x509keypair',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/x509keypairs/test_x509keypair',
|
||||
expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
|
@ -116,7 +116,7 @@ class TestListX509KeyPair(api_base.FunctionalTest):
|
|||
for id_ in range(5):
|
||||
x509keypair = obj_utils.create_test_x509keypair(
|
||||
self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
keypair_list.append(x509keypair.uuid)
|
||||
response = self.get_json('/x509keypairs')
|
||||
self.assertEqual(len(keypair_list), len(response['x509keypairs']))
|
||||
|
@ -124,7 +124,7 @@ class TestListX509KeyPair(api_base.FunctionalTest):
|
|||
self.assertEqual(sorted(keypair_list), sorted(uuids))
|
||||
|
||||
def test_links(self):
|
||||
uuid = utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
obj_utils.create_test_x509keypair(self.context, id=1, uuid=uuid)
|
||||
response = self.get_json('/x509keypairs/%s' % uuid)
|
||||
self.assertIn('links', response.keys())
|
||||
|
@ -137,7 +137,7 @@ class TestListX509KeyPair(api_base.FunctionalTest):
|
|||
def test_collection_links(self):
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_x509keypair(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/x509keypairs/?limit=3')
|
||||
self.assertEqual(3, len(response['x509keypairs']))
|
||||
|
||||
|
@ -148,7 +148,7 @@ class TestListX509KeyPair(api_base.FunctionalTest):
|
|||
cfg.CONF.set_override('max_limit', 3, 'api')
|
||||
for id_ in range(5):
|
||||
obj_utils.create_test_x509keypair(self.context, id=id_,
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.get_json('/x509keypairs')
|
||||
self.assertEqual(3, len(response['x509keypairs']))
|
||||
|
||||
|
@ -222,7 +222,7 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(201, response.status_int)
|
||||
self.assertEqual(cdict['name'], response.json['name'])
|
||||
self.assertTrue(utils.is_uuid_like(response.json['uuid']))
|
||||
self.assertTrue(uuidutils.is_uuid_like(response.json['uuid']))
|
||||
|
||||
def test_create_x509keypair_no_bay_uuid(self):
|
||||
cdict = apiutils.x509keypair_post_data()
|
||||
|
@ -232,7 +232,8 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(400, response.status_int)
|
||||
|
||||
def test_create_x509keypair_with_non_existent_bay_uuid(self):
|
||||
cdict = apiutils.x509keypair_post_data(bay_uuid=utils.generate_uuid())
|
||||
cdict = apiutils.x509keypair_post_data(
|
||||
bay_uuid=uuidutils.generate_uuid())
|
||||
response = self.post_json('/x509keypairs', cdict, expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
|
@ -271,7 +272,7 @@ class TestDelete(api_base.FunctionalTest):
|
|||
self.assertTrue(response.json['errors'])
|
||||
|
||||
def test_delete_x509keypair_not_found(self):
|
||||
uuid = utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
response = self.delete('/x509keypairs/%s' % uuid, expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
|
@ -291,10 +292,10 @@ class TestDelete(api_base.FunctionalTest):
|
|||
def test_delete_multiple_x509keypair_by_name(self):
|
||||
obj_utils.create_test_x509keypair(self.context,
|
||||
name='test_x509keypair',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
obj_utils.create_test_x509keypair(self.context,
|
||||
name='test_x509keypair',
|
||||
uuid=utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
response = self.delete('/x509keypairs/test_x509keypair',
|
||||
expect_errors=True)
|
||||
self.assertEqual(409, response.status_int)
|
||||
|
|
|
@ -19,7 +19,6 @@ import os
|
|||
import os.path
|
||||
import shutil
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
import netaddr
|
||||
|
@ -519,25 +518,6 @@ class IntLikeTestCase(base.TestCase):
|
|||
self.assertFalse(utils.is_int_like("a1"))
|
||||
|
||||
|
||||
class UUIDTestCase(base.TestCase):
|
||||
|
||||
def test_generate_uuid(self):
|
||||
uuid_string = utils.generate_uuid()
|
||||
self.assertIsInstance(uuid_string, str)
|
||||
self.assertEqual(36, len(uuid_string))
|
||||
# make sure there are 4 dashes
|
||||
self.assertEqual(32, len(uuid_string.replace('-', '')))
|
||||
|
||||
def test_is_uuid_like(self):
|
||||
self.assertTrue(utils.is_uuid_like(str(uuid.uuid4())))
|
||||
|
||||
def test_id_is_uuid_like(self):
|
||||
self.assertFalse(utils.is_uuid_like(1234567))
|
||||
|
||||
def test_name_is_uuid_like(self):
|
||||
self.assertFalse(utils.is_uuid_like('zhongyueluo'))
|
||||
|
||||
|
||||
class TempFilesTestCase(base.TestCase):
|
||||
|
||||
def test_tempdir(self):
|
||||
|
|
|
@ -70,7 +70,7 @@ class TestConductorUtils(base.TestCase):
|
|||
expected_context,
|
||||
expected_baymodel_uuid)
|
||||
|
||||
@patch('magnum.common.utils.is_uuid_like')
|
||||
@patch('oslo_utils.uuidutils.is_uuid_like')
|
||||
@patch('magnum.objects.Bay.get_by_name')
|
||||
def test_retrieve_bay_uuid_from_name(self, mock_bay_get_by_name,
|
||||
mock_uuid_like):
|
||||
|
@ -83,7 +83,7 @@ class TestConductorUtils(base.TestCase):
|
|||
mock_uuid_like.assert_called_once_with('fake_name')
|
||||
mock_bay_get_by_name.assert_called_once_with('context', 'fake_name')
|
||||
|
||||
@patch('magnum.common.utils.is_uuid_like')
|
||||
@patch('oslo_utils.uuidutils.is_uuid_like')
|
||||
@patch('magnum.objects.Bay.get_by_name')
|
||||
def test_retrieve_bay_uuid_from_uuid(self, mock_bay_get_by_name,
|
||||
mock_uuid_like):
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
"""Tests for custom SQLAlchemy types via Magnum DB."""
|
||||
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from magnum.common import utils as magnum_utils
|
||||
import magnum.db.sqlalchemy.api as sa_api
|
||||
from magnum.db.sqlalchemy import models
|
||||
from magnum.tests.unit.db import base
|
||||
|
@ -24,13 +24,13 @@ class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
|
|||
|
||||
def test_JSONEncodedDict_default_value(self):
|
||||
# Create pod w/o labels
|
||||
pod1_id = magnum_utils.generate_uuid()
|
||||
pod1_id = uuidutils.generate_uuid()
|
||||
self.dbapi.create_pod({'uuid': pod1_id})
|
||||
pod1 = sa_api.model_query(models.Pod).filter_by(uuid=pod1_id).one()
|
||||
self.assertEqual({}, pod1.labels)
|
||||
|
||||
# Create pod with labels
|
||||
pod2_id = magnum_utils.generate_uuid()
|
||||
pod2_id = uuidutils.generate_uuid()
|
||||
self.dbapi.create_pod({'uuid': pod2_id, 'labels': {'bar': 'foo'}})
|
||||
pod2 = sa_api.model_query(models.Pod).filter_by(uuid=pod2_id).one()
|
||||
self.assertEqual('foo', pod2.labels['bar'])
|
||||
|
@ -43,13 +43,13 @@ class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
|
|||
|
||||
def test_JSONEncodedList_default_value(self):
|
||||
# Create pod w/o images
|
||||
pod1_id = magnum_utils.generate_uuid()
|
||||
pod1_id = uuidutils.generate_uuid()
|
||||
self.dbapi.create_pod({'uuid': pod1_id})
|
||||
pod1 = sa_api.model_query(models.Pod).filter_by(uuid=pod1_id).one()
|
||||
self.assertEqual([], pod1.images)
|
||||
|
||||
# Create pod with images
|
||||
pod2_id = magnum_utils.generate_uuid()
|
||||
pod2_id = uuidutils.generate_uuid()
|
||||
self.dbapi.create_pod({'uuid': pod2_id,
|
||||
'images': ['myimage1', 'myimage2']})
|
||||
pod2 = sa_api.model_query(models.Pod).filter_by(uuid=pod2_id).one()
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
# under the License.
|
||||
|
||||
"""Tests for manipulating Bays via the DB API"""
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnum.common import context
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.objects.fields import BayStatus as bay_status
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
@ -68,7 +67,7 @@ class DbBayTestCase(base.DbTestCase):
|
|||
def test_get_bay_list(self):
|
||||
uuids = []
|
||||
for i in range(1, 6):
|
||||
bay = utils.create_test_bay(uuid=magnum_utils.generate_uuid())
|
||||
bay = utils.create_test_bay(uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(bay['uuid']))
|
||||
res = self.dbapi.get_bay_list(self.context)
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -77,7 +76,7 @@ class DbBayTestCase(base.DbTestCase):
|
|||
def test_get_bay_list_sorted(self):
|
||||
uuids = []
|
||||
for _ in range(5):
|
||||
bay = utils.create_test_bay(uuid=magnum_utils.generate_uuid())
|
||||
bay = utils.create_test_bay(uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(bay.uuid))
|
||||
res = self.dbapi.get_bay_list(self.context, sort_key='uuid')
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -89,19 +88,19 @@ class DbBayTestCase(base.DbTestCase):
|
|||
sort_key='foo')
|
||||
|
||||
def test_get_bay_list_with_filters(self):
|
||||
bm1 = utils.get_test_baymodel(id=1, uuid=magnum_utils.generate_uuid())
|
||||
bm2 = utils.get_test_baymodel(id=2, uuid=magnum_utils.generate_uuid())
|
||||
bm1 = utils.get_test_baymodel(id=1, uuid=uuidutils.generate_uuid())
|
||||
bm2 = utils.get_test_baymodel(id=2, uuid=uuidutils.generate_uuid())
|
||||
self.dbapi.create_baymodel(bm1)
|
||||
self.dbapi.create_baymodel(bm2)
|
||||
|
||||
bay1 = utils.create_test_bay(
|
||||
name='bay-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
baymodel_id=bm1['uuid'],
|
||||
status=bay_status.CREATE_IN_PROGRESS)
|
||||
bay2 = utils.create_test_bay(
|
||||
name='bay-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
baymodel_id=bm2['uuid'],
|
||||
node_count=1,
|
||||
master_count=1,
|
||||
|
@ -154,9 +153,9 @@ class DbBayTestCase(base.DbTestCase):
|
|||
uuids = []
|
||||
for i in range(1, 6):
|
||||
bay = utils.create_test_bay(
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
project_id=magnum_utils.generate_uuid(),
|
||||
user_id=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
project_id=uuidutils.generate_uuid(),
|
||||
user_id=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(bay['uuid']))
|
||||
ctx = context.make_admin_context(all_tenants=True)
|
||||
res = self.dbapi.get_bay_list(ctx)
|
||||
|
@ -167,7 +166,7 @@ class DbBayTestCase(base.DbTestCase):
|
|||
utils.create_test_bay()
|
||||
self.assertEqual(1, len(self.dbapi.get_bay_list(self.context)))
|
||||
res = self.dbapi.get_bay_list(self.context, filters={
|
||||
'baymodel_id': magnum_utils.generate_uuid()})
|
||||
'baymodel_id': uuidutils.generate_uuid()})
|
||||
self.assertEqual(0, len(res))
|
||||
|
||||
def test_destroy_bay(self):
|
||||
|
@ -272,7 +271,7 @@ class DbBayTestCase(base.DbTestCase):
|
|||
self.assertEqual(new_nc, res.node_count)
|
||||
|
||||
def test_update_bay_not_found(self):
|
||||
bay_uuid = magnum_utils.generate_uuid()
|
||||
bay_uuid = uuidutils.generate_uuid()
|
||||
self.assertRaises(exception.BayNotFound, self.dbapi.update_bay,
|
||||
bay_uuid, {'node_count': 5})
|
||||
|
||||
|
|
|
@ -14,11 +14,10 @@
|
|||
# under the License.
|
||||
|
||||
"""Tests for manipulating Baymodel via the DB API"""
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
||||
|
@ -32,7 +31,7 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
uuids = []
|
||||
for i in range(1, 6):
|
||||
bm = utils.create_test_baymodel(id=i,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(bm['uuid']))
|
||||
res = self.dbapi.get_baymodel_list(self.context)
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -41,7 +40,7 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
def test_get_baymodel_list_sorted(self):
|
||||
uuids = []
|
||||
for _ in range(5):
|
||||
bm = utils.create_test_baymodel(uuid=magnum_utils.generate_uuid())
|
||||
bm = utils.create_test_baymodel(uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(bm['uuid']))
|
||||
res = self.dbapi.get_baymodel_list(self.context, sort_key='uuid')
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -56,12 +55,12 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
bm1 = utils.create_test_baymodel(
|
||||
id=1,
|
||||
name='bm-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
image_id='image1')
|
||||
bm2 = utils.create_test_baymodel(
|
||||
id=2,
|
||||
name='bm-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
image_id='image2')
|
||||
|
||||
res = self.dbapi.get_baymodel_list(self.context,
|
||||
|
@ -119,11 +118,11 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
def test_get_baymodel_by_name_multiple_baymodel(self):
|
||||
utils.create_test_baymodel(
|
||||
id=1, name='bm',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
image_id='image1')
|
||||
utils.create_test_baymodel(
|
||||
id=2, name='bm',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
image_id='image2')
|
||||
self.assertRaises(exception.Conflict, self.dbapi.get_baymodel_by_name,
|
||||
self.context, 'bm')
|
||||
|
@ -156,7 +155,7 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
self.context, bm['id'])
|
||||
|
||||
def test_destroy_baymodel_by_uuid(self):
|
||||
uuid = magnum_utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
utils.create_test_baymodel(uuid=uuid)
|
||||
self.assertIsNotNone(self.dbapi.get_baymodel_by_uuid(self.context,
|
||||
uuid))
|
||||
|
@ -176,7 +175,7 @@ class DbBaymodelTestCase(base.DbTestCase):
|
|||
self.dbapi.destroy_baymodel, bm['id'])
|
||||
|
||||
def test_create_baymodel_already_exists(self):
|
||||
uuid = magnum_utils.generate_uuid()
|
||||
uuid = uuidutils.generate_uuid()
|
||||
utils.create_test_baymodel(id=1, uuid=uuid)
|
||||
self.assertRaises(exception.BayModelAlreadyExists,
|
||||
utils.create_test_baymodel,
|
||||
|
|
|
@ -14,11 +14,10 @@
|
|||
# under the License.
|
||||
|
||||
"""Tests for manipulating Containers via the DB API"""
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
||||
|
@ -59,13 +58,13 @@ class DbContainerTestCase(base.DbTestCase):
|
|||
self.assertRaises(exception.ContainerNotFound,
|
||||
self.dbapi.get_container_by_uuid,
|
||||
self.context,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
|
||||
def test_get_container_list(self):
|
||||
uuids = []
|
||||
for i in range(1, 6):
|
||||
container = utils.create_test_container(
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(container['uuid']))
|
||||
res = self.dbapi.get_container_list(self.context)
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -75,7 +74,7 @@ class DbContainerTestCase(base.DbTestCase):
|
|||
uuids = []
|
||||
for _ in range(5):
|
||||
container = utils.create_test_container(
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(container.uuid))
|
||||
res = self.dbapi.get_container_list(self.context, sort_key='uuid')
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -89,12 +88,12 @@ class DbContainerTestCase(base.DbTestCase):
|
|||
def test_get_container_list_with_filters(self):
|
||||
container1 = utils.create_test_container(
|
||||
name='container-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
bay_uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=uuidutils.generate_uuid())
|
||||
container2 = utils.create_test_container(
|
||||
name='container-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
bay_uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=uuidutils.generate_uuid())
|
||||
|
||||
res = self.dbapi.get_container_list(self.context,
|
||||
filters={'name': 'container-one'})
|
||||
|
@ -130,7 +129,7 @@ class DbContainerTestCase(base.DbTestCase):
|
|||
def test_destroy_container_that_does_not_exist(self):
|
||||
self.assertRaises(exception.ContainerNotFound,
|
||||
self.dbapi.destroy_container,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
|
||||
def test_update_container(self):
|
||||
container = utils.create_test_container()
|
||||
|
@ -143,7 +142,7 @@ class DbContainerTestCase(base.DbTestCase):
|
|||
self.assertEqual(new_image, res.image)
|
||||
|
||||
def test_update_container_not_found(self):
|
||||
container_uuid = magnum_utils.generate_uuid()
|
||||
container_uuid = uuidutils.generate_uuid()
|
||||
new_image = 'new-image'
|
||||
self.assertRaises(exception.ContainerNotFound,
|
||||
self.dbapi.update_container,
|
||||
|
|
|
@ -14,11 +14,10 @@
|
|||
# under the License.
|
||||
|
||||
"""Tests for manipulating Pods via the DB API"""
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils as utils
|
||||
|
||||
|
@ -55,7 +54,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
|
||||
def test_get_pod_by_name_multiple_pods(self):
|
||||
utils.create_test_pod(bay_uuid=self.bay.uuid,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
self.assertRaises(exception.Conflict, self.dbapi.get_pod_by_name,
|
||||
self.pod.name)
|
||||
|
||||
|
@ -70,7 +69,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
self.assertRaises(exception.PodNotFound,
|
||||
self.dbapi.get_pod_by_uuid,
|
||||
self.context,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
self.assertRaises(exception.PodNotFound,
|
||||
self.dbapi.get_pod_by_name,
|
||||
'bad-name')
|
||||
|
@ -78,7 +77,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
def test_get_pod_list(self):
|
||||
uuids = [self.pod.uuid]
|
||||
for i in range(1, 6):
|
||||
pod = utils.create_test_pod(uuid=magnum_utils.generate_uuid(),
|
||||
pod = utils.create_test_pod(uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=self.bay.uuid)
|
||||
uuids.append(six.text_type(pod.uuid))
|
||||
res = self.dbapi.get_pod_list(self.context)
|
||||
|
@ -88,7 +87,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
def test_get_pod_list_sorted(self):
|
||||
uuids = [self.pod.uuid]
|
||||
for _ in range(5):
|
||||
pod = utils.create_test_pod(uuid=magnum_utils.generate_uuid())
|
||||
pod = utils.create_test_pod(uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(pod.uuid))
|
||||
res = self.dbapi.get_pod_list(self.context, sort_key='uuid')
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -100,19 +99,19 @@ class DbPodTestCase(base.DbTestCase):
|
|||
sort_key='foo')
|
||||
|
||||
def test_get_pod_list_with_filters(self):
|
||||
bay1 = utils.get_test_bay(id=11, uuid=magnum_utils.generate_uuid())
|
||||
bay2 = utils.get_test_bay(id=12, uuid=magnum_utils.generate_uuid())
|
||||
bay1 = utils.get_test_bay(id=11, uuid=uuidutils.generate_uuid())
|
||||
bay2 = utils.get_test_bay(id=12, uuid=uuidutils.generate_uuid())
|
||||
self.dbapi.create_bay(bay1)
|
||||
self.dbapi.create_bay(bay2)
|
||||
|
||||
pod1 = utils.create_test_pod(
|
||||
name='pod-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=bay1['uuid'],
|
||||
status='status1')
|
||||
pod2 = utils.create_test_pod(
|
||||
name='pod-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=bay2['uuid'],
|
||||
status='status2')
|
||||
|
||||
|
@ -145,7 +144,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
{'bay_uuid': self.bay.uuid})
|
||||
self.assertEqual(1, len(res))
|
||||
res = self.dbapi.get_pod_list(self.context, filters={
|
||||
'bay_uuid': magnum_utils.generate_uuid()})
|
||||
'bay_uuid': uuidutils.generate_uuid()})
|
||||
self.assertEqual(0, len(res))
|
||||
|
||||
def test_destroy_pod(self):
|
||||
|
@ -164,7 +163,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
def test_destroy_pod_that_does_not_exist(self):
|
||||
self.assertRaises(exception.PodNotFound,
|
||||
self.dbapi.destroy_pod,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
|
||||
def test_update_pod(self):
|
||||
old_name = self.pod.name
|
||||
|
@ -174,7 +173,7 @@ class DbPodTestCase(base.DbTestCase):
|
|||
self.assertEqual(new_name, res.name)
|
||||
|
||||
def test_update_pod_not_found(self):
|
||||
pod_uuid = magnum_utils.generate_uuid()
|
||||
pod_uuid = uuidutils.generate_uuid()
|
||||
self.assertRaises(exception.PodNotFound, self.dbapi.update_pod,
|
||||
pod_uuid, {'status': 'Running'})
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
|
||||
"""Tests for manipulating Services via the DB API"""
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils as utils
|
||||
|
||||
|
@ -55,7 +55,7 @@ class DbRCTestCase(base.DbTestCase):
|
|||
|
||||
def test_get_rc_by_name_multiple_rcs(self):
|
||||
utils.create_test_rc(bay_uuid=self.bay.uuid,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
self.assertRaises(exception.Conflict, self.dbapi.get_rc_by_name,
|
||||
self.context, self.rc.name)
|
||||
|
||||
|
@ -70,14 +70,14 @@ class DbRCTestCase(base.DbTestCase):
|
|||
self.assertRaises(exception.ReplicationControllerNotFound,
|
||||
self.dbapi.get_rc_by_uuid,
|
||||
self.context,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
|
||||
def test_get_rc_list(self):
|
||||
uuids = [self.rc.uuid]
|
||||
for i in range(1, 6):
|
||||
rc = utils.create_test_rc(
|
||||
bay_uuid=self.bay.uuid,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(rc.uuid))
|
||||
rc = self.dbapi.get_rc_list(self.context)
|
||||
rc_uuids = [r.uuid for r in rc]
|
||||
|
@ -86,7 +86,7 @@ class DbRCTestCase(base.DbTestCase):
|
|||
def test_get_rc_list_sorted(self):
|
||||
uuids = [self.rc.uuid]
|
||||
for _ in range(5):
|
||||
rc = utils.create_test_rc(uuid=magnum_utils.generate_uuid())
|
||||
rc = utils.create_test_rc(uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(rc.uuid))
|
||||
res = self.dbapi.get_rc_list(self.context, sort_key='uuid')
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -102,7 +102,7 @@ class DbRCTestCase(base.DbTestCase):
|
|||
'bay_uuid': self.bay.uuid})
|
||||
self.assertEqual(1, len(rc))
|
||||
rc = self.dbapi.get_rc_list(self.context, filters={
|
||||
'bay_uuid': magnum_utils.generate_uuid()})
|
||||
'bay_uuid': uuidutils.generate_uuid()})
|
||||
self.assertEqual(0, len(rc))
|
||||
|
||||
def test_destroy_rc(self):
|
||||
|
@ -121,7 +121,7 @@ class DbRCTestCase(base.DbTestCase):
|
|||
def test_destroy_rc_that_does_not_exist(self):
|
||||
self.assertRaises(exception.ReplicationControllerNotFound,
|
||||
self.dbapi.destroy_rc,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
|
||||
def test_update_rc(self):
|
||||
old_name = self.rc.name
|
||||
|
@ -131,7 +131,7 @@ class DbRCTestCase(base.DbTestCase):
|
|||
self.assertEqual(new_name, res.name)
|
||||
|
||||
def test_update_rc_not_found(self):
|
||||
rc_uuid = magnum_utils.generate_uuid()
|
||||
rc_uuid = uuidutils.generate_uuid()
|
||||
self.assertRaises(exception.ReplicationControllerNotFound,
|
||||
self.dbapi.update_rc,
|
||||
rc_uuid, {'replica': 4})
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
|
||||
"""Tests for manipulating Services via the DB API"""
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils as utils
|
||||
|
||||
|
@ -55,7 +55,7 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
|
||||
def test_get_service_by_name_multiple_service(self):
|
||||
utils.create_test_service(bay_uuid=self.bay.uuid,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
self.assertRaises(exception.Conflict, self.dbapi.get_service_by_name,
|
||||
self.context, self.service.name)
|
||||
|
||||
|
@ -70,14 +70,14 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
self.assertRaises(exception.ServiceNotFound,
|
||||
self.dbapi.get_service_by_uuid,
|
||||
self.context,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
|
||||
def test_get_service_list(self):
|
||||
uuids = [self.service.uuid]
|
||||
for i in range(1, 6):
|
||||
service = utils.create_test_service(
|
||||
bay_uuid=self.bay.uuid,
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(service.uuid))
|
||||
res = self.dbapi.get_service_list(self.context)
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -87,7 +87,7 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
uuids = [self.service.uuid]
|
||||
for _ in range(5):
|
||||
service = utils.create_test_service(
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(service.uuid))
|
||||
res = self.dbapi.get_service_list(self.context, sort_key='uuid')
|
||||
res_uuids = [r.uuid for r in res]
|
||||
|
@ -99,19 +99,19 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
sort_key='foo')
|
||||
|
||||
def test_get_service_list_with_filters(self):
|
||||
bay1 = utils.get_test_bay(id=11, uuid=magnum_utils.generate_uuid())
|
||||
bay2 = utils.get_test_bay(id=12, uuid=magnum_utils.generate_uuid())
|
||||
bay1 = utils.get_test_bay(id=11, uuid=uuidutils.generate_uuid())
|
||||
bay2 = utils.get_test_bay(id=12, uuid=uuidutils.generate_uuid())
|
||||
self.dbapi.create_bay(bay1)
|
||||
self.dbapi.create_bay(bay2)
|
||||
|
||||
service1 = utils.create_test_service(
|
||||
name='service-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=bay1['uuid'],
|
||||
ports=[{'port': 8000}])
|
||||
service2 = utils.create_test_service(
|
||||
name='service-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=bay2['uuid'],
|
||||
ports=[{'port': 8001}])
|
||||
|
||||
|
@ -144,7 +144,7 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
'bay_uuid': self.bay.uuid})
|
||||
self.assertEqual(1, len(res))
|
||||
res = self.dbapi.get_service_list(self.context, filters={
|
||||
'bay_uuid': magnum_utils.generate_uuid()})
|
||||
'bay_uuid': uuidutils.generate_uuid()})
|
||||
self.assertEqual(0, len(res))
|
||||
|
||||
def test_destroy_service_by_uuid(self):
|
||||
|
@ -158,7 +158,7 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
def test_destroy_service_that_does_not_exist(self):
|
||||
self.assertRaises(exception.ServiceNotFound,
|
||||
self.dbapi.destroy_service,
|
||||
magnum_utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
|
||||
def test_update_service(self):
|
||||
old_name = self.service.name
|
||||
|
@ -168,7 +168,7 @@ class DbServiceTestCase(base.DbTestCase):
|
|||
self.assertEqual(new_name, res.name)
|
||||
|
||||
def test_update_service_not_found(self):
|
||||
service_uuid = magnum_utils.generate_uuid()
|
||||
service_uuid = uuidutils.generate_uuid()
|
||||
self.assertRaises(exception.ServiceNotFound, self.dbapi.update_service,
|
||||
service_uuid, {'port': 80})
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
"""Tests for manipulating X509KeyPairs via the DB API"""
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from magnum.common import context
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
||||
|
@ -70,25 +70,25 @@ class DbX509KeyPairTestCase(base.DbTestCase):
|
|||
uuids = []
|
||||
for i in range(1, 6):
|
||||
x509keypair = utils.create_test_x509keypair(
|
||||
uuid=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(x509keypair['uuid']))
|
||||
res = self.dbapi.get_x509keypair_list(self.context)
|
||||
res_uuids = [r.uuid for r in res]
|
||||
self.assertEqual(sorted(uuids), sorted(res_uuids))
|
||||
|
||||
def test_get_x509keypair_list_with_filters(self):
|
||||
bay1 = utils.get_test_bay(id=1, uuid=magnum_utils.generate_uuid())
|
||||
bay2 = utils.get_test_bay(id=2, uuid=magnum_utils.generate_uuid())
|
||||
bay1 = utils.get_test_bay(id=1, uuid=uuidutils.generate_uuid())
|
||||
bay2 = utils.get_test_bay(id=2, uuid=uuidutils.generate_uuid())
|
||||
self.dbapi.create_bay(bay1)
|
||||
self.dbapi.create_bay(bay2)
|
||||
|
||||
x509keypair1 = utils.create_test_x509keypair(
|
||||
name='x509keypair-one',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=bay1['uuid'])
|
||||
x509keypair2 = utils.create_test_x509keypair(
|
||||
name='x509keypair-two',
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
bay_uuid=bay2['uuid'])
|
||||
x509keypair3 = utils.create_test_x509keypair(
|
||||
name='x509keypair-three',
|
||||
|
@ -115,9 +115,9 @@ class DbX509KeyPairTestCase(base.DbTestCase):
|
|||
uuids = []
|
||||
for i in range(1, 6):
|
||||
x509keypair = utils.create_test_x509keypair(
|
||||
uuid=magnum_utils.generate_uuid(),
|
||||
project_id=magnum_utils.generate_uuid(),
|
||||
user_id=magnum_utils.generate_uuid())
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
project_id=uuidutils.generate_uuid(),
|
||||
user_id=uuidutils.generate_uuid())
|
||||
uuids.append(six.text_type(x509keypair['uuid']))
|
||||
ctx = context.make_admin_context(all_tenants=True)
|
||||
res = self.dbapi.get_x509keypair_list(ctx)
|
||||
|
@ -128,7 +128,7 @@ class DbX509KeyPairTestCase(base.DbTestCase):
|
|||
utils.create_test_x509keypair()
|
||||
self.assertEqual(1, len(self.dbapi.get_x509keypair_list(self.context)))
|
||||
res = self.dbapi.get_x509keypair_list(self.context, filters={
|
||||
'bay_uuid': magnum_utils.generate_uuid()})
|
||||
'bay_uuid': uuidutils.generate_uuid()})
|
||||
self.assertEqual(0, len(res))
|
||||
|
||||
def test_destroy_x509keypair(self):
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
from testtools.matchers import HasLength
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum import objects
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
@ -171,7 +171,7 @@ class TestBayObject(base.DbTestCase):
|
|||
@mock.patch('magnum.objects.BayModel.get_by_uuid')
|
||||
def test_refresh(self, mock_baymodel_get):
|
||||
uuid = self.fake_bay['uuid']
|
||||
new_uuid = magnum_utils.generate_uuid()
|
||||
new_uuid = uuidutils.generate_uuid()
|
||||
returns = [dict(self.fake_bay, uuid=uuid),
|
||||
dict(self.fake_bay, uuid=new_uuid)]
|
||||
expected = [mock.call(self.context, uuid),
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
from testtools.matchers import HasLength
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum import objects
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
@ -111,7 +111,7 @@ class TestBayModelObject(base.DbTestCase):
|
|||
|
||||
def test_refresh(self):
|
||||
uuid = self.fake_baymodel['uuid']
|
||||
new_uuid = magnum_utils.generate_uuid()
|
||||
new_uuid = uuidutils.generate_uuid()
|
||||
returns = [dict(self.fake_baymodel, uuid=uuid),
|
||||
dict(self.fake_baymodel, uuid=new_uuid)]
|
||||
expected = [mock.call(self.context, uuid),
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
from testtools.matchers import HasLength
|
||||
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum import objects
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
@ -125,7 +125,7 @@ class TestContainerObject(base.DbTestCase):
|
|||
|
||||
def test_refresh(self):
|
||||
uuid = self.fake_container['uuid']
|
||||
new_uuid = magnum_utils.generate_uuid()
|
||||
new_uuid = uuidutils.generate_uuid()
|
||||
returns = [dict(self.fake_container, uuid=uuid),
|
||||
dict(self.fake_container, uuid=new_uuid)]
|
||||
expected = [mock.call(self.context, uuid),
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
from testtools.matchers import HasLength
|
||||
|
||||
from magnum.common import exception
|
||||
from magnum.common import utils as magnum_utils
|
||||
from magnum import objects
|
||||
from magnum.tests.unit.db import base
|
||||
from magnum.tests.unit.db import utils
|
||||
|
@ -148,7 +148,7 @@ class TestX509KeyPairObject(base.DbTestCase):
|
|||
|
||||
def test_refresh(self):
|
||||
uuid = self.fake_x509keypair['uuid']
|
||||
new_uuid = magnum_utils.generate_uuid()
|
||||
new_uuid = uuidutils.generate_uuid()
|
||||
returns = [dict(self.fake_x509keypair, uuid=uuid),
|
||||
dict(self.fake_x509keypair, uuid=new_uuid)]
|
||||
expected = [mock.call(self.context, uuid),
|
||||
|
|
Loading…
Reference in New Issue