Пример #1
0
def create_tier_if_not_exists(
    network_id: str,
    tier_id: str,
    admin_cert: types.ClientCert = types.ClientCert(
        cert='./../../.cache/test_certs/admin_operator.pem',
        key='./../../.cache/test_certs/admin_operator.key.pem',
    ),
) -> None:
    """
    Create a placeholder tier on Orchestrator if the specified one doesn't
    already exist.

    Args:
        network_id: Network the tier belongs to
        tier_id: ID for the tier
        admin_cert: Cert for API access
    """
    tiers = cloud_get(f'networks/{network_id}/tiers', admin_cert=admin_cert)
    if tier_id in tiers:
        return

    tier_payload = types.Tier(
        id=tier_id,
        version='0.0.0-0',
        images=[],
        gateways=[],
    )
    cloud_post(
        f'networks/{network_id}/tiers',
        tier_payload,
        admin_cert=admin_cert,
    )
Пример #2
0
def create_tier_if_not_exists(
    network_id: str,
    tier_id: str,
    url: Optional[str] = None,
    admin_cert: Optional[types.ClientCert] = None,
) -> None:
    """
    Create a placeholder tier on Orchestrator if the specified one doesn't
    already exist.

    Args:
        network_id: Network the tier belongs to
        tier_id: ID for the tier
        url: API base URL
        admin_cert: Cert for API access
    """
    tiers = cloud_get(f'networks/{network_id}/tiers', url, admin_cert)

    if tier_id in tiers:
        return

    tier_payload = types.Tier(
        id=tier_id,
        version='0.0.0-0',
        images=[],
        gateways=[],
    )
    cloud_post(
        f'networks/{network_id}/tiers',
        tier_payload,
        admin_cert=admin_cert,
    )