forked from openstack/devstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_image.sh
More file actions
executable file
·82 lines (73 loc) · 1.66 KB
/
upload_image.sh
File metadata and controls
executable file
·82 lines (73 loc) · 1.66 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# upload_image.sh - Upload Ubuntu images (create if necessary) in various formats
#
# upload_image.sh release format
#
# format target
# qcow2 kvm,qemu
# vmdk vmw6
# vbox vdi
# vhd vpc
HOST=${HOST:-demo.rcb.me}
PORT=${PORT:-9292}
usage() {
echo "$0 - Upload Ubuntu images"
echo ""
echo "$0 [-h host] [-p port] release format"
exit 1
}
while getopts h:p: c; do
case $c in
h) HOST=$OPTARG
;;
p) PORT=$OPTARG
;;
esac
done
shift `expr $OPTIND - 1`
RELEASE=$1
FORMAT=$2
case $RELEASE in
natty) ;;
maverick) ;;
lucid) ;;
karmic) ;;
jaunty) ;;
*) echo "Unknown release: $RELEASE"
usage
esac
case $FORMAT in
kvm|qcow2) FORMAT=qcow2
TARGET=kvm
;;
vmserver|vmdk) FORMAT=vmdk
TARGET=vmserver
;;
vbox|vdi) TARGET=kvm
FORMAT=vdi
;;
vhd|vpc) TARGET=kvm
FORMAT=vpc
;;
*) echo "Unknown format: $FORMAT"
usage
esac
GLANCE=`which glance`
if [ -z "$GLANCE" ]; then
echo "Glance not found, must install client"
sudo apt-get install python-pip python-eventlet python-routes python-greenlet python-argparse python-sqlalchemy python-wsgiref python-pastedeploy python-xattr
sudo pip install kombu
git clone https://github.com/cloudbuilders/glance.git
cd glance
sudo python setup.py develop
cd ..
GLANCE=`which glance`
fi
# Create image if it doesn't exist
if [ ! -r $RELEASE.$FORMAT ]; then
DIR=`dirname $0`
echo "$RELEASE.$FORMAT not found, creating...must be root to do this:"
$DIR/make_image.sh $RELEASE $FORMAT
fi
# Upload the image
$GLANCE add name=$RELEASE.$FORMAT is_public=true disk_format=$FORMAT --host $HOST --port $PORT <$RELEASE.$FORMAT