Commit e38031a7 authored by Rafael Monnerat's avatar Rafael Monnerat

Revert "slapos_*: No more Friend Allocation Scope"

  This work is unfinished, so it will be reworked on a branch.
parent 3bb36903
Pipeline #18091 passed with stage
in 0 seconds
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Allocate services for the owner of the friends of the compute_node</string> </value>
</item>
<item>
<key> <string>effective_date</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>friend</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Friend</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -4,7 +4,7 @@ kw['url_string'] = context.getUrlString() ...@@ -4,7 +4,7 @@ kw['url_string'] = context.getUrlString()
software_installation_list = context.portal_catalog(**kw) software_installation_list = context.portal_catalog(**kw)
compute_node_list = [] compute_node_list = []
allocation_scope_list = ['open/personal', 'open/public'] allocation_scope_list = ['open/personal', 'open/public', 'open/friend']
for software_installation in software_installation_list: for software_installation in software_installation_list:
compute_node = software_installation.getAggregateValue() compute_node = software_installation.getAggregateValue()
if software_installation.getSlapState() == 'start_requested' and \ if software_installation.getSlapState() == 'start_requested' and \
......
...@@ -163,6 +163,17 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -163,6 +163,17 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertEqual('open', server.getCapacityScope()) self.assertEqual('open', server.getCapacityScope())
self.tic() self.tic()
@changeSkin('RJS')
def setServerOpenFriend(self, server, friend_list=None):
if friend_list is None:
friend_list = []
server.edit(
allocation_scope='open/friend', subject_list=friend_list)
self.assertEqual('open/friend', server.getAllocationScope())
self.assertEqual('open', server.getCapacityScope())
self.assertSameSet(friend_list, server.getSubjectList())
self.tic()
def formatComputeNode(self, compute_node, partition_count=10): def formatComputeNode(self, compute_node, partition_count=10):
compute_node_dict = dict( compute_node_dict = dict(
software_root='/opt', software_root='/opt',
......
...@@ -234,6 +234,72 @@ return True""" ) ...@@ -234,6 +234,72 @@ return True""" )
self.assertEqual(self.partition.getRelativeUrl(), self.assertEqual(self.partition.getRelativeUrl(),
self.software_instance.getAggregate(portal_type='Compute Partition')) self.software_instance.getAggregate(portal_type='Compute Partition'))
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_allocation_scope_open_friend(self):
self._makeTree()
self._makeComputeNode()
self._installSoftware(self.compute_node,
self.software_instance.getUrlString())
# change compute_node owner
new_id = self.generateNewId()
person_user = self.portal.person_module.template_member.\
Base_createCloneDocument(batch_mode=1)
person_user.edit(
title="live_test_%s" % new_id,
reference="live_test_%s" % new_id,
default_email_text="live_test_%s@example.org" % new_id,
)
person_user.validate()
for assignment in person_user.contentValues(portal_type="Assignment"):
assignment.open()
self.compute_node.edit(
source_administration=person_user.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl(),
allocation_scope='open/friend')
self.tic()
self.assertEqual(None, self.software_instance.getAggregateValue(
portal_type='Compute Partition'))
self.software_instance.SoftwareInstance_tryToAllocatePartition()
self.assertEqual(self.partition.getRelativeUrl(),
self.software_instance.getAggregate(portal_type='Compute Partition'))
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_host_allocation_scope_open_friend(self):
self._makeSlaveTree()
self._makeComputeNode()
self._allocateHost(self.requested_software_instance,
self.partition)
# change compute_node owner
new_id = self.generateNewId()
person_user = self.portal.person_module.template_member.\
Base_createCloneDocument(batch_mode=1)
person_user.edit(
title="live_test_%s" % new_id,
reference="live_test_%s" % new_id,
default_email_text="live_test_%s@example.org" % new_id,
)
person_user.validate()
for assignment in person_user.contentValues(portal_type="Assignment"):
assignment.open()
self.compute_node.edit(
source_administration=person_user.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl(),
allocation_scope='open/friend')
self.tic()
self.assertEqual(None, self.software_instance.getAggregateValue(
portal_type='Compute Partition'))
self.software_instance.SoftwareInstance_tryToAllocatePartition()
self.assertEqual(self.partition.getRelativeUrl(),
self.software_instance.getAggregate(portal_type='Compute Partition'))
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True') @simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_does_not_fail_on_instance_with_damaged_sla_xml(self): def test_allocation_does_not_fail_on_instance_with_damaged_sla_xml(self):
self._makeTree() self._makeTree()
......
...@@ -2,11 +2,12 @@ portal = context.getPortalObject() ...@@ -2,11 +2,12 @@ portal = context.getPortalObject()
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None) category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)
category_subscription = portal.restrictedTraverse("portal_categories/allocation_scope/open/subscription", None) category_subscription = portal.restrictedTraverse("portal_categories/allocation_scope/open/subscription", None)
category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)
if category_public is not None: if category_public is not None:
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type='Compute Node', portal_type='Compute Node',
default_allocation_scope_uid=[category_public.getUid(), category_subscription.getUid()], default_allocation_scope_uid=[category_public.getUid(), category_friend.getUid(), category_subscription.getUid()],
validation_state="validated", validation_state="validated",
method_id='ComputeNode_checkAndUpdateAllocationScope', method_id='ComputeNode_checkAndUpdateAllocationScope',
activate_kw={'tag': tag} activate_kw={'tag': tag}
......
...@@ -6,6 +6,9 @@ from Products.ERP5Type.Document import newTempBase ...@@ -6,6 +6,9 @@ from Products.ERP5Type.Document import newTempBase
public_category_uid = portal.restrictedTraverse( public_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/public", None).getUid() "portal_categories/allocation_scope/open/public", None).getUid()
friend_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/friend", None).getUid()
personal_category_uid = portal.restrictedTraverse( personal_category_uid = portal.restrictedTraverse(
"portal_categories/allocation_scope/open/personal", None).getUid() "portal_categories/allocation_scope/open/personal", None).getUid()
...@@ -37,7 +40,7 @@ def checkForError(reference): ...@@ -37,7 +40,7 @@ def checkForError(reference):
for compute_node in portal.portal_catalog( for compute_node in portal.portal_catalog(
default_allocation_scope_uid = [personal_category_uid, public_category_uid], default_allocation_scope_uid = [personal_category_uid, public_category_uid, friend_category_uid],
select_list={"reference": None}, select_list={"reference": None},
**kw): **kw):
......
...@@ -5,7 +5,7 @@ portal = context.getPortalObject() ...@@ -5,7 +5,7 @@ portal = context.getPortalObject()
allocation_scope = compute_node.getAllocationScope() allocation_scope = compute_node.getAllocationScope()
compute_node_reference = compute_node.getReference() compute_node_reference = compute_node.getReference()
if allocation_scope not in ['open/public', 'open/personal']: if allocation_scope not in ['open/public', 'open/friend', 'open/personal']:
return return
if allocation_scope == target_allocation_scope: if allocation_scope == target_allocation_scope:
......
...@@ -78,7 +78,7 @@ if aggregate_portal_type == "Instance Tree": ...@@ -78,7 +78,7 @@ if aggregate_portal_type == "Instance Tree":
if instance.getAggregate() is not None: if instance.getAggregate() is not None:
compute_node = instance.getAggregateValue().getParentValue() compute_node = instance.getAggregateValue().getParentValue()
if instance.getPortalType() == "Software Instance" and \ if instance.getPortalType() == "Software Instance" and \
compute_node.getAllocationScope() in ["open/public", "open/subscription"] and \ compute_node.getAllocationScope() in ["open/public", "open/friend", "open/subscription"] and \
instance.getSlapState() == "start_requested" and \ instance.getSlapState() == "start_requested" and \
instance.SoftwareInstance_hasReportedError(): instance.SoftwareInstance_hasReportedError():
message_list.append("%s has error (%s, %s at %s scope %s)" % (instance.getReference(), instance.getTitle(), message_list.append("%s has error (%s, %s at %s scope %s)" % (instance.getReference(), instance.getTitle(),
......
...@@ -430,6 +430,14 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -430,6 +430,14 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
slapos_crm_check_compute_node_state slapos_crm_check_compute_node_state
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkState") self._test_alarm(alarm, self.compute_node, "ComputeNode_checkState")
def test_alarm_check_friend_compute_node_state(self):
self._makeComputeNode()
self.compute_node.edit(allocation_scope='open/friend')
self.tic()
alarm = self.portal.portal_alarms.\
slapos_crm_check_compute_node_state
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkState")
def test_alarm_check_personal_compute_node_state(self): def test_alarm_check_personal_compute_node_state(self):
self._makeComputeNode() self._makeComputeNode()
self.compute_node.edit(allocation_scope='open/personal') self.compute_node.edit(allocation_scope='open/personal')
...@@ -456,6 +464,11 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -456,6 +464,11 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
allocation_scope='open/public', allocation_scope='open/public',
monitor_scope="disabled") monitor_scope="disabled")
def test_alarm_check_compute_node_state_on_friend_compute_node_with_monitor_scope_disabled(self):
self._test_alarm_check_compute_node_state_not_selected(
allocation_scope='open/friend',
monitor_scope="disabled")
def test_alarm_check_compute_node_state_on_personal_compute_node_with_monitor_scope_disabled(self): def test_alarm_check_compute_node_state_on_personal_compute_node_with_monitor_scope_disabled(self):
self._test_alarm_check_compute_node_state_not_selected( self._test_alarm_check_compute_node_state_not_selected(
allocation_scope='open/personal', allocation_scope='open/personal',
...@@ -484,6 +497,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeAllocationScope(SlapOSTestCaseMixin ...@@ -484,6 +497,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeAllocationScope(SlapOSTestCaseMixin
slapos_crm_check_update_allocation_scope slapos_crm_check_update_allocation_scope
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkAndUpdateAllocationScope") self._test_alarm(alarm, self.compute_node, "ComputeNode_checkAndUpdateAllocationScope")
def test_alarm_not_allowed_allocation_scope_OpenFriend(self):
self._makeComputeNode()
self.compute_node.edit(allocation_scope = 'open/friend')
self.tic()
alarm = self.portal.portal_alarms.\
slapos_crm_check_update_allocation_scope
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkAndUpdateAllocationScope")
def test_alarm_not_allowed_allocationScope_open_personal(self): def test_alarm_not_allowed_allocationScope_open_personal(self):
self._makeComputeNode() self._makeComputeNode()
self.compute_node.edit(allocation_scope = 'open/personal') self.compute_node.edit(allocation_scope = 'open/personal')
...@@ -502,6 +524,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase ...@@ -502,6 +524,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
slapos_crm_check_software_installation_state slapos_crm_check_software_installation_state
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState") self._test_alarm(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState")
def test_alarm_run_on_open_friend(self):
self._makeComputeNode()
self.compute_node.edit(allocation_scope = 'open/friend')
self.tic()
alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState")
def test_alarm_run_on_open_personal(self): def test_alarm_run_on_open_personal(self):
self._makeComputeNode() self._makeComputeNode()
self.compute_node.edit(allocation_scope = 'open/personal', self.compute_node.edit(allocation_scope = 'open/personal',
...@@ -521,6 +552,16 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase ...@@ -521,6 +552,16 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
slapos_crm_check_software_installation_state slapos_crm_check_software_installation_state
self._test_alarm_not_visited(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState") self._test_alarm_not_visited(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState")
def test_alarm_dont_run_on_open_friend_with_monitor_scope_disabled(self):
self._makeComputeNode()
self.compute_node.edit(allocation_scope = 'open/friend')
self.tic()
self.compute_node.edit(monitor_scope = 'disabled')
self.tic()
alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
self._test_alarm_not_visited(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState")
def test_alarm_dont_run_on_open_personal_with_monitor_scope_disabled(self): def test_alarm_dont_run_on_open_personal_with_monitor_scope_disabled(self):
self._makeComputeNode() self._makeComputeNode()
self.compute_node.edit(allocation_scope = 'open/personal', self.compute_node.edit(allocation_scope = 'open/personal',
......
...@@ -649,7 +649,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -649,7 +649,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'reference=None', 'reference=None',
'assert reference == "slapos-crm-compute_node_allocation_scope.notification"\n' \ 'assert reference == "slapos-crm-compute_node_allocation_scope.notification"\n' \
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_compute_nodeNotAllowedAllocationScope_OpenPublic"])') 'context.REQUEST["test_ComputeNodeNotAllowedAllocationScope_OpenPublic"])')
@simulate('SupportRequest_trySendNotificationMessage', @simulate('SupportRequest_trySendNotificationMessage',
'message_title, message, destination_relative_url', 'message_title, message, destination_relative_url',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
...@@ -657,11 +657,11 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -657,11 +657,11 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'comment="Visited by SupportRequest_trySendNotificationMessage ' \ 'comment="Visited by SupportRequest_trySendNotificationMessage ' \
'%s %s %s" % (message_title, message, destination_relative_url))\n' \ '%s %s %s" % (message_title, message, destination_relative_url))\n' \
'return 1') 'return 1')
def test_compute_nodeNotAllowedAllocationScope_OpenPublic(self): def test_ComputeNodeNotAllowedAllocationScope_OpenPublic(self):
compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0] compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0]
person = compute_node.getSourceAdministrationValue() person = compute_node.getSourceAdministrationValue()
self.portal.REQUEST['test_compute_nodeNotAllowedAllocationScope_OpenPublic'] = \ self.portal.REQUEST['test_ComputeNodeNotAllowedAllocationScope_OpenPublic'] = \
self._makeNotificationMessage(compute_node.getReference()) self._makeNotificationMessage(compute_node.getReference())
compute_node.edit(allocation_scope='open/public') compute_node.edit(allocation_scope='open/public')
...@@ -679,13 +679,48 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -679,13 +679,48 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'Test NM content\n%s\n' % compute_node.getReference(), person.getRelativeUrl()), 'Test NM content\n%s\n' % compute_node.getReference(), person.getRelativeUrl()),
ticket.workflow_history['edit_workflow'][-1]['comment']) ticket.workflow_history['edit_workflow'][-1]['comment'])
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-crm-compute_node_allocation_scope.notification"\n' \
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNodeNotAllowedAllocationScope_OpenFriend"])')
@simulate('SupportRequest_trySendNotificationMessage',
'message_title, message, destination_relative_url',
'context.portal_workflow.doActionFor(' \
'context, action="edit_action", ' \
'comment="Visited by SupportRequest_trySendNotificationMessage ' \
'%s %s %s" % (message_title, message, destination_relative_url))\n' \
'return 1')
def test_ComputeNodeNotAllowedAllocationScope_OpenFriend(self):
compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0]
person = compute_node.getSourceAdministrationValue()
self.portal.REQUEST['test_ComputeNodeNotAllowedAllocationScope_OpenFriend'] = \
self._makeNotificationMessage(compute_node.getReference())
friend_person = self.makePerson()
compute_node.edit(allocation_scope='open/friend',
destination_section=friend_person.getRelativeUrl())
ticket = compute_node.ComputeNode_checkAndUpdateAllocationScope()
self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/personal')
self.assertEqual(ticket.getSimulationState(), 'suspended')
self.assertEqual('Visited by SupportRequest_trySendNotificationMessage ' \
'%s %s %s' % \
('Allocation scope of %s changed to %s' % (compute_node.getReference(),
'open/personal'),
'Test NM content\n%s\n' % compute_node.getReference(), person.getRelativeUrl()),
ticket.workflow_history['edit_workflow'][-1]['comment'])
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0') @simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
@simulate('ComputeNode_hasContactedRecently', '*args, **kwargs','return False') @simulate('ComputeNode_hasContactedRecently', '*args, **kwargs','return False')
@simulate('NotificationTool_getDocumentValue', @simulate('NotificationTool_getDocumentValue',
'reference=None', 'reference=None',
'assert reference == "slapos-crm-compute-node-allocation-scope-closed.notification"\n' \ 'assert reference == "slapos-crm-compute-node-allocation-scope-closed.notification"\n' \
'return context.restrictedTraverse(' \ 'return context.restrictedTraverse(' \
'context.REQUEST["test_compute_nodeToCloseAllocationScope_OpenPersonal"])') 'context.REQUEST["test_ComputeNodeToCloseAllocationScope_OpenPersonal"])')
@simulate('SupportRequest_trySendNotificationMessage', @simulate('SupportRequest_trySendNotificationMessage',
'message_title, message, destination_relative_url', 'message_title, message, destination_relative_url',
'context.portal_workflow.doActionFor(' \ 'context.portal_workflow.doActionFor(' \
...@@ -693,12 +728,12 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -693,12 +728,12 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'comment="Visited by SupportRequest_trySendNotificationMessage ' \ 'comment="Visited by SupportRequest_trySendNotificationMessage ' \
'%s %s %s" % (message_title, message, destination_relative_url))\n' \ '%s %s %s" % (message_title, message, destination_relative_url))\n' \
'return 1') 'return 1')
def test_compute_nodeToCloseAllocationScope_OpenPersonal(self): def test_ComputeNodeToCloseAllocationScope_OpenPersonal(self):
compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0] compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0]
person = compute_node.getSourceAdministrationValue() person = compute_node.getSourceAdministrationValue()
target_allocation_scope = 'close/outdated' target_allocation_scope = 'close/outdated'
self.portal.REQUEST['test_compute_nodeToCloseAllocationScope_OpenPersonal'] = \ self.portal.REQUEST['test_ComputeNodeToCloseAllocationScope_OpenPersonal'] = \
self._makeNotificationMessage(compute_node.getReference()) self._makeNotificationMessage(compute_node.getReference())
compute_node.edit(allocation_scope='open/personal') compute_node.edit(allocation_scope='open/personal')
...@@ -714,7 +749,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -714,7 +749,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'Test NM content\n%s\n' % compute_node.getReference(), person.getRelativeUrl()), 'Test NM content\n%s\n' % compute_node.getReference(), person.getRelativeUrl()),
support_request.workflow_history['edit_workflow'][-1]['comment']) support_request.workflow_history['edit_workflow'][-1]['comment'])
def test_compute_nodeNormalAllocationScope_OpenPersonal(self): def test_ComputeNodeNormalAllocationScope_OpenPersonal(self):
compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0] compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0]
person = compute_node.getSourceAdministrationValue() person = compute_node.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider') self._updatePersonAssignment(person, 'role/service_provider')
...@@ -724,7 +759,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -724,7 +759,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
self.tic() self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/personal') self.assertEqual(compute_node.getAllocationScope(), 'open/personal')
def test_compute_nodeAllowedAllocationScope_OpenPublic(self): def test_ComputeNodeAllowedAllocationScope_OpenPublic(self):
compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0] compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0]
person = compute_node.getSourceAdministrationValue() person = compute_node.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider') self._updatePersonAssignment(person, 'role/service_provider')
...@@ -734,6 +769,19 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin): ...@@ -734,6 +769,19 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
self.tic() self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/public') self.assertEqual(compute_node.getAllocationScope(), 'open/public')
def test_ComputeNodeAllowedAllocationScope_OpenFriend(self):
compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0]
friend_person = self.makePerson()
person = compute_node.getSourceAdministrationValue()
self._updatePersonAssignment(person, 'role/service_provider')
compute_node.edit(allocation_scope='open/friend',
destination_section=friend_person.getRelativeUrl())
compute_node.ComputeNode_checkAndUpdateAllocationScope()
self.tic()
self.assertEqual(compute_node.getAllocationScope(), 'open/friend')
class TestComputeNode_hasContactedRecently(SlapOSTestCaseMixinWithAbort): class TestComputeNode_hasContactedRecently(SlapOSTestCaseMixinWithAbort):
def createSPL(self, compute_node): def createSPL(self, compute_node):
......
...@@ -24,5 +24,9 @@ elif scope == 'open/personal': ...@@ -24,5 +24,9 @@ elif scope == 'open/personal':
person = compute_node.getSourceAdministrationValue(portal_type="Person") person = compute_node.getSourceAdministrationValue(portal_type="Person")
if person is not None: if person is not None:
return {"Auditor": ["SHADOW-%s" % person.getUserId()]} return {"Auditor": ["SHADOW-%s" % person.getUserId()]}
elif scope == 'open/friend':
person_list = compute_node.getDestinationSectionValueList(portal_type="Person")
if person_list:
return {"Auditor": ["SHADOW-%s" % x.getUserId() for x in person_list]}
return category_list return category_list
...@@ -43,6 +43,13 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin): ...@@ -43,6 +43,13 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self.assertNotEqual(None, personal_server) self.assertNotEqual(None, personal_server)
self.setServerOpenPersonal(personal_server) self.setServerOpenPersonal(personal_server)
friend_server_title = 'Friend Server for %s' % owner_reference
friend_server_id = self.requestComputeNode(friend_server_title)
friend_server = self.portal.portal_catalog.getResultValue(
portal_type='Compute Node', reference=friend_server_id)
self.assertNotEqual(None, friend_server)
self.setServerOpenFriend(friend_server)
# and install some software on them # and install some software on them
public_server_software = self.generateNewSoftwareReleaseUrl() public_server_software = self.generateNewSoftwareReleaseUrl()
self.supplySoftware(public_server, public_server_software) self.supplySoftware(public_server, public_server_software)
...@@ -50,9 +57,13 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin): ...@@ -50,9 +57,13 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
personal_server_software = self.generateNewSoftwareReleaseUrl() personal_server_software = self.generateNewSoftwareReleaseUrl()
self.supplySoftware(personal_server, personal_server_software) self.supplySoftware(personal_server, personal_server_software)
friend_server_software = self.generateNewSoftwareReleaseUrl()
self.supplySoftware(friend_server, friend_server_software)
# format the compute_nodes # format the compute_nodes
self.formatComputeNode(public_server) self.formatComputeNode(public_server)
self.formatComputeNode(personal_server) self.formatComputeNode(personal_server)
self.formatComputeNode(friend_server)
# join as the another visitor and request software instance on public # join as the another visitor and request software instance on public
...@@ -73,55 +84,68 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin): ...@@ -73,55 +84,68 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
public_server_software, public_instance_type, public_server_software, public_instance_type,
public_server) public_server)
# join as Other Person and request a software instance on compute_node # join as owner friend and request a software instance on compute_node
# configured by owner # configured by owner
self.logout() self.logout()
other_reference = 'other-%s' % self.generateNewId() friend_reference = 'friend-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, other_reference) self.joinSlapOS(self.web_site, friend_reference)
self.login() self.login()
other_person = self.portal.portal_catalog.getResultValue( friend_person = self.portal.portal_catalog.getResultValue(
portal_type='ERP5 Login', reference=other_reference).getParentValue() portal_type='ERP5 Login', reference=friend_reference).getParentValue()
friend_email = friend_person.getDefaultEmailText()
# allow other to alloce on public compute_node # allow friend to alloce on friendly compute_node
self.login(owner_person.getUserId()) self.login(owner_person.getUserId())
self.setServerOpenFriend(friend_server, [friend_email])
other_instance_title = 'Other title %s' % self.generateNewId() friend_instance_title = 'Friend title %s' % self.generateNewId()
other_instance_type = 'other_type' friend_instance_type = 'friend_type'
self.checkInstanceAllocation(other_person.getUserId(), other_reference, self.checkInstanceAllocation(friend_person.getUserId(), friend_reference,
other_instance_title, public_server_software, other_instance_type, friend_instance_title, friend_server_software, friend_instance_type,
public_server) friend_server)
# check that Other Person is able to request slave instance matching the # check that friend is able to request slave instance matching the
# public's compute_node software instance # public's compute_node software instance
other_slave_instance_title = 'Other slave title %s' % self.\ friend_slave_instance_title = 'Friend slave title %s' % self.\
generateNewId() generateNewId()
self.checkSlaveInstanceAllocation(other_person.getUserId(), self.checkSlaveInstanceAllocation(friend_person.getUserId(),
other_reference, other_slave_instance_title, public_server_software, friend_reference, friend_slave_instance_title, public_server_software,
public_instance_type, public_server) public_instance_type, public_server)
# turn public guy to a Other Person and check that he can allocate slave # turn public guy to a friend and check that he can allocate slave
# instance on instance provided by Other Person # instance on instance provided by friend
self.login() self.login()
public_person = self.portal.portal_catalog.getResultValue( public_person = self.portal.portal_catalog.getResultValue(
portal_type='ERP5 Login', reference=public_reference).getParentValue() portal_type='ERP5 Login', reference=public_reference).getParentValue()
public_email = public_person.getDefaultEmailText()
self.login(owner_person.getUserId()) self.login(owner_person.getUserId())
self.setServerOpenFriend(friend_server, [friend_email, public_email])
public_slave_instance_title = 'Public slave title %s' % self\
.generateNewId()
self.checkSlaveInstanceAllocation(public_person.getUserId(),
public_reference, public_slave_instance_title, friend_server_software,
friend_instance_type, friend_server)
# now deallocate the slaves # now deallocate the slaves
self.checkSlaveInstanceUnallocation(other_person.getUserId(), self.checkSlaveInstanceUnallocation(public_person.getUserId(),
other_reference, other_slave_instance_title, public_server_software, public_reference, public_slave_instance_title, friend_server_software,
other_instance_type, public_server) friend_instance_type, friend_server)
self.checkSlaveInstanceUnallocation(friend_person.getUserId(),
friend_reference, friend_slave_instance_title, public_server_software,
public_instance_type, public_server)
# and the instances # and the instances
self.checkInstanceUnallocation(public_person.getUserId(), self.checkInstanceUnallocation(public_person.getUserId(),
public_reference, public_instance_title, public_reference, public_instance_title,
public_server_software, public_instance_type, public_server) public_server_software, public_instance_type, public_server)
self.checkInstanceUnallocation(other_person.getUserId(), self.checkInstanceUnallocation(friend_person.getUserId(),
other_reference, other_instance_title, friend_reference, friend_instance_title,
public_server_software, other_instance_type, public_server) friend_server_software, friend_instance_type, friend_server)
# and uninstall some software on them # and uninstall some software on them
self.logout() self.logout()
...@@ -130,12 +154,15 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin): ...@@ -130,12 +154,15 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
state='destroyed') state='destroyed')
self.supplySoftware(personal_server, personal_server_software, self.supplySoftware(personal_server, personal_server_software,
state='destroyed') state='destroyed')
self.supplySoftware(friend_server, friend_server_software,
state='destroyed')
self.logout() self.logout()
# Uninstall from compute_node # Uninstall from compute_node
self.login() self.login()
self.simulateSlapgridSR(public_server) self.simulateSlapgridSR(public_server)
self.simulateSlapgridSR(personal_server) self.simulateSlapgridSR(personal_server)
self.simulateSlapgridSR(friend_server)
# check the Open Sale Order coverage # check the Open Sale Order coverage
self.stepCallSlaposRequestUpdateInstanceTreeOpenSaleOrderAlarm() self.stepCallSlaposRequestUpdateInstanceTreeOpenSaleOrderAlarm()
...@@ -144,7 +171,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin): ...@@ -144,7 +171,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self.login() self.login()
self.assertOpenSaleOrderCoverage(owner_reference) self.assertOpenSaleOrderCoverage(owner_reference)
self.assertOpenSaleOrderCoverage(other_reference) self.assertOpenSaleOrderCoverage(friend_reference)
self.assertOpenSaleOrderCoverage(public_reference) self.assertOpenSaleOrderCoverage(public_reference)
# generate simulation for open order # generate simulation for open order
...@@ -232,7 +259,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin): ...@@ -232,7 +259,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self.tic() self.tic()
# check final document state # check final document state
for person_reference in (owner_reference, other_reference, for person_reference in (owner_reference, friend_reference,
public_reference): public_reference):
person = self.portal.portal_catalog.getResultValue( person = self.portal.portal_catalog.getResultValue(
portal_type='ERP5 Login', reference=person_reference).getParentValue() portal_type='ERP5 Login', reference=person_reference).getParentValue()
...@@ -241,8 +268,8 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin): ...@@ -241,8 +268,8 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self.login(public_person.getUserId()) self.login(public_person.getUserId())
self.usePayzenManually(self.web_site, public_person.getUserId()) self.usePayzenManually(self.web_site, public_person.getUserId())
self.login(other_person.getUserId()) self.login(friend_person.getUserId())
self.usePayzenManually(self.web_site, other_person.getUserId()) self.usePayzenManually(self.web_site, friend_person.getUserId())
class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin): class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
...@@ -593,4 +620,4 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin): ...@@ -593,4 +620,4 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
self.tic() self.tic()
# check final document state # check final document state
self.assertPersonDocumentCoverage(person) self.assertPersonDocumentCoverage(person)
\ No newline at end of file
...@@ -206,6 +206,23 @@ class TestComputeNode(TestSlapOSGroupRoleSecurityMixin): ...@@ -206,6 +206,23 @@ class TestComputeNode(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(compute_node, self.user_id, ['Owner']) self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor']) self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor'])
# open/friend
friend_reference = 'TESTPERSON-%s' % self.generateNewId()
friend_person = self.portal.person_module.newContent(portal_type='Person',
reference=friend_reference)
compute_node.edit(allocation_scope='open/friend',
destination_section=friend_person.getRelativeUrl()
)
compute_node.updateLocalRolesOnSecurityGroups()
shadow_friend_user_id = 'SHADOW-%s' % friend_person.getUserId()
self.assertSecurityGroup(compute_node,
[self.user_id, 'G-COMPANY', shadow_friend_user_id,
person.getUserId(), compute_node.getUserId()], False)
self.assertRoles(compute_node, shadow_friend_user_id, ['Auditor'])
self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor'])
def test_selfComputeNode(self): def test_selfComputeNode(self):
reference = 'TESTCOMP-%s' % self.generateNewId() reference = 'TESTCOMP-%s' % self.generateNewId()
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node', compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
......
...@@ -76,17 +76,23 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -76,17 +76,23 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
person = self.makePerson() person = self.makePerson()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""]) self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
self._test_ComputeNode_setAllocationScope_public( compute_node = self._test_ComputeNode_setAllocationScope_public(
source_administration=person.getRelativeUrl()) source_administration=person.getRelativeUrl())
self.assertEqual(compute_node.getSubjectList(), [''])
self.assertEqual(compute_node.getDestinationSection(), None)
def test_ComputeNode_setAllocationScope_subscription_with_source_adm(self): def test_ComputeNode_setAllocationScope_subscription_with_source_adm(self):
person = self.makePerson() person = self.makePerson()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""]) self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
self._test_ComputeNode_setAllocationScope_public( compute_node = self._test_ComputeNode_setAllocationScope_public(
source_administration=person.getRelativeUrl(), source_administration=person.getRelativeUrl(),
allocation_scope="open/subscription") allocation_scope="open/subscription")
self.assertEqual(compute_node.getSubjectList(), [''])
self.assertEqual(compute_node.getDestinationSection(), None)
def _test_ComputeNode_setAllocationScope_personal(self, def _test_ComputeNode_setAllocationScope_personal(self,
upgrade_scope=None, upgrade_scope=None,
...@@ -97,6 +103,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -97,6 +103,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
monitor_scope=None, monitor_scope=None,
upgrade_scope=upgrade_scope, upgrade_scope=upgrade_scope,
source_administration=source_administration) source_administration=source_administration)
if subject_list:
compute_node.setSubjectList(subject_list)
self.commit() self.commit()
compute_node.edit(allocation_scope='open/personal') compute_node.edit(allocation_scope='open/personal')
...@@ -108,16 +116,22 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -108,16 +116,22 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
def test_ComputeNode_setAllocationScope_personal(self): def test_ComputeNode_setAllocationScope_personal(self):
compute_node = self._test_ComputeNode_setAllocationScope_personal() compute_node = self._test_ComputeNode_setAllocationScope_personal()
self.assertEqual(compute_node.getUpgradeScope(), 'ask_confirmation') 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): def test_ComputeNode_setAllocationScope_personal_upgrade_disabled(self):
compute_node = self._test_ComputeNode_setAllocationScope_personal( compute_node = self._test_ComputeNode_setAllocationScope_personal(
upgrade_scope="disabled") upgrade_scope="disabled")
self.assertEqual(compute_node.getUpgradeScope(), '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): def test_ComputeNode_setAllocationScope_personal_upgrade_auto(self):
compute_node = self._test_ComputeNode_setAllocationScope_personal( compute_node = self._test_ComputeNode_setAllocationScope_personal(
upgrade_scope="auto") upgrade_scope="auto")
self.assertEqual(compute_node.getUpgradeScope(), 'auto') self.assertEqual(compute_node.getUpgradeScope(), 'auto')
self.assertEqual(compute_node.getSubjectList(), [])
self.assertEqual(compute_node.getDestinationSection(), None)
def test_ComputeNode_setAllocationScope_personal_with_source_adm(self): def test_ComputeNode_setAllocationScope_personal_with_source_adm(self):
person = self.makePerson() person = self.makePerson()
...@@ -128,6 +142,9 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -128,6 +142,9 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
source_administration=person.getRelativeUrl(), source_administration=person.getRelativeUrl(),
) )
self.assertEqual(compute_node.getUpgradeScope(), 'ask_confirmation') 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_personal_with_subject_list(self): def test_ComputeNode_setAllocationScope_personal_with_subject_list(self):
person = self.makePerson() person = self.makePerson()
...@@ -139,6 +156,74 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -139,6 +156,74 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
subject_list=["some@example.com"] subject_list=["some@example.com"]
) )
self.assertEqual(compute_node.getUpgradeScope(), 'ask_confirmation') 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'):
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:
compute_node.setSubjectList(subject_list)
self.commit()
compute_node.edit(allocation_scope='open/friend')
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()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
compute_node = self._test_ComputeNode_setAllocationScope_friend(
source_administration=person.getRelativeUrl())
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
def test_ComputeNode_setAllocationScope_friend_with_subject_list(self):
person = self.makePerson()
self.tic()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
compute_node = self._test_ComputeNode_setAllocationScope_friend(
source_administration=person.getRelativeUrl(),
subject_list=["some@example.com"]
)
self.assertSameSet(compute_node.getSubjectList(),
['some@example.com', person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
def _test_ComputeNode_setAllocationScope_closed(self, def _test_ComputeNode_setAllocationScope_closed(self,
upgrade_scope=None, upgrade_scope=None,
...@@ -150,7 +235,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -150,7 +235,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
monitor_scope=None, monitor_scope=None,
upgrade_scope=upgrade_scope, upgrade_scope=upgrade_scope,
source_administration=source_administration) source_administration=source_administration)
if subject_list:
compute_node.setSubjectList(subject_list)
self.commit() self.commit()
compute_node.edit(allocation_scope=allocation_scope) compute_node.edit(allocation_scope=allocation_scope)
...@@ -169,9 +255,13 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -169,9 +255,13 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.tic() self.tic()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""]) self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
self._test_ComputeNode_setAllocationScope_closed( compute_node = self._test_ComputeNode_setAllocationScope_closed(
source_administration=person.getRelativeUrl()) source_administration=person.getRelativeUrl())
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
def test_ComputeNode_setAllocationScope_closed_termination_no_source_adm(self): def test_ComputeNode_setAllocationScope_closed_termination_no_source_adm(self):
self._test_ComputeNode_setAllocationScope_closed( self._test_ComputeNode_setAllocationScope_closed(
allocation_scope="close/termination", allocation_scope="close/termination",
...@@ -182,10 +272,14 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -182,10 +272,14 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.tic() self.tic()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""]) self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
self._test_ComputeNode_setAllocationScope_closed( compute_node = self._test_ComputeNode_setAllocationScope_closed(
allocation_scope="close/termination", allocation_scope="close/termination",
source_administration=person.getRelativeUrl()) source_administration=person.getRelativeUrl())
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
def test_ComputeNode_setAllocationScope_closed_outdated_no_source_adm(self): def test_ComputeNode_setAllocationScope_closed_outdated_no_source_adm(self):
self._test_ComputeNode_setAllocationScope_closed( self._test_ComputeNode_setAllocationScope_closed(
allocation_scope="close/outdated", allocation_scope="close/outdated",
...@@ -196,10 +290,14 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -196,10 +290,14 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.tic() self.tic()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""]) self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
self._test_ComputeNode_setAllocationScope_closed( compute_node = self._test_ComputeNode_setAllocationScope_closed(
allocation_scope="close/outdated", allocation_scope="close/outdated",
source_administration=person.getRelativeUrl()) source_administration=person.getRelativeUrl())
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
def test_ComputeNode_setAllocationScope_closed_maintenance_no_source_adm(self): def test_ComputeNode_setAllocationScope_closed_maintenance_no_source_adm(self):
self._test_ComputeNode_setAllocationScope_closed( self._test_ComputeNode_setAllocationScope_closed(
allocation_scope="close/maintenance", allocation_scope="close/maintenance",
...@@ -210,10 +308,15 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -210,10 +308,15 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.tic() self.tic()
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""]) self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
self._test_ComputeNode_setAllocationScope_closed( compute_node = self._test_ComputeNode_setAllocationScope_closed(
allocation_scope="close/maintenance", allocation_scope="close/maintenance",
source_administration=person.getRelativeUrl()) source_administration=person.getRelativeUrl())
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(),
[person.getRelativeUrl()])
class TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference( class TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference(
SlapOSTestCaseMixin): SlapOSTestCaseMixin):
......
...@@ -10,6 +10,13 @@ if allocation_scope in ['open/public', 'open/subscription']: ...@@ -10,6 +10,13 @@ if allocation_scope in ['open/public', 'open/subscription']:
if upgrade_scope in [None, 'ask_confirmation']: if upgrade_scope in [None, 'ask_confirmation']:
upgrade_scope = 'auto' 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': elif allocation_scope == 'open/personal':
capacity_scope = 'open' capacity_scope = 'open'
# Keep the same. # Keep the same.
...@@ -20,7 +27,31 @@ else: ...@@ -20,7 +27,31 @@ else:
monitor_scope = 'disabled' monitor_scope = 'disabled'
capacity_scope = 'close' capacity_scope = 'close'
compute_node.edit( edit_kw = {
capacity_scope=capacity_scope, 'capacity_scope': capacity_scope,
monitor_scope=monitor_scope, 'monitor_scope': monitor_scope,
upgrade_scope=upgrade_scope) 'upgrade_scope': upgrade_scope
}
self_person = compute_node.getSourceAdministrationValue(portal_type="Person")
if self_person is None:
compute_node.edit(**edit_kw)
return
self_email = self_person.getDefaultEmailCoordinateText()
if allocation_scope in ['open/public', 'open/subscription']:
# reset friends and update in place
edit_kw['subject_list'] = ['']
edit_kw['destination_section'] = None
elif allocation_scope == 'open/personal':
# reset friends to self and update in place
edit_kw['subject_list'] = [self_email]
edit_kw['destination_section'] = self_person.getRelativeUrl()
else:
subject_list = compute_node.getSubjectList()
if self_email not in subject_list:
# add self as friend
subject_list.append(self_email)
edit_kw['subject_list'] = subject_list
compute_node.edit(**edit_kw)
...@@ -103,14 +103,14 @@ ...@@ -103,14 +103,14 @@
"Closed for termination", "Closed for termination",
"Closed forever", "Closed forever",
"Closed outdated", "Closed outdated",
"", "Open for Friends only",
"Open for Personal use only", "Open for Personal use only",
"Open Public", "Open Public",
"Open for Subscribers only", "Open for Subscribers only",
"Network", "Network",
"Allocation Scope", "Allocation Scope",
"Monitoring", "Monitoring",
"", "Your Friends email",
"Upgrade", "Upgrade",
"The name of a document in ERP5", "The name of a document in ERP5",
"Current Site", "Current Site",
...@@ -169,6 +169,7 @@ ...@@ -169,6 +169,7 @@
[results[2][14], 'close/termination'], [results[2][14], 'close/termination'],
[results[2][15], 'close/forever'], [results[2][15], 'close/forever'],
[results[2][16], 'close/outdated'], [results[2][16], 'close/outdated'],
[results[2][17], 'open/friend'],
[results[2][18], 'open/personal'], [results[2][18], 'open/personal'],
[results[2][19], 'open/public'], [results[2][19], 'open/public'],
[results[2][20], 'open/subscription']], [results[2][20], 'open/subscription']],
...@@ -244,6 +245,17 @@ ...@@ -244,6 +245,17 @@
"hidden": 0, "hidden": 0,
"type": "ListField" "type": "ListField"
}, },
"my_subject_list": {
"description": "",
"title": results[2][24],
"default": gadget.state.doc.subject_list,
"css_class": "",
"required": 1,
"editable": 1,
"key": "subject_list",
"hidden": (gadget.state.doc.allocation_scope === "open/friend") ? 0 : 1,
"type": "LinesField"
},
"my_upgrade_scope": { "my_upgrade_scope": {
"description": "", "description": "",
"title": results[2][25], "title": results[2][25],
...@@ -347,7 +359,8 @@ ...@@ -347,7 +359,8 @@
], [ ], [
"right", "right",
[["my_source"], ["my_source_project"], ["my_monitor_scope"], [["my_source"], ["my_source_project"], ["my_monitor_scope"],
["my_upgrade_scope"], ["my_allocation_scope"]] ["my_upgrade_scope"], ["my_allocation_scope"],
["my_subject_list"]]
], [ ], [
"bottom", "bottom",
[["ticket_listbox"], ["listbox"]] [["ticket_listbox"], ["listbox"]]
......
portal = context.getPortalObject() portal = context.getPortalObject()
category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None) category_public = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)
category_friend = portal.restrictedTraverse("portal_categories/allocation_scope/open/friend", None)
category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None) category_personal = portal.restrictedTraverse("portal_categories/allocation_scope/open/personal", None)
return portal.portal_catalog( return portal.portal_catalog(
portal_type='Compute Node', portal_type='Compute Node',
default_allocation_scope_uid=[ default_allocation_scope_uid=[
category_public.getUid(), category_public.getUid(),
category_friend.getUid(),
category_personal.getUid()], category_personal.getUid()],
validation_state="validated", validation_state="validated",
) )
...@@ -450,11 +450,30 @@ ...@@ -450,11 +450,30 @@
<tr> <tr>
<td>select</td> <td>select</td>
<td>//select[@id="allocation_scope"]</td> <td>//select[@id="allocation_scope"]</td>
<td tal:content="python: '%s' % (here.Base_translateString('Open Public', lang=lang))"></td> <td tal:content="python: '%s' % (here.Base_translateString('Open for Friends only', lang=lang))"></td>
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/save" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/save" />
<tr>
<td>waitForElementPresent</td>
<td>//textarea[@id="subject_list"]</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>//textarea[@id="subject_list"]</td>
<td>demo@user.com</td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/save" />
<tr>
<td>assertValue</td>
<td>//textarea[@id="subject_list"]</td>
<td>demo@user.com</td>
</tr>
<tal:block define="menu_item python: 'Servers'; header menu_item"> <tal:block define="menu_item python: 'Servers'; header menu_item">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/access_menu_item" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/access_menu_item" />
</tal:block> </tal:block>
......
...@@ -80,6 +80,7 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin): ...@@ -80,6 +80,7 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
def test_alarm_compute_node_create_upgrade_decision(self): def test_alarm_compute_node_create_upgrade_decision(self):
compute_node = self._makeComputeNode(allocation_scope = 'open/public')[0] compute_node = self._makeComputeNode(allocation_scope = 'open/public')[0]
compute_node2 = self._makeComputeNode(allocation_scope = 'open/personal')[0] compute_node2 = self._makeComputeNode(allocation_scope = 'open/personal')[0]
compute_node3 = self._makeComputeNode(allocation_scope = 'open/friend')[0]
self.tic() self.tic()
self._simulateScript('ComputeNode_checkAndCreateUpgradeDecision', 'True') self._simulateScript('ComputeNode_checkAndCreateUpgradeDecision', 'True')
...@@ -96,6 +97,9 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin): ...@@ -96,6 +97,9 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
self.assertEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision', self.assertEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision',
compute_node2.workflow_history['edit_workflow'][-1]['comment']) compute_node2.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision',
compute_node3.workflow_history['edit_workflow'][-1]['comment'])
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()
instance_tree2 = self._makeInstanceTree() instance_tree2 = self._makeInstanceTree()
......
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