IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Proper handling to add tags

tags/0.92
parent
commit
1336e5a08c
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      zfs.py

+ 6
- 1
zfs.py View File

@@ -73,6 +73,10 @@ def zfs_snapshot_by_sha256(sha256):
def zfs_tag(name, tags): def zfs_tag(name, tags):
lst = zfs_parse_output(['zfs', 'list', '-o', 'focker:tags', '-H', name])
tags = list(tags)
tags.extend(lst[0][0].split(' '))
tags = list(set(tags))
if len(tags) > 0: if len(tags) > 0:
zfs_run(['zfs', 'set', 'focker:tags=' + ' '.join(tags), name]) zfs_run(['zfs', 'set', 'focker:tags=' + ' '.join(tags), name])
else: else:
@@ -85,7 +89,8 @@ def zfs_untag(tags):
for row in lst: for row in lst:
cur_tags = row[1].split(' ') cur_tags = row[1].split(' ')
for t in tags: for t in tags:
cur_tags.remove(t)
if t in cur_tags:
cur_tags.remove(t)
zfs_tag(row[0], cur_tags) zfs_tag(row[0], cur_tags)


Loading…
Cancel
Save