From: Sage Weil Date: Fri, 25 Jun 2021 19:08:03 +0000 (-0400) Subject: qa/tasks/cephfs/test_nfs: fiddle with sudo X-Git-Tag: v17.1.0~1551^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8788af5663c52f54bede3076b52b8fda11b4c908;p=ceph.git qa/tasks/cephfs/test_nfs: fiddle with sudo - no sudo for 'ceph' commands - explicit sudo for _sys_cmd (things like 'rados' don't need sudo!) Signed-off-by: Sage Weil --- diff --git a/qa/tasks/cephfs/test_nfs.py b/qa/tasks/cephfs/test_nfs.py index 603774562752..bc52bdc3f22e 100644 --- a/qa/tasks/cephfs/test_nfs.py +++ b/qa/tasks/cephfs/test_nfs.py @@ -23,7 +23,6 @@ class TestNFS(MgrTestCase): return self._cmd("orch", *args) def _sys_cmd(self, cmd): - cmd[0:0] = ['sudo'] ret = self.ctx.cluster.run(args=cmd, check_status=False, stdout=BytesIO(), stderr=BytesIO()) stdout = ret[0].stdout if stdout: @@ -61,13 +60,13 @@ class TestNFS(MgrTestCase): } def _check_nfs_server_status(self): - res = self._sys_cmd(['systemctl', 'status', 'nfs-server']) + res = self._sys_cmd(['sudo', 'systemctl', 'status', 'nfs-server']) if isinstance(res, bytes) and b'Active: active' in res: self._disable_nfs() def _disable_nfs(self): log.info("Disabling NFS") - self._sys_cmd(['systemctl', 'disable', 'nfs-server', '--now']) + self._sys_cmd(['sudo', 'systemctl', 'disable', 'nfs-server', '--now']) def _fetch_nfs_status(self): return self._orch_cmd('ps', f'--service_name={self.expected_name}') @@ -502,7 +501,7 @@ class TestNFS(MgrTestCase): }} }}""" port, ip = self._get_port_ip_info() - self.ctx.cluster.run(args=['sudo', 'ceph', 'nfs', 'cluster', 'config', + self.ctx.cluster.run(args=['ceph', 'nfs', 'cluster', 'config', 'set', self.cluster_id, '-i', '-'], stdin=config) time.sleep(30) res = self._sys_cmd(['rados', '-p', pool, '-N', self.cluster_id, 'get', @@ -524,7 +523,7 @@ class TestNFS(MgrTestCase): ''' try: cluster_id = 'invalidtest' - self.ctx.cluster.run(args=['sudo', 'ceph', 'nfs', 'cluster', + self.ctx.cluster.run(args=['ceph', 'nfs', 'cluster', 'config', 'set', self.cluster_id, '-i', '-'], stdin='testing') self.fail(f"User config set for non-existing cluster {cluster_id}") except CommandFailedError as e: @@ -550,7 +549,7 @@ class TestNFS(MgrTestCase): Test creation of export via apply ''' self._test_create_cluster() - self.ctx.cluster.run(args=['sudo', 'ceph', 'nfs', 'export', 'apply', + self.ctx.cluster.run(args=['ceph', 'nfs', 'export', 'apply', self.cluster_id, '-i', '-'], stdin=json.dumps({ "path": "/", @@ -579,7 +578,7 @@ class TestNFS(MgrTestCase): new_pseudo_path = '/testing' export_block['pseudo'] = new_pseudo_path export_block['access_type'] = 'RO' - self.ctx.cluster.run(args=['sudo', 'ceph', 'nfs', 'export', 'apply', + self.ctx.cluster.run(args=['ceph', 'nfs', 'export', 'apply', self.cluster_id, '-i', '-'], stdin=json.dumps(export_block)) self._check_nfs_cluster_status('running', 'NFS Ganesha cluster restart failed') @@ -601,7 +600,7 @@ class TestNFS(MgrTestCase): else: export_block_new[key] = value try: - self.ctx.cluster.run(args=['sudo', 'ceph', 'nfs', 'export', 'apply', + self.ctx.cluster.run(args=['ceph', 'nfs', 'export', 'apply', self.cluster_id, '-i', '-'], stdin=json.dumps(export_block_new)) except CommandFailedError: