6429922e99
Now that we have a shade version of the launch node script adding in support for attaching a cinder volume is simple. Do this so that launching mirrors which rely on cinder volumes is simpler. This updates the mount_volume.sh script to setup the first cinder volume with lvm and mount it under the specified path. It will also install lvm2 pacakges since they may not be present on all base images. This updates the make_swap.sh script to avoid blindly using /dev/vdb as the location for swap as this may be a cinder volume or config drive. We add availability zone, device specification, mount path, and fs label support to shade-launch-node.py as these are all necessary inputs to properly mount a cinder volume in a VM. Change-Id: Ie95fd4bd5fca8df4f8046d43d1333935cad567e3
51 lines
1.5 KiB
Bash
51 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
DEVICE=$1
|
|
MOUNT_PATH=$2
|
|
FS_LABEL=$3
|
|
|
|
# Because images may not have all the things we need.
|
|
if which apt-get ; then
|
|
apt-get update && apt-get install -y lvm2
|
|
elif which yum ; then
|
|
yum -y install lvm2
|
|
fi
|
|
|
|
# Sanity check that we don't break anything that already has an fs.
|
|
if ! blkid | grep $DEVICE ; then
|
|
set -e
|
|
parted --script $DEVICE mklabel msdos mkpart primary 0% 100% set 1 lvm on
|
|
partprobe -s $DEVICE
|
|
pvcreate ${DEVICE}1
|
|
vgcreate main ${DEVICE}1
|
|
lvcreate -l 100%FREE -n $FS_LABEL main
|
|
mkfs.ext4 -m 0 -j -L $FS_LABEL /dev/main/$FS_LABEL
|
|
tune2fs -i 0 -c 0 /dev/main/$FS_LABEL
|
|
|
|
# Remove existing fstab entries for this device.
|
|
perl -nle "m,/dev/main/$FS_LABEL, || print" -i /etc/fstab
|
|
|
|
if [ ! -d $MOUNT_PATH ] ; then
|
|
mkdir -p $MOUNT_PATH
|
|
fi
|
|
|
|
echo "/dev/main/$FS_LABEL $MOUNT_PATH ext4 errors=remount-ro,barrier=0 0 2" >> /etc/fstab
|
|
mount -a
|
|
else
|
|
exit 1
|
|
fi
|