diff --git a/tackerclient/tacker/v1_0/nfvo/vnffgd.py b/tackerclient/tacker/v1_0/nfvo/vnffgd.py index d65fb184..40a0b804 100644 --- a/tackerclient/tacker/v1_0/nfvo/vnffgd.py +++ b/tackerclient/tacker/v1_0/nfvo/vnffgd.py @@ -16,7 +16,6 @@ import yaml from oslo_serialization import jsonutils -from tackerclient.common import utils from tackerclient.i18n import _ from tackerclient.tacker import v1_0 as tackerV10 @@ -42,9 +41,7 @@ class CreateVNFFGD(tackerV10.CreateCommand): remove_output_fields = ["attributes"] def add_known_arguments(self, parser): - group = parser.add_mutually_exclusive_group(required=True) - group.add_argument('--vnffgd-file', help=_('Specify VNFFGD file')) - group.add_argument('--vnffgd', help=_('Specify VNFFGD (DEPRECATED)')) + parser.add_argument('--vnffgd-file', help=_('Specify VNFFGD file')) parser.add_argument( 'name', metavar='NAME', help=_('Set a name for the VNFFGD')) @@ -58,14 +55,6 @@ class CreateVNFFGD(tackerV10.CreateCommand): with open(parsed_args.vnffgd_file) as f: vnffgd = yaml.safe_load(f.read()) body[self.resource]['template'] = {'vnffgd': vnffgd} - if parsed_args.vnffgd: - # TODO(sridhar_ram): Only file based input supported starting - # Ocata, remove all direct inputs in Pike - utils.deprecate_warning(what="Direct VNFFGD template input", - as_of="O", - remove_in=1) - body[self.resource]['template'] = { - 'vnffgd': yaml.safe_load(parsed_args.vnffgd)} tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id', 'name', 'description']) return body diff --git a/tackerclient/tacker/v1_0/vnfm/vnf.py b/tackerclient/tacker/v1_0/vnfm/vnf.py index c6e6cb11..07ecf2f6 100644 --- a/tackerclient/tacker/v1_0/vnfm/vnf.py +++ b/tackerclient/tacker/v1_0/vnfm/vnf.py @@ -17,7 +17,6 @@ import yaml -from tackerclient.common import utils from tackerclient.i18n import _ from tackerclient.tacker import v1_0 as tackerV10 @@ -76,9 +75,6 @@ class CreateVNF(tackerV10.CreateCommand): parser.add_argument( '--config-file', help=_('YAML file with VNF configuration')) - parser.add_argument( - '--config', - help=_('Specify config yaml data (DEPRECATED)')) parser.add_argument( '--param-file', help=_('Specify parameter yaml file')) @@ -94,15 +90,6 @@ class CreateVNF(tackerV10.CreateCommand): config = yaml.load( config_yaml, Loader=yaml.SafeLoader) - if parsed_args.config: - # TODO(sridhar_ram): Only file based input supported starting - # Ocata, remove all direct inputs in Pike - utils.deprecate_warning(what="Direct config YAML input", as_of="O", - remove_in=1) - config = parsed_args.config - if isinstance(config, str) or isinstance(config, unicode): - config_str = parsed_args.config.decode('unicode_escape') - config = yaml.load(config_str, Loader=yaml.SafeLoader) if config: args['attributes']['config'] = config if parsed_args.vim_region_name: diff --git a/tackerclient/tacker/v1_0/vnfm/vnfd.py b/tackerclient/tacker/v1_0/vnfm/vnfd.py index ef6cfb40..56096faf 100644 --- a/tackerclient/tacker/v1_0/vnfm/vnfd.py +++ b/tackerclient/tacker/v1_0/vnfm/vnfd.py @@ -20,7 +20,6 @@ from __future__ import print_function from oslo_serialization import jsonutils import yaml -from tackerclient.common import utils from tackerclient.i18n import _ from tackerclient.tacker import v1_0 as tackerV10 @@ -65,9 +64,7 @@ class CreateVNFD(tackerV10.CreateCommand): remove_output_fields = ["attributes"] def add_known_arguments(self, parser): - group = parser.add_mutually_exclusive_group(required=True) - group.add_argument('--vnfd-file', help=_('Specify VNFD file')) - group.add_argument('--vnfd', help=_('Specify VNFD (DEPRECATED)')) + parser.add_argument('--vnfd-file', help=_('Specify VNFD file')) parser.add_argument( 'name', metavar='NAME', help=_('Set a name for the VNFD')) @@ -82,16 +79,6 @@ class CreateVNFD(tackerV10.CreateCommand): with open(parsed_args.vnfd_file) as f: vnfd = f.read() vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader) - if parsed_args.vnfd: - # TODO(sridhar_ram): Only file based input supported starting - # Ocata, remove all direct inputs in Pike - utils.deprecate_warning(what="Direct VNFD template input", - as_of="O", - remove_in=1) - vnfd = parsed_args.vnfd - if isinstance(vnfd, str) or isinstance(vnfd, unicode): - vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader) - if vnfd: body[self.resource]['attributes'] = {'vnfd': vnfd} diff --git a/tackerclient/tests/unit/vm/test_cli10_vnfd.py b/tackerclient/tests/unit/vm/test_cli10_vnfd.py index 261e49fa..53615763 100644 --- a/tackerclient/tests/unit/vm/test_cli10_vnfd.py +++ b/tackerclient/tests/unit/vm/test_cli10_vnfd.py @@ -14,6 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. +from mock import mock_open +from mock import patch import sys from tackerclient.tacker.v1_0.vnfm import vnfd @@ -28,7 +30,10 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base): plurals = {'vnfds': 'vnfd'} super(CLITestV10VmVNFDJSON, self).setUp(plurals=plurals) - def test_create_vnfd_all_params(self): + @patch("tackerclient.tacker.v1_0.vnfm.vnfd.open", + side_effect=mock_open(read_data="vnfd"), + create=True) + def test_create_vnfd_all_params(self, mo): cmd = vnfd.CreateVNFD( test_cli10.MyApp(sys.stdout), None) my_id = 'my-id' @@ -37,7 +42,7 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base): attr_val = 'vnfd' args = [ name, - '--vnfd', 'vnfd' + '--vnfd-file', 'vnfd-file' ] position_names = ['name'] position_values = [name] @@ -49,12 +54,15 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base): args, position_names, position_values, extra_body=extra_body) - def test_create_vnfd_with_mandatory_params(self): + @patch("tackerclient.tacker.v1_0.vnfm.vnfd.open", + side_effect=mock_open(read_data="vnfd"), + create=True) + def test_create_vnfd_with_mandatory_params(self, mo): cmd = vnfd.CreateVNFD( test_cli10.MyApp(sys.stdout), None) name = 'my_name' my_id = 'my-id' - args = [name, '--vnfd', 'vnfd', ] + args = [name, '--vnfd-file', 'vnfd-file', ] position_names = ['name'] position_values = [name] extra_body = { diff --git a/tackerclient/tests/unit/vm/test_cli10_vnffgd.py b/tackerclient/tests/unit/vm/test_cli10_vnffgd.py index ff80d426..6345330f 100644 --- a/tackerclient/tests/unit/vm/test_cli10_vnffgd.py +++ b/tackerclient/tests/unit/vm/test_cli10_vnffgd.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +from mock import mock_open +from mock import patch import sys from tackerclient.tacker.v1_0.nfvo import vnffgd @@ -24,7 +26,10 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base): plurals = {'vnffgds': 'vnffgd'} super(CLITestV10VmVNFFGDJSON, self).setUp(plurals=plurals) - def test_create_vnffgd_all_params(self): + @patch("tackerclient.tacker.v1_0.nfvo.vnffgd.open", + side_effect=mock_open(read_data="vnffgd"), + create=True) + def test_create_vnffgd_all_params(self, mo): cmd = vnffgd.CreateVNFFGD(test_cli10.MyApp(sys.stdout), None) my_id = 'my-id' name = 'my-name' @@ -33,7 +38,7 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base): description = 'vnffgd description' args = [ name, - '--vnffgd', 'vnffgd', + '--vnffgd-file', 'vnffgd_file', '--description', description, ] position_names = ['name', 'description'] @@ -46,7 +51,10 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base): args, position_names, position_values, extra_body=extra_body) - def test_create_vnffgd_with_mandatory_params(self): + @patch("tackerclient.tacker.v1_0.nfvo.vnffgd.open", + side_effect=mock_open(read_data="vnffgd"), + create=True) + def test_create_vnffgd_with_mandatory_params(self, mo): cmd = vnffgd.CreateVNFFGD(test_cli10.MyApp(sys.stdout), None) my_id = 'my-id' name = 'my-name' @@ -54,7 +62,7 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base): attr_val = 'vnffgd' args = [ name, - '--vnffgd', 'vnffgd', + '--vnffgd-file', 'vnffgd_file', ] position_names = ['name'] position_values = [name]