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:
Cedric Brandily 2015-03-26 22:28:39 +01:00
parent 95e14f6fb9
commit 679e31c1de
3 changed files with 23 additions and 3 deletions

View File

@ -486,6 +486,10 @@
# 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
# communication with the OpenStack service. (string value)
#endpoint_type = publicURL

View File

@ -25,6 +25,10 @@ LOG = logging.getLogger(__name__)
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',
default='publicURL',
help=_(
@ -80,8 +84,10 @@ class OpenStackClients(object):
return self._heat
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_type=endpoint_type)
endpoint_type=endpoint_type,
region_name=region_name)
args = {
'endpoint': endpoint,

View File

@ -12,6 +12,7 @@
from heatclient.v1 import client as heatclient
import mock
from oslo_config import cfg
from magnum.common import clients
from magnum.common import exception
@ -32,7 +33,8 @@ class ClientsTest(base.BaseTestCase):
@mock.patch.object(heatclient, 'Client')
@mock.patch.object(clients.OpenStackClients, 'url_for')
@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")
con = mock.MagicMock()
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
@ -47,7 +49,15 @@ class ClientsTest(base.BaseTestCase):
auth_url='keystone_url', ca_file=None, key_file=None,
password=None, insecure=False)
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):
con = mock.MagicMock()