def setUp(self): """Set up the default loader.""" self.maxDiff = None self._loader = ProductLoader() self._loader.load_products(PRODUCT_DIR)
def set_from_product(self, requested_product="", requested_variant="", buildstamp_product="", buildstamp_variant="", default_product=""): """Set the configuration from the product configuration files. We will use configuration files of a product requested by the user if any. Otherwise, we will use a product specified by the .buildstamp file or a default product. The configuration files are loaded from /etc/anaconda/product.d. :param str requested_product: a name of the requested product :param str requested_variant: a name of the requested variant :param str buildstamp_product: a name of the product from .buildstamp :param str buildstamp_variant: a name of the variant from .buildstamp :param str default_product: a name of the default product """ loader = ProductLoader() loader.load_products(os.path.join(ANACONDA_CONFIG_DIR, "product.d")) # Use the requested product name and variant name. if requested_product: if not loader.check_product(requested_product, requested_variant): raise ConfigurationError( "Unable to find any suitable configuration files for " "the product name '{}' and the variant name '{}'." "".format(requested_product, requested_variant) ) product_name = requested_product variant_name = requested_variant # Or use the product name and the variant name from .buildstamp. elif loader.check_product(buildstamp_product, buildstamp_variant): product_name = buildstamp_product variant_name = buildstamp_variant # Or the product name from .buildstamp. elif loader.check_product(buildstamp_product): product_name = buildstamp_product variant_name = "" # Or use the default product name. elif loader.check_product(default_product): product_name = default_product variant_name = "" # Or use no product configuration. else: log.warning( "Unable to find any suitable configuration files for the detected " "product and variant names. No product configuration will be used." ) return # Read the configuration files of the product. config_paths = loader.collect_configurations(product_name, variant_name) for config_path in config_paths: self.read(config_path) self.validate()