summaryrefslogtreecommitdiff
path: root/hooks
diff options
authorMario Splivalo <mario.splivalo@canonical.com>2015-01-21 22:46:06 +0100
committerMario Splivalo <mario.splivalo@canonical.com>2015-01-21 22:46:06 +0100
commit3a9ad463d9a788e93a0f899dd95772af28fb5751 (patch)
treeac23cca0c791c5711e7cf0b2169bbaadaf8d7e64 /hooks
parenta272318441932ce908b5be7f3aff8041350959ad (diff)
Replaced python-portalocker with python-filelock. The later exists
in both precise and trusty.
Diffstat (limited to 'hooks')
-rwxr-xr-xhooks/hooks.py21
1 files changed, 5 insertions, 16 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py
index 31f9d47..ec55a65 100755
--- a/hooks/hooks.py
+++ b/hooks/hooks.py
@@ -59,29 +59,19 @@ from charmhelpers.contrib.hahelpers.cluster import (
peer_units
)
-series = lsb_release()['DISTRIB_CODENAME']
-
try:
from pymongo import Connection
from pymongo.errors import OperationFailure
except ImportError:
- juju_log('DEBUG: INSTALLING THE ALL MIGHTY python-pymongo')
apt_install("python-pymongo", fatal=True)
from pymongo import Connection
from pymongo.errors import OperationFailure
try:
- from portalocker import Lock
+ from lockfile import FileLock
except ImportError:
- if series == 'precise':
- from charmhelpers.contrib.python.packages import pip_install
- pip_proxy = config('pip_proxy')
- if pip_proxy == 'None':
- pip_proxy = ''
- pip_install('portalocker', fatal=True, upgrade=True, proxy=pip_proxy)
- else:
- apt_install("python-portalocker", fatal=True)
- from portalocker import Lock
+ apt_install("python-lockfile", fatal=True)
+ from lockfile import FileLock
hooks = Hooks()
@@ -530,14 +520,13 @@ def enable_replset(replicaset_name=None):
try:
juju_log('enable_replset: trying to get lock on: %s' %
default_mongodb_init_config)
- with Lock(INIT_LOCKFILE, mode='a', timeout=100,
- check_interval=.25, fail_when_locked=False):
+ with FileLock(INIT_LOCKFILE):
juju_log('enable_replset: lock acquired', level=DEBUG)
with open(default_mongodb_init_config) as mongo_init_file:
mongodb_init_config = mongo_init_file.read()
if re.search(' --replSet %s ' % replicaset_name,
mongodb_init_config, re.MULTILINE) is None:
- juju_log('enable_replset: --relset not preset,'
+ juju_log('enable_replset: --replset not preset,'
' enabling',
level=DEBUG)
mongodb_init_config = regex_sub([(' -- ',