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!
浏览代码

Add jail.conf key in focker compose jail spec in order to pass parameters directly to jail.conf.

master
父节点
当前提交
6b9d3953d5
共有 3 个文件被更改,包括 19 次插入8 次删除
  1. +9
    -6
      focker/compose.py
  2. +3
    -1
      focker/jail.py
  3. +7
    -1
      tests/test_compose.py

+ 9
- 6
focker/compose.py 查看文件

@@ -135,18 +135,21 @@ def build_jails(spec):
zfs_untag([ jailname ], focker_type='jail')
zfs_tag(name, [ jailname ])
path = zfs_mountpoint(name)
overrides={
'exec.stop': jailspec.get('exec.stop', '/bin/sh /etc/rc.shutdown'),
'ip4.addr': jailspec.get('ip4.addr', '127.0.1.0'),
'interface': jailspec.get('interface', 'lo1'),
'host.hostname': jailspec.get('host.hostname', jailname)
}
if 'jail.conf' in jailspec:
overrides.update(jailspec['jail.conf'])
generated_names[jailname] = jail_create(path,
jailspec.get('exec.start', '/bin/sh /etc/rc'),
jailspec.get('env', {}),
[ [from_, on] \
for (from_, on) in jailspec.get('mounts', {}).items() ],
hostname=jailname,
overrides={
'exec.stop': jailspec.get('exec.stop', '/bin/sh /etc/rc.shutdown'),
'ip4.addr': jailspec.get('ip4.addr', '127.0.1.0'),
'interface': jailspec.get('interface', 'lo1'),
'host.hostname': jailspec.get('host.hostname', jailname)
})
overrides=overrides)
setup_dependencies(spec, generated_names)


+ 3
- 1
focker/jail.py 查看文件

@@ -117,7 +117,9 @@ def jail_create(path, command, env, mounts, hostname=None, overrides={}):
blk['exec.clean'] = True
blk['host.hostname'] = hostname or name
for (k, v) in overrides.items():
blk[k] = quote(v)
blk[k] = quote(v) \
if isinstance(v, str) \
else v
jail_conf_write(conf)
return name


+ 7
- 1
tests/test_compose.py 查看文件

@@ -226,7 +226,11 @@ def test_build_jails():
'exec.stop': 'test-exec-stop',
'ip4.addr': 'test-ip4-addr',
'interface': 'test-interface',
'host.hostname': 'test-build-jails-A'
'host.hostname': 'test-build-jails-A',
'jail.conf': {
'allow.mount': True,
'ip6.addr': 'abcd:abcd::0'
}
}
}
spec['test-build-jails-B'] = spec['test-build-jails-A'].copy()
@@ -247,6 +251,8 @@ def test_build_jails():
assert b['exec.stop'].strip('\'"') == 'test-exec-stop'
assert b['ip4.addr'].strip('\'"') == 'test-ip4-addr'
assert b['interface'].strip('\'"') == 'test-interface'
assert b['allow.mount']
assert b['ip6.addr'] == '\'abcd:abcd::0\''
subprocess.check_output(['focker', 'jail', 'remove', '--force', 'test-build-jails-A'])
subprocess.check_output(['focker', 'jail', 'remove', '--force', 'test-build-jails-B'])
subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-focker-bootstrap'])


正在加载...
取消
保存