Skip to content
Snippets Groups Projects

Feature/vrf

Merged Neda Moeini requested to merge feature/vrf into develop
All threads resolved!
2 files
+ 43
10
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -289,6 +289,26 @@ def get_all_active_sites() -> list[dict[str, Any]]:
]
def is_resource_type_value_unique(resource_type: str, value: str) -> bool:
"""Check if the given value for the specified resource type is unique in the database.
This function verifies if the specified value for the given resource type is not already in the core database.
:param resource_type: The resource type to check.
:type resource_type: str
:param value: The value to check.
:type value: str
:return: True if the value is unique (not found), False if it exists.
:rtype: bool
"""
exists = (
ResourceTypeTable.query.join(SubscriptionInstanceValueTable)
.filter(ResourceTypeTable.resource_type == resource_type, SubscriptionInstanceValueTable.value == value)
.scalar()
)
return exists is None
def is_virtual_circuit_id_available(virtual_circuit_id: str) -> bool:
"""Check if the given virtual circuit ID is unique in the database.
@@ -300,12 +320,17 @@ def is_virtual_circuit_id_available(virtual_circuit_id: str) -> bool:
:return: True if the virtual circuit ID is unique (not found), False if it exists.
:rtype: bool
"""
exists = (
ResourceTypeTable.query.join(SubscriptionInstanceValueTable)
.filter(
ResourceTypeTable.resource_type == "virtual_circuit_id",
SubscriptionInstanceValueTable.value == virtual_circuit_id,
)
.scalar()
)
return exists is None
return is_resource_type_value_unique("virtual_circuit_id", virtual_circuit_id)
def is_vrf_name_unique(vrf_name: str) -> bool:
"""Check if the given VRF name is unique in the database.
This function verifies if the specified VRF name is not already present in the core database.
:param vrf_name: The VRF name to check.
:type vrf_name: str
:return: True if the VRF name is unique (not found), False if it exists.
:rtype: bool
"""
return is_resource_type_value_unique("vrf_name", vrf_name)
Loading