samba.py 文件源码

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

项目:charm-glusterfs 作者: openstack 项目源码 文件源码
def samba_config_changed() -> bool:
    """
    Checks whether a samba config file has changed or not.
    :param volume_name: str.
    :return: True or False
    """
    volume_name = config("volume_name")
    samba_path = os.path.join(os.sep, 'etc', 'samba', 'smb.conf')
    if os.path.exists(samba_path):
        # Lets check if the smb.conf matches what we're going to write.
        # If so then it was already setup and there's nothing to do
        with open(samba_path) as existing_config:
            old_config = existing_config.readlines()
            new_config = io.StringIO()
            render_samba_configuration(new_config, volume_name)
            if "".join(new_config) == "".join(old_config):
                # configs are identical
                return False
            else:
                return True
    # Config doesn't exist.
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号