From a2f21e25e8796311f395a1e83bac3e3a5769c038 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Fri, 10 Jul 2020 09:17:43 -0400 Subject: [PATCH] Update NFS helper restart Because ``service`` commands are deprecated in favor of ``systemctl` commands, the check to see if the service command succeeds in the NFS helper used by e.g. the lvm and generic back ends fails. The string sought to indicate an error is never present. Update the helper to use ``systemctl`` commands instead and error check for them correctly. Closes-bug: #1887695 Change-Id: Ibb1c15f997fa60e1ba5bfb7437502d8aa454d35f (cherry picked from commit 391ec7dffa701f54843b3aafdc6d2f8b4dfe0504) (cherry picked from commit eb0de241b395fdc309d3b13b1adac464316f3f10) (cherry picked from commit 0a3125439627da84bddfdf075b833f998f1935a7) --- manila/share/drivers/helpers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manila/share/drivers/helpers.py b/manila/share/drivers/helpers.py index e0ecf36614..84cc2a39be 100644 --- a/manila/share/drivers/helpers.py +++ b/manila/share/drivers/helpers.py @@ -344,11 +344,12 @@ class NFSHelper(NASHelperBase): self._ssh_exec(server, sync_cmd) self._ssh_exec(server, ['sudo', 'exportfs', '-a']) out, _ = self._ssh_exec( - server, ['sudo', 'service', 'nfs-kernel-server', 'status'], + server, + ['sudo', 'systemctl', 'is-active', 'nfs-kernel-server'], check_exit_code=False) - if "not" in out: + if "inactive" in out: self._ssh_exec( - server, ['sudo', 'service', 'nfs-kernel-server', 'restart']) + server, ['sudo', 'systemctl', 'restart', 'nfs-kernel-server']) def _get_export_location_template(self, export_location_or_path): path = export_location_or_path.split(':')[-1]