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
1a2dcd97
Commit
1a2dcd97
authored
Jan 23, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_pdm: check upgrade
parent
3f096f85
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
143 additions
and
1235 deletions
+143
-1235
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecision_processUpgrade.py
...portal_skins/slapos_pdm/UpgradeDecision_processUpgrade.py
+40
-0
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecision_processUpgrade.xml
...ortal_skins/slapos_pdm/UpgradeDecision_processUpgrade.xml
+3
-25
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
+12
-72
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
...ents/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
+0
-67
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
+88
-953
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_requestUpgrade.py
...terface_workflow/script_UpgradeDecision_requestUpgrade.py
+0
-51
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/state_draft.xml
..._workflow/upgrade_slap_interface_workflow/state_draft.xml
+0
-1
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/transition_request_upgrade.xml
...de_slap_interface_workflow/transition_request_upgrade.xml
+0
-66
No files found.
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecision_processUpgrade.py
0 → 100644
View file @
1a2dcd97
from
DateTime
import
DateTime
upgrade_decision
=
context
if
upgrade_decision
.
getSimulationState
()
!=
'started'
:
# Update Decision is not on started state, Upgrade is not possible!
return
instance_tree
=
upgrade_decision
.
getAggregateValue
(
"Instance Tree"
)
software_release_url
=
upgrade_decision
.
getSoftwareReleaseValue
().
getUrlString
()
status
=
instance_tree
.
getSlapState
()
if
status
==
"start_requested"
:
state
=
"started"
elif
status
==
"stop_requested"
:
state
=
"stopped"
elif
status
==
"destroy_requested"
:
state
=
"destroyed"
else
:
raise
ValueError
(
'Unhandled state: %s'
%
status
)
if
state
==
'destroyed'
:
# Nothing to do
upgrade_decision
.
reject
(
comment
=
"Instance Tree destroyed"
)
else
:
person
=
instance_tree
.
getDestinationSectionValue
(
portal_type
=
"Person"
)
person
.
requestSoftwareInstance
(
state
=
state
,
software_release
=
software_release_url
,
software_title
=
instance_tree
.
getTitle
(),
software_type
=
instance_tree
.
getSourceReference
(),
instance_xml
=
instance_tree
.
getTextContent
(),
sla_xml
=
instance_tree
.
getSlaXml
(),
shared
=
instance_tree
.
isRootSlave
(),
project_reference
=
instance_tree
.
getFollowUpReference
()
)
upgrade_decision
.
stop
(
comment
=
"Upgrade Processed for the Instance Tree!"
)
master/bt5/slapos_pdm/
WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_request
Upgrade.xml
→
master/bt5/slapos_pdm/
SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecision_process
Upgrade.xml
View file @
1a2dcd97
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<ZopeData>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<pickle>
<global
name=
"
Workflow Script"
module=
"erp5.portal_type
"
/>
<global
name=
"
PythonScript"
module=
"Products.PythonScripts.PythonScript
"
/>
</pickle>
</pickle>
<pickle>
<pickle>
<dictionary>
<dictionary>
...
@@ -50,33 +50,11 @@
...
@@ -50,33 +50,11 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
state_change
</string>
</value>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
script_UpgradeDecision_requestUpgrade
</string>
</value>
<value>
<string>
UpgradeDecision_processUpgrade
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Workflow Script
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
UpgradeDecision_requestUpgrade
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
View file @
1a2dcd97
...
@@ -21,15 +21,12 @@
...
@@ -21,15 +21,12 @@
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
TemporaryAlarmScript
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
TemporaryAlarmScript
class
TestSlapOSUpgradeDecisionProcess
(
SlapOSTestCaseMixin
):
class
TestSlapOSUpgradeDecisionProcess
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
new_id
=
self
.
generateNewId
()
def
_makeUpgradeDecision
(
self
,
confirm
=
True
):
def
_makeUpgradeDecision
(
self
,
confirm
=
True
):
upgrade_decision
=
self
.
portal
.
\
upgrade_decision
=
self
.
portal
.
\
upgrade_decision_module
.
newContent
(
upgrade_decision_module
.
newContent
(
portal_type
=
"Upgrade Decision"
,
portal_type
=
"Upgrade Decision"
,
title
=
"TESTUPDE-%s"
%
self
.
new_id
)
title
=
"TESTUPDE-%s"
%
self
.
generateNewId
()
)
if
confirm
:
if
confirm
:
upgrade_decision
.
confirm
()
upgrade_decision
.
confirm
()
return
upgrade_decision
return
upgrade_decision
...
@@ -39,85 +36,28 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
...
@@ -39,85 +36,28 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
.
instance_tree_module
.
template_instance_tree
\
.
instance_tree_module
.
template_instance_tree
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
.
validate
()
instance_tree
.
validate
()
new_id
=
self
.
generateNewId
()
instance_tree
.
edit
(
instance_tree
.
edit
(
title
=
"Test hosting sub start %s"
%
self
.
new_id
,
title
=
"Test hosting sub start %s"
%
new_id
,
reference
=
"TESTHSS-%s"
%
self
.
new_id
,
reference
=
"TESTHSS-%s"
%
new_id
)
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
slap_state
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
slap_state
)
return
instance_tree
return
instance_tree
def
test_
tocheck_
alarm_upgrade_decision_process_instance_tree
(
self
):
def
test_alarm_upgrade_decision_process_instance_tree
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
start
()
upgrade_decision
.
start
()
self
.
tic
()
self
.
tic
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_started
,
upgrade_decision
,
'UpgradeDecision_processUpgrade'
)
def
test_tocheck_alarm_upgrade_decision_process_planned
(
self
):
with
TemporaryAlarmScript
(
self
.
portal
,
'UpgradeDecision_processUpgrade'
):
upgrade_decision
=
self
.
_makeUpgradeDecision
(
confirm
=
0
)
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_started
.
\
upgrade_decision
.
plan
()
activeSense
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_planned
,
upgrade_decision
,
'UpgradeDecision_notify'
)
def
test_tocheck_alarm_upgrade_decision_process_stopped
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
start
()
upgrade_decision
.
stop
()
self
.
tic
()
self
.
tic
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_stopped
,
upgrade_decision
,
'UpgradeDecision_notifyDelivered'
)
def
_test_alarm_compute_node_create_upgrade_decision
(
self
,
allocation_scope
,
upgrade_scope
):
compute_node
=
self
.
_makeComputeNode
(
allocation_scope
=
allocation_scope
)[
0
]
compute_node
.
setUpgradeScope
(
upgrade_scope
)
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_compute_node_create_upgrade_decision
,
compute_node
,
'ComputeNode_checkAndCreateUpgradeDecision'
)
def
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
self
,
allocation_scope
,
upgrade_scope
):
compute_node
=
self
.
_makeComputeNode
(
allocation_scope
=
allocation_scope
)[
0
]
compute_node
.
setUpgradeScope
(
upgrade_scope
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_pdm_compute_node_create_upgrade_decision
,
compute_node
,
'ComputeNode_checkAndCreateUpgradeDecision'
)
def
test_alarm_compute_node_create_upgrade_decision_auto
(
self
):
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/public'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/personal'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/subscription'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/outdated'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/maintanance'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/termination'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/noallocation'
,
'auto'
)
def
test_alarm_compute_node_create_upgrade_decision_ask_confirmation
(
self
):
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/public'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/personal'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/subscription'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/outdated'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/maintanance'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/termination'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/noallocation'
,
'confirmation'
)
def
test_alarm_compute_node_create_upgrade_decision_never
(
self
):
self
.
assertEqual
(
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'open/public'
,
'never'
)
'Visited by UpgradeDecision_processUpgrade'
,
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'open/personal'
,
'never'
)
upgrade_decision
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'open/subscription'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'close/outdated'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'close/maintanance'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'close/termination'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'close/noallocation'
,
'never'
)
def
test_alarm_instance_tree_create_upgrade_decision
(
self
):
def
test_alarm_instance_tree_create_upgrade_decision
(
self
):
instance_tree
=
self
.
_makeInstanceTree
()
instance_tree
=
self
.
_makeInstanceTree
()
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
View file @
1a2dcd97
...
@@ -37,73 +37,6 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -37,73 +37,6 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
)
)
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
def
bootstrapAllocableInstanceTree
(
self
,
is_allocated
=
False
,
shared
=
False
,
node
=
"compute"
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
release_variation
=
software_product
.
contentValues
(
portal_type
=
'Software Product Release Variation'
)[
0
]
type_variation
=
software_product
.
contentValues
(
portal_type
=
'Software Product Type Variation'
)[
0
]
self
.
tic
()
if
node
==
"compute"
:
person
.
requestComputeNode
(
compute_node_title
=
'test compute node'
,
project_reference
=
project
.
getReference
())
self
.
tic
()
compute_node
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Compute Node'
,
reference
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_reference'
)
)
assert
compute_node
is
not
None
elif
node
==
"remote"
:
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Remote Node"
,
follow_up_value
=
project
)
elif
node
==
"instance"
:
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Instance Node"
,
follow_up_value
=
project
)
else
:
raise
ValueError
(
"Unsupported node value: %s"
%
node
)
request_kw
=
dict
(
software_release
=
release_variation
.
getUrlString
(),
software_type
=
type_variation
.
getTitle
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
shared
,
software_title
=
'test tree'
,
state
=
'started'
,
project_reference
=
project
.
getReference
()
)
person
.
requestSoftwareInstance
(
**
request_kw
)
instance_tree
=
self
.
portal
.
REQUEST
.
get
(
'request_instance_tree'
)
if
is_allocated
:
if
(
node
==
"instance"
)
and
(
shared
):
real_compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Compute Node"
,
follow_up_value
=
project
)
partition
=
real_compute_node
.
newContent
(
portal_type
=
'Compute Partition'
)
software_instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
"Software Instance"
,
follow_up_value
=
project
,
aggregate_value
=
partition
)
compute_node
.
edit
(
specialise_value
=
software_instance
)
elif
(
node
==
"instance"
)
and
(
not
shared
):
raise
NotImplementedError
(
'can not allocate on instance node'
)
else
:
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
)
instance
=
instance_tree
.
getSuccessorValue
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
return
software_product
,
release_variation
,
type_variation
,
compute_node
,
instance_tree
def
checkCreatedUpgradeDecision
(
self
,
upgrade_decision
,
instance_tree
,
def
checkCreatedUpgradeDecision
(
self
,
upgrade_decision
,
instance_tree
,
software_product
,
release_variation
,
software_product
,
release_variation
,
type_variation
):
type_variation
):
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
View file @
1a2dcd97
...
@@ -19,983 +19,118 @@
...
@@ -19,983 +19,118 @@
#
#
##############################################################################
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
simulate
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
DateTime
import
DateTime
class
TestSlapOSPDMMixinSkins
(
SlapOSTestCaseMixin
):
class
TestSlapOSPDMMixinSkins
(
SlapOSTestCaseMixin
):
def
XXXafterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
new_id
=
self
.
generateNewId
()
self
.
request_kw
=
dict
(
software_title
=
self
.
generateNewSoftwareTitle
(),
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateEmptyXml
(),
shared
=
False
,
state
=
"started"
)
def
_makePerson
(
self
,
project
):
def
bootstrapAllocableInstanceTree
(
self
,
is_allocated
=
False
,
shared
=
False
,
node
=
"compute"
):
return
self
.
makePerson
(
project
,
new_id
=
self
.
new_id
)
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
)
def
_makeComputePartitions
(
self
,
compute_node
):
software_product
=
self
.
_makeSoftwareProduct
(
project
)
for
i
in
range
(
1
,
5
):
release_variation
=
software_product
.
contentValues
(
portal_type
=
'Software Product Release Variation'
)[
0
]
id_
=
'partition%s'
%
(
i
,
)
type_variation
=
software_product
.
contentValues
(
portal_type
=
'Software Product Type Variation'
)[
0
]
p
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
id
=
id_
,
title
=
id_
,
reference
=
id_
,
default_network_address_ip_address
=
'ip_address_%s'
%
i
,
default_network_address_netmask
=
'netmask_%s'
%
i
)
p
.
markFree
()
p
.
validate
()
def
_requestSoftwareRelease
(
self
,
software_product_url
,
effective_date
=
None
):
self
.
tic
()
software_release
=
self
.
_makeSoftwareRelease
(
self
.
project
)
if
node
==
"compute"
:
if
not
effective_date
:
person
.
requestComputeNode
(
compute_node_title
=
'test compute node'
,
effective_date
=
DateTime
()
project_reference
=
project
.
getReference
())
software_release
.
edit
(
self
.
tic
()
aggregate_value
=
software_product_url
,
compute_node
=
self
.
portal
.
portal_catalog
.
getResultValue
(
effective_date
=
effective_date
portal_type
=
'Compute Node'
,
reference
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_reference'
)
)
)
software_release
.
publish
()
assert
compute_node
is
not
None
return
software_release
elif
node
==
"remote"
:
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
def
_makeCustomSoftwareRelease
(
self
,
software_product
,
software_url
):
portal_type
=
"Remote Node"
,
return
self
.
_makeSoftwareRelease
(
software_product
,
url
=
software_url
)
follow_up_value
=
project
def
_makeSoftwareInstallation
(
self
,
compute_node
,
software_release_url
):
software_installation
=
self
.
portal
\
.
software_installation_module
.
template_software_installation
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
software_installation
.
edit
(
url_string
=
software_release_url
,
aggregate
=
compute_node
.
getRelativeUrl
(),
reference
=
'TESTSOFTINSTS-%s'
%
new_id
,
title
=
'Start requested for %s'
%
compute_node
.
getUid
()
)
)
software_installation
.
validate
()
elif
node
==
"instance"
:
software_installation
.
requestStart
()
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Instance Node"
,
return
software_installation
follow_up_value
=
project
def
_makeInstanceTree
(
self
):
instance_tree
=
self
.
portal
\
.
instance_tree_module
.
template_instance_tree
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
.
validate
()
instance_tree
.
edit
(
title
=
"Test hosting sub start %s"
%
self
.
new_id
,
reference
=
"TESTHSS-%s"
%
self
.
new_id
,
)
)
else
:
raise
ValueError
(
"Unsupported node value: %s"
%
node
)
return
instance_tree
request_kw
=
dict
(
software_release
=
release_variation
.
getUrlString
(),
def
_makeSoftwareInstance
(
self
,
instance_tree
,
software_url
):
software_type
=
type_variation
.
getTitle
(),
kw
=
dict
(
software_release
=
software_url
,
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
,
shared
=
shared
,
software_title
=
instance_tree
.
getTitle
(),
software_title
=
'test tree'
,
state
=
'started'
state
=
'started'
,
)
project_reference
=
project
.
getReference
()
instance_tree
.
requestStart
(
**
kw
)
instance_tree
.
requestInstance
(
**
kw
)
def
_makeFullInstanceTree
(
self
,
project
,
software_url
=
""
,
person
=
None
):
if
not
person
:
person
=
self
.
_makePerson
(
project
)
instance_tree
=
self
.
portal
\
.
instance_tree_module
.
template_instance_tree
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
.
edit
(
title
=
self
.
request_kw
[
'software_title'
],
reference
=
"TESTHS-%s"
%
self
.
new_id
,
url_string
=
software_url
,
source_reference
=
self
.
request_kw
[
'software_type'
],
text_content
=
self
.
request_kw
[
'instance_xml'
],
sla_xml
=
self
.
request_kw
[
'sla_xml'
],
root_slave
=
self
.
request_kw
[
'shared'
],
destination_section
=
person
.
getRelativeUrl
()
)
)
instance_tree
.
validate
()
person
.
requestSoftwareInstance
(
**
request_kw
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
'start_requested'
)
instance_tree
=
self
.
portal
.
REQUEST
.
get
(
'request_instance_tree'
)
return
instance_tree
def
_makeFullSoftwareInstance
(
self
,
instance_tree
,
software_url
):
software_instance
=
self
.
portal
.
software_instance_module
\
.
template_software_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
software_instance
.
edit
(
title
=
self
.
request_kw
[
'software_title'
],
reference
=
"TESTSI-%s"
%
self
.
generateNewId
(),
url_string
=
software_url
,
source_reference
=
self
.
request_kw
[
'software_type'
],
text_content
=
self
.
request_kw
[
'instance_xml'
],
sla_xml
=
self
.
request_kw
[
'sla_xml'
],
specialise
=
instance_tree
.
getRelativeUrl
()
)
instance_tree
.
edit
(
successor
=
software_instance
.
getRelativeUrl
()
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'start_requested'
)
software_instance
.
validate
()
return
software_instance
def
_makeUpgradeDecision
(
self
):
return
self
.
portal
.
\
upgrade_decision_module
.
newContent
(
portal_type
=
"Upgrade Decision"
,
title
=
"TESTUPDE-%s"
%
self
.
new_id
)
def
_makeUpgradeDecisionLine
(
self
,
upgrade_decision
):
return
upgrade_decision
.
newContent
(
portal_type
=
"Upgrade Decision Line"
,
title
=
"TESTUPDE-%s"
%
self
.
new_id
)
class
TestSlapOSPDMSkins
(
TestSlapOSPDMMixinSkins
):
def
test_tocheckSoftwareRelease_createUpgradeDecision_compute_node
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
software_release
.
SoftwareRelease_createUpgradeDecision
(
source_url
=
compute_node
.
getRelativeUrl
(),
title
=
"TEST-SRUPDE-%s"
%
self
.
new_id
)
self
.
tic
()
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'draft'
)
self
.
assertEqual
(
upgrade_decision
.
getDestinationSection
(),
person
.
getRelativeUrl
())
decision_line
=
upgrade_decision
.
contentValues
(
portal_type
=
'Upgrade Decision Line'
)[
0
]
self
.
assertEqual
(
decision_line
.
getTitle
(),
'Request decision upgrade for %s on Compute Node %s'
%
(
software_release
.
getTitle
(),
compute_node
.
getReference
())
)
self
.
assertEqual
(
decision_line
.
getAggregate
(
portal_type
=
'Compute Node'
),
compute_node
.
getRelativeUrl
())
self
.
assertEqual
(
decision_line
.
getAggregate
(
portal_type
=
'Software Release'
),
software_release
.
getRelativeUrl
())
def
test_tocheckSoftwareRelease_createUpgradeDecision_hostingSubscription
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
instance_tree
=
self
.
_makeInstanceTree
()
instance_tree
.
edit
(
destination_section_value
=
person
.
getRelativeUrl
())
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
software_release
.
SoftwareRelease_createUpgradeDecision
(
source_url
=
instance_tree
.
getRelativeUrl
(),
title
=
"TEST-SRUPDE-%s"
%
self
.
new_id
)
self
.
tic
()
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'draft'
)
self
.
assertEqual
(
upgrade_decision
.
getDestinationSection
(),
person
.
getRelativeUrl
())
decision_line
=
upgrade_decision
.
contentValues
(
portal_type
=
'Upgrade Decision Line'
)[
0
]
self
.
assertEqual
(
decision_line
.
getAggregate
(
portal_type
=
'Instance Tree'
),
instance_tree
.
getRelativeUrl
())
self
.
assertEqual
(
decision_line
.
getAggregate
(
portal_type
=
'Software Release'
),
software_release
.
getRelativeUrl
())
def
test_tocheckSoftwareRelease_getUpgradeDecisionInProgress
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
compute_node
])
software_release2
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
.
confirm
()
reference
=
upgrade_decision
.
getReference
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
reference
)
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
software_release
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
reference
)
in_progress
=
software_release2
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
,
None
)
def
test_tocheckSoftwareRelease_getUpgradeDecisionInProgress_cancelled
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
compute_node
])
upgrade_decision
.
confirm
()
upgrade_decision
.
cancel
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
,
None
)
upgrade_decision2
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line2
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision2
)
upgrade_decision_line2
.
setAggregateValueList
([
software_release
,
compute_node
])
upgrade_decision2
.
confirm
()
upgrade_decision2
.
start
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
upgrade_decision2
.
getReference
())
def
test_tocheckSoftwareRelease_getUpgradeDecisionInProgress_rejected
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
compute_node
])
upgrade_decision
.
confirm
()
upgrade_decision
.
reject
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
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
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
,
None
)
upgrade_decision2
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line2
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision2
)
upgrade_decision_line2
.
setAggregateValueList
([
new_release
,
compute_node
])
upgrade_decision2
.
confirm
()
upgrade_decision2
.
start
()
self
.
tic
()
in_progress
=
new_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
upgrade_decision2
.
getReference
())
def
test_tocheckSoftwareRelease_getUpgradeDecisionInProgress_hosting_subs
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
instance_tree
=
self
.
_makeInstanceTree
()
instance_tree
.
edit
(
destination_section_value
=
person
.
getRelativeUrl
())
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
upgrade_decision
.
confirm
()
reference
=
upgrade_decision
.
getReference
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
instance_tree
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
reference
)
upgrade_decision
.
cancel
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
instance_tree
.
getUid
())
self
.
assertEqual
(
in_progress
,
None
)
def
test_tocheckSoftwareRelease_getUpgradeDecisionInProgress_software_product
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
software_release3
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
compute_node
])
upgrade_decision
.
confirm
()
reference
=
upgrade_decision
.
getReference
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
reference
)
in_progress
=
software_release2
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
reference
)
in_progress
=
software_release3
.
SoftwareRelease_getUpgradeDecisionInProgress
(
compute_node
.
getUid
())
self
.
assertEqual
(
in_progress
,
None
)
def
test_tocheckSoftwareRelease_getUpgradeDecisionInProgress_software_product_hs
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
instance_tree
=
self
.
_makeInstanceTree
()
instance_tree
.
edit
(
destination_section_value
=
person
.
getRelativeUrl
())
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
software_release3
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
upgrade_decision
.
confirm
()
reference
=
upgrade_decision
.
getReference
()
reference
=
upgrade_decision
.
getReference
()
self
.
tic
()
in_progress
=
software_release
.
SoftwareRelease_getUpgradeDecisionInProgress
(
instance_tree
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
reference
)
in_progress
=
software_release2
.
SoftwareRelease_getUpgradeDecisionInProgress
(
instance_tree
.
getUid
())
self
.
assertEqual
(
in_progress
.
getReference
(),
reference
)
in_progress
=
software_release3
.
SoftwareRelease_getUpgradeDecisionInProgress
(
instance_tree
.
getUid
())
self
.
assertEqual
(
in_progress
,
None
)
def
test_tocheckComputeNode_checkAndCreateUpgradeDecision_auto
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
,
allocation_scope
=
"open"
)
compute_node
.
edit
(
upgrade_scope
=
"auto"
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release
.
getUrlString
())
self
.
tic
()
upgrade_decision
=
compute_node
.
ComputeNode_checkAndCreateUpgradeDecision
()
self
.
assertEqual
(
len
(
upgrade_decision
),
0
)
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
# Should be ignored, Publication Date is for tomorrow
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
(),
(
DateTime
()
+
1
))
self
.
tic
()
upgrade_decision
=
compute_node
.
ComputeNode_checkAndCreateUpgradeDecision
()
self
.
assertEqual
(
len
(
upgrade_decision
),
1
)
self
.
assertEqual
(
upgrade_decision
[
0
].
getSimulationState
(),
'started'
)
compute_node_aggregate
=
upgrade_decision
[
0
].
UpgradeDecision_getAggregateValue
(
"Compute Node"
)
self
.
assertEqual
(
compute_node_aggregate
,
compute_node
)
release
=
upgrade_decision
[
0
].
UpgradeDecision_getAggregateValue
(
"Software Release"
)
self
.
assertEqual
(
release
.
getUrlString
(),
software_release2
.
getUrlString
())
self
.
tic
()
upgrade_decision2
=
compute_node
.
ComputeNode_checkAndCreateUpgradeDecision
()
self
.
assertEqual
(
len
(
upgrade_decision2
),
0
)
def
test_tocheckComputeNode_checkAndCreateUpgradeDecision_ask_confirmation_with_exist
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
,
allocation_scope
=
"open/personal"
)
compute_node
.
edit
(
upgrade_scope
=
"ask_confirmation"
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release
.
getUrlString
())
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
tic
()
self
.
assertEqual
(
compute_node
.
getUpgradeScope
(),
"ask_confirmation"
)
upgrade_decision
=
compute_node
.
ComputeNode_checkAndCreateUpgradeDecision
()[
0
]
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'planned'
)
software_release3
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
tic
()
upgrade_decision2
=
compute_node
.
ComputeNode_checkAndCreateUpgradeDecision
()[
0
]
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'cancelled'
)
self
.
assertEqual
(
upgrade_decision2
.
getSimulationState
(),
'planned'
)
release
=
upgrade_decision2
.
UpgradeDecision_getAggregateValue
(
"Software Release"
)
self
.
assertEqual
(
release
.
getUrlString
(),
software_release3
.
getUrlString
())
def
test_tocheckComputeNode_checkAndCreateUpgradeDecision_auto_with_exist
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
,
allocation_scope
=
"open"
)
compute_node
.
edit
(
upgrade_scope
=
"auto"
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release
.
getUrlString
())
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
tic
()
upgrade_decision
=
compute_node
.
ComputeNode_checkAndCreateUpgradeDecision
()[
0
]
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'started'
)
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
tic
()
upgrade_decision2
=
compute_node
.
ComputeNode_checkAndCreateUpgradeDecision
()
self
.
assertEqual
(
len
(
upgrade_decision2
),
0
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'started'
)
def
test_tocheckUpgradeDecision_isUpgradeFinished_compute_node
(
self
):
project
=
self
.
addProject
()
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
compute_node
])
upgrade_decision
.
confirm
()
upgrade_decision
.
stop
()
self
.
assertFalse
(
upgrade_decision
.
UpgradeDecision_isUpgradeFinished
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release
.
getUrlString
())
self
.
tic
()
self
.
assertTrue
(
upgrade_decision
.
UpgradeDecision_isUpgradeFinished
())
def
test_tocheckUpgradeDecision_requestChangeState_started
(
self
):
if
is_allocated
:
upgrade_decision
=
self
.
_makeUpgradeDecision
()
if
(
node
==
"instance"
)
and
(
shared
):
upgrade_decision
.
setReference
(
"UD-TESTDECISION"
)
real_compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
upgrade_decision
.
confirm
()
portal_type
=
"Compute Node"
,
requested_state
=
"started"
follow_up_value
=
project
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'confirmed'
)
upgrade_decision
.
UpgradeDecision_requestChangeState
(
requested_state
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'started'
)
def
test_tocheckUpgradeDecision_requestChangeState_reject
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
setReference
(
"UD-TESTDECISION"
)
upgrade_decision
.
confirm
()
requested_state
=
"rejected"
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'confirmed'
)
upgrade_decision
.
UpgradeDecision_requestChangeState
(
requested_state
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'rejected'
)
def
test_tocheckUpgradeDecision_requestChangeState_stopped
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
setReference
(
"UD-TESTDECISION"
)
upgrade_decision
.
confirm
()
upgrade_decision
.
stop
()
requested_state
=
"started"
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'stopped'
)
result
=
upgrade_decision
.
UpgradeDecision_requestChangeState
(
requested_state
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'stopped'
)
self
.
assertEqual
(
result
,
"Transition from state %s to %s is not permitted"
%
(
upgrade_decision
.
getSimulationState
(),
requested_state
))
def
test_tocheckUpgradeDecision_requestChangeState_rejected
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
setReference
(
"UD-TESTDECISION"
)
upgrade_decision
.
confirm
()
upgrade_decision
.
start
()
requested_state
=
"rejected"
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'started'
)
result
=
upgrade_decision
.
UpgradeDecision_requestChangeState
(
requested_state
)
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'started'
)
self
.
assertEqual
(
result
,
"Transition from state %s to %s is not permitted"
%
(
upgrade_decision
.
getSimulationState
(),
requested_state
))
def
test_tocheckUpgradeDecision_isUpgradeFinished_instance_tree
(
self
):
project
=
self
.
addProject
()
instance_tree
=
self
.
_makeInstanceTree
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
upgrade_decision
.
confirm
()
upgrade_decision
.
stop
()
self
.
assertFalse
(
upgrade_decision
.
UpgradeDecision_isUpgradeFinished
())
instance_tree
.
setUrlString
(
software_release
.
getUrlString
())
self
.
assertTrue
(
upgrade_decision
.
UpgradeDecision_isUpgradeFinished
())
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-upgrade-compute-node.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecision_notify_compute_node"])'
)
def
test_tocheckUpgradeDecision_notify_compute_node
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
edit
(
destination_decision_value
=
person
)
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
compute_node
])
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${compute_node_title}
${compute_node_reference}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
)
self
.
portal
.
REQUEST
\
partition
=
real_compute_node
.
newContent
(
portal_type
=
'Compute Partition'
)
[
'testUpgradeDecision_notify_compute_node'
]
=
\
software_instance
=
self
.
portal
.
software_instance_module
.
newContent
(
notification_message
.
getRelativeUrl
()
portal_type
=
"Software Instance"
,
follow_up_value
=
project
,
self
.
tic
()
aggregate_value
=
partition
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notify
())
upgrade_decision
.
plan
()
self
.
tic
()
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notify
())
self
.
tic
()
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'confirmed'
)
self
.
assertEqual
(
len
(
upgrade_decision
.
getFollowUpRelatedValueList
()),
1
)
event
=
upgrade_decision
.
getFollowUpRelatedValue
()
self
.
assertEqual
(
event
.
getTitle
(),
"New Software available for Installation at %s"
%
compute_node
.
getTitle
())
self
.
assertEqual
(
event
.
getTextContent
().
splitlines
(),
[
software_product
.
getTitle
(),
compute_node
.
getTitle
(),
compute_node
.
getReference
(),
software_release
.
getTitle
(),
software_release
.
getReference
(),
software_release
.
getUrlString
()])
self
.
assertEqual
(
event
.
getSimulationState
(),
"delivered"
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-upgrade-instance-tree.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecision_notify_instance_tree"])'
)
def
test_tocheckUpgradeDecision_notify_instance_tree
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
instance_tree
=
self
.
_makeInstanceTree
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
edit
(
destination_decision_value
=
person
)
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
old_url
=
instance_tree
.
getUrlString
()
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${instance_tree_title}
${old_software_release_url}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
)
self
.
portal
.
REQUEST
\
compute_node
.
edit
(
specialise_value
=
software_instance
)
[
'testUpgradeDecision_notify_instance_tree'
]
=
\
elif
(
node
==
"instance"
)
and
(
not
shared
):
notification_message
.
getRelativeUrl
(
)
raise
NotImplementedError
(
'can not allocate on instance node'
)
else
:
self
.
tic
(
)
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
)
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notify
())
instance
=
instance_tree
.
getSuccessorValue
()
instance
.
edit
(
aggregate_value
=
partition
)
upgrade_decision
.
plan
()
self
.
tic
()
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notify
())
self
.
tic
()
self
.
tic
()
return
software_product
,
release_variation
,
type_variation
,
compute_node
,
instance_tree
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'confirmed'
)
self
.
assertEqual
(
len
(
upgrade_decision
.
getFollowUpRelatedValueList
()),
1
)
event
=
upgrade_decision
.
getFollowUpRelatedValue
()
self
.
assertEqual
(
event
.
getTitle
(),
"New Upgrade available for %s"
%
instance_tree
.
getTitle
())
self
.
assertEqual
(
event
.
getTextContent
().
splitlines
(),
[
software_product
.
getTitle
(),
instance_tree
.
getTitle
(),
old_url
,
software_release
.
getTitle
(),
software_release
.
getReference
(),
software_release
.
getUrlString
()])
self
.
assertEqual
(
event
.
getSimulationState
(),
"delivered"
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
class
TestSlapOSPDMSkins
(
TestSlapOSPDMMixinSkins
):
'reference=None'
,
'assert reference == "slapos-upgrade-delivered-compute-node.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecision_notifyDelivered_compute_node"])'
)
@
simulate
(
'UpgradeDecision_isUpgradeFinished'
,
''
,
'return 1'
)
def
test_tocheckUpgradeDecision_notifyDelivered_compute_node
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
edit
(
destination_decision_value
=
person
)
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
compute_node
])
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
def
test_requestUpgrade
(
self
):
portal_type
=
"Notification Message"
,
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
()
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${compute_node_title}
${compute_node_reference}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
self
.
portal
.
REQUEST
\
[
'testUpgradeDecision_notifyDelivered_compute_node'
]
=
\
notification_message
.
getRelativeUrl
()
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for compute node"
,
compute_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notifyDelivered
())
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
upgrade_decision
.
start
()
upgrade_decision
.
start
()
upgrade_decision
.
stop
()
self
.
tic
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
'stop_requested'
)
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notifyDelivered
()
)
upgrade_decision
.
UpgradeDecision_processUpgrade
(
)
self
.
tic
()
self
.
assertEqual
(
new_release_variation
.
getUrlString
(),
instance_tree
.
getUrlString
())
self
.
assertEqual
(
'stop_requested'
,
instance_tree
.
getSlapState
())
self
.
assertEqual
(
'stopped'
,
upgrade_decision
.
getSimulationState
())
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'delivered'
)
def
test_requestUpgrade_destroyed_instance_tree
(
self
):
self
.
assertEqual
(
len
(
upgrade_decision
.
getFollowUpRelatedValueList
()),
1
)
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
()
event
=
upgrade_decision
.
getFollowUpRelatedValue
()
self
.
assertEqual
(
event
.
getTitle
(),
"Upgrade processed at %s for %s"
%
(
compute_node
.
getTitle
(),
software_release
.
getReference
()))
self
.
assertEqual
(
event
.
getTextContent
().
splitlines
(),
[
software_product
.
getTitle
(),
compute_node
.
getTitle
(),
compute_node
.
getReference
(),
software_release
.
getTitle
(),
software_release
.
getReference
(),
software_release
.
getUrlString
()])
self
.
assertEqual
(
event
.
getSimulationState
(),
"delivered"
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-upgrade-delivered-instance-tree.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecision_notifyDelivered_instance_tree"])'
)
@
simulate
(
'UpgradeDecision_isUpgradeFinished'
,
''
,
'return 1'
)
def
test_tocheckUpgradeDecision_notifyDelivered_instance_tree
(
self
):
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
instance_tree
=
self
.
_makeInstanceTree
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
edit
(
destination_decision_value
=
person
)
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
old_url
=
instance_tree
.
getUrlString
()
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${instance_tree_title}
${old_software_release_url}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
self
.
portal
.
REQUEST
\
[
'testUpgradeDecision_notifyDelivered_instance_tree'
]
=
\
notification_message
.
getRelativeUrl
()
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for compute node"
,
compute_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notifyDelivered
())
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
upgrade_decision
.
start
()
upgrade_decision
.
start
()
upgrade_decision
.
stop
()
self
.
tic
()
self
.
assertEqual
(
None
,
upgrade_decision
.
UpgradeDecision_notifyDelivered
())
self
.
tic
()
self
.
assertEqual
(
upgrade_decision
.
getSimulationState
(),
'delivered'
)
self
.
assertEqual
(
len
(
upgrade_decision
.
getFollowUpRelatedValueList
()),
1
)
event
=
upgrade_decision
.
getFollowUpRelatedValue
()
self
.
assertEqual
(
event
.
getTitle
(),
"Upgrade Processed for %s (%s)"
%
(
instance_tree
.
getTitle
(),
software_release
.
getReference
()))
self
.
assertEqual
(
event
.
getTextContent
().
splitlines
(),
[
software_product
.
getTitle
(),
instance_tree
.
getTitle
(),
old_url
,
software_release
.
getTitle
(),
software_release
.
getReference
(),
software_release
.
getUrlString
()])
self
.
assertEqual
(
event
.
getSimulationState
(),
"delivered"
)
def
test_tocheckUpgradeDecisionLine_cancel_already_cancelled
(
self
):
project
=
self
.
addProject
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
cancel
(
comment
=
"Cancelled by the test"
)
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
])
self
.
tic
()
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
self
.
assertEqual
(
'cancelled'
,
upgrade_decision
.
getSimulationState
())
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Cancelled by the test"
,
workflow_history_list
[
-
1
].
comment
)
def
test_tocheckUpgradeDecisionLine_cancel_archived_software_release
(
self
):
project
=
self
.
addProject
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
])
software_release
.
setAggregateValue
(
software_product
)
self
.
tic
()
software_release
.
archive
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
'destroy_requested'
)
self
.
assertEqual
(
'draft'
,
upgrade_decision
.
getSimulationState
())
software_product
.
invalidate
()
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
upgrade_decision
.
UpgradeDecision_processUpgrade
()
self
.
assertEqual
(
'cancelled'
,
upgrade_decision
.
getSimulationState
())
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Software Product is invalidated."
,
workflow_history_list
[
-
1
].
comment
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-upgrade-delivered-compute-node.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_instance_tree"])'
)
def
test_tocheckUpgradeDecisionLine_cancel_destroyed_instance_tree
(
self
):
project
=
self
.
addProject
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
instance_tree
=
self
.
_makeFullInstanceTree
(
software_release
.
getUrlString
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${compute_node_title}
${compute_node_reference}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
self
.
portal
.
REQUEST
\
[
'testUpgradeDecisionLine_cancel_destroyed_instance_tree'
]
=
\
notification_message
.
getRelativeUrl
()
self
.
tic
()
kw
=
dict
(
software_release
=
instance_tree
.
getUrlString
(),
software_type
=
instance_tree
.
getSourceReference
(),
instance_xml
=
instance_tree
.
getTextContent
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
)
instance_tree
.
requestDestroy
(
**
kw
)
self
.
tic
()
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
self
.
assertEqual
(
'cancelled'
,
upgrade_decision
.
getSimulationState
())
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Instance Tree is destroyed."
,
workflow_history_list
[
-
1
].
comment
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-upgrade-delivered-compute-node.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_instance_tree"])'
)
def
test_tocheckUpgradeDecisionLine_cancel_destroyed_instance_tree_and_disabled_monitor
(
self
):
project
=
self
.
addProject
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
instance_tree
=
self
.
_makeFullInstanceTree
(
software_release
.
getUrlString
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${compute_node_title}
${compute_node_reference}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
self
.
portal
.
REQUEST
\
[
'testUpgradeDecisionLine_cancel_destroyed_instance_tree'
]
=
\
notification_message
.
getRelativeUrl
()
self
.
tic
()
kw
=
dict
(
software_release
=
instance_tree
.
getUrlString
(),
software_type
=
instance_tree
.
getSourceReference
(),
instance_xml
=
instance_tree
.
getTextContent
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
)
instance_tree
.
requestDestroy
(
**
kw
)
instance_tree
.
setMonitorScope
(
"disabled"
)
self
.
tic
()
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
self
.
assertEqual
(
'cancelled'
,
upgrade_decision
.
getSimulationState
())
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Instance Tree is destroyed."
,
workflow_history_list
[
-
1
].
comment
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-upgrade-delivered-compute-node.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr"])'
)
def
test_tocheckUpgradeDecisionLine_cancel_destroyed_hs_archived_sr
(
self
):
project
=
self
.
addProject
()
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_release
=
self
.
_makeSoftwareRelease
(
software_product
)
instance_tree
=
self
.
_makeFullInstanceTree
(
software_release
.
getUrlString
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
instance_tree
])
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${compute_node_title}
${compute_node_reference}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
self
.
portal
.
REQUEST
\
[
'testUpgradeDecisionLine_cancel_destroyed_hs_archived_sr'
]
=
\
notification_message
.
getRelativeUrl
()
self
.
tic
()
kw
=
dict
(
software_release
=
instance_tree
.
getUrlString
(),
software_type
=
instance_tree
.
getSourceReference
(),
instance_xml
=
instance_tree
.
getTextContent
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
)
instance_tree
.
requestDestroy
(
**
kw
)
software_release
.
archive
()
software_product
.
invalidate
()
self
.
tic
()
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
self
.
assertEqual
(
'cancelled'
,
upgrade_decision
.
getSimulationState
())
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Software Product is invalidated."
,
workflow_history_list
[
-
1
].
comment
)
self
.
assertNotEqual
(
new_release_variation
.
getUrlString
(),
instance_tree
.
getUrlString
())
self
.
assertEqual
(
'destroy_requested'
,
instance_tree
.
getSlapState
())
self
.
assertEqual
(
'rejected'
,
upgrade_decision
.
getSimulationState
())
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_requestUpgrade.py
deleted
100644 → 0
View file @
3f096f85
upgrade_decision
=
state_change
[
"object"
]
from
DateTime
import
DateTime
if
upgrade_decision
.
getSimulationState
()
!=
'started'
:
# Update Decision is not on started state, Upgrade is not possible!
return
instance_tree
=
upgrade_decision
.
UpgradeDecision_getAggregateValue
(
"Instance Tree"
)
software_release
=
upgrade_decision
.
UpgradeDecision_getAggregateValue
(
"Software Release"
)
compute_node
=
upgrade_decision
.
UpgradeDecision_getAggregateValue
(
"Compute Node"
)
if
software_release
is
None
:
return
if
compute_node
is
None
and
instance_tree
is
None
:
return
if
compute_node
is
not
None
and
instance_tree
is
not
None
:
raise
ValueError
(
"Something is wrong, you cannot upgrade Compute Node and Instance Tree on the same decision."
)
software_release_url
=
software_release
.
getUrlString
()
if
compute_node
is
not
None
:
compute_node
.
requestSoftwareRelease
(
software_release_url
=
software_release_url
,
state
=
"available"
)
upgrade_decision
.
stop
(
comment
=
"Upgrade Processed for the Compute Node!"
)
return
status
=
instance_tree
.
getSlapState
()
if
status
==
"start_requested"
:
state
=
"started"
elif
status
==
"stop_requested"
:
state
=
"stopped"
elif
status
==
"destroy_requested"
:
state
=
"destroyed"
person
=
instance_tree
.
getDestinationSectionValue
(
portal_type
=
"Person"
)
person
.
requestSoftwareInstance
(
state
=
state
,
software_release
=
software_release_url
,
software_title
=
instance_tree
.
getTitle
(),
software_type
=
instance_tree
.
getSourceReference
(),
instance_xml
=
instance_tree
.
getTextContent
(),
sla_xml
=
instance_tree
.
getSlaXml
(),
shared
=
instance_tree
.
isRootSlave
()
)
upgrade_decision
.
stop
(
comment
=
"Upgrade Processed for the Instance Tree!"
)
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/state_draft.xml
View file @
1a2dcd97
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
<tuple>
<tuple>
<string>
destination/portal_workflow/upgrade_slap_interface_workflow/transition_approve_registration
</string>
<string>
destination/portal_workflow/upgrade_slap_interface_workflow/transition_approve_registration
</string>
<string>
destination/portal_workflow/upgrade_slap_interface_workflow/transition_notify
</string>
<string>
destination/portal_workflow/upgrade_slap_interface_workflow/transition_notify
</string>
<string>
destination/portal_workflow/upgrade_slap_interface_workflow/transition_request_upgrade
</string>
</tuple>
</tuple>
</value>
</value>
</item>
</item>
...
...
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/transition_request_upgrade.xml
deleted
100644 → 0
View file @
3f096f85
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Workflow Transition"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
action_name
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/workflow
</string>
<string>
before_script/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_checkConsistency
</string>
<string>
after_script/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_requestUpgrade
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string>
Perform the Upgrade
</string>
</value>
</item>
<item>
<key>
<string>
guard_permission
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
transition_request_upgrade
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Workflow Transition
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Request Upgrade
</string>
</value>
</item>
<item>
<key>
<string>
trigger_type
</string>
</key>
<value>
<int>
2
</int>
</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