diff options
Diffstat (limited to 'functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py')
-rw-r--r-- | functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py b/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py index 814e9e333..46584456f 100644 --- a/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py +++ b/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py @@ -7,14 +7,17 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 +# pylint: disable=missing-docstring + """vrouter controll module""" import logging import os -import prettytable import time import yaml +import prettytable + from functest.opnfv_tests.vnf.router.utilvnf import Utilvnf from functest.opnfv_tests.vnf.router.vnf_controller.checker import Checker from functest.opnfv_tests.vnf.router.vnf_controller.ssh_client import ( @@ -23,7 +26,7 @@ from functest.opnfv_tests.vnf.router.vnf_controller.vm_controller import ( VmController) -class VnfController(object): +class VnfController(): """vrouter controll class""" logger = logging.getLogger(__name__) @@ -33,7 +36,7 @@ class VnfController(object): self.util = Utilvnf() self.vm_controller = VmController(util_info) - with open(self.util.test_env_config_yaml) as file_fd: + with open(self.util.test_env_config_yaml, encoding='utf-8') as file_fd: test_env_config_yaml = yaml.safe_load(file_fd) file_fd.close() @@ -45,10 +48,10 @@ class VnfController(object): def config_vnf(self, source_vnf, destination_vnf, test_cmd_file_path, parameter_file_path, prompt_file_path): - parameter_file = open(parameter_file_path, - 'r') - cmd_input_param = yaml.safe_load(parameter_file) - parameter_file.close() + # pylint: disable=too-many-arguments + with open( + parameter_file_path, 'r', encoding='utf-8') as parameter_file: + cmd_input_param = yaml.safe_load(parameter_file) cmd_input_param["macaddress"] = source_vnf["data_plane_network_mac"] cmd_input_param["source_ip"] = source_vnf["data_plane_network_ip"] @@ -63,22 +66,20 @@ class VnfController(object): def result_check(self, target_vnf, reference_vnf, check_rule_file_path_list, parameter_file_path, prompt_file_path): + # pylint: disable=too-many-arguments,too-many-locals res_dict_data_list = [] - parameter_file = open(parameter_file_path, - 'r') - cmd_input_param = yaml.safe_load(parameter_file) - parameter_file.close() + with open( + parameter_file_path, 'r', encoding='utf-8') as parameter_file: + cmd_input_param = yaml.safe_load(parameter_file) cmd_input_param["source_ip"] = target_vnf["data_plane_network_ip"] cmd_input_param["destination_ip"] = reference_vnf[ "data_plane_network_ip"] - prompt_file = open(prompt_file_path, - 'r') - prompt = yaml.safe_load(prompt_file) - prompt_file.close() + with open(prompt_file_path, 'r', encoding='utf-8') as prompt_file: + prompt = yaml.safe_load(prompt_file) terminal_mode_prompt = prompt["terminal_mode"] ssh = SshClient(target_vnf["floating_ip"], @@ -93,8 +94,8 @@ class VnfController(object): checker = Checker() res_table = prettytable.PrettyTable( - header_style='upper', padding_width=5, - field_names=['test item', 'result']) + header_style='upper', padding_width=5, + field_names=['test item', 'result']) status = True res_data_list = [] |