summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2010-02-20 20:09:17 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-02-20 20:09:17 +0000
commit818c1d478e637b68218647b0f7bab2dbf85e8614 (patch)
tree8f21c417cc44e8e1ab7508d941f9a29f7aac817f
parentde160a5a2bcd1b2e769165f80052ad38122999c0 (diff)
downloadbcfg2-818c1d478e637b68218647b0f7bab2dbf85e8614.tar.gz
bcfg2-818c1d478e637b68218647b0f7bab2dbf85e8614.tar.bz2
bcfg2-818c1d478e637b68218647b0f7bab2dbf85e8614.zip
Options.py: Add configurable lockfile option (Resolves Ticket #850)
Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5734 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--doc/bcfg2.conf-options.txt19
-rw-r--r--doc/contents.txt1
-rw-r--r--src/lib/Options.py4
-rwxr-xr-xsrc/sbin/bcfg26
4 files changed, 27 insertions, 3 deletions
diff --git a/doc/bcfg2.conf-options.txt b/doc/bcfg2.conf-options.txt
new file mode 100644
index 000000000..85bc0190f
--- /dev/null
+++ b/doc/bcfg2.conf-options.txt
@@ -0,0 +1,19 @@
+.. -*- mode: rst -*-
+
+.. _bcfg2.conf-options:
+
+==========
+bcfg2.conf
+==========
+
+This page documents the various options available in bcfg2.conf. The
+various sections correspond to the sections in the file itself.
+
+components
+==========
+
+logging
+-------
+
+Specify an alternate path for the lockfile used by the bcfg2 client.
+Default value is ``/var/lock/bcfg2.run``
diff --git a/doc/contents.txt b/doc/contents.txt
index 1509cdd3a..80c4a9072 100644
--- a/doc/contents.txt
+++ b/doc/contents.txt
@@ -17,6 +17,7 @@ Welcome to Bcfg2's documentation!
server/index
client/index
gettinghelp
+ bcfg2.conf-options
development/index
unsorted/index
diff --git a/src/lib/Options.py b/src/lib/Options.py
index c67fde910..c2e265b87 100644
--- a/src/lib/Options.py
+++ b/src/lib/Options.py
@@ -172,6 +172,10 @@ def colon_split(c_string):
CFILE = Option('Specify configuration file', DEFAULT_CONFIG_LOCATION, cmd='-C',
odesc='<conffile>')
+LOCKFILE = Option('Specify lockfile',
+ "/var/lock/bcfg2.run",
+ cf=('components', 'lockfile'),
+ odesc='<Path to lockfile>')
HELP = Option('Print this usage message', False, cmd='-h')
DEBUG = Option("Enable debugging output", False, cmd='-d')
VERBOSE = Option("Enable verbose output", False, cmd='-v')
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index 293f88e9f..13ecf1886 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -28,7 +28,6 @@ def cb_sigint_handler(signum, frame):
DECISION_LIST = Bcfg2.Options.Option('Decision List', default=False,
cmd="--decision-list", odesc='<file>',
long_arg=True)
-LOCKFILE = "/var/lock/bcfg2.run"
class Client:
@@ -45,6 +44,7 @@ class Client:
'extra': Bcfg2.Options.CLIENT_EXTRA_DISPLAY,
'quick': Bcfg2.Options.CLIENT_QUICK,
'debug': Bcfg2.Options.DEBUG,
+ 'lockfile': Bcfg2.Options.LOCKFILE,
'drivers': Bcfg2.Options.CLIENT_DRIVERS,
'dryrun': Bcfg2.Options.CLIENT_DRYRUN,
'paranoid': Bcfg2.Options.CLIENT_PARANOID,
@@ -259,7 +259,7 @@ class Client:
if not self.setup['omit-lock-check']:
#check lock here
try:
- lockfile = open(LOCKFILE, 'w')
+ lockfile = open(self.setup['lockfile'], 'w')
try:
fcntl.lockf(lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
@@ -277,7 +277,7 @@ class Client:
if lockfile:
try:
fcntl.lockf(lockfile.fileno(), fcntl.LOCK_UN)
- os.remove(LOCKFILE)
+ os.remove(self.setup['lockfile'])
except OSError:
self.logger.error("Failed to unlock lockfile %s" % lockfile.name)