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
Klaus Wölfel
slapos.core
Commits
94921f8d
Commit
94921f8d
authored
Sep 20, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorise code.
parent
eeec5cad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
49 deletions
+28
-49
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+28
-49
No files found.
master/product/Vifib/Tool/SlapTool.py
View file @
94921f8d
...
...
@@ -135,6 +135,28 @@ class SlapTool(BaseTool):
# Public GET methods
####################################################
def
_getComputerInformation
(
self
,
computer_id
,
user
,
full
):
user_document
=
self
.
getPortalObject
().
portal_catalog
.
getResultValue
(
reference
=
user
,
portal_type
=
[
'Person'
,
'Computer'
,
'Software Instance'
])
user_type
=
user_document
.
getPortalType
()
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml'
)
slap_computer
=
Computer
(
computer_id
)
parent_uid
=
self
.
_getComputerUidByReference
(
computer_id
)
slap_computer
.
_computer_partition_list
=
[]
if
user_type
in
(
'Computer'
,
'Person'
):
slap_computer
.
_software_release_list
=
\
self
.
_getSoftwareReleaseValueListForComputer
(
computer_id
,
full
=
full
)
else
:
slap_computer
.
_software_release_list
=
[]
for
computer_partition
in
self
.
getPortalObject
().
portal_catalog
(
parent_uid
=
parent_uid
,
validation_state
=
"validated"
,
portal_type
=
"Computer Partition"
):
slap_computer
.
_computer_partition_list
.
append
(
self
.
_getSlapPartitionByPackingList
(
computer_partition
.
getObject
()))
return
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerInformation'
)
def
getComputerInformation
(
self
,
computer_id
):
...
...
@@ -144,35 +166,12 @@ class SlapTool(BaseTool):
Reuses slap library for easy marshalling.
"""
def
_getComputerInformation
(
computer_id
,
user
):
user_document
=
self
.
getPortalObject
().
portal_catalog
.
getResultValue
(
reference
=
user
,
portal_type
=
[
'Person'
,
'Computer'
,
'Software Instance'
])
user_type
=
user_document
.
getPortalType
()
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml'
)
slap_computer
=
Computer
(
computer_id
)
parent_uid
=
self
.
_getComputerUidByReference
(
computer_id
)
slap_computer
.
_computer_partition_list
=
[]
if
user_type
==
'Computer'
:
slap_computer
.
_software_release_list
=
\
self
.
_getSoftwareReleaseValueListForComputer
(
computer_id
)
else
:
slap_computer
.
_software_release_list
=
[]
for
computer_partition
in
self
.
getPortalObject
().
portal_catalog
(
parent_uid
=
parent_uid
,
validation_state
=
"validated"
,
portal_type
=
"Computer Partition"
):
slap_computer
.
_computer_partition_list
.
append
(
self
.
_getSlapPartitionByPackingList
(
computer_partition
.
getObject
()))
return
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
)
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
().
getUserName
()
self
.
_logAccess
(
user
,
user
,
'#access %s'
%
computer_id
)
return
CachingMethod
(
_getComputerInformation
,
return
CachingMethod
(
self
.
_getComputerInformation
,
id
=
'_getComputerInformation'
,
cache_factory
=
'slap_cache_factory'
)(
computer_id
,
user
)
cache_factory
=
'slap_cache_factory'
)(
computer_id
,
user
,
False
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getFullComputerInformation'
)
...
...
@@ -183,32 +182,12 @@ class SlapTool(BaseTool):
Reuses slap library for easy marshalling.
"""
def
_getFullComputerInformation
(
computer_id
,
user
):
user_document
=
self
.
getPortalObject
().
portal_catalog
.
getResultValue
(
reference
=
user
,
portal_type
=
[
'Person'
,
'Computer'
,
'Software Instance'
])
user_type
=
user_document
.
getPortalType
()
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml'
)
slap_computer
=
Computer
(
computer_id
)
parent_uid
=
self
.
_getComputerUidByReference
(
computer_id
)
slap_computer
.
_computer_partition_list
=
[]
if
user_type
in
(
'Computer'
,
'Person'
):
slap_computer
.
_software_release_list
=
\
self
.
_getSoftwareReleaseValueListForComputer
(
computer_id
,
full
=
True
)
else
:
slap_computer
.
_software_release_list
=
[]
for
computer_partition
in
self
.
getPortalObject
().
portal_catalog
(
parent_uid
=
parent_uid
,
validation_state
=
"validated"
,
portal_type
=
"Computer Partition"
):
slap_computer
.
_computer_partition_list
.
append
(
self
.
_getSlapPartitionByPackingList
(
computer_partition
.
getObject
()))
return
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
)
user
=
self
.
getPortalObject
().
portal_membership
.
getAuthenticatedMember
().
getUserName
()
self
.
_logAccess
(
user
,
user
,
'#access %s'
%
computer_id
)
return
CachingMethod
(
_getFull
ComputerInformation
,
return
CachingMethod
(
self
.
_get
ComputerInformation
,
id
=
'_getFullComputerInformation'
,
cache_factory
=
'slap_cache_factory'
)(
computer_id
,
user
)
cache_factory
=
'slap_cache_factory'
)(
computer_id
,
user
,
True
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerPartitionCertificate'
)
...
...
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