Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin-telecom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
wendelin-telecom
Commits
0c72b893
Commit
0c72b893
authored
Jan 24, 2025
by
Paul Graydon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wendelin_telecom_base: Make ORS object management scripts more robust
parent
446f7dad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
14 deletions
+39
-14
bt5/wendelin_telecom_base/SkinTemplateItem/portal_skins/wendelin_telecom_base/DataAcquisitionUnit_createOrsDataSupply.py
...n_telecom_base/DataAcquisitionUnit_createOrsDataSupply.py
+5
-7
bt5/wendelin_telecom_base/SkinTemplateItem/portal_skins/wendelin_telecom_base/DataAcquisitionUnit_getOrsDataSupply.py
...elin_telecom_base/DataAcquisitionUnit_getOrsDataSupply.py
+32
-6
bt5/wendelin_telecom_base/SkinTemplateItem/portal_skins/wendelin_telecom_base/ERP5Site_registerOrs.py
...ortal_skins/wendelin_telecom_base/ERP5Site_registerOrs.py
+2
-1
No files found.
bt5/wendelin_telecom_base/SkinTemplateItem/portal_skins/wendelin_telecom_base/DataAcquisitionUnit_createOrsDataSupply.py
View file @
0c72b893
'''
'''
Creates a pre-configured Data Supply related to a Data Acquisition Unit representing an ORS.
Creates a pre-configured Data Supply related to a Data Acquisition Unit representing an ORS.
The related Data Supply has the same reference as the Data Acquisition Unit.
The related Data Supply has the same reference as the Data Acquisition Unit, which is the
ORS's fluentbit tag and is needed for proper ingestion of its logs.
The script first checks if the Data Supply already exists, and will create it if it doesn't.
The script first checks if the Data Supply already exists, and will create it if it doesn't.
If batch == 1, the Data Supply object is returned in both cases of the above check.
If batch == 1, the Data Supply object is returned in both cases of the above check.
Otherwise, the user is redirected to the Data Supply's view page.
Otherwise, the user is redirected to the Data Supply's view page.
'''
'''
if
not
context
.
getReference
():
if
not
context
.
getReference
():
if
batch
:
return
None
return
context
.
Base_redirect
(
'view'
,
keep_items
=
{
return
context
.
Base_redirect
(
'view'
,
keep_items
=
{
'portal_status_message'
:
'Reference is not defined.'
,
'portal_status_message'
:
'Reference is not defined.'
,
'portal_status_level'
:
'error'
'portal_status_level'
:
'error'
})
})
reference
=
context
.
getReference
()
reference
=
context
.
getReference
()
data_supply
=
context
.
portal_catalog
.
getResultValue
(
data_supply
=
context
.
DataAcquisitionUnit_getOrsDataSupply
()
portal_type
=
'Data Supply'
,
reference
=
reference
,
validation_state
=
'validated'
)
if
data_supply
:
if
data_supply
:
if
batch
:
if
batch
:
return
data_supply
return
data_supply
...
...
bt5/wendelin_telecom_base/SkinTemplateItem/portal_skins/wendelin_telecom_base/DataAcquisitionUnit_getOrsDataSupply.py
View file @
0c72b893
'''
'''
Return the pre-configured Data Supply related to a Data Acquisition Unit representing an ORS.
Return the pre-configured Data Supply related to a Data Acquisition Unit representing an ORS.
If the Data Acquisition Unit does not have a reference or the Data Supply does not exist, return None.
The related Data Supply must have the same reference as the Data Acquisition Unit.
If the Data Acquisition Unit or the Data Supply do not fit the expected ORS format, return None.
In the unexpected event several matching Data Supplies exist, return the oldest one, as it is
most likely to be the one created by the ORS registration process.
'''
'''
if
not
context
.
getReference
()
:
if
context
.
getReference
()
is
None
:
return
None
return
None
reference
=
context
.
getReference
()
ors_tag
=
context
.
getReference
()
portal
=
context
.
getPortalObject
()
return
context
.
portal_catalog
.
getResultValue
(
data_supply_list
=
portal
.
data_supply_module
.
searchFolder
(
portal_type
=
'Data Supply'
,
portal_type
=
'Data Supply'
,
reference
=
reference
,
reference
=
ors_tag
,
validation_state
=
'validated'
validation_state
=
'validated'
)
)
data_supply_url_list
=
[
data_supply
.
getRelativeUrl
()
for
data_supply
in
data_supply_list
]
related_data_supply_list
=
[]
for
data_supply_line
in
context
.
Base_getRelatedObjectList
(
portal_type
=
'Data Supply Line'
,
validation_state
=
'validated'
):
# Be sure to only fetch Data Supplies the user has access to
data_supply_url
=
data_supply_line
.
getParentRelativeUrl
()
if
data_supply_url
in
data_supply_url_list
:
related_data_supply_list
.
append
(
portal
.
restrictedTraverse
(
data_supply_url
))
if
not
related_data_supply_list
:
return
None
# Several related Data Supplies have the expected reference: unexpected
# Return the one that was created first
related_data_supply_list
.
sort
(
key
=
lambda
x
:
x
.
getCreationDate
())
return
related_data_supply_list
[
0
]
bt5/wendelin_telecom_base/SkinTemplateItem/portal_skins/wendelin_telecom_base/ERP5Site_registerOrs.py
View file @
0c72b893
...
@@ -49,7 +49,8 @@ related_data_acquisition_unit_list = [
...
@@ -49,7 +49,8 @@ related_data_acquisition_unit_list = [
portal_type
=
'Data Acquisition Unit'
,
portal_type
=
'Data Acquisition Unit'
,
validation_state
=
'validated'
validation_state
=
'validated'
)
\
)
\
if
related_data_acquisition_unit
.
getReference
().
startswith
(
fluentbit_tag_prefix
)
if
related_data_acquisition_unit
.
getReference
()
is
not
None
\
and
related_data_acquisition_unit
.
getReference
().
startswith
(
fluentbit_tag_prefix
)
]
]
destination_project
=
None
destination_project
=
None
if
related_data_acquisition_unit_list
:
if
related_data_acquisition_unit_list
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment