Merge "Take os_actions_endpoint_type into use"
This commit is contained in:
commit
56a0ef4e33
@ -98,8 +98,8 @@ rpc_response_timeout_opt = cfg.IntOpt(
|
||||
|
||||
os_endpoint_type = cfg.StrOpt(
|
||||
'os-actions-endpoint-type',
|
||||
default=os.environ.get('OS_ACTIONS_ENDPOINT_TYPE', 'publicURL'),
|
||||
choices=['publicURL', 'adminURL', 'internalURL'],
|
||||
default=os.environ.get('OS_ACTIONS_ENDPOINT_TYPE', 'public'),
|
||||
choices=['public', 'admin', 'internal'],
|
||||
help='Type of endpoint in identity service catalog to use for'
|
||||
' communication with OpenStack services.'
|
||||
)
|
||||
|
@ -48,7 +48,7 @@ class OpenStackActionTest(base.BaseTestCase):
|
||||
mock_ks_endpoint_v2):
|
||||
|
||||
# this is the default, but be explicit
|
||||
config.CONF.set_default('os_actions_endpoint_type', 'publicURL')
|
||||
config.CONF.set_default('os_actions_endpoint_type', 'public')
|
||||
|
||||
test_ctx = ctx.MistralContext(
|
||||
user_id=None,
|
||||
@ -62,7 +62,7 @@ class OpenStackActionTest(base.BaseTestCase):
|
||||
ctx.set_ctx(test_ctx)
|
||||
|
||||
# attributes mirror keystone Endpoint object exactly
|
||||
# (with endpoint type publicURL)
|
||||
# (with endpoint type public)
|
||||
keystone_attrs = {
|
||||
'url': 'http://192.0.2.1:5000/v2.0',
|
||||
'enabled': True,
|
||||
@ -107,7 +107,7 @@ class OpenStackActionTest(base.BaseTestCase):
|
||||
2,
|
||||
username=None,
|
||||
api_key=None,
|
||||
endpoint_type='publicURL',
|
||||
endpoint_type='public',
|
||||
service_type='compute',
|
||||
auth_token=test_ctx.auth_token,
|
||||
tenant_id=test_ctx.project_id,
|
||||
@ -138,7 +138,7 @@ class OpenStackActionTest(base.BaseTestCase):
|
||||
2,
|
||||
username=None,
|
||||
api_key=None,
|
||||
endpoint_type='publicURL',
|
||||
endpoint_type='public',
|
||||
service_type='compute',
|
||||
auth_token=test_ctx.auth_token,
|
||||
tenant_id=test_ctx.project_id,
|
||||
|
@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from mistral import config
|
||||
from mistral.tests.unit import base
|
||||
from mistral.utils.openstack import keystone
|
||||
|
||||
@ -29,6 +30,11 @@ SERVICES_CATALOG = [
|
||||
"interface": "public",
|
||||
"url": "https://example.com/nova/public",
|
||||
"region": "RegionOne"
|
||||
},
|
||||
{
|
||||
"interface": "internal",
|
||||
"url": "https://example.com/nova/internal",
|
||||
"region": "RegionOne"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -45,6 +51,11 @@ SERVICES_CATALOG = [
|
||||
"interface": "public",
|
||||
"url": "https://example.com/nova2/public/r2",
|
||||
"region": "RegionTwo"
|
||||
},
|
||||
{
|
||||
"interface": "internal",
|
||||
"url": "https://example.com/nova2/internal",
|
||||
"region": "RegionTwo"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -61,6 +72,11 @@ SERVICES_CATALOG = [
|
||||
"interface": "public",
|
||||
"url": "https://example.com/heat/public",
|
||||
"region": "RegionOne"
|
||||
},
|
||||
{
|
||||
"interface": "internal",
|
||||
"url": "https://example.com/heat/internal",
|
||||
"region": "RegionTwo"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -73,6 +89,10 @@ class KeystoneUtilsTest(base.BaseTest):
|
||||
|
||||
self.values = {'id': 'my_id'}
|
||||
|
||||
def override_config(self, name, override, group=None):
|
||||
config.CONF.set_override(name, override, group)
|
||||
self.addCleanup(config.CONF.clear_override, name, group)
|
||||
|
||||
def test_format_url_dollar_sign(self):
|
||||
url_template = "http://host:port/v1/$(id)s"
|
||||
|
||||
@ -93,7 +113,7 @@ class KeystoneUtilsTest(base.BaseTest):
|
||||
keystone.format_url(url_template, self.values)
|
||||
)
|
||||
|
||||
def test_service_endpoints_select(self):
|
||||
def test_service_endpoints_select_default(self):
|
||||
def find(name, typ=None, catalog=SERVICES_CATALOG):
|
||||
return keystone.select_service_endpoints(name, typ, catalog)
|
||||
|
||||
@ -113,3 +133,22 @@ class KeystoneUtilsTest(base.BaseTest):
|
||||
endpoints = find('nova', None, [])
|
||||
self.assertEqual([], endpoints,
|
||||
message='empty catalog should be accepted')
|
||||
|
||||
def test_service_endpoints_select_internal(self):
|
||||
def find(name, typ=None, catalog=SERVICES_CATALOG):
|
||||
return keystone.select_service_endpoints(name, typ, catalog)
|
||||
|
||||
self.override_config('os_actions_endpoint_type', 'internal')
|
||||
endpoints = find('nova', 'compute')
|
||||
self.assertEqual('https://example.com/nova/internal', endpoints[0].url,
|
||||
message='internal interface must be selected')
|
||||
|
||||
endpoints = find('nova2')
|
||||
self.assertEqual("https://example.com/nova2/internal",
|
||||
endpoints[0].url,
|
||||
message='internal endpoints must be selected '
|
||||
'in each region')
|
||||
|
||||
endpoints = find('heat')
|
||||
self.assertEqual('https://example.com/heat/internal', endpoints[0].url,
|
||||
message='selection should work without type set')
|
||||
|
@ -118,7 +118,9 @@ def select_service_endpoints(service_name, service_type, services):
|
||||
continue
|
||||
|
||||
for endpoint in catalog["endpoints"]:
|
||||
if endpoint["interface"] == 'public':
|
||||
# Keystone v2.0 uses <interface>URL while v3 only uses the
|
||||
# interface without the URL suffix.
|
||||
if CONF.os_actions_endpoint_type in endpoint["interface"]:
|
||||
endpoints.append(enp.Endpoint(None, endpoint, loaded=True))
|
||||
|
||||
return endpoints
|
||||
|
Loading…
x
Reference in New Issue
Block a user