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
Hide 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
...
@@ -33,7 +33,7 @@ import collections
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
Products.ERP5Type.Utils
import
unicode2str
from
zLOG
import
LOG
,
INFO
from
zLOG
import
LOG
,
INFO
try
:
try
:
...
@@ -198,14 +198,14 @@ class SoftwareInstance(Item):
...
@@ -198,14 +198,14 @@ class SoftwareInstance(Item):
for
internet_protocol_address
in
compute_partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
):
for
internet_protocol_address
in
compute_partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
):
# XXX - There is new values, and we must keep compatibility
# XXX - There is new values, and we must keep compatibility
address_tuple
=
(
address_tuple
=
(
internet_protocol_address
.
getNetworkInterface
(
''
).
decode
(
"UTF-8"
),
unicode2str
(
internet_protocol_address
.
getNetworkInterface
(
''
)
),
internet_protocol_address
.
getIpAddress
().
decode
(
"UTF-8"
))
unicode2str
(
internet_protocol_address
.
getIpAddress
()
))
if
internet_protocol_address
.
getGatewayIpAddress
(
''
)
and
\
if
internet_protocol_address
.
getGatewayIpAddress
(
''
)
and
\
internet_protocol_address
.
getNetmask
(
''
):
internet_protocol_address
.
getNetmask
(
''
):
address_tuple
=
address_tuple
+
(
address_tuple
=
address_tuple
+
(
internet_protocol_address
.
getGatewayIpAddress
().
decode
(
"UTF-8"
),
unicode2str
(
internet_protocol_address
.
getGatewayIpAddress
()
),
internet_protocol_address
.
getNetmask
().
decode
(
"UTF-8"
),
unicode2str
(
internet_protocol_address
.
getNetmask
()
),
internet_protocol_address
.
getNetworkAddress
(
''
).
decode
(
"UTF-8"
))
unicode2str
(
internet_protocol_address
.
getNetworkAddress
(
''
)
))
full_ip_list
.
append
(
address_tuple
)
full_ip_list
.
append
(
address_tuple
)
else
:
else
:
ip_list
.
append
(
address_tuple
)
ip_list
.
append
(
address_tuple
)
...
@@ -228,31 +228,31 @@ class SoftwareInstance(Item):
...
@@ -228,31 +228,31 @@ class SoftwareInstance(Item):
self
.
_getModificationDateAsTimestamp
(
shared_instance
)))
self
.
_getModificationDateAsTimestamp
(
shared_instance
)))
append
({
append
({
'slave_title'
:
shared_instance
.
getTitle
().
decode
(
"UTF-8"
),
'slave_title'
:
unicode2str
(
shared_instance
.
getTitle
()
),
'slap_software_type'
:
\
'slap_software_type'
:
\
shared_instance
.
getSourceReference
().
decode
(
"UTF-8"
),
unicode2str
(
shared_instance
.
getSourceReference
()
),
'slave_reference'
:
shared_instance
.
getReference
().
decode
(
"UTF-8"
),
'slave_reference'
:
unicode2str
(
shared_instance
.
getReference
()
),
'timestamp'
:
shared_timestamp
,
'timestamp'
:
shared_timestamp
,
'xml'
:
shared_instance
.
getTextContent
(),
'xml'
:
shared_instance
.
getTextContent
(),
'connection_xml'
:
shared_instance
.
getConnectionXml
(),
'connection_xml'
:
shared_instance
.
getConnectionXml
(),
})
})
timestamp
=
max
(
timestamp
,
shared_timestamp
)
timestamp
=
max
(
timestamp
,
shared_timestamp
)
return
{
return
{
'instance_guid'
:
self
.
getReference
().
decode
(
"UTF-8"
),
'instance_guid'
:
unicode2str
(
self
.
getReference
()
),
'instance_title'
:
self
.
getTitle
().
decode
(
"UTF-8"
),
'instance_title'
:
unicode2str
(
self
.
getTitle
()
),
'root_instance_title'
:
instance_tree
.
getTitle
().
decode
(
"UTF-8"
),
'root_instance_title'
:
unicode2str
(
instance_tree
.
getTitle
()
),
'root_instance_short_title'
:
instance_tree
.
getShortTitle
().
decode
(
"UTF-8"
),
'root_instance_short_title'
:
unicode2str
(
instance_tree
.
getShortTitle
()
),
'xml'
:
self
.
getTextContent
(),
'xml'
:
self
.
getTextContent
(),
'connection_xml'
:
self
.
getConnectionXml
(),
'connection_xml'
:
self
.
getConnectionXml
(),
'filter_xml'
:
self
.
getSlaXml
(),
'filter_xml'
:
self
.
getSlaXml
(),
'slap_computer_id'
:
\
'slap_computer_id'
:
\
compute_partition
.
getParentValue
().
getReference
().
decode
(
"UTF-8"
),
unicode2str
(
compute_partition
.
getParentValue
().
getReference
()
),
'slap_computer_partition_id'
:
\
'slap_computer_partition_id'
:
\
compute_partition
.
getReference
().
decode
(
"UTF-8"
),
unicode2str
(
compute_partition
.
getReference
()
),
'slap_software_type'
:
\
'slap_software_type'
:
\
self
.
getSourceReference
().
decode
(
"UTF-8"
),
unicode2str
(
self
.
getSourceReference
()
),
'slap_software_release_url'
:
\
'slap_software_release_url'
:
\
self
.
getUrlString
().
decode
(
"UTF-8"
),
unicode2str
(
self
.
getUrlString
()
),
'slave_instance_list'
:
shared_instance_list
,
'slave_instance_list'
:
shared_instance_list
,
'ip_list'
:
ip_list
,
'ip_list'
:
ip_list
,
'full_ip_list'
:
full_ip_list
,
'full_ip_list'
:
full_ip_list
,
...
@@ -276,8 +276,8 @@ class SoftwareInstance(Item):
...
@@ -276,8 +276,8 @@ class SoftwareInstance(Item):
for
internet_protocol_address
in
compute_partition
.
contentValues
(
for
internet_protocol_address
in
compute_partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
):
portal_type
=
'Internet Protocol Address'
):
ip_address_list
.
append
(
ip_address_list
.
append
(
(
internet_protocol_address
.
getNetworkInterface
(
''
).
decode
(
"UTF-8"
),
(
unicode2str
(
internet_protocol_address
.
getNetworkInterface
(
''
)
),
internet_protocol_address
.
getIpAddress
().
decode
(
"UTF-8"
))
unicode2str
(
internet_protocol_address
.
getIpAddress
()
))
)
)
return
ip_address_list
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
...
@@ -32,6 +32,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from
Products.ERP5Type.tests.utils
import
DummyMailHostMixin
from
Products.ERP5Type.tests.utils
import
DummyMailHostMixin
from
OFS.Traversable
import
NotFound
from
OFS.Traversable
import
NotFound
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
Products.ERP5Type.Utils
import
unicode2str
import
time
import
time
from
lxml
import
etree
from
lxml
import
etree
...
@@ -64,8 +65,8 @@ class SlapOSComputeNodeMixin(object):
...
@@ -64,8 +65,8 @@ class SlapOSComputeNodeMixin(object):
):
):
software_installation
=
_assertACI
(
software_installation
.
getObject
())
software_installation
=
_assertACI
(
software_installation
.
getObject
())
software_release_dict
=
{
software_release_dict
=
{
"software_release"
:
software_installation
.
getUrlString
().
decode
(
'UTF-8'
),
"software_release"
:
unicode2str
(
software_installation
.
getUrlString
()
),
"computer_guid"
:
self
.
getReference
().
decode
(
'UTF-8'
)
"computer_guid"
:
unicode2str
(
self
.
getReference
()
)
}
}
if
software_installation
.
getSlapState
()
==
'destroy_requested'
:
if
software_installation
.
getSlapState
()
==
'destroy_requested'
:
software_release_dict
[
"_requested_state"
]
=
'destroyed'
software_release_dict
[
"_requested_state"
]
=
'destroyed'
...
@@ -85,7 +86,7 @@ class SlapOSComputeNodeMixin(object):
...
@@ -85,7 +86,7 @@ class SlapOSComputeNodeMixin(object):
def
_getCacheComputeNodeInformation
(
self
,
user
):
def
_getCacheComputeNodeInformation
(
self
,
user
):
compute_node_dict
=
{
compute_node_dict
=
{
"_computer_id"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"_computer_id"
:
unicode2str
(
self
.
getReference
()
),
"_computer_partition_list"
:
[],
"_computer_partition_list"
:
[],
"_software_release_list"
:
self
.
_getSoftwareReleaseValueList
()
"_software_release_list"
:
self
.
_getSoftwareReleaseValueList
()
}
}
...
@@ -192,7 +193,7 @@ class SlapOSComputeNodeMixin(object):
...
@@ -192,7 +193,7 @@ class SlapOSComputeNodeMixin(object):
return
self
.
_getCacheComputeNodeInformation
(
user
),
None
return
self
.
_getCacheComputeNodeInformation
(
user
),
None
else
:
else
:
compute_node_dict
=
{
compute_node_dict
=
{
"_computer_id"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"_computer_id"
:
unicode2str
(
self
.
getReference
()
),
"_computer_partition_list"
:
[],
"_computer_partition_list"
:
[],
"_software_release_list"
:
[]
"_software_release_list"
:
[]
}
}
...
@@ -259,10 +260,10 @@ class SlapOSComputeNodeMixin(object):
...
@@ -259,10 +260,10 @@ class SlapOSComputeNodeMixin(object):
compute_node
=
compute_partition_document
compute_node
=
compute_partition_document
while
compute_node
.
getPortalType
()
!=
'Compute Node'
:
while
compute_node
.
getPortalType
()
!=
'Compute Node'
:
compute_node
=
compute_node
.
getParentValue
()
compute_node
=
compute_node
.
getParentValue
()
compute_node_id
=
compute_node
.
getReference
().
decode
(
"UTF-8"
)
compute_node_id
=
unicode2str
(
compute_node
.
getReference
()
)
partition_dict
=
{
partition_dict
=
{
"compute_node_id"
:
compute_node_id
,
"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
,
"_software_release_document"
:
None
,
"_requested_state"
:
'destroyed'
,
"_requested_state"
:
'destroyed'
,
"_need_modification"
:
0
"_need_modification"
:
0
...
@@ -288,7 +289,7 @@ class SlapOSComputeNodeMixin(object):
...
@@ -288,7 +289,7 @@ class SlapOSComputeNodeMixin(object):
partition_dict
[
'_access_status'
]
=
software_instance
.
getTextAccessStatus
()
partition_dict
[
'_access_status'
]
=
software_instance
.
getTextAccessStatus
()
partition_dict
[
'_software_release_document'
]
=
{
partition_dict
[
'_software_release_document'
]
=
{
"software_release"
:
software_instance
.
getUrlString
().
decode
(
"UTF-8"
),
"software_release"
:
unicode2str
(
software_instance
.
getUrlString
()
),
"computer_guid"
:
compute_node_id
"computer_guid"
:
compute_node_id
}
}
...
...
master/bt5/slapos_cloud/MixinTemplateItem/portal_components/mixin.erp5.SlapOSComputePartitionMixin.py
View file @
04324a26
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
erp5.component.module.SlapOSCloud
import
_assertACI
from
zLOG
import
LOG
,
INFO
from
zLOG
import
LOG
,
INFO
from
OFS.Traversable
import
NotFound
from
OFS.Traversable
import
NotFound
from
Products.ERP5Type.Utils
import
unicode2str
try
:
try
:
from
slapos.util
import
calculate_dict_hash
from
slapos.util
import
calculate_dict_hash
...
@@ -76,11 +77,11 @@ class SlapOSComputePartitionMixin(object):
...
@@ -76,11 +77,11 @@ class SlapOSComputePartitionMixin(object):
compute_node
=
self
compute_node
=
self
while
compute_node
.
getPortalType
()
!=
'Compute Node'
:
while
compute_node
.
getPortalType
()
!=
'Compute Node'
:
compute_node
=
compute_node
.
getParentValue
()
compute_node
=
compute_node
.
getParentValue
()
compute_node_id
=
compute_node
.
getReference
().
decode
(
"UTF-8"
)
compute_node_id
=
unicode2str
(
compute_node
.
getReference
()
)
partition_dict
=
{
partition_dict
=
{
"compute_node_id"
:
compute_node_id
,
"compute_node_id"
:
compute_node_id
,
"partition_id"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"partition_id"
:
unicode2str
(
self
.
getReference
()
),
"_software_release_document"
:
None
,
"_software_release_document"
:
None
,
"_requested_state"
:
'destroyed'
,
"_requested_state"
:
'destroyed'
,
"_need_modification"
:
0
"_need_modification"
:
0
...
@@ -110,7 +111,7 @@ class SlapOSComputePartitionMixin(object):
...
@@ -110,7 +111,7 @@ class SlapOSComputePartitionMixin(object):
partition_dict
[
'_requested_state'
]
=
'started'
partition_dict
[
'_requested_state'
]
=
'started'
partition_dict
[
'_software_release_document'
]
=
{
partition_dict
[
'_software_release_document'
]
=
{
"software_release"
:
software_instance
.
getUrlString
().
decode
(
"UTF-8"
),
"software_release"
:
unicode2str
(
software_instance
.
getUrlString
()
),
"computer_guid"
:
compute_node_id
"computer_guid"
:
compute_node_id
}
}
partition_dict
[
'_access_status'
]
=
software_instance
.
getTextAccessStatus
()
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
...
@@ -16,6 +16,7 @@ import hashlib
import
json
import
json
from
binascii
import
hexlify
from
binascii
import
hexlify
from
OFS.Traversable
import
NotFound
from
OFS.Traversable
import
NotFound
from
Products.ERP5Type.Utils
import
unicode2str
def
hashData
(
data
):
def
hashData
(
data
):
...
@@ -42,11 +43,10 @@ class Simulator:
...
@@ -42,11 +43,10 @@ class Simulator:
def
canonical_xml
(
xml
):
def
canonical_xml
(
xml
):
return
etree
.
tostring
(
return
unicode2str
(
etree
.
tostring
(
etree
.
fromstring
(
xml
),
etree
.
fromstring
(
xml
),
method
=
"c14n"
,
method
=
"c14n"
,
).
decode
(
'utf-8'
)
))
class
TestSlapOSSlapToolMixin
(
SlapOSTestCaseMixin
):
class
TestSlapOSSlapToolMixin
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
...
...
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
View file @
04324a26
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#
#
##############################################################################
##############################################################################
from
Products.ERP5Type.Utils
import
unicode2str
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
from
OFS.Traversable
import
NotFound
from
OFS.Traversable
import
NotFound
...
@@ -124,7 +124,7 @@ def castToStr(dict_kw):
...
@@ -124,7 +124,7 @@ def castToStr(dict_kw):
if
not
isinstance
(
_value
,
str
):
if
not
isinstance
(
_value
,
str
):
text
=
str
(
_value
)
text
=
str
(
_value
)
etree
.
SubElement
(
instance
,
"parameter"
,
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
,
return
etree
.
tostring
(
instance
,
pretty_print
=
True
,
xml_declaration
=
True
,
encoding
=
'utf-8'
)
xml_declaration
=
True
,
encoding
=
'utf-8'
)
...
@@ -522,7 +522,7 @@ class SlapTool(BaseTool):
...
@@ -522,7 +522,7 @@ class SlapTool(BaseTool):
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
person
.
requestComputeNode
(
compute_node_title
=
compute_node_title
,
project_reference
=
project_reference
)
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
)
return
dumps
(
compute_node
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
@@ -699,8 +699,8 @@ class SlapTool(BaseTool):
...
@@ -699,8 +699,8 @@ class SlapTool(BaseTool):
def
_generateComputerCertificate
(
self
,
compute_node_id
):
def
_generateComputerCertificate
(
self
,
compute_node_id
):
self
.
getPortalObject
().
portal_catalog
.
getComputeNodeObject
(
compute_node_id
).
generateCertificate
()
self
.
getPortalObject
().
portal_catalog
.
getComputeNodeObject
(
compute_node_id
).
generateCertificate
()
result
=
{
result
=
{
'certificate'
:
self
.
REQUEST
.
get
(
'compute_node_certificate'
).
decode
(
"UTF-8"
),
'certificate'
:
unicode2str
(
self
.
REQUEST
.
get
(
'compute_node_certificate'
)
),
'key'
:
self
.
REQUEST
.
get
(
'compute_node_key'
).
decode
(
"UTF-8"
)
'key'
:
unicode2str
(
self
.
REQUEST
.
get
(
'compute_node_key'
)
)
}
}
return
dumps
(
result
)
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