summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Vuletich <vuletich@mcs.anl.gov>2006-08-24 21:43:01 +0000
committerChris Vuletich <vuletich@mcs.anl.gov>2006-08-24 21:43:01 +0000
commit7d04c19afa0f690a3123fc5a7c929a4675b37b84 (patch)
treef562e16dc360b91514b12335e36edbb764fa5e77 /src
parentc9c418532cc15c3c1c914083867923bd74f644b6 (diff)
downloadbcfg2-7d04c19afa0f690a3123fc5a7c929a4675b37b84.tar.gz
bcfg2-7d04c19afa0f690a3123fc5a7c929a4675b37b84.tar.bz2
bcfg2-7d04c19afa0f690a3123fc5a7c929a4675b37b84.zip
Implement interactive mode for the client
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2107 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Client/Debian.py4
-rw-r--r--src/lib/Client/Toolset.py21
-rwxr-xr-xsrc/sbin/bcfg26
3 files changed, 28 insertions, 3 deletions
diff --git a/src/lib/Client/Debian.py b/src/lib/Client/Debian.py
index 4c13443f0..b431f982d 100644
--- a/src/lib/Client/Debian.py
+++ b/src/lib/Client/Debian.py
@@ -20,8 +20,8 @@ class ToolsetImpl(Bcfg2.Client.Toolset.Toolset):
self.logger.debug('Configuring Debian toolset')
os.environ["DEBIAN_FRONTEND"] = 'noninteractive'
# dup /dev/null on top of stdin
- null = open('/dev/null', 'w+')
- os.dup2(null.fileno(), sys.__stdin__.fileno())
+ #null = open('/dev/null', 'w+')
+ #os.dup2(null.fileno(), sys.__stdin__.fileno())
if not self.setup['dryrun']:
if self.setup['kevlar']:
self.saferun("dpkg --force-confold --configure --pending")
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py
index fbf4ae7c4..7aa6a420f 100644
--- a/src/lib/Client/Toolset.py
+++ b/src/lib/Client/Toolset.py
@@ -555,7 +555,7 @@ class Toolset(object):
self.logger.info("Packages to remove:")
self.logger.info(self.pkgwork['remove'])
if [entry for entry in self.states if not (self.states[entry] or entry.tag == 'Package')]:
- self.logger.info("Entries to update:")
+ self.logger.info("Entries are incorrect:")
self.logger.info(["%s: %s" % (entry.tag, entry.get('name'))
for entry in self.states if not (self.states[entry]
or entry.tag == 'Package')])
@@ -563,6 +563,22 @@ class Toolset(object):
self.logger.info("Services to remove:")
self.logger.info(self.extra_services)
+ def PromptUser(self):
+ '''Prompts user for each entry in interactive mode'''
+ #get list of entries that need to be updated
+ #ask user for each entry
+ work = self.pkgwork['add'] + self.pkgwork['update']
+ work += [ent for ent in self.states if ent.tag != 'Package' and not self.states[ent]]
+ self.iinst = [];
+ for entry in work:
+ try:
+ if raw_input("Would you like to install %s%s? (y/N): " % (entry.tag, entry.get('name'))) in ['y','Y']:
+ self.iinst.append((entry.tag, entry.get('name')))
+ except:
+ continue
+ self.logger.info("You chose to install:")
+ self.logger.info(['%s:%s' % item for item in self.iinst])
+
def Install(self):
'''Correct detected misconfigurations'''
if self.setup['dryrun']:
@@ -585,6 +601,9 @@ class Toolset(object):
# add non-package entries
work += [ent for ent in self.states if ent.tag != 'Package' and not self.states[ent]]
+ if self.setup['interactive']:
+ work = [entry for entry in work if (entry.tag, entry.get('name')) in self.iinst]
+
# Counters
## Packages left to install
left = len(work) + len(self.pkgwork['remove'])
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index 909a8360a..e803043c9 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -41,6 +41,8 @@ class Client:
False, False, False, False),
'file': (('-f', "<configspec>", "configure from a file rather than querying the server"),
False, False, False, False),
+ 'interactive': (('-I', False, "prompt the user for each change"),
+ False, False, False, True),
'cache': (('-c', "<configspec>", "store the configuration in a file"),
False, False, False, False),
'profile': (('-p', '<profile>', "assert the given profile for the host"),
@@ -253,6 +255,10 @@ class Client:
# summarize current state
self.toolset.CondDisplayState('initial')
+ # run bcfg in interactive mode
+ if self.setup['interactive']:
+ self.toolset.PromptUser()
+
# install incorrect aspects of configuration
self.toolset.Install()