import yaml
-from opnfv.deployment import factory
-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 """
logger.info(" IS_CI_RUN=%s" % CONST.IS_CI_RUN)
-def print_deployment_info():
- handler = None
- if CONST.INSTALLER_IP:
- if CONST.INSTALLER_TYPE == 'apex':
- pkey = '/root/.ssh/id_rsa'
- if os.path.isfile(pkey):
- handler = factory.Factory.get_handler(CONST.INSTALLER_TYPE,
- CONST.INSTALLER_IP,
- 'stack',
- pkey_file=pkey)
- elif CONST.INSTALLER_TYPE == 'fuel':
- handler = factory.Factory.get_handler(CONST.INSTALLER_TYPE,
- CONST.INSTALLER_IP,
- 'root',
- installer_pwd='r00tme')
-
- if handler:
- logger.info('\n\nDeployment information:\n%s' %
- handler.get_deployment_info())
-
-
def create_directories():
print_separator()
logger.info("Creating needed directories...")
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):
elif kwargs['action'] == "start":
logger.info("######### Preparing Functest environment #########\n")
check_env_variables()
- print_deployment_info()
create_directories()
source_rc_file()
patch_config_file()
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: