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
评论列表
文章目录