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
Boxiang Sun
slapos.core
Commits
b29a79a6
Commit
b29a79a6
authored
Sep 18, 2019
by
Łukasz Nowak
Committed by
Łukasz Nowak
Oct 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos/master: Use methods from slapos.util
/reviewed-on
nexedi/slapos.core!132
parent
973a0724
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
17 deletions
+11
-17
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
...ateItem/portal_components/test.erp5.testSlapOSSlapTool.py
+4
-4
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+7
-13
No files found.
master/bt5/slapos_slap_tool/TestTemplateItem/portal_components/test.erp5.testSlapOSSlapTool.py
View file @
b29a79a6
...
...
@@ -1247,7 +1247,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<list id='i9'>
<dictionary id='i10'>
<string>connection-parameter-hash</string>
<string>4
4136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
</string>
<string>4
f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945
</string>
<string>paramé</string>
<string>%(slave_1_param)s</string>
<string>slap_software_type</string>
...
...
@@ -1445,8 +1445,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal>"""
stored_xml
=
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="p2é">v2é</parameter>
<parameter id="p1é">v1é</parameter>
<parameter id="p2é">v2é</parameter>
</instance>
"""
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
...
...
@@ -1478,8 +1478,8 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal>"""
stored_xml
=
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="p2é">v2é</parameter>
<parameter id="p1é">v1é</parameter>
<parameter id="p2é">v2é</parameter>
</instance>
"""
self
.
login
(
self
.
start_requested_software_instance
.
getUserId
())
...
...
@@ -2390,7 +2390,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
<list id='i9'>
<dictionary id='i10'>
<string>connection-parameter-hash</string>
<string>4
4136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
</string>
<string>4
f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945
</string>
<string>paramé</string>
<string>%(slave_1_param)s</string>
<string>slap_software_type</string>
...
...
master/product/Vifib/Tool/SlapTool.py
View file @
b29a79a6
...
...
@@ -41,7 +41,6 @@ from Products.ERP5Type import Permissions
from
Products.ERP5Type.Cache
import
DEFAULT_CACHE_SCOPE
from
Products.ERP5Type.Cache
import
CachingMethod
from
lxml
import
etree
import
hashlib
import
time
from
Products.ERP5Type.tests.utils
import
DummyMailHostMixin
try
:
...
...
@@ -50,7 +49,7 @@ try:
ComputerPartition
as
SlapComputerPartition
,
SoftwareInstance
,
SoftwareRelease
)
from
slapos.
proxy.views
import
dict2xml
from
slapos.
util
import
dict2xml
,
xml2dict
,
calculate_dict_hash
except
ImportError
:
# Do no prevent instance from starting
# if libs are not installed
...
...
@@ -68,6 +67,10 @@ except ImportError:
raise
ImportError
def
dict2xml
(
dictionary
):
raise
ImportError
def
xml2dict
(
dictionary
):
raise
ImportError
def
calculate_dict_hash
(
dictionary
):
raise
ImportError
from
zLOG
import
LOG
,
INFO
import
xml_marshaller
...
...
@@ -833,7 +836,7 @@ class SlapTool(BaseTool):
slave_instance_dict
.
pop
(
"connection_xml"
))
slave_instance_dict
.
update
(
connection_dict
)
slave_instance_dict
[
'connection-parameter-hash'
]
=
\
hashlib
.
sha256
(
str
(
connection_dict
)).
hexdigest
(
)
calculate_dict_hash
(
connection_dict
)
if
slave_instance_dict
.
has_key
(
"xml"
):
slave_instance_dict
.
update
(
self
.
_instanceXmlToDict
(
slave_instance_dict
.
pop
(
"xml"
)))
...
...
@@ -896,16 +899,7 @@ class SlapTool(BaseTool):
def
_instanceXmlToDict
(
self
,
xml
):
result_dict
=
{}
try
:
if
xml
is
not
None
and
xml
!=
''
:
tree
=
etree
.
fromstring
(
xml
)
for
element
in
tree
.
findall
(
'parameter'
):
key
=
element
.
get
(
'id'
)
value
=
result_dict
.
get
(
key
,
None
)
if
value
is
not
None
:
value
=
value
+
' '
+
element
.
text
else
:
value
=
element
.
text
result_dict
[
key
]
=
value
result_dict
=
xml2dict
(
xml
)
except
(
etree
.
XMLSchemaError
,
etree
.
XMLSchemaParseError
,
etree
.
XMLSchemaValidateError
,
etree
.
XMLSyntaxError
):
LOG
(
'SlapTool'
,
INFO
,
'Issue during parsing xml:'
,
error
=
True
)
...
...
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