diff options
Diffstat (limited to 'hooks')
| -rwxr-xr-x | hooks/hooks.py | 21 |
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([(' -- ', |
