Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
slapos.core
Commits
e38031a7
Commit
e38031a7
authored
Oct 29, 2021
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "slapos_*: No more Friend Allocation Scope"
This work is unfinished, so it will be reworked on a branch.
parent
3bb36903
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
528 additions
and
57 deletions
+528
-57
master/bt5/slapos_category/PathTemplateItem/portal_categories/allocation_scope/open/friend.xml
...teItem/portal_categories/allocation_scope/open/friend.xml
+81
-0
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareRelease_getUsableComputeNodeList.py
.../slapos_cloud/SoftwareRelease_getUsableComputeNodeList.py
+1
-1
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
...omponents/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
+11
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
...al_components/test.erp5.testSlapOSCloudAllocationAlarm.py
+66
-0
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdateComputeNodeAllocationScope.py
...itoring/Alarm_checkAndUpdateComputeNodeAllocationScope.py
+2
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ComputeNodeModule_getComputeNodeTicketReportList.py
...oring/ComputeNodeModule_getComputeNodeTicketReportList.py
+4
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ComputeNode_checkAndUpdateAllocationScope.py
...m_monitoring/ComputeNode_checkAndUpdateAllocationScope.py
+1
-1
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_recheckMonitoring.py
...slapos_crm_monitoring/SupportRequest_recheckMonitoring.py
+1
-1
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+41
-0
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
+56
-8
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_core/ComputeNode_getSecurityCategoryFromAllocationScope.py
...ore/ComputeNode_getSecurityCategoryFromAllocationScope.py
+4
-0
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.py
...tal_components/test.erp5.testSlapOSERP5DefaultScenario.py
+56
-29
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
...l_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
+17
-0
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.py
...components/test.erp5.testSlapOSERP5InteractionWorkflow.py
+110
-7
master/bt5/slapos_erp5/WorkflowTemplateItem/portal_workflow/slapos_erp5_interaction_workflow/script_ComputeNode_updateAllocation.py
...teraction_workflow/script_ComputeNode_updateAllocation.py
+35
-4
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_compute_node_view_js.js
..._module/rjs_gadget_erp5_page_slap_compute_node_view_js.js
+16
-3
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Base_getOpenComputeNodeList.py
...kins/slapos_hal_json_style/Base_getOpenComputeNodeList.py
+2
-0
master/bt5/slapos_jio_ui_test/PathTemplateItem/portal_tests/slaposjs_zuite/testSlapOSJSServer.zpt
...teItem/portal_tests/slaposjs_zuite/testSlapOSJSServer.zpt
+20
-1
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
+4
-0
No files found.
master/bt5/slapos_category/PathTemplateItem/portal_categories/allocation_scope/open/friend.xml
0 → 100644
View file @
e38031a7
<?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>
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareRelease_getUsableComputeNodeList.py
View file @
e38031a7
...
...
@@ -4,7 +4,7 @@ kw['url_string'] = context.getUrlString()
software_installation_list
=
context
.
portal_catalog
(
**
kw
)
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
:
compute_node
=
software_installation
.
getAggregateValue
()
if
software_installation
.
getSlapState
()
==
'start_requested'
and
\
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
View file @
e38031a7
...
...
@@ -163,6 +163,17 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
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
):
compute_node_dict
=
dict
(
software_root
=
'/opt'
,
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
View file @
e38031a7
...
...
@@ -234,6 +234,72 @@ return True""" )
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
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'
)
def
test_allocation_does_not_fail_on_instance_with_damaged_sla_xml
(
self
):
self
.
_makeTree
()
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/Alarm_checkAndUpdateComputeNodeAllocationScope.py
View file @
e38031a7
...
...
@@ -2,11 +2,12 @@ portal = context.getPortalObject()
category_public
=
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open/public"
,
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
:
portal
.
portal_catalog
.
searchAndActivate
(
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"
,
method_id
=
'ComputeNode_checkAndUpdateAllocationScope'
,
activate_kw
=
{
'tag'
:
tag
}
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ComputeNodeModule_getComputeNodeTicketReportList.py
View file @
e38031a7
...
...
@@ -6,6 +6,9 @@ from Products.ERP5Type.Document import newTempBase
public_category_uid
=
portal
.
restrictedTraverse
(
"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
(
"portal_categories/allocation_scope/open/personal"
,
None
).
getUid
()
...
...
@@ -37,7 +40,7 @@ def checkForError(reference):
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
},
**
kw
):
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ComputeNode_checkAndUpdateAllocationScope.py
View file @
e38031a7
...
...
@@ -5,7 +5,7 @@ portal = context.getPortalObject()
allocation_scope
=
compute_node
.
getAllocationScope
()
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
if
allocation_scope
==
target_allocation_scope
:
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_recheckMonitoring.py
View file @
e38031a7
...
...
@@ -78,7 +78,7 @@ if aggregate_portal_type == "Instance Tree":
if
instance
.
getAggregate
()
is
not
None
:
compute_node
=
instance
.
getAggregateValue
().
getParentValue
()
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
.
SoftwareInstance_hasReportedError
():
message_list
.
append
(
"%s has error (%s, %s at %s scope %s)"
%
(
instance
.
getReference
(),
instance
.
getTitle
(),
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
e38031a7
...
...
@@ -430,6 +430,14 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
slapos_crm_check_compute_node_state
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
):
self
.
_makeComputeNode
()
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
...
...
@@ -456,6 +464,11 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
allocation_scope
=
'open/public'
,
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
):
self
.
_test_alarm_check_compute_node_state_not_selected
(
allocation_scope
=
'open/personal'
,
...
...
@@ -484,6 +497,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeAllocationScope(SlapOSTestCaseMixin
slapos_crm_check_update_allocation_scope
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
):
self
.
_makeComputeNode
()
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
...
...
@@ -502,6 +524,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
slapos_crm_check_software_installation_state
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
):
self
.
_makeComputeNode
()
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
,
...
...
@@ -521,6 +552,16 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
slapos_crm_check_software_installation_state
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
):
self
.
_makeComputeNode
()
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
,
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMSkins.py
View file @
e38031a7
...
...
@@ -649,7 +649,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'reference=None'
,
'assert reference == "slapos-crm-compute_node_allocation_scope.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["test_
compute_n
odeNotAllowedAllocationScope_OpenPublic"])'
)
'context.REQUEST["test_
ComputeN
odeNotAllowedAllocationScope_OpenPublic"])'
)
@
simulate
(
'SupportRequest_trySendNotificationMessage'
,
'message_title, message, destination_relative_url'
,
'context.portal_workflow.doActionFor('
\
...
...
@@ -657,11 +657,11 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'comment="Visited by SupportRequest_trySendNotificationMessage '
\
'%s %s %s" % (message_title, message, destination_relative_url))
\
n
'
\
'return 1'
)
def
test_
compute_n
odeNotAllowedAllocationScope_OpenPublic
(
self
):
def
test_
ComputeN
odeNotAllowedAllocationScope_OpenPublic
(
self
):
compute_node
=
self
.
_makeComputeNode
(
owner
=
self
.
makePerson
(
user
=
0
))[
0
]
person
=
compute_node
.
getSourceAdministrationValue
()
self
.
portal
.
REQUEST
[
'test_
compute_n
odeNotAllowedAllocationScope_OpenPublic'
]
=
\
self
.
portal
.
REQUEST
[
'test_
ComputeN
odeNotAllowedAllocationScope_OpenPublic'
]
=
\
self
.
_makeNotificationMessage
(
compute_node
.
getReference
())
compute_node
.
edit
(
allocation_scope
=
'open/public'
)
...
...
@@ -679,13 +679,48 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'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
(
'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
(
'ComputeNode_hasContactedRecently'
,
'*args, **kwargs'
,
'return False'
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-crm-compute-node-allocation-scope-closed.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["test_
compute_n
odeToCloseAllocationScope_OpenPersonal"])'
)
'context.REQUEST["test_
ComputeN
odeToCloseAllocationScope_OpenPersonal"])'
)
@
simulate
(
'SupportRequest_trySendNotificationMessage'
,
'message_title, message, destination_relative_url'
,
'context.portal_workflow.doActionFor('
\
...
...
@@ -693,12 +728,12 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'comment="Visited by SupportRequest_trySendNotificationMessage '
\
'%s %s %s" % (message_title, message, destination_relative_url))
\
n
'
\
'return 1'
)
def
test_
compute_n
odeToCloseAllocationScope_OpenPersonal
(
self
):
def
test_
ComputeN
odeToCloseAllocationScope_OpenPersonal
(
self
):
compute_node
=
self
.
_makeComputeNode
(
owner
=
self
.
makePerson
(
user
=
0
))[
0
]
person
=
compute_node
.
getSourceAdministrationValue
()
target_allocation_scope
=
'close/outdated'
self
.
portal
.
REQUEST
[
'test_
compute_n
odeToCloseAllocationScope_OpenPersonal'
]
=
\
self
.
portal
.
REQUEST
[
'test_
ComputeN
odeToCloseAllocationScope_OpenPersonal'
]
=
\
self
.
_makeNotificationMessage
(
compute_node
.
getReference
())
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
...
...
@@ -714,7 +749,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
'Test NM content
\
n
%s
\
n
'
%
compute_node
.
getReference
(),
person
.
getRelativeUrl
()),
support_request
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_
compute_n
odeNormalAllocationScope_OpenPersonal
(
self
):
def
test_
ComputeN
odeNormalAllocationScope_OpenPersonal
(
self
):
compute_node
=
self
.
_makeComputeNode
(
owner
=
self
.
makePerson
(
user
=
0
))[
0
]
person
=
compute_node
.
getSourceAdministrationValue
()
self
.
_updatePersonAssignment
(
person
,
'role/service_provider'
)
...
...
@@ -724,7 +759,7 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
self
.
tic
()
self
.
assertEqual
(
compute_node
.
getAllocationScope
(),
'open/personal'
)
def
test_
compute_n
odeAllowedAllocationScope_OpenPublic
(
self
):
def
test_
ComputeN
odeAllowedAllocationScope_OpenPublic
(
self
):
compute_node
=
self
.
_makeComputeNode
(
owner
=
self
.
makePerson
(
user
=
0
))[
0
]
person
=
compute_node
.
getSourceAdministrationValue
()
self
.
_updatePersonAssignment
(
person
,
'role/service_provider'
)
...
...
@@ -734,6 +769,19 @@ class TestSlapOSComputeNode_notifyWrongAllocationScope(TestCRMSkinsMixin):
self
.
tic
()
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
):
def
createSPL
(
self
,
compute_node
):
...
...
master/bt5/slapos_erp5/SkinTemplateItem/portal_skins/slapos_core/ComputeNode_getSecurityCategoryFromAllocationScope.py
View file @
e38031a7
...
...
@@ -24,5 +24,9 @@ elif scope == 'open/personal':
person
=
compute_node
.
getSourceAdministrationValue
(
portal_type
=
"Person"
)
if
person
is
not
None
:
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
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.py
View file @
e38031a7
...
...
@@ -43,6 +43,13 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self
.
assertNotEqual
(
None
,
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
public_server_software
=
self
.
generateNewSoftwareReleaseUrl
()
self
.
supplySoftware
(
public_server
,
public_server_software
)
...
...
@@ -50,9 +57,13 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
personal_server_software
=
self
.
generateNewSoftwareReleaseUrl
()
self
.
supplySoftware
(
personal_server
,
personal_server_software
)
friend_server_software
=
self
.
generateNewSoftwareReleaseUrl
()
self
.
supplySoftware
(
friend_server
,
friend_server_software
)
# format the compute_nodes
self
.
formatComputeNode
(
public_server
)
self
.
formatComputeNode
(
personal_server
)
self
.
formatComputeNode
(
friend_server
)
# join as the another visitor and request software instance on public
...
...
@@ -73,55 +84,68 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
public_server_software
,
public_instance_type
,
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
self
.
logout
()
other_reference
=
'other
-%s'
%
self
.
generateNewId
()
self
.
joinSlapOS
(
self
.
web_site
,
other
_reference
)
friend_reference
=
'friend
-%s'
%
self
.
generateNewId
()
self
.
joinSlapOS
(
self
.
web_site
,
friend
_reference
)
self
.
login
()
other_person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'ERP5 Login'
,
reference
=
other_reference
).
getParentValue
()
friend_person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
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
.
setServerOpenFriend
(
friend_server
,
[
friend_email
])
other_instance_title
=
'Other
title %s'
%
self
.
generateNewId
()
other_instance_type
=
'other
_type'
self
.
checkInstanceAllocation
(
other_person
.
getUserId
(),
other
_reference
,
other_instance_title
,
public_server_software
,
other
_instance_type
,
public
_server
)
friend_instance_title
=
'Friend
title %s'
%
self
.
generateNewId
()
friend_instance_type
=
'friend
_type'
self
.
checkInstanceAllocation
(
friend_person
.
getUserId
(),
friend
_reference
,
friend_instance_title
,
friend_server_software
,
friend
_instance_type
,
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
other_slave_instance_title
=
'Other
slave title %s'
%
self
.
\
friend_slave_instance_title
=
'Friend
slave title %s'
%
self
.
\
generateNewId
()
self
.
checkSlaveInstanceAllocation
(
other
_person
.
getUserId
(),
other_reference
,
other
_slave_instance_title
,
public_server_software
,
self
.
checkSlaveInstanceAllocation
(
friend
_person
.
getUserId
(),
friend_reference
,
friend
_slave_instance_title
,
public_server_software
,
public_instance_type
,
public_server
)
# turn public guy to a
Other Person
and check that he can allocate slave
# instance on instance provided by
Other Person
# turn public guy to a
friend
and check that he can allocate slave
# instance on instance provided by
friend
self
.
login
()
public_person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'ERP5 Login'
,
reference
=
public_reference
).
getParentValue
()
public_email
=
public_person
.
getDefaultEmailText
()
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
self
.
checkSlaveInstanceUnallocation
(
other_person
.
getUserId
(),
other_reference
,
other_slave_instance_title
,
public_server_software
,
other_instance_type
,
public_server
)
self
.
checkSlaveInstanceUnallocation
(
public_person
.
getUserId
(),
public_reference
,
public_slave_instance_title
,
friend_server_software
,
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
self
.
checkInstanceUnallocation
(
public_person
.
getUserId
(),
public_reference
,
public_instance_title
,
public_server_software
,
public_instance_type
,
public_server
)
self
.
checkInstanceUnallocation
(
other
_person
.
getUserId
(),
other_reference
,
other
_instance_title
,
public_server_software
,
other_instance_type
,
public
_server
)
self
.
checkInstanceUnallocation
(
friend
_person
.
getUserId
(),
friend_reference
,
friend
_instance_title
,
friend_server_software
,
friend_instance_type
,
friend
_server
)
# and uninstall some software on them
self
.
logout
()
...
...
@@ -130,12 +154,15 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
state
=
'destroyed'
)
self
.
supplySoftware
(
personal_server
,
personal_server_software
,
state
=
'destroyed'
)
self
.
supplySoftware
(
friend_server
,
friend_server_software
,
state
=
'destroyed'
)
self
.
logout
()
# Uninstall from compute_node
self
.
login
()
self
.
simulateSlapgridSR
(
public_server
)
self
.
simulateSlapgridSR
(
personal_server
)
self
.
simulateSlapgridSR
(
friend_server
)
# check the Open Sale Order coverage
self
.
stepCallSlaposRequestUpdateInstanceTreeOpenSaleOrderAlarm
()
...
...
@@ -144,7 +171,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self
.
login
()
self
.
assertOpenSaleOrderCoverage
(
owner_reference
)
self
.
assertOpenSaleOrderCoverage
(
other
_reference
)
self
.
assertOpenSaleOrderCoverage
(
friend
_reference
)
self
.
assertOpenSaleOrderCoverage
(
public_reference
)
# generate simulation for open order
...
...
@@ -232,7 +259,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self
.
tic
()
# check final document state
for
person_reference
in
(
owner_reference
,
other
_reference
,
for
person_reference
in
(
owner_reference
,
friend
_reference
,
public_reference
):
person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'ERP5 Login'
,
reference
=
person_reference
).
getParentValue
()
...
...
@@ -241,8 +268,8 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
self
.
login
(
public_person
.
getUserId
())
self
.
usePayzenManually
(
self
.
web_site
,
public_person
.
getUserId
())
self
.
login
(
other
_person
.
getUserId
())
self
.
usePayzenManually
(
self
.
web_site
,
other
_person
.
getUserId
())
self
.
login
(
friend
_person
.
getUserId
())
self
.
usePayzenManually
(
self
.
web_site
,
friend
_person
.
getUserId
())
class
TestSlapOSDefaultCRMEscalation
(
DefaultScenarioMixin
):
...
...
@@ -593,4 +620,4 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
self
.
tic
()
# check final document state
self
.
assertPersonDocumentCoverage
(
person
)
\ No newline at end of file
self
.
assertPersonDocumentCoverage
(
person
)
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
View file @
e38031a7
...
...
@@ -206,6 +206,23 @@ class TestComputeNode(TestSlapOSGroupRoleSecurityMixin):
self
.
assertRoles
(
compute_node
,
self
.
user_id
,
[
'Owner'
])
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
):
reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
'Compute Node'
,
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.py
View file @
e38031a7
...
...
@@ -76,17 +76,23 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
person
=
self
.
makePerson
()
self
.
assertNotIn
(
person
.
getDefaultEmailCoordinateText
(),
[
None
,
""
])
self
.
_test_ComputeNode_setAllocationScope_public
(
compute_node
=
self
.
_test_ComputeNode_setAllocationScope_public
(
source_administration
=
person
.
getRelativeUrl
())
self
.
assertEqual
(
compute_node
.
getSubjectList
(),
[
''
])
self
.
assertEqual
(
compute_node
.
getDestinationSection
(),
None
)
def
test_ComputeNode_setAllocationScope_subscription_with_source_adm
(
self
):
person
=
self
.
makePerson
()
self
.
assertNotIn
(
person
.
getDefaultEmailCoordinateText
(),
[
None
,
""
])
self
.
_test_ComputeNode_setAllocationScope_public
(
compute_node
=
self
.
_test_ComputeNode_setAllocationScope_public
(
source_administration
=
person
.
getRelativeUrl
(),
allocation_scope
=
"open/subscription"
)
self
.
assertEqual
(
compute_node
.
getSubjectList
(),
[
''
])
self
.
assertEqual
(
compute_node
.
getDestinationSection
(),
None
)
def
_test_ComputeNode_setAllocationScope_personal
(
self
,
upgrade_scope
=
None
,
...
...
@@ -97,6 +103,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
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/personal'
)
...
...
@@ -108,16 +116,22 @@ 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
)
def
test_ComputeNode_setAllocationScope_personal_with_source_adm
(
self
):
person
=
self
.
makePerson
()
...
...
@@ -128,6 +142,9 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
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
()])
def
test_ComputeNode_setAllocationScope_personal_with_subject_list
(
self
):
person
=
self
.
makePerson
()
...
...
@@ -139,6 +156,74 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
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'
):
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
,
upgrade_scope
=
None
,
...
...
@@ -150,7 +235,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
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
=
allocation_scope
)
...
...
@@ -169,9 +255,13 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
tic
()
self
.
assertNotIn
(
person
.
getDefaultEmailCoordinateText
(),
[
None
,
""
])
self
.
_test_ComputeNode_setAllocationScope_closed
(
compute_node
=
self
.
_test_ComputeNode_setAllocationScope_closed
(
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
):
self
.
_test_ComputeNode_setAllocationScope_closed
(
allocation_scope
=
"close/termination"
,
...
...
@@ -182,10 +272,14 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
tic
()
self
.
assertNotIn
(
person
.
getDefaultEmailCoordinateText
(),
[
None
,
""
])
self
.
_test_ComputeNode_setAllocationScope_closed
(
compute_node
=
self
.
_test_ComputeNode_setAllocationScope_closed
(
allocation_scope
=
"close/termination"
,
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
):
self
.
_test_ComputeNode_setAllocationScope_closed
(
allocation_scope
=
"close/outdated"
,
...
...
@@ -196,10 +290,14 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
tic
()
self
.
assertNotIn
(
person
.
getDefaultEmailCoordinateText
(),
[
None
,
""
])
self
.
_test_ComputeNode_setAllocationScope_closed
(
compute_node
=
self
.
_test_ComputeNode_setAllocationScope_closed
(
allocation_scope
=
"close/outdated"
,
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
):
self
.
_test_ComputeNode_setAllocationScope_closed
(
allocation_scope
=
"close/maintenance"
,
...
...
@@ -210,10 +308,15 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
tic
()
self
.
assertNotIn
(
person
.
getDefaultEmailCoordinateText
(),
[
None
,
""
])
self
.
_test_ComputeNode_setAllocationScope_closed
(
compute_node
=
self
.
_test_ComputeNode_setAllocationScope_closed
(
allocation_scope
=
"close/maintenance"
,
source_administration
=
person
.
getRelativeUrl
())
self
.
assertEqual
(
compute_node
.
getSubjectList
(),
[
person
.
getDefaultEmailCoordinateText
()])
self
.
assertEqual
(
compute_node
.
getDestinationSectionList
(),
[
person
.
getRelativeUrl
()])
class
TestSlapOSERP5InteractionWorkflowComputerNetworkSetReference
(
SlapOSTestCaseMixin
):
...
...
master/bt5/slapos_erp5/WorkflowTemplateItem/portal_workflow/slapos_erp5_interaction_workflow/script_ComputeNode_updateAllocation.py
View file @
e38031a7
...
...
@@ -10,6 +10,13 @@ if allocation_scope in ['open/public', 'open/subscription']:
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.
...
...
@@ -20,7 +27,31 @@ else:
monitor_scope
=
'disabled'
capacity_scope
=
'close'
compute_node
.
edit
(
capacity_scope
=
capacity_scope
,
monitor_scope
=
monitor_scope
,
upgrade_scope
=
upgrade_scope
)
edit_kw
=
{
'capacity_scope'
:
capacity_scope
,
'monitor_scope'
:
monitor_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
)
master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_compute_node_view_js.js
View file @
e38031a7
...
...
@@ -103,14 +103,14 @@
"
Closed for termination
"
,
"
Closed forever
"
,
"
Closed outdated
"
,
""
,
"
Open for Friends only
"
,
"
Open for Personal use only
"
,
"
Open Public
"
,
"
Open for Subscribers only
"
,
"
Network
"
,
"
Allocation Scope
"
,
"
Monitoring
"
,
""
,
"
Your Friends email
"
,
"
Upgrade
"
,
"
The name of a document in ERP5
"
,
"
Current Site
"
,
...
...
@@ -169,6 +169,7 @@
[
results
[
2
][
14
],
'
close/termination
'
],
[
results
[
2
][
15
],
'
close/forever
'
],
[
results
[
2
][
16
],
'
close/outdated
'
],
[
results
[
2
][
17
],
'
open/friend
'
],
[
results
[
2
][
18
],
'
open/personal
'
],
[
results
[
2
][
19
],
'
open/public
'
],
[
results
[
2
][
20
],
'
open/subscription
'
]],
...
...
@@ -244,6 +245,17 @@
"
hidden
"
:
0
,
"
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
"
:
{
"
description
"
:
""
,
"
title
"
:
results
[
2
][
25
],
...
...
@@ -347,7 +359,8 @@
],
[
"
right
"
,
[[
"
my_source
"
],
[
"
my_source_project
"
],
[
"
my_monitor_scope
"
],
[
"
my_upgrade_scope
"
],
[
"
my_allocation_scope
"
]]
[
"
my_upgrade_scope
"
],
[
"
my_allocation_scope
"
],
[
"
my_subject_list
"
]]
],
[
"
bottom
"
,
[[
"
ticket_listbox
"
],
[
"
listbox
"
]]
...
...
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/Base_getOpenComputeNodeList.py
View file @
e38031a7
portal
=
context
.
getPortalObject
()
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
)
return
portal
.
portal_catalog
(
portal_type
=
'Compute Node'
,
default_allocation_scope_uid
=
[
category_public
.
getUid
(),
category_friend
.
getUid
(),
category_personal
.
getUid
()],
validation_state
=
"validated"
,
)
master/bt5/slapos_jio_ui_test/PathTemplateItem/portal_tests/slaposjs_zuite/testSlapOSJSServer.zpt
View file @
e38031a7
...
...
@@ -450,11 +450,30 @@
<tr>
<td>
select
</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>
<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
metal:use-macro=
"here/Zuite_SlapOSCommonTemplate/macros/access_menu_item"
/>
</tal:block>
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
View file @
e38031a7
...
...
@@ -80,6 +80,7 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
def
test_alarm_compute_node_create_upgrade_decision
(
self
):
compute_node
=
self
.
_makeComputeNode
(
allocation_scope
=
'open/public'
)[
0
]
compute_node2
=
self
.
_makeComputeNode
(
allocation_scope
=
'open/personal'
)[
0
]
compute_node3
=
self
.
_makeComputeNode
(
allocation_scope
=
'open/friend'
)[
0
]
self
.
tic
()
self
.
_simulateScript
(
'ComputeNode_checkAndCreateUpgradeDecision'
,
'True'
)
...
...
@@ -96,6 +97,9 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
self
.
assertEqual
(
'Visited by ComputeNode_checkAndCreateUpgradeDecision'
,
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
):
instance_tree
=
self
.
_makeInstanceTree
()
instance_tree2
=
self
.
_makeInstanceTree
()
...
...
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