From 555f0d2cb8dc4004afbd780c2b24781c64d31d33 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Mon, 16 Mar 2009 20:51:01 +0000 Subject: Remove some FIXMEs in bcfg2-admin init Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5124 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Admin/Init.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/lib/Server/Admin/Init.py') diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py index af307ec4e..2d53c3548 100644 --- a/src/lib/Server/Admin/Init.py +++ b/src/lib/Server/Admin/Init.py @@ -76,8 +76,7 @@ os_list = [ class Init(Bcfg2.Server.Admin.Mode): - __shorthelp__ = ("Compare two client specifications or " - "directories of specifications") # FIXME + __shorthelp__ = ("Interactively initialize a new repository") __longhelp__ = __shorthelp__ + "\n\nbcfg2-admin init" __usage__ = "bcfg2-admin init" options = { @@ -87,14 +86,14 @@ class Init(Bcfg2.Server.Admin.Mode): 'repo' : Bcfg2.Options.SERVER_REPOSITORY, 'sendmail' : Bcfg2.Options.SENDMAIL_PATH, } + repopath = "" + response = "" def __call__(self, args): Bcfg2.Server.Admin.Mode.__call__(self, args) opts = Bcfg2.Options.OptionParser(self.options) opts.parse([]) - self.response = "" - # FIXME don't overwrite existing bcfg2.conf file configfile = raw_input("Store bcfg2 configuration in [%s]: " % opts['configfile']) if configfile == '': @@ -146,12 +145,18 @@ class Init(Bcfg2.Server.Admin.Mode): password, keypath, server_uri ) - try: - open(configfile, "w").write(confdata) - os.chmod(configfile, 0600) - except: - # FIXME how to handle - print "Failed to write configuration file to '%s'\n" % configfile + # don't overwrite existing bcfg2.conf file + if os.path.exists(configfile): + print("\nWarning: %s already exists. Will not be " + "overwritten...\n" % configfile) + else: + try: + open(configfile, "w").write(confdata) + os.chmod(configfile, 0600) + except Exception, e: + print("Error %s occured while trying to write configuration " + "file to '%s'\n" % + (e, configfile)) # FIXME automate ssl key generation # FIXME key generation may fail as non-root user -- cgit v1.2.3-1-g7c22