tahoe-lafs/src/allmydata/scripts/runner.py
robk-tahoe 5578559b85 added offloaded key generation
this adds a new service to pre-generate RSA key pairs.  This allows
the expensive (i.e. slow) key generation to be placed into a process
outside the node, so that the node's reactor will not block when it
needs a key pair, but instead can retrieve them from a pool of already
generated key pairs in the key-generator service.

it adds a tahoe create-key-generator command which initialises an 
empty dir with a tahoe-key-generator.tac file which can then be run
via twistd.  it stashes its .pem and portnum for furl stability and
writes the furl of the key gen service to key_generator.furl, also
printing it to stdout.

by placing a key_generator.furl file into the nodes config directory
(e.g. ~/.tahoe) a node will attempt to connect to such a service, and
will use that when creating mutable files (i.e. directories) whenever
possible.  if the keygen service is unavailable, it will perform the
key generation locally instead, as before.
2008-04-01 18:45:13 -07:00

79 lines
2.3 KiB
Python

import sys
from cStringIO import StringIO
from twisted.python import usage
from allmydata.scripts.common import BaseOptions
import debug, create_node, startstop_node, cli, keygen
_general_commands = ( create_node.subCommands
+ keygen.subCommands
+ debug.subCommands
+ cli.subCommands
)
class Options(BaseOptions, usage.Options):
synopsis = "Usage: tahoe <command> [command options]"
subCommands = []
subCommands += _general_commands
subCommands += startstop_node.subCommands
def postOptions(self):
if not hasattr(self, 'subOptions'):
raise usage.UsageError("must specify a command")
def runner(argv, run_by_human=True, stdout=sys.stdout, stderr=sys.stderr,
install_node_control=True, additional_commands=None):
config = Options()
if install_node_control:
config.subCommands.extend(startstop_node.subCommands)
ac_dispatch = {}
if additional_commands:
for ac in additional_commands:
config.subCommands.extend(ac.subCommands)
ac_dispatch.update(ac.dispatch)
try:
config.parseOptions(argv)
except usage.error, e:
if not run_by_human:
raise
print "%s: %s" % (sys.argv[0], e)
print
c = getattr(config, 'subOptions', config)
print str(c)
return 1
command = config.subCommand
so = config.subOptions
if config['quiet']:
stdout = StringIO()
rc = 0
if command in create_node.dispatch:
for basedir in so.basedirs:
f = create_node.dispatch[command]
rc = f(basedir, so, stdout, stderr) or rc
elif command in startstop_node.dispatch:
rc = startstop_node.dispatch[command](so, stdout, stderr)
elif command in debug.dispatch:
rc = debug.dispatch[command](so, stdout, stderr)
elif command in cli.dispatch:
rc = cli.dispatch[command](so, stdout, stderr)
elif command in keygen.dispatch:
rc = keygen.dispatch[command](so, stdout, stderr)
elif command in ac_dispatch:
rc = ac_dispatch[command](so, stdout, stderr)
else:
raise usage.UsageError()
return rc
def run(install_node_control=True):
rc = runner(sys.argv[1:])
sys.exit(rc)