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

Added -f switch in focker jail prune

tags/0.92
parent
commit
ee2fcd0eb1
2 changed files with 6 additions and 3 deletions
  1. +2
    -0
      focker.py
  2. +4
    -3
      jail.py

+ 2
- 0
focker.py View File

@@ -65,6 +65,7 @@ def create_parser():
parser.add_argument('--tags', '-t', type=str, nargs='+', default=[]) parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
parser.add_argument('--env', '-e', type=str, nargs='+', default=[]) parser.add_argument('--env', '-e', type=str, nargs='+', default=[])
parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[]) parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[])
parser.add_argument('--hostname', '-n', type=str)
parser = subparsers.add_parser('run') parser = subparsers.add_parser('run')
parser.set_defaults(func=command_jail_run) parser.set_defaults(func=command_jail_run)
@@ -87,6 +88,7 @@ def create_parser():
parser = subparsers.add_parser('prune') parser = subparsers.add_parser('prune')
parser.set_defaults(func=command_jail_prune) parser.set_defaults(func=command_jail_prune)
parser.add_argument('--force', '-f', action='store_true')
# volume # volume
subparsers = subparsers_top.add_parser('volume').add_subparsers() subparsers = subparsers_top.add_parser('volume').add_subparsers()


+ 4
- 3
jail.py View File

@@ -17,7 +17,7 @@ def gen_env_command(command, env):
return command return command
def jail_create(path, command, env, mounts, hostname):
def jail_create(path, command, env, mounts, hostname=None):
name = os.path.split(path)[-1] name = os.path.split(path)[-1]
if os.path.exists('/etc/jail.conf'): if os.path.exists('/etc/jail.conf'):
conf = jailconf.load('/etc/jail.conf') conf = jailconf.load('/etc/jail.conf')
@@ -159,7 +159,8 @@ def command_jail_create(args):
{ a.split(':')[0]: ':'.join(a.split(':')[1:]) \ { a.split(':')[0]: ':'.join(a.split(':')[1:]) \
for a in args.env }, for a in args.env },
[ [a.split(':')[0], ':'.join(a.split(':')[1:])] \ [ [a.split(':')[0], ':'.join(a.split(':')[1:])] \
for a in args.mounts ] )
for a in args.mounts ],
args.hostname )
print(sha256) print(sha256)
print(path) print(path)
@@ -213,5 +214,5 @@ def command_jail_prune(args):
used.add(j['path']) used.add(j['path'])
lst = zfs_list(fields=['focker:sha256,focker:tags,mountpoint,name'], focker_type='jail') lst = zfs_list(fields=['focker:sha256,focker:tags,mountpoint,name'], focker_type='jail')
for j in lst: for j in lst:
if j[1] == '-' and j[2] not in used:
if j[1] == '-' and (j[2] not in used or args.force):
jail_remove(j[2]) jail_remove(j[2])

Loading…
Cancel
Save