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
594335b7
Commit
594335b7
authored
Nov 29, 2023
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_upgrader: migrate computer network
parent
01550c05
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
242 additions
and
21 deletions
+242
-21
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep2.py
...ader/Base_triggerFullSiteMigrationToVirtualMasterStep2.py
+44
-20
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep2.xml
...der/Base_triggerFullSiteMigrationToVirtualMasterStep2.xml
+1
-1
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputeNode_checkSiteMigrationToVirtualMaster.py
...upgrader/ComputeNode_checkSiteMigrationToVirtualMaster.py
+6
-0
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_checkSiteMigrationToVirtualMaster.py
...ader/ComputerNetwork_checkSiteMigrationToVirtualMaster.py
+42
-0
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_checkSiteMigrationToVirtualMaster.xml
...der/ComputerNetwork_checkSiteMigrationToVirtualMaster.xml
+62
-0
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_triggerObjectMigrationToVirtualMaster.py
.../ComputerNetwork_triggerObjectMigrationToVirtualMaster.py
+25
-0
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_triggerObjectMigrationToVirtualMaster.xml
...ComputerNetwork_triggerObjectMigrationToVirtualMaster.xml
+62
-0
No files found.
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep2.py
View file @
594335b7
...
...
@@ -3,24 +3,30 @@ portal = context.getPortalObject()
tag
=
script
.
id
not_migrated_select_dict
=
{
'default_follow_up_uid'
:
None
}
############################################
# Delete all object to drop
############################################
packet_kw
=
{
'activate_kw'
:
{
'tag'
:
tag
},
# 'serialization_tag': tag},
'packet_size'
:
1
,
# Separate calls to many transactions (calculation can take time)
'activity_count'
:
1000
,
}
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'Base_deleteProcessedDocumentDuringPurge'
,
portal_type
=
[
"Upgrade Decision"
],
**
packet_kw
)
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'Base_deleteProcessedDocumentDuringPurge'
,
portal_type
=
[
"Regularisation Request"
],
**
packet_kw
)
if
run_count
==
1
:
############################################
# Delete all object to drop
############################################
packet_kw
=
{
'activate_kw'
:
{
'tag'
:
tag
},
# 'serialization_tag': tag},
'packet_size'
:
1
,
# Separate calls to many transactions (calculation can take time)
'activity_count'
:
1000
,
}
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'Base_deleteProcessedDocumentDuringPurge'
,
portal_type
=
[
"Upgrade Decision"
],
**
packet_kw
)
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'Base_deleteProcessedDocumentDuringPurge'
,
portal_type
=
[
"Regularisation Request"
],
**
packet_kw
)
############################################
# Migrate existing projects
############################################
portal
.
project_module
.
activate
(
**
{
'tag'
:
tag
,
'priority'
:
1
}).
ProjectModule_triggerObjectMigrationToVirtualMaster
()
############################################
# Gather compute node informations
...
...
@@ -50,6 +56,24 @@ portal.portal_catalog.searchAndActivate(
**
not_migrated_select_dict
)
portal
.
project_module
.
activate
(
**
{
'tag'
:
tag
,
'priority'
:
1
}).
ProjectModule_triggerObjectMigrationToVirtualMaster
()
############################################
# Gather computer network informations
############################################
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'ComputerNetwork_checkSiteMigrationToVirtualMaster'
,
activate_kw
=
{
'tag'
:
tag
,
'priority'
:
1
},
portal_type
=
"Computer Network"
,
select_dict
=
not_migrated_select_dict
,
left_join_list
=
not_migrated_select_dict
.
keys
(),
**
not_migrated_select_dict
)
context
.
activate
(
after_tag
=
tag
).
getId
()
if
run_count
<
5
:
# Run the migration script multiple times
# Because some object are migrated only after some others are migrated
context
.
activate
(
after_tag
=
tag
).
Base_triggerFullSiteMigrationToVirtualMasterStep2
(
run_count
=
run_count
+
1
)
else
:
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/Base_triggerFullSiteMigrationToVirtualMasterStep2.xml
View file @
594335b7
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
<value>
<string>
run_count=1
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputeNode_checkSiteMigrationToVirtualMaster.py
View file @
594335b7
...
...
@@ -42,6 +42,7 @@ for partition in partition_list:
# XXX check if the instance tree is only hosted on this machine
instance_tree_list
=
list
(
set
(
instance_tree_list
))
computer_network
=
compute_node
.
getSubordinationValue
(
portal_type
=
"Computer Network"
)
# Already migrate unused compute node
if
(
len
(
not_migrated_compute_node
[
'instance_list'
])
==
0
)
and
\
...
...
@@ -57,6 +58,11 @@ elif not_migrated_compute_node['project_relative_url'] is not None:
compute_node
.
activate
().
Base_activateObjectMigrationToVirtualMaster
(
not_migrated_compute_node
[
'project_relative_url'
])
not_migrated_compute_node_dict
.
pop
(
compute_node_relative_url
)
elif
(
computer_network
is
not
None
)
and
(
computer_network
.
getFollowUp
(
None
)
is
not
None
):
# Network is already linked to a project
compute_node
.
activate
().
Base_activateObjectMigrationToVirtualMaster
(
computer_network
.
getFollowUp
())
not_migrated_compute_node_dict
.
pop
(
compute_node_relative_url
)
else
:
# If the related instance are all grouped on this machine, and from the same user
from_same_user_only
=
True
...
...
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_checkSiteMigrationToVirtualMaster.py
0 → 100644
View file @
594335b7
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
computer_network
=
context
.
getObject
()
computer_network_relative_url
=
computer_network
.
getRelativeUrl
()
last_affectation_list
=
computer_network
.
Item_getAffectationList
()
project_relative_url
=
None
if
last_affectation_list
and
last_affectation_list
[
0
].
project_uid
:
project_uid
=
last_affectation_list
[
0
].
project_uid
project_relative_url
=
portal
.
portal_catalog
.
getResultValue
(
uid
=
project_uid
).
getRelativeUrl
()
not_migrated_computer_network
=
{
'title'
:
computer_network
.
getTitle
(),
'project_relative_url'
:
project_relative_url
,
# Category has been dropped from the Computer Network portal type
'source_administration'
:
([
x
[
len
(
'source_administration/'
):]
for
x
in
computer_network
.
getCategoryList
()
if
x
.
startswith
(
'source_administration'
)]
or
[
None
])[
0
],
}
# If network has no compute node, move it to user personal project
compute_node_list
=
[
x
.
getObject
()
for
x
in
portal
.
portal_catalog
(
portal_type
=
"Compute Node"
,
subordination__uid
=
computer_network
.
getUid
()
)]
project_list
=
[
x
.
getFollowUp
(
None
)
for
x
in
compute_node_list
]
project_list
=
list
(
set
(
project_list
))
# Node linked to a project
if
not_migrated_computer_network
[
'project_relative_url'
]
is
not
None
:
computer_network
.
activate
().
Base_activateObjectMigrationToVirtualMaster
(
not_migrated_computer_network
[
'project_relative_url'
])
elif
(
len
(
compute_node_list
)
==
0
)
and
(
not_migrated_computer_network
[
'source_administration'
]
is
not
None
):
# No compute node. Move it to user personal project
source_administration_value
=
portal
.
restrictedTraverse
(
not_migrated_computer_network
[
'source_administration'
])
source_administration_value
.
Person_checkSiteMigrationCreatePersonalVirtualMaster
([
computer_network_relative_url
])
elif
(
len
(
project_list
)
==
1
)
and
(
project_list
[
0
]
is
not
None
):
# All nodes are linked to the same project
computer_network
.
activate
().
Base_activateObjectMigrationToVirtualMaster
(
project_list
[
0
])
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_checkSiteMigrationToVirtualMaster.xml
0 → 100644
View file @
594335b7
<?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
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ComputerNetwork_checkSiteMigrationToVirtualMaster
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_triggerObjectMigrationToVirtualMaster.py
0 → 100644
View file @
594335b7
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
computer_network
=
context
project
=
portal
.
restrictedTraverse
(
project_relative_url
)
edit_kw
=
{}
# Check if it has been migrated first
if
computer_network
.
getFollowUpValue
()
is
None
:
edit_kw
[
'follow_up_value'
]
=
project
# Migrate
if
edit_kw
:
computer_network
.
edit
(
**
edit_kw
)
# Drop outdated categories
category_list
=
computer_network
.
getCategoryList
()
new_category_list
=
[
x
for
x
in
category_list
if
not
x
.
startswith
(
'source_administration'
)]
if
len
(
category_list
)
!=
len
(
new_category_list
):
computer_network
.
setCategoryList
(
new_category_list
)
master/bt5/slapos_upgrader/SkinTemplateItem/portal_skins/slapos_upgrader/ComputerNetwork_triggerObjectMigrationToVirtualMaster.xml
0 → 100644
View file @
594335b7
<?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>
project_relative_url, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ComputerNetwork_triggerObjectMigrationToVirtualMaster
</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