Commit a7943c82 authored by Thomas Goirand's avatar Thomas Goirand

* Do not use INSERT with '' as value for IDs, just omit it, so it works with

    mariadb 10.3.
parent 80e4d086
......@@ -6,6 +6,8 @@ openstack-cluster-installer (17) UNRELEASED; urgency=medium
* Fix neutron.conf [database]/connection to be empty on compute nodes.
* Fix puppet scheduling of swiftproxy install.
* Fixed machines table with default SQL values.
* Do not use INSERT with '' as value for IDs, just omit it, so it works with
mariadb 10.3.
-- Thomas Goirand <zigo@debian.org> Tue, 22 Jan 2019 10:14:26 +0100
......
......@@ -1422,7 +1422,7 @@ function api_actions($con,$conf){
return $json;
}
$r = mysqli_query($con, "INSERT INTO locations (id, name, swiftregion) VALUES ('', '$safe_location_name', '$safe_swiftregion_name')");
$r = mysqli_query($con, "INSERT INTO locations (name, swiftregion) VALUES ('$safe_location_name', '$safe_swiftregion_name')");
return $json;
break;
case "location_delete":
......@@ -1480,7 +1480,13 @@ function api_actions($con,$conf){
$json["message"] = "Error: swiftregion name already exists.";
return $json;
}
$r = mysqli_query($con, "INSERT INTO swiftregions (id, name) VALUES ('', '$safe_swiftregion_name')");
$q = "INSERT INTO swiftregions (name) VALUES ('$safe_swiftregion_name')";
$r = mysqli_query($con, $q);
if($r === FALSE){
$json["status"] = "error";
$json["message"] = mysqli_error($con) . " with query $q";
return $json;
}
return $json;
break;
case "swiftregion_delete":
......@@ -1913,7 +1919,7 @@ function api_actions($con,$conf){
}else{
$safe_is_public = "no";
}
$q = "INSERT INTO networks (id, name, location_id, ip, cidr, is_public) VALUES ('', '$safe_network_name', '$safe_location_id', '$safe_network_ip', '$safe_cidr_mask', '$safe_is_public')";
$q = "INSERT INTO networks (name, location_id, ip, cidr, is_public) VALUES ('$safe_network_name', '$safe_location_id', '$safe_network_ip', '$safe_cidr_mask', '$safe_is_public')";
$r = mysqli_query($con, $q);
if($r === FALSE){
$json["status"] = "error";
......
......@@ -317,7 +317,7 @@ function perform_actions($con,$conf){
$n = mysqli_num_rows($r);
if($n == 0){
$role_count = 0;
$q = "INSERT INTO rolecounts (id, cluster, role, count) VALUES ('', '$safe_cluster_id', '$safe_role_id', '0')";
$q = "INSERT INTO rolecounts (cluster, role, count) VALUES ('$safe_cluster_id', '$safe_role_id', '0')";
$r = mysqli_query($con, $q);
$role_count_id = mysqli_insert_id($con);
}else{
......@@ -451,7 +451,7 @@ function perform_actions($con,$conf){
$out .= "Location ID in wrong format.";
return $out;
}
$q = "INSERT INTO networks (id, name, ip, cidr, mtu, is_public, location_id) VALUES ('', '$safe_network_name', '$safe_ip', '$safe_cidr', '$safe_mtu', '$safe_is_public', '$safe_location_id')";
$q = "INSERT INTO networks (name, ip, cidr, mtu, is_public, location_id) VALUES ('$safe_network_name', '$safe_ip', '$safe_cidr', '$safe_mtu', '$safe_is_public', '$safe_location_id')";
$r = mysqli_query($con, $q);
break;
case "edit_network":
......@@ -792,7 +792,7 @@ function perform_actions($con,$conf){
$out .= "Swift zone name is wrong.";
return $out;
}
$q = "INSERT INTO swiftregions (id, name) VALUES ('', '$safe_name')";
$q = "INSERT INTO swiftregions (name) VALUES ('$safe_name')";
$r = mysqli_query($con, $q);
break;
case "delete_swiftregion":
......
......@@ -53,7 +53,7 @@ function add_node_to_cluster($con, $conf, $machine_id, $cluster_id, $role_name,
$n = mysqli_num_rows($r);
if($n == 0){
$role_count = 0;
$q = "INSERT INTO rolecounts (id, cluster, role, count) VALUES ('', '$cluster_id', '$role_id', '1')";
$q = "INSERT INTO rolecounts (cluster, role, count) VALUES ('$cluster_id', '$role_id', '1')";
$r = mysqli_query($con, $q);
if($r === FALSE){
$json["status"] = "error";
......@@ -143,7 +143,7 @@ function insert_cluster_pass($con, $conf, $cluster_id, $service, $passtype){
$bytes = openssl_random_pseudo_bytes(32, $crypto_strong);
$hex = bin2hex($bytes);
}
$q = "INSERT INTO passwords (id, cluster, service, passtype, pass) VALUES ('', '$cluster_id', '$service', '$passtype', '$hex')";
$q = "INSERT INTO passwords (cluster, service, passtype, pass) VALUES ('$cluster_id', '$service', '$passtype', '$hex')";
$r = mysqli_query($con, $q);
}
......@@ -166,7 +166,7 @@ function new_cluster($con, $conf, $cluster_name, $cluster_domain){
}
// Create the cluster
$q = "INSERT INTO clusters (id, name, domain) VALUES ('', '$cluster_name', '$cluster_domain'); ";
$q = "INSERT INTO clusters (name, domain) VALUES ('$cluster_name', '$cluster_domain'); ";
$r = mysqli_query($con, $q);
if($r === FALSE){
$json["status"] = "error";
......
......@@ -112,7 +112,7 @@ if($n == 0){
$reg = '/^[0-9]{6,16}$/';
if(!preg_match($reg,$blk_size)) die("Block device size not an int of size max 11 chars.");
$safe_blk_size = $blk_size / (1024*1024);
$r = mysqli_query($con, "INSERT INTO blockdevices (id, machine_id, name, size_mb) VALUES ('', '".$machine_id."', '".$safe_blk_name."', '".$safe_blk_size."')");
$r = mysqli_query($con, "INSERT INTO blockdevices (machine_id, name, size_mb) VALUES ('".$machine_id."', '".$safe_blk_name."', '".$safe_blk_size."')");
}
}
}
......@@ -132,7 +132,7 @@ if($n == 0){
$reg = '/^[0-9]{1,10}$/';
if(!preg_match($reg,$if_max_speed)) die("Network interface max_speed suspicious");
$safe_if_max_speed = $if_max_speed;
$r = mysqli_query($con, "INSERT INTO ifnames (id, machine_id, name, macaddr, max_speed) VALUES ('', '$machine_id', '$safe_if_name', '$safe_if_macaddr', '$safe_if_max_speed')");
$r = mysqli_query($con, "INSERT INTO ifnames (machine_id, name, macaddr, max_speed) VALUES ('$machine_id', '$safe_if_name', '$safe_if_macaddr', '$safe_if_max_speed')");
}
}
}
......@@ -189,7 +189,7 @@ if($n == 0){
$myblkdev = $blkdev_array[$i];
$safe_blk_name = $myblkdev["name"];
$safe_blk_size = $myblkdev["size_mb"];
$r = mysqli_query($con, "INSERT INTO blockdevices (id, machine_id, name, size_mb) VALUES ('', '".$machine_id."', '".$safe_blk_name."', '".$safe_blk_size."')");
$r = mysqli_query($con, "INSERT INTO blockdevices (machine_id, name, size_mb) VALUES ('".$machine_id."', '".$safe_blk_name."', '".$safe_blk_size."')");
}
}
}
......@@ -240,7 +240,7 @@ if($n == 0){
$safe_if_name = $myiface["name"];
$safe_if_macaddr = $myiface["macaddr"];
$safe_if_max_speed = $myiface["max_speed"];
$q = "INSERT INTO ifnames (id, machine_id, name, macaddr, max_speed) VALUES ('', '$machine_id', '$safe_if_name', '$safe_if_macaddr', '$safe_if_max_speed')";
$q = "INSERT INTO ifnames (machine_id, name, macaddr, max_speed) VALUES ('$machine_id', '$safe_if_name', '$safe_if_macaddr', '$safe_if_max_speed')";
$r = mysqli_query($con, $q);
}
}
......
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