utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:charm-swift-proxy 作者: openstack 项目源码 文件源码
def get_process_id_list(self, sentry_unit, process_name,
                            expect_success=True):
        """Get a list of process ID(s) from a single sentry juju unit
        for a single process name.

        :param sentry_unit: Amulet sentry instance (juju unit)
        :param process_name: Process name
        :param expect_success: If False, expect the PID to be missing,
            raise if it is present.
        :returns: List of process IDs
        """
        cmd = 'pidof -x "{}"'.format(process_name)
        if not expect_success:
            cmd += " || exit 0 && exit 1"
        output, code = sentry_unit.run(cmd)
        if code != 0:
            msg = ('{} `{}` returned {} '
                   '{}'.format(sentry_unit.info['unit_name'],
                               cmd, code, output))
            amulet.raise_status(amulet.FAIL, msg=msg)
        return str(output).split()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号