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
06c8982e
Commit
06c8982e
authored
5 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
updated to build organisation as users from different source
parent
299201d7
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
+48
-35
48 additions, 35 deletions
inventory_provider/db/ims_data.py
with
48 additions
and
35 deletions
inventory_provider/db/ims_data.py
+
48
−
35
View file @
06c8982e
...
@@ -141,9 +141,8 @@ def otrs_get_customer_users_rows(ds):
...
@@ -141,9 +141,8 @@ def otrs_get_customer_users_rows(ds):
# TODO - check the rules for validation once model has been confirmed
# TODO - check the rules for validation once model has been confirmed
def
_is_valid_customer
(
cus
):
def
_is_valid_customer
(
cus
):
# commented out as no contact details are in IMS
if
not
cus
[
'
email
'
]:
# if not cus['email']:
return
False
# return False
return
True
return
True
# TODO - check this rule for getting the customer_id2 once model has been confirmed # noqa
# TODO - check this rule for getting the customer_id2 once model has been confirmed # noqa
...
@@ -158,30 +157,38 @@ def otrs_get_customer_users_rows(ds):
...
@@ -158,30 +157,38 @@ def otrs_get_customer_users_rows(ds):
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerRelatedContacts
'
],
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerRelatedContacts
'
],
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerType
'
]
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerType
'
]
]):
]):
# Org as User
# # Org as User
org_customer
=
OrderedDict
({
# org_customer = OrderedDict({
'
type
'
:
customer
[
'
CustomerType
'
][
'
Name
'
]
if
customer
[
# 'type': customer['CustomerType']['Name'] if customer[
'
CustomerType
'
]
else
''
,
# 'CustomerType'] else '',
'
email
'
:
customer
[
'
AccountEmail
'
],
# 'email': customer['AccountEmail'],
'
username
'
:
customer
[
'
AccountEmail
'
],
# 'username': customer['AccountEmail'],
'
customer_id
'
:
customer
[
'
Name
'
],
# 'customer_id': customer['Name'],
'
customer_id_2
'
:
_get_customer_id2
(
customer
),
# 'customer_id_2': _get_customer_id2(customer),
'
title
'
:
''
,
# 'title': '',
'
firstname
'
:
customer
[
'
Name
'
],
# 'firstname': customer['Name'],
'
lastname
'
:
'
-
'
,
# 'lastname': '-',
'
phone
'
:
''
,
# 'phone': '',
'
fax
'
:
''
,
# 'fax': '',
'
mobile
'
:
''
,
# 'mobile': '',
'
street
'
:
''
,
# 'street': '',
'
zip
'
:
''
,
# 'zip': '',
'
city
'
:
''
,
# 'city': '',
'
country
'
:
''
,
# 'country': '',
'
comments
'
:
''
# 'comments': 'Organisation imported as a user'
})
# })
if
_is_valid_customer
(
org_customer
):
# if _is_valid_customer(org_customer):
del
org_customer
[
'
type
'
]
# del org_customer['type']
yield
org_customer
.
values
()
#
# end of Org as User
# # todo - remove from here after testing
# # dummy_email = f'dumy_{dummy_counter}@geant.org'
# # org_customer['email'] = dummy_email
# # org_customer['username'] = dummy_email
# # dummy_counter += 1
# # todo - remove up to here after testing
#
# yield list(org_customer.values())
# # end of Org as User
# Contacts as Users
# Contacts as Users
if
customer
[
'
CustomerRelatedContacts
'
]:
if
customer
[
'
CustomerRelatedContacts
'
]:
...
@@ -198,7 +205,11 @@ def otrs_get_customer_users_rows(ds):
...
@@ -198,7 +205,11 @@ def otrs_get_customer_users_rows(ds):
'
customer_id_2
'
:
_get_customer_id2
(
customer
),
'
customer_id_2
'
:
_get_customer_id2
(
customer
),
'
title
'
:
''
,
'
title
'
:
''
,
'
firstname
'
:
contact
[
'
Contact
'
][
'
Name
'
],
'
firstname
'
:
contact
[
'
Contact
'
][
'
Name
'
],
'
lastname
'
:
contact
[
'
Contact
'
][
'
LastName
'
],
'
lastname
'
:
'
'
.
join
(
filter
(
None
,
[
contact
[
'
Contact
'
][
'
InFix
'
],
contact
[
'
Contact
'
][
'
LastName
'
]
])),
'
phone
'
:
''
,
'
phone
'
:
''
,
'
fax
'
:
''
,
'
fax
'
:
''
,
'
mobile
'
:
''
,
'
mobile
'
:
''
,
...
@@ -210,13 +221,15 @@ def otrs_get_customer_users_rows(ds):
...
@@ -210,13 +221,15 @@ def otrs_get_customer_users_rows(ds):
})
})
if
not
_is_valid_customer
(
t_customer_user
):
if
not
_is_valid_customer
(
t_customer_user
):
continue
continue
customer_user
=
_choose_customer_user
(
if
contact
[
'
Contact
'
][
'
IsGroup
'
]:
t_customer_user
,
t_customer_user
[
'
comments
'
]
=
\
customer_user
'
Organisation imported as a user
'
)
if
customer_user
:
del
t_customer_user
[
'
type
'
]
del
customer_user
[
'
type
'
]
yield
list
(
t_customer_user
.
values
())
yield
customer_user
.
values
()
# if customer_user:
# del customer_user['type']
# yield list(customer_user.values())
# end of Contact as User
# end of Contact as User
...
...
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