def pytest_configure(config): """ Load config files, and initialize ocs-ci library. Args: config (pytest.config): Pytest config object """ if not (config.getoption("--help") or config.getoption("collectonly")): process_cluster_cli_params(config) config_file = os.path.expanduser( os.path.join( ocsci_config.RUN['log_dir'], f"run-{ocsci_config.RUN['run_id']}-config.yaml", )) dump_config_to_file(config_file) log.info(f"Dump of the consolidated config file is located here: " f"{config_file}") # Add OCS related versions to the html report and remove extraneous metadata markers_arg = config.getoption('-m') if ocsci_config.RUN['cli_params'].get('teardown') or ( "deployment" in markers_arg and ocsci_config.RUN['cli_params'].get('deploy')): log.info( "Skiping versions collecting because: Deploy or destroy of " "cluster is performed.") return print("Collecting Cluster versions") # remove extraneous metadata del config._metadata['Python'] del config._metadata['Packages'] del config._metadata['Plugins'] del config._metadata['Platform'] config._metadata['Test Run Name'] = get_testrun_name() try: # add cluster version clusterversion = get_cluster_version() config._metadata['Cluster Version'] = clusterversion # add ceph version ceph_version = get_ceph_version() config._metadata['Ceph Version'] = ceph_version # add rook version rook_version = get_rook_version() config._metadata['Rook Version'] = rook_version # add csi versions csi_versions = get_csi_versions() config._metadata['csi-provisioner'] = csi_versions.get( 'csi-provisioner') config._metadata['cephfsplugin'] = csi_versions.get( 'csi-cephfsplugin') config._metadata['rbdplugin'] = csi_versions.get('csi-rbdplugin') except (FileNotFoundError, CommandFailed): pass
def gather_version_info_for_report(config): """ This function gather all version related info used for report. Args: config (pytest.config): Pytest config object """ gather_version_completed = False try: # add cluster version clusterversion = get_cluster_version() config._metadata['Cluster Version'] = clusterversion # add ceph version ceph_version = get_ceph_version() config._metadata['Ceph Version'] = ceph_version # add csi versions csi_versions = get_csi_versions() config._metadata['cephfsplugin'] = csi_versions.get('csi-cephfsplugin') config._metadata['rbdplugin'] = csi_versions.get('csi-rbdplugin') # add ocs operator version if ocsci_config.REPORTING['us_ds'] == 'DS': config._metadata['OCS operator'] = ( get_ocs_build_number() ) mods = {} mods = get_version_info( namespace=ocsci_config.ENV_DATA['cluster_namespace'] ) skip_list = ['ocs-operator'] for key, val in mods.items(): if key not in skip_list: config._metadata[key] = val.rsplit('/')[-1] gather_version_completed = True except ResourceNotFoundError as ex: log.error( "Problem ocurred when looking for some resource! Error: %s", ex ) except FileNotFoundError as ex: log.error("File not found! Error: %s", ex) except CommandFailed as ex: log.error("Failed to execute command! Error: %s", ex) except Exception as ex: log.error("Failed to gather version info! Error: %s", ex) finally: if not gather_version_completed: log.warning( "Failed to gather version details! The report of version might" "not be complete!" )
def pytest_configure(config): """ Load config files, and initialize ocs-ci library. Args: config (pytest.config): Pytest config object """ if not config.getoption("--help"): process_cluster_cli_params(config) # Add OCS related versions to the html report and remove extraneous metadata markers_arg = config.getoption('-m') if ocsci_config.RUN['cli_params'].get('teardown') or ( "deployment" in markers_arg and ocsci_config.RUN['cli_params'].get('deploy')): log.info( "Skiping versions collecting because: Deploy or destroy of " "cluster is performed.") return print("Collecting Cluster versions") # remove extraneous metadata del config._metadata['Python'] del config._metadata['Packages'] del config._metadata['Plugins'] del config._metadata['Platform'] try: # add cluster version clusterversion = get_cluster_version() config._metadata['Cluster Version'] = clusterversion # add ceph version ceph_version = get_ceph_version() config._metadata['Ceph Version'] = ceph_version # add rook version rook_version = get_rook_version() config._metadata['Rook Version'] = rook_version # add csi versions csi_versions = get_csi_versions() config._metadata['csi-provisioner'] = csi_versions.get( 'csi-provisioner') config._metadata['cephfsplugin'] = csi_versions.get('cephfsplugin') config._metadata['rbdplugin'] = csi_versions.get('rbdplugin') except (FileNotFoundError, CommandFailed): pass
def gather_version_info_for_report(config): """ This function gather all version related info used for report. Args: config (pytest.config): Pytest config object """ gather_version_completed = False try: # add cluster version clusterversion = get_cluster_version() config._metadata["Cluster Version"] = clusterversion # add ceph version if not ocsci_config.ENV_DATA["mcg_only_deployment"]: ceph_version = get_ceph_version() config._metadata["Ceph Version"] = ceph_version # add csi versions csi_versions = get_csi_versions() config._metadata["cephfsplugin"] = csi_versions.get( "csi-cephfsplugin") config._metadata["rbdplugin"] = csi_versions.get("csi-rbdplugin") # add ocs operator version config._metadata["OCS operator"] = get_ocs_build_number() mods = {} mods = get_version_info( namespace=ocsci_config.ENV_DATA["cluster_namespace"]) skip_list = ["ocs-operator"] for key, val in mods.items(): if key not in skip_list: config._metadata[key] = val.rsplit("/")[-1] gather_version_completed = True except ResourceNotFoundError: log.exception("Problem occurred when looking for some resource!") except FileNotFoundError: log.exception("File not found!") except CommandFailed: log.exception("Failed to execute command!") except Exception: log.exception("Failed to gather version info!") finally: if not gather_version_completed: log.warning( "Failed to gather version details! The report of version might" "not be complete!")
def __init__(self, rhel_worker_nodes): """ Initializes the required variables, create rhelpod, upload all the helper files to pod and install required packages. Args: rhel_worker_nodes (list): list of RHEL nodes e.g:['rhel1-0.vavuthu.qe.rh-ocs.com', 'rhel1-1.vavuthu.qe.rh-ocs.com', 'rhel1-2.vavuthu.qe.rh-ocs.com'] """ self.rhel_worker_nodes = rhel_worker_nodes self.ssh_key_pem = config.DEPLOYMENT['ssh_key_private'] self.pod_ssh_key_pem = os.path.join(constants.POD_UPLOADPATH, self.ssh_key_pem.split("/")[-1]) self.ops_mirror_pem = os.path.join(f"{constants.DATA_DIR}", constants.OCP_PEM) self.cluster_path = config.ENV_DATA['cluster_path'] self.kubeconfig = os.path.join(config.ENV_DATA['cluster_path'], config.RUN.get('kubeconfig_location')) self.pod_name = "rhelpod" self.pull_secret_path = os.path.join(constants.TOP_DIR, "data", "pull-secret") self.pod_pull_secret_path = os.path.join(constants.POD_UPLOADPATH, "pull-secret") self.pod_kubeconfig_path = os.path.join( constants.POD_UPLOADPATH, config.RUN.get('kubeconfig_location').split("/")[-1]) self.rhelpod = create_rhelpod(constants.DEFAULT_NAMESPACE, self.pod_name) # map the cluster version with constants.REPO_MAPPING cluster_version = get_cluster_version() version_obj = Version(cluster_version) version = ".".join( map(str, [version_obj.major, version_obj.minor, version_obj.patch])) self.ocp_repo = constants.REPO_MAPPING[version] # Upload helper files to pod for OCP installation on RHEL self.upload_helpers(self.ocp_repo) # Install packages in pod self.rhelpod.install_packages(constants.RHEL_POD_PACKAGES)
def pytest_configure(config): """ Load config files, and initialize ocs-ci library. Args: config (pytest.config): Pytest config object """ if not (config.getoption("--help") or config.getoption("collectonly")): process_cluster_cli_params(config) config_file = os.path.expanduser( os.path.join( ocsci_config.RUN['log_dir'], f"run-{ocsci_config.RUN['run_id']}-config.yaml", )) dump_config_to_file(config_file) log.info(f"Dump of the consolidated config file is located here: " f"{config_file}") # Add OCS related versions to the html report and remove extraneous metadata markers_arg = config.getoption('-m') if ocsci_config.RUN['cli_params'].get('teardown') or ( "deployment" in markers_arg and ocsci_config.RUN['cli_params'].get('deploy')): log.info( "Skiping versions collecting because: Deploy or destroy of " "cluster is performed.") return print("Collecting Cluster versions") # remove extraneous metadata del config._metadata['Python'] del config._metadata['Packages'] del config._metadata['Plugins'] del config._metadata['Platform'] config._metadata['Test Run Name'] = get_testrun_name() try: # add cluster version clusterversion = get_cluster_version() config._metadata['Cluster Version'] = clusterversion # add ceph version ceph_version = get_ceph_version() config._metadata['Ceph Version'] = ceph_version # add csi versions csi_versions = get_csi_versions() config._metadata['cephfsplugin'] = csi_versions.get( 'csi-cephfsplugin') config._metadata['rbdplugin'] = csi_versions.get('csi-rbdplugin') # add ocs operator version ocs_catalog = CatalogSource( resource_name=OPERATOR_CATALOG_SOURCE_NAME, namespace="openshift-marketplace") if ocsci_config.REPORTING['us_ds'] == 'DS': config._metadata['OCS operator'] = ( ocs_catalog.get_image_name()) mods = get_version_info( namespace=ocsci_config.ENV_DATA['cluster_namespace']) skip_list = ['ocs-operator'] for key, val in mods.items(): if key not in skip_list: config._metadata[key] = val.rsplit('/')[-1] except (FileNotFoundError, CommandFailed): pass