コード例 #1
0
def process_the_list_of_tiers(step):
    """
    Lettuce step. This function parses dataset to prepare each tier data.
     Tiers list will be returned with the tiers parsed from dataset
    :param step: Lettuce step with all data about tiers
    :return: List of processed tiers from step data
    """
    tier_list = list()
    for row in step.hashes:
        data = dataset_utils.prepare_data(row)
        tier = Tier(data.get(NAME), world.config[PAAS][TIER_IMAGE])
        tier.parse_and_add_products(data.get(PRODUCTS))

        if TIER_REQUEST_IMAGE in data:
            tier.tier_image = data.get(TIER_REQUEST_IMAGE)

        if TIER_REQUEST_REGION in data:
            tier.region = data.get(TIER_REQUEST_REGION)

        # For each product, check if there are defined attributes
        for paas_product_with_attributes in world.paas_product_list_with_attributes:
            for attribute in paas_product_with_attributes['attributes']:
                attribute_type = attribute['type'] if 'type' in attribute else None
                tier.add_attribute_to_product(paas_product_with_attributes['name'], attribute['key'],
                                              attribute['value'], attribute_type)

        tier.parse_and_add_networks(data.get(NETWORKS))
        tier_list.append(tier)

    return tier_list