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
3a7eaf8e
Verified
Commit
3a7eaf8e
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
Re-introduce old faker provider for ip networks
Since the default one does not support limiting the subnet size
parent
e9a7d85d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!172
Add IPAM step to IPtrunk creation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/conftest.py
+18
-0
18 additions, 0 deletions
test/conftest.py
with
18 additions
and
0 deletions
test/conftest.py
+
18
−
0
View file @
3a7eaf8e
import
contextlib
import
ipaddress
import
logging
import
os
from
pathlib
import
Path
...
...
@@ -41,6 +42,23 @@ class UseJuniperSide(strEnum):
class
FakerProvider
(
BaseProvider
):
def
ipv4_network
(
self
,
*
,
min_subnet
=
1
,
max_subnet
=
32
)
->
ipaddress
.
IPv4Network
:
subnet
=
str
(
self
.
generator
.
random_int
(
min
=
min_subnet
,
max
=
max_subnet
))
ipv4
=
self
.
generator
.
ipv4
()
interface
=
ipaddress
.
IPv4Interface
(
ipv4
+
"
/
"
+
subnet
)
# Extra step for converting ``10.53.92.39/24`` to ``10.53.92.0/24``
network
=
interface
.
network
.
network_address
return
ipaddress
.
IPv4Network
(
str
(
network
)
+
"
/
"
+
subnet
)
def
ipv6_network
(
self
,
*
,
min_subnet
=
1
,
max_subnet
=
128
)
->
ipaddress
.
IPv6Network
:
subnet
=
str
(
self
.
generator
.
random_int
(
min
=
min_subnet
,
max
=
max_subnet
))
ipv6
=
self
.
generator
.
ipv6
()
interface
=
ipaddress
.
IPv6Interface
(
ipv6
+
"
/
"
+
subnet
)
network
=
interface
.
network
.
network_address
return
ipaddress
.
IPv6Network
(
str
(
network
)
+
"
/
"
+
subnet
)
def
tt_number
(
self
)
->
str
:
random_date
=
self
.
generator
.
date
(
pattern
=
"
%Y%m%d
"
)
random_int
=
self
.
generator
.
random_int
(
min
=
10000000
,
max
=
99999999
)
...
...
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