Compare commits
11 Commits
stable/202
...
mitaka-eol
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8bb518893 | ||
|
|
56e3f5f5bb | ||
|
|
aa5d500024 | ||
|
|
c0f8feca4b | ||
|
|
1bccdcb084 | ||
|
|
84fb385cd2 | ||
|
|
240b8d434c | ||
|
|
3af84f735f | ||
|
|
cb3607784d | ||
|
|
91b9345f33 | ||
|
|
ea5212cb2a |
@@ -2,3 +2,4 @@
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=openstack/python-tackerclient.git
|
||||
defaultbranch=stable/mitaka
|
||||
|
||||
@@ -6,10 +6,10 @@ cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0
|
||||
iso8601>=0.1.9 # MIT
|
||||
netaddr!=0.7.16,>=0.7.12 # BSD
|
||||
requests!=2.9.0,>=2.8.1 # Apache-2.0
|
||||
python-keystoneclient!=1.8.0,!=2.1.0,>=1.6.0 # Apache-2.0
|
||||
python-keystoneclient!=1.8.0,!=2.1.0,<3.0.0,>=1.6.0 # Apache-2.0
|
||||
simplejson>=2.2.0 # MIT
|
||||
six>=1.9.0 # MIT
|
||||
Babel>=1.3 # BSD
|
||||
Babel!=2.3.0,!=2.3.1,!=2.3.2,!=2.3.3,>=1.3 # BSD
|
||||
|
||||
oslo.i18n>=2.1.0 # Apache-2.0
|
||||
oslo.utils>=3.5.0 # Apache-2.0
|
||||
oslo.i18n>=2.1.0 # Apache-2.0
|
||||
oslo.utils>=3.5.0 # Apache-2.0
|
||||
|
||||
@@ -148,12 +148,6 @@ class OverQuotaClient(Conflict):
|
||||
pass
|
||||
|
||||
|
||||
# TODO(amotoki): It is unused in Tacker, but it is referred to
|
||||
# in Horizon code. After Horizon code is updated, remove it.
|
||||
class AlreadyAttachedClient(Conflict):
|
||||
pass
|
||||
|
||||
|
||||
class IpAddressGenerationFailureClient(Conflict):
|
||||
pass
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ from cliff.formatters import table
|
||||
from cliff import lister
|
||||
from cliff import show
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
|
||||
from tackerclient.common._i18n import _
|
||||
@@ -385,6 +386,8 @@ class TackerCommand(command.OpenStackCommand):
|
||||
def format_output_data(self, data):
|
||||
# Modify data to make it more readable
|
||||
if self.resource in data:
|
||||
data[self.resource] = strutils.mask_dict_password(
|
||||
data[self.resource])
|
||||
for k, v in data[self.resource].iteritems():
|
||||
if isinstance(v, list):
|
||||
value = '\n'.join(jsonutils.dumps(
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import strutils
|
||||
import yaml
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
@@ -28,10 +29,13 @@ class ListVIM(tackerV10.ListCommand):
|
||||
"""List VIMs that belong to a given tenant."""
|
||||
|
||||
resource = _VIM
|
||||
|
||||
list_columns = ['id', 'tenant_id', 'name', 'type', 'description',
|
||||
'auth_url', 'placement_attr', 'auth_cred']
|
||||
|
||||
def extend_list(self, data, parsed_args):
|
||||
for index, value in enumerate(data):
|
||||
data[index] = strutils.mask_dict_password(value)
|
||||
|
||||
|
||||
class ShowVIM(tackerV10.ShowCommand):
|
||||
"""Show information of a given VIM."""
|
||||
|
||||
@@ -25,11 +25,15 @@ def args2body_vim(config_param, vim):
|
||||
:return: vim body with args populated
|
||||
"""
|
||||
vim['vim_project'] = {'id': config_param.pop('project_id', ''),
|
||||
'name': config_param.pop('project_name', '')}
|
||||
'name': config_param.pop('project_name', ''),
|
||||
'project_domain_name':
|
||||
config_param.pop('project_domain_name', '')}
|
||||
if not vim['vim_project']['id'] and not vim['vim_project']['name']:
|
||||
raise exceptions.TackerClientException(message='Project Id or name '
|
||||
'must be specified',
|
||||
status_code=404)
|
||||
vim['auth_cred'] = {'username': config_param.pop('username', ''),
|
||||
'password': config_param.pop('password', ''),
|
||||
'user_id': config_param.pop('user_id', '')}
|
||||
'user_id': config_param.pop('user_id', ''),
|
||||
'user_domain_name':
|
||||
config_param.pop('user_domain_name', '')}
|
||||
|
||||
@@ -69,7 +69,7 @@ class CreateVNF(tackerV10.CreateCommand):
|
||||
help='specify config yaml file')
|
||||
parser.add_argument(
|
||||
'--config',
|
||||
help='specify config yaml file')
|
||||
help='specify config yaml data')
|
||||
parser.add_argument(
|
||||
'--param-file',
|
||||
help='specify parameter yaml file'
|
||||
@@ -125,7 +125,7 @@ class UpdateVNF(tackerV10.UpdateCommand):
|
||||
help='specify config yaml file')
|
||||
parser.add_argument(
|
||||
'--config',
|
||||
help='specify config yaml file')
|
||||
help='specify config yaml data')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}}
|
||||
|
||||
0
tackerclient/tests/unit/nfvo/__init__.py
Normal file
0
tackerclient/tests/unit/nfvo/__init__.py
Normal file
52
tackerclient/tests/unit/nfvo/test_vim_utils.py
Normal file
52
tackerclient/tests/unit/nfvo/test_vim_utils.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# Copyright 2016 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from mock import sentinel
|
||||
import testtools
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
from tackerclient.tacker.v1_0.nfvo import vim_utils
|
||||
|
||||
|
||||
class CLITestAuthNoAuth(testtools.TestCase):
|
||||
|
||||
def test_args2body_vim(self):
|
||||
config_param = {'project_id': sentinel.prj_id1,
|
||||
'username': sentinel.usrname1,
|
||||
'password': sentinel.password1,
|
||||
'project_domain_name': sentinel.prj_domain_name1,
|
||||
'user_domain_name': sentinel.user_domain.name, }
|
||||
vim = {}
|
||||
auth_cred = config_param.copy()
|
||||
auth_cred.pop('project_id')
|
||||
auth_cred.pop('project_domain_name')
|
||||
auth_cred.update({'user_id': ''})
|
||||
expected_vim = {'auth_cred': auth_cred,
|
||||
'vim_project':
|
||||
{'id': sentinel.prj_id1,
|
||||
'name': '',
|
||||
'project_domain_name': sentinel.prj_domain_name1}}
|
||||
vim_utils.args2body_vim(config_param.copy(), vim)
|
||||
self.assertEqual(expected_vim, vim)
|
||||
|
||||
def test_args2body_vim_no_project(self):
|
||||
config_param = {'username': sentinel.usrname1,
|
||||
'password': sentinel.password1,
|
||||
'user_domain_name': sentinel.user_domain.name, }
|
||||
vim = {}
|
||||
self.assertRaises(exceptions.TackerClientException,
|
||||
vim_utils.args2body_vim,
|
||||
config_param, vim)
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
import sys
|
||||
|
||||
import mox
|
||||
|
||||
from tackerclient.tacker.v1_0.nfvo import vim
|
||||
from tackerclient.tests.unit import test_cli10
|
||||
|
||||
@@ -32,9 +34,11 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
|
||||
def setUp(self):
|
||||
plurals = {'vims': 'vim'}
|
||||
super(CLITestV10VIMJSON, self).setUp(plurals=plurals)
|
||||
self.vim_project = {'name': 'abc', 'id': ''}
|
||||
self.vim_project = {
|
||||
'name': 'abc', 'id': '',
|
||||
'project_domain_name': 'prj_domain_name'}
|
||||
self.auth_cred = {'username': 'xyz', 'password': '12345', 'user_id':
|
||||
''}
|
||||
'', 'user_domain_name': 'user_domain_name'}
|
||||
self.auth_url = 'http://1.2.3.4:5000'
|
||||
|
||||
def test_register_vim_all_params(self):
|
||||
@@ -43,7 +47,9 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
|
||||
name = 'test_vim'
|
||||
description = 'Vim Description'
|
||||
vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz',
|
||||
'password': '12345', 'project_name': 'abc'}
|
||||
'password': '12345', 'project_name': 'abc',
|
||||
'project_domain_name': 'prj_domain_name',
|
||||
'user_domain_name': 'user_domain_name'}
|
||||
args = [
|
||||
'--config', str(vim_config),
|
||||
'--name', name,
|
||||
@@ -61,7 +67,9 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
|
||||
my_id = 'my-id'
|
||||
|
||||
vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz',
|
||||
'password': '12345', 'project_name': 'abc'}
|
||||
'password': '12345', 'project_name': 'abc',
|
||||
'project_domain_name': 'prj_domain_name',
|
||||
'user_domain_name': 'user_domain_name'}
|
||||
args = [
|
||||
'--config', str(vim_config),
|
||||
]
|
||||
@@ -76,6 +84,39 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
|
||||
cmd = vim.ListVIM(test_cli10.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
||||
|
||||
def _test_list_vims_extend(self, data, expected_data, args=['-f', 'json']):
|
||||
resp_str = self.client.serialize({self._RESOURCES: data})
|
||||
resp = (test_cli10.MyResp(200), resp_str)
|
||||
cmd = vim.ListVIM(
|
||||
test_cli10.MyApp(sys.stdout), None)
|
||||
self.mox.StubOutWithMock(cmd, "get_client")
|
||||
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
||||
|
||||
cmd.get_client().MultipleTimes().AndReturn(self.client)
|
||||
path = getattr(self.client, self._RESOURCES + '_path')
|
||||
self.client.httpclient.request(test_cli10.MyUrlComparator(
|
||||
test_cli10.end_url(path, format=self.format), self.client),
|
||||
'GET', body=None, headers=mox.ContainsKeyValue(
|
||||
'X-Auth-Token', test_cli10.TOKEN)).AndReturn(resp)
|
||||
self.mox.ReplayAll()
|
||||
cmd_parser = cmd.get_parser("list_" + self._RESOURCES)
|
||||
parsed_args = cmd_parser.parse_args(args)
|
||||
result = cmd.take_action(parsed_args)
|
||||
res_data = [res for res in result[1]]
|
||||
self.mox.VerifyAll()
|
||||
self.mox.UnsetStubs()
|
||||
for res, exp in zip(res_data, expected_data):
|
||||
self.assertEqual(len(exp), len(res))
|
||||
self.assertEqual(exp, res)
|
||||
|
||||
def test_list_vims_extend(self):
|
||||
vim_data = [{'id': 'my_id1', 'auth_cred': {'password':
|
||||
'encrypted_pw'}}, {'id': 'my_id2', 'auth_cred': {
|
||||
'password': 'another_encrypted_pw'}}]
|
||||
expected_data = [('my_id1', {'password': '***'}),
|
||||
('my_id2', {'password': '***'})]
|
||||
self._test_list_vims_extend(vim_data, expected_data)
|
||||
|
||||
def test_show_vim_id(self):
|
||||
cmd = vim.ShowVIM(test_cli10.MyApp(sys.stdout), None)
|
||||
args = ['--fields', 'id', self.test_id]
|
||||
@@ -91,7 +132,9 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
|
||||
def test_update_vim(self):
|
||||
cmd = vim.UpdateVIM(test_cli10.MyApp(sys.stdout), None)
|
||||
update_config = {'username': 'xyz', 'password': '12345',
|
||||
'project_name': 'abc'}
|
||||
'project_name': 'abc',
|
||||
'project_domain_name': 'prj_domain_name',
|
||||
'user_domain_name': 'user_domain_name'}
|
||||
my_id = 'my-id'
|
||||
key = 'config'
|
||||
value = str(update_config)
|
||||
|
||||
@@ -5,7 +5,7 @@ hacking<0.11,>=0.10.2
|
||||
cliff-tablib>=1.0 # Apache-2.0
|
||||
coverage>=3.6 # Apache-2.0
|
||||
discover # BSD
|
||||
fixtures>=1.3.1 # Apache-2.0/BSD
|
||||
fixtures<2.0,>=1.3.1 # Apache-2.0/BSD
|
||||
mox>=0.5.3 # Apache-2.0
|
||||
flake8<2.6.0,>2.4.1 # MIT
|
||||
pep8==1.5.7 # MIT
|
||||
|
||||
Reference in New Issue
Block a user