Make VNFD/VNF/VIM Name Mandatory in Tacker CLI

Change-Id: I7e94cc43a61fbeb2b406d1e973ca422359e761a0
Partial-Bug: #1474966
This commit is contained in:
Manikantha Srinivas Tadi 2016-06-17 08:43:19 -04:00
parent e88619e985
commit f4daaa09ba
7 changed files with 46 additions and 25 deletions

View File

@ -0,0 +1,3 @@
---
features:
- Made VNFD/VNF/VIM names mandatory in tacker CLI.

View File

@ -50,7 +50,7 @@ class CreateVIM(tackerV10.CreateCommand):
group.add_argument('--config', help='Specify VIM config parameters ' group.add_argument('--config', help='Specify VIM config parameters '
'as a direct input') 'as a direct input')
parser.add_argument( parser.add_argument(
'--name', 'name', metavar='NAME',
help='Set a name for the VIM') help='Set a name for the VIM')
parser.add_argument( parser.add_argument(
'--description', '--description',

View File

@ -43,7 +43,7 @@ class CreateVNF(tackerV10.CreateCommand):
def add_known_arguments(self, parser): def add_known_arguments(self, parser):
parser.add_argument( parser.add_argument(
'--name', 'name', metavar='NAME',
help='Set a name for the VNF') help='Set a name for the VNF')
vnfd_group = parser.add_mutually_exclusive_group(required=True) vnfd_group = parser.add_mutually_exclusive_group(required=True)
vnfd_group.add_argument( vnfd_group.add_argument(

View File

@ -48,7 +48,7 @@ class CreateVNFD(tackerV10.CreateCommand):
group.add_argument('--vnfd-file', help='Specify VNFD file') group.add_argument('--vnfd-file', help='Specify VNFD file')
group.add_argument('--vnfd', help='Specify VNFD') group.add_argument('--vnfd', help='Specify VNFD')
parser.add_argument( parser.add_argument(
'--name', 'name', metavar='NAME',
help='Set a name for the VNFD') help='Set a name for the VNFD')
parser.add_argument( parser.add_argument(
'--description', '--description',

View File

@ -39,36 +39,49 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
def test_register_vim_all_params(self): def test_register_vim_all_params(self):
cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None) cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None)
name = 'my-name'
my_id = 'my-id' my_id = 'my-id'
name = 'test_vim'
description = 'Vim Description' description = 'Vim Description'
vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz', vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz',
'password': '12345', 'project_name': 'abc'} 'password': '12345', 'project_name': 'abc'}
args = [ args = [
name,
'--config', str(vim_config), '--config', str(vim_config),
'--name', name, '--description', description,
'--description', description] ]
position_names = ['auth_cred', 'vim_project', 'auth_url'] position_names = ['name', 'auth_cred', 'vim_project', 'auth_url']
position_values = [self.auth_cred, self.vim_project, self.auth_url] position_values = [
extra_body = {'type': 'openstack', 'name': name, 'description': name,
description, 'is_default': False} self.auth_cred,
self._test_create_resource(self._RESOURCE, cmd, None, my_id, self.vim_project,
self.auth_url
]
extra_body = {'type': 'openstack', 'description': description,
'is_default': False}
self._test_create_resource(self._RESOURCE, cmd, name, my_id,
args, position_names, position_values, args, position_names, position_values,
extra_body=extra_body) extra_body=extra_body)
def test_register_vim_with_mandatory_params(self): def test_register_vim_with_mandatory_params(self):
cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None) cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None)
name = 'my-name'
my_id = 'my-id' my_id = 'my-id'
vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz', vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz',
'password': '12345', 'project_name': 'abc'} 'password': '12345', 'project_name': 'abc'}
args = [ args = [
name,
'--config', str(vim_config), '--config', str(vim_config),
] ]
position_names = ['auth_cred', 'vim_project', 'auth_url'] position_names = ['name', 'auth_cred', 'vim_project', 'auth_url']
position_values = [self.auth_cred, self.vim_project, self.auth_url] position_values = [
name,
self.auth_cred,
self.vim_project,
self.auth_url
]
extra_body = {'type': 'openstack', 'is_default': False} extra_body = {'type': 'openstack', 'is_default': False}
self._test_create_resource(self._RESOURCE, cmd, None, my_id, args, self._test_create_resource(self._RESOURCE, cmd, name, my_id, args,
position_names, position_values, position_names, position_values,
extra_body=extra_body) extra_body=extra_body)

View File

@ -91,6 +91,7 @@ class CLITestV10VmVNFJSON(test_cli10.CLITestV10Base):
def test_create_vnf_all_params(self): def test_create_vnf_all_params(self):
cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None) cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
name = 'my_name'
my_id = 'my-id' my_id = 'my-id'
vnfd_id = 'vnfd' vnfd_id = 'vnfd'
vim_id = 'vim_id' vim_id = 'vim_id'
@ -99,28 +100,31 @@ class CLITestV10VmVNFJSON(test_cli10.CLITestV10Base):
value = 'value' value = 'value'
args = [ args = [
name,
'--vnfd-id', vnfd_id, '--vnfd-id', vnfd_id,
'--vim-id', vim_id, '--vim-id', vim_id,
'--vim-region-name', region_name, '--vim-region-name', region_name,
'--%s' % key, value] '--%s' % key, value]
position_names = ['vnfd_id', 'vim_id', 'attributes'] position_names = ['name', 'vnfd_id', 'vim_id', 'attributes']
position_values = [vnfd_id, vim_id, {}] position_values = [name, vnfd_id, vim_id, {}]
extra_body = {key: value, 'placement_attr': {'region_name': extra_body = {key: value, 'placement_attr': {'region_name':
region_name}} region_name}}
self._test_create_resource(self._RESOURCE, cmd, None, my_id, self._test_create_resource(self._RESOURCE, cmd, name, my_id,
args, position_names, position_values, args, position_names, position_values,
extra_body=extra_body) extra_body=extra_body)
def test_create_vnf_with_mandatory_params(self): def test_create_vnf_with_mandatory_params(self):
cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None) cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
name = 'my_name'
my_id = 'my-id' my_id = 'my-id'
vnfd_id = 'vnfd' vnfd_id = 'vnfd'
args = [ args = [
name,
'--vnfd-id', vnfd_id, '--vnfd-id', vnfd_id,
] ]
position_names = ['vnfd_id', 'attributes'] position_names = ['name', 'vnfd_id', 'attributes']
position_values = [vnfd_id, {}] position_values = [name, vnfd_id, {}]
self._test_create_resource(self._RESOURCE, cmd, None, my_id, self._test_create_resource(self._RESOURCE, cmd, name, my_id,
args, position_names, position_values) args, position_names, position_values)
def test_list_vnfs(self): def test_list_vnfs(self):

View File

@ -38,7 +38,7 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base):
attr_key = 'vnfd' attr_key = 'vnfd'
attr_val = 'vnfd' attr_val = 'vnfd'
args = [ args = [
'--name', name, name,
'--vnfd', 'vnfd' '--vnfd', 'vnfd'
] ]
position_names = ['name', 'mgmt_driver', 'infra_driver'] position_names = ['name', 'mgmt_driver', 'infra_driver']
@ -54,17 +54,18 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base):
def test_create_vnfd_with_mandatory_params(self): def test_create_vnfd_with_mandatory_params(self):
cmd = vnfd.CreateVNFD( cmd = vnfd.CreateVNFD(
test_cli10.MyApp(sys.stdout), None) test_cli10.MyApp(sys.stdout), None)
name = 'my_name'
my_id = 'my-id' my_id = 'my-id'
mgmt_driver = 'noop' mgmt_driver = 'noop'
infra_driver = 'heat' infra_driver = 'heat'
args = ['--vnfd', 'vnfd', ] args = [name, '--vnfd', 'vnfd', ]
position_names = ['mgmt_driver', 'infra_driver'] position_names = ['name', 'mgmt_driver', 'infra_driver']
position_values = [mgmt_driver, infra_driver] position_values = [name, mgmt_driver, infra_driver]
extra_body = { extra_body = {
'service_types': [{'service_type': 'vnfd'}], 'service_types': [{'service_type': 'vnfd'}],
'attributes': {'vnfd': 'vnfd'} 'attributes': {'vnfd': 'vnfd'}
} }
self._test_create_resource(self._RESOURCE, cmd, None, my_id, self._test_create_resource(self._RESOURCE, cmd, name, my_id,
args, position_names, position_values, args, position_names, position_values,
extra_body=extra_body) extra_body=extra_body)