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
110cbd80
Commit
110cbd80
authored
5 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
updated otrs_get_customer_users_rows to yield Organisations and Customers
parent
f552b4fe
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/ims_data.py
+49
-25
49 additions, 25 deletions
inventory_provider/db/ims_data.py
with
49 additions
and
25 deletions
inventory_provider/db/ims_data.py
+
49
−
25
View file @
110cbd80
...
...
@@ -119,8 +119,10 @@ def otrs_get_customer_company_rows(ds):
yield
[
customer
[
'
Name
'
],
customer
[
'
FullName
'
],
''
,
''
,
''
,
''
,
''
,
''
]
def
otrs_get_users_as_customers
(
ds
):
yielded
=
False
def
otrs_get_customer_users_rows
(
ds
):
yield
[
'
email
'
,
'
username
'
,
'
customer_id
'
,
'
customer_id_2
'
,
'
title
'
,
'
firstname
'
,
'
lastname
'
,
'
phone
'
,
'
fax
'
,
'
mobile
'
,
'
street
'
,
'
zip
'
,
'
city
'
,
'
country
'
,
'
comments
'
]
type_priority
=
{
RelateType
.
SITE
:
1
,
RelateType
.
GROUP
:
2
,
...
...
@@ -130,20 +132,58 @@ def otrs_get_users_as_customers(ds):
RelateType
.
CUSTOMER
:
6
,
}
# TODO - check the rules for prioritisation once model has been confirmed
def
_choose_customer_user
(
cu_1
,
cu_2
):
if
not
cu_2
or
type_priority
.
get
(
cu_1
[
'
type
'
],
0
)
>
type_priority
.
get
(
cu_2
[
'
type
'
],
0
):
return
cu_1
return
cu_2
# TODO - check the rules for validation once model has been confirmed
def
_is_valid_customer
(
cus
):
# commented out as no contact details are in IMS
# if not cus['email']:
# return False
return
True
# TODO - check this rule for getting the customer_id2 once model has been confirmed # noqa
def
_get_customer_id2
(
cus
):
if
cus
[
'
CustomerType
'
]
and
cus
[
'
CustomerType
'
][
'
Name
'
]
==
'
NREN NOC
'
:
return
True
return
''
for
customer
in
ds
.
get_all_entities
(
'
Customer
'
,
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerRelatedContacts
'
]):
[
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerRelatedContacts
'
],
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerType
'
]
]):
# Org as User
org_customer
=
OrderedDict
({
'
type
'
:
customer
[
'
CustomerType
'
][
'
Name
'
]
if
customer
[
'
CustomerType
'
]
else
''
,
'
email
'
:
customer
[
'
AccountEmail
'
],
'
username
'
:
customer
[
'
AccountEmail
'
],
'
customer_id
'
:
customer
[
'
Name
'
],
'
customer_id_2
'
:
_get_customer_id2
(
customer
),
'
title
'
:
''
,
'
firstname
'
:
customer
[
'
Name
'
],
'
lastname
'
:
'
-
'
,
'
phone
'
:
''
,
'
fax
'
:
''
,
'
mobile
'
:
''
,
'
street
'
:
''
,
'
zip
'
:
''
,
'
city
'
:
''
,
'
country
'
:
''
,
'
comments
'
:
''
})
if
_is_valid_customer
(
org_customer
):
del
org_customer
[
'
type
'
]
yield
org_customer
.
values
()
# end of Org as User
# Contacts as Users
if
customer
[
'
CustomerRelatedContacts
'
]:
customer_user
=
None
...
...
@@ -155,13 +195,13 @@ def otrs_get_users_as_customers(ds):
'
email
'
:
contact
[
'
Contact
'
][
'
Mail
'
],
'
username
'
:
contact
[
'
Contact
'
][
'
Mail
'
],
# TODO if tal_id is going to be present use that # noqa
'
customer_id
'
:
customer
[
'
Name
'
],
'
customer_id_2
'
:
''
,
# TODO populate - need the rules for this # noqa
'
title
'
:
contact
[
'
Contact
'
][
'
PreFix
'
],
# TODO - double check this is the right field # noqa
'
customer_id_2
'
:
_get_customer_id2
(
customer
),
'
title
'
:
''
,
'
firstname
'
:
contact
[
'
Contact
'
][
'
Name
'
],
'
lastname
'
:
contact
[
'
Contact
'
][
'
LastName
'
],
'
phone
'
:
contact
[
'
Contact
'
][
'
Phone
'
]
,
'
fax
'
:
contact
[
'
Contact
'
][
'
Fax
'
]
,
'
mobile
'
:
contact
[
'
Contact
'
][
'
Mobile
'
]
,
'
phone
'
:
''
,
'
fax
'
:
''
,
'
mobile
'
:
''
,
'
street
'
:
''
,
'
zip
'
:
''
,
'
city
'
:
''
,
...
...
@@ -177,23 +217,7 @@ def otrs_get_users_as_customers(ds):
if
customer_user
:
del
customer_user
[
'
type
'
]
yield
customer_user
.
values
()
yielded
=
True
# Is there a better way to do this?
if
not
yielded
:
return
[]
def
otrs_get_orgs_as_customers
(
ds
):
return
[]
def
otrs_get_customer_users_rows
(
ds
):
yield
[
'
email
'
,
'
username
'
,
'
customer_id
'
,
'
customer_id_2
'
,
'
title
'
,
'
firstname
'
,
'
lastname
'
,
'
phone
'
,
'
fax
'
,
'
mobile
'
,
'
street
'
,
'
zip
'
,
'
city
'
,
'
country
'
,
'
comments
'
]
yield
from
otrs_get_users_as_customers
(
ds
)
yield
from
otrs_get_orgs_as_customers
(
ds
)
# end of Contact as User
if
__name__
==
'
__main__
'
:
...
...
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