diff options
author | 2017-09-11 13:55:51 +0000 | |
---|---|---|
committer | 2017-09-11 13:55:51 +0000 | |
commit | 00ec6171218b0d43d9ac566515ca04cd6b8b4b28 (patch) | |
tree | 3049641b1fc7f5c70865b248653d6872ce877b36 /sfc/lib/utils.py | |
parent | f2d9ca06bd9a70b4ee50c0dd51fcb061cf2baaca (diff) | |
parent | 56fb19b663557ce07be6d4e5c07fd4a5b9276ed2 (diff) |
Merge "Adapt functionality to the new Tacker API"
Diffstat (limited to 'sfc/lib/utils.py')
-rw-r--r-- | sfc/lib/utils.py | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index cb831969..aacce25f 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -13,13 +13,13 @@ import re import subprocess import requests import time -import yaml - +import json import logging +from functest.utils.constants import CONST import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as os_utils -import functest.utils.openstack_tacker as os_tacker +import sfc.lib.openstack_tacker as os_tacker logger = logging.getLogger(__name__) @@ -79,28 +79,27 @@ def get_av_zones(): def create_vnf_in_av_zone( - tacker_client, vnf_name, vnfd_name, default_param_file, av_zone=None): + tacker_client, + vnf_name, + vnfd_name, + vim_name, + default_param_file, + av_zone=None): param_file = default_param_file if av_zone is not None or av_zone != 'nova': param_file = os.path.join( '/tmp', - 'param_{0}.yaml'.format(av_zone.replace('::', '_'))) + 'param_{0}.json'.format(av_zone.replace('::', '_'))) data = { - 'vdus': { - 'vdu1': { - 'param': { - 'zone': av_zone - } - } - } - } + 'zone': av_zone + } with open(param_file, 'w+') as f: - yaml.dump(data, f, default_flow_style=False) - + json.dump(data, f) os_tacker.create_vnf(tacker_client, vnf_name, vnfd_name=vnfd_name, + vim_name=vim_name, param_file=param_file) @@ -639,3 +638,18 @@ def fill_installer_dict(installer_type): "pkey_file": default_string+"pkey_file" } return installer_yaml_fields + + +def register_vim(tacker_client, vim_file=None): + tmp_file = '/tmp/register-vim.json' + if vim_file is not None: + with open(vim_file) as f: + json_dict = json.load(f) + + json_dict['vim']['auth_url'] = CONST.__getattribute__('OS_AUTH_URL') + json_dict['vim']['auth_cred']['password'] = CONST.__getattribute__( + 'OS_PASSWORD') + + json.dump(json_dict, open(tmp_file, 'w')) + + os_tacker.create_vim(tacker_client, vim_file=tmp_file) |