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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
e4681d73
Commit
e4681d73
authored
Feb 13, 2025
by
Rafael Monnerat
👻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: Fixup some py3 bytes x str inconsistencies
parent
51230a65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
20 deletions
+22
-20
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
...omponents/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
+8
-8
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
...onentTemplateItem/portal_components/tool.erp5.SlapTool.py
+14
-12
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
View file @
e4681d73
...
...
@@ -25,7 +25,7 @@ from erp5.component.test.testSlapOSCloudSecurityGroup import TestSlapOSSecurityM
from
erp5.component.test.SlapOSTestCaseMixin
import
changeSkin
import
re
from
slapos.util
import
dumps
,
loads
from
Products.ERP5Type.Utils
import
str2bytes
from
Products.ERP5Type.Utils
import
str2bytes
,
bytes2str
from
AccessControl.SecurityManagement
import
getSecurityManager
,
\
setSecurityManager
...
...
@@ -229,7 +229,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
try
:
self
.
login
(
compute_node
.
getUserId
())
self
.
portal
.
portal_slap
.
loadComputerConfigurationFromXML
(
dumps
(
compute_node_dict
))
bytes2str
(
dumps
(
compute_node_dict
)
))
self
.
tic
()
self
.
assertEqual
(
partition_count
,
len
(
compute_node
.
contentValues
(
portal_type
=
'Compute Partition'
)))
...
...
@@ -276,9 +276,9 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
if
partition
.
_requested_state
==
'destroyed'
\
and
partition
.
_need_modification
==
1
:
self
.
portal
.
portal_slap
.
destroyedComputerPartition
(
compute_node
.
getReference
(),
partition
.
_partition_id
.
encode
(
"UTF-8"
)
partition
.
_partition_id
)
destroyed_partition_id_list
.
append
(
partition
.
_partition_id
.
encode
(
"UTF-8"
)
)
destroyed_partition_id_list
.
append
(
partition
.
_partition_id
)
finally
:
setSecurityManager
(
sm
)
self
.
tic
()
...
...
@@ -306,10 +306,10 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
and
partition
.
_need_modification
==
1
:
instance_reference
=
partition
.
_instance_guid
.
encode
(
'UTF-8'
)
ip_list
=
partition
.
_parameter_dict
[
'ip_list'
]
connection_xml
=
dumps
(
dict
(
connection_xml
=
bytes2str
(
dumps
(
dict
(
url_1
=
'http://%s/'
%
ip_list
[
0
][
1
],
url_2
=
'http://%s/'
%
ip_list
[
1
][
1
],
))
))
)
self
.
login
()
instance_user_id
=
self
.
portal
.
portal_catalog
.
getResultValue
(
reference
=
instance_reference
,
portal_type
=
"Software Instance"
).
getUserId
()
...
...
@@ -324,10 +324,10 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
)
for
slave
in
partition
.
_parameter_dict
[
'slave_instance_list'
]:
slave_reference
=
slave
[
'slave_reference'
]
connection_xml
=
dumps
(
dict
(
connection_xml
=
bytes2str
(
dumps
(
dict
(
url_1
=
'http://%s/%s'
%
(
ip_list
[
0
][
1
],
slave_reference
),
url_2
=
'http://%s/%s'
%
(
ip_list
[
1
][
1
],
slave_reference
)
))
))
)
self
.
portal
.
portal_slap
.
setComputerPartitionConnectionXml
(
computer_id
=
compute_node_reference
,
computer_partition_id
=
partition
.
_partition_id
,
...
...
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
View file @
e4681d73
...
...
@@ -28,7 +28,7 @@
#
##############################################################################
from
Products.ERP5Type.Utils
import
str2unicode
from
Products.ERP5Type.Utils
import
str2unicode
,
bytes2str
,
str2bytes
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
Unauthorized
from
OFS.Traversable
import
NotFound
...
...
@@ -75,7 +75,7 @@ except ImportError:
from
zLOG
import
LOG
,
INFO
from
six
import
StringIO
import
six
import
pkg_resources
from
DateTime
import
DateTime
from
App.Common
import
rfc1123_date
...
...
@@ -112,13 +112,15 @@ def convertToREST(function):
raise
Unauthorized
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml; charset=utf-8'
)
if
isinstance
(
retval
,
bytes
):
return
'%s'
%
bytes2str
(
retval
)
return
'%s'
%
retval
wrapper
.
__doc__
=
function
.
__doc__
return
wrapper
def
castToStr
(
dict_kw
):
instance
=
etree
.
Element
(
'instance'
)
for
_id
,
_value
in
dict_kw
.
iteritems
(
):
for
_id
,
_value
in
six
.
iteritems
(
dict_kw
):
# cast everything to string.
text
=
_value
if
not
isinstance
(
_value
,
str
):
...
...
@@ -690,7 +692,7 @@ class SlapTool(BaseTool):
'loadComputerConfigurationFromXML'
)
def
loadComputerConfigurationFromXML
(
self
,
xml
):
"Load the given xml as configuration for the compute_node object"
compute_node_dict
=
loads
(
xml
)
compute_node_dict
=
loads
(
str2bytes
(
xml
)
)
compute_node
=
self
.
getPortalObject
().
portal_catalog
.
getComputeNodeObject
(
compute_node_dict
[
'reference'
])
compute_node
.
ComputeNode_updateFromDict
(
compute_node_dict
)
return
'Content properly posted.'
...
...
@@ -771,11 +773,11 @@ class SlapTool(BaseTool):
def
_validateXML
(
self
,
to_be_validated
,
xsd_model
):
"""Will validate the xml file"""
#We parse the XSD model
xsd_model
=
StringIO
(
xsd_model
)
xsd_model
=
six
.
StringIO
(
xsd_model
)
xmlschema_doc
=
etree
.
parse
(
xsd_model
)
xmlschema
=
etree
.
XMLSchema
(
xmlschema_doc
)
string_to_validate
=
StringIO
(
to_be_validated
)
string_to_validate
=
six
.
StringIO
(
to_be_validated
)
try
:
document
=
etree
.
parse
(
string_to_validate
)
...
...
@@ -927,7 +929,7 @@ class SlapTool(BaseTool):
compute_node_id
,
compute_partition_id
,
slave_reference
)
connection_xml
=
dict2xml
(
loads
(
connection_xml
))
connection_xml
=
dict2xml
(
loads
(
str2bytes
(
connection_xml
)
))
if
not
software_instance
.
isLastData
(
value
=
connection_xml
):
software_instance
.
updateConnection
(
connection_xml
=
connection_xml
,
...
...
@@ -952,19 +954,19 @@ class SlapTool(BaseTool):
In any other case returns not important data and HTTP code is 403 Forbidden
"""
if
state
:
state
=
loads
(
st
ate
)
state
=
loads
(
st
r2bytes
(
state
)
)
if
state
is
None
:
state
=
'started'
if
shared_xml
is
not
_MARKER
:
shared
=
loads
(
s
hared_xml
)
shared
=
loads
(
s
tr2bytes
(
shared_xml
)
)
else
:
shared
=
False
if
partition_parameter_xml
:
partition_parameter_kw
=
loads
(
partition_parameter_xml
)
partition_parameter_kw
=
loads
(
str2bytes
(
partition_parameter_xml
)
)
else
:
partition_parameter_kw
=
dict
()
if
filter_xml
:
filter_kw
=
loads
(
filter_xml
)
filter_kw
=
loads
(
str2bytes
(
filter_xml
)
)
if
software_type
==
'pull-backup'
and
not
'retention_delay'
in
filter_kw
:
filter_kw
[
'retention_delay'
]
=
7.0
else
:
...
...
@@ -1109,7 +1111,7 @@ class SlapTool(BaseTool):
slap_software_release
.
_known_state
=
software_release_dict
[
'_known_state'
]
slap_compute_node
.
_software_release_list
.
append
(
slap_software_release
)
return
dumps
(
slap_compute_node
)
return
bytes2str
(
dumps
(
slap_compute_node
)
)
def
_getSoftwareInstanceForComputePartition
(
self
,
compute_node_id
,
compute_partition_id
,
slave_reference
=
None
):
...
...
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