Commit 3c01d90e authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

slapos: Encode unicode to UTF-8

/reviewed-on !480
parent faa89605
......@@ -190,12 +190,15 @@ class Recipe(object):
# Then try to get all the parameters. In case of problem, put empty string.
for param in return_parameters:
options['connection-%s' % param] = ''
value = ''
try:
options['connection-%s' % param] = return_parameter_dict[param]
value = return_parameter_dict[param]
except KeyError:
if self.failed is None:
self.failed = param
if isinstance(value, unicode):
value = value.encode('UTF-8')
options['connection-%s' % param] = value
def _filterForStorage(self, partition_parameter_kw):
return partition_parameter_kw
......
......@@ -264,6 +264,8 @@ class Recipe(object):
# be very careful with overriding master's information
for key, value in flatten_dict(partition_params).items():
if key not in options:
if isinstance(value, unicode):
value = value.encode('UTF-8')
options[key] = value
# print out augmented options to see what we are passing
logger.debug(str(options))
......
......@@ -83,6 +83,7 @@ class RecipeTestMixin(object):
result = recipe.install()
self.assertEqual([], result)
self.assertEqual(options['connection-anything'], 'done')
self.assertIsInstance(options['connection-anything'], str)
self.request_instance.assert_called_with(
'', 'RootSoftwareInstance', '', filter_kw={},
partition_parameter_kw=self.called_partition_parameter_kw,
......
......@@ -18,7 +18,7 @@ class SlapConfigurationTest(unittest.TestCase):
self.resource_file = os.path.join(self.instance_root, slapformat.Partition.resource_file)
self.resource = {
"tun": {
"ipv4": "192.168.0.1"
"ipv4": u"192.168.0.1"
},
"address_list": [
10, 20
......@@ -48,6 +48,7 @@ class SlapConfigurationTest(unittest.TestCase):
self.assertEqual(options['tun-ipv4'], "192.168.0.1",
"Folded attrs should be separated by -")
self.assertIsInstance(options['tun-ipv4'], str)
self.assertEqual(options['address-list'], [10, 20],
"All underscores should be replaced with -")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment