diff options
author | Manuel Buil <mbuil@suse.com> | 2018-05-21 12:14:51 +0200 |
---|---|---|
committer | Brady Johnson <bjohnson@inocybe.com> | 2018-05-21 14:21:03 +0000 |
commit | e122e00cb02adc65870cbb05f394dfc9a0cf55b2 (patch) | |
tree | 3ea95087a95802ccae6630c8696ed0f228edc8a5 | |
parent | 772ceec147145e16f1c7be03c48d20292e4bd770 (diff) |
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 <mbuil@suse.com>
-rw-r--r-- | sfc/lib/openstack_utils.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sfc/lib/openstack_utils.py b/sfc/lib/openstack_utils.py index 7eef2850..d518ec6f 100644 --- a/sfc/lib/openstack_utils.py +++ b/sfc/lib/openstack_utils.py @@ -346,8 +346,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}}) @@ -515,8 +516,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}}}) |