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!
Explorar el Código

Add support for depend.

master
Stanislaw Adaszewski hace 4 años
padre
commit
40b8c450bd
Se han modificado 2 ficheros con 33 adiciones y 7 borrados
  1. +3
    -1
      example/gateway/focker-compose.yml
  2. +30
    -6
      focker/compose.py

+ 3
- 1
example/gateway/focker-compose.yml Ver fichero

@@ -46,7 +46,9 @@ jails:
nginx-https:
image: nginx-https
depend: certbot
depend:
- certbot
- nginx-http
mounts:
certbot-data: /usr/local/etc/letsencrypt
exec.start: |


+ 30
- 6
focker/compose.py Ver fichero

@@ -17,7 +17,8 @@ from .zfs import AmbiguousValueError, \
from .jail import jail_fs_create, \
jail_create, \
jail_remove, \
backup_file
backup_file, \
quote
from .misc import random_sha256_hexdigest, \
find_prefix
import subprocess
@@ -25,6 +26,7 @@ import jailconf
import os
from .misc import focker_lock, \
focker_unlock
import pdb
def exec_prebuild(spec, path):
@@ -81,12 +83,31 @@ def build_images(spec, path, args):
raise RuntimeError('Image build failed: ' + str(res.returncode))
def setup_dependencies(spec, generated_names):
if os.path.exists('/etc/jail.conf'):
conf = jailconf.load('/etc/jail.conf')
else:
conf = jailconf.JailConf()
for (jailname, jailspec) in spec.items():
if 'depend' not in jailspec:
continue
depend = jailspec.get('depend', [])
if isinstance(depend, str):
depend = [ depend ]
if not isinstance(depend, list):
raise ValueError('depend must be a string or a list of strings')
# pdb.set_trace()
depend = list(map(lambda a: generated_names[a], depend))
if len(depend) == 1:
depend = depend[0]
conf[generated_names[jailname]]['depend'] = \
depend
conf.write('/etc/jail.conf')
def build_jails(spec):
#if os.path.exists('/etc/jail.conf'):
# conf = jailconf.load('/etc/jail.conf')
#else:
# conf = jailconf.JailConf()
backup_file('/etc/jail.conf')
generated_names = {}
for (jailname, jailspec) in spec.items():
try:
name, _ = zfs_find(jailname, focker_type='jail')
@@ -99,7 +120,8 @@ def build_jails(spec):
zfs_untag([ jailname ], focker_type='jail')
zfs_tag(name, [ jailname ])
path = zfs_mountpoint(name)
jail_create(path,
generated_names[jailname] = \
jail_create(path,
jailspec.get('exec.start', '/bin/sh /etc/rc'),
jailspec.get('env', {}),
[ [from_, on] \
@@ -111,6 +133,8 @@ def build_jails(spec):
'interface': jailspec.get('interface', 'lo1')
})
setup_dependencies(spec, generated_names)
def command_compose_build(args):
if not os.path.exists(args.filename):


Cargando…
Cancelar
Guardar