diff options
author | Calin Gherghe <calin.gherghe@intel.com> | 2017-03-09 06:55:30 -0500 |
---|---|---|
committer | Calin Gherghe <calin.gherghe@intel.com> | 2017-03-10 17:28:59 +0000 |
commit | 1573180333a8b1a49dc21f6412f53fff01fe351e (patch) | |
tree | 63e8a7f213b5a37e2731f1feebcb19de8e46cffe | |
parent | 5649793d2037d6f26211be4035e28842ebb3e737 (diff) |
Fix for Functest 'BarometerCollectd ERROR - Private key file not found'
This patch addresses the blocking Functest issue regarding the ssh keys.
It eliminates the need of using the baro_utils/get_ssh_keys.sh script.
Change-Id: I4499e48257ddab955ae6694c2ece0bff5e877cad
Signed-off-by: Calin Gherghe <calin.gherghe@intel.com>
-rw-r--r-- | baro_tests/collectd.py | 25 | ||||
-rw-r--r-- | baro_tests/config_server.py | 3 | ||||
-rwxr-xr-x | baro_utils/get_ssh_keys.sh | 16 |
3 files changed, 25 insertions, 19 deletions
diff --git a/baro_tests/collectd.py b/baro_tests/collectd.py index 3f2067af..505e617b 100644 --- a/baro_tests/collectd.py +++ b/baro_tests/collectd.py @@ -20,8 +20,18 @@ import time import logging from config_server import * from tests import * +from opnfv.deployment import factory +from functest.utils import functest_utils +from functest.utils.constants import CONST CEILOMETER_NAME = 'ceilometer' +ID_RSA_SRC = '/root/.ssh/id_rsa' +ID_RSA_DST_DIR = '/home/opnfv/.ssh' +ID_RSA_DST = ID_RSA_DST_DIR + '/id_rsa' +INSTALLER_PARAMS_YAML = os.path.join(CONST.dir_repo_functest, 'functest/ci/installer_params.yaml') +FUEL_IP = functest_utils.get_parameter_from_yaml('fuel.ip', INSTALLER_PARAMS_YAML) +FUEL_USER = functest_utils.get_parameter_from_yaml('fuel.user', INSTALLER_PARAMS_YAML) +FUEL_PW = functest_utils.get_parameter_from_yaml('fuel.password', INSTALLER_PARAMS_YAML) class KeystoneException(Exception): @@ -386,6 +396,17 @@ def _exec_testcase( res = False _process_result(compute_node.get_id(), test_labels[name], res, results) +def get_ssh_keys(): + if not os.path.isdir(ID_RSA_DST_DIR): + os.makedirs(ID_RSA_DST_DIR) + if not os.path.isfile(ID_RSA_DST): + logger.info("RSA key file {} doesn't exist, it will be downloaded from instaler node.".format(ID_RSA_DST)) + handler = factory.Factory.get_handler('fuel', FUEL_IP, FUEL_USER, installer_pwd=FUEL_PW) + fuel = handler.get_installer_node() + fuel.get_file(ID_RSA_SRC, ID_RSA_DST) + else: + logger.info("RSA key file {} exists.".format(ID_RSA_DST)) + def main(bt_logger=None): """Check each compute node sends ceilometer metrics. @@ -395,12 +416,14 @@ def main(bt_logger=None): """ logging.getLogger("paramiko").setLevel(logging.WARNING) logging.getLogger("stevedore").setLevel(logging.WARNING) + logging.getLogger("opnfv.deployment.manager").setLevel(logging.WARNING) if bt_logger is None: _check_logger() else: global logger logger = bt_logger - conf = ConfigServer('10.20.0.2', 'root', logger) + get_ssh_keys() + conf = ConfigServer(FUEL_IP, FUEL_USER, logger) controllers = conf.get_controllers() if len(controllers) == 0: logger.error('No controller nodes found!') diff --git a/baro_tests/config_server.py b/baro_tests/config_server.py index 4d649269..358a8ffe 100644 --- a/baro_tests/config_server.py +++ b/baro_tests/config_server.py @@ -69,8 +69,7 @@ class ConfigServer(object): self.__private_key_file = ID_RSA_PATH if not os.path.isfile(self.__private_key_file): self.__logger.error( - "Private key file '{}'".format(self.__private_key_file) - + " not found. Please try to run {} script.".format(SSH_KEYS_SCRIPT)) + "Private key file '{}' not found.".format(self.__private_key_file)) raise IOError("Private key file '{}' not found.".format(self.__private_key_file)) # get list of available nodes diff --git a/baro_utils/get_ssh_keys.sh b/baro_utils/get_ssh_keys.sh deleted file mode 100755 index f90c32c9..00000000 --- a/baro_utils/get_ssh_keys.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# -*- coding: utf-8 -*- - -#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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -mkdir -p /home/opnfv/.ssh/ -scp root@"$INSTALLER_IP":/root/.ssh/* /home/opnfv/.ssh/ |