Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
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
dashboardv3
inventory-provider
Commits
3542dedf
Commit
3542dedf
authored
10 months ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Updated gap.py to support older Python versions
parent
0c589a07
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/gap.py
+6
-4
6 additions, 4 deletions
inventory_provider/gap.py
inventory_provider/routes/poller.py
+1
-1
1 addition, 1 deletion
inventory_provider/routes/poller.py
with
7 additions
and
5 deletions
inventory_provider/gap.py
+
6
−
4
View file @
3542dedf
import
concurrent.futures
import
logging
import
socket
from
typing
import
Dict
,
Optional
import
requests
from
requests.adapters
import
HTTPAdapter
...
...
@@ -52,7 +53,7 @@ def get_token(aai_config: dict) -> str:
return
response
.
json
()[
'
access_token
'
]
def
make_request
(
body
:
dict
,
token
:
str
,
app_config
:
dict
)
->
d
ict
:
def
make_request
(
body
:
dict
,
token
:
str
,
app_config
:
dict
)
->
D
ict
:
"""
Make a request to the orchestrator using the given body.
"""
api_url
=
f
'
{
app_config
[
"
orchestrator
"
][
"
url
"
]
}
/api/graphql
'
headers
=
{
'
Authorization
'
:
f
'
Bearer
{
token
}
'
}
...
...
@@ -66,14 +67,15 @@ def make_request(body: dict, token: str, app_config: dict) -> dict:
response
=
session
.
post
(
api_url
,
headers
=
headers
,
json
=
body
)
response
.
raise_for_status
()
# The graphql API returns a 200 status code even if there are errors in the response
if
errors
:
=
response
.
json
().
get
(
'
errors
'
):
errors
=
response
.
json
().
get
(
'
errors
'
)
if
errors
:
err_msg
=
f
'
GraphQL query returned errors:
{
errors
}
'
logger
.
error
(
err_msg
)
raise
ValueError
(
err_msg
)
return
response
.
json
()
def
extract_router_info
(
device
:
dict
,
token
:
str
,
app_config
:
dict
)
->
dict
or
None
:
def
extract_router_info
(
device
:
dict
,
token
:
str
,
app_config
:
dict
)
->
Optional
[
dict
]
:
tag_to_key_map
=
{
"
RTR
"
:
"
router
"
,
"
OFFICE_ROUTER
"
:
"
officeRouter
"
,
...
...
@@ -122,7 +124,7 @@ def extract_router_info(device: dict, token: str, app_config: dict) -> dict or N
return
None
def
load_routers_from_orchestrator
(
app_config
:
dict
)
->
d
ict
:
def
load_routers_from_orchestrator
(
app_config
:
dict
)
->
D
ict
:
"""
Gets devices from the orchestrator and returns a dictionary of FQDNs and vendors.
"""
token
=
get_token
(
app_config
[
'
aai
'
])
routers
=
{}
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/routes/poller.py
+
1
−
1
View file @
3542dedf
...
...
@@ -940,7 +940,7 @@ def load_error_report_interfaces(
)
)
def
transform_interface
(
interface
:
dict
)
->
d
ict
:
def
transform_interface
(
interface
:
dict
)
->
D
ict
:
return
{
"
router
"
:
interface
[
"
router
"
],
"
name
"
:
interface
[
"
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