Fix PATH issue for VirtualBox on Windows

The support to deploy on a remote machine is broke the
default behaviour on the Windows OS, so now it always
needs to set the $PATH manually before using the scripts.

Also, the new functionality didn't work on the remote
Windows machine because the scripts change the $PATH on
the local system only.

This commit adds some more checks and fixes the local
$PATH setup. It didn't check remote system requirements
so deploy on a remote machine still have some problems.
Added several messages in the scripts.

Also this commit contain increased timeouts to fix
failures during network interfaces add/change operations
on some Windows systems.

Change-Id: If5dadc1ece3931f42eac423aae4d7016d45c2040
Closes-Bug: #1534129
Partial-Bug: #1491925
This commit is contained in:
Maksim Malchuk 2016-01-15 16:54:13 +03:00
parent 85e5cf4817
commit 5cdbcc30d1
12 changed files with 166 additions and 58 deletions

View File

@ -7,6 +7,8 @@ Requirements
- VirtualBox with VirtualBox Extension Pack
- procps
- expect
- openssh-client
- xxd
- Cygwin for Windows host PC
- Enable VT-x/AMD-V acceleration option on your hardware for 64-bits guests
@ -17,6 +19,9 @@ 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\_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 you run this script under Cygwin, you may have to add path to VirtualBox directory to your PATH.
Usually it is enough to run: export PATH=$PATH:/cygdrive/c/Program Files/Oracle/VirtualBox
If there are any errors, the script will report them and abort.
If you want to change settings (number of OpenStack nodes, CPU, RAM, HDD), please refer to "config.sh".
@ -31,3 +36,9 @@ The variable REMOTE_PORT allows to specify custom port for ssh.
# or
REMOTE_HOST=user@user.mos.mirantis.net REMOTE_PORT=23 ./launch_8GB.sh
```
TODO
----
- add the ability to use Boot ROM during the remote deploy
- add the new (even smaller) Boot ROM with iPXE HTTP enabled

View File

@ -26,7 +26,7 @@ source ./functions/vm.sh
source ./functions/network.sh
echo "Deleting old interfaces if exists..."
if [[ "$rm_network" == "0" ]]; then
if [[ "${rm_network}" == "0" ]]; then
delete_fuel_ifaces
else
delete_all_hostonly_interfaces

View File

@ -24,7 +24,7 @@ source ./functions/vm.sh
source ./functions/network.sh
# Delete host-only interfaces
if [[ "$rm_network" == "0" ]]; then
if [[ "${rm_network}" == "0" ]]; then
delete_fuel_ifaces
else
delete_all_hostonly_interfaces

View File

@ -18,6 +18,7 @@
#
# This script performs initial check and configuration of the host system. It:
# - verifies that all available command-line tools are present on the host system
# - accepts one parameter value ('launch' or 'clean') which indicates how it is should be used
#
# We are avoiding using 'which' because of http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
#
@ -61,8 +62,6 @@ else
fi
# Check for VirtualBox
echo "If you run this script under Cygwin, you may have to add path to VirtualBox directory to your PATH. "
echo "Usually it is enough to run \"export PATH=\$PATH:\"/cygdrive/c/Program Files/Oracle/VirtualBox\" "
echo -n "Checking for \"VBoxManage\"... "
execute type VBoxManage >/dev/null 2>&1
if [ $? -eq 1 ]; then
@ -80,16 +79,25 @@ if [ "$extpacks" -le 0 ]; then
fi
echo "OK"
# execute some checks only in the 'launch' mode
if [ $1 == "launch" ]; then
# Check for VirtualBox iPXE firmware
echo -n "Checking for VirtualBox iPXE firmware..."
if [ -z $pxe_path ]; then
echo "SKIP"
echo "VirtualBox iPXE firmware is not found. Used standard firmware from the VirtualBox Extension Pack."
execute VBoxManage setextradata global VBoxInternal/Devices/pcbios/0/Config/LanBootRom
if [ -z "$REMOTE_HOST" ]; then
echo "VirtualBox iPXE firmware is not found. Used standard firmware from the VirtualBox Extension Pack."
execute VBoxManage setextradata global VBoxInternal/Devices/pcbios/0/Config/LanBootRom
fi
else
execute VBoxManage setextradata global VBoxInternal/Devices/pcbios/0/Config/LanBootRom "$(pwd)/$pxe_path" 2>/dev/null
echo "OK"
echo "Going to use iPXE boot firmware file $pxe_path"
if [ -z "$REMOTE_HOST" ]; then
execute VBoxManage setextradata global VBoxInternal/Devices/pcbios/0/Config/LanBootRom "$(pwd)/$pxe_path" 2>/dev/null
echo "Going to use iPXE boot firmware file $pxe_path"
else
echo "The iPXE boot on the remote system should be configured manually."
fi
fi
# Check for ISO image to be available
@ -104,6 +112,8 @@ echo "Going to use Mirantis OpenStack ISO file $iso_path"
# Copy ISO to host
copy_if_required $iso_path
fi # end 'launch' mode check
# Check if SSH is installed. Cygwin does not install SSH by default.
echo -n "Checking if SSH client installed... "
execute type ssh >/dev/null 2>&1

View File

@ -16,19 +16,20 @@
source ./functions/shell.sh
# Check remote host/port settings
check_remote_settings
# Add VirtualBox directory to PATH
case "$(execute uname)" in
CYGWIN*)
vbox_path_registry=`execute cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir`
vbox_path=`execute cygpath "$vbox_path_registry"| sed -e 's%/$%%'`
export PATH=$PATH:$vbox_path
;;
*)
;;
esac
add_virtualbox_path
# Shutdown installation and clean environment
./actions/prepare-environment.sh || exit 1
./actions/clean-previous-installation.sh || exit 1
./actions/delete-interfaces.sh || exit 1
echo "Prepare the host system..."
./actions/prepare-environment.sh clean || exit 1
echo
echo "Сlean previous installation if exists..."
./actions/clean-previous-installation.sh || exit 1
echo
echo "Deleting old interfaces if exists..."
./actions/delete-interfaces.sh || exit 1

View File

@ -42,10 +42,11 @@ 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"
# Determining the type of operating system and adding CPU core to the master node
# Determining the type of operating system, set global variables and adding CPU core to the master node
case "$(execute uname)" in
Linux)
os_type="linux"
net_sleep="2s"
if [ "$(execute nproc)" -gt "1" ]; then
vm_master_cpu_cores=2
else
@ -54,6 +55,7 @@ mask="255.255.255.0"
;;
Darwin)
os_type="darwin"
net_sleep="2s"
mac_nproc=`execute sysctl -a | grep machdep.cpu.thread_count | sed 's/^machdep.cpu.thread_count\:[ \t]*//'`
if [ "$mac_nproc" -gt "1" ]; then
vm_master_cpu_cores=2
@ -63,6 +65,7 @@ mask="255.255.255.0"
;;
CYGWIN*)
os_type="cygwin"
net_sleep="12s"
if [ "$(execute nproc)" -gt "1" ]; then
vm_master_cpu_cores=2
else

View File

@ -67,7 +67,7 @@ is_hostonly_interface_present() {
# Call VBoxManage directly instead of function, due to changed IFS
local found_iface=(`execute VBoxManage list hostonlyifs | egrep "Name: + $name\$" | awk '/Name/ { $1 = ""; print substr($0, 2) }'`)
# Change default divider back
case "$(execute uname)" in
case "$(uname)" in
CYGWIN*)
IFS=$OIFS
;;
@ -87,18 +87,23 @@ check_if_iface_settings_applied() {
ip=$2
mask=$3
echo "Verifying interface $name has IP $ip and mask $mask properly set."
OIFS=$IFS
case "$(execute uname)" in
case "$(uname)" in
CYGWIN*)
OIFS=$IFS
IFS=","
;;
*)
IFS=$OIFS
;;
esac
local new_name=(`execute VBoxManage list hostonlyifs | egrep -A9 "Name: + $name\$" | awk '/Name/ { $1 = ""; print substr($0, 2) }'`)
IFS=$OIFS
sleep 2s
case "$(uname)" in
CYGWIN*)
IFS=$OIFS
;;
*)
;;
esac
sleep ${net_sleep}
local new_ip=(`execute VBoxManage list hostonlyifs | egrep -A9 "Name: + $name\$" | awk '/IPAddress:/ { print $2 }'`)
local new_mask=(`execute VBoxManage list hostonlyifs | egrep -A9 "Name: + $name\$" | awk '/NetworkMask:/ { print $2 }'`)
local new_dhcp=(`execute VBoxManage list hostonlyifs | egrep -A9 "Name: + $name\$" | awk '/DHCP:/ { print $2 }'`)
@ -139,9 +144,9 @@ create_hostonly_interfaces() {
echo "Disabling DHCP server on interface: $name..."
# These magic 1 second sleeps around DHCP config are required under Windows/Cygwin
# due to VBoxSvc COM server accepts next request before previous one is actually finished.
sleep 2s
sleep ${net_sleep}
execute VBoxManage dhcpserver remove --ifname "$name" 2>/dev/null
sleep 2s
sleep ${net_sleep}
# Set up IP address and network mask
echo "Configuring IP address $ip and network mask $mask on interface: $name..."
execute VBoxManage hostonlyif ipconfig "$id" --ip $ip --netmask $mask
@ -173,15 +178,14 @@ delete_fuel_ifaces() {
local fuel_ifaces=$(get_fuel_ifaces)
if [ ! -z "$fuel_ifaces" ]; then
check_running_vms "$fuel_ifaces"
OIFS=$IFS
IFS=","
for interface in $fuel_ifaces; do
IFS=$OIFS
echo "Deleting host-only interface: $interface..."
execute VBoxManage hostonlyif remove "$interface"
check_removed_iface "$interface"
done
fi
unset IFS
echo "Done."
}
@ -190,14 +194,13 @@ delete_all_hostonly_interfaces() {
local all_hostonly_interfaces=$(get_hostonly_interfaces)
# Checking that the running virtual machines don't use removable host-only interfaces
check_running_vms $all_hostonly_interfaces
OIFS=$IFS
IFS=","
# Delete every single hostonly interface in the system
for interface in $all_hostonly_interfaces; do
IFS=$OIFS
echo "Deleting host-only interface: ${interface}..."
execute VBoxManage hostonlyif remove "${interface}"
check_removed_iface "${interface}"
done
unset IFS
echo "Done."
}

View File

@ -18,15 +18,6 @@
# Each command might be executed on the local machine or on the remote machine
# depending on environment settings
shell_ssh_options=""
shell_scp_options=""
if [ -n "$REMOTE_PORT" ]; then
shell_ssh_options="-p $REMOTE_PORT $shell_ssh_options"
shell_scp_options="-P $REMOTE_PORT $shell_scp_options"
fi
function execute() {
# use shell substitution pattern ${parameter/pattern/string}, to escape spaces in arguments.
if [ -n "$REMOTE_HOST" ]; then
@ -41,19 +32,20 @@ function execute() {
function copy_if_required() {
local source_path=$1
if [ -n "$REMOTE_HOST" ]; then
if ! execute test -f $source_path; then
local local_size=`wc -c <${source_path} 2>/dev/null`
local remote_size=`execute wc -c <${source_path} 2>/dev/null`
if [ "${local_size}" != "${remote_size}" ]; then
# the scripts always find iso in original path
# reconstruct same path on remote machine
local source_dir=$(dirname $source_path)
echo "Copying $source_path to $REMOTE_HOST:$source_path..."
execute mkdir -p $source_dir && copy $source_path $source_path || exit 1
else
echo "Skip copying the file $source_path, it already exists on $REMOTE_HOST."
echo "Skip copying the file $source_path, same file already exists on $REMOTE_HOST."
fi
fi
}
function copy() {
local src=$1
local dst=$2
@ -64,3 +56,55 @@ function copy() {
cp $src $dst
fi
}
# Add VirtualBox directory to PATH
function add_virtualbox_path() {
case "$(execute uname 2>/dev/null)" in
CYGWIN*)
execute type VBoxManage &>/dev/null
if [ $? -eq 1 ]; then
if [ -n "$REMOTE_HOST" ]; then
echo "When using the \$REMOTE_HOST it's required to add path to VirtualBox directory"
echo "to your PATH on remote system globaly in the remote system settings. Aborting."
exit 1
else
# check 64bit Windows registry branch
if [ -f /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir ]; then
vbox_path_registry=`cat /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir`
# check 32bit Windows registry branch
elif [ -f /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir ]; then
vbox_path_registry=`cat /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir`
# check default Windows registry branch
elif [ -f /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir ]; then
vbox_path_registry=`cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir`
else
# default override if registry lookup fails
vbox_path_registry='C:\Program Files\Oracle\VirtualBox\'
fi
vbox_path=`cygpath "$vbox_path_registry"| sed -e 's%/$%%'`
export PATH=$PATH:$vbox_path
fi
fi
;;
*)
;;
esac
}
# Check remote host/port settings
function check_remote_settings() {
if [ -n "$REMOTE_HOST" ]; then
echo
echo "WARNING! All the commands will be executed on the remote system: ${REMOTE_HOST}"
echo "WARNING! The remote system should be configured correctly. Please read the README.md file"
echo
fi
# configure ssh/scp options
if [ -n "$REMOTE_PORT" ]; then
shell_ssh_options="-p $REMOTE_PORT $shell_ssh_options"
shell_scp_options="-P $REMOTE_PORT $shell_scp_options"
else
shell_ssh_options=""
shell_scp_options=""
fi
}

View File

@ -1,5 +1,20 @@
#!/bin/bash -eu
# AT translated set 2 encoder
# Copyright 2015 Mirantis, Inc.
#
# 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.
# This file contains the functions for AT translated set 2 encoder
type xxd > /dev/null || exit 1

View File

@ -16,19 +16,14 @@
source ./functions/shell.sh
# Check remote host/port settings
check_remote_settings
# Add VirtualBox directory to PATH
case "$(execute uname)" in
CYGWIN*)
vbox_path_registry=`execute cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir`
vbox_path=`execute cygpath "$vbox_path_registry"| sed -e 's%/$%%'`
export PATH=$PATH:$vbox_path
;;
*)
;;
esac
add_virtualbox_path
echo "Prepare the host system..."
./actions/prepare-environment.sh || exit 1
./actions/prepare-environment.sh launch || exit 1
echo
echo "Check available memory on the host system..."

View File

@ -1,4 +1,17 @@
#!/bin/bash
CONFIG_FOR="16GB" ./launch.sh
# Copyright 2013 Mirantis, Inc.
#
# 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.
CONFIG_FOR="16GB" ./launch.sh

View File

@ -1,4 +1,17 @@
#!/bin/bash
CONFIG_FOR="8GB" ./launch.sh
# Copyright 2013 Mirantis, Inc.
#
# 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.
CONFIG_FOR="8GB" ./launch.sh