diff --git a/contrib/README.md b/contrib/README.md new file mode 100644 index 0000000..4dce561 --- /dev/null +++ b/contrib/README.md @@ -0,0 +1,4 @@ +contrib +======= + +This directory used for some useful scripts/additions used mostly for debugging purposes. diff --git a/contrib/add-slave/README.md b/contrib/add-slave/README.md new file mode 100644 index 0000000..8b5f7dc --- /dev/null +++ b/contrib/add-slave/README.md @@ -0,0 +1,15 @@ +add-slave-node-and-boot +======================= + +* This script is used for the debugging purposes to create and boot the new + slave node with same settings used in the latest one by number (clone it). + +* To remove accidentialy added node from the list this command should be used + (in this example 99 is the node id): + +``` +fuel node --node-id 99 --delete-from-db --force +``` + +* This script should be executed from the root fuel-virtualbox scripts + directory. diff --git a/contrib/add-slave/add-slave-node-and-boot.sh b/contrib/add-slave/add-slave-node-and-boot.sh new file mode 100755 index 0000000..cb8bdc0 --- /dev/null +++ b/contrib/add-slave/add-slave-node-and-boot.sh @@ -0,0 +1,102 @@ +#!/bin/bash + +# Copyright 2016 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 node +get_fuel_name_ifaces +echo + +# Get the number of the last slave node +last_idx=$(execute VBoxManage list vms | grep "${vm_name_prefix}slave-" | sed -e"s/${vm_name_prefix}slave-//g" | cut -d'"' -f2 | sort -nu | tail -1) +if [ -z "${last_idx}" ]; then + echo "ERROR: Couldn't parse VMs list or ${vm_name_prefix}slave nodes don't exist." + echo + exit 1 +fi + +# Number for the new slave node +idx="$(($last_idx + 1))" + +# Name for the new slave node +name="${vm_name_prefix}slave-${idx}" + +# Ammount of RAM for the new slave node +vm_ram=$(execute VBoxManage showvminfo "${vm_name_prefix}slave-${last_idx}" --machinereadable 2>/dev/null | grep '^memory=' | cut -d'=' -f2) +[ -z $vm_ram ] && vm_ram=$vm_slave_memory_default + +# Number of CPUs for the new slave node +vm_cpu=$(execute VBoxManage showvminfo "${vm_name_prefix}slave-${last_idx}" --machinereadable 2>/dev/null | grep '^cpus=' | cut -d'=' -f2) +[ -z $vm_cpu ] && vm_cpu=$vm_slave_cpu_default + +# Create and start slave node +echo "Creating slave #${idx}, with name '${name}', and the same configuration as slave #${last_idx}:" +echo " - memory=${vm_ram}, cpus=${vm_cpu}" +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 COM1 port for serial console +execute VBoxManage modifyvm $name --uart1 0x03f8 4 --uartmode1 disconnected + +# Add NIC1 MAC to description +mac=$(execute VBoxManage showvminfo $name --machinereadable | grep '^macaddress1=' | cut -d'"' -f2) +if [ -n "${mac}" ]; then + mac_address=$(echo $mac | sed 's/..\B/&:/g;s/./\L&/g') + execute VBoxManage modifyvm $name --description "${mac}" +fi + +# Add RDP connection +if [ ${headless} -eq 1 ]; then + enable_vrde $name $((${RDPport} + idx)) +fi + +echo +enable_network_boot_for_vm $name +echo "Preparing to start the node..." +# The delay required for downloading tftp boot image +sleep 10 + +start_vm $name + +echo +echo "Slave node have been added and started. They will boot over PXE and get discovered by the master node." +echo "Please wait while the slave node appears in the list of the available nodes, this can take some time." +echo "You can use the command 'fuel node' on the Fuel master node to check the list of available nodes." + +if [ -n "${mac}" ]; then + echo "The MAC address of the new node is: '${mac_address}'." +fi +echo diff --git a/contrib/osx-nat-pf/README.md b/contrib/osx-nat-pf/README.md new file mode 100644 index 0000000..74df6cd --- /dev/null +++ b/contrib/osx-nat-pf/README.md @@ -0,0 +1,6 @@ +osx-nat-pf +========== + +This script (osx-nat-pf.sh) could be used to enable routing and NAT for Admin network (10.20.0.0/24) in Mac OSX 9 (Yosemite) or Mac OSX 10 (El Capitan). The previous versions of Mac OSX use 'ipfw' so another solution should be used. + +This script could be used for debugging purposes and uses an administrative permissions, so you need to enter the administrator password on request. diff --git a/contrib/osx-nat-pf/osx-nat-pf.rules b/contrib/osx-nat-pf/osx-nat-pf.rules new file mode 100644 index 0000000..0523b6d --- /dev/null +++ b/contrib/osx-nat-pf/osx-nat-pf.rules @@ -0,0 +1,2 @@ +nat on en0 proto {tcp, udp, icmp} from 10.20.0.0/24 to any -> (en0) +pass from {lo0, 10.20.0.0/24} to any keep state diff --git a/contrib/osx-nat-pf/osx-nat-pf.sh b/contrib/osx-nat-pf/osx-nat-pf.sh new file mode 100755 index 0000000..fd933e6 --- /dev/null +++ b/contrib/osx-nat-pf/osx-nat-pf.sh @@ -0,0 +1,4 @@ +#!/bin/sh +sudo pfctl -f ./osx-nat-pf.rules -e # starts pfctl and loads the rules from the osx-nat-pf.rules file +sudo sysctl net.inet.ip.forwarding=1 # enabe routing mode + diff --git a/contrib/send-sysrq/README.md b/contrib/send-sysrq/README.md new file mode 100644 index 0000000..05f3707 --- /dev/null +++ b/contrib/send-sysrq/README.md @@ -0,0 +1,42 @@ +send-sysrq +========== + +This tool is a helper for sending Alt+SysRq+ combination to the guest OS in VirtualBox VM, which is used in Linux for printing different sorts of debug messages to the kernel log, like list of processes, stack traces of CPUs and so on, or for performing actions: reboot, sync e.t.c. It's very useful when all other ways to communicate to the VM become unavailable. + +Please, set sysctl kernel.sysrq to 1 in the guest OS to make all sysrq commands available: + +``` +sysctl -w kernel.sysrq=1 # in the guest OS +``` + +### Examples of usage (useful for fuel developers): + +* Increase log verbosity: + +``` +send-sysrq fuel-slave-1 loglevel-7 +``` + +* Print processes information to the kernel log: + +``` +send-sysrq fuel-slave-1 show-task-states +``` + +* Print verbose memory usage to the kernel log: + +``` +send-sysrq fuel-slave-1 show-memory-usage +``` + +* Print, what system is doing right now: + +``` +send-sysrq fuel-slave-1 show-registers +``` + +* More examples: + +``` +send-sysrq +```