Browse Source

Add useful scripts and README.md files

Please read README.md files for more information.

Change-Id: I4f65d7ea6c9d9bf8f02d97e63ec09a2f1aae0006
Closes-Bug: #1592592
Signed-off-by: Maksim Malchuk <mmalchuk@mirantis.com>
Maksim Malchuk 2 years ago
parent
commit
1f356e5b1b

+ 4
- 0
contrib/README.md View File

@@ -0,0 +1,4 @@
1
+contrib
2
+=======
3
+
4
+This directory used for some useful scripts/additions used mostly for debugging purposes.

+ 15
- 0
contrib/add-slave/README.md View File

@@ -0,0 +1,15 @@
1
+add-slave-node-and-boot
2
+=======================
3
+
4
+* This script is used for the debugging purposes to create and boot the new
5
+  slave node with same settings used in the latest one by number (clone it).
6
+
7
+* To remove accidentialy added node from the list this command should be used
8
+  (in this example 99 is the node id):
9
+
10
+```
11
+fuel node --node-id 99 --delete-from-db --force
12
+```
13
+
14
+* This script should be executed from the root fuel-virtualbox scripts
15
+  directory.

+ 102
- 0
contrib/add-slave/add-slave-node-and-boot.sh View File

@@ -0,0 +1,102 @@
1
+#!/bin/bash
2
+
3
+#    Copyright 2016 Mirantis, Inc.
4
+#
5
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+#    not use this file except in compliance with the License. You may obtain
7
+#    a copy of the License at
8
+#
9
+#         http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+#    Unless required by applicable law or agreed to in writing, software
12
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+#    License for the specific language governing permissions and limitations
15
+#    under the License.
16
+
17
+#
18
+# This script creates slaves node for the product, launches its installation,
19
+# and waits for its completion
20
+#
21
+
22
+# Include the handy functions to operate VMs
23
+source ./config.sh
24
+source ./functions/vm.sh
25
+source ./functions/network.sh
26
+
27
+# Get variables "host_nic_name" for the slave node
28
+get_fuel_name_ifaces
29
+echo
30
+
31
+# Get the number of the last slave node
32
+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)
33
+if [ -z "${last_idx}" ]; then
34
+  echo "ERROR: Couldn't parse VMs list or ${vm_name_prefix}slave nodes don't exist."
35
+  echo
36
+  exit 1
37
+fi
38
+
39
+# Number for the new slave node
40
+idx="$(($last_idx + 1))"
41
+
42
+# Name for the new slave node
43
+name="${vm_name_prefix}slave-${idx}"
44
+
45
+# Ammount of RAM for the new slave node
46
+vm_ram=$(execute VBoxManage showvminfo "${vm_name_prefix}slave-${last_idx}" --machinereadable 2>/dev/null | grep '^memory=' | cut -d'=' -f2)
47
+[ -z $vm_ram ] && vm_ram=$vm_slave_memory_default
48
+
49
+# Number of CPUs for the new slave node
50
+vm_cpu=$(execute VBoxManage showvminfo "${vm_name_prefix}slave-${last_idx}" --machinereadable 2>/dev/null | grep '^cpus=' | cut -d'=' -f2)
51
+[ -z $vm_cpu ] && vm_cpu=$vm_slave_cpu_default
52
+
53
+# Create and start slave node
54
+echo "Creating slave #${idx}, with name '${name}', and the same configuration as slave #${last_idx}:"
55
+echo " - memory=${vm_ram}, cpus=${vm_cpu}"
56
+echo
57
+create_vm $name "${host_nic_name[0]}" $vm_cpu $vm_ram $vm_slave_first_disk_mb
58
+
59
+# Add additional NICs to VM
60
+if [ ${#host_nic_name[*]} -gt 1 ]; then
61
+  for nic in $(eval echo {1..$((${#host_nic_name[*]}-1))}); do
62
+    add_hostonly_adapter_to_vm $name $((nic+1)) "${host_nic_name[${nic}]}"
63
+  done
64
+fi
65
+
66
+# Add additional disks to VM
67
+echo
68
+add_disk_to_vm $name 1 $vm_slave_second_disk_mb
69
+add_disk_to_vm $name 2 $vm_slave_third_disk_mb
70
+
71
+# Add COM1 port for serial console
72
+execute VBoxManage modifyvm $name --uart1 0x03f8 4 --uartmode1 disconnected
73
+
74
+# Add NIC1 MAC to description
75
+mac=$(execute VBoxManage showvminfo $name --machinereadable | grep '^macaddress1=' | cut -d'"' -f2)
76
+if [ -n "${mac}" ]; then
77
+  mac_address=$(echo $mac | sed 's/..\B/&:/g;s/./\L&/g')
78
+  execute VBoxManage modifyvm $name --description "${mac}"
79
+fi
80
+
81
+# Add RDP connection
82
+if [ ${headless} -eq 1 ]; then
83
+  enable_vrde $name $((${RDPport} + idx))
84
+fi
85
+
86
+echo
87
+enable_network_boot_for_vm $name
88
+echo "Preparing to start the node..."
89
+# The delay required for downloading tftp boot image
90
+sleep 10
91
+
92
+start_vm $name
93
+
94
+echo
95
+echo "Slave node have been added and started. They will boot over PXE and get discovered by the master node."
96
+echo "Please wait while the slave node appears in the list of the available nodes, this can take some time."
97
+echo "You can use the command 'fuel node' on the Fuel master node to check the list of available nodes."
98
+
99
+if [ -n "${mac}" ]; then
100
+  echo "The MAC address of the new node is: '${mac_address}'."
101
+fi
102
+echo

+ 6
- 0
contrib/osx-nat-pf/README.md View File

@@ -0,0 +1,6 @@
1
+osx-nat-pf
2
+==========
3
+
4
+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.
5
+
6
+This script could be used for debugging purposes and uses an administrative permissions, so you need to enter the administrator password on request.

+ 2
- 0
contrib/osx-nat-pf/osx-nat-pf.rules View File

@@ -0,0 +1,2 @@
1
+nat on en0 proto {tcp, udp, icmp} from 10.20.0.0/24 to any -> (en0)
2
+pass from {lo0, 10.20.0.0/24} to any keep state

+ 4
- 0
contrib/osx-nat-pf/osx-nat-pf.sh View File

@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+sudo pfctl -f ./osx-nat-pf.rules -e # starts pfctl and loads the rules from the osx-nat-pf.rules file
3
+sudo sysctl net.inet.ip.forwarding=1 # enabe routing mode
4
+

+ 42
- 0
contrib/send-sysrq/README.md View File

@@ -0,0 +1,42 @@
1
+send-sysrq
2
+==========
3
+
4
+This tool is a helper for sending Alt+SysRq+<key> 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.
5
+
6
+Please, set sysctl kernel.sysrq to 1 in the guest OS to make all sysrq commands available:
7
+
8
+```
9
+sysctl -w kernel.sysrq=1 # in the guest OS
10
+```
11
+
12
+### Examples of usage (useful for fuel developers):
13
+
14
+* Increase log verbosity:
15
+
16
+```
17
+send-sysrq fuel-slave-1 loglevel-7
18
+```
19
+
20
+* Print processes information to the kernel log:
21
+
22
+```
23
+send-sysrq fuel-slave-1 show-task-states
24
+```
25
+
26
+* Print verbose memory usage to the kernel log:
27
+
28
+```
29
+send-sysrq fuel-slave-1 show-memory-usage
30
+```
31
+
32
+* Print, what system is doing right now:
33
+
34
+```
35
+send-sysrq fuel-slave-1 show-registers
36
+```
37
+
38
+* More examples:
39
+
40
+```
41
+send-sysrq
42
+```

Loading…
Cancel
Save