Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
952b0676
Commit
952b0676
authored
Dec 08, 2023
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_upgrader: create Software Product (and its variations)
parent
155fc19a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
267 additions
and
1 deletion
+267
-1
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep3.py
...ader/Base_triggerFullSiteMigrationToVirtualMasterStep3.py
+9
-1
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep4.py
...ader/Base_triggerFullSiteMigrationToVirtualMasterStep4.py
+18
-0
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep4.xml
...der/Base_triggerFullSiteMigrationToVirtualMasterStep4.xml
+62
-0
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Project_checkSoftwareProductToVirtualMaster.py
...s_upgrader/Project_checkSoftwareProductToVirtualMaster.py
+116
-0
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Project_checkSoftwareProductToVirtualMaster.xml
..._upgrader/Project_checkSoftwareProductToVirtualMaster.xml
+62
-0
No files found.
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep3.py
View file @
952b0676
...
...
@@ -17,6 +17,14 @@ portal.portal_catalog.searchAndActivate(
**
packet_kw
)
# Delete existing old product only
if
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Software Release"
)
is
not
None
:
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'Base_deleteProcessedDocumentDuringPurge'
,
portal_type
=
[
"Software Product"
,
"Software Release"
],
**
packet_kw
)
############################################
# Gather compute node informations
############################################
...
...
@@ -46,4 +54,4 @@ if (run_count == 10):
context
.
activate
(
after_tag
=
tag
).
Base_triggerFullSiteMigrationToVirtualMasterStep2
(
run_count
=
run_count
+
1
)
else
:
context
.
activate
(
after_tag
=
tag
).
getId
()
context
.
activate
(
after_tag
=
tag
).
Base_triggerFullSiteMigrationToVirtualMasterStep4
()
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep4.py
0 → 100644
View file @
952b0676
# create the software products
################################################
portal
=
context
.
getPortalObject
()
tag
=
script
.
id
############################################
# Create products per project
############################################
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'Project_checkSoftwareProductToVirtualMaster'
,
method_kw
=
{
'activate_kw'
:
{
'tag'
:
tag
}},
activate_kw
=
{
'tag'
:
tag
,
'priority'
:
1
},
portal_type
=
"Project"
,
)
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep4.xml
0 → 100644
View file @
952b0676
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_triggerFullSiteMigrationToVirtualMasterStep4
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Project_checkSoftwareProductToVirtualMaster.py
0 → 100644
View file @
952b0676
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
project
=
context
def
calculateSoftwareProductTitle
(
software_release_url
):
if
not
software_release_url
.
startswith
(
'http'
):
return
software_release_url
try
:
result
=
software_release_url
.
split
(
'/'
)[
-
2
]
except
IndexError
:
result
=
software_release_url
if
not
software_release_url
.
endswith
(
'software.cfg'
):
result
+=
' %s'
%
software_release_url
.
split
(
'/'
)[
-
1
]
return
result
soft_dict
=
{}
###########################################################
# First, calculate the list of product by checking the instances
###########################################################
group_by_list
=
[
"url_string"
,
"follow_up__uid"
,
"source_reference"
]
sql_result_list
=
portal
.
portal_catalog
(
portal_type
=
[
"Software Instance"
,
"Slave Instance"
],
slap_state
=
[
"start_requested"
,
"stop_requested"
],
follow_up__uid
=
project
.
getUid
()
)
for
sql_result
in
sql_result_list
:
software_release_url
=
sql_result
.
getUrlString
()
software_product_title
=
calculateSoftwareProductTitle
(
software_release_url
)
if
software_product_title
not
in
soft_dict
:
soft_dict
[
software_product_title
]
=
{
'release_list'
:
[],
'type_list'
:
[]
}
soft_dict
[
software_product_title
][
'release_list'
].
append
(
software_release_url
)
soft_dict
[
software_product_title
][
'type_list'
].
append
(
sql_result
.
getSourceReference
())
###########################################################
# Second, get info from all installed softwares
###########################################################
group_by_list
=
[
"url_string"
,
"follow_up__uid"
]
sql_result_list
=
portal
.
portal_catalog
(
select_list
=
group_by_list
,
portal_type
=
"Software Installation"
,
slap_state
=
[
"start_requested"
],
follow_up__uid
=
project
.
getUid
(),
group_by
=
group_by_list
,
)
for
sql_result
in
sql_result_list
:
compute_node
=
sql_result
.
getAggregateValue
()
if
(
compute_node
is
not
None
)
and
(
compute_node
.
getAllocationScope
()
==
'open'
):
software_release_url
=
sql_result
[
'url_string'
]
software_product_title
=
calculateSoftwareProductTitle
(
software_release_url
)
if
software_product_title
not
in
soft_dict
:
soft_dict
[
software_product_title
]
=
{
'release_list'
:
[],
'type_list'
:
[]
}
soft_dict
[
software_product_title
][
'release_list'
].
append
(
software_release_url
)
###########################################################
# Create needed Software Product
###########################################################
for
soft
,
variation_dict
in
soft_dict
.
items
():
software_product
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Software Product"
,
follow_up__uid
=
project
.
getUid
()
)
if
software_product
is
None
:
software_product
=
portal
.
software_product_module
.
newContent
(
portal_type
=
"Software Product"
,
title
=
soft
,
follow_up_value
=
project
,
activate_kw
=
activate_kw
)
software_product
.
validate
()
for
software_type
in
list
(
set
(
variation_dict
[
'type_list'
])):
type_variation
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Software Product Type Variation"
,
title
=
software_type
,
parent_uid
=
software_product
.
getUid
()
)
if
type_variation
is
None
:
software_product
.
newContent
(
portal_type
=
"Software Product Type Variation"
,
title
=
software_type
,
activate_kw
=
activate_kw
)
release_list
=
list
(
set
(
variation_dict
[
'release_list'
]))
release_list
.
sort
()
for
software_release
in
release_list
:
software_release_variation
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Software Product Release Variation"
,
url_string
=
software_release
,
parent_uid
=
software_product
.
getUid
()
)
if
software_release_variation
is
None
:
software_product
.
newContent
(
portal_type
=
"Software Product Release Variation"
,
title
=
software_release
,
url_string
=
software_release
,
activate_kw
=
activate_kw
)
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Project_checkSoftwareProductToVirtualMaster.xml
0 → 100644
View file @
952b0676
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None, activate_kw=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Project_checkSoftwareProductToVirtualMaster
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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