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!
Selaa lähdekoodia

Added ability to untag

tags/0.92
Stanislaw Adaszewski 4 vuotta sitten
vanhempi
commit
9554a7313a
3 muutettua tiedostoa jossa 16 lisäystä ja 6 poistoa
  1. +6
    -1
      focker.py
  2. +3
    -0
      image.py
  3. +7
    -5
      zfs.py

+ 6
- 1
focker.py Näytä tiedosto

@@ -2,7 +2,8 @@ from argparse import ArgumentParser
import yaml
import os
# from weir import zfs, process
from .image import command_image_build
from .image import command_image_build, \
command_image_untag
import sys
from .zfs import zfs_init
@@ -17,6 +18,10 @@ def create_parser():
parser.add_argument('focker_dir', type=str)
parser.add_argument('--tag', '-t', type=str, nargs='+', default=[])
parser = subparsers.add_parser('untag')
parser.set_defaults(func=command_image_untag)
parser.add_argument('tags', type=str, nargs='+', default=[])
return parser_top


+ 3
- 0
image.py Näytä tiedosto

@@ -70,3 +70,6 @@ def command_image_build(args):
image, image_sha256 = build(spec)
zfs_untag(args.tag)
zfs_tag(image.split('@')[0], args.tag)
def command_image_untag(args):
zfs_untag(args.tags)

+ 7
- 5
zfs.py Näytä tiedosto

@@ -72,11 +72,12 @@ def zfs_snapshot_by_sha256(sha256):
return lst[0][1]
def zfs_tag(name, tags):
def zfs_tag(name, tags, replace=False):
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 not replace:
tags = list(tags)
tags.extend(lst[0][0].split(' '))
tags = list(set(tags))
if len(tags) > 0:
zfs_run(['zfs', 'set', 'focker:tags=' + ' '.join(tags), name])
else:
@@ -84,6 +85,7 @@ def zfs_tag(name, tags):
def zfs_untag(tags):
# print('zfs_untag(), tags:', tags)
lst = zfs_parse_output(['zfs', 'list', '-o', 'name,focker:tags', '-H'])
lst = filter(lambda a: any([b in a[1].split(' ') for b in tags]), lst)
for row in lst:
@@ -91,7 +93,7 @@ def zfs_untag(tags):
for t in tags:
if t in cur_tags:
cur_tags.remove(t)
zfs_tag(row[0], cur_tags)
zfs_tag(row[0], cur_tags, replace=True)
def zfs_init():


Loading…
Peruuta
Tallenna