Compare commits

...

3 Commits

Author SHA1 Message Date
gong yong sheng
258aa70e3b 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
(cherry picked from commit 3b60ab1aaa)
2017-01-20 22:56:21 +00:00
OpenStack Proposal Bot
a3c4723161 Updated from global requirements
Change-Id: Iee4f4946386d1eec4ead9a59c017e8e60d159537
2016-09-20 13:16:36 +00:00
Doug Hellmann
22c72c1c0a Update .gitreview for stable/newton
Change-Id: Ica1c231811ee7b8a57897a2d267ebf43b10e2fa9
2016-09-02 09:44:46 -04:00
6 changed files with 31 additions and 13 deletions

View File

@@ -2,3 +2,4 @@
host=review.openstack.org
port=29418
project=openstack/python-tackerclient.git
defaultbranch=stable/newton

View File

@@ -4,7 +4,7 @@
pbr>=1.6 # Apache-2.0
cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0
iso8601>=0.1.11 # MIT
netaddr!=0.7.16,>=0.7.12 # BSD
netaddr!=0.7.16,>=0.7.13 # BSD
requests>=2.10.0 # Apache-2.0
python-keystoneclient!=2.1.0,>=2.0.0 # Apache-2.0
simplejson>=2.2.0 # MIT

View File

@@ -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))

View File

@@ -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],

View File

@@ -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

View File

@@ -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)