RAPI client: fix Python 3 compatibility
RAPI client: fix Python 3 compatibility

Under Python 3, PycURL writes bytes to the write function, rather than
strings. This is currently broken because we allocate a StringIO buffer
that can't handle bytes. Rather than do version guesswork, we add a shim
class that behaves like a Reader and a Writer, but uses BytesIO or
StringIO under the hood based on the first write's type.

Note that this only matters for PycURL, simplejson has no problem
loading data from binary file-like objects.

This fixes #1421.

Signed-off-by: Apollon Oikonomopoulos <ed81ed0a45ccd5c8869bda52e38353a6299ee39e@dmesg.gr>

mbakke/ganeti,mbakke/ganeti,mbakke/ganeti,ganeti/ganeti,ganeti/ganeti,ganeti/ganeti