]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add option for nova endpoint type
authorJeremy McDermond <mcdermj@xenotropic.com>
Tue, 8 Dec 2015 18:14:09 +0000 (10:14 -0800)
committerJeremy McDermond <mcdermj@xenotropic.com>
Thu, 10 Dec 2015 08:40:36 +0000 (08:40 +0000)
When the neutron notification to nova was updated to use novaclient the
nova_url parameter was disabled.  This prevents administrators from
using anything but the publicURL as the proper endpoint to notify nova.
This patch adds an option to pass on to novaclient for the
endpoint_type so that the administrator can set the notification url to
public, internal or admin.

Change-Id: I405f761944449cab6b8c8895f98419f79cd74cad
Closes-Bug: #1478471
DocImpact: Need to add a new option to the neutron configuration
reference.

neutron/common/config.py
neutron/notifiers/nova.py
neutron/tests/unit/notifiers/test_nova.py

index 3fcc4c4c112efc15b59075e47f02519f388103eb..be57a2b34f291e7e9f5305711dc071005d4e42b5 100644 (file)
@@ -204,6 +204,12 @@ nova_opts = [
     cfg.StrOpt('region_name',
                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)
 
index 2f9cfabb2ccf6e296fdfe64f2fe6fe4eefe2f4b2..9abe6bcc90d3b56d90fbe5fff35ce58b8fce4295 100644 (file)
@@ -60,6 +60,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)
index 6fd8e3f7fd7a7765a7a115b3bf41bdd42281402e..2481a59d847bec0ef37ecc4dda3f7a2743ccb31d 100644 (file)
@@ -309,3 +309,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)