mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-07 11:50:21 +00:00
rewrite the config file more safely
use cli options for whatever we can use the config apis for the other thing this avoids clobbering configuration we don't know about - such as the storage=False setting (which made all nodes storage servers).
This commit is contained in:
parent
1d1653d361
commit
a8917d553c
@ -8,6 +8,12 @@ from twisted.internet.defer import Deferred
|
|||||||
from twisted.internet.protocol import ProcessProtocol
|
from twisted.internet.protocol import ProcessProtocol
|
||||||
from twisted.internet.error import ProcessExitedAlready, ProcessDone
|
from twisted.internet.error import ProcessExitedAlready, ProcessDone
|
||||||
|
|
||||||
|
from allmydata.util.configutil import (
|
||||||
|
get_config,
|
||||||
|
set_config,
|
||||||
|
write_config,
|
||||||
|
)
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@ -156,6 +162,10 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
|
|||||||
'--introducer', introducer_furl,
|
'--introducer', introducer_furl,
|
||||||
'--hostname', 'localhost',
|
'--hostname', 'localhost',
|
||||||
'--listen', 'tcp',
|
'--listen', 'tcp',
|
||||||
|
'--webport', web_port,
|
||||||
|
'--shares-needed', unicode(needed),
|
||||||
|
'--shares-happy', unicode(happy),
|
||||||
|
'--shares-total', unicode(total),
|
||||||
]
|
]
|
||||||
if not storage:
|
if not storage:
|
||||||
args.append('--no-storage')
|
args.append('--no-storage')
|
||||||
@ -169,30 +179,10 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
|
|||||||
created_d = done_proto.done
|
created_d = done_proto.done
|
||||||
|
|
||||||
def created(_):
|
def created(_):
|
||||||
with open(join(node_dir, 'tahoe.cfg'), 'w') as f:
|
config_path = join(node_dir, 'tahoe.cfg')
|
||||||
f.write('''
|
config = get_config(config_path)
|
||||||
[node]
|
set_config(config, 'node', 'log_gatherer.furl', flog_gatherer)
|
||||||
nickname = %(name)s
|
write_config(config_path, config)
|
||||||
web.port = %(web_port)s
|
|
||||||
web.static = public_html
|
|
||||||
log_gatherer.furl = %(log_furl)s
|
|
||||||
|
|
||||||
[client]
|
|
||||||
# Which services should this client connect to?
|
|
||||||
introducer.furl = %(furl)s
|
|
||||||
shares.needed = %(needed)d
|
|
||||||
shares.happy = %(happy)d
|
|
||||||
shares.total = %(total)d
|
|
||||||
|
|
||||||
''' % {
|
|
||||||
'name': name,
|
|
||||||
'furl': introducer_furl,
|
|
||||||
'web_port': web_port,
|
|
||||||
'log_furl': flog_gatherer,
|
|
||||||
'needed': needed,
|
|
||||||
'happy': happy,
|
|
||||||
'total': total,
|
|
||||||
})
|
|
||||||
created_d.addCallback(created)
|
created_d.addCallback(created)
|
||||||
else:
|
else:
|
||||||
created_d = defer.succeed(None)
|
created_d = defer.succeed(None)
|
||||||
@ -234,5 +224,3 @@ def await_file_vanishes(path, timeout=10):
|
|||||||
return
|
return
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
raise Exception("'{}' still exists after {}s".format(path, timeout))
|
raise Exception("'{}' still exists after {}s".format(path, timeout))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user