From 9274d9d35ee71eea6913c11e1bba57298dc98e9b Mon Sep 17 00:00:00 2001 From: Erwan MAS Date: Thu, 18 Jun 2020 17:40:02 +0000 Subject: [PATCH] Small fixes : - add a predicat on machines.cluster , when we want to calculate ipaddr for sql - when we generate hosts file , order by network so all ips will be in the same network - copy options from ssh command to scp command - extract the digit by takeing the right part ( the current way does not work when cluster name as a '-' ) --- src/inc/enc.php | 4 ++-- src/inc/slave_actions.php | 2 +- src/inc/ssh.php | 2 +- utils/usr/bin/oci-make-osd | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/inc/enc.php b/src/inc/enc.php index cac34d8e..275034c9 100644 --- a/src/inc/enc.php +++ b/src/inc/enc.php @@ -549,7 +549,7 @@ function puppet_enc($con,$conf){ }else{ $qrole = 'controller'; } - $q = "SELECT machines.hostname AS hostname, machines.id AS nodeid, INET_NTOA(ips.ip) AS ipaddr FROM machines, ips, networks WHERE machines.role='$qrole' AND machines.id=ips.machine AND ips.network=networks.id AND networks.is_public='no' AND networks.role!='vm-net' AND networks.role!='ovs-bridge' AND networks.role!='ceph-cluster' AND networks.role!='ipmi'"; + $q = "SELECT machines.hostname AS hostname, machines.id AS nodeid, INET_NTOA(ips.ip) AS ipaddr FROM machines, ips, networks WHERE machines.role='$qrole' AND machines.cluster='$cluster_id' AND machines.id=ips.machine AND ips.network=networks.id AND networks.is_public='no' AND networks.role!='vm-net' AND networks.role!='ovs-bridge' AND networks.role!='ceph-cluster' AND networks.role!='ipmi'"; $r = mysqli_query($con, $q); if($r === FALSE){ $json["status"] = "error"; @@ -569,7 +569,7 @@ function puppet_enc($con,$conf){ $enc_non_master_sql = " non_master_sql:\n"; $enc_non_master_sql_ip = " non_master_sql_ip:\n"; - $q = "SELECT machines.hostname AS hostname, machines.id AS nodeid, INET_NTOA(ips.ip) AS ipaddr FROM machines, ips, networks WHERE machines.role='$qrole' AND machines.id=ips.machine AND ips.network=networks.id AND networks.is_public='no' AND networks.role!='vm-net' AND networks.role!='ovs-bridge' AND networks.role!='ceph-cluster' AND networks.role!='ipmi' AND machines.hostname!='$first_sql_hostname'"; + $q = "SELECT machines.hostname AS hostname, machines.id AS nodeid, INET_NTOA(ips.ip) AS ipaddr FROM machines, ips, networks WHERE machines.role='$qrole' AND machines.cluster='$cluster_id' AND machines.id=ips.machine AND ips.network=networks.id AND networks.is_public='no' AND networks.role!='vm-net' AND networks.role!='ovs-bridge' AND networks.role!='ceph-cluster' AND networks.role!='ipmi' AND machines.hostname!='$first_sql_hostname'"; $r = mysqli_query($con, $q); if($r === FALSE){ $json["status"] = "error"; diff --git a/src/inc/slave_actions.php b/src/inc/slave_actions.php index aa378e8d..e98b03ef 100644 --- a/src/inc/slave_actions.php +++ b/src/inc/slave_actions.php @@ -1341,7 +1341,7 @@ $pxe_server_ipaddr $pxe_server_hostname $other_host_hostname = str_replace("." . $cluster_domain, "", $other_host_fqdn); $other_host_id = $other_host["id"]; - $q_oh = "SELECT INET_NTOA(ips.ip) AS addr FROM networks, ips WHERE ips.machine='$other_host_id' AND networks.cluster='$machine_cluster' AND networks.id=ips.network LIMIT 1"; + $q_oh = "SELECT INET_NTOA(ips.ip) AS addr FROM networks, ips WHERE ips.machine='$other_host_id' AND networks.cluster='$machine_cluster' AND networks.id=ips.network order by case when role='all' then 1 when role='vm-net' then 2 when role='ceph-cluster' then 3 else 9 end LIMIT 1"; $r_oh = mysqli_query($con, $q_oh); $n_oh = mysqli_num_rows($r_oh); if($n_oh == 1){ diff --git a/src/inc/ssh.php b/src/inc/ssh.php index b4712f12..3b33bf9e 100644 --- a/src/inc/ssh.php +++ b/src/inc/ssh.php @@ -38,7 +38,7 @@ function scp_a_file($conf, $con, $ip_addr, $local_file, $remote_dest, $mode){ ssh2_scp_send($ssh, $local_file, $remote_dest, $mode); ssh2_disconnect($ssh); }else{ - $cmd = "scp -o \"StrictHostKeyChecking no\" -i /etc/openstack-cluster-installer/id_rsa $local_file root@$ip_addr:$remote_dest"; + $cmd = "scp -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o \"StrictHostKeyChecking no\" -i /etc/openstack-cluster-installer/id_rsa $local_file root@$ip_addr:$remote_dest"; $output = array(); $return_var = 0; exec($cmd, $output, $return_var); diff --git a/utils/usr/bin/oci-make-osd b/utils/usr/bin/oci-make-osd index d0ca95fa..672fd04d 100755 --- a/utils/usr/bin/oci-make-osd +++ b/utils/usr/bin/oci-make-osd @@ -26,7 +26,7 @@ chown ceph /etc/ceph/ceph.client.admin.keyring # - drive letter # - OSD id # - OSD port number -MAJOR_NUM=$(hostname -s | cut -d- -f3) +MAJOR_NUM=$(hostname -s | sed 's/^.*\-\([0-9]*\)$/\1/p;d' ) if echo ${HDD_DEV} | grep -q nvme ; then NVME_DRIVE_NUM=$(echo ${HDD_DEV} | sed sed -e s/nvme// -e s/n1//) # We add 1 to avoid issue when nvme0n1 -- GitLab