-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreatedevstack.sh
More file actions
executable file
·48 lines (38 loc) · 1.04 KB
/
createdevstack.sh
File metadata and controls
executable file
·48 lines (38 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash -x
# Parameters
INSTANCENAME="$1"
# Variable
UBUNTUURL="https://cloud-images.ubuntu.com/daily/server/trusty/current/trusty-server-cloudimg-amd64-disk1.img"
MOUNTDIR="/tmp/ubuntumount"
INSTANCEIMAGE="devstack-$INSTANCENAME.img"
INSTANCECFGDRIVE="$INSTANCENAME-config.iso"
# Check if mount folder exists
if [ -d "$MOUNTDIR" ]
then
echo "Directory $MOUNTDIR exists."
else
echo "Error: Directory $MOUNTDIR does not exists."
mkdir -p $MOUNTDIR
fi
# Check for nbd mod
lsmod | grep nbd >& /dev/null
if [ $? -eq 0 ]
then
echo "nbd has been loaded"
else
modprobe nbd max_part=16
fi
# Get latest Ubuntu image
wget $UBUNTUURL
# Copy new image
cp trusty-server-cloudimg-amd64-disk1.img $INSTANCEIMAGE
# Resize image
qemu-img resize $INSTANCEIMAGE +10GB
# Create cloud config drive
genisoimage -o $INSTANCECFGDRIVE.iso -V cidata -r -J files/meta-data files/user-data
# Copy image to libvirt
cp $INSTANCEIMAGE /var/lib/libvirt/images
cp $INSTANCECFGDRIVE /var/lib/libvirt/images
# Cleanup build folder
rm $INSTANCEIMAGE
rm $INSTANCECFGDRIVE