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
Jérome Perrin
slapos.core
Commits
3de0ab52
Commit
3de0ab52
authored
May 10, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support non ASCII character in slaptool.
xml_marshaller requires unicode string.
parent
38525388
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
248 additions
and
228 deletions
+248
-228
master/bt5/slapos_cloud/DocumentTemplateItem/SoftwareInstance.py
...bt5/slapos_cloud/DocumentTemplateItem/SoftwareInstance.py
+1
-1
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
...5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
+199
-198
master/bt5/slapos_slap_tool/bt/revision
master/bt5/slapos_slap_tool/bt/revision
+1
-1
master/product/SlapOS/tests/testSlapOSMixin.py
master/product/SlapOS/tests/testSlapOSMixin.py
+7
-5
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+39
-22
No files found.
master/bt5/slapos_cloud/DocumentTemplateItem/SoftwareInstance.py
View file @
3de0ab52
...
...
@@ -55,7 +55,7 @@ class SoftwareInstance(Item):
if
xml
is
None
or
xml
==
''
:
return
result_dict
tree
=
etree
.
fromstring
(
xml
.
encode
(
'utf-8'
)
)
tree
=
etree
.
fromstring
(
xml
)
for
element
in
tree
.
findall
(
'parameter'
):
key
=
element
.
get
(
'id'
)
...
...
master/bt5/slapos_cloud/bt/revision
View file @
3de0ab52
278
\ No newline at end of file
279
\ No newline at end of file
master/bt5/slapos_slap_tool/TestTemplateItem/testSlapOSSlapTool.py
View file @
3de0ab52
This diff is collapsed.
Click to expand it.
master/bt5/slapos_slap_tool/bt/revision
View file @
3de0ab52
25
\ No newline at end of file
26
\ No newline at end of file
master/product/SlapOS/tests/testSlapOSMixin.py
View file @
3de0ab52
...
...
@@ -541,21 +541,23 @@ class testSlapOSMixin(ERP5TypeTestCase):
self
.
portal
.
REQUEST
.
headers
=
{}
def
generateNewId
(
self
):
return
self
.
portal
.
portal_ids
.
generateNewId
(
return
"%sö"
%
self
.
portal
.
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_core_test'
))
def
generateNewSoftwareReleaseUrl
(
self
):
return
'http://example.org/t
e
st%s.cfg'
%
self
.
generateNewId
()
return
'http://example.org/t
ê
st%s.cfg'
%
self
.
generateNewId
()
def
generateNewSoftwareType
(
self
):
return
'Type%s'
%
self
.
generateNewId
()
return
'Type
ë@î
%s'
%
self
.
generateNewId
()
def
generateNewSoftwareTitle
(
self
):
return
'Title%s'
%
self
.
generateNewId
()
return
'Title
é#ï
%s'
%
self
.
generateNewId
()
def
generateSafeXml
(
self
):
return
'<?xml version="1.0" encoding="utf-8"?><instance><parameter '
\
'id="param">%s</parameter></instance>'
%
self
.
generateNewId
()
'id="%s">%s</parameter></instance>'
%
\
(
"paramé"
.
decode
(
"UTF-8"
).
encode
(
"UTF-8"
),
self
.
generateNewId
().
decode
(
"UTF-8"
).
encode
(
"UTF-8"
))
def
generateEmptyXml
(
self
):
return
'<?xml version="1.0" encoding="utf-8"?><instance></instance>'
...
...
master/product/Vifib/Tool/SlapTool.py
View file @
3de0ab52
...
...
@@ -165,7 +165,7 @@ class SlapTool(BaseTool):
def
_getCacheComputerInformation
(
self
,
computer_id
,
user
):
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml; charset=utf-8'
)
slap_computer
=
Computer
(
computer_id
)
slap_computer
=
Computer
(
computer_id
.
decode
(
"UTF-8"
)
)
parent_uid
=
self
.
_getComputerUidByReference
(
computer_id
)
slap_computer
.
_computer_partition_list
=
[]
...
...
@@ -230,7 +230,7 @@ class SlapTool(BaseTool):
reference
=
user
,
portal_type
=
[
'Person'
,
'Computer'
,
'Software Instance'
]))
user_type
=
user_document
.
getPortalType
()
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml; charset=utf-8'
)
slap_computer
=
Computer
(
computer_id
)
slap_computer
=
Computer
(
computer_id
.
decode
(
"UTF-8"
)
)
parent_uid
=
self
.
_getComputerUidByReference
(
computer_id
)
slap_computer
.
_computer_partition_list
=
[]
...
...
@@ -386,7 +386,7 @@ class SlapTool(BaseTool):
portal
=
self
.
getPortalObject
()
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
person
.
requestComputer
(
computer_title
=
computer_title
)
computer
=
Computer
(
self
.
REQUEST
.
get
(
'computer_reference'
))
computer
=
Computer
(
self
.
REQUEST
.
get
(
'computer_reference'
)
.
decode
(
"UTF-8"
)
)
return
xml_marshaller
.
xml_marshaller
.
dumps
(
computer
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
@@ -596,8 +596,8 @@ class SlapTool(BaseTool):
def
_generateComputerCertificate
(
self
,
computer_id
):
self
.
_getComputerDocument
(
computer_id
).
generateCertificate
()
result
=
{
'certificate'
:
self
.
REQUEST
.
get
(
'computer_certificate'
),
'key'
:
self
.
REQUEST
.
get
(
'computer_key'
)
'certificate'
:
self
.
REQUEST
.
get
(
'computer_certificate'
)
.
decode
(
"UTF-8"
)
,
'key'
:
self
.
REQUEST
.
get
(
'computer_key'
)
.
decode
(
"UTF-8"
)
}
return
xml_marshaller
.
xml_marshaller
.
dumps
(
result
)
...
...
@@ -630,8 +630,8 @@ class SlapTool(BaseTool):
portal
=
self
.
getPortalObject
()
computer_partition_document
=
self
.
_getComputerPartitionDocument
(
computer_reference
,
computer_partition_reference
)
slap_partition
=
SlapComputerPartition
(
computer_reference
,
computer_partition_reference
)
slap_partition
=
SlapComputerPartition
(
computer_reference
.
decode
(
"UTF-8"
)
,
computer_partition_reference
.
decode
(
"UTF-8"
)
)
slap_partition
.
_software_release_document
=
None
slap_partition
.
_requested_state
=
'destroyed'
slap_partition
.
_need_modification
=
0
...
...
@@ -664,8 +664,10 @@ class SlapTool(BaseTool):
slap_partition
.
_requested_state
=
'started'
slap_partition
.
_software_release_document
=
SoftwareRelease
(
software_release
=
software_instance
.
getUrlString
(),
computer_guid
=
computer_reference
)
software_release
=
software_instance
.
getUrlString
().
decode
(
"UTF-8"
),
computer_guid
=
computer_reference
.
decode
(
"UTF-8"
))
slap_partition
.
_software_release_document
.
_software_release
=
\
slap_partition
.
_software_release_document
.
_software_release
.
decode
(
"UTF-8"
)
slap_partition
.
_need_modification
=
1
...
...
@@ -742,7 +744,7 @@ class SlapTool(BaseTool):
result_dict
=
{}
try
:
if
xml
is
not
None
and
xml
!=
''
:
tree
=
etree
.
fromstring
(
xml
.
encode
(
'utf-8'
)
)
tree
=
etree
.
fromstring
(
xml
)
for
element
in
tree
.
findall
(
'parameter'
):
key
=
element
.
get
(
'id'
)
value
=
result_dict
.
get
(
key
,
None
)
...
...
@@ -761,9 +763,9 @@ class SlapTool(BaseTool):
portal
=
self
.
getPortalObject
()
while
computer
.
getPortalType
()
!=
'Computer'
:
computer
=
computer
.
getParentValue
()
computer_id
=
computer
.
getReference
()
computer_id
=
computer
.
getReference
()
.
decode
(
"UTF-8"
)
slap_partition
=
SlapComputerPartition
(
computer_id
,
computer_partition_document
.
getReference
(
))
computer_partition_document
.
getReference
().
decode
(
"UTF-8"
))
slap_partition
.
_software_release_document
=
None
slap_partition
.
_requested_state
=
'destroyed'
...
...
@@ -795,8 +797,10 @@ class SlapTool(BaseTool):
slap_partition
.
_requested_state
=
'started'
slap_partition
.
_software_release_document
=
SoftwareRelease
(
software_release
=
software_instance
.
getUrlString
(),
software_release
=
software_instance
.
getUrlString
()
.
decode
(
"UTF-8"
)
,
computer_guid
=
computer_id
)
slap_partition
.
_software_release_document
.
_software_release
=
\
slap_partition
.
_software_release_document
.
_software_release
.
decode
(
"UTF-8"
)
slap_partition
.
_need_modification
=
1
...
...
@@ -952,8 +956,12 @@ class SlapTool(BaseTool):
'created_at'
:
'%s'
%
rfc1123_date
(
DateTime
()),
"text"
:
"#error no data found for %s"
%
context_reference
}
# Prepare for xml marshalling
d
[
"user"
]
=
d
[
"user"
].
decode
(
"UTF-8"
)
d
[
"text"
]
=
d
[
"text"
].
decode
(
"UTF-8"
)
else
:
d
=
json
.
loads
(
d
)
# Keep in cache server for 7 days
self
.
REQUEST
.
response
.
setStatus
(
200
)
self
.
REQUEST
.
response
.
setHeader
(
'Cache-Control'
,
...
...
@@ -1298,7 +1306,9 @@ class SlapTool(BaseTool):
ip_list
=
[]
for
internet_protocol_address
in
computer_partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
):
ip_list
.
append
((
internet_protocol_address
.
getNetworkInterface
(
''
),
internet_protocol_address
.
getIpAddress
()))
ip_list
.
append
((
internet_protocol_address
.
getNetworkInterface
(
''
).
decode
(
"UTF-8"
),
internet_protocol_address
.
getIpAddress
().
decode
(
"UTF-8"
)))
slave_instance_list
=
[]
if
(
software_instance
.
getPortalType
()
==
"Software Instance"
):
...
...
@@ -1313,8 +1323,9 @@ class SlapTool(BaseTool):
# XXX Use catalog to filter more efficiently
if
slave_instance
.
getSlapState
()
==
"start_requested"
:
append
({
'slave_title'
:
slave_instance
.
getTitle
(),
'slap_software_type'
:
slave_instance
.
getSourceReference
(),
'slave_title'
:
slave_instance
.
getTitle
().
decode
(
"UTF-8"
),
'slap_software_type'
:
\
slave_instance
.
getSourceReference
().
decode
(
"UTF-8"
),
'slave_reference'
:
slave_instance
.
getReference
(),
'xml'
:
slave_instance
.
getTextContent
(),
'connection_xml'
:
slave_instance
.
getConnectionXml
(),
...
...
@@ -1326,10 +1337,14 @@ class SlapTool(BaseTool):
'instance_guid'
:
software_instance
.
getReference
(),
'xml'
:
software_instance
.
getTextContent
(),
'connection_xml'
:
software_instance
.
getConnectionXml
(),
'slap_computer_id'
:
computer_partition
.
getParentValue
().
getReference
(),
'slap_computer_partition_id'
:
computer_partition
.
getReference
(),
'slap_software_type'
:
software_instance
.
getSourceReference
(),
'slap_software_release_url'
:
software_instance
.
getUrlString
(),
'slap_computer_id'
:
\
computer_partition
.
getParentValue
().
getReference
().
decode
(
"UTF-8"
),
'slap_computer_partition_id'
:
\
computer_partition
.
getReference
().
decode
(
"UTF-8"
),
'slap_software_type'
:
\
software_instance
.
getSourceReference
().
decode
(
"UTF-8"
),
'slap_software_release_url'
:
\
software_instance
.
getUrlString
().
decode
(
"UTF-8"
),
'slave_instance_list'
:
slave_instance_list
,
'ip_list'
:
ip_list
,
'timestamp'
:
"%i"
%
timestamp
,
...
...
@@ -1348,8 +1363,10 @@ class SlapTool(BaseTool):
):
software_installation
=
_assertACI
(
software_installation
.
getObject
())
software_release_response
=
SoftwareRelease
(
software_release
=
software_installation
.
getUrlString
(),
computer_guid
=
computer_reference
)
software_release
=
software_installation
.
getUrlString
().
decode
(
'UTF-8'
),
computer_guid
=
computer_reference
.
decode
(
'UTF-8'
))
software_release_response
.
_software_release
=
\
software_release_response
.
_software_release
.
decode
(
"UTF-8"
)
if
software_installation
.
getSlapState
()
==
'destroy_requested'
:
software_release_response
.
_requested_state
=
'destroyed'
else
:
...
...
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