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
Carlos Ramos Carreño
slapos.core
Commits
b72c0fc2
Commit
b72c0fc2
authored
Jan 16, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
Capacity scope for personal and friend
See merge request
nexedi/slapos.core!473
parents
d84c2d18
0dcc8ebf
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
112 additions
and
78 deletions
+112
-78
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Alarm_managePublicComputeNodeCapacityScope.py
...lapos_cloud/Alarm_managePublicComputeNodeCapacityScope.py
+3
-1
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputeNode_checkAndUpdateCapacityScope.py
...s/slapos_cloud/ComputeNode_checkAndUpdateCapacityScope.py
+2
-2
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
...omponents/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
+2
-4
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+39
-8
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.xml
...Item/portal_components/test.erp5.testSlapOSCloudAlarm.xml
+3
-24
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.py
...tal_components/test.erp5.testSlapOSERP5DefaultScenario.py
+2
-1
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.py
...components/test.erp5.testSlapOSERP5InteractionWorkflow.py
+50
-0
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.xml
...omponents/test.erp5.testSlapOSERP5InteractionWorkflow.xml
+3
-24
master/bt5/slapos_erp5/WorkflowTemplateItem/portal_workflow/slapos_erp5_interaction_workflow/script_ComputeNode_updateAllocation.py
...teraction_workflow/script_ComputeNode_updateAllocation.py
+8
-14
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Alarm_managePublicComputeNodeCapacityScope.py
View file @
b72c0fc2
portal
=
context
.
getPortalObject
()
category_list
=
[
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open/public"
,
None
),
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open/subscription"
,
None
)]
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open/subscription"
,
None
),
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open/friend"
,
None
),
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open/personal"
,
None
)]
category_uid_list
=
[
i
.
getUid
()
for
i
in
category_list
if
i
is
not
None
]
...
...
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputeNode_checkAndUpdateCapacityScope.py
View file @
b72c0fc2
...
...
@@ -4,8 +4,8 @@ from zExceptions import Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
if
compute_node
.
getAllocationScope
()
not
in
[
'open/public'
,
'open/subscription'
]:
# Don't update non
public compute_node
if
compute_node
.
getAllocationScope
()
not
in
[
'open/public'
,
'open/subscription'
,
'open/personal'
,
'open/friend'
]:
# Don't update non
closed computers
return
can_allocate
=
True
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
View file @
b72c0fc2
...
...
@@ -147,8 +147,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server
.
edit
(
allocation_scope
=
'open/public'
)
self
.
assertEqual
(
'open/public'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'close'
,
server
.
getCapacityScope
())
server
.
edit
(
capacity_scope
=
'open'
)
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
tic
()
@
changeSkin
(
'RJS'
)
...
...
@@ -156,8 +155,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server
.
edit
(
allocation_scope
=
'open/subscription'
)
self
.
assertEqual
(
'open/subscription'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'close'
,
server
.
getCapacityScope
())
server
.
edit
(
capacity_scope
=
'open'
)
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
tic
()
@
changeSkin
(
'RJS'
)
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
b72c0fc2
...
...
@@ -429,14 +429,15 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
'Visited by SoftwareInstance_tryToGarbageCollect'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestSlapOSUpdateComputeNodeCapacityScopeAlarm
(
SlapOSTestCaseMixin
):
class
TestSlapOSComputeNode_checkAndUpdateCapacityScope
(
SlapOSTestCaseMixin
):
allocation_scope_to_test
=
'open/public'
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
self
.
compute_node
.
edit
(
allocation_scope
=
'open/public'
,
allocation_scope
=
self
.
allocation_scope_to_test
,
reference
=
'TESTC-%s'
%
self
.
generateNewId
(),
)
self
.
compute_node
.
edit
(
capacity_scope
=
'open'
)
...
...
@@ -548,11 +549,29 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
self
.
assertEqual
(
"Compute Node reported an error"
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_ComputeNode_checkAndUpdateCapacityScope_with_error_non_public
(
self
):
self
.
compute_node
.
setAccessStatus
(
'#error not ok'
)
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
self
.
compute_node
.
getCapacityScope
())
class
TestSlapOSComputeNode_checkAndUpdateCapacityScopeSubscription
(
TestSlapOSComputeNode_checkAndUpdateCapacityScope
):
allocation_scope_to_test
=
'open/subscription'
class
TestSlapOSComputeNode_checkAndUpdateCapacityScopePersonal
(
TestSlapOSComputeNode_checkAndUpdateCapacityScope
):
allocation_scope_to_test
=
'open/personal'
class
TestSlapOSComputeNode_checkAndUpdateCapacityScopeFriend
(
TestSlapOSComputeNode_checkAndUpdateCapacityScope
):
allocation_scope_to_test
=
'open/friend'
class
TestSlapOSUpdateComputeNodeCapacityScopeAlarm
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
self
.
compute_node
.
edit
(
allocation_scope
=
'open/public'
,
reference
=
'TESTC-%s'
%
self
.
generateNewId
(),
)
self
.
compute_node
.
edit
(
capacity_scope
=
'open'
)
self
.
compute_node
.
validate
()
self
.
compute_node
.
setAccessStatus
(
"#access ok"
)
transaction
.
commit
()
def
_simulateComputeNode_checkAndUpdateCapacityScope
(
self
):
script_name
=
'ComputeNode_checkAndUpdateCapacityScope'
...
...
@@ -584,8 +603,20 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
'Visited by ComputeNode_checkAndUpdateCapacityScope'
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_non_public
(
self
):
def
test_alarm_subscription
(
self
):
self
.
compute_node
.
edit
(
allocation_scope
=
'open/subscription'
)
self
.
test_alarm
()
def
test_alarm_personal
(
self
):
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
test_alarm
()
def
test_alarm_friend
(
self
):
self
.
compute_node
.
edit
(
allocation_scope
=
'open/friend'
)
self
.
test_alarm
()
def
test_alarm_closed
(
self
):
self
.
compute_node
.
edit
(
allocation_scope
=
'close/outdated'
)
self
.
tic
()
self
.
_simulateComputeNode_checkAndUpdateCapacityScope
()
try
:
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.xml
View file @
b72c0fc2
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSCloudAlarm
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.py
View file @
b72c0fc2
...
...
@@ -54,6 +54,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
personal_server_id
=
self
.
requestComputeNode
(
personal_server_title
)
personal_server
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Compute Node'
,
reference
=
personal_server_id
)
self
.
setAccessToMemcached
(
personal_server
)
self
.
assertNotEqual
(
None
,
personal_server
)
self
.
setServerOpenPersonal
(
personal_server
)
...
...
@@ -61,6 +62,7 @@ class TestSlapOSDefaultScenario(DefaultScenarioMixin):
friend_server_id
=
self
.
requestComputeNode
(
friend_server_title
)
friend_server
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Compute Node'
,
reference
=
friend_server_id
)
self
.
setAccessToMemcached
(
friend_server
)
self
.
assertNotEqual
(
None
,
friend_server
)
self
.
setServerOpenFriend
(
friend_server
)
...
...
@@ -392,7 +394,6 @@ class TestSlapOSDefaultCRMEscalation(DefaultScenarioMixin):
self
.
assertOpenSaleOrderCoverage
(
public_reference
)
# generate simulation for open order
self
.
stepCallUpdateOpenOrderSimulationAlarm
()
self
.
tic
()
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.py
View file @
b72c0fc2
...
...
@@ -37,6 +37,19 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'enabled'
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
None
)
self
.
commit
()
compute_node
.
edit
(
capacity_scope
=
"open"
,
monitor_scope
=
'enabled'
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
allocation_scope
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'open'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'enabled'
)
return
compute_node
def
test_ComputeNode_setAllocationScope_public_no_source_adm
(
self
):
...
...
@@ -82,6 +95,18 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'disabled'
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
None
)
self
.
commit
()
compute_node
.
edit
(
capacity_scope
=
"open"
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'open'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'disabled'
)
return
compute_node
...
...
@@ -132,6 +157,18 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node
.
edit
(
allocation_scope
=
'open/friend'
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'enabled'
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
None
)
self
.
commit
()
compute_node
.
edit
(
capacity_scope
=
"open"
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
'open/friend'
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'open'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'enabled'
)
return
compute_node
...
...
@@ -179,6 +216,19 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node
.
edit
(
allocation_scope
=
allocation_scope
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'disabled'
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
None
)
self
.
commit
()
compute_node
.
edit
(
capacity_scope
=
"open"
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
allocation_scope
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'disabled'
)
return
compute_node
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.xml
View file @
b72c0fc2
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSERP5InteractionWorkflow
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
master/bt5/slapos_erp5/WorkflowTemplateItem/portal_workflow/slapos_erp5_interaction_workflow/script_ComputeNode_updateAllocation.py
View file @
b72c0fc2
compute_node
=
state_object
[
"object"
]
allocation_scope
=
compute_node
.
getAllocationScope
()
if
allocation_scope
in
[
'open/public'
,
'open/subscription'
]:
# Public compute_node capacity is handle by an alarm
capacity_scope
=
'close'
monitor_scope
=
'enabled'
elif
allocation_scope
==
'open/friend'
:
# Capacity is not handled for 'private' compute_nodes
capacity_scope
=
'open'
edit_kw
=
{}
if
compute_node
.
getCapacityScope
()
is
None
:
edit_kw
[
'capacity_scope'
]
=
'close'
if
allocation_scope
in
[
'open/public'
,
'open/subscription'
,
'open/friend'
]:
monitor_scope
=
'enabled'
elif
allocation_scope
==
'open/personal'
:
capacity_scope
=
'open'
# Keep the same.
monitor_scope
=
compute_node
.
getMonitorScope
(
"disabled"
)
else
:
monitor_scope
=
'disabled'
capacity_scope
=
'close'
edit_kw
[
'capacity_scope'
]
=
'close'
edit_kw
=
{
'capacity_scope'
:
capacity_scope
,
'monitor_scope'
:
monitor_scope
}
edit_kw
[
'monitor_scope'
]
=
monitor_scope
self_person
=
compute_node
.
getSourceAdministrationValue
(
portal_type
=
"Person"
)
if
self_person
is
None
:
...
...
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