Merge "guestfs: With libguestfs >= v1.41.1 decode returned bytes to string" into stable/victoria
This commit is contained in:
commit
e954a56fec
|
@ -109,7 +109,7 @@ class GuestFS(object):
|
||||||
"mode": 0o700
|
"mode": 0o700
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.files[path]["content"]
|
return bytes(self.files[path]["content"].encode())
|
||||||
|
|
||||||
def write(self, path, content):
|
def write(self, path, content):
|
||||||
if path not in self.files:
|
if path not in self.files:
|
||||||
|
|
|
@ -615,8 +615,8 @@ def _set_passwd(username, admin_passwd, passwd_data, shadow_data):
|
||||||
|
|
||||||
:param username: the username
|
:param username: the username
|
||||||
:param admin_passwd: the admin password
|
:param admin_passwd: the admin password
|
||||||
:param passwd_data: path to the passwd file
|
:param passwd_data: Data from the passwd file decoded as a string
|
||||||
:param shadow_data: path to the shadow password file
|
:param shadow_data: Data from the shadow file decoded as a string
|
||||||
:returns: nothing
|
:returns: nothing
|
||||||
:raises: exception.NovaException(), IOError()
|
:raises: exception.NovaException(), IOError()
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,14 @@ class VFSGuestFS(vfs.VFS):
|
||||||
def read_file(self, path):
|
def read_file(self, path):
|
||||||
LOG.debug("Read file path=%s", path)
|
LOG.debug("Read file path=%s", path)
|
||||||
path = self._canonicalize_path(path)
|
path = self._canonicalize_path(path)
|
||||||
return self.handle.read_file(path)
|
data = self.handle.read_file(path)
|
||||||
|
# NOTE(lyarwood): libguestfs v1.41.1 (0ee02e0117527) switched the
|
||||||
|
# return type of read_file from string to bytes and as such we need to
|
||||||
|
# handle both here, decoding and returning a string if bytes is
|
||||||
|
# provided. https://bugzilla.redhat.com/show_bug.cgi?id=1661871
|
||||||
|
if isinstance(data, bytes):
|
||||||
|
return data.decode()
|
||||||
|
return data
|
||||||
|
|
||||||
def has_file(self, path):
|
def has_file(self, path):
|
||||||
LOG.debug("Has file path=%s", path)
|
LOG.debug("Has file path=%s", path)
|
||||||
|
|
Loading…
Reference in New Issue