Removed virtualbox scripts

Virtualbox scripts have been moved to a separate git
repository https://review.openstack.org/#/c/279074/

Change-Id: Ib7d38ff46fc9c632115c833287a45ac4f5b30ab2
This commit is contained in:
Vladimir Kozhukalov 2016-02-23 00:40:50 +03:00
parent 5766b810d8
commit ef9909a9b0
31 changed files with 3 additions and 3235 deletions

View File

@ -51,6 +51,9 @@ clean:
deep_clean: clean
sudo rm -rf $(LOCAL_MIRROR)
vbox-scripts:
echo "Target is deprecated. Virtualbox scripts have been moved to http://git.openstack.org/openstack/fuel-virtualbox.git"
# Common configuration file.
include $(SOURCE_DIR)/config.mk
@ -70,4 +73,3 @@ include $(SOURCE_DIR)/repos.mk
include $(SOURCE_DIR)/mirror/module.mk
include $(SOURCE_DIR)/packages/module.mk
include $(SOURCE_DIR)/iso/module.mk
include $(SOURCE_DIR)/virtualbox.mk

View File

@ -18,10 +18,6 @@ Directory structure:
RPM spec for fuel and fuel-release packages.
- ```utils```
Auxiliary scripts. (being deprecated)
- ```virtualbox```
Scripts that allow a user to try Fuel easily. Being run they start several virtual box
VMs. One of them is used for the Fuel master node and others are used as slave nodes
where Fuel installs an operating system and deploys OpenStack.
- ```Makefile```
It is the main GNU Make file which includes all other necessary GNU Make files.
- ```config.mk```
@ -36,5 +32,3 @@ Directory structure:
are listed here.
- ```sandbox.mk```
The script that is used for building chroot environments.
- ```virtualbox.mk```
The script that is used for preparing tarball archive with virtualbox scripts.

View File

@ -29,7 +29,6 @@ FUEL_LIBRARY_VERSION?=9.0
# Artifacts names
ISO_NAME?=fuel-$(PRODUCT_VERSION)
VBOX_SCRIPTS_NAME?=vbox-scripts-$(PRODUCT_VERSION)
# Where we put artifacts
ISO_PATH:=$(ARTS_DIR)/$(ISO_NAME).iso

View File

@ -1,9 +0,0 @@
########################
# VBOX-SCRIPTS ARTIFACT
########################
vbox-scripts: $(VBOX_SCRIPTS_PATH)
$(VBOX_SCRIPTS_PATH): \
$(call find-files,$(SOURCE_DIR)/virtualbox)
mkdir -p $(@D)
cd $(SOURCE_DIR) && zip -r $@ virtualbox

View File

@ -1,44 +0,0 @@
VirtualBox enviropment kit
==========================
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
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\_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".
To shutdown VMs and clean environment just run "./clean.sh"
To deploy on a remote machine just set environment variable REMOTE_HOST with ssh connection string.
The variable REMOTE_PORT allows to specify custom port for ssh.
```bash
REMOTE_HOST=user@user.mos.mirantis.net ./launch_8GB.sh
# 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

@ -1,48 +0,0 @@
#!/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)
if [ $total_memory -eq -1 ]; then
echo "Launch without checking RAM on host PC"
echo "Auto check memory is unavailable, you need install '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
echo "Done."

View File

@ -1,29 +0,0 @@
#!/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
echo "Done."

View File

@ -1,39 +0,0 @@
#!/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
echo "Deleting old interfaces if exists..."
if [[ "${rm_network}" == "0" ]]; then
delete_fuel_ifaces
else
delete_all_hostonly_interfaces
fi
echo
# Create the required host-only interfaces
for ip in $fuel_master_ips; do
create_hostonly_interfaces $ip
done

View File

@ -1,32 +0,0 @@
#!/bin/bash
# set -x
# 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 script deletes host-only network interfaces.
#
# Include scripts with handy functions to operate VMs and VirtualBox networking
source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
# Delete host-only interfaces
if [[ "${rm_network}" == "0" ]]; then
delete_fuel_ifaces
else
delete_all_hostonly_interfaces
fi

View File

@ -1,77 +0,0 @@
#!/bin/bash
# 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.
#
# This script creates a master node for the product, launches its installation,
# and waits for its completion
#
# Include the handy functions to operate VMs and track ISO installation progress
source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
source ./functions/product.sh
source ./functions/translate.sh
# Create master node for the product
# Get variables "host_nic_name" for the master node
get_fuel_name_ifaces
name="${vm_name_prefix}master"
# Create master node VM
create_vm $name "${host_nic_name[0]}" $vm_master_cpu_cores $vm_master_memory_mb $vm_master_disk_mb
# Add additional NICs
add_hostonly_adapter_to_vm $name 2 "${host_nic_name[1]}"
# Add NAT adapter for internet access
add_nat_adapter_to_vm $name 3 $vm_master_nat_network
# Mount ISO with installer
mount_iso_to_vm $name $iso_path
#add RDP connection
if [ ${headless} -eq 1 ]; then
enable_vrde $name ${RDPport}
fi
if [ "${skipfuelmenu}" = "yes" ]; then
boot_line="$(translate " vmlinuz $cmdline wait_for_external_config=yes showmenu=no"$'\n')"
else
boot_line="$(translate " vmlinuz $cmdline wait_for_external_config=yes"$'\n')"
fi
# Start virtual machine with the master node
echo
start_vm $name
echo
# Wait until product VM needs outbound network/internet access
wait_for_product_vm_to_download $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"
# 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"
# 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"
# Report success
echo
echo "Master node has been installed."
#Sleep 10s to wait for Cobbler to settle
sleep 10

View File

@ -1,34 +0,0 @@
#!/bin/bash
# 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.
#
# This script can be used as a handly utility to provide master node with the internet access
# It configures network interface inside the VM which is mapped to VirtualBox NAT adapter, and
# also configures default gateway.
#
# 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
# 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"

View File

@ -1,153 +0,0 @@
#!/bin/bash
# set -x
# 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.
#
# 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
#
# Include the script with handy functions to operate VMs and VirtualBox networking
source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
source ./functions/shell.sh
# Check for procps package
if [ "$(execute uname -s | cut -c1-6)" = "CYGWIN" ]; then
echo -n "Checking for 'free'... "
execute type free >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "\"free\" is not available in the path, but it's required. Please install the \"procps\" package. Aborting."
exit 1
else
echo "OK"
fi
fi
# Check for expect
echo -n "Checking for 'expect'... "
execute type expect >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "\"expect\" is not available in the path, but it's required. Please install Tcl \"expect\" package. Aborting."
exit 1
else
echo "OK"
fi
# Check for xxd
echo -n "Checking for 'xxd'... "
execute type xxd >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "\"xxd\" is not available in the path, but it's required. Please install the \"xxd\" package. Aborting."
exit 1
else
echo "OK"
fi
# Check for VirtualBox
echo -n "Checking for \"VBoxManage\"... "
execute type VBoxManage >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "\"VBoxManage\" is not available in the path, but it's required. Likely, VirtualBox is not installed. Aborting."
exit 1
else
echo "OK"
fi
# Check for VirtualBox Extension Pack
echo -n "Checking for VirtualBox Extension Pack... "
extpacks=`execute VBoxManage list extpacks | grep 'Usable' | grep 'true' | wc -l`
if [ "$extpacks" -le 0 ]; then
echo >&2 "VirtualBox Extension Pack is not installed. Please, download and install it from the official VirtualBox web site at https://www.virtualbox.org/wiki/Downloads"; exit 1;
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"
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
echo "OK"
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
echo -n "Checking for Mirantis OpenStack ISO image... "
if [ -z $iso_path ]; then
echo "Mirantis OpenStack image is not found. Please download it from software.mirantis.com and put under the 'iso' directory."
exit 1
fi
echo "OK"
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
if [ $? -eq 1 ]; then
echo "SSH client is not installed. Please install the \"openssh\" package if you run this script under Cygwin. Aborting."
exit 1
else
echo "OK"
fi
echo -n "Checking if ipconfig or ifconfig installed... "
case "$(execute uname)" in
Linux | Darwin)
if ! execute test -x /sbin/ifconfig ; then
echo "No ifconfig available at /sbin/ifconfig path! This path is hard-coded into VBoxNetAdpCtl utility."
echo "Please install ifconfig or create symlink to proper interface configuration utility. Aborting."
exit 1
fi
;;
CYGWIN*)
# Cygwin does not use ifconfig at all and even has no link to it.
# It uses built-in Windows ipconfig utility instead.
execute type ipconfig >/dev/null 2>&1
if [ $? -eq 1 ]; then
echo "No ipconfig available in Cygwin environment. Please check you can run ipconfig from Cygwin command prompt. Aborting."
exit 1
fi
;;
*)
echo "$(execute uname) is not supported operating system."
exit 1
;;
esac
echo "OK"
# Report success
echo "Done."

View File

@ -1,73 +0,0 @@
#!/bin/bash
# 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.
#
# This script creates slaves node for the product, launches its installation,
# and waits for its completion
#
# Include the handy functions to operate VMs
source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
# Get variables "host_nic_name" for the slave nodes
get_fuel_name_ifaces
# Create and start slave nodes
for idx in $(eval echo {1..$cluster_size}); do
name="${vm_name_prefix}slave-${idx}"
vm_ram=${vm_slave_memory_mb[$idx]}
[ -z $vm_ram ] && vm_ram=$vm_slave_memory_default
echo
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
add_hostonly_adapter_to_vm $name $((nic+1)) "${host_nic_name[${nic}]}"
done
fi
# Add additional disks to VM
echo
add_disk_to_vm $name 1 $vm_slave_second_disk_mb
add_disk_to_vm $name 2 $vm_slave_third_disk_mb
#add NIC1 MAC to description
mac=$(execute VBoxManage showvminfo $name --machinereadable |awk -F '=' '{ if ($1 == "macaddress1") print $2}')
execute VBoxManage modifyvm $name --description $mac
#add RDP connection
if [ ${headless} -eq 1 ]; then
enable_vrde $name $((${RDPport} + idx))
fi
enable_network_boot_for_vm $name
# The delay required for downloading tftp boot image
sleep 10
start_vm $name
done
# Report success
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/"
echo "The default username and password is admin:admin"

View File

@ -1,35 +0,0 @@
#!/bin/bash
# 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.
source ./functions/shell.sh
# Check remote host/port settings
check_remote_settings
# Add VirtualBox directory to PATH
add_virtualbox_path
# Shutdown installation and clean environment
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

@ -1,195 +0,0 @@
#!/bin/bash
# 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.
source ./functions/memory.sh
source ./functions/shell.sh
# Get the first available ISO from the directory 'iso'
iso_path=`ls -1t iso/*.iso 2>/dev/null | head -1`
# get the first available iPXE boot firmware from the directory 'drivers'
pxe_path=`ls -1t drivers/*.*rom 2>/dev/null | head -1`
# Every Mirantis OpenStack machine name will start from this prefix
vm_name_prefix=fuel-
# By default, all available vbox network interfaces will be removed.
# 0 - don't remove all vbox networks. Remove only fuel networks if they exist
# 1 - remove all vbox networks
rm_network=1
# Please add the IPs accordingly if you going to create non-default NICs number
# 10.20.0.1/24 - Mirantis OpenStack Admin network
# 172.16.0.1/24 - OpenStack Public/External/Floating network
# 172.16.1.1/24 - OpenStack Fixed/Internal/Private network
# 192.168.0.1/24 - OpenStack Management network
# 192.168.1.1/24 - OpenStack Storage network (for Ceph, Swift etc)
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, 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
vm_master_cpu_cores=1
fi
;;
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
else
vm_master_cpu_cores=1
fi
;;
CYGWIN*)
os_type="cygwin"
net_sleep="12s"
if [ "$(execute nproc)" -gt "1" ]; then
vm_master_cpu_cores=2
else
vm_master_cpu_cores=1
fi
;;
*)
echo "$(execute uname) is not supported operating system."
exit 1
;;
esac
# Master node settings
vm_master_memory_mb=1536
vm_master_disk_mb=65535
# Master node access to the internet through the host system, using VirtualBox NAT adapter
vm_master_nat_network=192.168.200.0/24
# These settings will be used to check if master node has installed or not.
# If you modify networking params for master node during the boot time
# (i.e. if you pressed Tab in a boot loader and modified params),
# make sure that these values reflect that change.
vm_master_ip=10.20.0.2
vm_master_username=root
vm_master_password=r00tme
vm_master_prompt='root@fuel ~]#'
# 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
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
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!
# 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
# 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
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
# slave will have three disks with sizes defined by the variables below. In a disk configuration
# dialog you will be able to allocate the whole disk or it's part for
# operating system (Base OS), VMs (Virtual Storage), Ceph or other function,
# depending on the roles applied to the server.
# Nodes with combined roles may require more disk space.
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
RDPport=5000
# set to "yes" if you want to boot the Fuel master node without the Fuel Menu. (enabling this will add an option "showmenu=no" to the kernel comdline so don't need to provide it below)
skipfuelmenu="no"
# use defaults from the isolinux.cfg if script started from the GitHub cloned repositoy files. otherwise use same defaults defined here.
cmdline="$(grep 'append initrd' ../iso/isolinux/isolinux.cfg -m1 2>/dev/null | sed -e 's/^[ ]*append[ ]*//')"
cmdline="${cmdline:-initrd=initrd.img net.ifnames=0 biosdevname=0 ks=hd:sr0:/ks.cfg ip=10.20.0.2::10.20.0.1:255.255.255.0:fuel.domain.tld:eth0:off::: dns1=10.20.0.1 selinux=0}"
# if you want to override the defaults feel free to uncomment and edit the line below
# cmdline="initrd=initrd.img net.ifnames=0 biosdevname=0 ks=hd:sr0:/ks.cfg ip=10.20.0.2::10.20.0.1:255.255.255.0:fuel.domain.tld:eth0:off::: dns1=10.20.0.1 selinux=0"

View File

@ -1,52 +0,0 @@
# iPXE - open source boot firmware for VirtualBox
This is a prebuilt binary version of **iPXE** as an **VirtualBox PXE ROM**.
The **iPXE** source code is maintained in a git repository. You can check out a copy of the code using:
```
git clone git://git.ipxe.org/ipxe.git
```
and build it using:
```
cd ipxe/src
make
```
You will need to have at least the following packages installed in order to build **iPXE**:
```
* gcc (version 3 or later)
* binutils (version 2.18 or later)
* make
* perl
* syslinux (for isolinux, only needed for building .iso images)
* liblzma or xz header files
* zlib, binutils and libiberty header files (only needed for EFI builds)
```
to build this **Intel 82540EM Gigabit Ethernet PXE ROM** for VirtualBox use:
```
make CONFIG=vbox bin/8086100e.isarom
```
Max size of a VirtualBox ROM is 56KB (57344 bytes).
There should be no need to pad the image as long as the binary is smaller or equal to this size.
To use the ROM in VirtualBox you need to enable it using this command:
```
vboxmanage setextradata global VBoxInternal/Devices/pcbios/0/Config/LanBootRom \
/absolute/path/to/8086100e.isarom
```
NB: If you build the ROM using the .rom prefix then it'll be built as a PCI
ROM, which won't work properly in VirtualBox. The error message you'll see
is "No more network devices", which is somewhat confusing. If you enter the
shell and use the "autoboot" command things will work as intended. Remember
to always build as a .isarom to avoid this issue.
You can find **iPXE** at the official site of the project: <http://ipxe.org/>.

View File

@ -1 +0,0 @@
Put ROM firmware in this folder

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +0,0 @@
#!/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
source ./functions/shell.sh
get_available_memory() {
local total_memory
case $(execute uname) in
Linux | CYGWIN*)
total_memory=$(execute LANG=C free | grep Mem | awk '{print $2}')
;;
Darwin)
total_memory=$(execute sysctl -n hw.memsize)
total_memory=$(( $total_memory / 1024 ))
;;
*)
total_memory="-1"
;;
esac
echo $total_memory
}

View File

@ -1,206 +0,0 @@
#!/bin/bash
# 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.
# This file contains the functions to manage host-only interfaces in the system
source ./functions/shell.sh
get_hostonly_interfaces() {
local ifaces=`execute VBoxManage list hostonlyifs | egrep '^Name' | sed 's/^Name\:[ \t]*//' | uniq | tr "\\n" ","`
echo -e "${ifaces}"
}
get_fuel_ifaces() {
local fuel_network=""
local fuel_networks=""
local fuel_iface=""
local fuel_ifaces=""
for i in $fuel_master_ips; do
fuel_network=$(echo "${i%.*}")
fuel_networks+="$fuel_network "
done
for ip in $fuel_networks; do
fuel_iface=`execute VBoxManage list hostonlyifs | egrep -B3 $ip | egrep '^Name' | sed 's/^Name\:[ \t]*//' | uniq | tr "\\n" ","`
fuel_ifaces+="$fuel_iface"
done
echo $fuel_ifaces
}
get_fuel_name_ifaces() {
local fuel_ifaces=$(get_fuel_ifaces)
IFS=","
set -- $fuel_ifaces
j=0
for i in $fuel_ifaces; do
host_nic_name[$j]=$i
j=$((j+1));
done
unset IFS
}
is_hostonly_interface_present() {
name=$1
# String comparison with IF works different in Cygwin, probably due to encoding.
# So, reduced Case is used. since it works the same way.
# Default divider character change is mandatory for Cygwin.
case "$(execute uname)" in
CYGWIN*)
OIFS=$IFS
IFS=","
;;
*)
;;
esac
# 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 "$(uname)" in
CYGWIN*)
IFS=$OIFS
;;
*)
;;
esac
# Check that the list of interfaces contains the given interface
if [[ "$found_iface" == "$name" ]]; then
return 0
else
return 1
fi
}
check_if_iface_settings_applied() {
name=$1
ip=$2
mask=$3
echo "Verifying interface $name has IP $ip and mask $mask properly set."
case "$(uname)" in
CYGWIN*)
OIFS=$IFS
IFS=","
;;
*)
;;
esac
local new_name=(`execute VBoxManage list hostonlyifs | egrep -A9 "Name: + $name\$" | awk '/Name/ { $1 = ""; print substr($0, 2) }'`)
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 }'`)
# First verify if we checking correct interface
if [[ "$name" != "$new_name" ]]; then
echo "Checking $name but found settings for $new_name"
return 1
fi
if [[ $ip != $new_ip ]]; then
echo "New IP address $ip does not match the applied one $new_ip"
return 1
fi
if [[ $mask != $new_mask ]]; then
echo "New Net Mask $mask does not match the applied one $new_mask"
return 1
fi
if [[ "Disabled" != $new_dhcp ]]; then
echo "Failed to disable DHCP for network $name"
return 1
fi
echo "OK."
return 0
}
create_hostonly_interfaces() {
# Creating host-only interface
local ip=$1
echo "Creating host-only interface..."
local id=`execute VBoxManage hostonlyif create | sed "s/'/_/g" | cut -d "_" -f2 | sed "s/^_//" | sed "s/_$//"`
# If it does not exist after creation, let's abort
if ! is_hostonly_interface_present "$id"; then
echo "Fatal error. Interface $id does not exist after creation. Exiting"
exit 1
else
echo "Interface" $id "was successfully created"
fi
# Disable DHCP
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 ${net_sleep}
execute VBoxManage dhcpserver remove --ifname "$name" 2>/dev/null
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
# Check what we have created actually.
# Sometimes VBox occasionally fails to apply settings to the last IFace under Windows
if !(check_if_iface_settings_applied "$id" $ip $mask); then
echo "Looks like VirtualBox failed to apply settings for interface $name"
echo "Sometimes such error happens under Windows."
echo "Please run launch.sh one more time."
echo "If this error remains after several attempts, then something really went wrong."
echo "Aborting."
exit 1
fi
echo
}
# Checking that the interface has been removed
check_removed_iface() {
local iface=$1
if is_hostonly_interface_present "$iface"; then
echo "Host-only interface \"$iface\" was not removed. Aborting..."
exit 1
fi
}
delete_fuel_ifaces() {
# Only the interfaces that have IP addresses from the 'fuel_master_ips'
# variable in the config.sh scripts will be removed
local fuel_ifaces=$(get_fuel_ifaces)
if [ ! -z "$fuel_ifaces" ]; then
check_running_vms "$fuel_ifaces"
IFS=","
for interface in $fuel_ifaces; do
echo "Deleting host-only interface: $interface..."
execute VBoxManage hostonlyif remove "$interface"
check_removed_iface "$interface"
done
fi
unset IFS
echo "Done."
}
delete_all_hostonly_interfaces() {
# All the hostonly interfaces will be removed
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
IFS=","
# Delete every single hostonly interface in the system
for interface in $all_hostonly_interfaces; do
echo "Deleting host-only interface: ${interface}..."
execute VBoxManage hostonlyif remove "${interface}"
check_removed_iface "${interface}"
done
unset IFS
echo "Done."
}

View File

@ -1,285 +0,0 @@
#!/bin/bash
# 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.
# This file contains the functions for connecting to Fuel VM, checking if the installation process completed
# and Fuel became operational, and also enabling outbound network/internet access for this VM through the
# host system
source ./functions/shell.sh
ssh_options='-oConnectTimeout=5 -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null -oRSAAuthentication=no -oPubkeyAuthentication=no'
wait_for_exec_in_bootstrap() {
ip=$1
username=$2
password=$3
prompt=$4
cmd=$5
# Log in into the VM, exec cmd and print exitcode
# Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
result=$(
execute expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
send "$cmd\r"
expect "$prompt"
send "echo \"rc=\$?\"\r"
expect "$prompt"
send "logout\r"
expect "$prompt"
ENDOFEXPECT
)
echo "$result" | grep -q "[r]c=0" >&2 && return 0
return 1
}
wait_for_product_vm_to_download() {
ip=$1
username=$2
password=$3
prompt=$4
echo -n "Waiting for product VM to download files. Please do NOT abort the script... "
# Loop until master node booted and wait_for_external_config started
maxdelay=3000
while ! wait_for_exec_in_bootstrap $ip $username $password "$prompt" "ps xa | grep '\[w\]ait_for_external_config'"; do
sleep 5
((waited += 5))
if (( waited >= maxdelay )); then
echo "Installation timed out! ($maxdelay seconds)" 1>&2
exit 1
fi
done
echo "OK"
}
wait_for_product_vm_to_install() {
ip=$1
username=$2
password=$3
prompt=$4
echo -n "Waiting for product VM to install. Please do NOT abort the script... "
# Loop until master node gets successfully installed
maxdelay=3000
while wait_for_exec_in_bootstrap $ip $username $password "$prompt" "ps xa | grep '\[b\]ootstrap_admin_node.sh'"; do
sleep 5
((waited += 5))
if (( waited >= maxdelay )); then
echo "Installation timed out! ($maxdelay seconds)" 1>&2
exit 1
fi
done
echo "OK"
}
check_internet_connection() {
line=$1
OIFS="${IFS}"
NIFS=$' '
IFS="${NIFS}"
for i in $line; do
if [[ "$i" == *% && "$i" != 100* ]]; then
return 0
fi
done
IFS="${OIFS}"
return 1
}
enable_outbound_network_for_product_vm() {
ip=$1
username=$2
password=$3
prompt=$4
# Check for internet access on the host system
echo -n "Checking for internet connectivity on the host system... "
check_hosts=`echo google.com wikipedia.com | tr ' ' '\n'`
case $(execute uname) in
Linux | Darwin)
for i in ${check_hosts} ; do
ping_host=`execute ping -c 2 ${i} | grep %`
ping_host_result+=$ping_host
done
;;
CYGWIN*)
if [ ! -z "`execute type ping | grep system32`" ]; then
for i in ${check_hosts} ; do
ping_host=`execute ping -n 5 ${i} | grep %`
ping_host_result+=$ping_host
done
elif [ ! -z "`execute type ping | grep bin`" ]; then
for i in ${check_hosts} ; do
ping_host=`execute ping ${i} count 5 | grep %`
ping_host_result+=$ping_host
done
else
print_no_internet_connectivity_banner
fi
;;
*)
print_no_internet_connectivity_banner
;;
esac
check_internet_connection "$ping_host_result"
if [[ $? -eq 0 ]]; then
echo "OK"
else
print_no_internet_connectivity_banner
fi
# Check host nameserver configuration
echo -n "Checking local DNS configuration... "
if execute test -f /etc/resolv.conf ; then
nameserver="$(execute grep '^nameserver' /etc/resolv.conf | grep -v 'nameserver\s\s*127.' | head -3)"
fi
if [ -z "$nameserver" ] && execute test -x /usr/bin/nmcli; then
# Get DNS from network manager
if [ -n "`execute LANG=C nmcli nm | grep \"running\s\+connected\"`" ]; then
nameserver="$(execute nmcli dev list | grep 'IP[46].DNS' | sed -e 's/IP[46]\.DNS\[[0-9]\+\]:\s\+/nameserver /'| grep -v 'nameserver\s\s*127.' | head -3)"
fi
fi
if [ -z "$nameserver" ]; then
echo "/etc/resolv.conf does not contain a nameserver. Using 8.8.8.8 for DNS."
nameserver="nameserver 8.8.8.8"
else
echo "OK"
fi
# Enable internet access on inside the VMs
echo -n "Enabling outbound network/internet access for the product VM... "
# Get network settings (ip address and ip network) for eth1 interface of the master node
local master_ip_pub_net=$(echo $fuel_master_ips | cut -f2 -d ' ')
master_ip_pub_net="${master_ip_pub_net%.*}"".1"
local master_pub_net="${master_ip_pub_net%.*}"".0"
# Convert nameservers list into the one line separated by the comma
dns_upstream="$(echo -e $nameserver | cut -d ' ' -f2 | sed -e':a;N;$!ba;s/\n/,/g')"
# Log in into the VM, configure and bring up the NAT interface, set default gateway, check internet connectivity
# Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
result=$(
execute expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
# make backups, remove network manager options, disable defaults, enable boot and disable network manager
send "sed -i.orig '/^UUID=\\\|^NM_CONTROLLED=/d;s/^\\\(.*\\\)=yes/\\\1=no/g;s/^ONBOOT=.*/ONBOOT=yes/;/^ONBOOT=/iNM_CONTROLLED=no' /etc/sysconfig/network-scripts/ifcfg-eth{0,1,2}\r"
expect "$prompt"
# eth1 should be static with private ip address and provided netmask
send "sed -i 's/^BOOTPROTO=.*/BOOTPROTO=static/;/^BOOTPROTO/aIPADDR=${master_ip_pub_net}\\\nNETMASK=${mask}' /etc/sysconfig/network-scripts/ifcfg-eth1\r"
expect "$prompt"
# eth2 should get ip address via dhcp and used default route
send "sed -i 's/^BOOTPROTO=.*/BOOTPROTO=dhcp/;s/^DEFROUTE=.*/DEFROUTE=yes/;/^BOOTPROTO/aPERSISTENT_DHCLIENT=yes' /etc/sysconfig/network-scripts/ifcfg-eth2\r"
expect "$prompt"
# make backup and disable zeroconf at all because we should use only DHCP on eth2
send "sed -i.orig '/NOZEROCONF/d;aNOZEROCONF=yes' /etc/sysconfig/network\r"
expect "$prompt"
# remove default route from eth0 and system wide settings if exists
send "sed -i '/^GATEWAY=/d' /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0\r"
expect "$prompt"
# fix bug https://bugs.centos.org/view.php?id=7351
send "sed -i.orig '/^DEVICE=lo/aTYPE=Loopback' /etc/sysconfig/network-scripts/ifcfg-lo\r"
expect "$prompt"
# remove old settings from the resolv.conf and dnsmasq.upstream if exists
send "sed -i.orig '/^nameserver/d' /etc/resolv.conf /etc/dnsmasq.upstream &>/dev/null\r"
expect "$prompt"
# update the resolv.conf and dnsmasq.upstream with the new settings
send "echo -e '$nameserver' | tee -a /etc/dnsmasq.upstream >>/etc/resolv.conf\r"
expect "$prompt"
# update the astute.yaml with the new settings
send "sed -i.orig '/DNS_UPSTREAM/c\\"DNS_UPSTREAM\\": \\"${dns_upstream}\\"' /etc/fuel/astute.yaml\r"
expect "$prompt"
# enable NAT (MASQUERADE) and forwarding for the public network
send "/sbin/iptables -t nat -A POSTROUTING -s $master_pub_net/24 \! -d $master_pub_net/24 -j MASQUERADE\r"
expect "$prompt"
send "/sbin/iptables -I FORWARD 1 --dst $master_pub_net/24 -j ACCEPT\r"
expect "$prompt"
send "/sbin/iptables -I FORWARD 1 --src $master_pub_net/24 -j ACCEPT\r"
expect "$prompt"
send "service iptables save &>/dev/null\r"
expect "$prompt"
# disable NetworkManager and apply the network changes
send "nmcli networking off &>/dev/null ; service network restart &>/dev/null\r"
expect "$prompt"
send "logout\r"
expect "$prompt"
ENDOFEXPECT
)
echo "OK"
# Waiting until the network services are restarted.
# 5 seconds is optimal time for different operating systems.
echo -n "Waiting until the network services are restarted... "
sleep 5s
result_inet=$(
execute expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
send "for i in {1..5}; do ping -c 2 google.com || ping -c 2 wikipedia.com || sleep 2; done\r"
expect "*icmp*"
expect "$prompt"
send "logout\r"
expect "$prompt"
ENDOFEXPECT
)
# When you are launching command in a sub-shell, there are issues with IFS (internal field separator)
# and parsing output as a set of strings. So, we are saving original IFS, replacing it, iterating over lines,
# and changing it back to normal
#
# http://blog.edwards-research.com/2010/01/quick-bash-trick-looping-through-output-lines/
OIFS="${IFS}"
NIFS=$'\n'
IFS="${NIFS}"
for line in $result_inet; do
IFS="${OIFS}"
if [[ $line == *icmp_seq* ]]; then
IFS="${NIFS}"
echo "OK"
wait_for_exec_in_bootstrap $ip $username $password "$prompt" "pkill -f ^wait_for_external_config"
return 0;
fi
IFS="${NIFS}"
done
print_no_internet_connectivity_banner
return 1
}
print_no_internet_connectivity_banner() {
echo "FAIL"
echo "############################################################"
echo "# WARNING: some of the Fuel features will not be supported #"
echo "# because there is no Internet connectivity #"
echo "############################################################"
}

View File

@ -1,110 +0,0 @@
#!/bin/bash
# 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, those encapsulate executing of command.
# Each command might be executed on the local machine or on the remote machine
# depending on environment settings
function execute() {
# use shell substitution pattern ${parameter/pattern/string}, to escape spaces in arguments.
if [ -n "$REMOTE_HOST" ]; then
eval "ssh $shell_ssh_options $REMOTE_HOST \"${@//\ /\\ }\""
else
eval "${@//\ /\\ }"
fi
}
# copy file to remote machine if needed
# be careful, do nothing in case if file with same name exists on target machine
function copy_if_required() {
local source_path=$1
if [ -n "$REMOTE_HOST" ]; 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, same file already exists on $REMOTE_HOST."
fi
fi
}
function copy() {
local src=$1
local dst=$2
if [ -n "$REMOTE_HOST" ]; then
eval "scp $shell_scp_options $src $REMOTE_HOST:$dst"
else
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,99 +0,0 @@
#!/bin/bash -eu
# 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
if ! test -f dumpkeys.cache; then
sudo dumpkeys --keys-only > dumpkeys.cache
fi
# XXX: hardcoded values are generated by:
#make_break_shift="$(eval echo \$at_table_$(echo -n Shift | xxd -ps))"
#make_shift="${make_break_shift% *}"
#break_shift="${make_break_shift#* }"
make_shift=36
break_shift=b6
map_set() {
# $1 - keycode
# $2 - normal value
# $3 - shifted value
[ "${2}${3}" = "nulnul" ] && return 1
make=$(printf %02x "$1")
break=$(printf %02x "$(($1 | 128))")
eval "at_table_$(echo -n "${3#+}" | xxd -ps)='$make_shift $make $break $break_shift'"
eval "at_table_$(echo -n "${2#+}" | xxd -ps)='$make $break'"
}
map_alias() {
# $1,$3,$5,... - names
# $2,$4,$6,... - aliases
while [ -n "$1" -a -n "$2" ]; do
eval "at_table_$(echo -n "${2#+}" | xxd -ps)=\${at_table_$(echo -n "${1#+}" | xxd -ps)}"
shift
shift
done
}
# at_table_$normal = n
# at_table_$shifted = n
while read keycode n _ normal shifted rest; do
[ "$keycode" = "keycode" ] || continue
map_set "${n}" "${normal}" "${shifted}"
done < dumpkeys.cache
# Extra mapping
map_alias \
one 1 exclam '!' \
two 2 at '@' \
three 3 numbersign '#' \
four 4 dollar '$' \
five 5 percent '%' \
six 6 asciicircum '^' \
seven 7 ampersand '&' \
eight 8 asterisk '*' \
nine 9 parenleft '(' \
zero 0 parenright ')' \
minus '-' underscore '_' \
equal '=' plus '+'
map_alias \
bracketleft '[' braceleft '{' \
bracketright ']' braceright '}' \
semicolon ';' colon ':' \
apostrophe "'" quotedbl '"' \
grave '`' asciitilde '~' \
backslash "\\" bar '|' \
comma ',' less '<' \
period '.' greater '>' \
slash '/' question '?' \
space ' ' Return $'\n'
translate() {
for t in $(echo -n "$*" | xxd -ps | sed -e 's/../& /g'); do
n="at_table_$t"
v="${!n}"
[ -z "$v" ] && echo "$0: unknown char: '$t'." >&2
echo -n " ${v}"
done
echo
}
[ "$(basename "$0")" = "translate.sh" ] && translate " vmlinuz initrd=initrd.img biosdevname=0 ks=cdrom:/ks.cfg ip=10.20.0.2 gw=10.20.0.1 dns1=10.20.0.1 netmask=255.255.255.0 hostname=fuel.domain.tld showmenu=no
"

View File

@ -1,243 +0,0 @@
#!/bin/bash
# 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.
# This file contains the functions to manage VMs in through VirtualBox CLI
source ./functions/shell.sh
get_vm_base_path() {
echo `execute VBoxManage list systemproperties | egrep '^Default machine folder' | sed 's/^Default machine folder\:[ \t]*//'`
}
get_vms_running() {
echo `execute VBoxManage list runningvms | sed 's/[ \t]*{.*}//' | sed 's/^"//' | sed 's/"$//'`
}
get_vms_present() {
echo `execute VBoxManage list vms | sed 's/[ \t]*{.*}//' | sed 's/^"//' | sed 's/"$//'`
}
is_vm_running() {
name=$1
list=$(get_vms_running)
# Check that the list of running VMs contains the given VM
for name_in_list in $list; do
if [[ "${name_in_list}" == "${name}" ]]; then
return 0
fi
done
return 1
}
is_vm_present() {
name=$1
list=$(get_vms_present)
for name_in_list in $list; do
if [[ "${name_in_list}" == "${name}" ]]; then
return 0
fi
done
return 1
}
check_running_vms() {
OIFS=$IFS
IFS=","
local hostonly_interfaces=$1
local list_running_vms=$(execute VBoxManage list runningvms | sed 's/\" {/\",{/g')
for vm_name in $list_running_vms; do
vm_name=$(echo $vm_name | grep "\"" | sed 's/"//g')
vm_names+="${vm_name},"
done
for i in $vm_names; do
for j in $hostonly_interfaces; do
running_vm=`execute VBoxManage showvminfo $i | grep "${j}"`
if [[ $? -eq 0 ]]; then
echo "The \"${i}\" VM uses host-only interface \"${j}\" and it cannot be removed...."
echo "You should turn off the \"${i}\" virtual machine, run the script again and then the host-only interface will be deleted. Aborting..."
exit 1
fi
done
done
IFS=$OIFS
}
create_vm() {
name=$1
nic=$2
cpu_cores=$3
memory_mb=$4
disk_mb=$5
os='RedHat_64'
# There is a chance that some files are left from previous VM instance
vm_base_path=$(get_vm_base_path | sed 's/\\/\\\\/g')
vm_path="${vm_base_path}/${name}/"
execute rm -rf "${vm_path}"
# Create virtual machine with the right name and type (assuming CentOS)
execute VBoxManage createvm --name $name --ostype $os --register
# Set the real-time clock (RTC) operate in UTC time
# Set memory and CPU parameters
# Set video memory to 16MB, so VirtualBox does not complain about "non-optimal" settings in the UI
execute VBoxManage modifyvm $name --rtcuseutc on --memory $memory_mb --cpus $cpu_cores --vram 16
# Configure main network interface for management/PXE network
add_hostonly_adapter_to_vm $name 1 "${nic}"
execute VBoxManage modifyvm $name --boot1 disk --boot2 dvd --boot3 net --boot4 none
# Configure storage controllers
execute VBoxManage storagectl $name --name 'IDE' --add ide --hostiocache on
execute VBoxManage storagectl $name --name 'SATA' --add sata --hostiocache on
# Create and attach the main hard drive
add_disk_to_vm $name 0 $disk_mb
}
add_hostonly_adapter_to_vm() {
name=$1
id=$2
nic=$3
echo "Adding hostonly adapter to ${name} and bridging with host NIC ${nic}..."
# Add Intel PRO/1000 MT Desktop (82540EM) card to VM. The card is 1Gbps.
execute VBoxManage modifyvm $name --nic${id} hostonly --hostonlyadapter${id} "${nic}" --nictype${id} 82540EM \
--cableconnected${id} on --macaddress${id} auto
execute VBoxManage modifyvm $name --nicpromisc${id} allow-all
}
add_nat_adapter_to_vm() {
name=$1
id=$2
nat_network=$3
echo "Adding NAT adapter to ${name} for outbound network access through the host system..."
# Add Intel PRO/1000 MT Desktop (82540EM) card to VM. The card is 1Gbps.
execute VBoxManage modifyvm $name --nic${id} nat --nictype${id} 82540EM \
--cableconnected${id} on --macaddress${id} auto --natnet${id} "${nat_network}"
execute VBoxManage modifyvm $name --nicpromisc${id} allow-all
}
add_disk_to_vm() {
vm_name=$1
port=$2
disk_mb=$3
echo "Adding disk to ${vm_name}, with size ${disk_mb} Mb..."
vm_base_path=$(get_vm_base_path | sed 's/\\/\\\\/g')
vm_disk_path="${vm_base_path}/${vm_name}"
vm_disk_file="${vm_disk_path}/${vm_name}_${port}.vdi"
execute VBoxManage createhd --filename "${vm_disk_file}" --size $disk_mb --format VDI
execute VBoxManage storageattach $vm_name --storagectl 'SATA' --port $port --device 0 --type hdd --medium "${vm_disk_file}"
# Add serial numbers of disks to slave nodes
echo "Adding serial numbers of disks to ${vm_name}..."
execute VBoxManage setextradata $vm_name "VBoxInternal/Devices/ahci/0/Config/Port${port}/SerialNumber" "VBOX-MIRANTIS-VHD${port}"
}
delete_vm() {
name=$1
vm_base_path=$(get_vm_base_path | sed 's/\\/\\\\/g')
vm_path="${vm_base_path}/${name}/"
# Power off VM, if it's running
count=0
while is_vm_running $name; do
echo "Stopping Virtual Machine ${name}..."
execute VBoxManage controlvm $name poweroff
if [[ "${count}" != 5 ]]; then
count=$((count+1))
sleep 5
else
echo "VirtualBox cannot stop VM ${name}... Exiting"
exit 1
fi
done
echo "Deleting existing virtual machine ${name}..."
while is_vm_present $name
do
execute VBoxManage unregistervm $name --delete
done
# Virtualbox does not fully delete VM file structure, so we need to delete the corresponding directory with files as well
execute 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
for name in $list; do
if [[ $name == $name_prefix* ]]; then
echo "Found existing VM: ${name}. Deleting it..."
delete_vm $name
fi
done
}
start_vm() {
name=$1
# Just start it
if [[ $headless == 1 ]]; then
execute VBoxManage startvm $name --type headless
else
execute VBoxManage startvm $name
fi
if [ -n "${boot_line}" ]; then
sleep 3
# Pressing/releasing escape key
execute VBoxManage controlvm ${name} keyboardputscancode 01 81
for letter in ${boot_line}; do
execute VBoxManage controlvm ${name} keyboardputscancode ${letter}
done
fi
}
mount_iso_to_vm() {
name=$1
iso_path=$2
# Mount ISO to the VM
execute VBoxManage storageattach $name --storagectl 'IDE' --port 0 --device 0 --type dvddrive --medium "${iso_path}"
}
enable_network_boot_for_vm() {
name=$1
# Set the right boot priority
execute VBoxManage modifyvm $name --boot1 net --boot2 disk --boot3 none --boot4 none --nicbootprio1 1
}
enable_vrde(){
name=$1
port=${2:-$RDPport}
# Enable VRDE, set port and address
execute VBoxManage modifyvm $name --vrde on
execute VBoxManage modifyvm $name --vrdeport $port
}

View File

@ -1 +0,0 @@
Put ISO in this folder

View File

@ -1,44 +0,0 @@
#!/bin/bash
# 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.
source ./functions/shell.sh
# Check remote host/port settings
check_remote_settings
# Add VirtualBox directory to PATH
add_virtualbox_path
echo "Prepare the host system..."
./actions/prepare-environment.sh launch || exit 1
echo
echo "Check available memory on the host system..."
./actions/check-available-memory.sh || exit 1
echo
echo "Сlean previous installation if exists..."
./actions/clean-previous-installation.sh || exit 1
echo
# Сreate 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

View File

@ -1,17 +0,0 @@
#!/bin/bash
# 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,17 +0,0 @@
#!/bin/bash
# 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