- logger.info("Fetching RC file...")
-
- if CONST.openstack_creds is None:
- logger.warning("The environment variable 'creds' must be set and"
- "pointing to the local RC file. Using default: "
- "/home/opnfv/functest/conf/openstack.creds ...")
- os.path.join(CONST.dir_functest_conf, 'openstack.creds')
-
- if not os.path.isfile(CONST.openstack_creds):
- logger.info("RC file not provided. "
- "Fetching it from the installer...")
- if CONST.INSTALLER_IP is None:
- logger.error("The env variable CI_INSTALLER_IP must be provided in"
- " order to fetch the credentials from the installer.")
- raise Exception("Missing CI_INSTALLER_IP.")
- if CONST.INSTALLER_TYPE not in opnfv_constants.INSTALLERS:
- logger.error("Cannot fetch credentials. INSTALLER_TYPE=%s is "
- "not a valid OPNFV installer. Available "
- "installers are : %s." %
- (CONST.INSTALLER_TYPE,
- opnfv_constants.INSTALLERS))
- raise Exception("Wrong INSTALLER_TYPE.")
-
- cmd = ("/home/opnfv/repos/releng/utils/fetch_os_creds.sh "
- "-d %s -i %s -a %s"
- % (CONST.openstack_creds,
- CONST.INSTALLER_TYPE,
- CONST.INSTALLER_IP))
- logger.debug("Executing command: %s" % cmd)
- p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
- output = p.communicate()[0]
- logger.debug("\n%s" % output)
- if p.returncode != 0:
- raise Exception("Failed to fetch credentials from installer.")
- else:
- logger.info("RC file provided in %s."
- % CONST.openstack_creds)
- if os.path.getsize(CONST.openstack_creds) == 0:
- raise Exception("The file %s is empty." % CONST.openstack_creds)