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
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
04324a26
Commit
04324a26
authored
Dec 10, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3: Use unicode2str
parent
b2db5730
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
37 deletions
+39
-37
master/bt5/slapos_cloud/DocumentTemplateItem/portal_components/document.erp5.SoftwareInstance.py
...eItem/portal_components/document.erp5.SoftwareInstance.py
+19
-19
master/bt5/slapos_cloud/MixinTemplateItem/portal_components/mixin.erp5.SlapOSComputeNodeMixin.py
...em/portal_components/mixin.erp5.SlapOSComputeNodeMixin.py
+8
-7
master/bt5/slapos_cloud/MixinTemplateItem/portal_components/mixin.erp5.SlapOSComputePartitionMixin.py
...rtal_components/mixin.erp5.SlapOSComputePartitionMixin.py
+4
-3
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
...ateItem/portal_components/test.erp5.testSlapOSSlapTool.py
+3
-3
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
...onentTemplateItem/portal_components/tool.erp5.SlapTool.py
+5
-5
No files found.
master/bt5/slapos_cloud/DocumentTemplateItem/portal_components/document.erp5.SoftwareInstance.py
View file @
04324a26
...
...
@@ -33,7 +33,7 @@ import collections
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
Products.ERP5Type.Utils
import
unicode2str
from
zLOG
import
LOG
,
INFO
try
:
...
...
@@ -198,14 +198,14 @@ class SoftwareInstance(Item):
for
internet_protocol_address
in
compute_partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
):
# XXX - There is new values, and we must keep compatibility
address_tuple
=
(
internet_protocol_address
.
getNetworkInterface
(
''
).
decode
(
"UTF-8"
),
internet_protocol_address
.
getIpAddress
().
decode
(
"UTF-8"
))
unicode2str
(
internet_protocol_address
.
getNetworkInterface
(
''
)
),
unicode2str
(
internet_protocol_address
.
getIpAddress
()
))
if
internet_protocol_address
.
getGatewayIpAddress
(
''
)
and
\
internet_protocol_address
.
getNetmask
(
''
):
address_tuple
=
address_tuple
+
(
internet_protocol_address
.
getGatewayIpAddress
().
decode
(
"UTF-8"
),
internet_protocol_address
.
getNetmask
().
decode
(
"UTF-8"
),
internet_protocol_address
.
getNetworkAddress
(
''
).
decode
(
"UTF-8"
))
unicode2str
(
internet_protocol_address
.
getGatewayIpAddress
()
),
unicode2str
(
internet_protocol_address
.
getNetmask
()
),
unicode2str
(
internet_protocol_address
.
getNetworkAddress
(
''
)
))
full_ip_list
.
append
(
address_tuple
)
else
:
ip_list
.
append
(
address_tuple
)
...
...
@@ -228,31 +228,31 @@ class SoftwareInstance(Item):
self
.
_getModificationDateAsTimestamp
(
shared_instance
)))
append
({
'slave_title'
:
shared_instance
.
getTitle
().
decode
(
"UTF-8"
),
'slave_title'
:
unicode2str
(
shared_instance
.
getTitle
()
),
'slap_software_type'
:
\
shared_instance
.
getSourceReference
().
decode
(
"UTF-8"
),
'slave_reference'
:
shared_instance
.
getReference
().
decode
(
"UTF-8"
),
unicode2str
(
shared_instance
.
getSourceReference
()
),
'slave_reference'
:
unicode2str
(
shared_instance
.
getReference
()
),
'timestamp'
:
shared_timestamp
,
'xml'
:
shared_instance
.
getTextContent
(),
'connection_xml'
:
shared_instance
.
getConnectionXml
(),
})
timestamp
=
max
(
timestamp
,
shared_timestamp
)
return
{
'instance_guid'
:
self
.
getReference
().
decode
(
"UTF-8"
),
'instance_title'
:
self
.
getTitle
().
decode
(
"UTF-8"
),
'root_instance_title'
:
instance_tree
.
getTitle
().
decode
(
"UTF-8"
),
'root_instance_short_title'
:
instance_tree
.
getShortTitle
().
decode
(
"UTF-8"
),
'instance_guid'
:
unicode2str
(
self
.
getReference
()
),
'instance_title'
:
unicode2str
(
self
.
getTitle
()
),
'root_instance_title'
:
unicode2str
(
instance_tree
.
getTitle
()
),
'root_instance_short_title'
:
unicode2str
(
instance_tree
.
getShortTitle
()
),
'xml'
:
self
.
getTextContent
(),
'connection_xml'
:
self
.
getConnectionXml
(),
'filter_xml'
:
self
.
getSlaXml
(),
'slap_computer_id'
:
\
compute_partition
.
getParentValue
().
getReference
().
decode
(
"UTF-8"
),
unicode2str
(
compute_partition
.
getParentValue
().
getReference
()
),
'slap_computer_partition_id'
:
\
compute_partition
.
getReference
().
decode
(
"UTF-8"
),
unicode2str
(
compute_partition
.
getReference
()
),
'slap_software_type'
:
\
self
.
getSourceReference
().
decode
(
"UTF-8"
),
unicode2str
(
self
.
getSourceReference
()
),
'slap_software_release_url'
:
\
self
.
getUrlString
().
decode
(
"UTF-8"
),
unicode2str
(
self
.
getUrlString
()
),
'slave_instance_list'
:
shared_instance_list
,
'ip_list'
:
ip_list
,
'full_ip_list'
:
full_ip_list
,
...
...
@@ -276,8 +276,8 @@ class SoftwareInstance(Item):
for
internet_protocol_address
in
compute_partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
):
ip_address_list
.
append
(
(
internet_protocol_address
.
getNetworkInterface
(
''
).
decode
(
"UTF-8"
),
internet_protocol_address
.
getIpAddress
().
decode
(
"UTF-8"
))
(
unicode2str
(
internet_protocol_address
.
getNetworkInterface
(
''
)
),
unicode2str
(
internet_protocol_address
.
getIpAddress
()
))
)
return
ip_address_list
...
...
master/bt5/slapos_cloud/MixinTemplateItem/portal_components/mixin.erp5.SlapOSComputeNodeMixin.py
View file @
04324a26
...
...
@@ -32,6 +32,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from
Products.ERP5Type.tests.utils
import
DummyMailHostMixin
from
OFS.Traversable
import
NotFound
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
Products.ERP5Type.Utils
import
unicode2str
import
time
from
lxml
import
etree
...
...
@@ -64,8 +65,8 @@ class SlapOSComputeNodeMixin(object):
):
software_installation
=
_assertACI
(
software_installation
.
getObject
())
software_release_dict
=
{
"software_release"
:
software_installation
.
getUrlString
().
decode
(
'UTF-8'
),
"computer_guid"
:
self
.
getReference
().
decode
(
'UTF-8'
)
"software_release"
:
unicode2str
(
software_installation
.
getUrlString
()
),
"computer_guid"
:
unicode2str
(
self
.
getReference
()
)
}
if
software_installation
.
getSlapState
()
==
'destroy_requested'
:
software_release_dict
[
"_requested_state"
]
=
'destroyed'
...
...
@@ -85,7 +86,7 @@ class SlapOSComputeNodeMixin(object):
def
_getCacheComputeNodeInformation
(
self
,
user
):
compute_node_dict
=
{
"_computer_id"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"_computer_id"
:
unicode2str
(
self
.
getReference
()
),
"_computer_partition_list"
:
[],
"_software_release_list"
:
self
.
_getSoftwareReleaseValueList
()
}
...
...
@@ -192,7 +193,7 @@ class SlapOSComputeNodeMixin(object):
return
self
.
_getCacheComputeNodeInformation
(
user
),
None
else
:
compute_node_dict
=
{
"_computer_id"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"_computer_id"
:
unicode2str
(
self
.
getReference
()
),
"_computer_partition_list"
:
[],
"_software_release_list"
:
[]
}
...
...
@@ -259,10 +260,10 @@ class SlapOSComputeNodeMixin(object):
compute_node
=
compute_partition_document
while
compute_node
.
getPortalType
()
!=
'Compute Node'
:
compute_node
=
compute_node
.
getParentValue
()
compute_node_id
=
compute_node
.
getReference
().
decode
(
"UTF-8"
)
compute_node_id
=
unicode2str
(
compute_node
.
getReference
()
)
partition_dict
=
{
"compute_node_id"
:
compute_node_id
,
"partition_id"
:
compute_partition_document
.
getReference
().
decode
(
"UTF-8"
),
"partition_id"
:
unicode2str
(
compute_partition_document
.
getReference
()
),
"_software_release_document"
:
None
,
"_requested_state"
:
'destroyed'
,
"_need_modification"
:
0
...
...
@@ -288,7 +289,7 @@ class SlapOSComputeNodeMixin(object):
partition_dict
[
'_access_status'
]
=
software_instance
.
getTextAccessStatus
()
partition_dict
[
'_software_release_document'
]
=
{
"software_release"
:
software_instance
.
getUrlString
().
decode
(
"UTF-8"
),
"software_release"
:
unicode2str
(
software_instance
.
getUrlString
()
),
"computer_guid"
:
compute_node_id
}
...
...
master/bt5/slapos_cloud/MixinTemplateItem/portal_components/mixin.erp5.SlapOSComputePartitionMixin.py
View file @
04324a26
...
...
@@ -28,6 +28,7 @@
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
zLOG
import
LOG
,
INFO
from
OFS.Traversable
import
NotFound
from
Products.ERP5Type.Utils
import
unicode2str
try
:
from
slapos.util
import
calculate_dict_hash
...
...
@@ -76,11 +77,11 @@ class SlapOSComputePartitionMixin(object):
compute_node
=
self
while
compute_node
.
getPortalType
()
!=
'Compute Node'
:
compute_node
=
compute_node
.
getParentValue
()
compute_node_id
=
compute_node
.
getReference
().
decode
(
"UTF-8"
)
compute_node_id
=
unicode2str
(
compute_node
.
getReference
()
)
partition_dict
=
{
"compute_node_id"
:
compute_node_id
,
"partition_id"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"partition_id"
:
unicode2str
(
self
.
getReference
()
),
"_software_release_document"
:
None
,
"_requested_state"
:
'destroyed'
,
"_need_modification"
:
0
...
...
@@ -110,7 +111,7 @@ class SlapOSComputePartitionMixin(object):
partition_dict
[
'_requested_state'
]
=
'started'
partition_dict
[
'_software_release_document'
]
=
{
"software_release"
:
software_instance
.
getUrlString
().
decode
(
"UTF-8"
),
"software_release"
:
unicode2str
(
software_instance
.
getUrlString
()
),
"computer_guid"
:
compute_node_id
}
partition_dict
[
'_access_status'
]
=
software_instance
.
getTextAccessStatus
()
...
...
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
View file @
04324a26
...
...
@@ -16,6 +16,7 @@ import hashlib
import
json
from
binascii
import
hexlify
from
OFS.Traversable
import
NotFound
from
Products.ERP5Type.Utils
import
unicode2str
def
hashData
(
data
):
...
...
@@ -42,11 +43,10 @@ class Simulator:
def
canonical_xml
(
xml
):
return
etree
.
tostring
(
return
unicode2str
(
etree
.
tostring
(
etree
.
fromstring
(
xml
),
method
=
"c14n"
,
).
decode
(
'utf-8'
)
))
class
TestSlapOSSlapToolMixin
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
...
...
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
View file @
04324a26
...
...
@@ -28,7 +28,7 @@
#
##############################################################################
from
Products.ERP5Type.Utils
import
unicode2str
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
Unauthorized
from
OFS.Traversable
import
NotFound
...
...
@@ -124,7 +124,7 @@ def castToStr(dict_kw):
if
not
isinstance
(
_value
,
str
):
text
=
str
(
_value
)
etree
.
SubElement
(
instance
,
"parameter"
,
attrib
=
{
'id'
:
_id
}).
text
=
text
.
decode
(
"utf-8"
)
attrib
=
{
'id'
:
_id
}).
text
=
unicode2str
(
text
)
return
etree
.
tostring
(
instance
,
pretty_print
=
True
,
xml_declaration
=
True
,
encoding
=
'utf-8'
)
...
...
@@ -522,7 +522,7 @@ class SlapTool(BaseTool):
portal
=
self
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
person
.
requestComputeNode
(
compute_node_title
=
compute_node_title
,
project_reference
=
project_reference
)
compute_node
=
ComputeNode
(
self
.
REQUEST
.
get
(
'compute_node_reference'
).
decode
(
"UTF-8"
))
compute_node
=
ComputeNode
(
unicode2str
(
self
.
REQUEST
.
get
(
'compute_node_reference'
)
))
return
dumps
(
compute_node
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
@@ -699,8 +699,8 @@ class SlapTool(BaseTool):
def
_generateComputerCertificate
(
self
,
compute_node_id
):
self
.
getPortalObject
().
portal_catalog
.
getComputeNodeObject
(
compute_node_id
).
generateCertificate
()
result
=
{
'certificate'
:
self
.
REQUEST
.
get
(
'compute_node_certificate'
).
decode
(
"UTF-8"
),
'key'
:
self
.
REQUEST
.
get
(
'compute_node_key'
).
decode
(
"UTF-8"
)
'certificate'
:
unicode2str
(
self
.
REQUEST
.
get
(
'compute_node_certificate'
)
),
'key'
:
unicode2str
(
self
.
REQUEST
.
get
(
'compute_node_key'
)
)
}
return
dumps
(
result
)
...
...
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