Last active
July 16, 2018 23:36
-
-
Save abelboldu/b06e491374b760773ffec68b8515cff1 to your computer and use it in GitHub Desktop.
Openstack quick smoke test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Installing dependencies..." | |
APT=`command -v apt-get` || true | |
YUM=`command -v yum` || true | |
if [[ "$APT" != "" ]]; then | |
apt-get update > /dev/null; sudo apt-get install -qqy sshpass > /dev/null | |
elif [[ "$YUM" != "" ]]; then | |
yum -y install sshpass >> /dev/null | |
else | |
echo "Distro unsupported." | |
exit 1 | |
fi | |
echo "Loading environment..." | |
. /root/keystonerc_admin | |
echo "Creating network topology..." | |
neutron net-create private | |
neutron subnet-create --name private_subnet private 192.168.0.0/24 | |
sleep 1 | |
neutron router-create router | |
neutron router-gateway-set router public | |
neutron router-interface-add router private_subnet | |
sleep 2 | |
echo "Creating security groups..." | |
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 | |
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 | |
echo "Waiting nova to be up..." | |
sleep 8 | |
echo "Creating instances..." | |
nova boot --flavor nano --image "CirrOS 0.3.3" --nic net-id=`neutron net-list | grep private | awk '{print $2}'` c1 | |
nova boot --flavor nano --image "CirrOS 0.3.3" --nic net-id=`neutron net-list | grep private | awk '{print $2}'` c2 | |
echo "Adding floating IPs..." | |
neutron floatingip-create public | |
neutron floatingip-create public | |
nova add-floating-ip c1 200.200.200.3 | |
nova add-floating-ip c2 200.200.200.4 | |
echo "Waiting for instances to be up..." | |
sleep 30 | |
echo "Testing inner connectivity..." | |
cat << 'EOF' > ~/.ssh/config | |
Host 200.200.200.* | |
stricthostkeychecking no | |
UserKnownHostsFile /dev/null | |
EOF | |
# IP Forwarding + masquerade | |
sysctl -w net.ipv4.ip_forward=1 | |
iptables -t nat -I POSTROUTING -o eth0 -s 200.200.200.0/24 -j MASQUERADE | |
iptables -I FORWARD -s 200.200.200.0/24 -j ACCEPT | |
iptables -I FORWARD -d 200.200.200.0/24 -j ACCEPT | |
sshpass -p "cubswin:)" ssh cirros@200.200.200.3 ping -c2 200.200.200.4 | |
echo "Checking metadata..." | |
sshpass -p "cubswin:)" ssh -q cirros@200.200.200.3 curl -s http://169.254.169.254/latest/meta-data/hostname; echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment