Commit 508d2ac6 authored by Rafael Monnerat's avatar Rafael Monnerat

Set Upgrade scope "auto" by default

See merge request nexedi/slapos.core!345
parents 126bb776 c64a9eb3
......@@ -4,6 +4,8 @@ person = portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node.edit(
allocation_scope='open/personal',
source_administration_value=person,
upgrade_scope='auto',
capacity_scope='open'
)
erp5_login = compute_node.newContent(
......
......@@ -52,6 +52,12 @@
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_ComputeNode_approveRegistration</string> </value>
......
......@@ -36,7 +36,6 @@ if compute_node is None:
portal_type=compute_node_portal_type,
title=compute_node_title,
reference=reference,
capacity_scope='open',
activate_kw={'tag': tag}
)
compute_node.requestComputeNodeRegistration()
......
......@@ -52,6 +52,12 @@
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Person_requestComputeNode</string> </value>
......
......@@ -58,6 +58,7 @@ else:
reference=instance_tree_reference,
title=software_title,
destination_section=person.getRelativeUrl(),
upgrade_scope="auto",
activate_kw={'tag': tag},
)
......
......@@ -24,15 +24,12 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
SlapOSTestCaseMixin):
def _test_ComputeNode_setAllocationScope_public(self,
upgrade_scope=None,
allocation_scope="open/public",
source_administration=None,
expected_upgrade_scope='auto'):
source_administration=None):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node')
compute_node.edit(capacity_scope=None,
monitor_scope=None,
upgrade_scope=upgrade_scope,
source_administration=source_administration)
self.commit()
compute_node.edit(allocation_scope=allocation_scope)
......@@ -40,7 +37,6 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'enabled')
self.assertEqual(compute_node.getUpgradeScope(), expected_upgrade_scope)
return compute_node
def test_ComputeNode_setAllocationScope_public_no_source_adm(self):
......@@ -51,27 +47,6 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
allocation_scope="open/subscription"
)
def test_ComputeNode_setAllocationScope_public_ask_confirmation(self):
self._test_ComputeNode_setAllocationScope_public(
upgrade_scope="ask_confirmation")
def test_ComputeNode_setAllocationScope_subscription_ask_confirmation(self):
self._test_ComputeNode_setAllocationScope_public(
allocation_scope="open/subscription",
upgrade_scope="ask_confirmation"
)
def test_ComputeNode_setAllocationScope_public_upgrade_disabled(self):
self._test_ComputeNode_setAllocationScope_public(
upgrade_scope="disabled",
expected_upgrade_scope="disabled")
def test_ComputeNode_setAllocationScope_subscription_upgrade_disabled(self):
self._test_ComputeNode_setAllocationScope_public(
allocation_scope="open/subscription",
upgrade_scope="disabled",
expected_upgrade_scope="disabled")
def test_ComputeNode_setAllocationScope_public_with_source_adm(self):
person = self.makePerson()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
......@@ -95,13 +70,11 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
def _test_ComputeNode_setAllocationScope_personal(self,
upgrade_scope=None,
source_administration=None,
subject_list=None):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
capacity_scope=None,
monitor_scope=None,
upgrade_scope=upgrade_scope,
source_administration=source_administration)
if subject_list:
compute_node.setSubjectList(subject_list)
......@@ -115,21 +88,6 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
def test_ComputeNode_setAllocationScope_personal(self):
compute_node = self._test_ComputeNode_setAllocationScope_personal()
self.assertEqual(compute_node.getUpgradeScope(), 'ask_confirmation')
self.assertEqual(compute_node.getSubjectList(), [])
self.assertEqual(compute_node.getDestinationSection(), None)
def test_ComputeNode_setAllocationScope_personal_upgrade_disabled(self):
compute_node = self._test_ComputeNode_setAllocationScope_personal(
upgrade_scope="disabled")
self.assertEqual(compute_node.getUpgradeScope(), 'disabled')
self.assertEqual(compute_node.getSubjectList(), [])
self.assertEqual(compute_node.getDestinationSection(), None)
def test_ComputeNode_setAllocationScope_personal_upgrade_auto(self):
compute_node = self._test_ComputeNode_setAllocationScope_personal(
upgrade_scope="auto")
self.assertEqual(compute_node.getUpgradeScope(), 'auto')
self.assertEqual(compute_node.getSubjectList(), [])
self.assertEqual(compute_node.getDestinationSection(), None)
......@@ -141,7 +99,6 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node = self._test_ComputeNode_setAllocationScope_personal(
source_administration=person.getRelativeUrl(),
)
self.assertEqual(compute_node.getUpgradeScope(), 'ask_confirmation')
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
......@@ -155,21 +112,17 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
source_administration=person.getRelativeUrl(),
subject_list=["some@example.com"]
)
self.assertEqual(compute_node.getUpgradeScope(), 'ask_confirmation')
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
def _test_ComputeNode_setAllocationScope_friend(self,
upgrade_scope=None,
source_administration=None,
subject_list=None,
expected_upgrade_scope='auto'):
subject_list=None):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node')
compute_node.edit(capacity_scope=None,
monitor_scope=None,
upgrade_scope=upgrade_scope,
source_administration=source_administration)
if subject_list:
......@@ -181,21 +134,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'open')
self.assertEqual(compute_node.getMonitorScope(), 'enabled')
self.assertEqual(compute_node.getUpgradeScope(), expected_upgrade_scope)
return compute_node
def test_ComputeNode_setAllocationScope_friend_no_source_adm(self):
self._test_ComputeNode_setAllocationScope_friend()
def test_ComputeNode_setAllocationScope_friend_ask_confirmation(self):
self._test_ComputeNode_setAllocationScope_friend(
upgrade_scope="ask_confirmation")
def test_ComputeNode_setAllocationScope_friend_upgrade_disabled(self):
self._test_ComputeNode_setAllocationScope_friend(
upgrade_scope="disabled",
expected_upgrade_scope="disabled")
def test_ComputeNode_setAllocationScope_friend_with_source_adm(self):
person = self.makePerson()
self.tic()
......@@ -226,14 +166,12 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
def _test_ComputeNode_setAllocationScope_closed(self,
upgrade_scope=None,
source_administration=None,
allocation_scope="close/forever",
subject_list=None):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
capacity_scope=None,
monitor_scope=None,
upgrade_scope=upgrade_scope,
source_administration=source_administration)
if subject_list:
compute_node.setSubjectList(subject_list)
......@@ -243,7 +181,6 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled')
self.assertEqual(compute_node.getUpgradeScope(), upgrade_scope)
return compute_node
......
compute_node = state_object["object"]
allocation_scope = compute_node.getAllocationScope()
upgrade_scope = compute_node.getUpgradeScope()
if allocation_scope in ['open/public', 'open/subscription']:
# Public compute_node capacity is handle by an alarm
capacity_scope = 'close'
monitor_scope = 'enabled'
if upgrade_scope in [None, 'ask_confirmation']:
upgrade_scope = 'auto'
elif allocation_scope == 'open/friend':
# Capacity is not handled for 'private' compute_nodes
capacity_scope = 'open'
monitor_scope = 'enabled'
if upgrade_scope in [None, 'ask_confirmation']:
upgrade_scope = 'auto'
elif allocation_scope == 'open/personal':
capacity_scope = 'open'
# Keep the same.
monitor_scope = compute_node.getMonitorScope("disabled")
if upgrade_scope is None:
upgrade_scope = 'ask_confirmation'
else:
monitor_scope = 'disabled'
capacity_scope = 'close'
edit_kw = {
'capacity_scope': capacity_scope,
'monitor_scope': monitor_scope,
'upgrade_scope': upgrade_scope
'monitor_scope': monitor_scope
}
self_person = compute_node.getSourceAdministrationValue(portal_type="Person")
......
......@@ -52,6 +52,12 @@
<key> <string>_params</string> </key>
<value> <string>state_object</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_ComputeNode_updateAllocation</string> </value>
......
......@@ -941,10 +941,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(upgrade_decision.UpgradeDecision_tryToCancel(url2), True)
self.assertEqual(upgrade_decision.getSimulationState(), 'rejected')
def testComputeNode_checkAndCreateUpgradeDecision(self):
def testComputeNode_checkAndCreateUpgradeDecision_auto(self):
person = self._makePerson()
compute_node, _ = self._makeComputeNode(owner=person,
allocation_scope="open/public")
compute_node.edit(upgrade_scope="auto")
software_product = self._makeSoftwareProduct()
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
......@@ -975,9 +976,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
upgrade_decision2 = compute_node.ComputeNode_checkAndCreateUpgradeDecision()
self.assertEqual(len(upgrade_decision2), 0)
def testComputeNode_checkAndCreateUpgradeDecision_personal_with_exist(self):
def testComputeNode_checkAndCreateUpgradeDecision_ask_confirmation_with_exist(self):
person = self._makePerson()
compute_node, _ = self._makeComputeNode(owner=person, allocation_scope="open/personal")
compute_node, _ = self._makeComputeNode(owner=person,
allocation_scope="open/personal")
compute_node.edit(upgrade_scope="ask_confirmation")
software_product = self._makeSoftwareProduct()
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
......@@ -1002,10 +1005,11 @@ class TestSlapOSPDMSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(release.getUrlString(),
software_release3.getUrlString())
def testComputeNode_checkAndCreateUpgradeDecision_public_with_exist(self):
def testComputeNode_checkAndCreateUpgradeDecision_auto_with_exist(self):
person = self._makePerson()
compute_node, _ = self._makeComputeNode(owner=person,
allocation_scope="open/public")
compute_node.edit(upgrade_scope="auto")
software_product = self._makeSoftwareProduct()
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
......
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