Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos-mynij-dev
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
Mynij
slapos-mynij-dev
Commits
3c01d90e
Commit
3c01d90e
authored
Dec 20, 2018
by
Łukasz Nowak
Committed by
Łukasz Nowak
Dec 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos: Encode unicode to UTF-8
/reviewed-on
nexedi/slapos!480
parent
faa89605
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
3 deletions
+10
-3
slapos/recipe/request.py
slapos/recipe/request.py
+5
-2
slapos/recipe/slapconfiguration.py
slapos/recipe/slapconfiguration.py
+2
-0
slapos/test/recipe/test_request.py
slapos/test/recipe/test_request.py
+1
-0
slapos/test/recipe/test_slaposconfiguration.py
slapos/test/recipe/test_slaposconfiguration.py
+2
-1
No files found.
slapos/recipe/request.py
View file @
3c01d90e
...
@@ -190,12 +190,15 @@ class Recipe(object):
...
@@ -190,12 +190,15 @@ class Recipe(object):
# Then try to get all the parameters. In case of problem, put empty string.
# Then try to get all the parameters. In case of problem, put empty string.
for
param
in
return_parameters
:
for
param
in
return_parameters
:
options
[
'connection-%s'
%
param
]
=
''
value
=
''
try
:
try
:
options
[
'connection-%s'
%
param
]
=
return_parameter_dict
[
param
]
value
=
return_parameter_dict
[
param
]
except
KeyError
:
except
KeyError
:
if
self
.
failed
is
None
:
if
self
.
failed
is
None
:
self
.
failed
=
param
self
.
failed
=
param
if
isinstance
(
value
,
unicode
):
value
=
value
.
encode
(
'UTF-8'
)
options
[
'connection-%s'
%
param
]
=
value
def
_filterForStorage
(
self
,
partition_parameter_kw
):
def
_filterForStorage
(
self
,
partition_parameter_kw
):
return
partition_parameter_kw
return
partition_parameter_kw
...
...
slapos/recipe/slapconfiguration.py
View file @
3c01d90e
...
@@ -264,6 +264,8 @@ class Recipe(object):
...
@@ -264,6 +264,8 @@ class Recipe(object):
# be very careful with overriding master's information
# be very careful with overriding master's information
for
key
,
value
in
flatten_dict
(
partition_params
).
items
():
for
key
,
value
in
flatten_dict
(
partition_params
).
items
():
if
key
not
in
options
:
if
key
not
in
options
:
if
isinstance
(
value
,
unicode
):
value
=
value
.
encode
(
'UTF-8'
)
options
[
key
]
=
value
options
[
key
]
=
value
# print out augmented options to see what we are passing
# print out augmented options to see what we are passing
logger
.
debug
(
str
(
options
))
logger
.
debug
(
str
(
options
))
...
...
slapos/test/recipe/test_request.py
View file @
3c01d90e
...
@@ -83,6 +83,7 @@ class RecipeTestMixin(object):
...
@@ -83,6 +83,7 @@ class RecipeTestMixin(object):
result
=
recipe
.
install
()
result
=
recipe
.
install
()
self
.
assertEqual
([],
result
)
self
.
assertEqual
([],
result
)
self
.
assertEqual
(
options
[
'connection-anything'
],
'done'
)
self
.
assertEqual
(
options
[
'connection-anything'
],
'done'
)
self
.
assertIsInstance
(
options
[
'connection-anything'
],
str
)
self
.
request_instance
.
assert_called_with
(
self
.
request_instance
.
assert_called_with
(
''
,
'RootSoftwareInstance'
,
''
,
filter_kw
=
{},
''
,
'RootSoftwareInstance'
,
''
,
filter_kw
=
{},
partition_parameter_kw
=
self
.
called_partition_parameter_kw
,
partition_parameter_kw
=
self
.
called_partition_parameter_kw
,
...
...
slapos/test/recipe/test_slaposconfiguration.py
View file @
3c01d90e
...
@@ -18,7 +18,7 @@ class SlapConfigurationTest(unittest.TestCase):
...
@@ -18,7 +18,7 @@ class SlapConfigurationTest(unittest.TestCase):
self
.
resource_file
=
os
.
path
.
join
(
self
.
instance_root
,
slapformat
.
Partition
.
resource_file
)
self
.
resource_file
=
os
.
path
.
join
(
self
.
instance_root
,
slapformat
.
Partition
.
resource_file
)
self
.
resource
=
{
self
.
resource
=
{
"tun"
:
{
"tun"
:
{
"ipv4"
:
"192.168.0.1"
"ipv4"
:
u
"192.168.0.1"
},
},
"address_list"
:
[
"address_list"
:
[
10
,
20
10
,
20
...
@@ -48,6 +48,7 @@ class SlapConfigurationTest(unittest.TestCase):
...
@@ -48,6 +48,7 @@ class SlapConfigurationTest(unittest.TestCase):
self
.
assertEqual
(
options
[
'tun-ipv4'
],
"192.168.0.1"
,
self
.
assertEqual
(
options
[
'tun-ipv4'
],
"192.168.0.1"
,
"Folded attrs should be separated by -"
)
"Folded attrs should be separated by -"
)
self
.
assertIsInstance
(
options
[
'tun-ipv4'
],
str
)
self
.
assertEqual
(
options
[
'address-list'
],
[
10
,
20
],
self
.
assertEqual
(
options
[
'address-list'
],
[
10
,
20
],
"All underscores should be replaced with -"
)
"All underscores should be replaced with -"
)
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