Compare commits
5 Commits
2023.1-eom
...
yoga-eom
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b5c1c7821 | ||
|
|
0151fe1cc6 | ||
|
|
f2d12b19cd | ||
| 3eb3d5e84c | |||
| e520f8e9f1 |
@@ -2,3 +2,4 @@
|
||||
host=review.opendev.org
|
||||
port=29418
|
||||
project=openstack/python-tackerclient.git
|
||||
defaultbranch=stable/yoga
|
||||
|
||||
@@ -112,6 +112,13 @@ openstack.tackerclient.v2 =
|
||||
vnflcm_terminate = tackerclient.osc.v1.vnflcm.vnflcm:TerminateVnfLcm
|
||||
vnflcm_change-vnfpkg = tackerclient.osc.v1.vnflcm.vnflcm:ChangeVnfPkgVnfLcm
|
||||
vnflcm_delete = tackerclient.osc.v1.vnflcm.vnflcm:DeleteVnfLcm
|
||||
vnflcm_heal = tackerclient.osc.v1.vnflcm.vnflcm:HealVnfLcm
|
||||
vnflcm_update = tackerclient.osc.v1.vnflcm.vnflcm:UpdateVnfLcm
|
||||
vnflcm_scale = tackerclient.osc.v1.vnflcm.vnflcm:ScaleVnfLcm
|
||||
vnflcm_change-ext-conn = tackerclient.osc.v1.vnflcm.vnflcm:ChangeExtConnVnfLcm
|
||||
vnflcm_op_rollback = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:RollbackVnfLcmOp
|
||||
vnflcm_op_fail = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:FailVnfLcmOp
|
||||
vnflcm_op_retry = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:RetryVnfLcmOp
|
||||
vnflcm_op_list = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:ListVnfLcmOp
|
||||
vnflcm_op_show = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:ShowVnfLcmOp
|
||||
vnflcm_versions = tackerclient.osc.common.vnflcm.vnflcm_versions:VnfLcmVersions
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"additionalParams": {"all": true}
|
||||
}
|
||||
@@ -238,6 +238,12 @@ class HealVnfLcm(command.Command):
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(HealVnfLcm, self).get_parser(prog_name)
|
||||
usage_message = ('''%(prog)s [-h] [--cause CAUSE]
|
||||
[--vnfc-instance <vnfc-instance-id> '''
|
||||
'''[<vnfc-instance-id> ...]]
|
||||
[--additional-param-file <additional-param-file>]
|
||||
-- <vnf-instance>''')
|
||||
parser.usage = usage_message
|
||||
parser.add_argument(
|
||||
_VNF_INSTANCE,
|
||||
metavar="<vnf-instance>",
|
||||
@@ -251,6 +257,11 @@ class HealVnfLcm(command.Command):
|
||||
nargs="+",
|
||||
help=_("List of VNFC instances requiring a healing action.")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--additional-param-file',
|
||||
metavar="<additional-param-file>",
|
||||
help=_("Additional parameters passed by the NFVO as input "
|
||||
"to the healing process."))
|
||||
return parser
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
@@ -259,6 +270,8 @@ class HealVnfLcm(command.Command):
|
||||
body['cause'] = parsed_args.cause
|
||||
if parsed_args.vnfc_instance:
|
||||
body['vnfcInstanceId'] = parsed_args.vnfc_instance
|
||||
if parsed_args.additional_param_file:
|
||||
body.update(jsonfile2body(parsed_args.additional_param_file))
|
||||
|
||||
return body
|
||||
|
||||
|
||||
@@ -242,9 +242,12 @@ class ListVnfLcmOp(command.Lister):
|
||||
)
|
||||
return parser
|
||||
|
||||
def get_attributes(self):
|
||||
def get_attributes(self, exclude=None):
|
||||
"""Get attributes.
|
||||
|
||||
Args:
|
||||
exclude([exclude]): a list of fields which needs to exclude.
|
||||
|
||||
Returns:
|
||||
attributes([attributes]): a list of table entry definitions.
|
||||
Each entry should be a tuple consisting of
|
||||
@@ -270,10 +273,13 @@ class ListVnfLcmOp(command.Lister):
|
||||
]
|
||||
|
||||
attributes = []
|
||||
for field in fields:
|
||||
attributes.extend([(field['key'], field['value'],
|
||||
tacker_osc_utils.LIST_BOTH)])
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
|
||||
for field in fields:
|
||||
if field['value'] not in exclude:
|
||||
attributes.extend([(field['key'], field['value'],
|
||||
tacker_osc_utils.LIST_BOTH)])
|
||||
return tuple(attributes)
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@@ -301,7 +307,7 @@ class ListVnfLcmOp(command.Lister):
|
||||
client = self.app.client_manager.tackerclient
|
||||
vnflcm_op_occs = client.list_vnf_lcm_op_occs(**params)
|
||||
headers, columns = tacker_osc_utils.get_column_definitions(
|
||||
self.get_attributes(),
|
||||
self.get_attributes(exclude=exclude_fields),
|
||||
long_listing=True)
|
||||
|
||||
dictionary_properties = (utils.get_dict_properties(
|
||||
|
||||
@@ -288,6 +288,9 @@ class TestHealVnfLcm(TestVnfLcm):
|
||||
self.heal_vnf_lcm = vnflcm.HealVnfLcm(
|
||||
self.app, self.app_args, cmd_name='vnflcm heal')
|
||||
|
||||
_heal_sample_param_file = ("./tackerclient/osc/v1/vnflcm/samples/"
|
||||
"heal_vnf_instance_param_sample.json")
|
||||
|
||||
@ddt.data((['--cause', 'test-cause', "--vnfc-instance",
|
||||
'vnfc-id-1', 'vnfc-id-2'],
|
||||
[('cause', 'test-cause'),
|
||||
@@ -296,6 +299,8 @@ class TestHealVnfLcm(TestVnfLcm):
|
||||
[('cause', 'test-cause')]),
|
||||
(["--vnfc-instance", 'vnfc-id-1', 'vnfc-id-2'],
|
||||
[('vnfc_instance', ['vnfc-id-1', 'vnfc-id-2'])]),
|
||||
(["--additional-param-file", _heal_sample_param_file],
|
||||
[('additional_param_file', _heal_sample_param_file)]),
|
||||
([], []))
|
||||
@ddt.unpack
|
||||
def test_take_action(self, arglist, verifylist):
|
||||
@@ -340,6 +345,25 @@ class TestHealVnfLcm(TestVnfLcm):
|
||||
self.heal_vnf_lcm.take_action,
|
||||
parsed_args)
|
||||
|
||||
def test_take_action_param_file_not_exists(self):
|
||||
vnf_instance = vnflcm_fakes.vnf_instance_response()
|
||||
sample_param_file = "./not_exists.json"
|
||||
arglist = [vnf_instance['id'],
|
||||
'--additional-param-file', sample_param_file]
|
||||
verifylist = [('vnf_instance', vnf_instance['id']),
|
||||
('additional_param_file', sample_param_file)]
|
||||
|
||||
# command param
|
||||
parsed_args = self.check_parser(self.heal_vnf_lcm, arglist,
|
||||
verifylist)
|
||||
|
||||
ex = self.assertRaises(exceptions.InvalidInput,
|
||||
self.heal_vnf_lcm.take_action, parsed_args)
|
||||
|
||||
expected_msg = ("Invalid input: File %s does not exist "
|
||||
"or user does not have read privileges to it")
|
||||
self.assertEqual(expected_msg % sample_param_file, str(ex))
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestTerminateVnfLcm(TestVnfLcm):
|
||||
|
||||
@@ -26,7 +26,7 @@ from tackerclient.tests.unit.osc.v1.fixture_data import client
|
||||
from tackerclient.tests.unit.osc.v1 import vnflcm_op_occs_fakes
|
||||
|
||||
|
||||
def _get_columns_vnflcm_op_occs(action='show'):
|
||||
def _get_columns_vnflcm_op_occs(action='show', parameter=None):
|
||||
|
||||
if action == 'fail':
|
||||
return ['ID', 'Operation State', 'State Entered Time',
|
||||
@@ -34,8 +34,11 @@ def _get_columns_vnflcm_op_occs(action="/?originalUrl=https%3A%2F%2Fgit.openstack.org%2F%26%2339%3Bshow%26%2339%3B)%3A%253C%2Fcode">
|
||||
'Is Automatic Invocation', 'Is Cancel Pending',
|
||||
'Error', 'Links']
|
||||
elif action == 'list':
|
||||
return ['ID', 'Operation State', 'VNF Instance ID',
|
||||
'Operation']
|
||||
if parameter is not None:
|
||||
return ['ID', 'Operation']
|
||||
else:
|
||||
return ['ID', 'Operation State', 'VNF Instance ID',
|
||||
'Operation']
|
||||
else:
|
||||
return ['ID', 'Operation State', 'State Entered Time',
|
||||
'Start Time', 'VNF Instance ID', 'Grant ID',
|
||||
@@ -496,6 +499,36 @@ class TestListVnfLcmOp(TestVnfLcm):
|
||||
self.list_vnflcm_op_occ.take_action,
|
||||
parsed_args)
|
||||
|
||||
def test_take_action_with_exclude_fields(self):
|
||||
|
||||
vnflcm_op_occs_obj = vnflcm_op_occs_fakes.create_vnflcm_op_occs(
|
||||
count=3)
|
||||
parsed_args = self.check_parser(
|
||||
self.list_vnflcm_op_occ,
|
||||
["--exclude-fields", 'VNF Instance ID,Operation State'],
|
||||
[('exclude_fields', 'VNF Instance ID,Operation State')])
|
||||
self.requests_mock.register_uri(
|
||||
'GET', os.path.join(
|
||||
self.url,
|
||||
'vnflcm/v1/vnf_lcm_op_occs?'
|
||||
'exclude-fields=VNF Instance ID,Operation State'),
|
||||
json=vnflcm_op_occs_obj, headers=self.header)
|
||||
actual_columns, data = self.list_vnflcm_op_occ.take_action(parsed_args)
|
||||
headers, columns = tacker_osc_utils.get_column_definitions(
|
||||
self.list_vnflcm_op_occ.get_attributes(
|
||||
exclude=['VNF Instance ID', 'Operation State']),
|
||||
long_listing=True)
|
||||
expected_data = []
|
||||
for vnflcm_op_occ_obj_idx in vnflcm_op_occs_obj:
|
||||
expected_data.append(
|
||||
vnflcm_op_occs_fakes.get_vnflcm_op_occ_data(
|
||||
vnflcm_op_occ_obj_idx, columns=columns))
|
||||
|
||||
self.assertCountEqual(_get_columns_vnflcm_op_occs(
|
||||
action='list', parameter="exclude_fields"),
|
||||
actual_columns)
|
||||
self.assertListItemsEqual(expected_data, list(data))
|
||||
|
||||
|
||||
class TestShowVnfLcmOp(TestVnfLcm):
|
||||
|
||||
|
||||
4
tox.ini
4
tox.ini
@@ -12,7 +12,7 @@ setenv = VIRTUAL_ENV={envdir}
|
||||
LC_ALL=C
|
||||
usedevelop = True
|
||||
deps =
|
||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/yoga}
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = stestr run --slowest {posargs}
|
||||
@@ -30,7 +30,7 @@ commands = sphinx-build -W -b html doc/source doc/build/html
|
||||
|
||||
[testenv:releasenotes]
|
||||
deps =
|
||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/yoga}
|
||||
-r{toxinidir}/doc/requirements.txt
|
||||
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||
|
||||
|
||||
Reference in New Issue
Block a user