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
Klaus Wölfel
slapos.core
Commits
35b57e5a
Commit
35b57e5a
authored
Mar 10, 2015
by
Alain Takoudjou
Committed by
Rafael Monnerat
Mar 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not recreate upgrade decision for the same sr if it was rejected
parent
6d028a66
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
5 deletions
+154
-5
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/SoftwareRelease_getUpgradeDecisionInProgress.xml
...apos_pdm/SoftwareRelease_getUpgradeDecisionInProgress.xml
+8
-2
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecision_tryToCancel.xml
...m/portal_skins/slapos_pdm/UpgradeDecision_tryToCancel.xml
+6
-3
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
+140
-0
No files found.
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/SoftwareRelease_getUpgradeDecisionInProgress.xml
View file @
35b57e5a
...
@@ -61,14 +61,20 @@ decision_line_in_progress_list = portal.portal_catalog(\n
...
@@ -61,14 +61,20 @@ decision_line_in_progress_list = portal.portal_catalog(\n
\n
\n
for decision_line in decision_line_in_progress_list:\n
for decision_line in decision_line_in_progress_list:\n
upgrade_decision = decision_line.getParentValue()\n
upgrade_decision = decision_line.getParentValue()\n
if upgrade_decision.getSimulationState() not in [\'planned\',\n
simulation_state = upgrade_decision.getSimulationState()\n
\'confirmed\', \'started\', \'stopped\']:\n
if simulation_state not in [\'planned\', \'confirmed\',\n
\'started\', \'stopped\', \'rejected\']:\n
continue\n
continue\n
release_list = decision_line.getAggregateValueList(portal_type="Software Release")\n
release_list = decision_line.getAggregateValueList(portal_type="Software Release")\n
if len(release_list) >
1:\n
if len(release_list) >
1:\n
continue\n
continue\n
if not release_list[0]:\n
if not release_list[0]:\n
continue\n
continue\n
# If the current sr in rejected we must prevent creation of new upgrade decision for this sr\n
if simulation_state == \'rejected\' and \\\n
release_list[0].getUrlString() != context.getUrlString():\n
continue\n
\n
# If both software release belong to the same software product, there is an upgrade decision in progress \n
# If both software release belong to the same software product, there is an upgrade decision in progress \n
if product_reference == release_list[0].getAggregateReference():\n
if product_reference == release_list[0].getAggregateReference():\n
return upgrade_decision\n
return upgrade_decision\n
...
...
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecision_tryToCancel.xml
View file @
35b57e5a
...
@@ -51,9 +51,11 @@
...
@@ -51,9 +51,11 @@
<item>
<item>
<key>
<string>
_body
</string>
</key>
<key>
<string>
_body
</string>
</key>
<value>
<string>
upgrade_decision = context\n
<value>
<string>
upgrade_decision = context\n
cancel_state_list = [\'confirmed\', \'planned\']\n
cancellable_state_list = [\'confirmed\', \'planned\']\n
require_state_list = [\'rejected\', \'confirmed\', \'planned\']\n
simulation_state = upgrade_decision.getSimulationState()\n
\n
\n
if
upgrade_decision.getSimulationState() in cancel
_state_list:\n
if
simulation_state in require
_state_list:\n
current_release = upgrade_decision.UpgradeDecision_getSoftwareRelease()\n
current_release = upgrade_decision.UpgradeDecision_getSoftwareRelease()\n
if not current_release:\n
if not current_release:\n
# This upgrade decision is not valid\n
# This upgrade decision is not valid\n
...
@@ -61,7 +63,8 @@ if upgrade_decision.getSimulationState() in cancel_state_list:\n
...
@@ -61,7 +63,8 @@ if upgrade_decision.getSimulationState() in cancel_state_list:\n
if current_release.getUrlString() == new_url_string:\n
if current_release.getUrlString() == new_url_string:\n
# Cannot cancel because the software releases are the same\n
# Cannot cancel because the software releases are the same\n
return False\n
return False\n
upgrade_decision.cancel()\n
if simulation_state in cancellable_state_list:\n
upgrade_decision.cancel()\n
return True\n
return True\n
else:\n
else:\n
return False\n
return False\n
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
View file @
35b57e5a
...
@@ -851,6 +851,42 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
...
@@ -851,6 +851,42 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
computer
.
getUid
())
computer
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
upgrade_decision2
.
getReference
())
self
.
assertEqual
(
in_progress
.
getReference
(),
upgrade_decision2
.
getReference
())
def
testSoftwareRelease_getUpgradeDecisionInProgress_rejected
(
self
):
computer
=
self
.
_makeComputer
()
software_product
=
self
.
_makeSoftwareProduct
()
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
computer
])
upgrade_decision
.
confirm
()
upgrade_decision
.
reject
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
computer
.
getUid
())
# XXX - in_progress is the rejected upgrade decision
self
.
assertEqual
(
in_progress
.
getReference
(),
upgrade_decision
.
getReference
())
new_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
tic
()
in_progress
=
new_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
computer
.
getUid
())
self
.
assertEqual
(
in_progress
,
None
)
upgrade_decision2
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line2
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision2
)
upgrade_decision_line2
.
setAggregateValueList
([
new_release
,
computer
])
upgrade_decision2
.
confirm
()
upgrade_decision2
.
start
()
self
.
tic
()
in_progress
=
new_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
computer
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
upgrade_decision2
.
getReference
())
def
testSoftwareRelease_getUpgradeDecisionInProgress_hosting_subs
(
self
):
def
testSoftwareRelease_getUpgradeDecisionInProgress_hosting_subs
(
self
):
person
=
self
.
_makePerson
()
person
=
self
.
_makePerson
()
...
@@ -970,7 +1006,26 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
...
@@ -970,7 +1006,26 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
self
.
assertEqual
(
upgrade_decision2
.
UpgradeDecision_tryToCancel
(
url
),
False
)
self
.
assertEqual
(
upgrade_decision2
.
UpgradeDecision_tryToCancel
(
url
),
False
)
self
.
assertEqual
(
upgrade_decision2
.
UpgradeDecision_tryToCancel
(
url2
),
False
)
self
.
assertEqual
(
upgrade_decision2
.
UpgradeDecision_tryToCancel
(
url2
),
False
)
self
.
assertEqual
(
upgrade_decision2
.
getSimulationState
(),
'started'
)
self
.
assertEqual
(
upgrade_decision2
.
getSimulationState
(),
'started'
)
def
testUpgradeDecision_tryToCancel_withRejected
(
self
):
computer
=
self
.
_makeComputer
()
software_release
=
self
.
_makeSoftwareRelease
()
software_release2
=
self
.
_makeSoftwareRelease
()
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
computer
])
upgrade_decision
.
confirm
()
upgrade_decision
.
reject
()
url
=
software_release
.
getUrlString
()
url2
=
software_release2
.
getUrlString
()
# Try to cancel rejected UD with the same sr will return False
self
.
assertEqual
(
upgrade_decision
.
UpgradeDecision_tryToCancel
(
url
),
False
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'rejected'
)
# Try to cancel rejected UD will return True with url2
self
.
assertEqual
(
upgrade_decision
.
UpgradeDecision_tryToCancel
(
url2
),
True
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'rejected'
)
def
testComputer_checkAndCreateUpgradeDecision
(
self
):
def
testComputer_checkAndCreateUpgradeDecision
(
self
):
person
=
self
.
_makePerson
()
person
=
self
.
_makePerson
()
...
@@ -1172,7 +1227,92 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
...
@@ -1172,7 +1227,92 @@ class TestSlapOSPDMSkins(testSlapOSMixin):
release
=
up_decision2
.
UpgradeDecision_getSoftwareRelease
()
release
=
up_decision2
.
UpgradeDecision_getSoftwareRelease
()
self
.
assertEqual
(
release
.
getUrlString
(),
self
.
assertEqual
(
release
.
getUrlString
(),
software_release3
.
getUrlString
())
software_release3
.
getUrlString
())
def
testComputer_hostingSubscriptionCreateUpgradeDecision_rejected
(
self
):
person
=
self
.
_makePerson
()
computer
=
self
.
_makeComputer
()
computer
.
edit
(
source_administration_value
=
person
)
self
.
_makeComputerPartitions
(
computer
)
software_product
=
self
.
_makeSoftwareProduct
()
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
computer
,
url_string
)
# Create Hosting Subscription and Software Instance
hosting_subscription
=
self
.
_makeFullHostingSubscription
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
hosting_subscription
,
url_string
)
self
.
_markComputerPartitionBusy
(
computer
,
hosting_subscription
.
getPredecessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
computer
,
software_release2
.
getUrlString
())
self
.
tic
()
decision_list
=
computer
.
Computer_hostingSubscriptionCreateUpgradeDecision
()
self
.
assertEqual
(
decision_list
[
0
].
getSimulationState
(),
'planned'
)
# Reject upgrade decision
decision_list
[
0
].
reject
()
self
.
tic
()
in_progress
=
software_release2
.
SoftwareRelease_getUpgradeDecisionInProgress
(
hosting_subscription
.
getUid
())
decision_list
=
computer
.
Computer_hostingSubscriptionCreateUpgradeDecision
()
# There is an upgrade decision in progress
self
.
assertNotEqual
(
in_progress
,
None
)
# No new upgrade decision created with software_release2
self
.
assertEqual
(
decision_list
,
[])
def
testComputer_hostingSubscriptionCreateUpgradeDecision_rejected_2
(
self
):
person
=
self
.
_makePerson
()
computer
=
self
.
_makeComputer
()
computer
.
edit
(
source_administration_value
=
person
)
self
.
_makeComputerPartitions
(
computer
)
software_product
=
self
.
_makeSoftwareProduct
()
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
computer
,
url_string
)
# Create Hosting Subscription and Software Instance
hosting_subscription
=
self
.
_makeFullHostingSubscription
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
hosting_subscription
,
url_string
)
self
.
_markComputerPartitionBusy
(
computer
,
hosting_subscription
.
getPredecessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
computer
,
software_release2
.
getUrlString
())
self
.
tic
()
decision_list
=
computer
.
Computer_hostingSubscriptionCreateUpgradeDecision
()
self
.
assertEqual
(
decision_list
[
0
].
getSimulationState
(),
'planned'
)
# Reject upgrade decision
up_decision
=
decision_list
[
0
]
up_decision
.
reject
()
self
.
tic
()
# Install the another software release
software_release3
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
computer
,
software_release3
.
getUrlString
())
self
.
tic
()
decision2
=
computer
.
Computer_hostingSubscriptionCreateUpgradeDecision
()[
0
]
self
.
assertEqual
(
decision2
.
getSimulationState
(),
'planned'
)
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'rejected'
)
release
=
decision2
.
UpgradeDecision_getSoftwareRelease
()
self
.
assertEqual
(
release
.
getUrlString
(),
software_release3
.
getUrlString
())
def
testBase_acceptUpgradeDecision_no_reference
(
self
):
def
testBase_acceptUpgradeDecision_no_reference
(
self
):
self
.
_makeUpgradeDecision
()
self
.
_makeUpgradeDecision
()
...
...
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