Virtualbox Scripts minor enhancements

1.split prepare-environment.sh into 3 actions. 2. add VBoxManage path to
PATH. 3. create_vm() function able to create VMs with different OS types

Implements blueprint virtualbox-scripts-enhancements

Change-Id: I4d34ba3f39af8becbbe8dc700d57dd5ea8cce0ee
This commit is contained in:
Vasiliy Pleshakov 2014-03-05 15:02:43 +04:00
parent ed172addc5
commit 6a55e02170
5 changed files with 84 additions and 16 deletions

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

@ -18,8 +18,6 @@
#
# 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
#
@ -92,18 +90,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

@ -46,9 +46,10 @@ create_vm() {
cpu_cores=$3
memory_mb=$4
disk_mb=$5
os=${6:-'RedHat_64'}
# Create virtual machine with the right name and type (assuming CentOS)
VBoxManage createvm --name $name --ostype RedHat_64 --register
VBoxManage createvm --name $name --ostype $os --register
# Set the real-time clock (RTC) operate in UTC time
# Set memory and CPU parameters

View File

@ -14,9 +14,28 @@
# 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
# 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