Move stack_user_domain warning to startup
Add a startup_warnings() function in place to add other warnings there if at all possible. Change-Id: I4d8d02feccc42c2f3486f52bad488922eb08bbca Closes-bug: 1434286
This commit is contained in:
parent
9e2280d9fe
commit
a47639c4a4
@ -36,6 +36,7 @@ from oslo_config import cfg
|
|||||||
import oslo_i18n as i18n
|
import oslo_i18n as i18n
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
from heat.common import config
|
||||||
from heat.common.i18n import _LC
|
from heat.common.i18n import _LC
|
||||||
from heat.common import messaging
|
from heat.common import messaging
|
||||||
from heat.common import profiler
|
from heat.common import profiler
|
||||||
@ -54,6 +55,8 @@ if __name__ == '__main__':
|
|||||||
logging.set_defaults()
|
logging.set_defaults()
|
||||||
messaging.setup()
|
messaging.setup()
|
||||||
|
|
||||||
|
config.startup_sanity_check()
|
||||||
|
|
||||||
mgr = None
|
mgr = None
|
||||||
try:
|
try:
|
||||||
mgr = template._get_template_extension_manager()
|
mgr = template._get_template_extension_manager()
|
||||||
|
@ -21,9 +21,13 @@ from eventlet.green import socket
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
from heat.common.i18n import _LW
|
||||||
from heat.common import wsgi
|
from heat.common import wsgi
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
paste_deploy_group = cfg.OptGroup('paste_deploy')
|
paste_deploy_group = cfg.OptGroup('paste_deploy')
|
||||||
paste_deploy_opts = [
|
paste_deploy_opts = [
|
||||||
cfg.StrOpt('flavor',
|
cfg.StrOpt('flavor',
|
||||||
@ -277,6 +281,24 @@ revision_opts = [
|
|||||||
'file and add it as another config option.'))]
|
'file and add it as another config option.'))]
|
||||||
|
|
||||||
|
|
||||||
|
def startup_sanity_check():
|
||||||
|
if (not cfg.CONF.stack_user_domain_id and
|
||||||
|
not cfg.CONF.stack_user_domain_name):
|
||||||
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
|
# files which lack domain configuration
|
||||||
|
LOG.warn(_LW('stack_user_domain_id or stack_user_domain_name not '
|
||||||
|
'set in heat.conf falling back to using default'))
|
||||||
|
else:
|
||||||
|
domain_admin_user = cfg.CONF.stack_domain_admin
|
||||||
|
domain_admin_password = cfg.CONF.stack_domain_admin_password
|
||||||
|
if not (domain_admin_user and domain_admin_password):
|
||||||
|
raise exception.Error(_('heat.conf misconfigured, cannot '
|
||||||
|
'specify "stack_user_domain_id" or '
|
||||||
|
'"stack_user_domain_name" without '
|
||||||
|
'"stack_domain_admin" and '
|
||||||
|
'"stack_domain_admin_password"'))
|
||||||
|
|
||||||
|
|
||||||
def list_opts():
|
def list_opts():
|
||||||
yield None, rpc_opts
|
yield None, rpc_opts
|
||||||
yield None, engine_opts
|
yield None, engine_opts
|
||||||
|
@ -102,16 +102,6 @@ class KeystoneClientV3(object):
|
|||||||
self._stack_domain_is_id = False
|
self._stack_domain_is_id = False
|
||||||
self.domain_admin_user = cfg.CONF.stack_domain_admin
|
self.domain_admin_user = cfg.CONF.stack_domain_admin
|
||||||
self.domain_admin_password = cfg.CONF.stack_domain_admin_password
|
self.domain_admin_password = cfg.CONF.stack_domain_admin_password
|
||||||
if self.stack_domain:
|
|
||||||
if not (self.domain_admin_user and self.domain_admin_password):
|
|
||||||
raise exception.Error(_('heat.conf misconfigured, cannot '
|
|
||||||
'specify "stack_user_domain_id" or '
|
|
||||||
'"stack_user_domain_name" without '
|
|
||||||
'"stack_domain_admin" and '
|
|
||||||
'"stack_domain_admin_password"'))
|
|
||||||
else:
|
|
||||||
LOG.warn(_LW('stack_user_domain_id or stack_user_domain_name not '
|
|
||||||
'set in heat.conf falling back to using default'))
|
|
||||||
LOG.debug('Using stack domain %s' % self.stack_domain)
|
LOG.debug('Using stack domain %s' % self.stack_domain)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -360,8 +350,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain user create, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return self.create_stack_user(username=username, password=password)
|
return self.create_stack_user(username=username, password=password)
|
||||||
# We add the new user to a special keystone role
|
# We add the new user to a special keystone role
|
||||||
# This role is designed to allow easier differentiation of the
|
# This role is designed to allow easier differentiation of the
|
||||||
@ -413,8 +401,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain user delete, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return self.delete_stack_user(user_id)
|
return self.delete_stack_user(user_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -434,8 +420,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain project, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return self.context.tenant_id
|
return self.context.tenant_id
|
||||||
# Note we use the tenant ID not name to ensure uniqueness in a multi-
|
# Note we use the tenant ID not name to ensure uniqueness in a multi-
|
||||||
# domain environment (where the tenant name may not be globally unique)
|
# domain environment (where the tenant name may not be globally unique)
|
||||||
@ -451,8 +435,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain project, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# If stacks are created before configuring the heat domain, they
|
# If stacks are created before configuring the heat domain, they
|
||||||
@ -544,8 +526,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain keypair, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return self.create_ec2_keypair(user_id)
|
return self.create_ec2_keypair(user_id)
|
||||||
data_blob = {'access': uuid.uuid4().hex,
|
data_blob = {'access': uuid.uuid4().hex,
|
||||||
'secret': uuid.uuid4().hex}
|
'secret': uuid.uuid4().hex}
|
||||||
@ -561,8 +541,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain keypair, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return self.delete_ec2_keypair(credential_id=credential_id)
|
return self.delete_ec2_keypair(credential_id=credential_id)
|
||||||
self._check_stack_domain_user(user_id, project_id, 'delete_keypair')
|
self._check_stack_domain_user(user_id, project_id, 'delete_keypair')
|
||||||
try:
|
try:
|
||||||
@ -580,8 +558,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain disable, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return self.disable_stack_user(user_id)
|
return self.disable_stack_user(user_id)
|
||||||
self._check_stack_domain_user(user_id, project_id, 'disable')
|
self._check_stack_domain_user(user_id, project_id, 'disable')
|
||||||
self.domain_admin_client.users.update(user=user_id, enabled=False)
|
self.domain_admin_client.users.update(user=user_id, enabled=False)
|
||||||
@ -590,8 +566,6 @@ class KeystoneClientV3(object):
|
|||||||
if not self.stack_domain:
|
if not self.stack_domain:
|
||||||
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
# FIXME(shardy): Legacy fallback for folks using old heat.conf
|
||||||
# files which lack domain configuration
|
# files which lack domain configuration
|
||||||
LOG.warn(_LW('Falling back to legacy non-domain enable, '
|
|
||||||
'configure domain in heat.conf'))
|
|
||||||
return self.enable_stack_user(user_id)
|
return self.enable_stack_user(user_id)
|
||||||
self._check_stack_domain_user(user_id, project_id, 'enable')
|
self._check_stack_domain_user(user_id, project_id, 'enable')
|
||||||
self.domain_admin_client.users.update(user=user_id, enabled=True)
|
self.domain_admin_client.users.update(user=user_id, enabled=True)
|
||||||
|
@ -25,6 +25,7 @@ import mox
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
from heat.common import config
|
||||||
from heat.common import context
|
from heat.common import context
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common import heat_keystoneclient
|
from heat.common import heat_keystoneclient
|
||||||
@ -574,7 +575,6 @@ class KeystoneClientTest(common.HeatTestCase):
|
|||||||
self.assertIn(expected, six.text_type(exc))
|
self.assertIn(expected, six.text_type(exc))
|
||||||
|
|
||||||
def test_init_domain_cfg_not_set_fallback(self):
|
def test_init_domain_cfg_not_set_fallback(self):
|
||||||
|
|
||||||
"""Test error path when config lacks domain config."""
|
"""Test error path when config lacks domain config."""
|
||||||
|
|
||||||
self._clear_domain_override()
|
self._clear_domain_override()
|
||||||
@ -594,12 +594,8 @@ class KeystoneClientTest(common.HeatTestCase):
|
|||||||
cfg.CONF.clear_override('stack_domain_admin')
|
cfg.CONF.clear_override('stack_domain_admin')
|
||||||
cfg.CONF.clear_override('stack_domain_admin_password')
|
cfg.CONF.clear_override('stack_domain_admin_password')
|
||||||
|
|
||||||
ctx = utils.dummy_context()
|
|
||||||
ctx.username = None
|
|
||||||
ctx.password = None
|
|
||||||
ctx.trust_id = None
|
|
||||||
err = self.assertRaises(exception.Error,
|
err = self.assertRaises(exception.Error,
|
||||||
heat_keystoneclient.KeystoneClient, ctx)
|
config.startup_sanity_check)
|
||||||
exp_msg = ('heat.conf misconfigured, cannot specify '
|
exp_msg = ('heat.conf misconfigured, cannot specify '
|
||||||
'"stack_user_domain_id" or "stack_user_domain_name" '
|
'"stack_user_domain_id" or "stack_user_domain_name" '
|
||||||
'without "stack_domain_admin" and '
|
'without "stack_domain_admin" and '
|
||||||
|
Loading…
Reference in New Issue
Block a user