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
7f39c902
Commit
7f39c902
authored
5 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added get_service_users
parent
8b1f511b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/db/opsdb.py
+27
-0
27 additions, 0 deletions
inventory_provider/db/opsdb.py
with
27 additions
and
0 deletions
inventory_provider/db/opsdb.py
+
27
−
0
View file @
7f39c902
...
@@ -436,3 +436,30 @@ AND circuit_type = 'Path'
...
@@ -436,3 +436,30 @@ AND circuit_type = 'Path'
crs
.
execute
(
parent_query
,
[
circuit
[
'
absid
'
]])
crs
.
execute
(
parent_query
,
[
circuit
[
'
absid
'
]])
r
=
_convert_to_dict
(
crs
)
r
=
_convert_to_dict
(
crs
)
return
_fields2rsp
(
r
[
0
])
if
r
else
None
return
_fields2rsp
(
r
[
0
])
if
r
else
None
def
get_service_users
(
connection
,
service_ids
):
def
_sublists
(
l
,
n
):
for
x
in
range
(
0
,
len
(
l
),
n
):
yield
l
[
x
:
x
+
n
]
# not sure how to use a tuple in a prepared statement,
# so this is just doing a dumb string replacement ...
query
=
(
'
select c.absid, o.name
'
'
from organisation o
'
'
join circuit_orgs co on co.org_absid=o.absid
'
'
join circuit c on c.absid=co.circ_absid
'
'
where co.org_type=
\'
Circuit User
\'
'
'
and c.absid in (%s)
'
)
with
db
.
cursor
(
connection
)
as
crs
:
for
chunk
in
_sublists
(
service_ids
,
20
):
crs
.
execute
(
query
%
'
,
'
.
join
([
str
(
x
)
for
x
in
chunk
]))
for
r
in
crs
.
fetchall
():
yield
{
'
service_id
'
:
r
[
0
],
'
user
'
:
r
[
1
]}
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