os.rename(tmp, path)
+def init_get():
+ """
+ Get a init system using 'ceph-detect-init'
+ """
+ init = _check_output(
+ args=[
+ 'ceph-detect-init',
+ '--default', 'sysvinit',
+ ],
+ )
+ init = must_be_one_line(init)
+ return init
+
+
def check_osd_magic(path):
"""
Check that this path has the Ceph OSD magic.
if conf_val is not None:
init = conf_val
else:
- (distro, release, codename) = platform.dist()
- if distro == 'Ubuntu':
- init = 'upstart'
- else:
- init = 'sysvinit'
+ init = init_get()
LOG.debug('Marking with init system %s', init)
with file(os.path.join(path, init), 'w'):
PS4='${FUNCNAME[0]}: $LINENO: '
-export PATH=:$PATH # make sure program from sources are prefered
+export PATH=.:$PATH # make sure program from sources are prefered
DIR=test-ceph-disk
+virtualenv virtualenv-$DIR
+. virtualenv-$DIR/bin/activate
+(
+ if test -d ceph-detect-init/wheelhouse ; then
+ wheelhouse="--no-index --use-wheel --find-links=ceph-detect-init/wheelhouse"
+ fi
+ pip install $wheelhouse --editable ceph-detect-init
+)
OSD_DATA=$DIR/osd
MON_ID=a
MONA=127.0.0.1:7451
( unset PATH ; test_activate_dir ) || return 1
}
+function test_mark_init() {
+ run_mon
+
+ local osd_data=$(pwd)/$DIR/dir
+ $mkdir -p $osd_data
+
+ local osd_uuid=$($uuidgen)
+
+ $mkdir -p $OSD_DATA
+
+ ./ceph-disk $CEPH_DISK_ARGS \
+ prepare --osd-uuid $osd_uuid $osd_data || return 1
+
+ $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
+ --verbose \
+ activate \
+ --mark-init=auto \
+ --no-start-daemon \
+ $osd_data || return 1
+
+ test -f $osd_data/$(ceph-detect-init) || return 1
+
+ if test systemd = $(ceph-detect-init) ; then
+ expected=sysvinit
+ else
+ expected=systemd
+ fi
+ $timeout $TIMEOUT ./ceph-disk $CEPH_DISK_ARGS \
+ --verbose \
+ activate \
+ --mark-init=$expected \
+ --no-start-daemon \
+ $osd_data || return 1
+
+ ! test -f $osd_data/$(ceph-detect-init) || return 1
+ test -f $osd_data/$expected || return 1
+
+ $rm -fr $osd_data
+}
+
# ceph-disk prepare returns immediately on success if the magic file
# exists in the --osd-data directory.
function test_activate_dir_magic() {
default_actions+="test_activate_dir_magic "
default_actions+="test_activate_dir "
default_actions+="test_keyring_path "
+ default_actions+="test_mark_init "
local actions=${@:-$default_actions}
+ local status
for action in $actions ; do
setup
set -x
set +x
teardown
if test $status != 0 ; then
- return $status
+ break
fi
done
+ rm -fr virtualenv-$DIR
+ return $status
}
run $@