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
9e47b8df
Commit
9e47b8df
authored
1 year ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
parameterized default site and device role data.
parent
1905b3bc
No related branches found
No related tags found
1 merge request
!82
IP-TRUNK-CREATE-WORKFLOW-NETBOX-INTEGRATION
Pipeline
#84220
passed
1 year ago
Stage: tox
Stage: documentation
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gso/cli/netbox.py
+3
-2
3 additions, 2 deletions
gso/cli/netbox.py
gso/services/netbox_client.py
+3
-3
3 additions, 3 deletions
gso/services/netbox_client.py
gso/utils/device_info.py
+4
-0
4 additions, 0 deletions
gso/utils/device_info.py
with
10 additions
and
5 deletions
gso/cli/netbox.py
+
3
−
2
View file @
9e47b8df
...
@@ -2,6 +2,7 @@ import typer
...
@@ -2,6 +2,7 @@ import typer
from
pynetbox
import
RequestError
from
pynetbox
import
RequestError
from
gso.services.netbox_client
import
NetboxClient
from
gso.services.netbox_client
import
NetboxClient
from
gso.utils.device_info
import
DEFAULT_SITE
,
ROUTER_ROLE
app
:
typer
.
Typer
=
typer
.
Typer
()
app
:
typer
.
Typer
=
typer
.
Typer
()
...
@@ -21,14 +22,14 @@ def netbox_initial_setup() -> None:
...
@@ -21,14 +22,14 @@ def netbox_initial_setup() -> None:
typer
.
echo
(
"
Creating GÉANT site ...
"
)
typer
.
echo
(
"
Creating GÉANT site ...
"
)
try
:
try
:
nbclient
.
create_device_site
(
"
GEANT
"
,
"
geant
"
)
nbclient
.
create_device_site
(
DEFAULT_SITE
[
"
name
"
],
DEFAULT_SITE
[
"
slug
"
]
)
typer
.
echo
(
"
Site created successfully.
"
)
typer
.
echo
(
"
Site created successfully.
"
)
except
RequestError
as
e
:
except
RequestError
as
e
:
typer
.
echo
(
f
"
Error creating site:
{
e
}
"
)
typer
.
echo
(
f
"
Error creating site:
{
e
}
"
)
typer
.
echo
(
"
Creating Router device role ...
"
)
typer
.
echo
(
"
Creating Router device role ...
"
)
try
:
try
:
nbclient
.
create_device_role
(
"
router
"
,
"
router
"
)
nbclient
.
create_device_role
(
ROUTER_ROLE
[
"
name
"
],
ROUTER_ROLE
[
"
slug
"
]
)
typer
.
echo
(
"
Device role created successfully.
"
)
typer
.
echo
(
"
Device role created successfully.
"
)
except
RequestError
as
e
:
except
RequestError
as
e
:
typer
.
echo
(
f
"
Error creating device role:
{
e
}
"
)
typer
.
echo
(
f
"
Error creating device role:
{
e
}
"
)
...
...
This diff is collapsed.
Click to expand it.
gso/services/netbox_client.py
+
3
−
3
View file @
9e47b8df
...
@@ -7,7 +7,7 @@ from pynetbox.models.dcim import Devices, DeviceTypes, Interfaces
...
@@ -7,7 +7,7 @@ from pynetbox.models.dcim import Devices, DeviceTypes, Interfaces
from
gso.products
import
Router
from
gso.products
import
Router
from
gso.settings
import
load_oss_params
from
gso.settings
import
load_oss_params
from
gso.utils.device_info
import
FEASIBLE_IP_TRUNK_LAG_RANGE
,
TierInfo
from
gso.utils.device_info
import
DEFAULT_SITE
,
FEASIBLE_IP_TRUNK_LAG_RANGE
,
ROUTER_ROLE
,
TierInfo
from
gso.utils.exceptions
import
NotFoundError
,
WorkflowStateError
from
gso.utils.exceptions
import
NotFoundError
,
WorkflowStateError
...
@@ -123,10 +123,10 @@ class NetboxClient:
...
@@ -123,10 +123,10 @@ class NetboxClient:
device_type
=
self
.
netbox
.
dcim
.
device_types
.
get
(
model
=
tier_info
.
device_type
)
device_type
=
self
.
netbox
.
dcim
.
device_types
.
get
(
model
=
tier_info
.
device_type
)
# Get device role id
# Get device role id
device_role
=
self
.
netbox
.
dcim
.
device_roles
.
get
(
name
=
"
router
"
)
device_role
=
self
.
netbox
.
dcim
.
device_roles
.
get
(
name
=
ROUTER_ROLE
[
"
name
"
]
)
# Get site id
# Get site id
device_site
=
self
.
netbox
.
dcim
.
sites
.
get
(
name
=
"
GEANT
"
)
device_site
=
self
.
netbox
.
dcim
.
sites
.
get
(
name
=
DEFAULT_SITE
[
"
name
"
]
)
# Create new device
# Create new device
device
=
self
.
netbox
.
dcim
.
devices
.
create
(
device
=
self
.
netbox
.
dcim
.
devices
.
create
(
...
...
This diff is collapsed.
Click to expand it.
gso/utils/device_info.py
+
4
−
0
View file @
9e47b8df
...
@@ -32,3 +32,7 @@ class TierInfo:
...
@@ -32,3 +32,7 @@ class TierInfo:
# The range includes values from 1 to 10 (11 is not included)
# The range includes values from 1 to 10 (11 is not included)
FEASIBLE_IP_TRUNK_LAG_RANGE
=
range
(
1
,
11
)
FEASIBLE_IP_TRUNK_LAG_RANGE
=
range
(
1
,
11
)
# Define default values
ROUTER_ROLE
=
{
"
name
"
:
"
router
"
,
"
slug
"
:
"
router
"
}
DEFAULT_SITE
=
{
"
name
"
:
"
GEANT
"
,
"
slug
"
:
"
geant
"
}
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