Add "--vnffgd-template" to vnffg-update command
This patch will add "--vnffgd-template" to vnffg-update command to support update VNFFG from file. User can run: tacker vnffg-update --vnffgd-template <vnffgd-file-name> vnffg_name to update the existing VNFFG. Partially Implements: blueprint update-vnffg Change-Id: Ief0469d870530693798f798ecd2f52782318795b
This commit is contained in:
@@ -165,6 +165,10 @@ class UpdateVNFFG(tackerV10.UpdateCommand):
|
||||
resource = _VNFFG
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--vnffgd-template',
|
||||
help=_('VNFFGD file to update VNFFG')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--vnf-mapping',
|
||||
help=_('List of logical VNFD name to VNF instance name mapping. '
|
||||
@@ -176,7 +180,8 @@ class UpdateVNFFG(tackerV10.UpdateCommand):
|
||||
help=_('Should a reverse path be created for the NFP'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}}
|
||||
args = {}
|
||||
body = {self.resource: args}
|
||||
|
||||
tacker_client = self.get_client()
|
||||
tacker_client.format = parsed_args.request_format
|
||||
@@ -192,6 +197,17 @@ class UpdateVNFFG(tackerV10.UpdateCommand):
|
||||
|
||||
parsed_args.vnf_mapping = _vnf_mapping
|
||||
|
||||
if parsed_args.vnffgd_template:
|
||||
with open(parsed_args.vnffgd_template) as f:
|
||||
template = f.read()
|
||||
try:
|
||||
args['vnffgd_template'] = yaml.load(
|
||||
template, Loader=yaml.SafeLoader)
|
||||
except yaml.YAMLError as e:
|
||||
raise exceptions.InvalidInput(e)
|
||||
if not args['vnffgd_template']:
|
||||
raise exceptions.InvalidInput('The vnffgd template is empty')
|
||||
|
||||
tackerV10.update_dict(parsed_args, body[self.resource],
|
||||
['tenant_id', 'vnf_mapping', 'symmetrical'])
|
||||
return body
|
||||
|
@@ -0,0 +1 @@
|
||||
abcxyz
|
@@ -16,6 +16,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from tackerclient.common import utils
|
||||
from tackerclient.tacker.v1_0.nfvo import vnffg
|
||||
from tackerclient.tests.unit import test_cli10
|
||||
|
||||
@@ -94,11 +95,22 @@ class CLITestV10VmVNFFGJSON(test_cli10.CLITestV10Base):
|
||||
def test_update_vnffg(self):
|
||||
cmd = vnffg.UpdateVNFFG(test_cli10.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
key = 'new_key'
|
||||
value = 'new-value'
|
||||
update_vnffg = utils.get_file_path(
|
||||
'tests/unit/vm/samples/vnffg_update_file.yaml')
|
||||
vnf_mapping = 'VNFD1:VNF1'
|
||||
args = [
|
||||
my_id,
|
||||
'--vnf-mapping', vnf_mapping,
|
||||
'--vnffgd-template', str(update_vnffg),
|
||||
'--symmetrical'
|
||||
]
|
||||
extra_fields = {
|
||||
"vnf_mapping": {"VNFD1": "VNF1"},
|
||||
"vnffgd_template": "abcxyz",
|
||||
"symmetrical": True
|
||||
}
|
||||
self._test_update_resource(self._RESOURCE, cmd, my_id,
|
||||
[my_id, '--%s' % key, value],
|
||||
{'symmetrical': False, key: value},
|
||||
args, extra_fields,
|
||||
get_client_called_count=2)
|
||||
|
||||
def test_delete_vnffg(self):
|
||||
|
Reference in New Issue
Block a user