CLI for Individual VNF LCM Operation Occurrence
Add ``openstack vnflcm op show <vnf-lcm-op-occ-id>`` to python-tackerclient. This command can execute the get Individual VNF LCM Operation Occurrence by specifying vnf-lcm-op-occ-id as parameter. Implements: blueprint support-fundamental-lcm https://specs.openstack.org/openstack/tacker-specs/specs/wallaby/support-fundamental-vnf-lcm-based-on-ETSI-NFV.html Change-Id: Ibd24a2aa3ec90fbca4caabbcfb3c8a3883e4eae8
This commit is contained in:
parent
6b29bb78b1
commit
4e6dc4c031
|
@ -99,3 +99,4 @@ openstack.tackerclient.v1 =
|
||||||
vnflcm_op_fail = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:FailVnfLcmOp
|
vnflcm_op_fail = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:FailVnfLcmOp
|
||||||
vnflcm_op_retry = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:RetryVnfLcmOp
|
vnflcm_op_retry = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:RetryVnfLcmOp
|
||||||
vnflcm_op_list = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:ListVnfLcmOp
|
vnflcm_op_list = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:ListVnfLcmOp
|
||||||
|
vnflcm_op_show = tackerclient.osc.v1.vnflcm.vnflcm_op_occs:ShowVnfLcmOp
|
||||||
|
|
|
@ -24,11 +24,25 @@ _MIXED_CASE_FIELDS = ['operationState', 'stateEnteredTime', 'startTime',
|
||||||
'resourceChanges', 'changedInfo',
|
'resourceChanges', 'changedInfo',
|
||||||
'changedExtConnectivity']
|
'changedExtConnectivity']
|
||||||
|
|
||||||
_FORMATTERS = {'error': tacker_osc_utils.FormatComplexDataColumn,
|
_FORMATTERS = {
|
||||||
'_links': tacker_osc_utils.FormatComplexDataColumn}
|
'operationParams': tacker_osc_utils.FormatComplexDataColumn,
|
||||||
|
'error': tacker_osc_utils.FormatComplexDataColumn,
|
||||||
|
'resourceChanges': tacker_osc_utils.FormatComplexDataColumn,
|
||||||
|
'changedInfo': tacker_osc_utils.FormatComplexDataColumn,
|
||||||
|
'changedExtConnectivity': tacker_osc_utils.FormatComplexDataColumn,
|
||||||
|
'_links': tacker_osc_utils.FormatComplexDataColumn
|
||||||
|
}
|
||||||
|
|
||||||
|
_ATTR_MAP = (
|
||||||
|
('id', 'id', tacker_osc_utils.LIST_BOTH),
|
||||||
|
('operationState', 'operationState', tacker_osc_utils.LIST_BOTH),
|
||||||
|
('vnfInstanceId', 'vnfInstanceId', tacker_osc_utils.LIST_BOTH),
|
||||||
|
('operation', 'operation', tacker_osc_utils.LIST_BOTH)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _get_columns(vnflcm_op_occ_obj):
|
def _get_columns(vnflcm_op_occ_obj, action=None):
|
||||||
|
|
||||||
column_map = {
|
column_map = {
|
||||||
'id': 'ID',
|
'id': 'ID',
|
||||||
'operationState': 'Operation State',
|
'operationState': 'Operation State',
|
||||||
|
@ -42,6 +56,16 @@ def _get_columns(vnflcm_op_occ_obj):
|
||||||
'_links': 'Links'
|
'_links': 'Links'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if action == 'show':
|
||||||
|
column_map.update(
|
||||||
|
{'operationParams': 'Operation Parameters',
|
||||||
|
'grantId': 'Grant ID',
|
||||||
|
'resourceChanges': 'Resource Changes',
|
||||||
|
'changedInfo': 'Changed Info',
|
||||||
|
'cancelMode': 'Cancel Mode',
|
||||||
|
'changedExtConnectivity': 'Changed External Connectivity'}
|
||||||
|
)
|
||||||
|
|
||||||
return sdk_utils.get_osc_show_columns_for_sdk_resource(vnflcm_op_occ_obj,
|
return sdk_utils.get_osc_show_columns_for_sdk_resource(vnflcm_op_occ_obj,
|
||||||
column_map)
|
column_map)
|
||||||
|
|
||||||
|
@ -245,3 +269,38 @@ class ListVnfLcmOp(command.Lister):
|
||||||
)
|
)
|
||||||
|
|
||||||
return (headers, dictionary_properties)
|
return (headers, dictionary_properties)
|
||||||
|
|
||||||
|
|
||||||
|
class ShowVnfLcmOp(command.ShowOne):
|
||||||
|
_description = _("Display Operation Occurrence details")
|
||||||
|
|
||||||
|
def get_parser(self, program_name):
|
||||||
|
"""Add arguments to parser.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
program_name ([type]): program name
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
parser([ArgumentParser]):
|
||||||
|
"""
|
||||||
|
parser = super(ShowVnfLcmOp, self).get_parser(program_name)
|
||||||
|
parser.add_argument(
|
||||||
|
_VNF_LCM_OP_OCC_ID,
|
||||||
|
metavar="<vnf-lcm-op-occ-id>",
|
||||||
|
help=_('VNF lifecycle management operation occurrence ID.'))
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
"""Execute show_vnf_lcm_op_occs and output response.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
parsed_args ([Namespace]): arguments of CLI.
|
||||||
|
"""
|
||||||
|
client = self.app.client_manager.tackerclient
|
||||||
|
obj = client.show_vnf_lcm_op_occs(parsed_args.vnf_lcm_op_occ_id)
|
||||||
|
display_columns, columns = _get_columns(obj, action='show')
|
||||||
|
data = utils.get_item_properties(
|
||||||
|
sdk_utils.DictModel(obj),
|
||||||
|
columns, formatters=_FORMATTERS,
|
||||||
|
mixed_case_fields=_MIXED_CASE_FIELDS)
|
||||||
|
return (display_columns, data)
|
||||||
|
|
|
@ -25,7 +25,7 @@ from tackerclient.tests.unit.osc.v1.fixture_data import client
|
||||||
from tackerclient.tests.unit.osc.v1 import vnflcm_op_occs_fakes
|
from tackerclient.tests.unit.osc.v1 import vnflcm_op_occs_fakes
|
||||||
|
|
||||||
|
|
||||||
def _get_columns_vnflcm_op_occs(action=''):
|
def _get_columns_vnflcm_op_occs(action='show'):
|
||||||
|
|
||||||
if action == 'fail':
|
if action == 'fail':
|
||||||
return ['ID', 'Operation State', 'State Entered Time',
|
return ['ID', 'Operation State', 'State Entered Time',
|
||||||
|
@ -428,3 +428,74 @@ class TestListVnfLcmOp(TestVnfLcm):
|
||||||
self.assertRaises(exceptions.TackerClientException,
|
self.assertRaises(exceptions.TackerClientException,
|
||||||
self.list_vnflcm_op_occ.take_action,
|
self.list_vnflcm_op_occ.take_action,
|
||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
|
|
||||||
|
class TestShowVnfLcmOp(TestVnfLcm):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestShowVnfLcmOp, self).setUp()
|
||||||
|
self.show_vnf_lcm_op_occs = vnflcm_op_occs.ShowVnfLcmOp(
|
||||||
|
self.app, self.app_args, cmd_name='vnflcm op show')
|
||||||
|
|
||||||
|
def test_take_action(self):
|
||||||
|
"""Test of take_action()"""
|
||||||
|
vnflcm_op_occ = vnflcm_op_occs_fakes.vnflcm_op_occ_response()
|
||||||
|
|
||||||
|
arglist = [vnflcm_op_occ['id']]
|
||||||
|
verifylist = [('vnf_lcm_op_occ_id', vnflcm_op_occ['id'])]
|
||||||
|
|
||||||
|
# command param
|
||||||
|
parsed_args = self.check_parser(
|
||||||
|
self.show_vnf_lcm_op_occs, arglist, verifylist)
|
||||||
|
url = os.path.join(
|
||||||
|
self.url,
|
||||||
|
'vnflcm/v1/vnf_lcm_op_occs',
|
||||||
|
vnflcm_op_occ['id'])
|
||||||
|
|
||||||
|
self.requests_mock.register_uri(
|
||||||
|
'GET', url, headers=self.header, json=vnflcm_op_occ)
|
||||||
|
|
||||||
|
columns, data = (self.show_vnf_lcm_op_occs.take_action(parsed_args))
|
||||||
|
|
||||||
|
self.assertItemsEqual(_get_columns_vnflcm_op_occs(),
|
||||||
|
columns)
|
||||||
|
|
||||||
|
def test_take_action_vnf_lcm_op_occ_id_not_found(self):
|
||||||
|
"""Test if vnf-lcm-op-occ-id does not find."""
|
||||||
|
arglist = [uuidsentinel.vnf_lcm_op_occ_id]
|
||||||
|
verifylist = [('vnf_lcm_op_occ_id', uuidsentinel.vnf_lcm_op_occ_id)]
|
||||||
|
|
||||||
|
# command param
|
||||||
|
parsed_args = self.check_parser(
|
||||||
|
self.show_vnf_lcm_op_occs, arglist, verifylist)
|
||||||
|
|
||||||
|
url = os.path.join(
|
||||||
|
self.url,
|
||||||
|
'vnflcm/v1/vnf_lcm_op_occs',
|
||||||
|
uuidsentinel.vnf_lcm_op_occ_id)
|
||||||
|
self.requests_mock.register_uri(
|
||||||
|
'GET', url, headers=self.header, status_code=404, json={})
|
||||||
|
|
||||||
|
self.assertRaises(exceptions.TackerClientException,
|
||||||
|
self.show_vnf_lcm_op_occs.take_action,
|
||||||
|
parsed_args)
|
||||||
|
|
||||||
|
def test_take_action_internal_server_error(self):
|
||||||
|
"""Test for internal server error."""
|
||||||
|
arglist = [uuidsentinel.vnf_lcm_op_occ_id]
|
||||||
|
verifylist = [('vnf_lcm_op_occ_id', uuidsentinel.vnf_lcm_op_occ_id)]
|
||||||
|
|
||||||
|
# command param
|
||||||
|
parsed_args = self.check_parser(
|
||||||
|
self.show_vnf_lcm_op_occs, arglist, verifylist)
|
||||||
|
|
||||||
|
url = os.path.join(
|
||||||
|
self.url,
|
||||||
|
'vnflcm/v1/vnf_lcm_op_occs',
|
||||||
|
uuidsentinel.vnf_lcm_op_occ_id)
|
||||||
|
self.requests_mock.register_uri(
|
||||||
|
'GET', url, headers=self.header, status_code=500, json={})
|
||||||
|
|
||||||
|
self.assertRaises(exceptions.TackerClientException,
|
||||||
|
self.show_vnf_lcm_op_occs.take_action,
|
||||||
|
parsed_args)
|
||||||
|
|
|
@ -947,6 +947,10 @@ class VnfLCMClient(ClientBase):
|
||||||
retrieve_all, **_params)
|
retrieve_all, **_params)
|
||||||
return vnf_lcm_op_occs
|
return vnf_lcm_op_occs
|
||||||
|
|
||||||
|
@APIParamsCall
|
||||||
|
def show_vnf_lcm_op_occs(self, occ_id):
|
||||||
|
return self.get(self.vnf_lcm_op_occs_path % occ_id)
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client(object):
|
||||||
"""Unified interface to interact with multiple applications of tacker service.
|
"""Unified interface to interact with multiple applications of tacker service.
|
||||||
|
@ -1256,3 +1260,6 @@ class Client(object):
|
||||||
def list_vnf_lcm_op_occs(self, retrieve_all=True, **_params):
|
def list_vnf_lcm_op_occs(self, retrieve_all=True, **_params):
|
||||||
return self.vnf_lcm_client.list_vnf_lcm_op_occs(
|
return self.vnf_lcm_client.list_vnf_lcm_op_occs(
|
||||||
retrieve_all=retrieve_all, **_params)
|
retrieve_all=retrieve_all, **_params)
|
||||||
|
|
||||||
|
def show_vnf_lcm_op_occs(self, occ_id):
|
||||||
|
return self.vnf_lcm_client.show_vnf_lcm_op_occs(occ_id)
|
||||||
|
|
Loading…
Reference in New Issue