Support VNF creation from inline VNF template
Allows creating VNF from the VNFD template directly without the need of VNFD being stored in Tacker VNFD catalog. Change-Id: I719237dd04dd7fe13fb7e7964402d7074679b2d6 Implements: blueprint vnf-inline-template
This commit is contained in:
parent
b91c8a745e
commit
f66a4e0ccc
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Support to create VNF with direct VNFD template input from CLI.
|
@ -60,6 +60,9 @@ class CreateVNF(tackerV10.CreateCommand):
|
|||||||
vnfd_group.add_argument(
|
vnfd_group.add_argument(
|
||||||
'--vnfd-name',
|
'--vnfd-name',
|
||||||
help=_('VNFD Name to use as template to create VNF'))
|
help=_('VNFD Name to use as template to create VNF'))
|
||||||
|
vnfd_group.add_argument(
|
||||||
|
'--vnfd-template',
|
||||||
|
help=_("VNFD file to create VNF"))
|
||||||
vim_group = parser.add_mutually_exclusive_group()
|
vim_group = parser.add_mutually_exclusive_group()
|
||||||
vim_group.add_argument(
|
vim_group.add_argument(
|
||||||
'--vim-id',
|
'--vim-id',
|
||||||
@ -118,6 +121,12 @@ class CreateVNF(tackerV10.CreateCommand):
|
|||||||
parsed_args.
|
parsed_args.
|
||||||
vnfd_name)
|
vnfd_name)
|
||||||
parsed_args.vnfd_id = _id
|
parsed_args.vnfd_id = _id
|
||||||
|
elif parsed_args.vnfd_template:
|
||||||
|
with open(parsed_args.vnfd_template) as f:
|
||||||
|
template = f.read()
|
||||||
|
args['vnfd_template'] = yaml.load(
|
||||||
|
template, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
if parsed_args.param_file:
|
if parsed_args.param_file:
|
||||||
with open(parsed_args.param_file) as f:
|
with open(parsed_args.param_file) as f:
|
||||||
param_yaml = f.read()
|
param_yaml = f.read()
|
||||||
|
@ -32,7 +32,24 @@ class ListVNFD(tackerV10.ListCommand):
|
|||||||
"""List VNFD that belong to a given tenant."""
|
"""List VNFD that belong to a given tenant."""
|
||||||
|
|
||||||
resource = _VNFD
|
resource = _VNFD
|
||||||
list_columns = ['id', 'name', 'description']
|
list_columns = ['id', 'name', 'template_source', 'description']
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ListVNFD, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'--template-source',
|
||||||
|
help=_("List VNFD with specified template source. Available \
|
||||||
|
options are 'onboarded' (default), 'inline' or 'all'"),
|
||||||
|
action='store',
|
||||||
|
default='onboarded')
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def args2search_opts(self, parsed_args):
|
||||||
|
search_opts = super(ListVNFD, self).args2search_opts(parsed_args)
|
||||||
|
template_source = parsed_args.template_source
|
||||||
|
if parsed_args.template_source:
|
||||||
|
search_opts.update({'template_source': template_source})
|
||||||
|
return search_opts
|
||||||
|
|
||||||
|
|
||||||
class ShowVNFD(tackerV10.ShowCommand):
|
class ShowVNFD(tackerV10.ShowCommand):
|
||||||
|
@ -286,7 +286,8 @@ class CLITestV10Base(testtools.TestCase):
|
|||||||
def _test_list_resources(self, resources, cmd, detail=False, tags=[],
|
def _test_list_resources(self, resources, cmd, detail=False, tags=[],
|
||||||
fields_1=[], fields_2=[], page_size=None,
|
fields_1=[], fields_2=[], page_size=None,
|
||||||
sort_key=[], sort_dir=[], response_contents=None,
|
sort_key=[], sort_dir=[], response_contents=None,
|
||||||
base_args=None, path=None):
|
base_args=None, path=None,
|
||||||
|
template_source=None):
|
||||||
if response_contents is None:
|
if response_contents is None:
|
||||||
contents = [{self.id_field: 'myid1', },
|
contents = [{self.id_field: 'myid1', },
|
||||||
{self.id_field: 'myid2', }, ]
|
{self.id_field: 'myid2', }, ]
|
||||||
@ -305,6 +306,10 @@ class CLITestV10Base(testtools.TestCase):
|
|||||||
for field in fields_1:
|
for field in fields_1:
|
||||||
args.append('--fields')
|
args.append('--fields')
|
||||||
args.append(field)
|
args.append(field)
|
||||||
|
if template_source is not None:
|
||||||
|
args.append("--template-source")
|
||||||
|
args.append(template_source)
|
||||||
|
query += 'template_source=' + template_source
|
||||||
|
|
||||||
if tags:
|
if tags:
|
||||||
args.append('--')
|
args.append('--')
|
||||||
|
@ -112,14 +112,14 @@ class CLITestV10VmVNFJSON(test_cli10.CLITestV10Base):
|
|||||||
'vnfd_id',
|
'vnfd_id',
|
||||||
'vim_id',
|
'vim_id',
|
||||||
'description',
|
'description',
|
||||||
'attributes'
|
'attributes',
|
||||||
]
|
]
|
||||||
position_values = [
|
position_values = [
|
||||||
name,
|
name,
|
||||||
vnfd_id,
|
vnfd_id,
|
||||||
vim_id,
|
vim_id,
|
||||||
description,
|
description,
|
||||||
{}
|
{},
|
||||||
]
|
]
|
||||||
extra_body = {key: value, 'placement_attr': {'region_name':
|
extra_body = {key: value, 'placement_attr': {'region_name':
|
||||||
region_name}}
|
region_name}}
|
||||||
@ -127,7 +127,7 @@ class CLITestV10VmVNFJSON(test_cli10.CLITestV10Base):
|
|||||||
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_vnfd_id(self):
|
||||||
cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
|
cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
|
||||||
name = 'my_name'
|
name = 'my_name'
|
||||||
my_id = 'my-id'
|
my_id = 'my-id'
|
||||||
|
@ -67,11 +67,24 @@ class CLITestV10VmVNFDJSON(test_cli10.CLITestV10Base):
|
|||||||
|
|
||||||
def test_list_vnfds(self):
|
def test_list_vnfds(self):
|
||||||
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
||||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
self._test_list_resources(self._RESOURCES, cmd, True,
|
||||||
|
template_source='onboarded')
|
||||||
|
|
||||||
|
def test_list_inline_vnfds(self):
|
||||||
|
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
||||||
|
self._test_list_resources(self._RESOURCES, cmd, True,
|
||||||
|
template_source='inline')
|
||||||
|
|
||||||
|
def test_list_all_vnfds(self):
|
||||||
|
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
||||||
|
self._test_list_resources(self._RESOURCES, cmd, True,
|
||||||
|
template_source='all')
|
||||||
|
|
||||||
def test_list_vnfds_pagenation(self):
|
def test_list_vnfds_pagenation(self):
|
||||||
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
|
||||||
self._test_list_resources(self._RESOURCES, cmd, True)
|
print(cmd)
|
||||||
|
self._test_list_resources(self._RESOURCES, cmd, True,
|
||||||
|
template_source='onboarded')
|
||||||
|
|
||||||
def test_show_vnfd_id(self):
|
def test_show_vnfd_id(self):
|
||||||
cmd = vnfd.ShowVNFD(test_cli10.MyApp(sys.stdout), None)
|
cmd = vnfd.ShowVNFD(test_cli10.MyApp(sys.stdout), None)
|
||||||
|
@ -391,9 +391,10 @@ class Client(ClientBase):
|
|||||||
retrieve_all,
|
retrieve_all,
|
||||||
**_params)
|
**_params)
|
||||||
for vnfd in vnfds_dict['vnfds']:
|
for vnfd in vnfds_dict['vnfds']:
|
||||||
if 'description' in vnfd.keys() and \
|
if vnfd.get('description'):
|
||||||
len(vnfd['description']) > DEFAULT_DESC_LENGTH:
|
if len(vnfd['description']) > DEFAULT_DESC_LENGTH:
|
||||||
vnfd['description'] = vnfd['description'][:DEFAULT_DESC_LENGTH]
|
vnfd['description'] = \
|
||||||
|
vnfd['description'][:DEFAULT_DESC_LENGTH]
|
||||||
vnfd['description'] += '...'
|
vnfd['description'] += '...'
|
||||||
return vnfds_dict
|
return vnfds_dict
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user