From: Yuri Weinstein Date: Fri, 12 Mar 2021 17:05:07 +0000 (-0800) Subject: Merge pull request #39436 from rhcs-dashboard/wip-48654-octopus X-Git-Tag: v15.2.10~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b2ab238d4f074b84b61427ff16e47ad66ef501f8;p=ceph.git Merge pull request #39436 from rhcs-dashboard/wip-48654-octopus octopus: mgr/dashboard: CLI commands: read passwords from file Reviewed-by: Avan Thakkar Reviewed-by: Laura Paduano --- b2ab238d4f074b84b61427ff16e47ad66ef501f8 diff --cc qa/tasks/mgr/dashboard/helper.py index 7c491968259a,93d755937151..4c5cd8d72e72 --- a/qa/tasks/mgr/dashboard/helper.py +++ b/qa/tasks/mgr/dashboard/helper.py @@@ -429,9 -433,25 +432,25 @@@ class DashboardTestCase(MgrTestCase) @classmethod def _ceph_cmd_result(cls, cmd): exitstatus = cls.mgr_cluster.mon_manager.raw_cluster_cmd_result(*cmd) - log.info("command exit status: %d", exitstatus) + log.debug("command exit status: %d", exitstatus) return exitstatus + @classmethod + def _ceph_cmd_with_secret(cls, cmd: List[str], secret: str, return_exit_code: bool = False): + cmd.append('-i') + cmd.append('{}'.format(cls._ceph_create_tmp_file(secret))) + if return_exit_code: + return cls._ceph_cmd_result(cmd) + return cls._ceph_cmd(cmd) + + @classmethod + def _ceph_create_tmp_file(cls, content: str) -> str: + """Create a temporary file in the remote cluster""" + file_name = ''.join(random.choices(string.ascii_letters + string.digits, k=20)) + file_path = '/tmp/{}'.format(file_name) + cls._cmd(['sh', '-c', 'echo -n {} > {}'.format(content, file_path)]) + return file_path + def set_config_key(self, key, value): self._ceph_cmd(['config-key', 'set', key, value])