37e257913c
Added Dockerfile and configuration files under the new `docker` directory to build a Swift All in One container image. The primary goal of this container image is to provide application developers with a Swift/S3 endpoint that can be tested against during the development cycle. Added Zuul jobs to build docker container Change-Id: Ib10975a1862a4fa8c4eeaba139837cf1f22b272a
63 lines
1.9 KiB
Plaintext
Executable File
63 lines
1.9 KiB
Plaintext
Executable File
#!/usr/bin/with-contenv sh
|
|
|
|
cd /etc/swift
|
|
DEV_SIZE="1GB"
|
|
# POLICIES="object container account"
|
|
MY_STORAGE_TYPE=${STORAGE_TYPE:-"internal_dirs"}
|
|
MY_DEVICE_COUNT=${DEVICE_COUNT:-6}
|
|
|
|
echo "[[ checking --privileged ]]"
|
|
ip link add dummy0 type dummy >/dev/null
|
|
if [[ $? -eq 0 ]]; then
|
|
PRIVILEGED=true
|
|
# clean the dummy0 link
|
|
ip link delete dummy0 >/dev/null
|
|
else
|
|
PRIVILEGED=false
|
|
fi
|
|
|
|
echo "storage type is $MY_STORAGE_TYPE. container is privileged? $PRIVILEGED"
|
|
|
|
echo "[[ checking what to use as storage devices ]]"
|
|
DEVICE_LIST=""
|
|
if [[ $MY_STORAGE_TYPE == "external_devices" ]]; then
|
|
DEVICE_LIST=$(ls /dev/ | grep -i "swift-d")
|
|
MY_DEVICE_COUNT=$(wc -w $DEVICE_LIST)
|
|
echo " using external device. devices found: $DEVICE_LIST"
|
|
elif [[ $MY_DEVICE_COUNT -le 0 ]]; then
|
|
echo "Device count must be greater than 0"
|
|
exit -1
|
|
else
|
|
for i in $(seq 0 $(( MY_DEVICE_COUNT-1 ))); do
|
|
DEVICE_LIST="$DEVICE_LIST swift-d$i"
|
|
done
|
|
# echo " using internal devices. devices to create: $DEVICE_LIST"
|
|
fi
|
|
|
|
if [[ $MY_STORAGE_TYPE == "internal_devices" ]]; then
|
|
for device in $DEVICE_LIST; do
|
|
truncate -s $DEV_SIZE /dev/$device;
|
|
echo " created storage device /dev/swift-d$i of $DEV_SIZE";
|
|
done
|
|
fi
|
|
|
|
export PATH=$PATH:/opt/python/usr/local/bin/
|
|
|
|
echo "[[ creating directories ]]"
|
|
for dir in $DEVICE_LIST; do
|
|
mkdir -p /srv/node/$dir;
|
|
echo " created /srv/node/$dir";
|
|
done
|
|
|
|
if [[ $MY_STORAGE_TYPE == "internal_devices" ]] || [[ $MY_STORAGE_TYPE == "external_devices" ]]; then
|
|
echo "[[ formating and mounting storage devices ]] "
|
|
for device in $DEVICE_LIST; do
|
|
# truncate -s $DEV_SIZE /dev/swift-d$i;
|
|
# echo "created storage device /dev/swift-d$i of $DEV_SIZE";
|
|
mkfs.xfs -f -L D$i -i size=512 /dev/$device;
|
|
echo " created XFS file system on device /dev/$device";
|
|
mount -t xfs -o noatime,nodiratime,logbufs=8 /dev/$device /srv/node/$device;
|
|
echo " mounted /dev/$device as /srv/node/$device";
|
|
done
|
|
fi
|