diff --git a/README.md b/README.md index 95b4d5a..ef76edb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +VirtualBox enviropment 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" (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 diff --git a/actions/check-available-memory.sh b/actions/check-available-memory.sh new file mode 100644 index 0000000..14530c2 --- /dev/null +++ b/actions/check-available-memory.sh @@ -0,0 +1,44 @@ +#!/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 availble memory on host PC for quality provision VMs via VirtualBox +# + +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 \ No newline at end of file diff --git a/actions/prepare-environment.sh b/actions/prepare-environment.sh index 8187c98..e386522 100755 --- a/actions/prepare-environment.sh +++ b/actions/prepare-environment.sh @@ -27,6 +27,12 @@ source config.sh source functions/vm.sh source functions/network.sh +# Check for procps package +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 \"procpc\" 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 \"procpc\" package. Aborting."; exit 1; } +echo "OK" + # Check for expect echo -n "Checking for 'expect'... " expect -v >/dev/null 2>&1 || { echo >&2 " \"expect\" is not available in the path, but it's required. Please install Tcl \"expect\" package. Aborting."; exit 1; } diff --git a/config.sh b/config.sh index 159970e..45cd20e 100755 --- a/config.sh +++ b/config.sh @@ -178,23 +178,3 @@ fi vm_slave_first_disk_mb=65535 vm_slave_second_disk_mb=65535 vm_slave_third_disk_mb=65535 - -total_memory=$(get_available_memory $os_type) - -# 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 diff --git a/functions/memory.sh b/functions/memory.sh index fa66900..09b3596 100644 --- a/functions/memory.sh +++ b/functions/memory.sh @@ -25,7 +25,7 @@ get_available_memory() { if [ "$(which free)" != "" ]; then # using free total_memory=$(LANG=C free | grep Mem | awk '{print $2}') - elif [ $(which top) != '' ]; then + elif [ "$(which top)" != "" ]; then # using top total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }') else @@ -45,7 +45,7 @@ get_available_memory() { if [ "$(which free)" != "" ]; then # using free total_memory=$(LANG=C free | grep Mem | awk '{print $2}') - elif [ $(which top) != '' ]; then + elif [ "$(which top)" != "" ]; then # using top total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }') else