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
Xiaowu Zhang
slapos.core
Commits
af16f03d
Commit
af16f03d
authored
Dec 13, 2021
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: Introduce ComputerNetwork.requestTransfer
parent
0985f9a8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
241 additions
and
60 deletions
+241
-60
master/bt5/slapos_cloud/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
...rtalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
+1
-1
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputerNetwork_createMovement.py
...rtal_skins/slapos_cloud/ComputerNetwork_createMovement.py
+4
-58
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudCreateMovementSkins.py
...omponents/test.erp5.testSlapOSCloudCreateMovementSkins.py
+2
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_requestTransfer.py
...erface_workflow/script_ComputerNetwork_requestTransfer.py
+79
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_requestTransfer.xml
...rface_workflow/script_ComputerNetwork_requestTransfer.xml
+85
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/state_draft.xml
..._workflow/network_slap_interface_workflow/state_draft.xml
+1
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/transition_request_transfer.xml
...k_slap_interface_workflow/transition_request_transfer.xml
+68
-0
master/bt5/slapos_cloud/bt/template_portal_type_workflow_chain_list
.../slapos_cloud/bt/template_portal_type_workflow_chain_list
+1
-1
No files found.
master/bt5/slapos_cloud/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml
View file @
af16f03d
...
...
@@ -9,7 +9,7 @@
</chain>
<chain>
<type>
Computer Network
</type>
<workflow>
computer_
network_slap_interface_workflow
</workflow>
<workflow>
network_slap_interface_workflow
</workflow>
</chain>
<chain>
<type>
Hosting Subscription
</type>
...
...
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputerNetwork_createMovement.py
View file @
af16f03d
"""
Create an internal Packing List and attach the compute_node
"""
from
DateTime
import
DateTime
from
zExceptions
import
Unauthorized
user
=
context
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
if
user
is
None
or
user
.
getRelativeUrl
()
!=
context
.
getSourceAdministration
():
raise
Unauthorized
(
"Only the Computer Network owner can transfer it from one location to another."
)
portal_type
=
"Internal Packing List"
source_project
=
context
.
Item_getCurrentProjectValue
()
source_section
=
context
.
Item_getCurrentOwnerValue
()
if
destination_project
is
None
and
source_project
is
not
None
:
destination_project
=
source_project
.
getRelativeUrl
()
if
source_section
is
None
:
source_section
=
context
.
getSourceAdministrationValue
()
if
destination_section
is
None
:
destination_section
=
source_section
.
getRelativeUrl
()
source
=
context
.
getSourceAdministration
()
destination
=
context
.
getSourceAdministration
()
resource_value
=
context
.
product_module
.
compute_node
module
=
context
.
getDefaultModule
(
portal_type
=
portal_type
)
line_portal_type
=
'%s Line'
%
portal_type
delivery
=
module
.
newContent
(
title
=
"Transfer %s to %s"
%
(
context
.
getTitle
(),
destination_project
),
source
=
source
,
source_section_value
=
source_section
,
source_project_value
=
source_project
,
destination
=
destination
,
destination_section
=
destination_section
,
source_decision
=
destination_section
,
destination_decision
=
destination_section
,
context
.
requestTransfer
(
destination_project
=
destination_project
,
start_date
=
DateTime
(),
stop_date
=
DateTime
(),
portal_type
=
portal_type
)
delivery_line
=
delivery
.
newContent
(
portal_type
=
line_portal_type
,
title
=
context
.
getReference
(),
quantity_unit
=
resource_value
.
getQuantityUnit
(),
resource_value
=
resource_value
)
delivery_line
.
edit
(
price
=
0.0
,
quantity
=
1.0
,
aggregate
=
context
.
getRelativeUrl
())
delivery
.
confirm
()
delivery
.
stop
()
delivery
.
deliver
()
destination_section
=
destination_section
)
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudCreateMovementSkins.py
View file @
af16f03d
...
...
@@ -490,6 +490,8 @@ class TestInstanceTreecreateMovement(SlapOSTestCaseMixin):
def
_makeInstanceTree
(
self
):
instance_tree
=
self
.
portal
.
instance_tree_module
\
.
template_instance_tree
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
.
edit
(
reference
=
'TESTINTT-%s'
%
instance_tree
.
getId
(),
title
=
'TESTINTT-%s'
%
instance_tree
.
getId
())
instance_tree
.
validate
()
self
.
tic
()
return
instance_tree
...
...
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_requestTransfer.py
0 → 100644
View file @
af16f03d
computer_network
=
state_change
[
"object"
]
from
DateTime
import
DateTime
from
zExceptions
import
Unauthorized
portal
=
computer_network
.
getPortalObject
()
# Get required arguments
kwargs
=
state_change
.
kwargs
# Required args
# Raise TypeError if all parameters are not provided
try
:
# destination_project=None, destination_section=None
destination_section
=
kwargs
[
'destination_section'
]
destination_project
=
kwargs
[
"destination_project"
]
except
KeyError
:
raise
TypeError
(
"ComputerNetwork_requestTransfer takes exactly 2 arguments"
)
user
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
if
user
is
None
or
user
.
getRelativeUrl
()
!=
computer_network
.
getSourceAdministration
():
raise
Unauthorized
(
"Only the Computer Network owner can transfer it from one location to another."
)
tag
=
"%s_%s_%s_inProgress"
%
(
computer_network
.
getUid
(),
destination_section
,
destination_project
)
if
(
portal
.
portal_activities
.
countMessageWithTag
(
tag
)
>
0
):
# The software instance is already under creation but can not be fetched from catalog
# As it is not possible to fetch informations, it is better to raise an error
raise
NotImplementedError
(
tag
)
movement_portal_type
=
"Internal Packing List"
source_project
=
computer_network
.
Item_getCurrentProjectValue
()
source_section
=
computer_network
.
Item_getCurrentOwnerValue
()
source
=
computer_network
.
getSourceAdministration
()
destination
=
computer_network
.
getSourceAdministration
()
resource_value
=
portal
.
product_module
.
compute_node
if
destination_project
is
None
and
source_project
is
not
None
:
destination_project
=
source_project
.
getRelativeUrl
()
if
source_section
is
None
:
source_section
=
computer_network
.
getSourceAdministrationValue
()
if
destination_section
is
None
:
destination_section
=
source_section
.
getRelativeUrl
()
module
=
portal
.
getDefaultModule
(
portal_type
=
movement_portal_type
)
line_portal_type
=
'%s Line'
%
movement_portal_type
delivery
=
module
.
newContent
(
title
=
"Transfer %s to %s"
%
(
computer_network
.
getTitle
(),
destination_project
),
source
=
source
,
source_section_value
=
source_section
,
source_project_value
=
source_project
,
destination
=
destination
,
destination_section
=
destination_section
,
source_decision
=
destination_section
,
destination_decision
=
destination_section
,
destination_project
=
destination_project
,
start_date
=
DateTime
(),
stop_date
=
DateTime
(),
portal_type
=
movement_portal_type
)
delivery_line
=
delivery
.
newContent
(
portal_type
=
line_portal_type
,
title
=
computer_network
.
getReference
(),
quantity_unit
=
resource_value
.
getQuantityUnit
(),
resource_value
=
resource_value
)
delivery_line
.
edit
(
price
=
0.0
,
quantity
=
1.0
,
aggregate
=
computer_network
.
getRelativeUrl
())
delivery
.
confirm
()
delivery
.
stop
()
delivery
.
deliver
()
delivery
.
reindexObject
(
activate_kw
=
dict
(
tag
=
tag
))
delivery_line
.
reindexObject
(
activate_kw
=
dict
(
tag
=
tag
))
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_requestTransfer.xml
0 → 100644
View file @
af16f03d
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Workflow Script"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
state_change
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
script_ComputerNetwork_requestTransfer
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Workflow Script
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
ComputerNetwork_requestTransfer
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/state_draft.xml
View file @
af16f03d
...
...
@@ -17,6 +17,7 @@
<value>
<tuple>
<string>
destination/portal_workflow/network_slap_interface_workflow/transition_approve_registration
</string>
<string>
destination/portal_workflow/network_slap_interface_workflow/transition_request_transfer
</string>
</tuple>
</value>
</item>
...
...
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/network_slap_interface_workflow/transition_request_transfer.xml
0 → 100644
View file @
af16f03d
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Workflow Transition"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
action_name
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/workflow
</string>
<string>
before_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_checkConsistency
</string>
<string>
after_script/portal_workflow/network_slap_interface_workflow/script_ComputerNetwork_requestTransfer
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
guard_permission
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
transition_request_transfer
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Workflow Transition
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Request Transfer
</string>
</value>
</item>
<item>
<key>
<string>
trigger_type
</string>
</key>
<value>
<int>
2
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/bt/template_portal_type_workflow_chain_list
View file @
af16f03d
Compute Node | compute_node_slap_interface_workflow
Compute Node | slapos_cloud_interaction_workflow
Compute Partition | compute_partition_slap_interface_workflow
Computer Network |
computer_
network_slap_interface_workflow
Computer Network | network_slap_interface_workflow
Hosting Subscription | edit_workflow
Instance Tree | edit_workflow
Instance Tree | instance_slap_interface_workflow
...
...
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