Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
ee42b712
Verified
Commit
ee42b712
authored
11 months ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
Check if other IP trunk subscriptions are already overlapping with assigned IP resources
parent
8b503e03
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#88409
passed
11 months ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/services/subscriptions.py
+13
-0
13 additions, 0 deletions
gso/services/subscriptions.py
gso/workflows/iptrunk/create_iptrunk.py
+33
-1
33 additions, 1 deletion
gso/workflows/iptrunk/create_iptrunk.py
with
46 additions
and
1 deletion
gso/services/subscriptions.py
+
13
−
0
View file @
ee42b712
...
...
@@ -138,6 +138,19 @@ def get_active_iptrunk_subscriptions(includes: list[str] | None = None) -> list[
)
def
get_non_terminated_iptrunk_subscriptions
(
includes
:
list
[
str
]
|
None
=
None
)
->
list
[
SubscriptionType
]:
"""
Retrieve all IP trunk subscriptions that are not terminated.
:param list[Subscription] includes: Fields to be included in the returned Subscription objects.
:return list[Subscription]: A list of IP trunk subscriptions.
"""
return
get_subscriptions
(
product_types
=
[
ProductType
.
IP_TRUNK
],
lifecycles
=
[
SubscriptionLifecycle
.
INITIAL
,
SubscriptionLifecycle
.
PROVISIONING
,
SubscriptionLifecycle
.
ACTIVE
],
includes
=
includes
,
)
def
get_trunks_that_terminate_on_router
(
subscription_id
:
UUIDstr
,
lifecycle_state
:
SubscriptionLifecycle
)
->
list
[
SubscriptionTable
]:
...
...
This diff is collapsed.
Click to expand it.
gso/workflows/iptrunk/create_iptrunk.py
+
33
−
1
View file @
ee42b712
...
...
@@ -26,13 +26,14 @@ from gso.products.product_blocks.iptrunk import (
IptrunkType
,
PhysicalPortCapacity
,
)
from
gso.products.product_types.iptrunk
import
IptrunkInactive
,
IptrunkProvisioning
from
gso.products.product_types.iptrunk
import
Iptrunk
,
IptrunkInactive
,
IptrunkProvisioning
from
gso.products.product_types.router
import
Router
from
gso.services
import
infoblox
,
subscriptions
from
gso.services.lso_client
import
execute_playbook
,
lso_interaction
from
gso.services.netbox_client
import
NetboxClient
from
gso.services.partners
import
get_partner_by_name
from
gso.services.sharepoint
import
SharePointClient
from
gso.services.subscriptions
import
get_non_terminated_iptrunk_subscriptions
from
gso.settings
import
load_oss_params
from
gso.utils.helpers
import
(
LAGMember
,
...
...
@@ -233,6 +234,36 @@ def get_info_from_ipam(subscription: IptrunkInactive) -> State:
}
@step
(
"
Check if assigned networks are already taken by other trunk subscription
"
)
def
check_existing_trunk_allocations
(
subscription
:
IptrunkInactive
)
->
None
:
"""
Check if there already is a trunk with the same network resources assigned to it.
"""
if
not
subscription
.
iptrunk
.
iptrunk_ipv4_network
or
not
subscription
.
iptrunk
.
iptrunk_ipv6_network
:
msg
=
"
Missing IP resources in subscription object.
"
raise
ProcessFailureError
(
msg
,
details
=
[
subscription
.
iptrunk
.
iptrunk_ipv4_network
,
subscription
.
iptrunk
.
iptrunk_ipv6_network
]
)
all_trunks
=
[
Iptrunk
.
from_subscription
(
trunk
[
"
subscription_id
"
])
for
trunk
in
get_non_terminated_iptrunk_subscriptions
()
if
trunk
[
"
subscription_id
"
]
!=
subscription
.
subscription_id
]
overlapping_ipv4_networks
=
[
(
trunk
.
description
,
trunk
.
iptrunk
.
iptrunk_ipv4_network
)
for
trunk
in
all_trunks
if
trunk
.
iptrunk
.
iptrunk_ipv4_network
.
overlaps
(
subscription
.
iptrunk
.
iptrunk_ipv4_network
)
]
overlapping_ipv6_networks
=
[
(
trunk
.
description
,
trunk
.
iptrunk
.
iptrunk_ipv6_network
)
for
trunk
in
all_trunks
if
trunk
.
iptrunk
.
iptrunk_ipv6_network
.
overlaps
(
subscription
.
iptrunk
.
iptrunk_ipv6_network
)
]
if
overlapping_ipv4_networks
or
overlapping_ipv6_networks
:
msg
=
"
Newly assigned IP networks overlap with existing IP trunk subscriptions, please investigate.
"
raise
ProcessFailureError
(
msg
,
details
=
[
overlapping_ipv4_networks
,
overlapping_ipv6_networks
])
@step
(
"
Check for existing DNS records in the assigned IPv4 network
"
)
def
dig_all_hosts_v4
(
new_ipv4_network
:
str
)
->
None
:
"""
Check if any hosts have already been assigned inside the IPv4 network in Netbox.
"""
...
...
@@ -585,6 +616,7 @@ def create_iptrunk() -> StepList:
steps
=
(
begin
>>
get_info_from_ipam
>>
check_existing_trunk_allocations
>>
dig_all_hosts_v4
>>
dig_all_hosts_v6
>>
ping_all_hosts_v4
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment