update to work with infernalis in additionto firefly
This commit is contained in:
parent
d6b354ca17
commit
d86a0c9f50
@ -9,6 +9,5 @@ include:
|
|||||||
- ceph
|
- ceph
|
||||||
- payload.execd
|
- payload.execd
|
||||||
- contrib.openstack.alternatives
|
- contrib.openstack.alternatives
|
||||||
- contrib.openstack.utils
|
|
||||||
- contrib.network.ip
|
- contrib.network.ip
|
||||||
- contrib.charmsupport
|
- contrib.charmsupport
|
||||||
|
@ -11,8 +11,10 @@ import json
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from charmhelpers.core.host import (
|
from charmhelpers.core.host import (
|
||||||
mkdir,
|
mkdir,
|
||||||
|
chownr,
|
||||||
service_restart,
|
service_restart,
|
||||||
cmp_pkgrevno,
|
cmp_pkgrevno,
|
||||||
lsb_release
|
lsb_release
|
||||||
@ -24,6 +26,9 @@ from charmhelpers.core.hookenv import (
|
|||||||
cached,
|
cached,
|
||||||
status_set,
|
status_set,
|
||||||
)
|
)
|
||||||
|
from charmhelpers.fetch import (
|
||||||
|
apt_cache
|
||||||
|
)
|
||||||
from charmhelpers.contrib.storage.linux.utils import (
|
from charmhelpers.contrib.storage.linux.utils import (
|
||||||
zap_disk,
|
zap_disk,
|
||||||
is_block_device,
|
is_block_device,
|
||||||
@ -39,10 +44,58 @@ QUORUM = [LEADER, PEON]
|
|||||||
|
|
||||||
PACKAGES = ['ceph', 'gdisk', 'ntp', 'btrfs-tools', 'python-ceph', 'xfsprogs']
|
PACKAGES = ['ceph', 'gdisk', 'ntp', 'btrfs-tools', 'python-ceph', 'xfsprogs']
|
||||||
|
|
||||||
|
def ceph_user():
|
||||||
|
if get_version() > 1:
|
||||||
|
return 'ceph'
|
||||||
|
else:
|
||||||
|
return "root"
|
||||||
|
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
'''Derive Ceph release from an installed package.'''
|
||||||
|
import apt_pkg as apt
|
||||||
|
|
||||||
|
cache = apt_cache()
|
||||||
|
package = "ceph"
|
||||||
|
try:
|
||||||
|
pkg = cache[package]
|
||||||
|
except:
|
||||||
|
if not fatal:
|
||||||
|
return None
|
||||||
|
# the package is unknown to the current apt cache.
|
||||||
|
e = 'Could not determine version of package with no installation '\
|
||||||
|
'candidate: %s' % package
|
||||||
|
error_out(e)
|
||||||
|
|
||||||
|
if not pkg.current_ver:
|
||||||
|
if not fatal:
|
||||||
|
return None
|
||||||
|
# package is known, but no version is currently installed.
|
||||||
|
e = 'Could not determine version of uninstalled package: %s' % package
|
||||||
|
error_out(e)
|
||||||
|
|
||||||
|
vers = apt.upstream_version(pkg.current_ver.ver_str)
|
||||||
|
|
||||||
|
# x.y match only for 20XX.X
|
||||||
|
# and ignore patch level for other packages
|
||||||
|
match = re.match('^(\d+)\.(\d+)', vers)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
vers = match.group(0)
|
||||||
|
return float(vers)
|
||||||
|
|
||||||
|
|
||||||
|
def error_out(msg):
|
||||||
|
juju_log("FATAL ERROR: %s" % msg, level='ERROR')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def is_quorum():
|
def is_quorum():
|
||||||
asok = "/var/run/ceph/ceph-mon.{}.asok".format(get_unit_hostname())
|
asok = "/var/run/ceph/ceph-mon.{}.asok".format(get_unit_hostname())
|
||||||
cmd = [
|
cmd = [
|
||||||
|
"sudo",
|
||||||
|
"-u",
|
||||||
|
ceph_user(),
|
||||||
"ceph",
|
"ceph",
|
||||||
"--admin-daemon",
|
"--admin-daemon",
|
||||||
asok,
|
asok,
|
||||||
@ -67,6 +120,9 @@ def is_quorum():
|
|||||||
def is_leader():
|
def is_leader():
|
||||||
asok = "/var/run/ceph/ceph-mon.{}.asok".format(get_unit_hostname())
|
asok = "/var/run/ceph/ceph-mon.{}.asok".format(get_unit_hostname())
|
||||||
cmd = [
|
cmd = [
|
||||||
|
"sudo",
|
||||||
|
"-u",
|
||||||
|
ceph_user(),
|
||||||
"ceph",
|
"ceph",
|
||||||
"--admin-daemon",
|
"--admin-daemon",
|
||||||
asok,
|
asok,
|
||||||
@ -96,6 +152,9 @@ def wait_for_quorum():
|
|||||||
def add_bootstrap_hint(peer):
|
def add_bootstrap_hint(peer):
|
||||||
asok = "/var/run/ceph/ceph-mon.{}.asok".format(get_unit_hostname())
|
asok = "/var/run/ceph/ceph-mon.{}.asok".format(get_unit_hostname())
|
||||||
cmd = [
|
cmd = [
|
||||||
|
"sudo",
|
||||||
|
"-u",
|
||||||
|
ceph_user(),
|
||||||
"ceph",
|
"ceph",
|
||||||
"--admin-daemon",
|
"--admin-daemon",
|
||||||
asok,
|
asok,
|
||||||
@ -161,6 +220,9 @@ def wait_for_bootstrap():
|
|||||||
def import_osd_bootstrap_key(key):
|
def import_osd_bootstrap_key(key):
|
||||||
if not os.path.exists(_bootstrap_keyring):
|
if not os.path.exists(_bootstrap_keyring):
|
||||||
cmd = [
|
cmd = [
|
||||||
|
"sudo",
|
||||||
|
"-u",
|
||||||
|
ceph_user(),
|
||||||
'ceph-authtool',
|
'ceph-authtool',
|
||||||
_bootstrap_keyring,
|
_bootstrap_keyring,
|
||||||
'--create-keyring',
|
'--create-keyring',
|
||||||
@ -219,6 +281,9 @@ _radosgw_keyring = "/etc/ceph/keyring.rados.gateway"
|
|||||||
def import_radosgw_key(key):
|
def import_radosgw_key(key):
|
||||||
if not os.path.exists(_radosgw_keyring):
|
if not os.path.exists(_radosgw_keyring):
|
||||||
cmd = [
|
cmd = [
|
||||||
|
"sudo",
|
||||||
|
"-u",
|
||||||
|
ceph_user(),
|
||||||
'ceph-authtool',
|
'ceph-authtool',
|
||||||
_radosgw_keyring,
|
_radosgw_keyring,
|
||||||
'--create-keyring',
|
'--create-keyring',
|
||||||
@ -247,6 +312,9 @@ _default_caps = {
|
|||||||
def get_named_key(name, caps=None):
|
def get_named_key(name, caps=None):
|
||||||
caps = caps or _default_caps
|
caps = caps or _default_caps
|
||||||
cmd = [
|
cmd = [
|
||||||
|
"sudo",
|
||||||
|
"-u",
|
||||||
|
ceph_user(),
|
||||||
'ceph',
|
'ceph',
|
||||||
'--name', 'mon.',
|
'--name', 'mon.',
|
||||||
'--keyring',
|
'--keyring',
|
||||||
@ -270,7 +338,7 @@ def upgrade_key_caps(key, caps):
|
|||||||
# Not the MON leader OR not clustered
|
# Not the MON leader OR not clustered
|
||||||
return
|
return
|
||||||
cmd = [
|
cmd = [
|
||||||
'ceph', 'auth', 'caps', key
|
"sudo", "-u", ceph_user(),'ceph', 'auth', 'caps', key
|
||||||
]
|
]
|
||||||
for subsystem, subcaps in caps.iteritems():
|
for subsystem, subcaps in caps.iteritems():
|
||||||
cmd.extend([subsystem, '; '.join(subcaps)])
|
cmd.extend([subsystem, '; '.join(subcaps)])
|
||||||
@ -297,8 +365,8 @@ def bootstrap_monitor_cluster(secret):
|
|||||||
log('bootstrap_monitor_cluster: mon already initialized.')
|
log('bootstrap_monitor_cluster: mon already initialized.')
|
||||||
else:
|
else:
|
||||||
# Ceph >= 0.61.3 needs this for ceph-mon fs creation
|
# Ceph >= 0.61.3 needs this for ceph-mon fs creation
|
||||||
mkdir('/var/run/ceph', perms=0o755)
|
mkdir('/var/run/ceph', owner=ceph_user(), group=ceph_user(), perms=0o755)
|
||||||
mkdir(path)
|
mkdir(path, owner=ceph_user(), group=ceph_user())
|
||||||
# end changes for Ceph >= 0.61.3
|
# end changes for Ceph >= 0.61.3
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['ceph-authtool', keyring,
|
subprocess.check_call(['ceph-authtool', keyring,
|
||||||
@ -307,9 +375,11 @@ def bootstrap_monitor_cluster(secret):
|
|||||||
'--cap', 'mon', 'allow *'])
|
'--cap', 'mon', 'allow *'])
|
||||||
|
|
||||||
subprocess.check_call(['ceph-mon', '--mkfs',
|
subprocess.check_call(['ceph-mon', '--mkfs',
|
||||||
|
# '--setuser', ceph_user(),
|
||||||
|
# '--setgroup', ceph_user(),
|
||||||
'-i', hostname,
|
'-i', hostname,
|
||||||
'--keyring', keyring])
|
'--keyring', keyring])
|
||||||
|
chownr(path, ceph_user(), ceph_user())
|
||||||
with open(done, 'w'):
|
with open(done, 'w'):
|
||||||
pass
|
pass
|
||||||
with open(init_marker, 'w'):
|
with open(init_marker, 'w'):
|
||||||
@ -405,7 +475,7 @@ def osdize_dir(path):
|
|||||||
level=ERROR)
|
level=ERROR)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
mkdir(path)
|
mkdir(path, owner=ceph_user(), group=ceph_user())
|
||||||
cmd = [
|
cmd = [
|
||||||
'ceph-disk',
|
'ceph-disk',
|
||||||
'prepare',
|
'prepare',
|
||||||
|
@ -111,7 +111,7 @@ def emit_cephconf():
|
|||||||
# Install ceph.conf as an alternative to support
|
# Install ceph.conf as an alternative to support
|
||||||
# co-existence with other charms that write this file
|
# co-existence with other charms that write this file
|
||||||
charm_ceph_conf = "/var/lib/charm/{}/ceph.conf".format(service_name())
|
charm_ceph_conf = "/var/lib/charm/{}/ceph.conf".format(service_name())
|
||||||
mkdir(os.path.dirname(charm_ceph_conf))
|
mkdir(os.path.dirname(charm_ceph_conf), owner=ceph.ceph_user(), group=ceph.ceph_user())
|
||||||
render('ceph.conf', charm_ceph_conf, cephcontext, perms=0o644)
|
render('ceph.conf', charm_ceph_conf, cephcontext, perms=0o644)
|
||||||
install_alternative('ceph.conf', '/etc/ceph/ceph.conf',
|
install_alternative('ceph.conf', '/etc/ceph/ceph.conf',
|
||||||
charm_ceph_conf, 100)
|
charm_ceph_conf, 100)
|
||||||
|
Loading…
Reference in New Issue
Block a user