unconfigured clients look in the [clients] section for defaults
This change enables clients that have no specific settings in the [clients_xxx] sections of the configuration file to get defaults from the [clients] section. Change-Id: I071bd77a2e1f0ad366b80c095917a8debc5cef2b Closes-Bug: 1379958
This commit is contained in:
parent
5725b0e8b1
commit
4fd5087499
@ -131,11 +131,14 @@ class KeystoneClientV2(object):
|
||||
return creds
|
||||
|
||||
def _get_client_option(self, option):
|
||||
try:
|
||||
# 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')
|
||||
return getattr(cfg.CONF.clients_keystone, option)
|
||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
||||
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)
|
||||
|
||||
|
@ -585,7 +585,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)
|
||||
@ -601,7 +601,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_cinder]
|
||||
@ -612,7 +612,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)
|
||||
@ -628,7 +628,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
#
|
||||
@ -647,7 +647,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)
|
||||
@ -663,7 +663,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_heat]
|
||||
@ -674,7 +674,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)
|
||||
@ -690,7 +690,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
#
|
||||
@ -699,7 +699,7 @@
|
||||
|
||||
# Optional heat url in format like
|
||||
# http://0.0.0.0:8004/v1/%(tenant_id)s. (string value)
|
||||
#url=<None>
|
||||
#url=
|
||||
|
||||
|
||||
[clients_keystone]
|
||||
@ -710,7 +710,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)
|
||||
@ -726,7 +726,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_neutron]
|
||||
@ -737,7 +737,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)
|
||||
@ -753,7 +753,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_nova]
|
||||
@ -764,7 +764,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)
|
||||
@ -780,7 +780,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
#
|
||||
@ -799,7 +799,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)
|
||||
@ -815,7 +815,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[clients_trove]
|
||||
@ -826,7 +826,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)
|
||||
@ -842,7 +842,7 @@
|
||||
|
||||
# If set, then the server's certificate will not be verified.
|
||||
# (boolean value)
|
||||
#insecure=false
|
||||
#insecure=<None>
|
||||
|
||||
|
||||
[database]
|
||||
|
@ -174,7 +174,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=_(
|
||||
@ -192,8 +194,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.'))]
|
||||
|
||||
@ -220,7 +242,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,11 +248,14 @@ class KeystoneClientV3(object):
|
||||
return opts
|
||||
|
||||
def _get_client_option(self, option):
|
||||
try:
|
||||
# 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')
|
||||
return getattr(cfg.CONF.clients_keystone, option)
|
||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
||||
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)
|
||||
|
||||
|
@ -50,12 +50,18 @@ 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):
|
||||
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)
|
||||
|
||||
|
@ -145,11 +145,17 @@ class ClientPluginTest(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