sync with last charms.ceph

7839ca3 put create_keyrings as a public method

Change-Id: Ia1ab1860df33960519d0fac70b8315bc3e8e25a3
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
This commit is contained in:
Sahid Orentino Ferdjaoui 2019-10-24 09:59:36 +00:00
parent 4c21a984c6
commit 019e5ba45a
1 changed files with 24 additions and 4 deletions

View File

@ -29,7 +29,6 @@ from datetime import datetime
from charmhelpers.core import hookenv
from charmhelpers.core import templating
from charmhelpers.core.decorators import retry_on_exception
from charmhelpers.core.host import (
chownr,
cmp_pkgrevno,
@ -793,12 +792,33 @@ def is_leader():
return False
def manager_available():
# if manager daemon isn't on this release, just say it is Fine
if cmp_pkgrevno('ceph', '11.0.0') < 0:
return True
cmd = ["sudo", "-u", "ceph", "ceph", "mgr", "dump", "-f", "json"]
try:
result = json.loads(subprocess.check_output(cmd).decode('UTF-8'))
return result['available']
except subprocess.CalledProcessError as e:
log("'{}' failed: {}".format(" ".join(cmd), str(e)))
return False
except Exception:
return False
def wait_for_quorum():
while not is_quorum():
log("Waiting for quorum to be reached")
time.sleep(3)
def wait_for_manager():
while not manager_available():
log("Waiting for manager to be available")
time.sleep(5)
def add_bootstrap_hint(peer):
asok = "/var/run/ceph/ceph-mon.{}.asok".format(socket.gethostname())
cmd = [
@ -1274,7 +1294,6 @@ def bootstrap_monitor_cluster(secret):
path,
done,
init_marker)
_create_keyrings()
except:
raise
finally:
@ -1322,10 +1341,11 @@ def _create_monitor(keyring, secret, hostname, path, done, init_marker):
service_restart('ceph-mon-all')
@retry_on_exception(3, base_delay=5)
def _create_keyrings():
def create_keyrings():
"""Create keyrings for operation of ceph-mon units
NOTE: The quorum should be done before to execute this function.
:raises: Exception if keyrings cannot be created
"""
if cmp_pkgrevno('ceph', '14.0.0') >= 0: