diff options
| author | Vu Tran <vu.tran@windriver.com> | 2014-04-09 19:59:09 -0400 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-04-11 14:15:28 -0400 |
| commit | 322d51de8417142c6ffbf024b198b26069a53f46 (patch) | |
| tree | 7dc20eedcd969ecff64b57061a5263387fe1b424 /meta-openstack/recipes-devtools/python | |
| parent | c173214e9c25409944144c9b4bd9892949a834ba (diff) | |
| download | meta-cloud-services-322d51de8417142c6ffbf024b198b26069a53f46.tar.gz | |
swift: add setup package
Introduce swift setup package. At boot time, this
package setups a simple swift cluster including:
* 3 zones
* each zone has 1 storage device which are based
on loopback devices which the backing files size
is controlled by variable SWIFT_BACKING_FILE_SIZE
The script /etc/swift/swift_setup.sh is also provided to ease
the task of setting up a complicated Swift cluster. It reads a
cluster config file, which describes what storage devices are
included in what rings, and constructs the cluster.
For details of how to use swift_setup.sh and the format
of Swift cluster config file please refer to the
script's help:
$ swift_setup.sh
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-devtools/python')
4 files changed, 429 insertions, 2 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-swift/cluster.conf b/meta-openstack/recipes-devtools/python/python-swift/cluster.conf new file mode 100644 index 0000000..3cab8bd --- /dev/null +++ b/meta-openstack/recipes-devtools/python/python-swift/cluster.conf | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | # Swift cluster config file | ||
| 2 | # | ||
| 3 | # Each line specifies one storage device with the following format: | ||
| 4 | # | ||
| 5 | # <dev file>, <dev format>, <zone>, <ring names>, <weight> | ||
| 6 | # | ||
| 7 | # <dev file>: full path to a block device or full path to regular | ||
| 8 | # file which is used for backing up a loopback device. | ||
| 9 | # If <dev file> is empty string then this device is | ||
| 10 | # backed up by a directory in local filesystem. | ||
| 11 | # <dev format>: the disk format type, e.g. ext4, xfs... | ||
| 12 | # <zone>: the zone id which this block device belongs to | ||
| 13 | # <ring names>: a list (separated by space) ring name ("account", "container", | ||
| 14 | # or "object") which this device is added to | ||
| 15 | # <weight>: weight of this device in Swift zone | ||
| 16 | # | ||
| 17 | # Examples: | ||
| 18 | # | ||
| 19 | # /dev/sda1, ext4, 1, account, 1 | ||
| 20 | # /dev/sda2, ext4, 1, container, 1 | ||
| 21 | # /dev/sda3, ext4, 1, object, 1 | ||
| 22 | # /dev/sdb1, ext4, 2, account container object, 1 | ||
| 23 | # /dev/sdb2, ext4, 2, account container object, 1 | ||
| 24 | # /dev/sdb3, ext4, 2, account container object, 1 | ||
| 25 | # , ext4, 1, account container object, 1 | ||
| 26 | # , ext4, 2, account container object, 1 | ||
| 27 | # , ext4, 3, account container object, 1 | ||
| 28 | |||
| 29 | |||
| 30 | %SWIFT_BACKING_FILE_1%, ext4, 1, account container object, 1 | ||
| 31 | %SWIFT_BACKING_FILE_2%, ext4, 2, account container object, 1 | ||
| 32 | %SWIFT_BACKING_FILE_3%, ext4, 3, account container object, 1 | ||
diff --git a/meta-openstack/recipes-devtools/python/python-swift/swift.init b/meta-openstack/recipes-devtools/python/python-swift/swift.init new file mode 100644 index 0000000..cf12066 --- /dev/null +++ b/meta-openstack/recipes-devtools/python/python-swift/swift.init | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # chkconfig: 2345 20 20 | ||
| 4 | |||
| 5 | ### BEGIN INIT INFO | ||
| 6 | # Provides: swift-openstack | ||
| 7 | # Required-Start: $remote_fs $syslog | ||
| 8 | # Required-Stop: $remote_fs $syslog | ||
| 9 | # Default-Start: 3 5 | ||
| 10 | # Default-Stop: 0 1 2 6 | ||
| 11 | # Short-Description: OpenStack Swift | ||
| 12 | # Description: OpenStack Swift | ||
| 13 | ### END INIT INFO | ||
| 14 | |||
| 15 | |||
| 16 | DESC="Swift Cluster" | ||
| 17 | SWIFT_HOME=/etc/swift | ||
| 18 | SWIFT_INIT=/usr/bin/swift-init | ||
| 19 | |||
| 20 | start () | ||
| 21 | { | ||
| 22 | echo -n "Starting $DESC..." | ||
| 23 | if [ ! -e $SWIFT_HOME/account.builder -a ! -e $SWIFT_HOME/container.builder -a ! -e $SWIFT_HOME/object.builder ]; then | ||
| 24 | echo "no Swift cluster has been setup, failed." | ||
| 25 | exit 1 | ||
| 26 | fi | ||
| 27 | /etc/swift/swift_setup.sh mountdevs | ||
| 28 | $SWIFT_INIT proxy-server start | ||
| 29 | $SWIFT_INIT account-server start | ||
| 30 | $SWIFT_INIT container-server start | ||
| 31 | $SWIFT_INIT object-server start | ||
| 32 | echo "done." | ||
| 33 | } | ||
| 34 | |||
| 35 | |||
| 36 | stop () | ||
| 37 | { | ||
| 38 | echo -n "Stopping $DESC..." | ||
| 39 | $SWIFT_INIT all stop | ||
| 40 | /etc/swift/swift_setup.sh unmountdevs | ||
| 41 | echo "done." | ||
| 42 | } | ||
| 43 | |||
| 44 | |||
| 45 | status () | ||
| 46 | { | ||
| 47 | $SWIFT_INIT proxy-server status | ||
| 48 | $SWIFT_INIT account-server status | ||
| 49 | $SWIFT_INIT container-server status | ||
| 50 | $SWIFT_INIT object-server status | ||
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 | case "$1" in | ||
| 55 | start) | ||
| 56 | start | ||
| 57 | ;; | ||
| 58 | stop) | ||
| 59 | stop | ||
| 60 | ;; | ||
| 61 | restart|force-reload) | ||
| 62 | stop | ||
| 63 | start | ||
| 64 | ;; | ||
| 65 | status) | ||
| 66 | status | ||
| 67 | ;; | ||
| 68 | *) | ||
| 69 | echo "Usage: swift {start|stop|force-reload|restart|status}" | ||
| 70 | exit 1 | ||
| 71 | ;; | ||
| 72 | esac | ||
| 73 | |||
| 74 | exit 0 | ||
diff --git a/meta-openstack/recipes-devtools/python/python-swift/swift_setup.sh b/meta-openstack/recipes-devtools/python/python-swift/swift_setup.sh new file mode 100644 index 0000000..c1d02ed --- /dev/null +++ b/meta-openstack/recipes-devtools/python/python-swift/swift_setup.sh | |||
| @@ -0,0 +1,270 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | #set -x | ||
| 4 | |||
| 5 | SWIFT_RING_BUILDER=/usr/bin/swift-ring-builder | ||
| 6 | |||
| 7 | |||
| 8 | for_each_dev_in_cluster () | ||
| 9 | { | ||
| 10 | local cmd=$1 | ||
| 11 | |||
| 12 | dev_id=0 | ||
| 13 | while read line; do | ||
| 14 | line=`echo $line | sed -e 's/^ *//g' -e 's/ *$//g'` | ||
| 15 | [ -z "$line" ] && continue | ||
| 16 | |||
| 17 | dev=`echo $line | cut -d ',' -f 1 | sed -e 's/^ *//g' -e 's/ *$//g'` | ||
| 18 | dev_format=`echo $line | cut -d ',' -f 2 | sed -e 's/^ *//g' -e 's/ *$//g'` | ||
| 19 | zone=`echo $line | cut -d ',' -f 3 | sed -e 's/^ *//g' -e 's/ *$//g'` | ||
| 20 | ring_names=`echo $line | cut -d ',' -f 4 | sed -e 's/^ *//g' -e 's/ *$//g'` | ||
| 21 | weight=`echo $line | cut -d ',' -f 5 | sed -e 's/^ *//g' -e 's/ *$//g'` | ||
| 22 | |||
| 23 | [[ "${dev:0:1}" == "#" ]] && continue | ||
| 24 | if [ ! -z $dev ] && [ ! -e $dev ]; then | ||
| 25 | continue | ||
| 26 | fi | ||
| 27 | dev_id=$((dev_id+1)) | ||
| 28 | $cmd "$dev" "$dev_format" "$dev_id" "$zone" "$ring_names" "$weight" $2 $3 $4 | ||
| 29 | done < $cluster_conf | ||
| 30 | } | ||
| 31 | |||
| 32 | |||
| 33 | mount_dev () | ||
| 34 | { | ||
| 35 | local dev=$1 | ||
| 36 | local dev_id=$3 | ||
| 37 | local zone=$4 | ||
| 38 | |||
| 39 | mkdir -p $swift_home/node/z${zone}d${dev_id} | ||
| 40 | [ -z "$dev" ] && return 1 | ||
| 41 | if [ -b $dev ]; then | ||
| 42 | mount $dev $swift_home/node/z${zone}d${dev_id} | ||
| 43 | else | ||
| 44 | loopdev=`losetup --show -f $dev` | ||
| 45 | mount $loopdev $swift_home/node/z${zone}d${dev_id} | ||
| 46 | fi | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | unmount_dev () | ||
| 51 | { | ||
| 52 | local dev=$1 | ||
| 53 | |||
| 54 | [ -z "$dev" ] && return 1 | ||
| 55 | if [ -b $dev ]; then | ||
| 56 | umount $dev | ||
| 57 | else | ||
| 58 | loopdev=`losetup -j $dev | cut -d ":" -f 1 | tail -1` | ||
| 59 | if [ ! -z $loopdev ]; then | ||
| 60 | umount $loopdev | ||
| 61 | losetup -d $loopdev | ||
| 62 | fi | ||
| 63 | fi | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | format_dev () | ||
| 68 | { | ||
| 69 | local dev=$1 | ||
| 70 | local dev_format=$2 | ||
| 71 | |||
| 72 | [ -z "$dev" ] && return 1 | ||
| 73 | if [ -b $dev ]; then | ||
| 74 | mkfs.${dev_format} $dev | ||
| 75 | else | ||
| 76 | loopdev=`losetup --show -f $dev` | ||
| 77 | mkfs.${dev_format} $loopdev | ||
| 78 | sleep 2 | ||
| 79 | losetup -d $loopdev | ||
| 80 | fi | ||
| 81 | } | ||
| 82 | |||
| 83 | |||
| 84 | add_dev () | ||
| 85 | { | ||
| 86 | local dev_id=$3 | ||
| 87 | local zone=$4 | ||
| 88 | local ring_names=$5 | ||
| 89 | local weight=$6 | ||
| 90 | |||
| 91 | account_port=6002 | ||
| 92 | container_port=6001 | ||
| 93 | object_port=6000 | ||
| 94 | |||
| 95 | for ring in $ring_names; do | ||
| 96 | eval builder_port=\$${ring}_port | ||
| 97 | [ -z $builder_port ] && continue | ||
| 98 | $SWIFT_RING_BUILDER $swift_home/${ring}.builder add -r 1 -z $zone -i $host_ip -p $builder_port -d z${zone}d${dev_id} -w $weight | ||
| 99 | done | ||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | cluster_create_rings () | ||
| 104 | { | ||
| 105 | if [ ! -f $SWIFT_RING_BUILDER ]; then | ||
| 106 | echo "ERROR: Swift packages are not installed on this machine" | ||
| 107 | return 1 | ||
| 108 | fi | ||
| 109 | |||
| 110 | if [ -e $swift_home/account.builder -o -e $swift_home/container.builder -o -e $swift_home/object.builder ]; then | ||
| 111 | echo "ERROR: Swift cluster has been created" | ||
| 112 | return 1 | ||
| 113 | fi | ||
| 114 | |||
| 115 | sed "s/^swift_hash_path_suffix =.*/swift_hash_path_suffix = `uuidgen`/" -i $swift_home/swift.conf | ||
| 116 | |||
| 117 | # Create 3 ring builders: each ring has 2^12 partition | ||
| 118 | $SWIFT_RING_BUILDER $swift_home/account.builder create 12 $cluster_replica 1 | ||
| 119 | $SWIFT_RING_BUILDER $swift_home/container.builder create 12 $cluster_replica 1 | ||
| 120 | $SWIFT_RING_BUILDER $swift_home/object.builder create 12 $cluster_replica 1 | ||
| 121 | } | ||
| 122 | |||
| 123 | |||
| 124 | cluster_add_devs () | ||
| 125 | { | ||
| 126 | for_each_dev_in_cluster add_dev | ||
| 127 | |||
| 128 | $SWIFT_RING_BUILDER $swift_home/account.builder rebalance | ||
| 129 | $SWIFT_RING_BUILDER $swift_home/container.builder rebalance | ||
| 130 | $SWIFT_RING_BUILDER $swift_home/object.builder rebalance | ||
| 131 | } | ||
| 132 | |||
| 133 | |||
| 134 | cluster_delete_all () | ||
| 135 | { | ||
| 136 | for_each_dev_in_cluster unmount_dev | ||
| 137 | rm -rf $swift_home/*.ring.gz | ||
| 138 | rm -rf $swift_home/*.builder | ||
| 139 | rm -rf $swift_home/node | ||
| 140 | } | ||
| 141 | |||
| 142 | |||
| 143 | help () | ||
| 144 | { | ||
| 145 | cat << EOF | ||
| 146 | usage: swift_setup.sh [-hcirk] <command> | ||
| 147 | |||
| 148 | -h : View this help | ||
| 149 | -c : Swift cluster config file, default is /etc/swift/cluster.conf | ||
| 150 | -i : IP address of this machine, default is 127.0.0.1 | ||
| 151 | -r : The number of Swift replications | ||
| 152 | -k : Location where Swift builder and ring files stay, default is /etc/swift | ||
| 153 | |||
| 154 | <command> can be one of the followings: | ||
| 155 | |||
| 156 | createrings : Create Swift account, container, and object builder | ||
| 157 | clean : Delete all Swift build and ring files | ||
| 158 | mountdevs : Mount all devices specified in cluster config file | ||
| 159 | unmountdevs : Un-mount all devices specified in cluster config file | ||
| 160 | formatdevs : Format all devices specified in cluster config file | ||
| 161 | adddevs : Add all devices specified in cluster config file into | ||
| 162 | Swift rings | ||
| 163 | |||
| 164 | swift_setup.sh script helps to create or expand Swift cluster with | ||
| 165 | storage devices in this machine. | ||
| 166 | |||
| 167 | The Swift cluster config file (default is /etc/swift/cluster.conf) describes | ||
| 168 | how storage devices in this machine can be added into Swift cluster. | ||
| 169 | |||
| 170 | Each line of cluster config file specifies how one storage device can be | ||
| 171 | added into Swift cluster with the following format: | ||
| 172 | |||
| 173 | <dev file>, <dev format>, <zone>, <ring names>, <weight> | ||
| 174 | |||
| 175 | <dev file>: full path to a block device or full path to regular | ||
| 176 | file which is used for backing up a loopback device. | ||
| 177 | If <dev file> is empty string then this device is | ||
| 178 | backed up by a directory in local filesystem. | ||
| 179 | <dev format>: the disk format type, e.g. ext4, xfs... | ||
| 180 | <zone>: the zone id which this block device belongs to | ||
| 181 | <ring names>: a list (separated by space) ring name ("account", "container", | ||
| 182 | or "object") which this device is added to | ||
| 183 | <weight>: weight of this device in Swift zone | ||
| 184 | |||
| 185 | |||
| 186 | Example 1: To add storage devices in this machine into an existing | ||
| 187 | Swift Cluster: | ||
| 188 | |||
| 189 | $ /etc/init.d/swift stop | ||
| 190 | $ Sync the Swift builders and rings files into this machine | ||
| 191 | $ Modify /etc/cluster.conf to specify what storage devices | ||
| 192 | are added into cluster | ||
| 193 | $ swift_setup.sh formatdevs | ||
| 194 | $ swift_setup.sh mountdevs | ||
| 195 | $ swift_setup.sh -i <IP of this machine> adddevs | ||
| 196 | $ swift_setup.sh unmountdevs | ||
| 197 | $ /etc/init.d/swift start | ||
| 198 | |||
| 199 | Example 2: To create an new Swift cluster: | ||
| 200 | |||
| 201 | $ /etc/init.d/swift stop | ||
| 202 | $ Modify /etc/cluster.conf to reflect the desired cluster | ||
| 203 | $ swift_setup.sh clean | ||
| 204 | $ swift_setup.sh createrings | ||
| 205 | $ swift_setup.sh formatdevs | ||
| 206 | $ swift_setup.sh mountdevs | ||
| 207 | $ swift_setup.sh -i <IP of this machine> adddevs | ||
| 208 | $ swift_setup.sh unmountdevs | ||
| 209 | $ /etc/init.d/swift start | ||
| 210 | EOF | ||
| 211 | } | ||
| 212 | |||
| 213 | |||
| 214 | cluster_conf="/etc/swift/cluster.conf" | ||
| 215 | swift_home="/etc/swift" | ||
| 216 | host_ip="127.0.0.1" | ||
| 217 | cluster_replica="2" | ||
| 218 | |||
| 219 | while getopts "?hc:r:i:k:" opt; do | ||
| 220 | case $opt in | ||
| 221 | c) | ||
| 222 | cluster_conf=$OPTARG | ||
| 223 | ;; | ||
| 224 | r) | ||
| 225 | cluster_replica=$OPTARG | ||
| 226 | ;; | ||
| 227 | i) | ||
| 228 | host_ip=$OPTARG | ||
| 229 | ;; | ||
| 230 | k) | ||
| 231 | swift_home=$OPTARG | ||
| 232 | ;; | ||
| 233 | ?|h) | ||
| 234 | help | ||
| 235 | exit 0 | ||
| 236 | ;; | ||
| 237 | esac | ||
| 238 | done | ||
| 239 | |||
| 240 | # Move aside the optional arguments | ||
| 241 | shift $(( $OPTIND - 1 )) | ||
| 242 | |||
| 243 | |||
| 244 | case "$1" in | ||
| 245 | createrings) | ||
| 246 | cluster_create_rings | ||
| 247 | ;; | ||
| 248 | clean) | ||
| 249 | for_each_dev_in_cluster unmount_dev | ||
| 250 | cluster_delete_all | ||
| 251 | ;; | ||
| 252 | mountdevs) | ||
| 253 | for_each_dev_in_cluster mount_dev | ||
| 254 | ;; | ||
| 255 | unmountdevs) | ||
| 256 | for_each_dev_in_cluster unmount_dev | ||
| 257 | ;; | ||
| 258 | formatdevs) | ||
| 259 | for_each_dev_in_cluster format_dev | ||
| 260 | ;; | ||
| 261 | adddevs) | ||
| 262 | cluster_add_devs | ||
| 263 | ;; | ||
| 264 | *) | ||
| 265 | help | ||
| 266 | exit 0 | ||
| 267 | ;; | ||
| 268 | esac | ||
| 269 | |||
| 270 | exit 0 | ||
diff --git a/meta-openstack/recipes-devtools/python/python-swift_git.bb b/meta-openstack/recipes-devtools/python/python-swift_git.bb index 6ab147d..680dbc3 100644 --- a/meta-openstack/recipes-devtools/python/python-swift_git.bb +++ b/meta-openstack/recipes-devtools/python/python-swift_git.bb | |||
| @@ -11,18 +11,29 @@ SRC_URI = "git://github.com/openstack/${SRCNAME}.git;branch=stable/havana \ | |||
| 11 | file://proxy-server.conf \ | 11 | file://proxy-server.conf \ |
| 12 | file://dispersion.conf \ | 12 | file://dispersion.conf \ |
| 13 | file://test.conf \ | 13 | file://test.conf \ |
| 14 | file://swift.init \ | ||
| 15 | file://swift_setup.sh \ | ||
| 16 | file://cluster.conf \ | ||
| 14 | " | 17 | " |
| 15 | 18 | ||
| 16 | SRCREV="2f3526c559fe53ce904b735a81dee6de46127176" | 19 | SRCREV="2f3526c559fe53ce904b735a81dee6de46127176" |
| 17 | PV="2013.2.2+git${SRCPV}" | 20 | PV="2013.2.2+git${SRCPV}" |
| 18 | S = "${WORKDIR}/git" | 21 | S = "${WORKDIR}/git" |
| 19 | 22 | ||
| 20 | inherit setuptools python-dir hosts identity | 23 | inherit setuptools python-dir update-rc.d hosts identity |
| 24 | |||
| 25 | # The size of the backing file (in Gigabytes) of loopback devices | ||
| 26 | # which are used for setting up Swift storage devices. The value | ||
| 27 | # of "0G" is for disabling loopback devices and using local | ||
| 28 | # filesystem as Swift storage device. In this case, the local | ||
| 29 | # filesystem of must support xattrs. e.g ext4 | ||
| 30 | SWIFT_BACKING_FILE_SIZE ?= "2G" | ||
| 21 | 31 | ||
| 22 | do_install_append() { | 32 | do_install_append() { |
| 23 | SWIFT_CONF_DIR=${D}${sysconfdir}/swift | 33 | SWIFT_CONF_DIR=${D}${sysconfdir}/swift |
| 24 | 34 | ||
| 25 | install -d ${SWIFT_CONF_DIR} | 35 | install -d ${SWIFT_CONF_DIR} |
| 36 | install -d ${D}${sysconfdir}/init.d/ | ||
| 26 | 37 | ||
| 27 | install -m 600 ${S}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf | 38 | install -m 600 ${S}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf |
| 28 | install -m 600 ${WORKDIR}/proxy-server.conf ${SWIFT_CONF_DIR}/proxy-server.conf | 39 | install -m 600 ${WORKDIR}/proxy-server.conf ${SWIFT_CONF_DIR}/proxy-server.conf |
| @@ -31,6 +42,9 @@ do_install_append() { | |||
| 31 | install -m 600 ${S}/etc/object-server.conf-sample ${SWIFT_CONF_DIR}/object-server.conf | 42 | install -m 600 ${S}/etc/object-server.conf-sample ${SWIFT_CONF_DIR}/object-server.conf |
| 32 | install -m 600 ${WORKDIR}/dispersion.conf ${SWIFT_CONF_DIR}/dispersion.conf | 43 | install -m 600 ${WORKDIR}/dispersion.conf ${SWIFT_CONF_DIR}/dispersion.conf |
| 33 | install -m 600 ${WORKDIR}/test.conf ${SWIFT_CONF_DIR}/test.conf | 44 | install -m 600 ${WORKDIR}/test.conf ${SWIFT_CONF_DIR}/test.conf |
| 45 | install -m 755 ${WORKDIR}/swift.init ${D}${sysconfdir}/init.d/swift | ||
| 46 | install -m 700 ${WORKDIR}/swift_setup.sh ${SWIFT_CONF_DIR}/swift_setup.sh | ||
| 47 | install -m 600 ${WORKDIR}/cluster.conf ${SWIFT_CONF_DIR}/cluster.conf | ||
| 34 | 48 | ||
| 35 | sed 's/^# bind_port =.*/bind_port = 6002/' -i ${SWIFT_CONF_DIR}/account-server.conf | 49 | sed 's/^# bind_port =.*/bind_port = 6002/' -i ${SWIFT_CONF_DIR}/account-server.conf |
| 36 | sed 's/^# user =.*/user = root/' -i ${SWIFT_CONF_DIR}/account-server.conf | 50 | sed 's/^# user =.*/user = root/' -i ${SWIFT_CONF_DIR}/account-server.conf |
| @@ -71,7 +85,32 @@ do_install_append() { | |||
| 71 | grep -rl '^from test' ${D}/${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/test | xargs sed 's/^from test/from swift\.test/g' -i | 85 | grep -rl '^from test' ${D}/${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/test | xargs sed 's/^from test/from swift\.test/g' -i |
| 72 | } | 86 | } |
| 73 | 87 | ||
| 74 | PACKAGES += "${SRCNAME}-tests ${SRCNAME}" | 88 | pkg_postinst_${SRCNAME}-setup () { |
| 89 | if [ "x$D" != "x" ]; then | ||
| 90 | exit 1 | ||
| 91 | fi | ||
| 92 | |||
| 93 | CLUSTER_CONF=/etc/swift/cluster.conf | ||
| 94 | SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh' | ||
| 95 | |||
| 96 | for i in `seq 1 3`; do | ||
| 97 | BACKING_FILE=/etc/swift/swift_backing_$i | ||
| 98 | if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then | ||
| 99 | truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE | ||
| 100 | sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i $CLUSTER_CONF | ||
| 101 | else | ||
| 102 | sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF | ||
| 103 | fi | ||
| 104 | done | ||
| 105 | |||
| 106 | $SWIFT_SETUP createrings | ||
| 107 | $SWIFT_SETUP formatdevs | ||
| 108 | $SWIFT_SETUP mountdevs | ||
| 109 | $SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs | ||
| 110 | $SWIFT_SETUP unmountdevs | ||
| 111 | } | ||
| 112 | |||
| 113 | PACKAGES += "${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup" | ||
| 75 | 114 | ||
| 76 | FILES_${PN} = "${libdir}/*\ | 115 | FILES_${PN} = "${libdir}/*\ |
| 77 | " | 116 | " |
| @@ -79,6 +118,11 @@ FILES_${PN} = "${libdir}/*\ | |||
| 79 | FILES_${SRCNAME}-tests = "${sysconfdir}/${SRCNAME}/test.conf \ | 118 | FILES_${SRCNAME}-tests = "${sysconfdir}/${SRCNAME}/test.conf \ |
| 80 | " | 119 | " |
| 81 | 120 | ||
| 121 | FILES_${SRCNAME}-setup = "${sysconfdir}/init.d/swift \ | ||
| 122 | ${sysconfdir}/${SRCNAME}/swift_setup.sh \ | ||
| 123 | ${sysconfdir}/${SRCNAME}/cluster.conf \ | ||
| 124 | " | ||
| 125 | |||
| 82 | FILES_${SRCNAME} = "${bindir}/* \ | 126 | FILES_${SRCNAME} = "${bindir}/* \ |
| 83 | ${sysconfdir}/${SRCNAME}/* \ | 127 | ${sysconfdir}/${SRCNAME}/* \ |
| 84 | " | 128 | " |
| @@ -101,3 +145,10 @@ RDEPENDS_${PN} += " \ | |||
| 101 | " | 145 | " |
| 102 | 146 | ||
| 103 | RDEPENDS_${SRCNAME} = "${PN}" | 147 | RDEPENDS_${SRCNAME} = "${PN}" |
| 148 | |||
| 149 | RDEPENDS_${SRCNAME} = "${PN}" | ||
| 150 | RDEPENDS_${SRCNAME}-setup = "${SRCNAME}" | ||
| 151 | |||
| 152 | INITSCRIPT_PACKAGES = "${SRCNAME}-setup" | ||
| 153 | INITSCRIPT_NAME_${SRCNAME}-setup = "swift" | ||
| 154 | INITSCRIPT_PARAMS_${SRCNAME}-setup = "defaults" | ||
