Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix create_node and start_stop_node #1

Merged
merged 7 commits into from Feb 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/allmydata/scripts/common.py
Expand Up @@ -41,7 +41,7 @@ class BasedirOptions(BaseOptions):
optParameters = [
["basedir", "C", None, "Same as --node-directory (default %s)."
% get_default_nodedir()],
["logdir", "L", None, "Set logging folder."],
["logdir", "L", None, "Set directory to save twistd.log"],
]

def parseArgs(self, basedir=None):
Expand Down
40 changes: 26 additions & 14 deletions src/allmydata/scripts/create_node.py
Expand Up @@ -5,15 +5,24 @@
from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_output
import allmydata

class CreateClientOptions(BasedirOptions):
class CreateNodeCommonOptions(BasedirOptions):
optParameters = [
# we provide 'create-node'-time options for the most common
# configuration knobs. The rest can be controlled by editing
# tahoe.cfg before node startup.
("nickname", "n", None, "Specify the nickname for this node."),
("introducer", "i", None, "Specify the introducer FURL to use."),
("webport", "p", "tcp:3456:interface=127.0.0.1",
"Specify which TCP port to run the HTTP interface on. Use 'none' to disable."),
("incidents_dir", "I", None, "Set directory to save incident reports."),
("tempdir", "t", None, "Path to the temporary directory."),
]

class CreateClientOptions(CreateNodeCommonOptions):
optParameters = [
# we provide 'create-node'-time options for the most common
# configuration knobs. The rest can be controlled by editing
# tahoe.cfg before node startup.
("nickname", "n", None, "Specify the nickname for this node."),
("introducer", "i", None, "Specify the introducer FURL to use."),
]

def getSynopsis(self):
Expand All @@ -25,17 +34,20 @@ class CreateNodeOptions(CreateClientOptions):
("no-storage", None, "Do not offer storage service to other nodes."),
]
optParameters = [
("storedir", "s", None, "Path where the storage will be placed."),
("tempdir", "t", None, "Path to the temporary directory."),
("storage_dir", "s", None, "Path where the storage will be placed."),
]

def getSynopsis(self):
return "Usage: %s [global-opts] create-node [options] [NODEDIR]" % (self.command_name,)


class CreateIntroducerOptions(BasedirOptions):
class CreateIntroducerOptions(CreateNodeCommonOptions):
default_nodedir = None

optParameters = [
("webport", "p", "none",
"Specify which TCP port to run the HTTP interface on. Use 'none' to disable."),
]
def getSynopsis(self):
return "Usage: %s [global-opts] create-introducer [options] NODEDIR" % (self.command_name,)

Expand Down Expand Up @@ -93,12 +105,12 @@ def write_node_config(c, config):
c.write("web.static = public_html\n")
c.write("#tub.port =\n")
c.write("#tub.location = \n")
incidents_dir = os.path.join(config.get("logdir", ""), "incidents")
incidents_dir = config.get("incidents_dir")
if incidents_dir:
c.write("incidents_dir = %s\n" % incidents_dir)
else:
c.write("#incidents_dir =\n")
tempdir = config.get("tempdir", "")
tempdir = config.get("tempdir")
if tempdir:
c.write("tempdir = %s\n" % tempdir)
else:
Expand Down Expand Up @@ -135,7 +147,7 @@ def create_node(config, out=sys.stdout, err=sys.stderr):

c.write("[client]\n")
c.write("# Which services should this client connect to?\n")
c.write("introducer.furl = %s\n" % config.get("introducer", ""))
c.write("introducer.furl = %s\n" % config.get("introducer"))
c.write("helper.furl =\n")
c.write("#key_generator.furl =\n")
c.write("#stats_gatherer.furl =\n")
Expand All @@ -153,9 +165,9 @@ def create_node(config, out=sys.stdout, err=sys.stderr):
c.write("enabled = %s\n" % boolstr[storage_enabled])
c.write("#readonly =\n")
c.write("reserved_space = 1G\n")
storedir = config.get("storedir", "")
if storedir:
c.write("storage_dir = %s\n" % storedir)
storage_dir = config.get("storage_dir")
if storage_dir:
c.write("storage_dir = %s\n" % storage_dir)
else:
c.write("#storage_dir =\n")
c.write("#expire.enabled =\n")
Expand All @@ -180,10 +192,10 @@ def create_node(config, out=sys.stdout, err=sys.stderr):
from allmydata.util import fileutil
fileutil.make_dirs(os.path.join(basedir, "private"), 0700)
print >>out, "Node created in %s" % quote_output(basedir)
if not config.get("introducer", ""):
if not config.get("introducer"):
print >>out, " Please set [client]introducer.furl= in tahoe.cfg!"
print >>out, " The node cannot connect to a grid without it."
if not config.get("nickname", ""):
if not config.get("nickname"):
print >>out, " Please set [node]nickname= in tahoe.cfg"
return 0

Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/scripts/startstop_node.py
Expand Up @@ -73,7 +73,7 @@ def start(opts, out=sys.stdout, err=sys.stderr):
args.append("--syslog")
elif nodetype in ("client", "introducer"):
if opts["logdir"]:
logdir = os.path.expanduser(opts["logdir"])
logdir = os.path.realpath( os.path.expanduser(opts["logdir"]) )
else:
logdir = "logs"
fileutil.make_dirs(os.path.join(basedir, logdir))
Expand Down