Merge "Remove ensure_default_domain_exists"

This commit is contained in:
Zuul 2017-11-04 11:06:30 +00:00 committed by Gerrit Code Review
commit c4b7bcf452
2 changed files with 0 additions and 89 deletions

View File

@ -854,32 +854,6 @@ class Manager(manager.Manager):
def get_project_by_name(self, project_name, domain_id):
return self.driver.get_project_by_name(project_name, domain_id)
def ensure_default_domain_exists(self):
"""Create the default domain if it doesn't exist.
This is only used for the v2 API and can go away when V2 does.
"""
try:
default_domain_attrs = {
'name': 'Default',
'id': CONF.identity.default_domain_id,
'description': 'Domain created automatically to support V2.0 '
'operations.',
}
self.create_domain(CONF.identity.default_domain_id,
default_domain_attrs)
LOG.warning(
'The default domain was created automatically to contain V2 '
'resources. This is deprecated in the M release and will not '
'be supported in the O release. Create the default domain '
'manually or use the keystone-manage bootstrap command.')
except exception.Conflict:
LOG.debug('The default domain already exists.')
except Exception:
LOG.error('Failed to create the default domain.')
raise
def _require_matching_domain_id(self, new_ref, orig_ref):
"""Ensure the current domain ID matches the reference one, if any.

View File

@ -13,7 +13,6 @@
import copy
import uuid
import fixtures
import mock
from oslo_config import cfg
from testtools import matchers
@ -34,68 +33,6 @@ class TestResourceManagerNoFixtures(unit.SQLDriverOverrides, unit.TestCase):
self.useFixture(database.Database())
self.load_backends()
def test_ensure_default_domain_exists(self):
# When there's no default domain, ensure_default_domain_exists creates
# it.
# First make sure there's no default domain.
self.assertRaises(
exception.DomainNotFound,
self.resource_api.get_domain, CONF.identity.default_domain_id)
self.resource_api.ensure_default_domain_exists()
default_domain = self.resource_api.get_domain(
CONF.identity.default_domain_id)
expected_domain = {
'id': CONF.identity.default_domain_id,
'name': 'Default',
'enabled': True,
'description': 'Domain created automatically to support V2.0 '
'operations.',
'tags': []
}
self.assertEqual(expected_domain, default_domain)
def test_ensure_default_domain_exists_already_exists(self):
# When there's already a default domain, ensure_default_domain_exists
# doesn't do anything.
name = uuid.uuid4().hex
description = uuid.uuid4().hex
domain_attrs = {
'id': CONF.identity.default_domain_id,
'name': name,
'description': description,
}
self.resource_api.create_domain(CONF.identity.default_domain_id,
domain_attrs)
self.resource_api.ensure_default_domain_exists()
default_domain = self.resource_api.get_domain(
CONF.identity.default_domain_id)
expected_domain = {
'id': CONF.identity.default_domain_id,
'name': name,
'enabled': True,
'description': description,
'tags': []
}
self.assertEqual(expected_domain, default_domain)
def test_ensure_default_domain_exists_fails(self):
# When there's an unexpected exception creating domain it's passed on.
self.useFixture(fixtures.MockPatchObject(
self.resource_api, 'create_domain',
side_effect=exception.UnexpectedError))
self.assertRaises(exception.UnexpectedError,
self.resource_api.ensure_default_domain_exists)
def test_update_project_name_conflict(self):
name = uuid.uuid4().hex
description = uuid.uuid4().hex