Changes to improve work under windows

Added check for procps in prepare-environment
Available memory check moved to separate action
Added requirements section in README
Fixed top and free check in Cygwin

Closes-Bug: #1373655

Change-Id: I2e700602fe7bb81464975521023f4693462b4379
(cherry picked from commit 7c98912407)
This commit is contained in:
Dmitry Tyzhnenko 2014-09-29 17:34:47 +03:00 committed by Serhiy Ovsianikov
parent f74730adf7
commit 4e62ea7e89
5 changed files with 71 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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; }

View File

@ -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

View File

@ -24,10 +24,10 @@ get_available_memory() {
# runing on linux
if [ "$(which free)" != "" ]; then
# using free
total_memory=$(free | grep Mem | awk '{print $2}')
elif [ $(which top) != '' ]; then
total_memory=$(LANG=C free | grep Mem | awk '{print $2}')
elif [ "$(which top)" != "" ]; then
# using top
total_memory=$(top -n 1 | grep "Mem:" | awk '{ print $4 }')
total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }')
else
total_memory="-1"
fi
@ -44,10 +44,10 @@ get_available_memory() {
# runing on cygwin
if [ "$(which free)" != "" ]; then
# using free
total_memory=$(free | grep Mem | awk '{print $2}')
elif [ $(which top) != '' ]; then
total_memory=$(LANG=C free | grep Mem | awk '{print $2}')
elif [ "$(which top)" != "" ]; then
# using top
total_memory=$(top -n 1 | grep "Mem:" | awk '{ print $4 }')
total_memory=$(LANG=C top -n 1 | grep "Mem:" | awk '{ print $4 }')
else
total_memory="-1"
fi