Fix issues with byte encoded strings
If byte encoded strings are passed to the ovirt SDK. We get the error outlined here: https://bugzilla.redhat.com/show_bug.cgi?id=1924928 This change leaves the string validation in place, but passes while raising a warning. Ultimately, non-encoded strings are provided to ovirt SDK to prevent the mentioned issue. Change-Id: I8e62a650ebae974017e17342ec17aa61ba67eed9
This commit is contained in:
parent
34f96a4a53
commit
0bb36230c7
|
@ -133,20 +133,20 @@ def _getvm(driver_info):
|
|||
password = driver_info['ovirt_password']
|
||||
insecure = driver_info['ovirt_insecure']
|
||||
ca_file = driver_info['ovirt_ca_file']
|
||||
name = str.encode(
|
||||
driver_info['ovirt_vm_name'], encoding='ascii', errors='ignore')
|
||||
name = driver_info['ovirt_vm_name']
|
||||
url = "https://%s/ovirt-engine/api" % address
|
||||
try:
|
||||
# pycurl.Curl.setopt doesn't support unicode strings,
|
||||
# attempt to turn `url` into an all-ASCII string;
|
||||
# in Python 3.x setopt accepts bytes as it should.
|
||||
url = str.encode(url, encoding='ascii', errors='strict')
|
||||
|
||||
except UnicodeEncodeError:
|
||||
LOG.warning("oVirt URL '%(url)s' contains non-ascii characters, "
|
||||
"that might cause pycurl to explode "
|
||||
"momentarily", {'url': url})
|
||||
for string in name, url:
|
||||
try:
|
||||
# pycurl.Curl.setopt doesn't support unicode strings,
|
||||
# attempt to turn variables into an all-ASCII string;
|
||||
# in Python 3.x setopt accepts bytes as it should.
|
||||
str.encode(string, encoding='ascii', errors='strict')
|
||||
|
||||
except UnicodeEncodeError:
|
||||
LOG.warning("oVirt SDK does not accept non-ascii "
|
||||
"characters. A non-ascii character has "
|
||||
"been provided for: {}".format(string))
|
||||
try:
|
||||
connection = sdk.Connection(url=url, username=username,
|
||||
password=password, insecure=insecure,
|
||||
|
|
Loading…
Reference in New Issue