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
ecb845b3
Commit
ecb845b3
authored
1 year ago
by
JORGE SASIAIN
Committed by
Neda Moeini
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
NAT-244: raise NotFoundError when device/interface not found
parent
d7acdd0f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!94
Feature/Netbox integration terminate ip trunk
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gso/services/netbox_client.py
+4
-2
4 additions, 2 deletions
gso/services/netbox_client.py
with
4 additions
and
2 deletions
gso/services/netbox_client.py
+
4
−
2
View file @
ecb845b3
...
...
@@ -67,8 +67,7 @@ class NetboxClient:
return
self
.
netbox
.
dcim
.
devices
.
get
(
name
=
device_name
)
def
get_interfaces_by_device
(
self
,
device_name
:
str
,
speed
:
str
)
->
list
[
Interfaces
]:
"""
Get all interfaces of a device by name and speed.
"""
"""
Get all interfaces of a device by name and speed that are free and not allocated.
"""
device
=
self
.
get_device_by_name
(
device_name
)
return
list
(
self
.
netbox
.
dcim
.
interfaces
.
filter
(
device_id
=
device
.
id
,
enabled
=
False
,
mark_connected
=
False
,
speed
=
speed
)
...
...
@@ -84,6 +83,7 @@ class NetboxClient:
Returns the new interface object as dict.
"""
device
=
self
.
get_device_by_name
(
device_name
)
return
self
.
netbox
.
dcim
.
interfaces
.
create
(
name
=
iface_name
,
type
=
type
,
...
...
@@ -228,6 +228,7 @@ class NetboxClient:
def
allocate_interface
(
self
,
device_name
:
str
,
iface_name
:
str
)
->
Interfaces
:
"""
Allocate an interface by marking it as connected.
"""
# First get interface from device
device
=
self
.
get_device_by_name
(
device_name
)
interface
=
self
.
netbox
.
dcim
.
interfaces
.
get
(
device_id
=
device
.
id
,
name
=
iface_name
)
...
...
@@ -248,6 +249,7 @@ class NetboxClient:
def
free_interface
(
self
,
device_name
:
str
,
iface_name
:
str
)
->
Interfaces
:
"""
Free interface by marking disconnect and disable it.
"""
# First get interface from device
device
=
self
.
get_device_by_name
(
device_name
)
interface
=
self
.
netbox
.
dcim
.
interfaces
.
get
(
device_id
=
device
.
id
,
name
=
iface_name
)
...
...
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