Merge "Backport vbox scripts from fuel 6.0 to 4.1" into stable/4.1

This commit is contained in:
Jenkins 2015-04-28 21:18:26 +00:00 committed by Gerrit Code Review
commit 1a67e0a5ac
17 changed files with 429 additions and 87 deletions

18
virtualbox/README.md Normal file → Executable file
View File

@ -1,6 +1,20 @@
VirtualBox environment kit
==========================
Requirements
------------
- VirtualBox with VirtualBox Extension Pack
- procps
- expect
- Cygwin for Windows host PC
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". it will automatically pick up the iso, and will spin up master node and slave nodes
- 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.
If there are any errors, the script will report them and abort.

View File

@ -0,0 +1,46 @@
#!/bin/bash
# Copyright 2014 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 script check available memory on host PC for quality provision VMs via VirtualBox
#
source ./config.sh
source ./functions/memory.sh
total_memory=$(get_available_memory $os_type)
if [ $total_memory -eq -1 ]; then
echo "Launch without checking RAM on host PC"
echo "Auto check memory is unavailable, you need install 'top' and 'free'. Please install procps package."
else
# Count selected RAM configuration
for machine_number in $(eval echo {1..$cluster_size}); do
if [ -n "${vm_slave_memory_mb[$machine_number]}" ]; then
vm_total_mb=$(( $vm_total_mb + ${vm_slave_memory_mb[$machine_number]} ))
else
vm_total_mb=$(( $vm_total_mb + $vm_slave_memory_default ))
fi
done
vm_total_mb=$(( $vm_total_mb + $vm_master_memory_mb ))
# Do not run VMs if host PC not have enough RAM
can_allocate_mb=$(( ($total_memory - 524288) / 1024 ))
if [ $vm_total_mb -gt $can_allocate_mb ]; then
echo "Your host has not enough memory."
echo "You can allocate no more than ${can_allocate_mb}MB, but trying to run VMs with ${vm_total_mb}MB"
exit 1
fi
fi

View File

@ -0,0 +1,28 @@
#!/bin/bash
# set -x
# Copyright 2014 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 script performs initial check and configuration of the host system. It:
# - check that there is no previous installation of Mirantis OpenStack (if there is one, the script deletes it)
# Include the script with handy functions to operate VMs and VirtualBox networking
source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
# Delete all VMs from the previous Mirantis OpenStack installation
delete_vms_multiple $vm_name_prefix

View File

@ -0,0 +1,35 @@
#!/bin/bash
# set -x
# Copyright 2014 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 script performs initial check and configuration of the host system. It:
# - creates host-only network interfaces
#
# Include the script with handy functions to operate VMs and VirtualBox networking
source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
# Delete all host-only interfaces
delete_all_hostonly_interfaces
# Create the required host-only interfaces
# Change {0..2} to {0..4} below if you are going to create 5 interfaces instead of 3
for idx in $(eval echo {0..2}); do
create_hostonly_interface "${host_nic_name[$idx]}" ${host_nic_ip[$idx]} ${host_nic_mask[$idx]}
done

View File

@ -20,14 +20,12 @@
#
# Include the handy functions to operate VMs and track ISO installation progress
source config.sh
source functions/vm.sh
source functions/product.sh
source ./config.sh
source ./functions/vm.sh
source ./functions/product.sh
# Create master node for the product
name="${vm_name_prefix}master"
delete_vm $name
echo
create_vm $name "${host_nic_name[0]}" $vm_master_cpu_cores $vm_master_memory_mb $vm_master_disk_mb
echo
@ -44,6 +42,10 @@ mount_iso_to_vm $name $iso_path
echo
start_vm $name
if [ "$skipfuelmenu" = "yes" ]; then
wait_for_fuel_menu $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"
fi
# Wait until the machine gets installed and Puppet completes its run
wait_for_product_vm_to_install $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"
@ -54,3 +56,5 @@ enable_outbound_network_for_product_vm $vm_master_ip $vm_master_username $vm_mas
echo
echo "Master node has been installed."
#Sleep 10s to wait for Cobbler to settle
sleep 10

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
# Copyright 2013 Mirantis, Inc.
#
@ -22,13 +22,12 @@
# Typically, you would use this script after time after rebooting VirtualBox VM with the master node.
# Include the handy functions to operate VMs and track ISO installation progress
source config.sh
source functions/vm.sh
source functions/product.sh
source ./config.sh
source ./functions/vm.sh
source ./functions/product.sh
# Master node name
name="${vm_name_prefix}master"
# Enable outbound network/internet access for the machine
enable_outbound_network_for_product_vm $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt" 3 $vm_master_nat_gateway

View File

@ -18,16 +18,22 @@
#
# 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
# - check that there is no previous installation of Mirantis OpenStack (if there is one, the script deletes it)
# - creates host-only network interfaces
#
# We are avoiding using 'which' because of http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
#
# Include the script with handy functions to operate VMs and VirtualBox networking
source config.sh
source functions/vm.sh
source functions/network.sh
source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
# Check for procps package
if [ "$(uname -s | cut -c1-6)" = "CYGWIN" ]; then
echo -n "Checking for 'top' and 'free'"
free -V >/dev/null 2>&1 || { echo >&2 " \"free\" is not available in the path, but it's required. Please install \"procps\" package. Aborting."; exit 1; }
top -v >/dev/null 2>&1 || { echo >&2 " \"top\" is not available in the path, but it's required. Please install \"procps\" package. Aborting."; exit 1; }
echo "OK"
fi
# Check for expect
echo -n "Checking for 'expect'... "
@ -57,6 +63,7 @@ if [ -z $iso_path ]; then
exit 1
fi
echo "OK"
echo "Going to use Mirantis OpenStack ISO file $iso_path"
# Check if SSH is installed. Cygwin does not install SSH by default.
echo "Checking if SSH client installed... "
@ -92,18 +99,5 @@ case "$(uname)" in
esac
echo "OK"
# Delete all VMs from the previous Mirantis OpenStack installation
delete_vms_multiple $vm_name_prefix
# Delete all host-only interfaces
delete_all_hostonly_interfaces
# Create the required host-only interfaces
# Change {0..2} to {0..4} below if you are going to create 5 interfaces instead of 3
for idx in $(eval echo {0..2}); do
create_hostonly_interface "${host_nic_name[$idx]}" ${host_nic_ip[$idx]} ${host_nic_mask[$idx]}
done
# Report success
echo "Setup is done."

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
# Copyright 2013 Mirantis, Inc.
#
@ -20,19 +20,19 @@
#
# Include the handy functions to operate VMs
source config.sh
source functions/vm.sh
source ./config.sh
source ./functions/vm.sh
# Create and start slave nodes
for idx in $(eval echo {1..$cluster_size}); do
name="${vm_name_prefix}slave-${idx}"
echo
delete_vm $name
vm_ram=${vm_slave_memory_mb[$idx]}
[ -z $vm_ram ] && vm_ram=$vm_slave_memory_default
echo
create_vm $name "${host_nic_name[0]}" $vm_slave_cpu_cores $vm_ram $vm_slave_first_disk_mb
vm_cpu=${vm_slave_cpu[$idx]}
[ -z $vm_cpu ] && vm_cpu=$vm_slave_cpu_default
echo
create_vm $name "${host_nic_name[0]}" $vm_cpu $vm_ram $vm_slave_first_disk_mb
# Add additional NICs to VM
if [ ${#host_nic_name[*]} -gt 1 ]; then
for nic in $(eval echo {1..$((${#host_nic_name[*]}-1))}); do
@ -43,8 +43,9 @@ for idx in $(eval echo {1..$cluster_size}); do
echo
add_disk_to_vm $name 1 $vm_slave_second_disk_mb
add_disk_to_vm $name 2 $vm_slave_third_disk_mb
enable_network_boot_for_vm $name
# The delay required for downloading tftp boot image
sleep 10
start_vm $name
done
@ -53,4 +54,3 @@ echo
echo "Slave nodes have been created. They will boot over PXE and get discovered by the master node."
echo "To access master node, please point your browser to:"
echo " http://${vm_master_ip}:8000/"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
# Copyright 2013 Mirantis, Inc.
#
@ -14,11 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
# The number of nodes for installing OpenStack on
# - for minimal non-HA installation, specify 2 (1 controller + 1 compute)
# - for minimal non-HA with Cinder installation, specify 3 (1 ctrl + 1 compute + 1 cinder)
# - for minimal HA installation, specify 4 (3 controllers + 1 compute)
cluster_size=3
source ./functions/memory.sh
# Get the first available ISO from the directory 'iso'
iso_path=`ls -1t iso/*.iso 2>/dev/null | head -1`
@ -39,8 +35,13 @@ idx=0
for ip in 10.20.0.1 172.16.0.1 172.16.1.1 ; do
# VirtualBox for Windows has different virtual NICs naming and indexing
case "$(uname)" in
Linux | Darwin)
Linux)
host_nic_name[$idx]=vboxnet$idx
os_type="linux"
;;
Darwin)
host_nic_name[$idx]=vboxnet$idx
os_type="darwin"
;;
CYGWIN*)
if [ $idx -eq 0 ]; then
@ -48,6 +49,7 @@ for ip in 10.20.0.1 172.16.0.1 172.16.1.1 ; do
else
host_nic_name[$idx]='VirtualBox Host-Only Ethernet Adapter #'$((idx+1))
fi
os_type="cygwin"
;;
*)
echo "$(uname) is not supported operating system."
@ -61,7 +63,7 @@ done
# Master node settings
vm_master_cpu_cores=1
vm_master_memory_mb=1024
vm_master_memory_mb=1536
vm_master_disk_mb=65535
# Master node access to the internet through the host system, using VirtualBox NAT adapter
@ -77,21 +79,84 @@ vm_master_username=root
vm_master_password=r00tme
vm_master_prompt='root@fuel ~]#'
# Slave node settings
vm_slave_cpu_cores=1
# The number of nodes for installing OpenStack on
# - for minimal non-HA installation, specify 2 (1 controller + 1 compute)
# - for minimal non-HA with Cinder installation, specify 3 (1 ctrl + 1 compute + 1 cinder)
# - for minimal HA installation, specify 4 (3 controllers + 1 compute)
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
fi
# Slave node settings. This section allows you to define CPU count for each slave node.
# You can specify CPU count for your nodes as you wish, but keep in mind resources of your machine.
# If you don't, then will be used default parameter
if [ "$CONFIG_FOR" = "16GB" ]; then
vm_slave_cpu_default=1
vm_slave_cpu[1]=1
vm_slave_cpu[2]=1
vm_slave_cpu[3]=1
vm_slave_cpu[4]=1
vm_slave_cpu[5]=1
elif [ "$CONFIG_FOR" = "8GB" ]; then
vm_slave_cpu_default=1
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
vm_slave_cpu[1]=1
vm_slave_cpu[2]=1
vm_slave_cpu[3]=1
fi
# This section allows you to define RAM size in MB for each slave node.
# Keep in mind that PXE boot might not work correctly with values lower than 768.
# You can specify memory size for the specific slaves, other will get default vm_slave_memory_default
# Mirantis OpenStack 3.2 controllers require 1280 MiB of RAM as absolute minimum due to Heat!
vm_slave_memory_default=1536
# You may comment out all the following memory parameters to use default value for each node.
# It is recommended if you going to try HA configurations.
# for controller node at least 1.5Gb is required if you also run Ceph and Heat on it
# and for Ubuntu controller we need 2Gb of ram
vm_slave_memory_mb[1]=2048
vm_slave_memory_mb[2]=1024 # for compute node 1GB is recommended, otherwise VM instances in OpenStack may not boot
vm_slave_memory_mb[3]=1024 # for dedicated Cinder, 768Mb is OK, but Ceph needs 1Gb minimum
# For compute node 1GB is recommended, otherwise VM instances in OpenStack may not boot
# For dedicated Cinder, 768Mb is OK, but Ceph needs 1Gb minimum
if [ "$CONFIG_FOR" = "16GB" ]; then
vm_slave_memory_default=1536
vm_slave_memory_mb[1]=2048
vm_slave_memory_mb[2]=2048
vm_slave_memory_mb[3]=2048
vm_slave_memory_mb[4]=2048
vm_slave_memory_mb[5]=2048
elif [ "$CONFIG_FOR" = "8GB" ]; then
vm_slave_memory_default=1024
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
vm_slave_memory_mb[1]=2048
vm_slave_memory_mb[2]=1024
vm_slave_memory_mb[3]=1024
fi
# Within demo cluster created by this script, all slaves (controller
# and compute nodes) will have identical disk configuration. Each
@ -103,3 +168,7 @@ vm_slave_memory_mb[3]=1024 # for dedicated Cinder, 768Mb is OK, but Ceph needs
vm_slave_first_disk_mb=65535
vm_slave_second_disk_mb=65535
vm_slave_third_disk_mb=65535
# Set to 1 to run VirtualBox in headless mode
headless=0
skipfuelmenu="no"

56
virtualbox/functions/memory.sh Executable file
View File

@ -0,0 +1,56 @@
#!/bin/bash
# Copyright 2014 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 to get available memory on host PC
get_available_memory() {
os_type=$1
local total_memory=""
# Check available commands and RAM on host PC
if [ "$os_type" = "linux" ]; then
# running on linux
if [ "$(which free)" != "" ]; then
# using free
total_memory=$(LANG=C free | grep Mem | awk '{print $2}')
elif [ "$(which top)" != "" ]; then
# using top
total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }')
else
total_memory="-1"
fi
elif [ "$os_type" = "darwin" ]; then
# running on mac os darwin
if [ "$(which sysctl)" != "" ]; then
# using sysctl
total_memory=$(sysctl -n hw.memsize)
total_memory=$(( $total_memory / 1024 ))
else
total_memory="-1"
fi
elif [ "$os_type" = "cygwin" ]; then
# running on cygwin
if [ "$(which free)" != "" ]; then
# using free
total_memory=$(LANG=C free | grep Mem | awk '{print $2}')
elif [ "$(which top)" != "" ]; then
# using top
total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }')
else
total_memory="-1"
fi
fi
echo $total_memory
}

View File

@ -149,4 +149,3 @@ delete_all_hostonly_interfaces() {
VBoxManage hostonlyif remove "$interface"
done
}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
# Copyright 2013 Mirantis, Inc.
#
@ -18,14 +18,66 @@
# and Fuel became operational, and also enabling outbound network/internet access for this VM through the
# host system
ssh_options='-oConnectTimeout=5 -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null -oRSAAuthentication=no'
ssh_options='-oConnectTimeout=5 -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null -oRSAAuthentication=no -oPubkeyAuthentication=no'
wait_for_fuel_menu() {
ip=$1
username=$2
password=$3
prompt=$4
echo "Waiting for Fuel Menu so it can be skipped. Please do NOT abort the script..."
# Loop until master node gets successfully installed
maxdelay=3000
while ! skip_fuel_menu $ip $username $password "$prompt"; do
sleep 5
((waited += 5))
if (( waited >= maxdelay )); then
echo "Installation timed out! ($maxdelay seconds)" 1>&2
exit 1
fi
done
}
skip_fuel_menu() {
ip=$1
username=$2
password=$3
prompt=$4
# Log in into the VM, see if Fuel Setup is running or puppet already started
# Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
result=$(
expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
send "pgrep 'fuelmenu|puppet';echo \"returns $?\"\r"
expect "$prompt"
ENDOFEXPECT
)
if [[ "$result" =~ "returns 0" ]]; then
echo "Skipping Fuel Setup..."
expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
send "killall -w -SIGUSR1 fuelmenu\r"
expect "$prompt"
ENDOFEXPECT
return 0
else
return 1
fi
}
is_product_vm_operational() {
ip=$1
username=$2
password=$3
prompt=$4
# Log in into the VM, see if Puppet has completed its run
# Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
result=$(
@ -48,7 +100,6 @@ ENDOFEXPECT
OIFS="${IFS}"
NIFS=$'\n'
IFS="${NIFS}"
for line in $result; do
IFS="${OIFS}"
if [[ $line == Finished* ]]; then
@ -57,7 +108,6 @@ ENDOFEXPECT
fi
IFS="${NIFS}"
done
return 1
}
@ -66,12 +116,16 @@ wait_for_product_vm_to_install() {
username=$2
password=$3
prompt=$4
echo "Waiting for product VM to install. Please do NOT abort the script..."
# Loop until master node gets successfully installed
maxdelay=3000
while ! is_product_vm_operational $ip $username $password "$prompt"; do
sleep 5
((waited += 5))
if (( waited >= maxdelay )); then
echo "Installation timed out! ($maxdelay seconds)" 1>&2
exit 1
fi
done
}
@ -152,7 +206,6 @@ ENDOFEXPECT
OIFS="${IFS}"
NIFS=$'\n'
IFS="${NIFS}"
for line in $result; do
IFS="${OIFS}"
if [[ $line == *icmp_seq* ]]; then
@ -162,20 +215,15 @@ ENDOFEXPECT
fi
IFS="${NIFS}"
done
echo "FAIL"
print_no_internet_connectivity_banner
return 1
}
print_no_internet_connectivity_banner() {
echo "############################################################"
echo "# WARNING: some of the Fuel features will not be supported #"
echo "# (e.g. RHOS/RHEL integration) because there is #"
echo "# no Internet connectivity #"
echo "############################################################"
}

View File

@ -17,15 +17,15 @@
# This file contains the functions to manage VMs in through VirtualBox CLI
get_vm_base_path() {
echo -e `VBoxManage list systemproperties | grep '^Default machine folder' | sed 's/^Default machine folder\:[ \t]*//'`
echo `VBoxManage list systemproperties | grep '^Default machine folder' | sed 's/^Default machine folder\:[ \t]*//'`
}
get_vms_running() {
echo -e `VBoxManage list runningvms | sed 's/[ \t]*{.*}//' | sed 's/^"//' | sed 's/"$//'`
echo `VBoxManage list runningvms | sed 's/[ \t]*{.*}//' | sed 's/^"//' | sed 's/"$//'`
}
get_vms_present() {
echo -e `VBoxManage list vms | sed 's/[ \t]*{.*}//' | sed 's/^"//' | sed 's/"$//'`
echo `VBoxManage list vms | sed 's/[ \t]*{.*}//' | sed 's/^"//' | sed 's/"$//'`
}
is_vm_running() {
@ -40,15 +40,32 @@ is_vm_running() {
fi
}
is_vm_present() {
name=$1
list=$(get_vms_present)
if [[ $list = *$name* ]]; then
return 0
else
return 1
fi
}
create_vm() {
name=$1
nic=$2
cpu_cores=$3
memory_mb=$4
disk_mb=$5
# Create virtual machine with the right name and type (assuming CentOS)
VBoxManage createvm --name $name --ostype RedHat_64 --register
os='RedHat_64'
# There is a chance that some files are left from previous VM instance
vm_base_path=$(get_vm_base_path)
vm_path="$vm_base_path/$name/"
rm -rf "$vm_path"
# Create virtual machine with the right name and type (assuming CentOS)
VBoxManage createvm --name $name --ostype $os --register
# Set the real-time clock (RTC) operate in UTC time
# Set memory and CPU parameters
@ -57,6 +74,7 @@ create_vm() {
# Configure main network interface for management/PXE network
add_hostonly_adapter_to_vm $name 1 "$nic"
VBoxManage modifyvm $name --boot1 disk --boot2 dvd --boot3 net --boot4 none
# Configure storage controllers
VBoxManage storagectl $name --name 'IDE' --add ide --hostiocache on
@ -101,7 +119,7 @@ add_disk_to_vm() {
vm_disk_path="$(get_vm_base_path)/$vm_name/"
disk_name="${vm_name}_${port}"
disk_filename="${disk_name}.vdi"
VBoxManage createhd --filename "$vm_disk_path/$disk_name" --size $disk_mb --format VDI
VBoxManage createhd --filename "$vm_disk_path/$disk_filename" --size $disk_mb --format VDI
VBoxManage storageattach $vm_name --storagectl 'SATA' --port $port --device 0 --type hdd --medium "$vm_disk_path/$disk_filename"
}
@ -115,23 +133,24 @@ delete_vm() {
VBoxManage controlvm $name poweroff
fi
# Virtualbox does not fully delete VM file structure, so we need to delete the corresponding directory with files as well
if [ -d "$vm_path" ]; then
echo "Deleting existing virtual machine $name..."
echo "Deleting existing virtual machine $name..."
while is_vm_present $name
do
VBoxManage unregistervm $name --delete
rm -rf "$vm_path"
fi
done
# Virtualbox does not fully delete VM file structure, so we need to delete the corresponding directory with files as well
rm -rf "$vm_path"
}
delete_vms_multiple() {
name_prefix=$1
list=$(get_vms_present)
# Loop over the list of VMs and delete them, if its name matches the given refix
# Loop over the list of VMs and delete them, if its name matches the given refix
for name in $list; do
if [[ $name == $name_prefix* ]]; then
echo "Found existing VM: $name. Deleting it..."
delete_vm $name
delete_vm $name
fi
done
}
@ -140,14 +159,17 @@ start_vm() {
name=$1
# Just start it
#VBoxManage startvm $name --type headless
VBoxManage startvm $name
if [[ $headless == 1 ]]; then
VBoxManage startvm $name --type headless
else
VBoxManage startvm $name
fi
}
mount_iso_to_vm() {
name=$1
iso_path=$2
# Mount ISO to the VM
VBoxManage storageattach $name --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium "$iso_path"
}
@ -156,6 +178,6 @@ enable_network_boot_for_vm() {
name=$1
# Set the right boot priority
VBoxManage modifyvm $name --boot1 disk --boot2 net --boot3 none --boot4 none --nicbootprio1 1
VBoxManage modifyvm $name --boot1 net --boot2 disk --boot3 none --boot4 none --nicbootprio1 1
}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash
# Copyright 2013 Mirantis, Inc.
#
@ -14,12 +14,31 @@
# License for the specific language governing permissions and limitations
# under the License.
# add VirtualBox directory to PATH
case "$(uname)" in
CYGWIN*)
vbox_path_registry=`cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Oracle/VirtualBox/InstallDir`
vbox_path=`cygpath "$vbox_path_registry"| sed -e 's%/$%%'`
export PATH=$PATH:$vbox_path
;;
*)
;;
esac
# Prepare the host system
./actions/prepare-environment.sh || exit 1
# Check availble memory on the host system
./actions/check-available-memory.sh || exit 1
# clean previous installation if exists
./actions/clean-previous-installation.sh || exit 1
# create host-only interfaces
./actions/create-interfaces.sh || exit 1
# Create and launch master node
./actions/master-node-create-and-install.sh || exit 1
# Create and launch slave nodes
./actions/slave-nodes-create-and-boot.sh || exit 1

3
virtualbox/launch_16GB.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
CONFIG_FOR="16GB" ./launch.sh

3
virtualbox/launch_4GB.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
CONFIG_FOR="4GB" ./launch.sh

3
virtualbox/launch_8GB.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
CONFIG_FOR="8GB" ./launch.sh