snapshot.py 文件源码

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

项目:esdc-ce 作者: erigones 项目源码 文件源码
def create_from_zfs_name(cls, zfs_name, status=OK, name=None, timestamp=None, **kwargs):
        """Create new snapshot from info gathered from compute node"""
        t, id = zfs_name.split('-', 1)
        t = t[0]

        if t == TT_EXEC:
            type = cls.MANUAL
        elif t == TT_AUTO:
            type = cls.AUTO
        else:
            raise AssertionError('Unknown snapshot type')

        if not name or name == '-':
            name = zfs_name

        snap = cls(id=int(id), name=name, type=type, status=status, **kwargs)

        if timestamp:
            snap.created = datetime.fromtimestamp(timestamp, timezone.utc)

        snap.save(force_insert=True)

        return snap
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号