Commit 2b46c982 authored by Thomas Goirand's avatar Thomas Goirand

Add the feature to setup any machine with software RAID.

parent 46db9d41
......@@ -42,6 +42,7 @@ openstack-cluster-installer (22) UNRELEASED; urgency=medium
* Also install gnupg2 in the installed machines of the cluster.
* Add support for Stein's separated placement.
* Adapt puppet manifests so that they also work with Stein's puppet-openstack.
* Add the feature to setup any machine with software RAID.
[ Oliver Chaze ]
* swift: do not log in syslog general logs
......
......@@ -71,13 +71,32 @@ _ocicli() {
COMPREPLY=( $(compgen -W "${serial_list}" -- ${cur}) )
return 0
;;
3)
COMPREPLY=( $(compgen -W "--use_ceph_if_available" -- ${cur}) )
3|5|7|9|11|13|15|17)
COMPREPLY=( $(compgen -W "--use_ceph_if_available --install-on-raid --raid-type --raid-dev0 --raid-dev1 --raid-dev2 --raid-dev3 --raid-dev4 --serial-console-device" -- ${cur}) )
return 0
;;
4)
COMPREPLY=( $(compgen -W "yes no" -- ${cur}) )
return 0
4|6|8|10|12|14|16|18)
case "${prev}" in
"--use_ceph_if_available"|"--install-on-raid")
COMPREPLY=( $(compgen -W "yes no" -- ${cur}) )
return 0
;;
"--raid-type")
COMPREPLY=( $(compgen -W "0 1 10" -- ${cur}) )
return 0
;;
"--raid-dev0"|"--raid-dev1"|"--raid-dev2"|"--raid-dev3")
COMPREPLY=( $(compgen -W "sda sdb sdc sdd sde sdf sdg sdh sdi sdj sdk sdl sdm sdn sdo sdp vda vdb vdc vdd vde vdf vdg vdh" -- ${cur}) )
return 0
;;
"--serial-console-device")
COMPREPLY=( $(compgen -W "ttyS0 ttyS1 ttyS2 ttyS4 none" -- ${cur}) )
return 0
;;
*)
return 0
;;
esac
;;
*)
return 0
......
......@@ -17,7 +17,7 @@ usage (){
echo "Actions are:"
echo " machine-list"
echo " machine-show <machine_serial>"
echo " machine-set <machine_serial> --use_ceph_if_available <yes/no>"
echo " machine-set <machine_serial> --use_ceph_if_available <yes/no> --install-on-raid <yes/no> --raid-type <0/1/10/5> --raid-dev0 sda --raid-dev1 sdb --raid-dev2 sdc --raid-dev3 sdd --serial-console-device <ttyS0/ttyS1/none>"
echo " machine-add <machine_serial> <cluster_name> <role_name> <location_name>: add a machine to a cluster"
echo " machine-remove <machine_serial>: remove a machine from a cluster"
echo " machine-destroy <machine_serial>: completely remove a machine from OCI's db"
......@@ -126,6 +126,15 @@ ocicli_machine_show (){
OCICLI_MACHINE_SHOW_NOTES=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.notes)"')
OCICLI_MACHINE_SHOW_USE_CEPH=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.use_ceph_if_available)"')
OCICLI_MACHINE_SHOW_INSTALL_ON_RAID=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.install_on_raid)"')
OCICLI_MACHINE_SHOW_RAID_TYPE=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.raid_type)"')
OCICLI_MACHINE_SHOW_RAID_DEV0=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.raid_dev0)"')
OCICLI_MACHINE_SHOW_RAID_DEV1=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.raid_dev1)"')
OCICLI_MACHINE_SHOW_RAID_DEV2=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.raid_dev2)"')
OCICLI_MACHINE_SHOW_RAID_DEV3=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.raid_dev3)"')
OCICLI_MACHINE_SHOW_SERIAL_CONSOLE_DEV=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.serial_console_dev)"')
# From cluster
OCICLI_MACHINE_SHOW_CLUSTER_NAME=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.machine_cluster.name)"')
......@@ -157,14 +166,6 @@ ocicli_machine_show (){
done
echo ""
echo -n "Block devices:,"
for i in $(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.machine_blockdevices)"' | jq -r '.[].name') ; do
SIZE_MB=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]["machine_blockdevices"][] | select(.name == "'${i}'") | .["size_mb"]')
SIZE_GB=$((${SIZE_MB} / 1024))
echo -n "${i}:${SIZE_GB}G "
done
echo ""
echo -n "Interfaces:,"
for i in $(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.machine_ifs)"' | jq -r '.[].name') ; do
SPEED=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]["machine_ifs"][] | select(.name == "'${i}'") | .["max_speed"]')
......@@ -190,6 +191,29 @@ ocicli_machine_show (){
done
echo ""
echo -n "Block devices:,"
for i in $(cat ${API_RESPONSE_FILE} | jq -r '.["data"]| "\(.machine_blockdevices)"' | jq -r '.[].name') ; do
SIZE_MB=$(cat ${API_RESPONSE_FILE} | jq -r '.["data"]["machine_blockdevices"][] | select(.name == "'${i}'") | .["size_mb"]')
SIZE_GB=$((${SIZE_MB} / 1024))
echo -n "${i}:${SIZE_GB}G "
done
echo ""
echo "Install on RAID:,${OCICLI_MACHINE_SHOW_INSTALL_ON_RAID}"
echo "Raid type:,${OCICLI_MACHINE_SHOW_RAID_TYPE}"
echo "Raid device 0:,${OCICLI_MACHINE_SHOW_RAID_DEV0}"
echo "Raid device 1:,${OCICLI_MACHINE_SHOW_RAID_DEV1}"
case ${OCICLI_MACHINE_SHOW_RAID_TYPE} in
0|1)
echo -n ""
;;
5|10)
echo "Raid device 2:,${OCICLI_MACHINE_SHOW_RAID_DEV2}"
echo "Raid device 3:,${OCICLI_MACHINE_SHOW_RAID_DEV3}"
;;
esac
echo "Serial console device:,${OCICLI_MACHINE_SHOW_SERIAL_CONSOLE_DEV}"
}
ocicli_machine_set (){
......@@ -202,7 +226,43 @@ ocicli_machine_set (){
shift
shift
;;
"--install-on-raid")
INSTALL_ON_RAID=${2}
shift
shift
;;
"--raid-type")
RAID_TYPE=${2}
shift
shift
;;
"--raid-dev0")
RAID_DEV0=${2}
shift
shift
;;
"--raid-dev1")
RAID_DEV1=${2}
shift
shift
;;
"--raid-dev2")
RAID_DEV2=${2}
shift
shift
;;
"--raid-dev3")
RAID_DEV3=${2}
shift
shift
;;
"--serial-console-device")
SERIAL_CONSOLE_DEVICE=${2}
shift
shift
;;
*)
echo -n ""
;;
esac
done
......@@ -210,6 +270,27 @@ ocicli_machine_set (){
if [ -n "${USE_CEPH}" ] ; then
COMMAND="${COMMAND}&use_ceph=${USE_CEPH}"
fi
if [ -n "${INSTALL_ON_RAID}" ] ; then
COMMAND="${COMMAND}&install_on_raid=${INSTALL_ON_RAID}"
fi
if [ -n "${RAID_TYPE}" ] ; then
COMMAND="${COMMAND}&raid_type=${RAID_TYPE}"
fi
if [ -n "${RAID_DEV0}" ] ; then
COMMAND="${COMMAND}&raid_dev0=${RAID_DEV0}"
fi
if [ -n "${RAID_DEV1}" ] ; then
COMMAND="${COMMAND}&raid_dev1=${RAID_DEV1}"
fi
if [ -n "${RAID_DEV2}" ] ; then
COMMAND="${COMMAND}&raid_dev2=${RAID_DEV2}"
fi
if [ -n "${RAID_DEV3}" ] ; then
COMMAND="${COMMAND}&raid_dev3=${RAID_DEV3}"
fi
if [ -n "${SERIAL_CONSOLE_DEVICE}" ] ; then
COMMAND="${COMMAND}&serial_console_device=${SERIAL_CONSOLE_DEVICE}"
fi
ocicli_call ${COMMAND}
ocicli_display_status
}
......
......@@ -1586,13 +1586,114 @@ function api_actions($con,$conf){
return $json;
}
$machine = mysqli_fetch_array($r);
$Q_ADDON = "";
if(isset($_REQUEST["use_ceph"])){
if($_REQUEST["use_ceph"] == "yes"){
$Q_ADDON = " use_ceph_if_available='yes'";
$Q_ADDON .= "use_ceph_if_available='yes'";
}else{
$Q_ADDON .= "use_ceph_if_available='no'";
}
}
if(isset($_REQUEST["install_on_raid"])){
if($Q_ADDON != ""){
$Q_ADDON .= ", ";
}
if($_REQUEST["install_on_raid"] == "yes"){
$Q_ADDON .= "install_on_raid='yes'";
}else{
$Q_ADDON = " use_ceph_if_available='no'";
$Q_ADDON .= "install_on_raid='no'";
}
}
if(isset($_REQUEST["raid_type"])){
if($Q_ADDON != ""){
$Q_ADDON .= ", ";
}
switch($_REQUEST["raid_type"]){
case "0":
$Q_ADDON .= "raid_type='0'";
break;
default:
case "1":
$Q_ADDON .= "raid_type='1'";
break;
case "5":
$Q_ADDON .= "raid_type='5'";
break;
case "10":
$Q_ADDON .= "raid_type='10'";
break;
}
}
if(isset($_REQUEST["raid_dev0"])){
$raid_dev0 = safe_blockdev_name("raid_dev0");
if($raid_dev0 === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid raid device name.";
return $json;
}
if($Q_ADDON != ""){
$Q_ADDON .= ", ";
}
$Q_ADDON .= "raid_dev0='$raid_dev0'";
}
if(isset($_REQUEST["raid_dev1"])){
$raid_dev1 = safe_blockdev_name("raid_dev1");
if($raid_dev1 === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid raid device name.";
return $json;
}
if($Q_ADDON != ""){
$Q_ADDON .= ", ";
}
$Q_ADDON .= "raid_dev1='$raid_dev1'";
}
if(isset($_REQUEST["raid_dev2"])){
$raid_dev2 = safe_blockdev_name("raid_dev2");
if($raid_dev2 === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid raid device name.";
return $json;
}
if($Q_ADDON != ""){
$Q_ADDON .= ", ";
}
$Q_ADDON .= "raid_dev2='$raid_dev2'";
}
if(isset($_REQUEST["raid_dev3"])){
$raid_dev3 = safe_blockdev_name("raid_dev3");
if($raid_dev3 === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid raid device name.";
return $json;
}
if($Q_ADDON != ""){
$Q_ADDON .= ", ";
}
$Q_ADDON .= "raid_dev3='$raid_dev3'";
}
if(isset($_REQUEST["serial_console_device"])){
$serial_console_device = safe_blockdev_name("serial_console_device");
if($serial_console_device === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid serial device name.";
return $json;
}
if($Q_ADDON != ""){
$Q_ADDON .= ", ";
}
$Q_ADDON .= "serial_console_dev='$serial_console_device'";
}
$q = "UPDATE machines SET $Q_ADDON WHERE serial='$safe_machine_serial'";
$r = mysqli_query($con, $q);
......
......@@ -860,7 +860,33 @@ function slave_install_server_os_command($con, $conf, $machine_id){
$cmd .= " --debootstrap-url ".$conf["network"]["debian_mirror"];
$cmd .= " --sources.list-mirror ".$conf["network"]["debian_mirror"];
$cmd .= " --security-mirror ".$conf["network"]["debian_security_mirror"];
$cmd .= " --dest-hdd $install_hdd_name";
if($machine["install_on_raid"] == "no"){
$cmd .= " --dest-hdd $install_hdd_name";
}else{
switch($machine["raid_type"]){
case "0":
$cmd .= " --dest-hdd raid0";
$cmd .= " --raid-devices ".$machine["raid_dev0"].",".$machine["raid_dev1"];
break;
case "1":
$cmd .= " --dest-hdd raid1";
$cmd .= " --raid-devices ".$machine["raid_dev0"].",".$machine["raid_dev1"];
break;
case "10":
$cmd .= " --dest-hdd raid10";
$cmd .= " --raid-devices ".$machine["raid_dev0"].",".$machine["raid_dev1"].",".$machine["raid_dev2"].",".$machine["raid_dev3"];
break;
# case "5":
# $cmd .= " --dest-hdd raid5";
# $cmd .= " --raid-devices ".$machine["raid_dev0"].",".$machine["raid_dev1"].",".$machine["raid_dev2"].",".$machine["raid_dev3"];
# break;
default:
echo "Not implemented yet...";
die();
break;
}
}
$cmd .= " --no-cloud-init --extra-packages gnupg2,haveged,uuid-runtime,iotop,iftop,man-db,curl,less,lsb-release,joe,ssl-cert,most,screen,vim,vim-tiny,tcpd,xfsdump,unzip,tcpdump,ntpstat,ca-certificates,rpcbind,lftp,at,tree,lsof,bind9-host,dnsutils,strace,tmux,nano,bash-completion,openssl,ntp,file,net-tools,iproute2,ipmitool,ca-certificates,xfsprogs,e2fsprogs,parted,nmap,mtr-tiny,ladvd$package_list_file";
$cmd .= " --hook-script /usr/bin/openstack-cluster-installer-bodi-hook-script";
$cmd .= " --root-ssh-key /root/.ssh/authorized_keys";
......@@ -869,7 +895,9 @@ function slave_install_server_os_command($con, $conf, $machine_id){
$cmd .= ",openvswitch-switch";
}
$cmd .= " --hostname " . $machine["hostname"];
$cmd .= " --add-serial-getty ttyS1";
if($machine["serial_console_dev"] != "none"){
$cmd .= " --add-serial-getty ".$machine["serial_console_dev"];
}
$cmd .= " --reboot-after-install";
if($role == "swiftstore" || $role == "volume"){
$q = "SELECT * FROM blockdevices WHERE machine_id='$machine_id' AND name NOT LIKE '%a' ORDER BY name";
......
......@@ -234,4 +234,19 @@ function safe_ethname($param_name){
return $_REQUEST[$param_name];
}
function validate_blockdev_name($param_name){
if(!isset($_REQUEST[$param_name]) || $_REQUEST[$param_name] == ""){
return FALSE;
}
$param = $_REQUEST[$param_name];
$reg = "/^[-a-zA-Z0-9]+\$/";
if(!preg_match($reg,$param)) return FALSE;
else return TRUE;
}
function safe_blockdev_name($param_name){
if(validate_blockdev_name($param_name) === FALSE) return FALSE;
return $_REQUEST[$param_name];
}
?>
......@@ -96,7 +96,14 @@ $database = array(
"bios_version" => "varchar(128) NOT NULL default ''",
"ipmi_firmware_version" => "varchar(128) NOT NULL default ''",
"ipmi_detected_ip" => "varchar(64) NOT NULL default ''",
"use_ceph_if_available" => "enum('yes','no') NOT NULL default 'no'"
"use_ceph_if_available" => "enum('yes','no') NOT NULL default 'no'",
"install_on_raid" => "enum('yes','no') NOT NULL default 'no'",
"raid_type" => "enum('0','1','10','5') NOT NULL default '1'",
"raid_dev0" => "varchar(64) NOT NULL default 'sda'",
"raid_dev1" => "varchar(64) NOT NULL default 'sdb'",
"raid_dev2" => "varchar(64) NOT NULL default 'sdc'",
"raid_dev3" => "varchar(64) NOT NULL default 'sdd'",
"serial_console_dev" => "varchar(64) NOT NULL default 'ttyS1'",
),
"primary" => "(id)",
"keys" => array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment