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
Roque
slapos.core
Commits
878461b9
Commit
878461b9
authored
Aug 12, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement cyclic software instance tree protection.
parent
3dd464ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
177 additions
and
2 deletions
+177
-2
master/bt5/vifib_base/DocumentTemplateItem/SoftwareInstance.py
...r/bt5/vifib_base/DocumentTemplateItem/SoftwareInstance.py
+24
-0
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
...flow/scripts/SoftwareInstance_requestSoftwareInstance.xml
+2
-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
+150
-0
No files found.
master/bt5/vifib_base/DocumentTemplateItem/SoftwareInstance.py
View file @
878461b9
...
...
@@ -34,6 +34,9 @@ import collections
class
DisconnectedSoftwareTree
(
Exception
):
pass
class
CyclicSoftwareTree
(
Exception
):
pass
class
SoftwareInstance
(
Item
):
"""
"""
...
...
@@ -65,6 +68,27 @@ class SoftwareInstance(Item):
result_dict
[
key
]
=
value
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
):
...
...
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
View file @
878461b9
...
...
@@ -152,7 +152,8 @@ if not request_software_instance.getUid() in graph:\n
graph[software_instance.getUid()] = software_instance.getPredecessorUidList() + [request_software_instance.getUid()]\n
\n
# check if all elements are still connected\n
script.log(graph, root_software_instance.getUid())\n
script.log(graph)\n
software_instance.checkNotCyclic(graph)\n
software_instance.checkConnected(graph, root_software_instance.getUid())\n
\n
software_instance.edit(\n
...
...
master/bt5/vifib_base/bt/revision
View file @
878461b9
249
\ No newline at end of file
250
\ No newline at end of file
master/product/Vifib/tests/testVifibSlapWebService.py
View file @
878461b9
...
...
@@ -8199,6 +8199,156 @@ class TestVifibSlapWebService(testVifibMixin):
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepDirectRequestComputerPartitionRaisesCyclicSoftwareTree
(
self
,
sequence
,
**
kw
):
software_instance
=
self
.
portal
.
portal_catalog
.
getResultValue
(
uid
=
sequence
[
'software_instance_uid'
])
requested_reference
=
sequence
[
'requested_reference'
]
from
erp5.document.SoftwareInstance
import
CyclicSoftwareTree
self
.
assertRaises
(
CyclicSoftwareTree
,
software_instance
.
requestSoftwareInstance
,
software_release
=
sequence
[
'software_release_uri'
],
software_type
=
sequence
[
'requested_reference'
],
partition_reference
=
sequence
[
'requested_reference'
],
shared
=
False
,
instance_xml
=
self
.
minimal_correct_xml
,
sla_xml
=
self
.
minimal_correct_xml
,
state
=
'started'
)
def
test_bug_cyclic_software_instance
(
self
):
"""Check that no cyclic Software Instance trees would be created
In below scenario system shall behave like mentioned:
OpenOrder.request(SR, A) | SR(A)
A.request(SR, B) | SR(A) <- SR(B)
B.request(SR, A) | SR(A) <- SR(B) <- SR(C)
C.request(SR, B) raises immediately, because the result would be:
SR(A)
SR(B) <-> SR(C)
so B and C would be cyclic
"""
# Setup sufficient amount of CP
self
.
computer_partition_amount
=
3
sequence_list
=
SequenceList
()
sequence_string
=
"""
# Prepare software release
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create the computer
LoginTestVifibAdmin
CreateComputer
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install the software release
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Create Software Instance A (originates from Open Order)
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
ConfirmOrderedSaleOrderActiveSense
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListConfirmed
Logout
# From root request B
SelectRequestedReferenceB
SlapLoginCurrentSoftwareInstance
RequestComputerPartitionNotReadyResponse
Tic
SlapLogout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
# From B request C
SelectRequestedReferenceC
SlapLoginCurrentSoftwareInstance
RequestComputerPartitionNotReadyResponse
Tic
SlapLogout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
# Try to: from C request B and prove that it raises
SelectRequestedReferenceB
LoginDefaultUser # login as superuser in order to work in erp5
DirectRequestComputerPartitionRaisesCyclicSoftwareTree
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
########################################
# Software Instance graph helpers
########################################
...
...
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