@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])