Allow auth url without port for vim registration
This patch allows vim-register command to register keystone URL without port. Change-Id: Ie04a0253aa3f42ef532ccf8a7bddbbd1f88e3e34 Closes-bug: 1618756
This commit is contained in:
parent
48d458d290
commit
3b60ab1aaa
tackerclient
@ -25,7 +25,6 @@ from oslo_log import versionutils
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
from tackerclient.i18n import _
|
||||
@ -175,13 +174,6 @@ def add_boolean_argument(parser, name, **kwargs):
|
||||
**kwargs)
|
||||
|
||||
|
||||
def validate_url(url):
|
||||
url_parts = urlparse.urlparse(url)
|
||||
if not url_parts.scheme or not url_parts.netloc or not url_parts.port:
|
||||
raise exceptions.TackerClientException(message='Invalid URL')
|
||||
return url_parts
|
||||
|
||||
|
||||
def get_file_path(filename):
|
||||
file_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'../%s' % filename))
|
||||
|
@ -17,7 +17,6 @@
|
||||
import yaml
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
from tackerclient.common import utils
|
||||
from tackerclient.tacker import v1_0 as tackerV10
|
||||
from tackerclient.tacker.v1_0.nfvo import vim_utils
|
||||
|
||||
@ -73,7 +72,7 @@ class CreateVIM(tackerV10.CreateCommand):
|
||||
raise exceptions.TackerClientException(message='Auth URL must be '
|
||||
'specified',
|
||||
status_code=404)
|
||||
vim_obj['auth_url'] = utils.validate_url(auth_url).geturl()
|
||||
vim_obj['auth_url'] = vim_utils.validate_auth_url(auth_url).geturl()
|
||||
vim_obj['type'] = config_param.pop('type', 'openstack')
|
||||
vim_utils.args2body_vim(config_param, vim_obj)
|
||||
tackerV10.update_dict(parsed_args, body[self.resource],
|
||||
|
@ -13,7 +13,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
|
||||
@ -37,3 +37,10 @@ def args2body_vim(config_param, vim):
|
||||
'user_id': config_param.pop('user_id', ''),
|
||||
'user_domain_name':
|
||||
config_param.pop('user_domain_name', '')}
|
||||
|
||||
|
||||
def validate_auth_url(url):
|
||||
url_parts = urlparse.urlparse(url)
|
||||
if not url_parts.scheme or not url_parts.netloc:
|
||||
raise exceptions.TackerClientException(message='Invalid auth URL')
|
||||
return url_parts
|
||||
|
@ -21,7 +21,7 @@ from tackerclient.common import exceptions
|
||||
from tackerclient.tacker.v1_0.nfvo import vim_utils
|
||||
|
||||
|
||||
class CLITestAuthNoAuth(testtools.TestCase):
|
||||
class TestVIMUtils(testtools.TestCase):
|
||||
|
||||
def test_args2body_vim(self):
|
||||
config_param = {'project_id': sentinel.prj_id1,
|
||||
@ -50,3 +50,22 @@ class CLITestAuthNoAuth(testtools.TestCase):
|
||||
self.assertRaises(exceptions.TackerClientException,
|
||||
vim_utils.args2body_vim,
|
||||
config_param, vim)
|
||||
|
||||
def test_validate_auth_url_with_port(self):
|
||||
auth_url = "http://localhost:8000/test"
|
||||
url_parts = vim_utils.validate_auth_url(auth_url)
|
||||
self.assertEqual('http', url_parts.scheme)
|
||||
self.assertEqual('localhost:8000', url_parts.netloc)
|
||||
self.assertEqual(8000, url_parts.port)
|
||||
|
||||
def test_validate_auth_url_without_port(self):
|
||||
auth_url = "http://localhost/test"
|
||||
url_parts = vim_utils.validate_auth_url(auth_url)
|
||||
self.assertEqual('http', url_parts.scheme)
|
||||
self.assertEqual('localhost', url_parts.netloc)
|
||||
|
||||
def test_validate_auth_url_exception(self):
|
||||
auth_url = "localhost/test"
|
||||
self.assertRaises(exceptions.TackerClientException,
|
||||
vim_utils.validate_auth_url,
|
||||
auth_url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user