slapos.slap: cast xml from unicode to string if it is unicode.

parent 2fad6ceb
...@@ -495,7 +495,11 @@ def forwardRequestToExternalMaster(master_url, request_form): ...@@ -495,7 +495,11 @@ def forwardRequestToExternalMaster(master_url, request_form):
filter_kw['source_instance_id'] = partition_reference filter_kw['source_instance_id'] = partition_reference
new_request_form['filter_xml'] = dumps(filter_kw) new_request_form['filter_xml'] = dumps(filter_kw)
partition = loads(slap._connection_helper.POST('/requestComputerPartition', data=new_request_form)) xml = slap._connection_helper.POST('/requestComputerPartition', data=new_request_form)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
partition = loads(xml)
# XXX move to other end # XXX move to other end
partition._master_url = master_url partition._master_url = master_url
......
...@@ -85,6 +85,9 @@ class SlapRequester(SlapDocument): ...@@ -85,6 +85,9 @@ class SlapRequester(SlapDocument):
request_dict=request_dict, request_dict=request_dict,
connection_helper=self._connection_helper, connection_helper=self._connection_helper,
) )
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
software_instance = xml_marshaller.loads(xml) software_instance = xml_marshaller.loads(xml)
computer_partition = ComputerPartition( computer_partition = ComputerPartition(
software_instance.slap_computer_id.encode('UTF-8'), software_instance.slap_computer_id.encode('UTF-8'),
...@@ -656,6 +659,9 @@ class ConnectionHelper: ...@@ -656,6 +659,9 @@ class ConnectionHelper:
# We should stablise slap library soon. # We should stablise slap library soon.
xml = self.GET('getComputerInformation', params=params) xml = self.GET('getComputerInformation', params=params)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
return xml_marshaller.loads(xml) return xml_marshaller.loads(xml)
def do_request(self, method, path, params=None, data=None, headers=None): def do_request(self, method, path, params=None, data=None, headers=None):
...@@ -794,6 +800,9 @@ class slap: ...@@ -794,6 +800,9 @@ class slap:
'computer_partition_reference': partition_id, 'computer_partition_reference': partition_id,
} }
) )
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
result = xml_marshaller.loads(xml) result = xml_marshaller.loads(xml)
# XXX: dirty hack to make computer partition usable. xml_marshaller is too # XXX: dirty hack to make computer partition usable. xml_marshaller is too
# low-level for our needs here. # low-level for our needs here.
...@@ -828,7 +837,11 @@ class slap: ...@@ -828,7 +837,11 @@ class slap:
'software_release_url parameters are specified.') 'software_release_url parameters are specified.')
params['software_release_url'] = software_release_url params['software_release_url'] = software_release_url
result = xml_marshaller.loads(self._connection_helper.GET(url, params=params)) xml = self._connection_helper.GET(url, params=params)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
result = xml_marshaller.loads(xml)
assert(type(result) == list) assert(type(result) == list)
return result return result
......
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