From ff4536dcffc60330c0c483506c1f1ddac626f75c Mon Sep 17 00:00:00 2001 From: Toshiaki Takahashi Date: Mon, 10 Dec 2018 07:48:04 +0000 Subject: Fix anteater issues of baro_tests * Use yaml.safe_load instead of yaml.load * Not use curl (Use the file prepared by the procedure in the Functest Installation Guide) * Not use /tmp directoriy for security reasen * Add copyright to fix "Licence header missing" Change-Id: Ib4ad56e6a79d7f7d00058d5bd7c6690b8c360753 Signed-off-by: Toshiaki Takahashi --- baro_tests/barometer.py | 2 ++ baro_tests/collectd.py | 4 +++- baro_tests/config_server.py | 15 +++++++-------- baro_tests/local_agent.py | 8 ++++++-- baro_tests/tests.py | 4 +++- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/baro_tests/barometer.py b/baro_tests/barometer.py index a798f245..f75dbc31 100644 --- a/baro_tests/barometer.py +++ b/baro_tests/barometer.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # +# Copyright 2017 OPNFV +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/baro_tests/collectd.py b/baro_tests/collectd.py index 4148c27a..86871b47 100644 --- a/baro_tests/collectd.py +++ b/baro_tests/collectd.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- - +# +# Copyright 2017 OPNFV +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at diff --git a/baro_tests/config_server.py b/baro_tests/config_server.py index 71d4f152..d64a9146 100644 --- a/baro_tests/config_server.py +++ b/baro_tests/config_server.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- # +# Copyright 2017 OPNFV +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -35,6 +37,8 @@ APEX_IP = os.getenv("INSTALLER_IP").rstrip('\n') APEX_USER = 'root' APEX_USER_STACK = 'stack' APEX_PKEY = '/root/.ssh/id_rsa' +TEST_VM_IMAGE = 'cirros-0.4.0-x86_64-disk.img' +TEST_VM_IMAGE_PATH = '/home/opnfv/functest/images/' + TEST_VM_IMAGE class Node(object): @@ -381,7 +385,7 @@ class ConfigServer(object): '| sed -e "s/#.*$//" | sed -e "s/=/:/"' ) stdout = node.run_cmd(readcmd) - agent_conf = {"server": yaml.load(stdout)} + agent_conf = {"server": yaml.safe_load(stdout)} pingcmd = ( 'ping -n -c1 ' + agent_conf["server"]["amqp_host"] + @@ -793,18 +797,13 @@ class ConfigServer(object): self.__logger.debug('Create command is executed in {}' .format( (controller_node.get_dict()['name']))) - image_filename = 'cirros-0.4.0-x86_64-disk.img' - controller_node.run_cmd( - 'curl -sO ' - 'http://download.cirros-cloud.net/0.4.0/' - + image_filename) - node.put_file(constants.ENV_FILE, 'overcloudrc.v3') + node.put_file(TEST_VM_IMAGE_PATH, TEST_VM_IMAGE) image = controller_node.run_cmd( 'source overcloudrc.v3;' 'openstack image create -f value -c id' ' --disk-format qcow2 --file {0} {1}' - .format(image_filename, test_name)) + .format(TEST_VM_IMAGE, test_name)) flavor = controller_node.run_cmd( 'source overcloudrc.v3;' 'openstack flavor create -f value -c id {}' diff --git a/baro_tests/local_agent.py b/baro_tests/local_agent.py index 8201dee0..1a50d963 100644 --- a/baro_tests/local_agent.py +++ b/baro_tests/local_agent.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- - +# +# Copyright 2018 OPNFV +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -24,6 +26,8 @@ import tests logger = None +TEMP_DIR = '/root' + class LocalAgentClient(object): """Client to request LocalAgent""" @@ -201,7 +205,7 @@ def local_agent_main(bt_logger, conf, computes): if agent_server_running: test_name = 'barotest' - tmpfile = '/tmp/' + test_name + '.conf' + tmpfile = TEMP_DIR + '/' + test_name + '.conf' agent_config = conf.get_localagent_config(compute_node) listen_ip = compute_node.get_ip() diff --git a/baro_tests/tests.py b/baro_tests/tests.py index bd49583d..d315fcf1 100644 --- a/baro_tests/tests.py +++ b/baro_tests/tests.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- - +# +# Copyright 2017 OPNFV +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at -- cgit 1.2.3-korg