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
e42ba089
Commit
e42ba089
authored
Mar 29, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log more informations for instance and computer.
parent
57237fc5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
306 additions
and
16 deletions
+306
-16
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
...5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
+253
-0
master/bt5/slapos_slap_tool/bt/revision
master/bt5/slapos_slap_tool/bt/revision
+1
-1
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+52
-15
No files found.
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
View file @
e42ba089
...
...
@@ -566,6 +566,111 @@ class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
destroy_requested
.
getUrlString
(),
self
.
computer_id
)
self
.
assertEquals
(
destroy_requested
.
getValidationState
(),
"invalidated"
)
def
test_availableSoftwareRelease
(
self
):
self
.
_makeComplexComputer
()
self
.
computer_bang_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
login
(
self
.
computer_id
)
response
=
self
.
portal_slap
.
availableSoftwareRelease
(
'http://example.org'
,
self
.
computer_id
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerStatus
(
self
.
computer_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<unicode>created_at</unicode>
<unicode>%(created_at)s</unicode>
<unicode>text</unicode>
<unicode>#access software release http://example.org available</unicode>
<unicode>user</unicode>
<unicode>%(computer_id)s</unicode>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
computer_id
=
self
.
computer_id
,
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_buildingSoftwareRelease
(
self
):
self
.
_makeComplexComputer
()
self
.
computer_bang_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
login
(
self
.
computer_id
)
response
=
self
.
portal_slap
.
buildingSoftwareRelease
(
'http://example.org'
,
self
.
computer_id
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerStatus
(
self
.
computer_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<unicode>created_at</unicode>
<unicode>%(created_at)s</unicode>
<unicode>text</unicode>
<unicode>building software release http://example.org</unicode>
<unicode>user</unicode>
<unicode>%(computer_id)s</unicode>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
computer_id
=
self
.
computer_id
,
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_softwareReleaseError
(
self
):
self
.
_makeComplexComputer
()
self
.
computer_bang_simulator
=
tempfile
.
mkstemp
()[
1
]
self
.
login
(
self
.
computer_id
)
response
=
self
.
portal_slap
.
softwareReleaseError
(
'http://example.org'
,
self
.
computer_id
,
'error log'
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerStatus
(
self
.
computer_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<unicode>created_at</unicode>
<unicode>%(created_at)s</unicode>
<unicode>text</unicode>
<unicode>#error while installing http://example.org</unicode>
<unicode>user</unicode>
<unicode>%(computer_id)s</unicode>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
computer_id
=
self
.
computer_id
,
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
class
TestSlapOSSlapToolInstanceAccess
(
TestSlapOSSlapToolMixin
):
def
test_getComputerPartitionCertificate
(
self
):
self
.
_makeComplexComputer
()
...
...
@@ -1314,6 +1419,154 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
if
os
.
path
.
exists
(
self
.
instance_request_simulator
):
os
.
unlink
(
self
.
instance_request_simulator
)
def
test_availableComputerPartition
(
self
):
self
.
_makeComplexComputer
()
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
).
getReference
()
self
.
login
(
self
.
start_requested_software_instance
.
getReference
())
response
=
self
.
portal_slap
.
availableComputerPartition
(
self
.
computer_id
,
partition_id
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
computer_id
,
partition_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<unicode>created_at</unicode>
<unicode>%(created_at)s</unicode>
<unicode>text</unicode>
<unicode>#access instance available</unicode>
<unicode>user</unicode>
<unicode>%(instance_guid)s</unicode>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_buildingComputerPartition
(
self
):
self
.
_makeComplexComputer
()
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
).
getReference
()
self
.
login
(
self
.
start_requested_software_instance
.
getReference
())
response
=
self
.
portal_slap
.
buildingComputerPartition
(
self
.
computer_id
,
partition_id
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
computer_id
,
partition_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<unicode>created_at</unicode>
<unicode>%(created_at)s</unicode>
<unicode>text</unicode>
<unicode>building the instance</unicode>
<unicode>user</unicode>
<unicode>%(instance_guid)s</unicode>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_stoppedComputerPartition
(
self
):
self
.
_makeComplexComputer
()
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
).
getReference
()
self
.
login
(
self
.
start_requested_software_instance
.
getReference
())
response
=
self
.
portal_slap
.
stoppedComputerPartition
(
self
.
computer_id
,
partition_id
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
computer_id
,
partition_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<unicode>created_at</unicode>
<unicode>%(created_at)s</unicode>
<unicode>text</unicode>
<unicode>#access instance correctly stopped</unicode>
<unicode>user</unicode>
<unicode>%(instance_guid)s</unicode>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
def
test_startedComputerPartition
(
self
):
self
.
_makeComplexComputer
()
partition_id
=
self
.
start_requested_software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
).
getReference
()
self
.
login
(
self
.
start_requested_software_instance
.
getReference
())
response
=
self
.
portal_slap
.
startedComputerPartition
(
self
.
computer_id
,
partition_id
)
self
.
assertEqual
(
'None'
,
response
)
created_at
=
rfc1123_date
(
DateTime
())
response
=
self
.
portal_slap
.
getComputerPartitionStatus
(
self
.
computer_id
,
partition_id
)
# check returned XML
xml_fp
=
StringIO
.
StringIO
()
xml
.
dom
.
ext
.
PrettyPrint
(
xml
.
dom
.
ext
.
reader
.
Sax
.
FromXml
(
response
.
body
),
stream
=
xml_fp
)
xml_fp
.
seek
(
0
)
got_xml
=
xml_fp
.
read
()
expected_xml
=
"""
\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<dictionary id='i2'>
<unicode>created_at</unicode>
<unicode>%(created_at)s</unicode>
<unicode>text</unicode>
<unicode>#access instance correctly started</unicode>
<unicode>user</unicode>
<unicode>%(instance_guid)s</unicode>
</dictionary>
</marshal>
"""
%
dict
(
created_at
=
created_at
,
instance_guid
=
self
.
start_requested_software_instance
.
getReference
(),
)
self
.
assertEqual
(
expected_xml
,
got_xml
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_xml
.
split
(
'
\
n
'
),
got_xml
.
split
(
'
\
n
'
))]))
class
TestSlapOSSlapToolPersonAccess
(
TestSlapOSSlapToolMixin
):
def
afterSetUp
(
self
):
...
...
master/bt5/slapos_slap_tool/bt/revision
View file @
e42ba089
20
\ No newline at end of file
21
\ No newline at end of file
master/product/Vifib/Tool/SlapTool.py
View file @
e42ba089
...
...
@@ -426,9 +426,7 @@ class SlapTool(BaseTool):
"""
Add an error for a software Release workflow
"""
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
()
\
.
getUserName
()
self
.
_logAccess
(
user
,
computer_id
,
'#error while installing %s'
%
url
)
return
self
.
_softwareReleaseError
(
url
,
computer_id
,
error_log
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'buildingComputerPartition'
)
...
...
@@ -836,16 +834,21 @@ class SlapTool(BaseTool):
@
convertToREST
def
_buildingSoftwareRelease
(
self
,
url
,
computer_id
):
"""
Kept for compatibility
Log the computer status
"""
pass
user
=
self
.
getPortalObject
().
portal_membership
.
\
getAuthenticatedMember
().
getUserName
()
self
.
_logAccess
(
user
,
user
,
'building software release %s'
%
url
)
@
convertToREST
def
_availableSoftwareRelease
(
self
,
url
,
computer_id
):
"""
Kept for compatibility
Log the computer status
"""
pass
user
=
self
.
getPortalObject
().
portal_membership
.
\
getAuthenticatedMember
().
getUserName
()
self
.
_logAccess
(
user
,
user
,
'#access software release %s available'
%
\
url
)
@
convertToREST
def
_destroyedSoftwareRelease
(
self
,
url
,
computer_id
):
...
...
@@ -865,16 +868,28 @@ class SlapTool(BaseTool):
@
convertToREST
def
_buildingComputerPartition
(
self
,
computer_id
,
computer_partition_id
):
"""
Kept for compatibility
Log the computer status
"""
pass
instance
=
self
.
_getSoftwareInstanceForComputerPartition
(
computer_id
,
computer_partition_id
)
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
()
\
.
getUserName
()
self
.
_logAccess
(
user
,
instance
.
getReference
(),
'building the instance'
)
@
convertToREST
def
_availableComputerPartition
(
self
,
computer_id
,
computer_partition_id
):
"""
Kept for compatibility
Log the computer status
"""
pass
instance
=
self
.
_getSoftwareInstanceForComputerPartition
(
computer_id
,
computer_partition_id
)
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
()
\
.
getUserName
()
self
.
_logAccess
(
user
,
instance
.
getReference
(),
'#access instance available'
)
@
convertToREST
def
_softwareInstanceError
(
self
,
computer_id
,
...
...
@@ -957,16 +972,28 @@ class SlapTool(BaseTool):
@
convertToREST
def
_startedComputerPartition
(
self
,
computer_id
,
computer_partition_id
):
"""
Kept for compatibility
Log the computer status
"""
pass
instance
=
self
.
_getSoftwareInstanceForComputerPartition
(
computer_id
,
computer_partition_id
)
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
()
\
.
getUserName
()
self
.
_logAccess
(
user
,
instance
.
getReference
(),
'#access instance correctly started'
)
@
convertToREST
def
_stoppedComputerPartition
(
self
,
computer_id
,
computer_partition_id
):
"""
Kept for compatibility
Log the computer status
"""
pass
instance
=
self
.
_getSoftwareInstanceForComputerPartition
(
computer_id
,
computer_partition_id
)
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
()
\
.
getUserName
()
self
.
_logAccess
(
user
,
instance
.
getReference
(),
'#access instance correctly stopped'
)
@
convertToREST
def
_destroyedComputerPartition
(
self
,
computer_id
,
computer_partition_id
):
...
...
@@ -1424,4 +1451,14 @@ class SlapTool(BaseTool):
)
usage_report
.
validate
()
@
convertToREST
def
_softwareReleaseError
(
self
,
url
,
computer_id
,
error_log
):
"""
Log the computer status
"""
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
()
\
.
getUserName
()
self
.
_logAccess
(
user
,
computer_id
,
'#error while installing %s'
%
url
)
InitializeClass
(
SlapTool
)
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