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
Ivan Tyagov
slapos.core
Commits
9a8e2947
Commit
9a8e2947
authored
Jan 03, 2019
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[slapos_pdm]: Prevent multiple activity nodes to create upgrade decision twice
parent
37589c69
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/HostingSubscription_createUpgradeDecision.py
...s/slapos_pdm/HostingSubscription_createUpgradeDecision.py
+9
-13
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
+3
-1
No files found.
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/HostingSubscription_createUpgradeDecision.py
View file @
9a8e2947
...
...
@@ -2,6 +2,12 @@ from DateTime import DateTime
portal
=
context
.
getPortalObject
()
hosting_subscription
=
context
tag
=
"%s_requestUpgradeDecisionCreation_inProgress"
%
hosting_subscription
.
getUid
()
activate_kw
=
{
'tag'
:
tag
}
if
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
:
# nothing to do
return
root_instance
=
hosting_subscription
.
getPredecessorValue
()
if
root_instance
is
None
or
root_instance
.
getPortalType
()
==
"Slave Instance"
:
return
...
...
@@ -29,23 +35,13 @@ if decision_in_progress and \
newer_release
.
getUrlString
()):
return
requested_decision
=
context
.
REQUEST
.
get
(
"upgrade_decision_request"
,
None
)
if
requested_decision
is
not
None
and
\
requested_decision
.
getTitle
()
==
decision_title
:
related_hosting
=
requested_decision
.
UpgradeDecision_getHostingSubscription
()
related_release
=
requested_decision
.
UpgradeDecision_getSoftwareRelease
()
if
related_hosting
is
not
None
and
\
related_hosting
.
getUid
()
==
hosting_subscription
.
getUid
()
and
\
related_release
.
getUid
()
==
newer_release
.
getUid
():
return
upgrade_decision
=
newer_release
.
SoftwareRelease_createUpgradeDecision
(
source_url
=
hosting_subscription
.
getRelativeUrl
(),
title
=
decision_title
)
upgrade_decision
.
plan
()
upgrade_decision
.
setStartDate
(
DateTime
()
)
context
.
REQUEST
.
set
(
"upgrade_decision_request"
,
upgrade_decision
)
with
upgrade_decision
.
defaultActivateParameterDict
(
activate_kw
):
upgrade_decision
.
plan
(
)
upgrade_decision
.
setStartDate
(
DateTime
()
)
# Prevent concurrent transaction to create 2 upgrade decision for the same hosting_subscription
hosting_subscription
.
serialize
()
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
View file @
9a8e2947
...
...
@@ -26,6 +26,7 @@
#
##############################################################################
import
transaction
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
simulate
from
DateTime
import
DateTime
...
...
@@ -1134,7 +1135,7 @@ class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
up_decision
=
hosting_subscription
.
HostingSubscription_createUpgradeDecision
()
self
.
assertEqual
(
up_decision
,
None
)
def
testHostingSubscription_createUpgradeDecision_create_once
(
self
):
def
testHostingSubscription_createUpgradeDecision_create_once
_transaction
(
self
):
person
=
self
.
_makePerson
()
computer
=
self
.
_makeComputer
(
allocation_scope
=
"open/personal"
)
computer
.
edit
(
source_administration_value
=
person
)
...
...
@@ -1163,6 +1164,7 @@ class TestSlapOSPDMSkins(SlapOSTestCaseMixin):
up_decision
=
hosting_subscription
.
HostingSubscription_createUpgradeDecision
()
self
.
assertNotEqual
(
up_decision
,
None
)
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'planned'
)
transaction
.
commit
()
# call a second time without tic
up_decision
=
hosting_subscription
.
HostingSubscription_createUpgradeDecision
()
# no new Upgrade decision created
...
...
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