Fix non-working endpoint type argument
Whatever the endpoint type passed with --os-endpoint-type or OS_ENDPOINT_TYPE, the publicURL is always used (instead of, for instance, adminURL or internalURL). This patch passes the user-defined endpoint type to keystoneclient's get_endpoint() so that the correct endpoint is chosen from the catalog. Change-Id: Iee9f0e576d5fba3b4bf1dd267dfee233b0a7ea8f Closes-Bug: #1422487
This commit is contained in:
parent
99cfcb16ff
commit
4cda08d91c
|
@ -612,6 +612,7 @@ class HeatShell(object):
|
|||
keystone_session = self._get_keystone_session(**kwargs)
|
||||
project_id = args.os_project_id or args.os_tenant_id
|
||||
project_name = args.os_project_name or args.os_tenant_name
|
||||
endpoint_type = args.os_endpoint_type or 'publicURL'
|
||||
kwargs = {
|
||||
'username': args.os_username,
|
||||
'user_id': args.os_user_id,
|
||||
|
@ -632,9 +633,8 @@ class HeatShell(object):
|
|||
region_name = args.os_region_name
|
||||
endpoint = keystone_auth.get_endpoint(keystone_session,
|
||||
service_type=svc_type,
|
||||
interface=endpoint_type,
|
||||
region_name=region_name)
|
||||
|
||||
endpoint_type = args.os_endpoint_type or 'publicURL'
|
||||
kwargs = {
|
||||
'auth_url': args.os_auth_url,
|
||||
'session': keystone_session,
|
||||
|
|
|
@ -39,6 +39,7 @@ from heatclient.common import utils
|
|||
from heatclient import exc
|
||||
import heatclient.shell
|
||||
from heatclient.tests import fakes
|
||||
import heatclient.v1.shell
|
||||
|
||||
load_tests = testscenarios.load_tests_apply_scenarios
|
||||
TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
|
@ -123,13 +124,18 @@ class TestCase(testtools.TestCase):
|
|||
def register_keystone_v2_token_fixture(self):
|
||||
v2_token = keystone_fixture.V2Token(token_id=self.tokenid)
|
||||
service = v2_token.add_service('orchestration')
|
||||
service.add_endpoint('http://heat.example.com', region='RegionOne')
|
||||
service.add_endpoint('http://heat.example.com',
|
||||
admin='http://heat-admin.localdomain',
|
||||
internal='http://heat.localdomain',
|
||||
region='RegionOne')
|
||||
self.requests.post('%s/tokens' % V2_URL, json=v2_token)
|
||||
|
||||
def register_keystone_v3_token_fixture(self):
|
||||
v3_token = keystone_fixture.V3Token()
|
||||
service = v3_token.add_service('orchestration')
|
||||
service.add_standard_endpoints(public='http://heat.example.com')
|
||||
service.add_standard_endpoints(public='http://heat.example.com',
|
||||
admin='http://heat-admin.localdomain',
|
||||
internal='http://heat.localdomain')
|
||||
self.requests.post('%s/auth/tokens' % V3_URL,
|
||||
json=v3_token,
|
||||
headers={'X-Subject-Token': self.tokenid})
|
||||
|
@ -425,6 +431,77 @@ class ShellTestNoMoxV3(ShellTestNoMox):
|
|||
self.set_fake_env(FAKE_ENV_KEYSTONE_V3)
|
||||
|
||||
|
||||
class ShellTestEndpointType(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ShellTestEndpointType, self).setUp()
|
||||
self.m = mox.Mox()
|
||||
self.m.StubOutWithMock(http, '_construct_http_client')
|
||||
self.m.StubOutWithMock(heatclient.v1.shell, 'do_stack_list')
|
||||
self.addCleanup(self.m.VerifyAll)
|
||||
self.addCleanup(self.m.UnsetStubs)
|
||||
self.set_fake_env(FAKE_ENV_KEYSTONE_V2)
|
||||
|
||||
def test_endpoint_type_public_url(self):
|
||||
self.register_keystone_auth_fixture()
|
||||
kwargs = {
|
||||
'auth_url': 'http://keystone.example.com:5000/',
|
||||
'session': mox.IgnoreArg(),
|
||||
'auth': mox.IgnoreArg(),
|
||||
'service_type': 'orchestration',
|
||||
'endpoint_type': 'publicURL',
|
||||
'region_name': '',
|
||||
'username': 'username',
|
||||
'password': 'password',
|
||||
'include_pass': False
|
||||
}
|
||||
http._construct_http_client(u'http://heat.example.com', **kwargs)
|
||||
heatclient.v1.shell.do_stack_list(mox.IgnoreArg(), mox.IgnoreArg())
|
||||
|
||||
self.m.ReplayAll()
|
||||
heatclient.shell.main(('stack-list',))
|
||||
|
||||
def test_endpoint_type_admin_url(self):
|
||||
self.register_keystone_auth_fixture()
|
||||
kwargs = {
|
||||
'auth_url': 'http://keystone.example.com:5000/',
|
||||
'session': mox.IgnoreArg(),
|
||||
'auth': mox.IgnoreArg(),
|
||||
'service_type': 'orchestration',
|
||||
'endpoint_type': 'adminURL',
|
||||
'region_name': '',
|
||||
'username': 'username',
|
||||
'password': 'password',
|
||||
'include_pass': False
|
||||
}
|
||||
http._construct_http_client(u'http://heat-admin.localdomain', **kwargs)
|
||||
heatclient.v1.shell.do_stack_list(mox.IgnoreArg(), mox.IgnoreArg())
|
||||
|
||||
self.m.ReplayAll()
|
||||
heatclient.shell.main(('--os-endpoint-type=adminURL', 'stack-list',))
|
||||
|
||||
def test_endpoint_type_internal_url(self):
|
||||
self.register_keystone_auth_fixture()
|
||||
self.useFixture(fixtures.EnvironmentVariable('OS_ENDPOINT_TYPE',
|
||||
'internalURL'))
|
||||
kwargs = {
|
||||
'auth_url': 'http://keystone.example.com:5000/',
|
||||
'session': mox.IgnoreArg(),
|
||||
'auth': mox.IgnoreArg(),
|
||||
'service_type': 'orchestration',
|
||||
'endpoint_type': 'internalURL',
|
||||
'region_name': '',
|
||||
'username': 'username',
|
||||
'password': 'password',
|
||||
'include_pass': False
|
||||
}
|
||||
http._construct_http_client(u'http://heat.localdomain', **kwargs)
|
||||
heatclient.v1.shell.do_stack_list(mox.IgnoreArg(), mox.IgnoreArg())
|
||||
|
||||
self.m.ReplayAll()
|
||||
heatclient.shell.main(('stack-list',))
|
||||
|
||||
|
||||
class ShellTestCommon(ShellBase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue