Fix for Functest 'BarometerCollectd ERROR - Private key file not found' 11/30211/3
authorCalin Gherghe <calin.gherghe@intel.com>
Thu, 9 Mar 2017 11:55:30 +0000 (06:55 -0500)
committerCalin Gherghe <calin.gherghe@intel.com>
Fri, 10 Mar 2017 17:28:59 +0000 (17:28 +0000)
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>
baro_tests/collectd.py
baro_tests/config_server.py
baro_utils/get_ssh_keys.sh [deleted file]

index 3f2067a..505e617 100644 (file)
@@ -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!')
index 4d64926..358a8ff 100644 (file)
@@ -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 (executable)
index f90c32c..0000000
+++ /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/