forked from dguerri/dockerstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_openstack.sh
More file actions
executable file
·92 lines (75 loc) · 2.5 KB
/
Copy pathsetup_openstack.sh
File metadata and controls
executable file
·92 lines (75 loc) · 2.5 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
83
84
85
86
87
88
89
90
91
92
#! /usr/bin/env bash
#
# Copyright (c) 2015 Davide Guerri <davide.guerri@gmail.com>
#
# 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.
#
set -uexo pipefail
DOWNLOAD_DIR="$HOME/downloads"
CIDR="10.29.29.0/24"
GATEWAY="10.29.29.1"
START_IP="10.29.29.20"
END_IP="10.29.29.200"
DNS="10.29.29.1"
IMAGES=(
"http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
"https://cloud-images.ubuntu.com/vivid/current/vivid-server-cloudimg-amd64-disk1.img"
"https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img"
"https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2"
)
# -------------------------------------
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
download_if_not_exists() {
local url="$1"
local filename="$(basename $1)"
if [ ! -d "$DOWNLOAD_DIR" ]; then
mkdir "$DOWNLOAD_DIR"
fi
if [ ! -f "$DOWNLOAD_DIR/$filename" ]; then
curl -L -s -o "$DOWNLOAD_DIR/$filename" "$url"
fi
}
# -- [ Neutron
neutron net-create \
--shared \
--router:external \
--provider:network_type flat \
--provider:physical_network external \
external
neutron subnet-create \
--name external \
--gateway "$GATEWAY"\
--allocation-pool "start=$START_IP,end=$END_IP" \
--enable-dhcp \
--dns-nameserver "$DNS" \
external \
"$CIDR"
# -- [ Glance
for image in "${IMAGES[@]}"; do
download_if_not_exists "$image"
image_basename="$(basename $image)"
image_name="${image_basename%.*}"
openstack image create \
--public \
--container-format bare \
--disk-format qcow2 \
--file "$DOWNLOAD_DIR/$image_basename" \
"$image_name"
done
# -- [ Nova Key Pair
nova keypair-add --pub-key ~/.ssh/id_rsa.pub keyp1
# -- [ Nova default secgroup rules
nova secgroup-add-rule default tcp 1 65535 0.0.0.0/0
nova secgroup-add-rule default udp 1 65535 0.0.0.0/0
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0