Ejemplo n.º 1
0
def seed():
    FixedInputTable.query.delete()
    fixed_inputs = [
        FixedInputTable(name=PORT_SPEED, value=PORT_SPEED_VALUE),
        FixedInputTable(name=SERVICE_SPEED, value=SERVICE_SPEED_VALUE),
    ]
    product = ProductTable(
        product_id=PRODUCT_ID,
        name="ProductTable",
        description="description",
        product_type="Port",
        tag="SSP",
        status="active",
        fixed_inputs=fixed_inputs,
    )
    subscription = SubscriptionTable(
        subscription_id=SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=product,
        customer_id=uuid4(),
    )

    db.session.add(product)
    db.session.add(subscription)
    db.session.commit()
Ejemplo n.º 2
0
def create_subscription(**kwargs):
    attrs = {
        "description": "A subscription.",
        "customer_id": "85938c4c-0a11-e511-80d0-005056956c1a",
        "start_date": nowtz(),
        "status": "active",
        "insync": True,
        **kwargs,
    }
    o = SubscriptionTable(**attrs)
    db.session.add(o)
    db.session.commit()
    return o
Ejemplo n.º 3
0
def create_subscription(
    organisation: UUIDstr, product: ProductTable, subscription_name: str, subscription_id: UUIDstr
) -> UUID:
    subscription = SubscriptionTable(
        subscription_id=subscription_id,
        product_id=product.product_id,
        customer_id=organisation,
        description=subscription_name,
        start_date=None,
        end_date=None,
        insync=False,
        status="initial",
    )
    db.session.add(subscription)

    return subscription.subscription_id
def seed():
    product = ProductTable(
        name="ProductTable", description="description", product_type="Port", tag="Port", status="active"
    )
    subscription = SubscriptionTable(
        subscription_id=SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=product,
        customer_id=uuid4(),
        customer_descriptions=[
            SubscriptionCustomerDescriptionTable(
                id=SUBSCRIPTION_CUSTOMER_DESCRIPTION_ID, customer_id=CUSTOMER_ID, description="customer other alias"
            )
        ],
    )

    db.session.add(product)
    db.session.add(subscription)
    db.session.commit()
Ejemplo n.º 5
0
def seed():
    ProductTable.query.delete()
    resources = [
        ResourceTypeTable(resource_type=IMS_CIRCUIT_ID,
                          description="IMS circuit Id"),
    ]
    product_blocks = [
        ProductBlockTable(name="Ethernet",
                          description="d",
                          status="active",
                          resource_types=resources)
    ]
    fixed_inputs = [
        FixedInputTable(name=SERVICE_SPEED, value="1000"),
        FixedInputTable(name=CITY_TYPE, value="inner_city"),
        FixedInputTable(name="protection_type", value="Protected"),
    ]
    product = ProductTable(
        product_id=PRODUCT_ID,
        name="LightPath",
        description="descr",
        product_type="LightPath",
        tag="LightPath",
        status="active",
        product_blocks=product_blocks,
        fixed_inputs=fixed_inputs,
    )
    msp_product = ProductTable(
        product_id=MSP_PRODUCT_ID,
        name="MSP",
        description="descr",
        product_type="Port",
        tag="Port",
        status="active",
        product_blocks=product_blocks,
        fixed_inputs=[
            FixedInputTable(name=PORT_SPEED, value="1000"),
            FixedInputTable(name=DOMAIN, value="SURFNET7")
        ],
    )
    msp_product_100G = ProductTable(
        name="MSP 1100G",
        description="descr",
        product_type="Port",
        tag="Port",
        status="active",
        product_blocks=product_blocks,
        fixed_inputs=[
            FixedInputTable(name=PORT_SPEED, value="100000"),
            FixedInputTable(name="domain", value="SURFNET7"),
        ],
    )
    product_no_workflow = ProductTable(product_id=uuid4(),
                                       name="P",
                                       description="P",
                                       product_type="Port",
                                       tag="P",
                                       status="active")

    port_subscription_id = ResourceTypeTable(
        resource_type=PORT_SUBSCRIPTION_ID, description="Port Subscription Id")
    values = [
        SubscriptionInstanceValueTable(resource_type=port_subscription_id,
                                       value=str(depends_on_SUBSCRIPTION_ID))
    ]
    subscription = SubscriptionTable(
        subscription_id=SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=product,
        customer_id=uuid4(),
        instances=[
            SubscriptionInstanceTable(product_block=product_blocks[0],
                                      values=values)
        ],
    )
    depends_on_subscription = SubscriptionTable(
        subscription_id=depends_on_SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=msp_product,
        customer_id=uuid4(),
    )

    def lp_product(protection_type, product_id, speed="1000"):
        name = f"msp_ssp_{protection_type.lower()}"
        msp_ssp_fixed_inputs = [
            FixedInputTable(name="protection_type",
                            value=protection_type.capitalize()),
            FixedInputTable(name=SERVICE_SPEED, value=speed),
            FixedInputTable(name=CITY_TYPE, value="inner_city"),
        ]
        return ProductTable(
            product_id=product_id,
            name=f"name_{product_id}",
            description=name,
            product_type="LightPath",
            tag="LightPath",
            status="active",
            fixed_inputs=msp_ssp_fixed_inputs,
        )

    db.session.add(product)
    db.session.add(msp_product)
    db.session.add(msp_product_100G)
    db.session.add(lp_product("protected", uuid4(), speed="10000"))
    db.session.add(lp_product("protected", uuid4(), speed="750"))
    db.session.add(lp_product("redundant", REDUNDANT_MSP_SSP_ID))
    db.session.add(lp_product("protected", PROTECTED_MSP_SSP_ID, speed="250"))
    db.session.add(lp_product("unprotected", UNPROTECTED_MSP_SSP_ID))
    db.session.add(subscription)
    db.session.add(depends_on_subscription)
    db.session.add(product_no_workflow)
    db.session.commit()
Ejemplo n.º 6
0
def test_str_method():
    assert (
        str(SubscriptionTable()) ==
        "SubscriptionTable(subscription_id=None, description=None, status=None, product_id=None, customer_id=None, insync=None, start_date=None, end_date=None, note=None)"
    )
Ejemplo n.º 7
0
def seed():
    # These resource types are special
    resources = [
        ResourceTypeTable(resource_type=IMS_CIRCUIT_ID, description="Desc"),
        ResourceTypeTable(resource_type=PORT_SUBSCRIPTION_ID,
                          description="Desc"),
    ]
    product_blocks = [
        ProductBlockTable(name="ProductBlockA",
                          description="description a",
                          status="active",
                          resource_types=resources)
    ]
    fixed_inputs = [FixedInputTable(name="product_type", value="MSP100G")]
    # Wf needs to exist in code and needs to be a legacy wf with mapping

    lp_product = ProductTable(
        name="LightpathProduct",
        description="Service product that lives on ports",
        product_type="LightPath",
        tag=
        "LightPath",  # This is special since in_use_by/depends_on subscription code handles specific tags
        status="active",
        product_blocks=product_blocks,
        fixed_inputs=fixed_inputs,
    )
    port_a_product = ProductTable(
        product_id=PRODUCT_ID,
        name="PortAProduct",
        description="Port A description",
        product_type="Port",
        tag=
        "SP",  # This is special since in_use_by/depends_on subscription code handles specific tags
        status="active",
        product_blocks=product_blocks,
        fixed_inputs=fixed_inputs,
    )
    port_b_product = ProductTable(
        name="PortBProduct",
        description="Port B description",
        product_type="Port",
        tag="PORTB",
        status="active",
        product_blocks=product_blocks,
        fixed_inputs=fixed_inputs,
    )

    # Special resource type handled by get subscription by ipam prefix endpoint
    ip_prefix_resources = [
        ResourceTypeTable(resource_type=IPAM_PREFIX_ID,
                          description="Prefix id")
    ]
    ip_prefix_product_blocks = [
        ProductBlockTable(name="ProductBlockB",
                          description="description b",
                          status="active",
                          resource_types=ip_prefix_resources)
    ]
    ip_prefix_product = ProductTable(
        name="IPPrefixProduct",
        description="ProductTable that is used by service product",
        product_type="IP_PREFIX",
        tag="IP_PREFIX",
        status="active",
        product_blocks=ip_prefix_product_blocks,
    )
    ip_prefix_subscription = SubscriptionTable(
        subscription_id=IP_PREFIX_SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=ip_prefix_product,
        customer_id=CUSTOMER_ID,
        instances=[
            SubscriptionInstanceTable(
                product_block=ip_prefix_product_blocks[0],
                values=[
                    SubscriptionInstanceValueTable(
                        resource_type=ip_prefix_resources[0], value="26")
                ],
            )
        ],
    )

    port_a_subscription = SubscriptionTable(
        subscription_id=PORT_A_SUBSCRIPTION_ID,
        description="desc",
        status="initial",
        insync=True,
        product=port_a_product,
        customer_id=CUSTOMER_ID,
        instances=[
            SubscriptionInstanceTable(
                product_block=product_blocks[0],
                values=[
                    SubscriptionInstanceValueTable(resource_type=resources[0],
                                                   value="54321")
                ],
            )
        ],
    )

    provisioning_port_a_subscription = SubscriptionTable(
        subscription_id=PROVISIONING_PORT_A_SUBSCRIPTION_ID,
        description="desc",
        status="provisioning",
        insync=False,
        product=port_a_product,
        customer_id=CUSTOMER_ID,
        instances=[
            SubscriptionInstanceTable(
                product_block=product_blocks[0],
                values=[
                    SubscriptionInstanceValueTable(resource_type=resources[0],
                                                   value="12345")
                ],
            )
        ],
    )

    ssp_subscription = SubscriptionTable(
        subscription_id=SSP_SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=port_b_product,
        customer_id=CUSTOMER_ID,
        instances=[
            SubscriptionInstanceTable(
                product_block=product_blocks[0],
                values=[
                    SubscriptionInstanceValueTable(resource_type=resources[0],
                                                   value="54321")
                ],
            )
        ],
    )

    lp_subscription_instance_values_ssp = [
        SubscriptionInstanceValueTable(resource_type=resources[0],
                                       value="54321"),
        SubscriptionInstanceValueTable(resource_type=resources[1],
                                       value=str(PORT_A_SUBSCRIPTION_ID)),
    ]
    lp_subscription_instance_ssp = SubscriptionInstanceTable(
        product_block=product_blocks[0],
        values=lp_subscription_instance_values_ssp)
    lp_subscription_instance_values_msp = [
        SubscriptionInstanceValueTable(resource_type=resources[0],
                                       value="54321"),
        SubscriptionInstanceValueTable(resource_type=resources[1],
                                       value=str(SSP_SUBSCRIPTION_ID)),
    ]
    lp_subscription_instance_msp = SubscriptionInstanceTable(
        product_block=product_blocks[0],
        values=lp_subscription_instance_values_msp)
    lp_subscription = SubscriptionTable(
        subscription_id=SERVICE_SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=lp_product,
        customer_id=CUSTOMER_ID,
        instances=[lp_subscription_instance_ssp, lp_subscription_instance_msp],
    )

    invalid_subscription = SubscriptionTable(
        subscription_id=INVALID_SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=True,
        product=port_a_product,
        customer_id=CUSTOMER_ID,
        instances=[],
    )

    invalid_tagged_product = ProductTable(
        product_id=str(uuid4()),
        name="INVALID_PRODUCT",
        description="invalid descr",
        product_type="Port",
        tag="NEWMSP",
        status="active",
        product_blocks=product_blocks,
        fixed_inputs=fixed_inputs,
    )

    invalid_tagged_subscription = SubscriptionTable(
        subscription_id=INVALID_PORT_SUBSCRIPTION_ID,
        description="desc",
        status="active",
        insync=False,
        product=invalid_tagged_product,
        customer_id=CUSTOMER_ID,
        instances=[
            SubscriptionInstanceTable(
                product_block=product_blocks[0],
                values=[
                    SubscriptionInstanceValueTable(resource_type=resources[0],
                                                   value="54321")
                ],
            )
        ],
    )
    db.session.add(port_a_product)
    db.session.add(ip_prefix_product)
    db.session.add(ip_prefix_subscription)
    db.session.add(invalid_tagged_product)
    db.session.add(port_b_product)
    db.session.add(lp_product)
    db.session.add(port_a_subscription)
    db.session.add(provisioning_port_a_subscription)
    db.session.add(ssp_subscription)
    db.session.add(lp_subscription)
    db.session.add(invalid_subscription)
    db.session.add(invalid_tagged_subscription)
    db.session.commit()

    RELATION_RESOURCE_TYPES.extend([
        PORT_SUBSCRIPTION_ID,
        IP_PREFIX_SUBSCRIPTION_ID,
        INTERNETPINNEN_PREFIX_SUBSCRIPTION_ID,
        PARENT_IP_PREFIX_SUBSCRIPTION_ID,
        PEER_GROUP_SUBSCRIPTION_ID,
    ])

    return ip_prefix_product