HomeClusterLabs Projects

Convert URLs passed to pycurl to ASCII

Description

Convert URLs passed to pycurl to ASCII

The 'fence_rhevm' agent uses pycurl to interact with the oVirt API, and
it builds the URLs using string concatenation. For example, to build the
URL used to start a virtual machine it does the following:

url = "vms/" + options["id"] + "/" + action

This 'id' is extracted from the XML returned by the server, which may be
a plain 'str' or an 'unicode' object, depending on the version of pycurl
used. If it is an unicode object then resulting string will also be an
unicode object. When this unicode object is passed to pycurl it fails,
with the following traceback:

Traceback (most recent call last):
  ...
  File "/usr/sbin/fence_rhevm", line 106, in send_command
    conn.setopt(pycurl.URL, url)
TypeError: invalid arguments to setopt

The same happens with other agents. To avoid that this patch changes all
those agents so that they always encode the URL using ASCII before
passing it to pycurl.

Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com>

Event Timeline