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
Boxiang Sun
slapos.core
Commits
212fb30e
Commit
212fb30e
authored
Aug 16, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into promises
parents
73bdb764
6d3bed94
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
568 additions
and
5 deletions
+568
-5
master/bt5/vifib_base/DocumentTemplateItem/SoftwareInstance.py
...r/bt5/vifib_base/DocumentTemplateItem/SoftwareInstance.py
+48
-0
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
...flow/scripts/SoftwareInstance_requestSoftwareInstance.xml
+20
-1
master/bt5/vifib_base/bt/revision
master/bt5/vifib_base/bt/revision
+1
-1
master/product/Vifib/tests/testVifibSlapWebService.py
master/product/Vifib/tests/testVifibSlapWebService.py
+499
-3
No files found.
master/bt5/vifib_base/DocumentTemplateItem/SoftwareInstance.py
View file @
212fb30e
...
@@ -29,6 +29,13 @@ from AccessControl import ClassSecurityInfo
...
@@ -29,6 +29,13 @@ from AccessControl import ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
from
Products.ERP5.Document.Item
import
Item
from
Products.ERP5.Document.Item
import
Item
from
lxml
import
etree
from
lxml
import
etree
import
collections
class
DisconnectedSoftwareTree
(
Exception
):
pass
class
CyclicSoftwareTree
(
Exception
):
pass
class
SoftwareInstance
(
Item
):
class
SoftwareInstance
(
Item
):
"""
"""
...
@@ -60,3 +67,44 @@ class SoftwareInstance(Item):
...
@@ -60,3 +67,44 @@ class SoftwareInstance(Item):
value
=
element
.
text
value
=
element
.
text
result_dict
[
key
]
=
value
result_dict
[
key
]
=
value
return
result_dict
return
result_dict
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'checkNotCyclic'
)
def
checkNotCyclic
(
self
,
graph
):
# see http://neopythonic.blogspot.com/2009/01/detecting-cycles-in-directed-graph.html
todo
=
set
(
graph
.
keys
())
while
todo
:
node
=
todo
.
pop
()
stack
=
[
node
]
while
stack
:
top
=
stack
[
-
1
]
for
node
in
graph
[
top
]:
if
node
in
stack
:
raise
CyclicSoftwareTree
if
node
in
todo
:
stack
.
append
(
node
)
todo
.
remove
(
node
)
break
else
:
node
=
stack
.
pop
()
return
True
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'checkConnected'
)
def
checkConnected
(
self
,
graph
,
root
):
size
=
len
(
graph
)
visited
=
set
()
to_crawl
=
collections
.
deque
(
graph
[
root
])
while
to_crawl
:
current
=
to_crawl
.
popleft
()
if
current
in
visited
:
continue
visited
.
add
(
current
)
node_children
=
set
(
graph
[
current
])
to_crawl
.
extend
(
node_children
-
visited
)
# add one to visited, as root won't be visited, only children
# this is false positive in case of cyclic graphs, but they are
# anyway wrong in Software Instance trees
if
size
!=
len
(
visited
)
+
1
:
raise
DisconnectedSoftwareTree
return
True
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
View file @
212fb30e
...
@@ -64,9 +64,12 @@ instance_xml = kwargs["instance_xml"]\n
...
@@ -64,9 +64,12 @@ instance_xml = kwargs["instance_xml"]\n
sla_xml = kwargs["sla_xml"]\n
sla_xml = kwargs["sla_xml"]\n
state = kwargs["state"]\n
state = kwargs["state"]\n
\n
\n
# Get root software instance\n
# graph allows to "simulate" tree change after requested operation\n
graph = {}\n
# Get root software instance and create initial graph\n
predecessor_software_instance = software_instance\n
predecessor_software_instance = software_instance\n
while (predecessor_software_instance is not None):\n
while (predecessor_software_instance is not None):\n
graph[predecessor_software_instance.getUid()] = predecessor_software_instance.getPredecessorUidList()\n
root_software_instance = predecessor_software_instance\n
root_software_instance = predecessor_software_instance\n
predecessor_software_instance = predecessor_software_instance.getPredecessorRelatedValue(\n
predecessor_software_instance = predecessor_software_instance.getPredecessorRelatedValue(\n
portal_type="Software Instance")\n
portal_type="Software Instance")\n
...
@@ -84,6 +87,11 @@ request_software_instance = software_instance.portal_catalog.getResultValue(\n
...
@@ -84,6 +87,11 @@ request_software_instance = software_instance.portal_catalog.getResultValue(\n
root_uid=root_software_instance.getUid(),\n
root_uid=root_software_instance.getUid(),\n
)\n
)\n
\n
\n
# above query does not find root software instance, but as this case is easy\n
# to find, just check if such request does not come and raise\n
if root_software_instance.getTitle() == requested_partition_reference:\n
raise ValueError(\'It is disallowed to request root software instance\')\n
\n
if (request_software_instance is None):\n
if (request_software_instance is None):\n
if (portal.portal_activities.countMessageWithTag(tag) >
0):\n
if (portal.portal_activities.countMessageWithTag(tag) >
0):\n
# The software instance is already under creation but can not be fetched from catalog\n
# The software instance is already under creation but can not be fetched from catalog\n
...
@@ -130,6 +138,8 @@ else:\n
...
@@ -130,6 +138,8 @@ else:\n
predecessor_software_instance.edit(\n
predecessor_software_instance.edit(\n
predecessor_uid_list=predecessor_uid_list,\n
predecessor_uid_list=predecessor_uid_list,\n
activate_kw={\'tag\': tag},)\n
activate_kw={\'tag\': tag},)\n
graph[predecessor_software_instance.getUid()] = predecessor_uid_list\n
\n
if state == \'started\':\n
if state == \'started\':\n
request_software_instance.startRequested()\n
request_software_instance.startRequested()\n
request_software_instance.activate(after_tag=tag).requestStartComputerPartition()\n
request_software_instance.activate(after_tag=tag).requestStartComputerPartition()\n
...
@@ -139,7 +149,16 @@ else:\n
...
@@ -139,7 +149,16 @@ else:\n
else:\n
else:\n
raise ValueError(\'State %r is not supported\' % state)\n
raise ValueError(\'State %r is not supported\' % state)\n
predecessor_list = software_instance.getPredecessorList() + [request_software_instance.getRelativeUrl()]\n
predecessor_list = software_instance.getPredecessorList() + [request_software_instance.getRelativeUrl()]\n
# Add requested software instance to graph if does not exists there yet\n
if not request_software_instance.getUid() in graph:\n
graph[request_software_instance.getUid()] = []\n
\n
# update graph to reflect requested operation\n
graph[software_instance.getUid()] = software_instance.getPredecessorUidList() + [request_software_instance.getUid()]\n
\n
\n
# check if all elements are still connected\n
software_instance.checkNotCyclic(graph)\n
software_instance.checkConnected(graph, root_software_instance.getUid())\n
\n
\n
software_instance.edit(\n
software_instance.edit(\n
predecessor_list=predecessor_list,\n
predecessor_list=predecessor_list,\n
...
...
master/bt5/vifib_base/bt/revision
View file @
212fb30e
246
252
\ No newline at end of file
\ No newline at end of file
master/product/Vifib/tests/testVifibSlapWebService.py
View file @
212fb30e
This diff is collapsed.
Click to expand it.
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