Skip to content

Instantly share code, notes, and snippets.

@KLuka
Created November 11, 2015 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KLuka/d8a88a31e38ca0bcf7e0 to your computer and use it in GitHub Desktop.
Save KLuka/d8a88a31e38ca0bcf7e0 to your computer and use it in GitHub Desktop.
--- a/tackerclient/tacker/v1_0/vm/vnfd.py
+++ b/tackerclient/tacker/v1_0/vm/vnfd.py
@@ -19,6 +19,11 @@
#
# @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
@@ -38,6 +43,34 @@ class ShowVNFD(tackerV10.ShowCommand):
resource = _VNFD
+ def run(self, parsed_args):
+ if parsed_args.template:
+ self._show_template(parsed_args)
+ else:
+ super(ShowVNFD, self).run(parsed_args)
+
+ def get_parser(self, prog_name):
+ parser = super(ShowVNFD, self).get_parser(prog_name)
+ parser.add_argument(
+ '--template',
+ action='store_true',
+ default=False,
+ help='Show only VNFD template')
+ return parser
+
+ def _show_template(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):
+ pass
+ print(template or _('Unable to display VNFD template!'))
+
+
class CreateVNFD(tackerV10.CreateCommand):
"""create a VNFD."""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment