Skip to content

Netbox router

A router that must be present in Netbox.

validate_router_in_netbox(subscription_id)

Verify if a device exists in Netbox.

Parameters:

Name Type Description Default
subscription_id UUIDstr

The UUID of the router subscription.

required

Returns:

Type Description
UUIDstr

The UUID of the router subscription.

Raises:

Type Description
ValueError

if the device is not found.

Source code in gso/utils/types/netbox_router.py
def validate_router_in_netbox(subscription_id: UUIDstr) -> UUIDstr:
    """Verify if a device exists in Netbox.

    Args:
        subscription_id: The UUID of the router subscription.

    Returns:
        The UUID of the router subscription.

    Raises:
        ValueError: if the device is not found.
    """
    router_type = Router.from_subscription(subscription_id)
    if router_type.router.vendor == Vendor.NOKIA:
        device = NetboxClient().get_device_by_name(router_type.router.router_fqdn)
        if not device:
            msg = "The selected router does not exist in Netbox."
            raise ValueError(msg)
    return subscription_id