From 45ad7723d0e40e7c5475584fc2a5bc0b5ad3ef56 Mon Sep 17 00:00:00 2001 From: Linda Wang Date: Tue, 21 Nov 2017 03:38:49 +0000 Subject: Fix the way of getting endpoint port It will fail if the endpoint does not contain any port value when executing self.os_auth_url.rsplit("/")[2].rsplit(":")[1] JIRA: FUNCTEST-892 Change-Id: Iba4103884b7c6e3b157bb95d775fac02c32ae728 Signed-off-by: Linda Wang --- functest/cli/commands/cli_os.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'functest/cli') diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py index e97ab0809..71cd78c58 100644 --- a/functest/cli/commands/cli_os.py +++ b/functest/cli/commands/cli_os.py @@ -9,6 +9,7 @@ import os +from urlparse import urlparse import click @@ -27,8 +28,8 @@ class OpenStack(object): self.openstack_creds = CONST.__getattribute__('openstack_creds') self.snapshot_file = CONST.__getattribute__('openstack_snapshot_file') if self.os_auth_url: - self.endpoint_ip = self.os_auth_url.rsplit("/")[2].rsplit(":")[0] - self.endpoint_port = self.os_auth_url.rsplit("/")[2].rsplit(":")[1] + self.endpoint_ip = urlparse(self.os_auth_url).hostname + self.endpoint_port = urlparse(self.os_auth_url).port def ping_endpoint(self): if self.os_auth_url is None: -- cgit 1.2.3-korg