From 42b733746dcd155025065a389a5ef7ee28445ca3 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Mon, 21 May 2018 12:14:51 +0200 Subject: Improve logging and unify how to read from yaml vnffgd and vnfd are being parsed in different ways, we should parse them in the same way. We could do it directly with safe_load, however, the returned object is not easy to read. If we use read() instead, the resturned object is easy to read/log. Therefore, this patch combines both options Change-Id: I3416933801569a6f57962cd9906726229923136d Signed-off-by: Manuel Buil (cherry picked from commit e122e00cb02adc65870cbb05f394dfc9a0cf55b2) --- sfc/lib/openstack_utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sfc/lib/openstack_utils.py b/sfc/lib/openstack_utils.py index 44df4971..f21552d5 100644 --- a/sfc/lib/openstack_utils.py +++ b/sfc/lib/openstack_utils.py @@ -337,8 +337,9 @@ def create_vnfd(tacker_client, tosca_file=None, vnfd_name=None): vnfd_body = {} if tosca_file is not None: with open(tosca_file) as tosca_fd: - vnfd_body = tosca_fd.read() - logger.info('VNFD template:\n{0}'.format(vnfd_body)) + vnfd = tosca_fd.read() + vnfd_body = yaml.safe_load(vnfd) + logger.info('VNFD template:\n{0}'.format(vnfd)) return tacker_client.create_vnfd( body={"vnfd": {"attributes": {"vnfd": vnfd_body}, "name": vnfd_name}}) @@ -506,8 +507,9 @@ def create_vnffgd(tacker_client, tosca_file=None, vnffgd_name=None): vnffgd_body = {} if tosca_file is not None: with open(tosca_file) as tosca_fd: - vnffgd_body = yaml.safe_load(tosca_fd) - logger.info('VNFFGD template:\n{0}'.format(vnffgd_body)) + vnffgd = tosca_fd.read() + vnffgd_body = yaml.safe_load(vnffgd) + logger.info('VNFFGD template:\n{0}'.format(vnffgd)) return tacker_client.create_vnffgd( body={'vnffgd': {'name': vnffgd_name, 'template': {'vnffgd': vnffgd_body}}}) -- cgit 1.2.3-korg