Add deployment_handler printout to prepare env 33/29033/5
authorjose.lausuch <jose.lausuch@ericsson.com>
Sat, 18 Feb 2017 18:15:37 +0000 (19:15 +0100)
committerJose Lausuch <jose.lausuch@ericsson.com>
Tue, 21 Feb 2017 19:54:53 +0000 (19:54 +0000)
Example virtual deployment apex:
 http://paste.openstack.org/raw/599536/

Example CI POD:
 http://paste.openstack.org/raw/599537/

Change-Id: I0711b45a525bc074a9c05f0ea3a194b2db05f2d9
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
functest/ci/installer_params.yaml [new file with mode: 0644]
functest/ci/prepare_env.py
functest/utils/functest_logger.py

diff --git a/functest/ci/installer_params.yaml b/functest/ci/installer_params.yaml
new file mode 100644 (file)
index 0000000..bffa894
--- /dev/null
@@ -0,0 +1,16 @@
+apex:
+    ip: ''
+    user: 'stack'
+    pkey: '/root/.ssh/id_rsa'
+#compass:
+#    ip: ''
+#    user: 'root'
+#    password: 'root'
+fuel:
+    ip: '10.20.0.2'
+    user: 'root'
+    password: 'r00tme'
+#joid:
+#    ip: ''
+#    user: ''
+#    password: ''
index 6b24fe0..80bcfc7 100755 (executable)
@@ -21,13 +21,15 @@ import subprocess
 import sys
 
 import yaml
-from opnfv.utils import constants as opnfv_constants
 
 import functest.utils.functest_logger as ft_logger
 import functest.utils.functest_utils as ft_utils
 import functest.utils.openstack_utils as os_utils
 from functest.utils.constants import CONST
 
+from opnfv.utils import constants as opnfv_constants
+from opnfv.deployment import factory
+
 actions = ['start', 'check']
 
 """ logging configuration """
@@ -278,6 +280,32 @@ def check_environment():
     logger.info("Functest environment is installed.")
 
 
+def print_deployment_info():
+    installer_params_yaml = os.path.join(CONST.dir_repo_functest,
+                                         'functest/ci/installer_params.yaml')
+    if (CONST.INSTALLER_IP and CONST.INSTALLER_TYPE and
+            CONST.INSTALLER_TYPE in opnfv_constants.INSTALLERS):
+        installer_params = ft_utils.get_parameter_from_yaml(
+            CONST.INSTALLER_TYPE, installer_params_yaml)
+
+        user = installer_params.get('user', None)
+        password = installer_params.get('password', None)
+        pkey = installer_params.get('pkey', None)
+
+        try:
+            handler = factory.Factory.get_handler(
+                installer=CONST.INSTALLER_TYPE,
+                installer_ip=CONST.INSTALLER_IP,
+                installer_user=user,
+                installer_pwd=password,
+                pkey_file=pkey)
+            if handler:
+                logger.info('\n\nDeployment information:\n%s' %
+                            handler.get_deployment_info())
+        except Exception as e:
+            logger.debug("Cannot get deployment information. %s" % e)
+
+
 def main(**kwargs):
     try:
         if not (kwargs['action'] in actions):
@@ -296,6 +324,7 @@ def main(**kwargs):
             with open(CONST.env_active, "w") as env_file:
                 env_file.write("1")
             check_environment()
+            print_deployment_info()
         elif kwargs['action'] == "check":
             check_environment()
     except Exception as e:
index 0cba8c5..6dc46ef 100755 (executable)
@@ -30,9 +30,11 @@ from functest.utils.constants import CONST
 
 
 class Logger:
+
     def __init__(self, logger_name):
         self.setup_logging()
         self.logger = logging.getLogger(logger_name)
+        logging.getLogger("paramiko").setLevel(logging.WARNING)
 
     def getLogger(self):
         return self.logger