Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix for VBox "No Internet connection on compute nodes"
Browse files Browse the repository at this point in the history
The scripts work without any firewall tuning on the user's computers.
The Fuel master node is forwarding the public network through
the existing NAT interface.

Change-Id: I2962bccb39828da4ff011889f990a67d89322ca3
Closes-Bug: #1288135
  • Loading branch information
Serhiy Ovsianikov committed May 14, 2015
1 parent daa0877 commit deda3b6
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 250 deletions.
2 changes: 1 addition & 1 deletion virtualbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Run

In order to successfully run Mirantis OpenStack under VirtualBox, you need to:
- download the official release (.iso) and place it under 'iso/' directory
- run "./launch.sh" (or "./launch\_4GB.sh", "./launch\_8GB.sh" or "./launch\_16GB.sh" according to your system resources). It will automatically pick up the iso and spin up master node and slave nodes
- run "./launch.sh" (or "./launch\_8GB.sh" or "./launch\_16GB.sh" according to your system resources). It will automatically pick up the iso and spin up master node and slave nodes

If there are any errors, the script will report them and abort.

Expand Down
188 changes: 0 additions & 188 deletions virtualbox/actions/add-firewall-rules.sh

This file was deleted.

33 changes: 0 additions & 33 deletions virtualbox/actions/enable-ip-forwarding.sh

This file was deleted.

16 changes: 2 additions & 14 deletions virtualbox/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ iso_path=`ls -1t iso/*.iso 2>/dev/null | head -1`
vm_name_prefix=fuel-

# By default, all available network interfaces vboxnet won't be removed,
# if their IP addresses don't match with fuel_master_ips (10.20.0.1 172.16.0.1
# if their IP addresses don't match with fuel_master_ips (10.20.0.1 172.16.0.254
# 172.16.1.1)
# If you want to remove all existing vbox interfaces, then use rm_network=1
# 0 - don't remove all vbox networks. Remove only fuel networks if they exist
Expand All @@ -36,7 +36,7 @@ rm_network=0
# 172.16.1.1/24 - OpenStack Fixed/Internal/Private network
# 192.168.0.1/24 - OpenStack Management network
# 192.168.1.1/24 - OpenStack Storage network (for Ceph, Swift etc)
fuel_master_ips="10.20.0.1 172.16.0.1 172.16.1.1"
fuel_master_ips="10.20.0.1 172.16.0.254 172.16.1.1"

# Network mask for fuel interfaces
mask="255.255.255.0"
Expand Down Expand Up @@ -99,8 +99,6 @@ if [ "$CONFIG_FOR" = "16GB" ]; then
cluster_size=5
elif [ "$CONFIG_FOR" = "8GB" ]; then
cluster_size=3
elif [ "$CONFIG_FOR" = "4GB" ]; then
cluster_size=2
else
# Section for custom configuration
cluster_size=3
Expand All @@ -124,11 +122,6 @@ elif [ "$CONFIG_FOR" = "8GB" ]; then
vm_slave_cpu[1]=1
vm_slave_cpu[2]=1
vm_slave_cpu[3]=1
elif [ "$CONFIG_FOR" = "4GB" ]; then
vm_slave_cpu_default=1

vm_slave_cpu[1]=1
vm_slave_cpu[2]=1
else
# Section for custom configuration
vm_slave_cpu_default=1
Expand Down Expand Up @@ -165,11 +158,6 @@ elif [ "$CONFIG_FOR" = "8GB" ]; then
vm_slave_memory_mb[1]=1536
vm_slave_memory_mb[2]=1536
vm_slave_memory_mb[3]=1536
elif [ "$CONFIG_FOR" = "4GB" ]; then
vm_slave_memory_default=1024

vm_slave_memory_mb[1]=1024
vm_slave_memory_mb[2]=1024
else
# Section for custom configuration
vm_slave_memory_default=1024
Expand Down
10 changes: 8 additions & 2 deletions virtualbox/functions/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ get_hostonly_interfaces() {
}

get_fuel_ifaces() {
local fuel_iface
local fuel_network=""
local fuel_networks=""
local fuel_iface=""
local fuel_ifaces=""
for ip in $fuel_master_ips; do
for i in $fuel_master_ips; do
fuel_network=$(echo "${i%.*}")
fuel_networks+="$fuel_network "
done
for ip in $fuel_networks; do
fuel_iface=`VBoxManage list hostonlyifs | grep -B5 $ip | grep '^Name' | sed 's/^Name\:[ \t]*//' | uniq | tr "\\n" ","`
fuel_ifaces+="$fuel_iface"
done
Expand Down
37 changes: 34 additions & 3 deletions virtualbox/functions/product.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ enable_outbound_network_for_product_vm() {
# Enable internet access on inside the VMs
echo -n "Enabling outbound network/internet access for the product VM... "

# Get network settings (ip address and ip network) for eth1 interface of the master node
local master_ip_pub_net=$(echo $fuel_master_ips | cut -f2 -d ' ')
master_ip_pub_net="${master_ip_pub_net%.*}"".1"
local master_pub_net="${master_ip_pub_net%.*}"".0"

# Log in into the VM, configure and bring up the NAT interface, set default gateway, check internet connectivity
# Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
result=$(
Expand All @@ -247,6 +252,20 @@ enable_outbound_network_for_product_vm() {
expect "$prompt"
send "sed \"s/DNS_UPSTREAM:.*/DNS_UPSTREAM: \\\$(grep \'^nameserver\' /etc/dnsmasq.upstream | cut -d \' \' -f2)/g\" -i /etc/fuel/astute.yaml\r"
expect "$prompt"
send "sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
expect "$prompt"
send "sed -i 's/NM_CONTROLLED=yes/NM_CONTROLLED=no/g' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
expect "$prompt"
send "sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=static/g' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
expect "$prompt"
send " echo \"IPADDR=$master_ip_pub_net\" >> /etc/sysconfig/network-scripts/ifcfg-eth1\r"
expect "$prompt"
send " echo \"NETMASK=$mask\" >> /etc/sysconfig/network-scripts/ifcfg-eth1\r"
expect "$prompt"
send "/sbin/iptables -t nat -A POSTROUTING -s $master_pub_net/24 \! -d $master_pub_net/24 -j MASQUERADE\r"
expect "$prompt"
send "service iptables save >/dev/null 2>&1\r"
expect "$prompt"
send "dockerctl restart cobbler >/dev/null 2>&1\r"
expect "$prompt"
send "service network restart >/dev/null 2>&1\r"
Expand All @@ -257,11 +276,23 @@ enable_outbound_network_for_product_vm() {
send "dockerctl check cobbler >/dev/null 2>&1\r"
expect "*ready*"
expect "$prompt"
send "for i in 1 2 3 4 5; do ping -c 2 google.com || ping -c 2 wikipedia.com || sleep 2; done\r"
expect "*icmp*"
ENDOFEXPECT
)

result_inet=$(
expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
send "rezult=$(for i in 1 2 3 4 5; do ping -c 2 google.com || ping -c 2 wikipedia.com || sleep 2; done)\r"
expect "$prompt"
send "echo $rezult\r"
expect "$prompt"
ENDOFEXPECT
)

# When you are launching command in a sub-shell, there are issues with IFS (internal field separator)
# and parsing output as a set of strings. So, we are saving original IFS, replacing it, iterating over lines,
# and changing it back to normal
Expand All @@ -271,7 +302,7 @@ ENDOFEXPECT
NIFS=$'\n'
IFS="${NIFS}"

for line in $result; do
for line in $result_inet; do
IFS="${OIFS}"
if [[ $line == *icmp_seq* ]]; then
IFS="${NIFS}"
Expand Down
8 changes: 6 additions & 2 deletions virtualbox/functions/vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ check_running_vms() {
OIFS=$IFS
IFS=","
local hostonly_interfaces=$1
local list_running_vms=`VBoxManage list runningvms | awk '{print $1}' | sed 's/"//g' | uniq | tr "\\n" ","`
for i in $list_running_vms; do
local list_running_vms=$(VBoxManage list runningvms | sed 's/\" {/\",{/g')
for vm_name in $list_running_vms; do
vm_name=$(echo $vm_name | grep "\"" | sed 's/"//g')
vm_names+="$vm_name,"
done
for i in $vm_names; do
for j in $hostonly_interfaces; do
running_vm=`VBoxManage showvminfo $i | grep "$j"`
if [[ $? -eq 0 ]]; then
Expand Down
3 changes: 0 additions & 3 deletions virtualbox/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ esac
# Сreate host-only interfaces
./actions/create-interfaces.sh || exit 1

# Enable IP forwarding on host computer
./actions/enable-ip-forwarding.sh || exit 1

# Create and launch master node
./actions/master-node-create-and-install.sh || exit 1

Expand Down
4 changes: 0 additions & 4 deletions virtualbox/launch_4GB.sh

This file was deleted.

0 comments on commit deda3b6

Please sign in to comment.