Merge ~nicolasbock/stsstack-bundles:fake_webserver into stsstack-bundles:master

Proposed by Nicolas Bock
Status: Rejected
Rejected by: Edward Hope-Morley
Proposed branch: ~nicolasbock/stsstack-bundles:fake_webserver
Merge into: stsstack-bundles:master
Diff against target: 51 lines (+45/-0)
1 file modified
openstack/tools/run_fake_webserver.sh (+45/-0)
Reviewer Review Type Date Requested Status
Felipe Reyes Needs Fixing
Review via email: mp+392344@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Felipe Reyes (freyes) :
review: Needs Fixing
Revision history for this message
Edward Hope-Morley (hopem) wrote :

The repository has moved to https://github.com/canonical/stsstack-bundles/. Please resubmit there if you are still working on this patch.

Unmerged commits

c92e8ba... by Nicolas Bock

Add script to create a fake webserver for Octavia

The `run_fake_webserver.sh` configures running cirros VMs to run a
fake webserver using netcat on port 80. This can be used to verify
that the health monitor that is created with the
`create_octavia_lb.sh` script works properly.

Signed-off-by: Nicolas Bock <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/openstack/tools/run_fake_webserver.sh b/openstack/tools/run_fake_webserver.sh
2new file mode 100755
3index 0000000..b2e770b
4--- /dev/null
5+++ b/openstack/tools/run_fake_webserver.sh
6@@ -0,0 +1,45 @@
7+#!/bin/bash
8+
9+# This script assumes that there is at least one server that was
10+# created with
11+#
12+# ./tools/instance_launch.sh N cirros (so the testkey.priv exists)
13+#
14+# and has a security group that allows ssh and http ports
15+#
16+# ./tools/sec_groups.sh
17+#
18+# The VM will get a floating IP and then run a fake HTTP server on
19+# port 80.
20+
21+set -x -u -e
22+
23+cirros_password=gocubsgo
24+
25+readarray -t member_vm < <(openstack server list --column ID --format value --name cirros)
26+(( ${#member_vm[@]} )) || { echo "ERROR: could not find a cirros vm to add to lb pool"; exit 1; }
27+
28+for member in ${member_vm[@]}; do
29+ IP=$(openstack server show --format value --column addresses ${member} | awk '{print $2}')
30+ if [[ -z ${IP} ]]; then
31+ echo "Attaching floating IP to member ${member}"
32+ IP=$(openstack floating ip create --format value --column floating_ip_address ext_net)
33+ openstack server add floating ip ${member} ${IP}
34+ while true; do
35+ if ping -c 1 ${IP}; then
36+ break
37+ fi
38+ sleep 1
39+ done
40+ fi
41+
42+ sshpass -p${cirros_password} ssh cirros@${IP} -- cat \> webserver.sh <<EOF
43+#!/bin/sh
44+
45+while true; do
46+ printf "HTTP/1.1 200 OK\n\n \$(date) from ${IP}\n" | sudo nc -l -p 80
47+done
48+EOF
49+ sshpass -p${cirros_password} ssh cirros@${IP} -- chmod 755 webserver.sh
50+ sshpass -p${cirros_password} ssh cirros@${IP} -- nohup ./webserver.sh > /dev/null 2>&1 &
51+done

Subscribers

People subscribed via source and target branches