Compare commits

...

5 Commits

Author SHA1 Message Date
Itsuro Oda
1b5c1c7821 Add vnflcm v2 APIs
This patch supports CLI of vnflcm v2 APIs which are added in Yoga
release.

They are as follows.
* vnflcm update
* vnflcm scale
* vnflcm heal
* vnflcm change-ext-conn
* vnflcm op fail
* vnflcm op retry
* vnflcm op rollback

They are common with v1 except heal. An optional parameter
'--additional-param-file' is added to heal CLI.

Implements: blueprint support-nfv-solv3-heal-vnf
Implements: blueprint support-nfv-solv3-change-external-connectivity
Implements: blueprint support-nfv-solv3-modify-vnf
Implements: blueprint support-nfv-solv3-scale-vnf
Implements: blueprint support-nfv-solv3-error-handling
Change-Id: If4acd9c4d35ce7a5bf6c23db1a8238654d536c87
2022-03-10 10:54:05 +09:00
Pooja Singla
0151fe1cc6 Help message of heal cli modified
Usage message of all cli commands of tacker is constructed by
argument parser by default. It includes optional parameter
first and insert mandatory parameter at end.

All cli commands are implemented with this design only
except heal cli.

Heal cli is a special case in which optional parameter is
coming at end and mandatory parameter is coming before optional.
To fix this issue usage parameter of argument parser is set
in heal cli.

Closes-Bug: #1954744

Change-Id: I3b1d04df210ad07d4b9a99f300017d49e2b56f0b
2022-03-10 10:54:05 +09:00
Renu
f2d12b19cd Fix in "vnflcm op list" CLI with exclude-fields
"vnflcm op list" with "--exclude-fields" is not
excluding parameters from CLI result.

Closes-Bug: 1953377
Change-Id: If47beccfbab4b85173bbe159905d0605e721cedd
2022-03-10 10:54:05 +09:00
3eb3d5e84c Update TOX_CONSTRAINTS_FILE for stable/yoga
Update the URL to the upper-constraints file to point to the redirect
rule on releases.openstack.org so that anyone working on this branch
will switch to the correct upper-constraints list automatically when
the requirements repository branches.

Until the requirements repository has as stable/yoga branch, tests will
continue to use the upper-constraints list on master.

Change-Id: Iedebb0118e9beda8a5517877bcca90aef007b3a0
2022-03-03 10:50:58 +00:00
e520f8e9f1 Update .gitreview for stable/yoga
Change-Id: I58cb52e376e1af16efe031722030bc6b763b5588
2022-03-03 10:50:57 +00:00
8 changed files with 97 additions and 10 deletions

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
{
"additionalParams": {"all": true}
}

View File

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

View File

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

View File

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

View File

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

View File

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