summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-04-26 19:52:20 +0000
committerGerrit Code Review <review@openstack.org>2021-04-26 19:52:20 +0000
commit79707c6d074f8df6583520f8a9c20aab28cd76c0 (patch)
treec273629bf146fe3a9207de55a9a2b6819867e9ac
parentc12d07fe389079626542aa926cd9948c056109e7 (diff)
parente98935f705a931e3ae666820387a419be1622b64 (diff)
downloadnova-79707c6d074f8df6583520f8a9c20aab28cd76c0.tar.gz
Merge "guestfs: With libguestfs >= v1.41.1 decode returned bytes to string" into stable/wallaby
-rw-r--r--nova/tests/unit/virt/disk/vfs/fakeguestfs.py2
-rw-r--r--nova/virt/disk/api.py4
-rw-r--r--nova/virt/disk/vfs/guestfs.py9
3 files changed, 11 insertions, 4 deletions
diff --git a/nova/tests/unit/virt/disk/vfs/fakeguestfs.py b/nova/tests/unit/virt/disk/vfs/fakeguestfs.py
index 76304e1f15..01715a9f7b 100644
--- a/nova/tests/unit/virt/disk/vfs/fakeguestfs.py
+++ b/nova/tests/unit/virt/disk/vfs/fakeguestfs.py
@@ -109,7 +109,7 @@ class GuestFS(object):
"mode": 0o700
}
- return self.files[path]["content"]
+ return bytes(self.files[path]["content"].encode())
def write(self, path, content):
if path not in self.files:
diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py
index 79d629f283..9902c0608b 100644
--- a/nova/virt/disk/api.py
+++ b/nova/virt/disk/api.py
@@ -615,8 +615,8 @@ def _set_passwd(username, admin_passwd, passwd_data, shadow_data):
:param username: the username
:param admin_passwd: the admin password
- :param passwd_data: path to the passwd file
- :param shadow_data: path to the shadow password file
+ :param passwd_data: Data from the passwd file decoded as a string
+ :param shadow_data: Data from the shadow file decoded as a string
:returns: nothing
:raises: exception.NovaException(), IOError()
diff --git a/nova/virt/disk/vfs/guestfs.py b/nova/virt/disk/vfs/guestfs.py
index 90586ef8f1..861ad80746 100644
--- a/nova/virt/disk/vfs/guestfs.py
+++ b/nova/virt/disk/vfs/guestfs.py
@@ -306,7 +306,14 @@ class VFSGuestFS(vfs.VFS):
def read_file(self, path):
LOG.debug("Read file path=%s", 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):
LOG.debug("Has file path=%s", path)