Merge "Add option for nova endpoint type" into stable/liberty
This commit is contained in:
commit
b80fa23ac0
|
@ -785,6 +785,10 @@ admin_password = %SERVICE_PASSWORD%
|
|||
# PEM encoded client certificate cert file
|
||||
# certfile =
|
||||
|
||||
# Type of the nova endpoint to use. This endpoint will be looked up in the
|
||||
# keystone catalog and should be one of public, internal or admin.
|
||||
# endpoint_type = public
|
||||
|
||||
# Verify HTTPS connections.
|
||||
# insecure = False
|
||||
|
||||
|
|
|
@ -184,6 +184,12 @@ nova_opts = [
|
|||
deprecated_group='DEFAULT',
|
||||
help=_('Name of nova region to use. Useful if keystone manages'
|
||||
' more than one region.')),
|
||||
cfg.StrOpt('endpoint_type',
|
||||
default='public',
|
||||
choices=['public', 'admin', 'internal'],
|
||||
help=_('Type of the nova endpoint to use. This endpoint will'
|
||||
' be looked up in the keystone catalog and should be'
|
||||
' one of public, internal or admin.')),
|
||||
]
|
||||
cfg.CONF.register_opts(nova_opts, group=NOVA_CONF_SECTION)
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ class Notifier(object):
|
|||
NOVA_API_VERSION,
|
||||
session=session,
|
||||
region_name=cfg.CONF.nova.region_name,
|
||||
endpoint_type=cfg.CONF.nova.endpoint_type,
|
||||
extensions=extensions)
|
||||
self.batch_notifier = batch_notifier.BatchNotifier(
|
||||
cfg.CONF.send_events_interval, self.send_events)
|
||||
|
|
|
@ -305,3 +305,23 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
event = self.nova_notifier.create_port_changed_event('delete_port',
|
||||
{}, returned_obj)
|
||||
self.assertEqual(expected_event, event)
|
||||
|
||||
@mock.patch('novaclient.client.Client')
|
||||
def test_endpoint_types(self, mock_client):
|
||||
nova.Notifier()
|
||||
mock_client.assert_called_once_with(
|
||||
nova.NOVA_API_VERSION,
|
||||
session=mock.ANY,
|
||||
region_name=cfg.CONF.nova.region_name,
|
||||
endpoint_type='public',
|
||||
extensions=mock.ANY)
|
||||
|
||||
mock_client.reset_mock()
|
||||
cfg.CONF.set_override('endpoint_type', 'internal', 'nova')
|
||||
nova.Notifier()
|
||||
mock_client.assert_called_once_with(
|
||||
nova.NOVA_API_VERSION,
|
||||
session=mock.ANY,
|
||||
region_name=cfg.CONF.nova.region_name,
|
||||
endpoint_type='internal',
|
||||
extensions=mock.ANY)
|
||||
|
|
Loading…
Reference in New Issue