Merge "unconfigured clients look in the [clients] section for defaults"
This commit is contained in:
commit
756035b8e0
@ -131,11 +131,14 @@ class KeystoneClientV2(object):
|
|||||||
return creds
|
return creds
|
||||||
|
|
||||||
def _get_client_option(self, option):
|
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',
|
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||||
group='clients_keystone')
|
group='clients_keystone')
|
||||||
return getattr(cfg.CONF.clients_keystone, option)
|
v = getattr(cfg.CONF.clients_keystone, option)
|
||||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
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')
|
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||||
return getattr(cfg.CONF.clients, option)
|
return getattr(cfg.CONF.clients, option)
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -595,7 +595,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
[clients_cinder]
|
[clients_cinder]
|
||||||
@ -606,7 +606,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -622,7 +622,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -641,7 +641,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -657,7 +657,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
[clients_heat]
|
[clients_heat]
|
||||||
@ -668,7 +668,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -684,7 +684,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -693,7 +693,7 @@
|
|||||||
|
|
||||||
# Optional heat url in format like
|
# Optional heat url in format like
|
||||||
# http://0.0.0.0:8004/v1/%(tenant_id)s. (string value)
|
# http://0.0.0.0:8004/v1/%(tenant_id)s. (string value)
|
||||||
#url=<None>
|
#url=
|
||||||
|
|
||||||
|
|
||||||
[clients_keystone]
|
[clients_keystone]
|
||||||
@ -704,7 +704,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -720,7 +720,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
[clients_neutron]
|
[clients_neutron]
|
||||||
@ -731,7 +731,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -747,7 +747,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
[clients_nova]
|
[clients_nova]
|
||||||
@ -758,7 +758,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -774,7 +774,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -793,7 +793,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -809,7 +809,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
[clients_trove]
|
[clients_trove]
|
||||||
@ -820,7 +820,7 @@
|
|||||||
|
|
||||||
# Type of endpoint in Identity service catalog to use for
|
# Type of endpoint in Identity service catalog to use for
|
||||||
# communication with the OpenStack service. (string value)
|
# communication with the OpenStack service. (string value)
|
||||||
#endpoint_type=publicURL
|
#endpoint_type=<None>
|
||||||
|
|
||||||
# Optional CA cert file to use in SSL connections. (string
|
# Optional CA cert file to use in SSL connections. (string
|
||||||
# value)
|
# value)
|
||||||
@ -836,7 +836,7 @@
|
|||||||
|
|
||||||
# If set, then the server's certificate will not be verified.
|
# If set, then the server's certificate will not be verified.
|
||||||
# (boolean value)
|
# (boolean value)
|
||||||
#insecure=false
|
#insecure=<None>
|
||||||
|
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
|
@ -183,7 +183,9 @@ auth_password_opts = [
|
|||||||
help=_('Allowed keystone endpoints for auth_uri when '
|
help=_('Allowed keystone endpoints for auth_uri when '
|
||||||
'multi_cloud is enabled. At least one endpoint needs '
|
'multi_cloud is enabled. At least one endpoint needs '
|
||||||
'to be specified.'))]
|
'to be specified.'))]
|
||||||
clients_opts = [
|
|
||||||
|
# these options define baseline defaults that apply to all clients
|
||||||
|
default_clients_opts = [
|
||||||
cfg.StrOpt('endpoint_type',
|
cfg.StrOpt('endpoint_type',
|
||||||
default='publicURL',
|
default='publicURL',
|
||||||
help=_(
|
help=_(
|
||||||
@ -201,8 +203,28 @@ clients_opts = [
|
|||||||
help=_("If set, then the server's certificate will not "
|
help=_("If set, then the server's certificate will not "
|
||||||
"be verified."))]
|
"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 = [
|
heat_client_opts = [
|
||||||
cfg.StrOpt('url',
|
cfg.StrOpt('url',
|
||||||
|
default='',
|
||||||
help=_('Optional heat url in format like'
|
help=_('Optional heat url in format like'
|
||||||
' http://0.0.0.0:8004/v1/%(tenant_id)s.'))]
|
' 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 auth_password_group.name, auth_password_opts
|
||||||
yield revision_group.name, revision_opts
|
yield revision_group.name, revision_opts
|
||||||
yield profiler_group.name, profiler_opts
|
yield profiler_group.name, profiler_opts
|
||||||
yield 'clients', clients_opts
|
yield 'clients', default_clients_opts
|
||||||
|
|
||||||
for client in ('nova', 'swift', 'neutron', 'cinder',
|
for client in ('nova', 'swift', 'neutron', 'cinder',
|
||||||
'ceilometer', 'keystone', 'heat', 'glance', 'trove'):
|
'ceilometer', 'keystone', 'heat', 'glance', 'trove'):
|
||||||
|
@ -248,11 +248,14 @@ class KeystoneClientV3(object):
|
|||||||
return opts
|
return opts
|
||||||
|
|
||||||
def _get_client_option(self, option):
|
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',
|
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||||
group='clients_keystone')
|
group='clients_keystone')
|
||||||
return getattr(cfg.CONF.clients_keystone, option)
|
v = getattr(cfg.CONF.clients_keystone, option)
|
||||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
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')
|
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||||
return getattr(cfg.CONF.clients, option)
|
return getattr(cfg.CONF.clients, option)
|
||||||
|
|
||||||
|
@ -50,12 +50,18 @@ class ClientPlugin(object):
|
|||||||
return self.clients.client('keystone').url_for(**kwargs)
|
return self.clients.client('keystone').url_for(**kwargs)
|
||||||
|
|
||||||
def _get_client_option(self, client, option):
|
def _get_client_option(self, client, option):
|
||||||
|
# look for the option in the [clients_${client}] section
|
||||||
|
# unknown options raise cfg.NoSuchOptError
|
||||||
try:
|
try:
|
||||||
group_name = 'clients_' + client
|
group_name = 'clients_' + client
|
||||||
cfg.CONF.import_opt(option, 'heat.common.config',
|
cfg.CONF.import_opt(option, 'heat.common.config',
|
||||||
group=group_name)
|
group=group_name)
|
||||||
return getattr(getattr(cfg.CONF, group_name), option)
|
v = getattr(getattr(cfg.CONF, group_name), option)
|
||||||
except (cfg.NoSuchGroupError, cfg.NoSuchOptError):
|
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')
|
cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
|
||||||
return getattr(cfg.CONF.clients, option)
|
return getattr(cfg.CONF.clients, option)
|
||||||
|
|
||||||
|
@ -146,11 +146,17 @@ class ClientPluginTest(common.HeatTestCase):
|
|||||||
group='clients_heat')
|
group='clients_heat')
|
||||||
cfg.CONF.set_override('ca_file', '/tmp/foo',
|
cfg.CONF.set_override('ca_file', '/tmp/foo',
|
||||||
group='clients')
|
group='clients')
|
||||||
|
cfg.CONF.set_override('endpoint_type', 'internalURL',
|
||||||
|
group='clients')
|
||||||
|
|
||||||
# check heat group
|
# check heat group
|
||||||
self.assertEqual('/tmp/bar',
|
self.assertEqual('/tmp/bar',
|
||||||
plugin._get_client_option('heat', 'ca_file'))
|
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
|
# check fallback clients group for unknown client foo
|
||||||
self.assertEqual('/tmp/foo',
|
self.assertEqual('/tmp/foo',
|
||||||
plugin._get_client_option('foo', 'ca_file'))
|
plugin._get_client_option('foo', 'ca_file'))
|
||||||
|
Loading…
Reference in New Issue
Block a user