Skip to content
Snippets Groups Projects
Verified Commit e5568160 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

add two subscription services that return all active IP trunks, and all trunks...

add two subscription services that return all active IP trunks, and all trunks that terminate on a given router subscription
parent c9fd0e09
No related branches found
No related tags found
1 merge request!126Add iBGP workflow and LibreNMS client
......@@ -15,7 +15,9 @@ from orchestrator.db import (
SubscriptionInstanceValueTable,
SubscriptionTable,
)
from orchestrator.services.subscriptions import query_in_use_by_subscriptions
from orchestrator.types import SubscriptionLifecycle
from pydantic_forms.types import UUIDstr
from gso.products import ProductType
......@@ -85,6 +87,38 @@ def get_active_router_subscriptions(
return get_active_subscriptions(product_type="Router", includes=includes)
def get_active_iptrunk_subscriptions(
includes: list[str] | None = None,
) -> list[SubscriptionType]:
"""Retrieve active subscriptions specifically for IP trunks.
:param includes: The fields to be included in the returned Subscription objects.
:type includes: list[str]
:return: A list of Subscription objects for IP trunks.
:rtype: list[Subscription]
"""
return get_active_subscriptions(product_type="Iptrunk", includes=includes)
def get_active_trunks_that_terminate_on_router(subscription_id: UUIDstr) -> list[SubscriptionTable]:
"""Get all IP trunk subscriptions that are active, and terminate on the given ``subscription_id`` of a Router.
Given a ``subscription_id`` of a Router subscription, this method gives a list of all active IP trunk subscriptions
that terminate on this Router.
:param subscription_id: Subscription ID of a Router
:type subscription_id: UUIDstr
:return: A list of IP trunk subscriptions
:rtype: list[SubscriptionTable]
"""
return query_in_use_by_subscriptions(UUID(subscription_id)).join(ProductTable).filter(
ProductTable.product_type == "Iptrunk",
SubscriptionTable.status == "active"
).all()
def get_product_id_by_name(product_name: ProductType) -> UUID:
"""Retrieve the :term:`UUID` of a product by its name.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment