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
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
28f7797a
Commit
28f7797a
authored
1 year ago
by
JORGE SASIAIN
Browse files
Options
Downloads
Patches
Plain Diff
NAT-152: add comment field to create network
parent
7c327ed8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!9
Ipam service
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/services/_ipam.py
+9
-4
9 additions, 4 deletions
gso/services/_ipam.py
gso/services/ipam.py
+17
-7
17 additions, 7 deletions
gso/services/ipam.py
with
26 additions
and
11 deletions
gso/services/_ipam.py
+
9
−
4
View file @
28f7797a
...
...
@@ -147,6 +147,7 @@ def _allocate_network(
infoblox_params
:
settings
.
InfoBloxParams
,
network_params
:
Union
[
settings
.
V4NetworkParams
,
settings
.
V6NetworkParams
],
ip_version
=
4
,
comment
=
""
,
extattrs
=
{}
)
->
Union
[
V4ServiceNetwork
,
V6ServiceNetwork
]:
assert
ip_version
in
[
4
,
6
]
...
...
@@ -168,6 +169,7 @@ def _allocate_network(
},
"
_result_field
"
:
"
networks
"
,
},
"
comment
"
:
comment
,
"
extattrs
"
:
extattrs
}
...
...
@@ -203,7 +205,7 @@ def _allocate_network(
return
V6ServiceNetwork
(
v6
=
allocated_network
)
def
allocate_service_ipv4_network
(
service_type
,
extattrs
=
{}
def
allocate_service_ipv4_network
(
service_type
,
comment
=
""
,
extattrs
=
{}
)
->
V4ServiceNetwork
:
"""
Allocate IPv4 network within the container of the specified service type.
...
...
@@ -216,10 +218,11 @@ def allocate_service_ipv4_network(service_type, extattrs={}
return
_allocate_network
(
ipam_params
.
INFOBLOX
,
getattr
(
ipam_params
,
service_type
).
V4
,
4
,
comment
,
extattrs
)
def
allocate_service_ipv6_network
(
service_type
,
extattrs
=
{}
def
allocate_service_ipv6_network
(
service_type
,
comment
=
""
,
extattrs
=
{}
)
->
V6ServiceNetwork
:
"""
Allocate IPv6 network within the container of the specified service type.
...
...
@@ -232,6 +235,7 @@ def allocate_service_ipv6_network(service_type, extattrs={}
return
_allocate_network
(
ipam_params
.
INFOBLOX
,
getattr
(
ipam_params
,
service_type
).
V6
,
6
,
comment
,
extattrs
)
...
...
@@ -619,13 +623,14 @@ if __name__ == '__main__':
elif
choice
==
'
4
'
:
service_type
=
input
(
"
Enter service type:
"
)
comment
=
input
(
"
Enter a comment for the network:
"
)
ip_version
=
int
(
input
(
"
Enter IP version (4 or 6):
"
))
if
ip_version
==
4
:
new_network
=
allocate_service_ipv4_network
(
service_type
=
service_type
)
comment
=
comment
,
service_type
=
service_type
)
elif
ip_version
==
6
:
new_network
=
allocate_service_ipv6_network
(
service_type
=
service_type
)
comment
=
comment
,
service_type
=
service_type
)
else
:
print
(
"
Invalid IP version. Please enter either 4 or 6.
"
)
continue
...
...
This diff is collapsed.
Click to expand it.
gso/services/ipam.py
+
17
−
7
View file @
28f7797a
import
ipaddress
from
pydantic
import
BaseSettings
import
_ipam
from
gso.services
import
_ipam
class
V4ServiceNetwork
(
BaseSettings
):
...
...
@@ -30,11 +30,13 @@ class HostAddresses(BaseSettings):
v6
:
ipaddress
.
IPv6Address
def
new_service_networks
(
service_type
,
extattrs
=
{})
->
ServiceNetworks
:
def
new_service_networks
(
service_type
,
comment
=
""
,
extattrs
=
{})
->
ServiceNetworks
:
v4_service_network
=
_ipam
.
allocate_service_ipv4_network
(
service_type
=
service_type
,
extattrs
=
extattrs
)
service_type
=
service_type
,
comment
=
comment
,
extattrs
=
extattrs
)
v6_service_network
=
_ipam
.
allocate_service_ipv6_network
(
service_type
=
service_type
,
extattrs
=
extattrs
)
service_type
=
service_type
,
comment
=
comment
,
extattrs
=
extattrs
)
return
ServiceNetworks
(
v4
=
v4_service_network
.
v4
,
v6
=
v6_service_network
.
v6
)
...
...
@@ -66,7 +68,10 @@ if __name__ == '__main__':
hostname_B
=
'
h2
'
# h1 LO (loopback)
lo1_service_networks
=
new_service_networks
(
service_type
=
'
LO
'
)
lo1_service_networks
=
new_service_networks
(
service_type
=
'
LO
'
,
comment
=
"
Network for h1 LO
"
)
lo1_v4_host_address
=
lo1_service_networks
.
v4
.
network_address
lo1_v6_host_address
=
lo1_service_networks
.
v6
.
network_address
lo1_host_addresses
=
HostAddresses
(
v4
=
lo1_v4_host_address
,
...
...
@@ -83,14 +88,19 @@ if __name__ == '__main__':
"
Site
"
:
{
"
value
"
:
"
dummy_site
"
},
}
lo2_service_networks
=
\
new_service_networks
(
service_type
=
'
LO
'
,
extattrs
=
lo2_network_extattrs
)
new_service_networks
(
service_type
=
'
LO
'
,
comment
=
"
Network for h2 LO
"
,
extattrs
=
lo2_network_extattrs
)
new_service_host
(
hostname
=
hostname_B
,
service_type
=
'
LO
'
,
service_networks
=
lo2_service_networks
,
extattrs
=
lo2_host_extattrs
)
# h1-h2 TRUNK
trunk12_service_networks
=
new_service_networks
(
service_type
=
'
TRUNK
'
)
trunk12_service_networks
=
new_service_networks
(
service_type
=
'
TRUNK
'
,
comment
=
"
Network for h1-h2 TRUNK
"
)
new_service_host
(
hostname
=
hostname_A
,
service_type
=
'
TRUNK
'
,
service_networks
=
trunk12_service_networks
)
...
...
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