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:
parent
4c21a984c6
commit
019e5ba45a
|
@ -29,7 +29,6 @@ from datetime import datetime
|
||||||
|
|
||||||
from charmhelpers.core import hookenv
|
from charmhelpers.core import hookenv
|
||||||
from charmhelpers.core import templating
|
from charmhelpers.core import templating
|
||||||
from charmhelpers.core.decorators import retry_on_exception
|
|
||||||
from charmhelpers.core.host import (
|
from charmhelpers.core.host import (
|
||||||
chownr,
|
chownr,
|
||||||
cmp_pkgrevno,
|
cmp_pkgrevno,
|
||||||
|
@ -793,12 +792,33 @@ def is_leader():
|
||||||
return False
|
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():
|
def wait_for_quorum():
|
||||||
while not is_quorum():
|
while not is_quorum():
|
||||||
log("Waiting for quorum to be reached")
|
log("Waiting for quorum to be reached")
|
||||||
time.sleep(3)
|
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):
|
def add_bootstrap_hint(peer):
|
||||||
asok = "/var/run/ceph/ceph-mon.{}.asok".format(socket.gethostname())
|
asok = "/var/run/ceph/ceph-mon.{}.asok".format(socket.gethostname())
|
||||||
cmd = [
|
cmd = [
|
||||||
|
@ -1274,7 +1294,6 @@ def bootstrap_monitor_cluster(secret):
|
||||||
path,
|
path,
|
||||||
done,
|
done,
|
||||||
init_marker)
|
init_marker)
|
||||||
_create_keyrings()
|
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
@ -1322,10 +1341,11 @@ def _create_monitor(keyring, secret, hostname, path, done, init_marker):
|
||||||
service_restart('ceph-mon-all')
|
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
|
"""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
|
:raises: Exception if keyrings cannot be created
|
||||||
"""
|
"""
|
||||||
if cmp_pkgrevno('ceph', '14.0.0') >= 0:
|
if cmp_pkgrevno('ceph', '14.0.0') >= 0:
|
||||||
|
|
Loading…
Reference in New Issue