Merge "unconfigured clients look in the [clients] section for defaults"
This commit is contained in:
commit
756035b8e0
@ -131,13 +131,16 @@ class KeystoneClientV2(object):
|
||||
return creds
|
||||
|
||||
def _get_client_option(self, option):
|
||||
try:
|
||||
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||
group='clients_keystone')
|
||||
return getattr(cfg.CONF.clients_keystone, option)
|
||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
||||
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||
return getattr(cfg.CONF.clients, option)
|
||||
# look for the option in the [clients_keystone] section
|
||||
# unknown options raise cfg.NoSuchOptError
|
||||
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||
group='clients_keystone')
|
||||
v = getattr(cfg.CONF.clients_keystone, option)
|
||||
if v is not None:
|
||||
return v
|
||||
# look for the option in the generic [clients] section
|
||||
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||
return getattr(cfg.CONF.clients, option)
|
||||
|
||||
def create_stack_user(self, username, password=''):
|
||||
"""
|
||||
|
@ -579,7 +579,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -595,7 +595,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_cinder]
|
||||
@ -606,7 +606,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -622,7 +622,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
#
|
||||
@ -641,7 +641,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -657,7 +657,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_heat]
|
||||
@ -668,7 +668,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -684,7 +684,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
#
|
||||
@ -693,7 +693,7 @@
|
||||
|
||||
# Optional heat url in format like
|
||||
# http://0.0.0.0:8004/v1/%(tenant_id)s. (string value)
|
||||
#url=<None>
|
||||
#url=
|
||||
|
||||
|
||||
[clients_keystone]
|
||||
@ -704,7 +704,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -720,7 +720,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_neutron]
|
||||
@ -731,7 +731,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -747,7 +747,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_nova]
|
||||
@ -758,7 +758,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -774,7 +774,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
#
|
||||
@ -793,7 +793,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -809,7 +809,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_trove]
|
||||
@ -820,7 +820,7 @@
|
||||
|
||||
# Type of endpoint in Identity service catalog to use for
|
||||
# communication with the OpenStack service. (string value)
|
||||
#endpoint_type=publicURL
|
||||
#endpoint_type=<None>
|
||||
|
||||
# Optional CA cert file to use in SSL connections. (string
|
||||
# value)
|
||||
@ -836,7 +836,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[database]
|
||||
|
@ -183,7 +183,9 @@ auth_password_opts = [
|
||||
help=_('Allowed keystone endpoints for auth_uri when '
|
||||
'multi_cloud is enabled. At least one endpoint needs '
|
||||
'to be specified.'))]
|
||||
clients_opts = [
|
||||
|
||||
# these options define baseline defaults that apply to all clients
|
||||
default_clients_opts = [
|
||||
cfg.StrOpt('endpoint_type',
|
||||
default='publicURL',
|
||||
help=_(
|
||||
@ -201,8 +203,28 @@ clients_opts = [
|
||||
help=_("If set, then the server's certificate will not "
|
||||
"be verified."))]
|
||||
|
||||
# these options can be defined for each client
|
||||
# they must not specify defaults, since any options not defined in a client
|
||||
# specific group is looked up on the generic group above
|
||||
clients_opts = [
|
||||
cfg.StrOpt('endpoint_type',
|
||||
help=_(
|
||||
'Type of endpoint in Identity service catalog to use '
|
||||
'for communication with the OpenStack service.')),
|
||||
cfg.StrOpt('ca_file',
|
||||
help=_('Optional CA cert file to use in SSL connections.')),
|
||||
cfg.StrOpt('cert_file',
|
||||
help=_('Optional PEM-formatted certificate chain file.')),
|
||||
cfg.StrOpt('key_file',
|
||||
help=_('Optional PEM-formatted file that contains the '
|
||||
'private key.')),
|
||||
cfg.BoolOpt('insecure',
|
||||
help=_("If set, then the server's certificate will not "
|
||||
"be verified."))]
|
||||
|
||||
heat_client_opts = [
|
||||
cfg.StrOpt('url',
|
||||
default='',
|
||||
help=_('Optional heat url in format like'
|
||||
' http://0.0.0.0:8004/v1/%(tenant_id)s.'))]
|
||||
|
||||
@ -229,7 +251,7 @@ def list_opts():
|
||||
yield auth_password_group.name, auth_password_opts
|
||||
yield revision_group.name, revision_opts
|
||||
yield profiler_group.name, profiler_opts
|
||||
yield 'clients', clients_opts
|
||||
yield 'clients', default_clients_opts
|
||||
|
||||
for client in ('nova', 'swift', 'neutron', 'cinder',
|
||||
'ceilometer', 'keystone', 'heat', 'glance', 'trove'):
|
||||
|
@ -248,13 +248,16 @@ class KeystoneClientV3(object):
|
||||
return opts
|
||||
|
||||
def _get_client_option(self, option):
|
||||
try:
|
||||
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||
group='clients_keystone')
|
||||
return getattr(cfg.CONF.clients_keystone, option)
|
||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
||||
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||
return getattr(cfg.CONF.clients, option)
|
||||
# look for the option in the [clients_keystone] section
|
||||
# unknown options raise cfg.NoSuchOptError
|
||||
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||
group='clients_keystone')
|
||||
v = getattr(cfg.CONF.clients_keystone, option)
|
||||
if v is not None:
|
||||
return v
|
||||
# look for the option in the generic [clients] section
|
||||
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||
return getattr(cfg.CONF.clients, option)
|
||||
|
||||
def create_trust_context(self):
|
||||
"""Create a trust using the trustor identity in the current context.
|
||||
|
@ -50,14 +50,20 @@ class ClientPlugin(object):
|
||||
return self.clients.client('keystone').url_for(**kwargs)
|
||||
|
||||
def _get_client_option(self, client, option):
|
||||
# look for the option in the [clients_${client}] section
|
||||
# unknown options raise cfg.NoSuchOptError
|
||||
try:
|
||||
group_name = 'clients_' + client
|
||||
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||
group=group_name)
|
||||
return getattr(getattr(cfg.CONF, group_name), option)
|
||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
||||
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||
return getattr(cfg.CONF.clients, option)
|
||||
v = getattr(getattr(cfg.CONF, group_name), option)
|
||||
if v is not None:
|
||||
return v
|
||||
except cfg.NoSuchGroupError:
|
||||
pass # do not error if the client is unknown
|
||||
# look for the option in the generic [clients] section
|
||||
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||
return getattr(cfg.CONF.clients, option)
|
||||
|
||||
def is_client_exception(self, ex):
|
||||
'''Returns True if the current exception comes from the client.'''
|
||||
|
@ -146,11 +146,17 @@ class ClientPluginTest(common.HeatTestCase):
|
||||
group='clients_heat')
|
||||
cfg.CONF.set_override('ca_file', '/tmp/foo',
|
||||
group='clients')
|
||||
cfg.CONF.set_override('endpoint_type', 'internalURL',
|
||||
group='clients')
|
||||
|
||||
# check heat group
|
||||
self.assertEqual('/tmp/bar',
|
||||
plugin._get_client_option('heat', 'ca_file'))
|
||||
|
||||
# check fallback clients group for known client
|
||||
self.assertEqual('internalURL',
|
||||
plugin._get_client_option('glance', 'endpoint_type'))
|
||||
|
||||
# check fallback clients group for unknown client foo
|
||||
self.assertEqual('/tmp/foo',
|
||||
plugin._get_client_option('foo', 'ca_file'))
|
||||
|
Loading…
Reference in New Issue
Block a user