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
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
Carlos Ramos Carreño
slapos.core
Commits
4faf1cfa
Commit
4faf1cfa
authored
Apr 15, 2019
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_pdm: Create and launch upgrade based on upgrade scope
parent
26f32724
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
14 deletions
+25
-14
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/Alarm_checkAndUpgradeHostingSubscription.py
...ns/slapos_pdm/Alarm_checkAndUpgradeHostingSubscription.py
+2
-2
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/Computer_checkAndCreateUpgradeDecision.py
...kins/slapos_pdm/Computer_checkAndCreateUpgradeDecision.py
+7
-3
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/HostingSubscription_createUpgradeDecision.py
...s/slapos_pdm/HostingSubscription_createUpgradeDecision.py
+13
-6
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
+3
-3
No files found.
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/Alarm_checkAndUpgradeHostingSubscription.py
View file @
4faf1cfa
...
@@ -2,10 +2,10 @@ portal = context.getPortalObject()
...
@@ -2,10 +2,10 @@ portal = context.getPortalObject()
portal
.
portal_catalog
.
searchAndActivate
(
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
'Hosting Subscription'
,
portal_type
=
'Hosting Subscription'
,
validation_state
=
'validated'
,
validation_state
=
'validated'
,
slap_state
=
[
'start_requested'
,
'stop_requested'
],
method_id
=
'HostingSubscription_createUpgradeDecision'
,
method_id
=
'HostingSubscription_createUpgradeDecision'
,
packet_size
=
1
,
packet_size
=
1
,
activate_kw
=
{
'tag'
:
tag
}
activate_kw
=
{
'tag'
:
tag
},
**
{
"slapos_item.slap_state"
:
[
'start_requested'
,
'stop_requested'
]}
)
)
context
.
activate
(
after_tag
=
tag
).
getId
()
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/Computer_checkAndCreateUpgradeDecision.py
View file @
4faf1cfa
...
@@ -2,8 +2,12 @@ from DateTime import DateTime
...
@@ -2,8 +2,12 @@ from DateTime import DateTime
computer
=
context
computer
=
context
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
full_software_release_list
=
[
si
.
getUrlString
()
for
si
in
if
context
.
getUpgradeScope
()
==
"never"
:
return
full_software_release_list
=
[
si
.
url_string
for
si
in
portal
.
portal_catalog
(
portal
.
portal_catalog
(
select_dict
=
{
"url_string"
:
None
},
portal_type
=
'Software Installation'
,
portal_type
=
'Software Installation'
,
default_aggregate_uid
=
computer
.
getUid
(),
default_aggregate_uid
=
computer
.
getUid
(),
validation_state
=
'validated'
validation_state
=
'validated'
...
@@ -45,9 +49,9 @@ for software_release in software_release_list:
...
@@ -45,9 +49,9 @@ for software_release in software_release_list:
source_url
=
computer
.
getRelativeUrl
(),
source_url
=
computer
.
getRelativeUrl
(),
title
=
title
)
title
=
title
)
if
context
.
get
AllocationScope
()
in
[
"open/public"
,
"open/friend"
,
"open/subscription"
]
:
if
context
.
get
UpgradeScope
()
==
"auto"
:
upgrade_decision
.
start
()
upgrade_decision
.
start
()
elif
context
.
get
AllocationScope
()
in
[
"open/personal"
]
and
upgrade_decision
.
getSimulationState
()
!=
"planned"
:
elif
context
.
get
UpgradeScope
()
==
"ask_confirmation"
and
upgrade_decision
.
getSimulationState
()
!=
"planned"
:
upgrade_decision
.
plan
()
upgrade_decision
.
plan
()
upgrade_decision
.
setStartDate
(
DateTime
())
upgrade_decision
.
setStartDate
(
DateTime
())
...
...
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/HostingSubscription_createUpgradeDecision.py
View file @
4faf1cfa
...
@@ -2,22 +2,27 @@ from DateTime import DateTime
...
@@ -2,22 +2,27 @@ from DateTime import DateTime
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
hosting_subscription
=
context
hosting_subscription
=
context
if
context
.
getUpgradeScope
()
==
"never"
:
return
root_instance
=
hosting_subscription
.
getPredecessorValue
(
portal_type
=
"Software Instance"
)
if
root_instance
is
None
:
return
if
hosting_subscription
.
getSlapState
()
==
"destroy_requested"
:
return
tag
=
"%s_requestUpgradeDecisionCreation_inProgress"
%
hosting_subscription
.
getUid
()
tag
=
"%s_requestUpgradeDecisionCreation_inProgress"
%
hosting_subscription
.
getUid
()
activate_kw
=
{
'tag'
:
tag
}
activate_kw
=
{
'tag'
:
tag
}
if
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
:
if
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
:
# nothing to do
# nothing to do
return
return
root_instance
=
hosting_subscription
.
getPredecessorValue
()
if
root_instance
is
None
or
root_instance
.
getPortalType
()
==
"Slave Instance"
:
return
if
hosting_subscription
.
getSlapState
()
==
"destroy_requested"
:
return
partition
=
root_instance
.
getAggregateValue
(
portal_type
=
"Computer Partition"
)
partition
=
root_instance
.
getAggregateValue
(
portal_type
=
"Computer Partition"
)
if
partition
is
None
:
if
partition
is
None
:
return
return
if
not
partition
.
getParent
().
getAllocationScopeUid
()
in
[
category
.
getUid
()
\
if
not
partition
.
getParent
Value
().
getAllocationScopeUid
()
in
[
category
.
getUid
()
\
for
category
in
portal
.
portal_categories
.
allocation_scope
.
open
.
objectValues
()]:
for
category
in
portal
.
portal_categories
.
allocation_scope
.
open
.
objectValues
()]:
return
return
...
@@ -42,6 +47,8 @@ upgrade_decision = newer_release.SoftwareRelease_createUpgradeDecision(
...
@@ -42,6 +47,8 @@ upgrade_decision = newer_release.SoftwareRelease_createUpgradeDecision(
with
upgrade_decision
.
defaultActivateParameterDict
(
activate_kw
):
with
upgrade_decision
.
defaultActivateParameterDict
(
activate_kw
):
upgrade_decision
.
plan
()
upgrade_decision
.
plan
()
upgrade_decision
.
setStartDate
(
DateTime
())
upgrade_decision
.
setStartDate
(
DateTime
())
if
hosting_subscription
.
getUpgradeScope
()
==
"auto"
:
upgrade_decision
.
start
()
# Prevent concurrent transaction to create 2 upgrade decision for the same hosting_subscription
# Prevent concurrent transaction to create 2 upgrade decision for the same hosting_subscription
hosting_subscription
.
serialize
()
hosting_subscription
.
serialize
()
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
View file @
4faf1cfa
...
@@ -1026,9 +1026,8 @@ class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
...
@@ -1026,9 +1026,8 @@ class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
def
testComputer_checkAndCreateUpgradeDecision_personal_with_exist
(
self
):
def
testComputer_checkAndCreateUpgradeDecision_personal_with_exist
(
self
):
person
=
self
.
_makePerson
()
person
=
self
.
_makePerson
()
computer
=
self
.
_makeComputer
()
computer
=
self
.
_makeComputer
(
allocation_scope
=
"open/personal"
)
computer
.
edit
(
source_administration_value
=
person
,
computer
.
edit
(
source_administration_value
=
person
)
allocation_scope
=
"open/personal"
)
software_product
=
self
.
_makeSoftwareProduct
()
software_product
=
self
.
_makeSoftwareProduct
()
software_release
=
self
.
_requestSoftwareRelease
(
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
software_product
.
getRelativeUrl
())
...
@@ -1037,6 +1036,7 @@ class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
...
@@ -1037,6 +1036,7 @@ class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
computer
.
getUpgradeScope
(),
"ask_confirmation"
)
upgrade_decision
=
computer
.
Computer_checkAndCreateUpgradeDecision
()[
0
]
upgrade_decision
=
computer
.
Computer_checkAndCreateUpgradeDecision
()[
0
]
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'planned'
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'planned'
)
...
...
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