@@ -135,18 +135,21 @@ def build_jails(spec): | |||||
zfs_untag([ jailname ], focker_type='jail') | zfs_untag([ jailname ], focker_type='jail') | ||||
zfs_tag(name, [ jailname ]) | zfs_tag(name, [ jailname ]) | ||||
path = zfs_mountpoint(name) | 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, | generated_names[jailname] = jail_create(path, | ||||
jailspec.get('exec.start', '/bin/sh /etc/rc'), | jailspec.get('exec.start', '/bin/sh /etc/rc'), | ||||
jailspec.get('env', {}), | jailspec.get('env', {}), | ||||
[ [from_, on] \ | [ [from_, on] \ | ||||
for (from_, on) in jailspec.get('mounts', {}).items() ], | for (from_, on) in jailspec.get('mounts', {}).items() ], | ||||
hostname=jailname, | 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) | setup_dependencies(spec, generated_names) | ||||
@@ -117,7 +117,9 @@ def jail_create(path, command, env, mounts, hostname=None, overrides={}): | |||||
blk['exec.clean'] = True | blk['exec.clean'] = True | ||||
blk['host.hostname'] = hostname or name | blk['host.hostname'] = hostname or name | ||||
for (k, v) in overrides.items(): | for (k, v) in overrides.items(): | ||||
blk[k] = quote(v) | |||||
blk[k] = quote(v) \ | |||||
if isinstance(v, str) \ | |||||
else v | |||||
jail_conf_write(conf) | jail_conf_write(conf) | ||||
return name | return name | ||||
@@ -226,7 +226,11 @@ def test_build_jails(): | |||||
'exec.stop': 'test-exec-stop', | 'exec.stop': 'test-exec-stop', | ||||
'ip4.addr': 'test-ip4-addr', | 'ip4.addr': 'test-ip4-addr', | ||||
'interface': 'test-interface', | '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() | 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['exec.stop'].strip('\'"') == 'test-exec-stop' | ||||
assert b['ip4.addr'].strip('\'"') == 'test-ip4-addr' | assert b['ip4.addr'].strip('\'"') == 'test-ip4-addr' | ||||
assert b['interface'].strip('\'"') == 'test-interface' | 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-A']) | ||||
subprocess.check_output(['focker', 'jail', 'remove', '--force', 'test-build-jails-B']) | subprocess.check_output(['focker', 'jail', 'remove', '--force', 'test-build-jails-B']) | ||||
subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-focker-bootstrap']) | subprocess.check_output(['focker', 'image', 'remove', '--force', 'test-focker-bootstrap']) | ||||