Support keystone regions
This change enables keystone region support by defining the option 'region_name' in 'heat_client' section: * magnum searchs only in region_name region for heat endpoint when region_name is not None, * otherwise magnum search in all regions. DocImpact Closes-Bug: #1437049 Change-Id: Ib2895e7b56e48d6dfa8fe4680e12fc897d5cef03
This commit is contained in:
@@ -486,6 +486,10 @@
|
|||||||
# From magnum
|
# From magnum
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Region in Identity service catalog to use for
|
||||||
|
# communication with the OpenStack service. (string value)
|
||||||
|
#region_name = None
|
||||||
|
|
||||||
# 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 = publicURL
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
heat_client_opts = [
|
heat_client_opts = [
|
||||||
|
cfg.StrOpt('region_name',
|
||||||
|
default=None,
|
||||||
|
help=_('Region in Identity service catalog to use for '
|
||||||
|
'communication with the OpenStack service.')),
|
||||||
cfg.StrOpt('endpoint_type',
|
cfg.StrOpt('endpoint_type',
|
||||||
default='publicURL',
|
default='publicURL',
|
||||||
help=_(
|
help=_(
|
||||||
@@ -80,8 +84,10 @@ class OpenStackClients(object):
|
|||||||
return self._heat
|
return self._heat
|
||||||
|
|
||||||
endpoint_type = self._get_client_option('heat', 'endpoint_type')
|
endpoint_type = self._get_client_option('heat', 'endpoint_type')
|
||||||
|
region_name = self._get_client_option('heat', 'region_name')
|
||||||
endpoint = self.url_for(service_type='orchestration',
|
endpoint = self.url_for(service_type='orchestration',
|
||||||
endpoint_type=endpoint_type)
|
endpoint_type=endpoint_type,
|
||||||
|
region_name=region_name)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'endpoint': endpoint,
|
'endpoint': endpoint,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
from heatclient.v1 import client as heatclient
|
from heatclient.v1 import client as heatclient
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
from magnum.common import clients
|
from magnum.common import clients
|
||||||
from magnum.common import exception
|
from magnum.common import exception
|
||||||
@@ -32,7 +33,8 @@ class ClientsTest(base.BaseTestCase):
|
|||||||
@mock.patch.object(heatclient, 'Client')
|
@mock.patch.object(heatclient, 'Client')
|
||||||
@mock.patch.object(clients.OpenStackClients, 'url_for')
|
@mock.patch.object(clients.OpenStackClients, 'url_for')
|
||||||
@mock.patch.object(clients.OpenStackClients, 'auth_url')
|
@mock.patch.object(clients.OpenStackClients, 'auth_url')
|
||||||
def test_clients_heat(self, mock_auth, mock_url, mock_call):
|
def _test_clients_heat(self, expected_region_name, mock_auth, mock_url,
|
||||||
|
mock_call):
|
||||||
mock_auth.__get__ = mock.Mock(return_value="keystone_url")
|
mock_auth.__get__ = mock.Mock(return_value="keystone_url")
|
||||||
con = mock.MagicMock()
|
con = mock.MagicMock()
|
||||||
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
|
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
|
||||||
@@ -47,7 +49,15 @@ class ClientsTest(base.BaseTestCase):
|
|||||||
auth_url='keystone_url', ca_file=None, key_file=None,
|
auth_url='keystone_url', ca_file=None, key_file=None,
|
||||||
password=None, insecure=False)
|
password=None, insecure=False)
|
||||||
mock_url.assert_called_once_with(service_type='orchestration',
|
mock_url.assert_called_once_with(service_type='orchestration',
|
||||||
endpoint_type='publicURL')
|
endpoint_type='publicURL',
|
||||||
|
region_name=expected_region_name)
|
||||||
|
|
||||||
|
def test_clients_heat(self):
|
||||||
|
self._test_clients_heat(None)
|
||||||
|
|
||||||
|
def test_clients_heat_region(self):
|
||||||
|
cfg.CONF.set_override('region_name', 'myregion', group='heat_client')
|
||||||
|
self._test_clients_heat('myregion')
|
||||||
|
|
||||||
def test_clients_heat_noauth(self):
|
def test_clients_heat_noauth(self):
|
||||||
con = mock.MagicMock()
|
con = mock.MagicMock()
|
||||||
|
|||||||
Reference in New Issue
Block a user