Added command to display VNFD's template

Change-Id: I1e1a1674680e9f7c03e519b85930b8e51478b011
This commit is contained in:
KLuka 2015-11-12 18:16:39 +01:00
parent 56b3e8aea0
commit 83db572f62
2 changed files with 24 additions and 0 deletions

View File

@ -121,6 +121,7 @@ COMMAND_V1 = {
'vnfd-delete': vnfd.DeleteVNFD, 'vnfd-delete': vnfd.DeleteVNFD,
'vnfd-list': vnfd.ListVNFD, 'vnfd-list': vnfd.ListVNFD,
'vnfd-show': vnfd.ShowVNFD, 'vnfd-show': vnfd.ShowVNFD,
'vnfd-template-show': vnfd.ShowTemplateVNFD,
'vnf-create': vnf.CreateVNF, 'vnf-create': vnf.CreateVNF,
'vnf-update': vnf.UpdateVNF, 'vnf-update': vnf.UpdateVNF,

View File

@ -19,6 +19,11 @@
# #
# @author: Isaku Yamahata, Intel # @author: Isaku Yamahata, Intel
from __future__ import print_function
from oslo_serialization import jsonutils
from tackerclient.i18n import _
from tackerclient.tacker import v1_0 as tackerV10 from tackerclient.tacker import v1_0 as tackerV10
@ -72,3 +77,21 @@ class CreateVNFD(tackerV10.CreateCommand):
class DeleteVNFD(tackerV10.DeleteCommand): class DeleteVNFD(tackerV10.DeleteCommand):
"""Delete a given VNFD.""" """Delete a given VNFD."""
resource = _VNFD resource = _VNFD
class ShowTemplateVNFD(tackerV10.ShowCommand):
"""Show template of a given VNFD."""
resource = _VNFD
def run(self, parsed_args):
self.log.debug('run(%s)', parsed_args)
template = None
data = self.get_data(parsed_args)
try:
attributes_index = data[0].index('attributes')
attributes_json = data[1][attributes_index]
template = jsonutils.loads(attributes_json).get('vnfd', None)
except (IndexError, TypeError, ValueError) as e:
self.log.debug('Data handling error: %s', str(e))
print(template or _('Unable to display VNFD template!'))