Beispiel #1
0
    def create_candlepin_product(
        pool_uuid="unit_test_pool_id", product_id="unit_test_product_id", product_name="unit_test_product_name"
    ):
        from sreport.models import Product

        product = Product(
            product_id=product_id, name=product_name, created=datetime.now(tzutc()), updated=datetime.now(tzutc())
        )
        product.save()
        return product
Beispiel #2
0
    def create_products():
        # currently we rely on specific rhics to be created by the
        # generate_product_usage script in splice-server/playpen
        # assert that appears to be sane..

        num = RHIC.objects.all().count()
        if num != 9:
            raise Exception("rhics in rhic_serve db may not be valid")

        for key, value in PRODUCTS_DICT.items():
            # print('create_product', key)
            # print(RHIC.objects.count())
            # print(value[1])
            # all_rhics = RHIC.objects.all()
            rhic = RHIC.objects.filter(uuid=value[1])[0]
            contract_num = rhic.contract
            # print('contract_num', contract_num)
            # print('account_id', rhic.account_id)
            list_of_products = get_list_of_products(rhic.account_id, contract_num)

            products_contract = [(prod.name) for prod in list_of_products]
            intersect = set(products_contract).intersection(set(rhic.products))
            # print(intersect)
            if len(intersect) < 1:
                raise Exception("rhics and account/contracts in rhic_serve" "db may not be valid")

            for p in list_of_products:
                # print p.name
                if p.name == key:
                    row = Product(
                        quantity=p.quantity,
                        support_level=p.support_level,
                        sla=p.sla,
                        name=p.name,
                        engineering_ids=p.engineering_ids,
                    )
                    row.save()