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
a74849c4
Commit
a74849c4
authored
Oct 16, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement computer request via SlapTool.
parent
36e0ccc0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
200 additions
and
1 deletion
+200
-1
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/scripts/Person_requestComputer.xml
...lap_interface_workflow/scripts/Person_requestComputer.xml
+117
-0
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/states/draft.xml
..._workflow/person_slap_interface_workflow/states/draft.xml
+1
-0
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/states/open_order_created.xml
...son_slap_interface_workflow/states/open_order_created.xml
+1
-0
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/transitions/request_computer.xml
..._slap_interface_workflow/transitions/request_computer.xml
+62
-0
master/bt5/vifib_slap/bt/revision
master/bt5/vifib_slap/bt/revision
+1
-1
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+18
-0
No files found.
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/scripts/Person_requestComputer.xml
0 → 100644
View file @
a74849c4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</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>
_body
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
person = state_change[\'object\']\n
portal = person.getPortalObject()\n
# Get required arguments\n
kwargs = state_change.kwargs\n
\n
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
computer_title = kwargs[\'computer_title\']\n
except KeyError:\n
raise TypeError, "Person_requestComputer takes exactly 1 argument"\n
\n
tag = "%s_%s_computerInProgress" % (person.getUid(), \n
computer_title)\n
if (portal.portal_activities.countMessageWithTag(tag) >
0):\n
# The software instance is already under creation but can not be fetched from catalog\n
# As it is not possible to fetch informations, it is better to raise an error\n
raise NotImplementedError(tag)\n
\n
computer_portal_type = "Computer"\n
certificate_dict = {\'certificate\': None, \'key\': None}\n
computer = portal.portal_catalog.getResultValue(portal_type=computer_portal_type, title=computer_title)\n
if computer is None:\n
reference = "COMP-%s" % portal.portal_ids.generateNewId(\n
id_group=\'slap_computer_reference\',\n
id_generator=\'uid\')\n
certificate_dict = portal.portal_certificate_authority.getNewCertificate(reference)\n
module = portal.getDefaultModule(portal_type=computer_portal_type)\n
computer = module.newContent(\n
portal_type=computer_portal_type,\n
title=computer_title,\n
reference=reference,\n
destination_reference=certificate_dict["id"],\n
capacity_scope=\'open\',\n
activate_kw={\'tag\': tag}\n
)\n
computer.requestComputerRegistration()\n
computer.approveComputerRegistration()\n
\n
\n
computer = context.restrictedTraverse(computer.getRelativeUrl())\n
\n
context.REQUEST.set("computer_certificate", certificate_dict["certificate"])\n
context.REQUEST.set("computer_key", certificate_dict["key"])\n
context.REQUEST.set("computer", computer.getRelativeUrl())\n
context.REQUEST.set("computer_url", computer.absolute_url())\n
context.REQUEST.set("computer_reference", computer.getReference())\n
]]>
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
state_change
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Person_requestComputer
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/states/draft.xml
View file @
a74849c4
...
...
@@ -22,6 +22,7 @@
<key>
<string>
transitions
</string>
</key>
<value>
<tuple>
<string>
request_computer
</string>
<string>
request_software_instance
</string>
</tuple>
</value>
...
...
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/states/open_order_created.xml
View file @
a74849c4
...
...
@@ -23,6 +23,7 @@
<value>
<tuple>
<string>
draft
</string>
<string>
request_computer
</string>
<string>
request_software_instance
</string>
</tuple>
</value>
...
...
master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/person_slap_interface_workflow/transitions/request_computer.xml
0 → 100644
View file @
a74849c4
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"TransitionDefinition"
module=
"Products.DCWorkflow.Transitions"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
actbox_category
</string>
</key>
<value>
<string>
workflow
</string>
</value>
</item>
<item>
<key>
<string>
actbox_icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
actbox_name
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
actbox_url
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
after_script_name
</string>
</key>
<value>
<string>
Person_requestComputer
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
guard
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
request_computer
</string>
</value>
</item>
<item>
<key>
<string>
new_state_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
script_name
</string>
</key>
<value>
<string>
Person_checkConsistency
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
trigger_type
</string>
</key>
<value>
<int>
2
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/vifib_slap/bt/revision
View file @
a74849c4
839
\ No newline at end of file
840
\ No newline at end of file
master/product/Vifib/Tool/SlapTool.py
View file @
a74849c4
...
...
@@ -364,6 +364,24 @@ class SlapTool(BaseTool):
"""
return
self
.
_supplySupply
(
url
,
computer_id
,
state
)
@
convertToREST
def
_requestComputer
(
self
,
computer_title
):
portal
=
self
.
getPortalObject
()
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
person
.
requestComputer
(
computer_title
=
computer_title
)
computer
=
Computer
(
self
.
REQUEST
.
get
(
'computer_reference'
))
computer
.
_certificate
=
self
.
REQUEST
.
get
(
'computer_certificate'
)
computer
.
_key
=
self
.
REQUEST
.
get
(
'computer_key'
)
return
xml_marshaller
.
xml_marshaller
.
dumps
(
computer
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'requestComputer'
)
def
requestComputer
(
self
,
computer_title
):
"""
Request Computer
"""
return
self
.
_requestComputer
(
computer_title
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'buildingSoftwareRelease'
)
def
buildingSoftwareRelease
(
self
,
url
,
computer_id
):
...
...
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