-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkconf-drive
executable file
·22 lines (22 loc) · 1013 Bytes
/
mkconf-drive
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
set -e
if [ -z "$1" ]
then
echo "Reads first argument as name of the instance for which it will create a config drive"
exit 1
fi
source ${0%/*}/config
if [ ! -f /var/lib/libvirt/images/$INSTANCE_NAME-config.iso ]; then
INSTANCE_NAME=$1
cp -R $config_drive_tmpl /tmp/$INSTANCE_NAME-config_drive
config_drive=/tmp/$INSTANCE_NAME-config_drive
ln -s 2012-08-10 /tmp/$INSTANCE_NAME-config_drive/openstack/latest
sed -i s/INSTANCE_NAME/$INSTANCE_NAME/ $config_drive/openstack/latest/meta_data.json
sed -i s/INSTANCE_NAME/$INSTANCE_NAME/ $config_drive/openstack/latest/user_data
sed -i s"#SSH_KEY#$PUBKEY#" $config_drive/openstack/latest/user_data
$MKISOCMD -J -r -V config-2 -o /tmp/$INSTANCE_NAME-config.iso /tmp/$INSTANCE_NAME-config_drive
#rm -rf /tmp/$INSTANCE_NAME-config_drive
virsh -c $CONNECTION vol-create-as --pool $POOL $INSTANCE_NAME-config.iso 1 --format raw
virsh -c $CONNECTION vol-upload --pool $POOL $INSTANCE_NAME-config.iso /tmp/$INSTANCE_NAME-config.iso
else
echo "Config iso already exists"
fi