summaryrefslogtreecommitdiffstats
path: root/src/ceph/qa/workunits/ceph-helpers-root.sh
diff options
context:
space:
mode:
authorQiaowei Ren <qiaowei.ren@intel.com>2018-01-04 13:43:33 +0800
committerQiaowei Ren <qiaowei.ren@intel.com>2018-01-05 11:59:39 +0800
commit812ff6ca9fcd3e629e49d4328905f33eee8ca3f5 (patch)
tree04ece7b4da00d9d2f98093774594f4057ae561d4 /src/ceph/qa/workunits/ceph-helpers-root.sh
parent15280273faafb77777eab341909a3f495cf248d9 (diff)
initial code repo
This patch creates initial code repo. For ceph, luminous stable release will be used for base code, and next changes and optimization for ceph will be added to it. For opensds, currently any changes can be upstreamed into original opensds repo (https://github.com/opensds/opensds), and so stor4nfv will directly clone opensds code to deploy stor4nfv environment. And the scripts for deployment based on ceph and opensds will be put into 'ci' directory. Change-Id: I46a32218884c75dda2936337604ff03c554648e4 Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Diffstat (limited to 'src/ceph/qa/workunits/ceph-helpers-root.sh')
-rwxr-xr-xsrc/ceph/qa/workunits/ceph-helpers-root.sh92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/ceph/qa/workunits/ceph-helpers-root.sh b/src/ceph/qa/workunits/ceph-helpers-root.sh
new file mode 100755
index 0000000..f65f591
--- /dev/null
+++ b/src/ceph/qa/workunits/ceph-helpers-root.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+#
+# Copyright (C) 2015 Red Hat <contact@redhat.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library Public License for more details.
+#
+
+#######################################################################
+
+function install() {
+ for package in "$@" ; do
+ install_one $package
+ done
+ return 0
+}
+
+function install_one() {
+ case $(lsb_release -si) in
+ Ubuntu|Debian|Devuan)
+ sudo apt-get install -y "$@"
+ ;;
+ CentOS|Fedora|RedHatEnterpriseServer)
+ sudo yum install -y "$@"
+ ;;
+ *SUSE*)
+ sudo zypper --non-interactive install "$@"
+ ;;
+ *)
+ echo "$(lsb_release -si) is unknown, $@ will have to be installed manually."
+ ;;
+ esac
+}
+
+#######################################################################
+
+function control_osd() {
+ local action=$1
+ local id=$2
+
+ local init=$(ceph-detect-init)
+
+ case $init in
+ upstart)
+ sudo service ceph-osd $action id=$id
+ ;;
+ systemd)
+ sudo systemctl $action ceph-osd@$id
+ ;;
+ *)
+ echo ceph-detect-init returned an unknown init system: $init >&2
+ return 1
+ ;;
+ esac
+ return 0
+}
+
+#######################################################################
+
+function pool_read_write() {
+ local size=${1:-1}
+ local dir=/tmp
+ local timeout=360
+ local test_pool=test_pool
+
+ ceph osd pool delete $test_pool $test_pool --yes-i-really-really-mean-it || return 1
+ ceph osd pool create $test_pool 4 || return 1
+ ceph osd pool set $test_pool size $size || return 1
+ ceph osd pool set $test_pool min_size $size || return 1
+ ceph osd pool application enable $test_pool rados
+
+ echo FOO > $dir/BAR
+ timeout $timeout rados --pool $test_pool put BAR $dir/BAR || return 1
+ timeout $timeout rados --pool $test_pool get BAR $dir/BAR.copy || return 1
+ diff $dir/BAR $dir/BAR.copy || return 1
+ ceph osd pool delete $test_pool $test_pool --yes-i-really-really-mean-it || return 1
+}
+
+#######################################################################
+
+set -x
+
+"$@"