Created
November 11, 2015 08:33
-
-
Save KLuka/d8a88a31e38ca0bcf7e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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