Fixed zfs_get_snapshots hang when filesystems is an empty list
This commit is contained in:
@ -164,26 +164,27 @@ return[filesystem_name]=[ "snashot1", "snapshot2", ... ]
|
|||||||
"""
|
"""
|
||||||
def zfs_get_snapshots(ssh_to, filesystems, backup_name):
|
def zfs_get_snapshots(ssh_to, filesystems, backup_name):
|
||||||
|
|
||||||
snapshots=run(ssh_to=ssh_to, input="\0".join(filesystems), valid_exitcodes=[ 0,1 ], cmd=
|
if filesystems:
|
||||||
[ "xargs", "-0", "-n", "1", "zfs", "list", "-d", "1", "-r", "-t" ,"snapshot", "-H", "-o", "name" ]
|
snapshots=run(ssh_to=ssh_to, input="\0".join(filesystems), valid_exitcodes=[ 0,1 ], cmd=
|
||||||
)
|
[ "xargs", "-0", "-n", "1", "zfs", "list", "-d", "1", "-r", "-t" ,"snapshot", "-H", "-o", "name" ]
|
||||||
|
)
|
||||||
|
|
||||||
ret={}
|
ret={}
|
||||||
for snapshot in snapshots:
|
for snapshot in snapshots:
|
||||||
(filesystem, snapshot_name)=snapshot.split("@")
|
(filesystem, snapshot_name)=snapshot.split("@")
|
||||||
if re.match("^"+backup_name+"-[0-9]*$", snapshot_name):
|
if re.match("^"+backup_name+"-[0-9]*$", snapshot_name):
|
||||||
if not filesystem in ret:
|
if not filesystem in ret:
|
||||||
ret[filesystem]=[]
|
ret[filesystem]=[]
|
||||||
ret[filesystem].append(snapshot_name)
|
ret[filesystem].append(snapshot_name)
|
||||||
|
|
||||||
#also add any test-snapshots that where created with --test mode
|
#also add any test-snapshots that where created with --test mode
|
||||||
if args.test:
|
if args.test:
|
||||||
if ssh_to in test_snapshots:
|
if ssh_to in test_snapshots:
|
||||||
for filesystem in filesystems:
|
for filesystem in filesystems:
|
||||||
if filesystem in test_snapshots[ssh_to]:
|
if filesystem in test_snapshots[ssh_to]:
|
||||||
if not filesystem in ret:
|
if not filesystem in ret:
|
||||||
ret[filesystem]=[]
|
ret[filesystem]=[]
|
||||||
ret[filesystem].extend(test_snapshots[ssh_to][filesystem])
|
ret[filesystem].extend(test_snapshots[ssh_to][filesystem])
|
||||||
|
|
||||||
return(ret)
|
return(ret)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user