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
1d6512ba
Commit
1d6512ba
authored
5 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
Added OTRS Export development
parent
0599f9e5
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
+86
-1
86 additions, 1 deletion
inventory_provider/db/ims_data.py
with
86 additions
and
1 deletion
inventory_provider/db/ims_data.py
+
86
−
1
View file @
1d6512ba
import
re
from
collections
import
OrderedDict
from
inventory_provider.db
import
ims
from
inventory_provider.db.ims
import
IMS
,
InventoryStatus
from
inventory_provider.db.ims
import
IMS
,
InventoryStatus
,
RelateType
INTERNAL_POP_NAMES
=
{
'
Cambridge OC
'
,
...
...
@@ -111,6 +112,90 @@ def get_interface_info(ds):
yield
from
ds
.
get_all_entities
(
'
Port
'
)
def
otrs_get_customer_company_rows
(
ds
):
yield
[
'
customer_id
'
,
'
name
'
,
'
street
'
,
'
zip
'
,
'
city
'
,
'
country
'
,
'
url
'
,
'
comments
'
]
for
customer
in
ds
.
get_all_entities
(
'
Customer
'
):
yield
[
customer
[
'
Name
'
],
customer
[
'
FullName
'
],
''
,
''
,
''
,
''
,
''
,
''
]
def
otrs_get_users_as_customers
(
ds
):
yielded
=
False
type_priority
=
{
RelateType
.
SITE
:
1
,
RelateType
.
GROUP
:
2
,
RelateType
.
CONTRACT
:
3
,
RelateType
.
VENDOR
:
4
,
RelateType
.
CONTACT
:
5
,
RelateType
.
CUSTOMER
:
6
,
}
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
def
_is_valid_customer
(
cus
):
# if not cus['email']:
# return False
return
True
for
customer
in
ds
.
get_all_entities
(
'
Customer
'
,
ims
.
CUSTOMER_PROPERTIES
[
'
CustomerRelatedContacts
'
]):
if
customer
[
'
CustomerRelatedContacts
'
]:
customer_user
=
None
for
contact
in
customer
[
'
CustomerRelatedContacts
'
]:
# could just do this as an array, but this makes it easier to
# keep track of the fields
t_customer_user
=
OrderedDict
({
'
type
'
:
ims
.
RelateType
(
contact
[
'
MainTypeId
'
]),
'
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
'
firstname
'
:
contact
[
'
Contact
'
][
'
Name
'
],
'
lastname
'
:
contact
[
'
Contact
'
][
'
LastName
'
],
'
phone
'
:
contact
[
'
Contact
'
][
'
Phone
'
],
'
fax
'
:
contact
[
'
Contact
'
][
'
Fax
'
],
'
mobile
'
:
contact
[
'
Contact
'
][
'
Mobile
'
],
'
street
'
:
''
,
'
zip
'
:
''
,
'
city
'
:
''
,
'
country
'
:
''
,
'
comments
'
:
''
})
if
not
_is_valid_customer
(
t_customer_user
):
continue
customer_user
=
_choose_customer_user
(
t_customer_user
,
customer_user
)
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
)
if
__name__
==
'
__main__
'
:
import
sys
username
=
sys
.
argv
[
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