-def get_products_list(options, cfg, logger):
- '''method that gives the product list with their informations from
- configuration regarding the passed options.
-
- :param options Options: The Options instance that stores the commands
- arguments
- :param cfg Config: The global configuration
- :param logger Logger: The logger instance to use for the display and
- logging
- :return: The list of (product name, product_informations).
- :rtype: List
- '''
- # Get the products to be prepared, regarding the options
- if options.products is None:
- # No options, get all products sources
- products = cfg.APPLICATION.products
- else:
- # if option --products, check that all products of the command line
- # are present in the application.
- products = options.products
- for p in products:
- if p not in cfg.APPLICATION.products:
- raise src.SatException(_("Product %(product)s "
- "not defined in application %(application)s") %
- { 'product': p, 'application': cfg.VARS.application} )
-
- # Construct the list of tuple containing
- # the products name and their definition
- products_infos = src.product.get_products_infos(products, cfg)
-
- # if the property option was passed, filter the list
- if options.properties:
- [prop, value] = options.properties.split(":")
- products_infos = [(p_name, p_info) for
- (p_name, p_info) in products_infos
- if "properties" in p_info and
- prop in p_info.properties and
- p_info.properties[prop] == value]
-
-
- # get rid of fixed products
- products_infos = [pi for pi in products_infos if not(
- src.product.product_is_fixed(pi[1]))]
-
- return products_infos