Merge "direct input for config was deprecated in ocata. Removing now."
This commit is contained in:
		@@ -16,7 +16,6 @@ import yaml
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from oslo_serialization import jsonutils
 | 
					from oslo_serialization import jsonutils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from tackerclient.common import utils
 | 
					 | 
				
			||||||
from tackerclient.i18n import _
 | 
					from tackerclient.i18n import _
 | 
				
			||||||
from tackerclient.tacker import v1_0 as tackerV10
 | 
					from tackerclient.tacker import v1_0 as tackerV10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -42,9 +41,7 @@ class CreateVNFFGD(tackerV10.CreateCommand):
 | 
				
			|||||||
    remove_output_fields = ["attributes"]
 | 
					    remove_output_fields = ["attributes"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def add_known_arguments(self, parser):
 | 
					    def add_known_arguments(self, parser):
 | 
				
			||||||
        group = parser.add_mutually_exclusive_group(required=True)
 | 
					        parser.add_argument('--vnffgd-file', help=_('Specify VNFFGD file'))
 | 
				
			||||||
        group.add_argument('--vnffgd-file', help=_('Specify VNFFGD file'))
 | 
					 | 
				
			||||||
        group.add_argument('--vnffgd', help=_('Specify VNFFGD (DEPRECATED)'))
 | 
					 | 
				
			||||||
        parser.add_argument(
 | 
					        parser.add_argument(
 | 
				
			||||||
            'name', metavar='NAME',
 | 
					            'name', metavar='NAME',
 | 
				
			||||||
            help=_('Set a name for the VNFFGD'))
 | 
					            help=_('Set a name for the VNFFGD'))
 | 
				
			||||||
@@ -58,14 +55,6 @@ class CreateVNFFGD(tackerV10.CreateCommand):
 | 
				
			|||||||
            with open(parsed_args.vnffgd_file) as f:
 | 
					            with open(parsed_args.vnffgd_file) as f:
 | 
				
			||||||
                vnffgd = yaml.safe_load(f.read())
 | 
					                vnffgd = yaml.safe_load(f.read())
 | 
				
			||||||
                body[self.resource]['template'] = {'vnffgd': vnffgd}
 | 
					                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],
 | 
					        tackerV10.update_dict(parsed_args, body[self.resource],
 | 
				
			||||||
                              ['tenant_id', 'name', 'description'])
 | 
					                              ['tenant_id', 'name', 'description'])
 | 
				
			||||||
        return body
 | 
					        return body
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import yaml
 | 
					import yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from tackerclient.common import utils
 | 
					 | 
				
			||||||
from tackerclient.i18n import _
 | 
					from tackerclient.i18n import _
 | 
				
			||||||
from tackerclient.tacker import v1_0 as tackerV10
 | 
					from tackerclient.tacker import v1_0 as tackerV10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -76,9 +75,6 @@ class CreateVNF(tackerV10.CreateCommand):
 | 
				
			|||||||
        parser.add_argument(
 | 
					        parser.add_argument(
 | 
				
			||||||
            '--config-file',
 | 
					            '--config-file',
 | 
				
			||||||
            help=_('YAML file with VNF configuration'))
 | 
					            help=_('YAML file with VNF configuration'))
 | 
				
			||||||
        parser.add_argument(
 | 
					 | 
				
			||||||
            '--config',
 | 
					 | 
				
			||||||
            help=_('Specify config yaml data (DEPRECATED)'))
 | 
					 | 
				
			||||||
        parser.add_argument(
 | 
					        parser.add_argument(
 | 
				
			||||||
            '--param-file',
 | 
					            '--param-file',
 | 
				
			||||||
            help=_('Specify parameter yaml file'))
 | 
					            help=_('Specify parameter yaml file'))
 | 
				
			||||||
@@ -94,15 +90,6 @@ class CreateVNF(tackerV10.CreateCommand):
 | 
				
			|||||||
            config = yaml.load(
 | 
					            config = yaml.load(
 | 
				
			||||||
                config_yaml, Loader=yaml.SafeLoader)
 | 
					                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:
 | 
					        if config:
 | 
				
			||||||
            args['attributes']['config'] = config
 | 
					            args['attributes']['config'] = config
 | 
				
			||||||
        if parsed_args.vim_region_name:
 | 
					        if parsed_args.vim_region_name:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,6 @@ from __future__ import print_function
 | 
				
			|||||||
from oslo_serialization import jsonutils
 | 
					from oslo_serialization import jsonutils
 | 
				
			||||||
import yaml
 | 
					import yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from tackerclient.common import utils
 | 
					 | 
				
			||||||
from tackerclient.i18n import _
 | 
					from tackerclient.i18n import _
 | 
				
			||||||
from tackerclient.tacker import v1_0 as tackerV10
 | 
					from tackerclient.tacker import v1_0 as tackerV10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -65,9 +64,7 @@ class CreateVNFD(tackerV10.CreateCommand):
 | 
				
			|||||||
    remove_output_fields = ["attributes"]
 | 
					    remove_output_fields = ["attributes"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def add_known_arguments(self, parser):
 | 
					    def add_known_arguments(self, parser):
 | 
				
			||||||
        group = parser.add_mutually_exclusive_group(required=True)
 | 
					        parser.add_argument('--vnfd-file', help=_('Specify VNFD file'))
 | 
				
			||||||
        group.add_argument('--vnfd-file', help=_('Specify VNFD file'))
 | 
					 | 
				
			||||||
        group.add_argument('--vnfd', help=_('Specify VNFD (DEPRECATED)'))
 | 
					 | 
				
			||||||
        parser.add_argument(
 | 
					        parser.add_argument(
 | 
				
			||||||
            'name', metavar='NAME',
 | 
					            'name', metavar='NAME',
 | 
				
			||||||
            help=_('Set a name for the VNFD'))
 | 
					            help=_('Set a name for the VNFD'))
 | 
				
			||||||
@@ -82,16 +79,6 @@ class CreateVNFD(tackerV10.CreateCommand):
 | 
				
			|||||||
            with open(parsed_args.vnfd_file) as f:
 | 
					            with open(parsed_args.vnfd_file) as f:
 | 
				
			||||||
                vnfd = f.read()
 | 
					                vnfd = f.read()
 | 
				
			||||||
                vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader)
 | 
					                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:
 | 
					        if vnfd:
 | 
				
			||||||
            body[self.resource]['attributes'] = {'vnfd': vnfd}
 | 
					            body[self.resource]['attributes'] = {'vnfd': vnfd}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,8 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from mock import mock_open
 | 
				
			||||||
 | 
					from mock import patch
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from tackerclient.tacker.v1_0.vnfm import vnfd
 | 
					from tackerclient.tacker.v1_0.vnfm import vnfd
 | 
				
			||||||
@@ -28,7 +30,10 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base):
 | 
				
			|||||||
        plurals = {'vnfds': 'vnfd'}
 | 
					        plurals = {'vnfds': 'vnfd'}
 | 
				
			||||||
        super(CLITestV10VmVNFDJSON, self).setUp(plurals=plurals)
 | 
					        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(
 | 
					        cmd = vnfd.CreateVNFD(
 | 
				
			||||||
            test_cli10.MyApp(sys.stdout), None)
 | 
					            test_cli10.MyApp(sys.stdout), None)
 | 
				
			||||||
        my_id = 'my-id'
 | 
					        my_id = 'my-id'
 | 
				
			||||||
@@ -37,7 +42,7 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base):
 | 
				
			|||||||
        attr_val = 'vnfd'
 | 
					        attr_val = 'vnfd'
 | 
				
			||||||
        args = [
 | 
					        args = [
 | 
				
			||||||
            name,
 | 
					            name,
 | 
				
			||||||
            '--vnfd', 'vnfd'
 | 
					            '--vnfd-file', 'vnfd-file'
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
        position_names = ['name']
 | 
					        position_names = ['name']
 | 
				
			||||||
        position_values = [name]
 | 
					        position_values = [name]
 | 
				
			||||||
@@ -49,12 +54,15 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base):
 | 
				
			|||||||
                                   args, position_names, position_values,
 | 
					                                   args, position_names, position_values,
 | 
				
			||||||
                                   extra_body=extra_body)
 | 
					                                   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(
 | 
					        cmd = vnfd.CreateVNFD(
 | 
				
			||||||
            test_cli10.MyApp(sys.stdout), None)
 | 
					            test_cli10.MyApp(sys.stdout), None)
 | 
				
			||||||
        name = 'my_name'
 | 
					        name = 'my_name'
 | 
				
			||||||
        my_id = 'my-id'
 | 
					        my_id = 'my-id'
 | 
				
			||||||
        args = [name, '--vnfd', 'vnfd', ]
 | 
					        args = [name, '--vnfd-file', 'vnfd-file', ]
 | 
				
			||||||
        position_names = ['name']
 | 
					        position_names = ['name']
 | 
				
			||||||
        position_values = [name]
 | 
					        position_values = [name]
 | 
				
			||||||
        extra_body = {
 | 
					        extra_body = {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,8 @@
 | 
				
			|||||||
# License for the specific language governing permissions and limitations
 | 
					# License for the specific language governing permissions and limitations
 | 
				
			||||||
# under the License.
 | 
					# under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from mock import mock_open
 | 
				
			||||||
 | 
					from mock import patch
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from tackerclient.tacker.v1_0.nfvo import vnffgd
 | 
					from tackerclient.tacker.v1_0.nfvo import vnffgd
 | 
				
			||||||
@@ -24,7 +26,10 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base):
 | 
				
			|||||||
        plurals = {'vnffgds': 'vnffgd'}
 | 
					        plurals = {'vnffgds': 'vnffgd'}
 | 
				
			||||||
        super(CLITestV10VmVNFFGDJSON, self).setUp(plurals=plurals)
 | 
					        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)
 | 
					        cmd = vnffgd.CreateVNFFGD(test_cli10.MyApp(sys.stdout), None)
 | 
				
			||||||
        my_id = 'my-id'
 | 
					        my_id = 'my-id'
 | 
				
			||||||
        name = 'my-name'
 | 
					        name = 'my-name'
 | 
				
			||||||
@@ -33,7 +38,7 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base):
 | 
				
			|||||||
        description = 'vnffgd description'
 | 
					        description = 'vnffgd description'
 | 
				
			||||||
        args = [
 | 
					        args = [
 | 
				
			||||||
            name,
 | 
					            name,
 | 
				
			||||||
            '--vnffgd', 'vnffgd',
 | 
					            '--vnffgd-file', 'vnffgd_file',
 | 
				
			||||||
            '--description', description,
 | 
					            '--description', description,
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
        position_names = ['name', 'description']
 | 
					        position_names = ['name', 'description']
 | 
				
			||||||
@@ -46,7 +51,10 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base):
 | 
				
			|||||||
                                   args, position_names, position_values,
 | 
					                                   args, position_names, position_values,
 | 
				
			||||||
                                   extra_body=extra_body)
 | 
					                                   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)
 | 
					        cmd = vnffgd.CreateVNFFGD(test_cli10.MyApp(sys.stdout), None)
 | 
				
			||||||
        my_id = 'my-id'
 | 
					        my_id = 'my-id'
 | 
				
			||||||
        name = 'my-name'
 | 
					        name = 'my-name'
 | 
				
			||||||
@@ -54,7 +62,7 @@ class CLITestV10VmVNFFGDJSON(test_cli10.CLITestV10Base):
 | 
				
			|||||||
        attr_val = 'vnffgd'
 | 
					        attr_val = 'vnffgd'
 | 
				
			||||||
        args = [
 | 
					        args = [
 | 
				
			||||||
            name,
 | 
					            name,
 | 
				
			||||||
            '--vnffgd', 'vnffgd',
 | 
					            '--vnffgd-file', 'vnffgd_file',
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
        position_names = ['name']
 | 
					        position_names = ['name']
 | 
				
			||||||
        position_values = [name]
 | 
					        position_values = [name]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user