Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
brian-dashboard-manager
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
geant-swd
brian
brian-dashboard-manager
Commits
6a3efcf8
"...git@gitlab.software.geant.org:edugain/eac-manager.git" did not exist on "a770e418cdb9748083f78aebf84512814ad696a1"
Commit
6a3efcf8
authored
1 year ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
Fix unhandled errors from inventory-provider API
parent
8d790877
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
brian_dashboard_manager/inventory_provider/interfaces.py
+39
-15
39 additions, 15 deletions
brian_dashboard_manager/inventory_provider/interfaces.py
with
39 additions
and
15 deletions
brian_dashboard_manager/inventory_provider/interfaces.py
+
39
−
15
View file @
6a3efcf8
from
enum
import
Enum
,
auto
import
requests
import
requests
import
logging
import
logging
import
jsonschema
import
jsonschema
from
requests.exceptions
import
HTTPError
from
enum
import
Enum
,
auto
from
functools
import
reduce
from
functools
import
reduce
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -300,9 +301,14 @@ def _get_ip_info(host):
...
@@ -300,9 +301,14 @@ def _get_ip_info(host):
prev
[
router_name
]
=
router
prev
[
router_name
]
=
router
return
prev
return
prev
r
=
requests
.
get
(
f
'
{
host
}
/data/interfaces
'
)
try
:
r
.
raise_for_status
()
r
=
requests
.
get
(
f
'
{
host
}
/data/interfaces
'
)
interfaces
=
r
.
json
()
r
.
raise_for_status
()
interfaces
=
r
.
json
()
except
HTTPError
:
logger
.
exception
(
'
Failed to get IP info
'
)
interfaces
=
[]
jsonschema
.
validate
(
interfaces
,
ROUTER_INTERFACES_SCHEMA
)
jsonschema
.
validate
(
interfaces
,
ROUTER_INTERFACES_SCHEMA
)
return
reduce
(
reduce_func
,
interfaces
,
{})
return
reduce
(
reduce_func
,
interfaces
,
{})
...
@@ -316,8 +322,13 @@ def get_interfaces(host):
...
@@ -316,8 +322,13 @@ def get_interfaces(host):
"""
"""
r
=
requests
.
get
(
f
'
{
host
}
/poller/interfaces
'
)
r
=
requests
.
get
(
f
'
{
host
}
/poller/interfaces
'
)
r
.
raise_for_status
()
try
:
interfaces
=
r
.
json
()
r
.
raise_for_status
()
interfaces
=
r
.
json
()
except
HTTPError
:
logger
.
exception
(
'
Failed to get interfaces
'
)
interfaces
=
[]
jsonschema
.
validate
(
interfaces
,
INTERFACE_LIST_SCHEMA
)
jsonschema
.
validate
(
interfaces
,
INTERFACE_LIST_SCHEMA
)
ip_info
=
_get_ip_info
(
host
)
ip_info
=
_get_ip_info
(
host
)
...
@@ -336,6 +347,7 @@ def get_interfaces(host):
...
@@ -336,6 +347,7 @@ def get_interfaces(host):
interface
[
'
ipv4
'
]
=
ipv4
interface
[
'
ipv4
'
]
=
ipv4
interface
[
'
ipv6
'
]
=
ipv6
interface
[
'
ipv6
'
]
=
ipv6
return
interface
return
interface
filtered
=
filter
(
lambda
i
:
len
(
i
[
'
dashboards
'
])
>
0
,
interfaces
)
filtered
=
filter
(
lambda
i
:
len
(
i
[
'
dashboards
'
])
>
0
,
interfaces
)
enriched
=
list
(
map
(
enrich
,
filtered
))
enriched
=
list
(
map
(
enrich
,
filtered
))
return
enriched
return
enriched
...
@@ -351,8 +363,13 @@ def get_gws_direct(host):
...
@@ -351,8 +363,13 @@ def get_gws_direct(host):
"""
"""
r
=
requests
.
get
(
f
'
{
host
}
/poller/gws/direct
'
)
r
=
requests
.
get
(
f
'
{
host
}
/poller/gws/direct
'
)
r
.
raise_for_status
()
try
:
interfaces
=
r
.
json
()
r
.
raise_for_status
()
interfaces
=
r
.
json
()
except
HTTPError
:
logger
.
exception
(
'
Failed to get GWS direct data
'
)
interfaces
=
[]
jsonschema
.
validate
(
interfaces
,
GWS_DIRECT_DATA_SCHEMA
)
jsonschema
.
validate
(
interfaces
,
GWS_DIRECT_DATA_SCHEMA
)
return
interfaces
return
interfaces
...
@@ -364,10 +381,13 @@ def get_gws_indirect(host):
...
@@ -364,10 +381,13 @@ def get_gws_indirect(host):
:param host: Hostname to perform the request to.
:param host: Hostname to perform the request to.
:return: GWS Indirect data
:return: GWS Indirect data
"""
"""
try
:
r
=
requests
.
get
(
f
'
{
host
}
/poller/gws/indirect
'
)
r
=
requests
.
get
(
f
'
{
host
}
/poller/gws/indirect
'
)
r
.
raise_for_status
()
r
.
raise_for_status
()
interfaces
=
r
.
json
()
interfaces
=
r
.
json
()
except
HTTPError
:
logger
.
exception
(
'
Failed to get GWS indirect data
'
)
interfaces
=
[]
return
interfaces
return
interfaces
...
@@ -378,9 +398,13 @@ def get_eumetsat_multicast_subscriptions(host):
...
@@ -378,9 +398,13 @@ def get_eumetsat_multicast_subscriptions(host):
:param host: Hostname to perform the request to.
:param host: Hostname to perform the request to.
:return: EUMETSAT multicast subscriptions
:return: EUMETSAT multicast subscriptions
"""
"""
try
:
r
=
requests
.
get
(
f
'
{
host
}
/poller/eumetsat-multicast
'
)
r
.
raise_for_status
()
data
=
r
.
json
()
except
HTTPError
:
logger
.
exception
(
'
Failed to get EUMETSAT multicast subscriptions
'
)
data
=
[]
r
=
requests
.
get
(
f
'
{
host
}
/poller/eumetsat-multicast
'
)
r
.
raise_for_status
()
data
=
r
.
json
()
jsonschema
.
validate
(
data
,
MULTICAST_SUBSCRIPTION_LIST_SCHEMA
)
jsonschema
.
validate
(
data
,
MULTICAST_SUBSCRIPTION_LIST_SCHEMA
)
return
data
return
data
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