Commit c4cbdb6a authored by Łukasz Nowak's avatar Łukasz Nowak

slapos_pdm: Use upgrade_scope on Computer Node for cleanup enabling

The allocation_scope of Compute Node is as important, as Compute Node
owner regarding the software management itself.
parent 126bb776
......@@ -19,8 +19,9 @@ if compute_node is None:
return
if compute_node.ComputeNode_getSoftwareReleaseUsage(url_string) != 0:
return
if compute_node.getAllocationScope() not in ['open/public', 'open/subscription', 'close/forever']:
# handle only some specific compute_nodes: public ones and removed
if compute_node.getUpgradeScope() != 'auto':
# handle only Compute Nodes with automatic software management
return
software_installation.requestDestroy(
......
......@@ -141,6 +141,89 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap
self.assertEqual('validated', archived_used_software_installation.getValidationState())
self.assertEqual('start_requested', archived_used_software_installation.getSlapState())
def test_manual_upgrade_scope(self):
preference = self.portal.portal_preferences.getActiveSystemPreference()
preference.setPreferredCloudContractEnabled(True)
self.tic()
compute_node, partition = self._makeComputeNode()
compute_node.setUpgradeScope('confirmation')
archived_url_string = self.generateNewSoftwareReleaseUrl()
# create software release
archived_software_release = self.portal.software_release_module.newContent(
portal_type='Software Release',
version='1',
url_string=archived_url_string
)
archived_software_release.publish()
archived_software_release.archive()
self.assertEqual('draft', archived_software_release.getSimulationState())
# install an software release
archived_software_installation = self.portal.software_installation_module\
.newContent(portal_type='Software Installation',
url_string=archived_url_string,
aggregate=compute_node.getRelativeUrl())
archived_software_installation.validate()
archived_software_installation.requestStart()
archived_used_url_string = self.generateNewSoftwareReleaseUrl()
# create software release
archived_used_software_release = self.portal.software_release_module.newContent(
portal_type='Software Release',
version='1',
url_string=archived_used_url_string
)
archived_used_software_release.publish()
archived_used_software_release.archive()
self.assertEqual('draft', archived_used_software_release.getSimulationState())
# install an software release
archived_used_software_installation = self.portal.software_installation_module\
.newContent(portal_type='Software Installation',
url_string=archived_used_url_string,
aggregate=compute_node.getRelativeUrl())
archived_used_software_installation.validate()
archived_used_software_installation.requestStart()
# use the software release
instance = self.createInstance(archived_used_url_string)
instance.setAggregate(partition.getRelativeUrl())
partition.markBusy()
self.tic()
published_url_string = self.generateNewSoftwareReleaseUrl()
# create software release
published_software_release = self.portal.software_release_module.newContent(
portal_type='Software Release',
version='1',
url_string=published_url_string
)
published_software_release.publish()
self.assertEqual('draft', published_software_release.getSimulationState())
# install an software release
published_software_installation = self.portal.software_installation_module\
.newContent(portal_type='Software Installation',
url_string=published_url_string,
aggregate=compute_node.getRelativeUrl())
published_software_installation.validate()
published_software_installation.requestStart()
self.tic()
# as Compute Node is manually managed, nothing happens
self.stepCallSlaposPdmDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm()
self.tic()
self.assertEqual('start_requested', archived_software_installation.getSlapState())
self.assertEqual('validated', archived_software_installation.getValidationState())
self.assertEqual('start_requested', published_software_installation.getSlapState())
self.assertEqual('validated', published_software_installation.getValidationState())
self.assertEqual('start_requested', archived_used_software_installation.getSlapState())
self.assertEqual('validated', archived_used_software_installation.getValidationState())
self.assertEqual('draft', archived_software_release.getSimulationState())
self.assertEqual('draft', published_software_release.getSimulationState())
@simulateByEditWorkflowMark('SoftwareRelease_findAndDestroySoftwareInstallation')
def test_no_op_run_software_release(self):
archived_software_release = self.portal.software_release_module.newContent(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment