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
e48b476a
Commit
e48b476a
authored
2 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
use dedicated endpoint for all entities retrieval
parent
9b2a97db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/db/ims.py
+33
-8
33 additions, 8 deletions
inventory_provider/db/ims.py
test/test_ims.py
+1
-1
1 addition, 1 deletion
test/test_ims.py
with
34 additions
and
9 deletions
inventory_provider/db/ims.py
+
33
−
8
View file @
e48b476a
...
...
@@ -240,7 +240,7 @@ class IMS(object):
response
.
raise_for_status
()
break
def
_get_
entity
(
def
_get_
ims_data
(
self
,
url
,
params
=
None
,
...
...
@@ -332,7 +332,7 @@ class IMS(object):
url
=
f
'
{
entity_type
}
/
{
entity_id
}
'
return
\
self
.
_get_
entity
(
url
,
None
,
navigation_properties
,
use_cache
)
self
.
_get_
ims_data
(
url
,
None
,
navigation_properties
,
use_cache
)
@log_entry_and_exit
def
get_entity_by_name
(
...
...
@@ -342,7 +342,7 @@ class IMS(object):
navigation_properties
=
None
,
use_cache
=
False
):
url
=
f
'
{
entity
}
/byname/
"
{
name
}
"'
return
self
.
_get_
entity
(
url
,
None
,
navigation_properties
,
use_cache
)
return
self
.
_get_
ims_data
(
url
,
None
,
navigation_properties
,
use_cache
)
@log_entry_and_exit
def
get_filtered_entities
(
...
...
@@ -352,17 +352,31 @@ class IMS(object):
navigation_properties
=
None
,
use_cache
=
False
,
step_count
=
50
):
url
=
f
'
{
entity
}
/filtered/
{
filter_string
}
'
yield
from
self
.
get_entities
(
url
,
navigation_properties
,
use_cache
,
step_count
)
def
get_entities
(
self
,
url
,
navigation_properties
=
None
,
use_cache
=
False
,
step_count
=
50
):
more_to_come
=
True
start_entity
=
0
gateway_error_count
=
0
while
more_to_come
:
params
=
{
'
paginatorStartElement
'
:
start_entity
,
'
paginatorNumberOfElements
'
:
step_count
}
url
=
f
'
{
entity
}
/filtered/
{
filter_string
}
'
try
:
more_to_come
=
False
entities
=
self
.
_get_
entity
(
entities
=
self
.
_get_
ims_data
(
url
,
params
,
navigation_properties
,
...
...
@@ -372,6 +386,17 @@ class IMS(object):
if
r
.
status_code
==
requests
.
codes
.
not_found
\
and
NO_FILTERED_RESULTS_MESSAGE
in
r
.
text
.
lower
():
entities
=
None
elif
r
.
status_code
==
504
:
gateway_error_count
+=
1
logger
.
debug
(
f
"
GATEWAY TIME-OUT for
{
url
}
"
f
"
-- COUNT:
{
gateway_error_count
}
"
)
if
gateway_error_count
>
4
:
raise
e
time
.
sleep
(
5
)
logger
.
debug
(
"
WAKING UP
"
)
more_to_come
=
True
continue
else
:
raise
e
if
entities
:
...
...
@@ -388,9 +413,9 @@ class IMS(object):
use_cache
=
False
,
step_count
=
50
):
yield
from
self
.
get_filtered_entities
(
entit
y
,
'
Id <> 0
'
,
url
=
f
'
{
entity
}
/all
'
yield
from
self
.
get_
entit
ies
(
url
,
navigation_properties
,
use_cache
,
step_count
...
...
This diff is collapsed.
Click to expand it.
test/test_ims.py
+
1
−
1
View file @
e48b476a
...
...
@@ -139,7 +139,7 @@ def test_ims_class_get_all_entities(mocker):
list
(
ds
.
get_all_entities
(
'
Node
'
,
step_count
=
10
))
mock_get
.
assert_called_once_with
(
'
dummy_base/ims/Node/
filtered/Id <> 0
'
,
'
dummy_base/ims/Node/
all
'
,
headers
=
{
'
Authorization
'
:
'
Bearer dummy_bt
'
},
params
=
{
'
paginatorStartElement
'
:
0
,
...
...
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