summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Admin/Init.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-12-31 11:21:10 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-12-31 11:21:10 +0000
commitef5051726a3aa1f0192bd8d99c5c5b1ee9f067af (patch)
tree57bf0854d95c18cced379921657f746ad5faab04 /src/lib/Server/Admin/Init.py
parent104a1e27cee2d5524460d26c83d3e920cd88b2e9 (diff)
downloadbcfg2-ef5051726a3aa1f0192bd8d99c5c5b1ee9f067af.tar.gz
bcfg2-ef5051726a3aa1f0192bd8d99c5c5b1ee9f067af.tar.bz2
bcfg2-ef5051726a3aa1f0192bd8d99c5c5b1ee9f067af.zip
Switch over to more Options usage and complete tests (everything appears to work now)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4142 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Admin/Init.py')
-rw-r--r--src/lib/Server/Admin/Init.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py
index 0a76f44a7..d057fc1ff 100644
--- a/src/lib/Server/Admin/Init.py
+++ b/src/lib/Server/Admin/Init.py
@@ -1,7 +1,6 @@
import os, socket
import Bcfg2.Server.Admin
-
-from Bcfg2.Settings import settings
+import Bcfg2.Options
config = '''
[server]
@@ -69,11 +68,19 @@ os_list = [('Redhat/Fedora/RHEL/RHAS/Centos', 'redhat'),
class Init(Bcfg2.Server.Admin.Mode):
__shorthelp__ = 'bcfg2-admin init'
__longhelp__ = __shorthelp__ + '\n\tCompare two client specifications or directories of specifications'
+ options = {'repo': Bcfg2.Options.SERVER_REPOSITORY,
+ 'struct': Bcfg2.Options.SERVER_STRUCTURES,
+ 'gens': Bcfg2.Options.SERVER_GENERATORS,
+ 'proto': Bcfg2.Options.SERVER_PROTOCOL,
+ 'sendmail': Bcfg2.Options.SENDMAIL_PATH}
+
def __call__(self, args):
Bcfg2.Server.Admin.Mode.__call__(self, args)
- repopath = raw_input( "location of bcfg2 repository [%s]: " % settings.SERVER_REPOSITORY )
+ opts = Bcfg2.Options.OptionParser(options)
+ opts.parse([])
+ repopath = raw_input("location of bcfg2 repository [%s]: " % opts['repo'])
if repopath == '':
- repopath = settings.SERVER_REPOSITORY
+ repopath = opts['repo']
password = ''
while ( password == '' ):
password = raw_input(
@@ -88,18 +95,15 @@ class Init(Bcfg2.Server.Admin.Mode):
prompt += "%d: \n" % (os_list.index(entry) + 1, entry[0])
prompt += ': '
os_sel = os_list[int(raw_input(prompt))-1][1]
- self.initializeRepo(repopath, server, password, os_sel)
+ self.initializeRepo(repopath, server, password, os_sel, opts)
print "Repository created successfuly in %s" % (repopath)
- def initializeRepo(self, repo, server_uri, password, os_selection):
+ def initializeRepo(self, repo, server_uri, password, os_selection, opts):
'''Setup a new repo'''
keypath = os.path.dirname(os.path.abspath(settings.CONFIG_FILE))
confdata = config % (
- repo,
- settings.SERVER_STRUCTURES,
- settings.SERVER_GENERATORS,
- settings.SENDMAIL_PATH,
- settings.COMMUNICATION_PROTOCOL,
+ repo, opts['struct'], opts['gens'],
+ opts['sendmail'], opts['proto']
password, keypath, server_uri
)