| ... | ... |
@@ -19,6 +19,9 @@ set -o xtrace |
| 19 | 19 |
# Settings |
| 20 | 20 |
# ======== |
| 21 | 21 |
|
| 22 |
+# Use stackrc and localrc for settings |
|
| 23 |
+source ./stackrc |
|
| 24 |
+ |
|
| 22 | 25 |
HOST=${HOST:-localhost}
|
| 23 | 26 |
|
| 24 | 27 |
# Nova original used project_id as the *account* that owned resources (servers, |
| ... | ... |
@@ -33,7 +36,7 @@ export NOVA_PROJECT_ID=${TENANT:-demo}
|
| 33 | 33 |
export NOVA_USERNAME=${USERNAME:-demo}
|
| 34 | 34 |
|
| 35 | 35 |
# With Keystone you pass the keystone password instead of an api key. |
| 36 |
-export NOVA_API_KEY=${PASSWORD:-secrete}
|
|
| 36 |
+export NOVA_API_KEY=${ADMIN_PASSWORD:-secrete}
|
|
| 37 | 37 |
|
| 38 | 38 |
# With the addition of Keystone, to use an openstack cloud you should |
| 39 | 39 |
# authenticate against keystone, which returns a **Token** and **Service |
| ... | ... |
@@ -82,6 +85,15 @@ glance -A $TOKEN index |
| 82 | 82 |
# Let's grab the id of the first AMI image to launch |
| 83 | 83 |
IMAGE=`glance -A $TOKEN index | egrep ami | cut -d" " -f1` |
| 84 | 84 |
|
| 85 |
+# Security Groups |
|
| 86 |
+# --------------- |
|
| 87 |
+SECGROUP=test_secgroup |
|
| 88 |
+ |
|
| 89 |
+# List of secgroups: |
|
| 90 |
+nova secgroup-list |
|
| 91 |
+ |
|
| 92 |
+# Create a secgroup |
|
| 93 |
+nova secgroup-create $SECGROUP "test_secgroup description" |
|
| 85 | 94 |
|
| 86 | 95 |
# Flavors |
| 87 | 96 |
# ------- |
| ... | ... |
@@ -92,9 +104,9 @@ nova flavor-list |
| 92 | 92 |
# and grab the first flavor in the list to launch |
| 93 | 93 |
FLAVOR=`nova flavor-list | head -n 4 | tail -n 1 | cut -d"|" -f2` |
| 94 | 94 |
|
| 95 |
-NAME="firstpost" |
|
| 95 |
+NAME="myserver" |
|
| 96 | 96 |
|
| 97 |
-nova boot --flavor $FLAVOR --image $IMAGE $NAME |
|
| 97 |
+nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP |
|
| 98 | 98 |
|
| 99 | 99 |
# let's give it 10 seconds to launch |
| 100 | 100 |
sleep 10 |
| ... | ... |
@@ -113,10 +125,47 @@ ping -c1 -w1 $IP || true |
| 113 | 113 |
sleep 5 |
| 114 | 114 |
|
| 115 | 115 |
ping -c1 -w1 $IP |
| 116 |
+# allow icmp traffic |
|
| 117 |
+nova secgroup-add-rule $SECGROUP icmp -1 -1 0.0.0.0/0 |
|
| 118 |
+ |
|
| 119 |
+# List rules for a secgroup |
|
| 120 |
+nova secgroup-list-rules $SECGROUP |
|
| 121 |
+ |
|
| 122 |
+# allocate a floating ip |
|
| 123 |
+nova floating-ip-create |
|
| 124 |
+ |
|
| 125 |
+# store floating address |
|
| 126 |
+FIP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed 's/ //g'` |
|
| 127 |
+ |
|
| 128 |
+# add floating ip to our server |
|
| 129 |
+nova add-floating-ip $NAME $FIP |
|
| 130 |
+ |
|
| 131 |
+# sleep for a smidge |
|
| 132 |
+sleep 1 |
|
| 133 |
+ |
|
| 134 |
+# ping our fip |
|
| 135 |
+ping -c1 -w1 $FIP |
|
| 136 |
+ |
|
| 137 |
+# dis-allow icmp traffic |
|
| 138 |
+nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 |
|
| 139 |
+ |
|
| 140 |
+# sleep for a smidge |
|
| 141 |
+sleep 1 |
|
| 142 |
+ |
|
| 143 |
+# ping our fip |
|
| 144 |
+if ( ping -c1 -w1 $FIP); then |
|
| 145 |
+ print "Security group failure - ping should not be allowed!" |
|
| 146 |
+ exit 1 |
|
| 147 |
+fi |
|
| 148 |
+ |
|
| 149 |
+# de-allocate the floating ip |
|
| 150 |
+nova floating-ip-delete $FIP |
|
| 116 | 151 |
|
| 117 | 152 |
# shutdown the server |
| 118 | 153 |
nova delete $NAME |
| 119 | 154 |
|
| 155 |
+# Delete a secgroup |
|
| 156 |
+nova secgroup-delete $SECGROUP |
|
| 157 |
+ |
|
| 120 | 158 |
# FIXME: validate shutdown within 5 seconds |
| 121 | 159 |
# (nova show $NAME returns 1 or status != ACTIVE)? |
| 122 |
- |
| ... | ... |
@@ -290,6 +290,13 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` |
| 290 | 290 |
# be owned by the installation user, we create the directory and change the |
| 291 | 291 |
# ownership to the proper user. |
| 292 | 292 |
function git_clone {
|
| 293 |
+ # if there is an existing checkout, move it out of the way |
|
| 294 |
+ if [[ "$RECLONE" == "yes" ]]; then |
|
| 295 |
+ if [ -d $2 ]; then |
|
| 296 |
+ mv $2 /tmp/stack.`date +%s` |
|
| 297 |
+ fi |
|
| 298 |
+ fi |
|
| 299 |
+ |
|
| 293 | 300 |
if [ ! -d $2 ]; then |
| 294 | 301 |
sudo mkdir $2 |
| 295 | 302 |
sudo chown `whoami` $2 |
| ... | ... |
@@ -297,13 +304,6 @@ function git_clone {
|
| 297 | 297 |
cd $2 |
| 298 | 298 |
# This checkout syntax works for both branches and tags |
| 299 | 299 |
git checkout $3 |
| 300 |
- elif [[ "$RESET_BRANCHES" == "yes" ]]; then |
|
| 301 |
- cd $2 |
|
| 302 |
- git remote set-url origin $1 |
|
| 303 |
- git fetch origin |
|
| 304 |
- git checkout origin/$3 |
|
| 305 |
- git branch -D $3 |
|
| 306 |
- git checkout -b $3 |
|
| 307 | 300 |
fi |
| 308 | 301 |
} |
| 309 | 302 |
|
| ... | ... |
@@ -125,6 +125,7 @@ fi |
| 125 | 125 |
# Make sure that base requirements are installed |
| 126 | 126 |
chroot $CACHEDIR apt-get update |
| 127 | 127 |
chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
| 128 |
+chroot $CACHEDIR apt-get install -y --download-only rabbitmq-server libvirt-bin mysql-server |
|
| 128 | 129 |
chroot $CACHEDIR pip install `cat files/pips/*` |
| 129 | 130 |
|
| 130 | 131 |
# Clean out code repos if directed to do so |
| ... | ... |
@@ -137,10 +138,12 @@ mkdir -p $CACHEDIR/$DEST |
| 137 | 137 |
git_clone $NOVA_REPO $CACHEDIR/$DEST/nova $NOVA_BRANCH |
| 138 | 138 |
git_clone $GLANCE_REPO $CACHEDIR/$DEST/glance $GLANCE_BRANCH |
| 139 | 139 |
git_clone $KEYSTONE_REPO $CACHEDIR/$DESTkeystone $KEYSTONE_BRANCH |
| 140 |
-git_clone $NOVNC_REPO $CACHEDIR/$DEST/novnc $NOVNC_BRANCH |
|
| 140 |
+git_clone $NOVNC_REPO $CACHEDIR/$DEST/noVNC $NOVNC_BRANCH |
|
| 141 | 141 |
git_clone $DASH_REPO $CACHEDIR/$DEST/dash $DASH_BRANCH $DASH_TAG |
| 142 | 142 |
git_clone $NOVACLIENT_REPO $CACHEDIR/$DEST/python-novaclient $NOVACLIENT_BRANCH |
| 143 | 143 |
git_clone $OPENSTACKX_REPO $CACHEDIR/$DEST/openstackx $OPENSTACKX_BRANCH |
| 144 |
+git_clone $KEYSTONE_REPO $CACHEDIR/$DEST/keystone $KEYSTONE_BRANCH |
|
| 145 |
+git_clone $NOVNC_REPO $CACHEDIR/$DEST/novnc $NOVNC_BRANCH |
|
| 144 | 146 |
|
| 145 | 147 |
# Use this version of devstack? |
| 146 | 148 |
if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then |