diff --git a/check_innodb.sh b/check_innodb.sh index 2fc46b0..dc1ffd6 100755 --- a/check_innodb.sh +++ b/check_innodb.sh @@ -1,13 +1,15 @@ #!/bin/bash +. functions.sh +check_juju_version check_controller() { controller=$1 - model="${controller}:cpe-focal" + model="${controller}:${model_name}" RW_MYSQL_UNIT=$(juju status -m ${model} --format json | jq -r '[.applications."mysql-innodb-cluster".units | to_entries[]| select(.value."workload-status".message | contains("R/W")) | .key] | .[0]') - juju run-action -m ${model} ${RW_MYSQL_UNIT} --wait cluster-status --format json | jq -rc '.[].results."cluster-status"' | jq + ${juju_run_action} -m ${model} ${RW_MYSQL_UNIT} cluster-status --format json | jq -rc '.[].results."cluster-status"' | jq } diff --git a/fix_ovn_dbs.sh b/fix_ovn_dbs.sh new file mode 100755 index 0000000..0410008 --- /dev/null +++ b/fix_ovn_dbs.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +set -ax + +. functions.sh +check_juju_version +get_juju_status + +ovn_ips=$(jq -r '.applications."ovn-central".units | to_entries[].value."public-address"' "${juju_status_out}") +neutron_ips=$(jq -r '.applications."neutron-api".units | to_entries[].value."public-address"' "${juju_status_out}") + +ovn_names=$(jq -r '.applications."ovn-central".units | keys[]' "${juju_status_out}") +ovn_lead=$(echo $ovn_names | awk '{print $1}') +ovn_lead_ip=$(jq -r '.applications."ovn-central".units."'${ovn_lead}'"."public-address"' "${juju_status_out}") + +for unit in $ovn_names +do + ${juju_run_action} $unit pause +done + +${juju_run} -u ${ovn_lead} -- mv /var/lib/ovn/ovnnb_db.db /var/lib/ovn/ovnnb_db.db.old -v +${juju_run} -u ${ovn_lead} -- mv /var/lib/ovn/ovnsb_db.db /var/lib/ovn/ovnsb_db.db.old -v +${juju_run} -u ${ovn_lead} -- rm -rf /tmp/standalone_ovnnb_db.db +${juju_run} -u ${ovn_lead} -- rm -rf /tmp/standalone_ovnsb_db.db +${juju_run} -u ${ovn_lead} -- ovsdb-tool create /tmp/standalone_ovnnb_db.db /usr/share/ovn/ovn-nb.ovsschema +${juju_run} -u ${ovn_lead} -- ovsdb-tool create /tmp/standalone_ovnsb_db.db /usr/share/ovn/ovn-sb.ovsschema +${juju_run} -u ${ovn_lead} -- ovsdb-tool create-cluster /var/lib/ovn/ovnnb_db.db /tmp/standalone_ovnnb_db.db ssl:${ovn_lead_ip}:6643 +${juju_run} -u ${ovn_lead} -- ovsdb-tool create-cluster /var/lib/ovn/ovnsb_db.db /tmp/standalone_ovnsb_db.db ssl:${ovn_lead_ip}:6644 + +${juju_run_action} ${ovn_lead} resume + +ovn_nb_uuid=$(${juju_run} -u ${ovn_lead} -- "ovn-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound | grep ^Cluster | awk '{print \$4}' | sed -e s/\(//g -e s/\)//g") +ovn_sb_uuid=$(${juju_run} -u ${ovn_lead} -- "ovn-appctl -t /var/run/ovn/ovnsb_db.ctl cluster/status OVN_Southbound | grep ^Cluster | awk '{print \$4}' | sed -e s/\(//g -e s/\)//g") + +ovn_hosts_nb="ssl:${ovn_lead_ip}:6643" +ovn_hosts_sb="ssl:${ovn_lead_ip}:6644" + +for unit in $ovn_names +do + +[[ "$unit" == "$ovn_lead" ]] && continue + +ovn_unit_ip=$(jq -r '.applications."ovn-central".units."'${unit}'"."public-address"' "${juju_status_out}") + +ovn_hosts_nb="ssl:${ovn_unit_ip}:6643 ${ovn_hosts_nb}" +ovn_hosts_sb="ssl:${ovn_unit_ip}:6644 ${ovn_hosts_sb}" + +${juju_run} -u ${unit} -- mv /var/lib/ovn/ovnnb_db.db /var/lib/ovn/ovnnb_db.db.old -v +${juju_run} -u ${unit} -- mv /var/lib/ovn/ovnsb_db.db /var/lib/ovn/ovnsb_db.db.old -v + +${juju_run} -u ${unit} -- ovsdb-tool --cid=${ovn_nb_uuid} join-cluster /var/lib/ovn/ovnnb_db.db OVN_Northbound ${ovn_hosts_nb} +${juju_run} -u ${unit} -- ovsdb-tool --cid=${ovn_sb_uuid} join-cluster /var/lib/ovn/ovnsb_db.db OVN_Southbound ${ovn_hosts_sb} + +${juju_run_action} $unit resume + +done + +${juju_run} -a ovn-central -- hooks/update-status +${juju_run} -a ovn-central -- hooks/config-changed + +${juju_run} -u neutron-api/leader -- cp -v /etc/neutron/neutron.conf /etc/neutron/neutron.conf.copy +${juju_run} -u neutron-api/leader -- sed -i "s@auth_section = .*@#auth_section = keystone_authtoken@g" /etc/neutron/neutron.conf.copy +${juju_run} -u neutron-api/leader -- neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf.copy --config-file /etc/neutron/plugins/ml2/ml2_conf.ini --ovn-neutron_sync_mode repair +${juju_run} -u neutron-api/leader -- rm -v /etc/neutron/neutron.conf.copy + + +${juju_run} -a ovn-chassis -- sudo systemctl restart ovn-controller +${juju_run} -a neutron-api -- sudo systemctl restart neutron-api diff --git a/functions.sh b/functions.sh index c045d10..043da95 100644 --- a/functions.sh +++ b/functions.sh @@ -1,6 +1,7 @@ #!/bin/bash -model=" -m cpe-jammy" +model_name="cpe-jammy" +model=" -m ${model_name}" LMA_SERVERS="on" get_juju_status() diff --git a/get_all_relation_info.sh b/get_all_relation_info.sh index df4a1f3..c30ae72 100755 --- a/get_all_relation_info.sh +++ b/get_all_relation_info.sh @@ -6,6 +6,9 @@ # Example: ./get_all_relations_info.sh mysql # This will default to "mysql/0" # Example: ./get_all_relations_info.sh keystone/1 +. functions.sh +check_juju_version + APP=`echo ${1} | awk -F\/+ '{print $1}'` UNIT=`echo ${1} | awk -F\/+ '{print $2}'` @@ -13,12 +16,12 @@ UNIT=`echo ${1} | awk -F\/+ '{print $2}'` for r in `juju show-application ${APP} | grep endpoint-bindings -A999 | tail -n +3 | awk -F\: '{print $1}' | sort` do - for i in `juju run --unit ${APP}/${UNIT} "relation-ids ${r}" | awk -F\: '{print $2}' | sort` + for i in `${juju_run} -u ${APP}/${UNIT} -- "relation-ids ${r}" | awk -F\: '{print $2}' | sort` do echo "===========================================" echo "RELATION INFO FOR ${APP}/${UNIT} - ${r}:${i}" echo "" - juju run --unit ${APP}/${UNIT} "relation-get -r ${r}:${i} - ${APP}/${UNIT}" + ${juju_run} -u ${APP}/${UNIT} -- "relation-get -r ${r}:${i} - ${APP}/${UNIT}" echo "===========================================" done done diff --git a/get_passwords.sh b/get_passwords.sh index e954f9f..71d1266 100755 --- a/get_passwords.sh +++ b/get_passwords.sh @@ -1,15 +1,20 @@ #!/bin/bash -keystone_passwd=$(juju run --unit keystone/leader 'leader-get admin_passwd') -nagios_passwd=$(juju run --unit nagios/leader 'sudo cat /var/lib/juju/nagios.passwd') -grafana_passwd=$(juju run-action --wait grafana/leader get-admin-password | grep password | awk '{print $2}') -graylog_passwd=$(juju run-action --wait graylog/leader show-admin-password | grep admin-password | awk '{print $2}') -mysql_passwd=$(juju run --unit mysql/leader 'leader-get root-password') -innodb_admin_passwd=$(juju run --unit mysql-innodb-cluster/leader 'leader-get mysql.passwd') -innodb_cluster_passwd=$(juju run --unit mysql-innodb-cluster/leader 'leader-get cluster-password') +. functions.sh +check_juju_version + +keystone_passwd=$(${juju_run} -u keystone/leader 'leader-get admin_passwd') +nagios_passwd=$(${juju_run} -u nagios/leader 'sudo cat /var/lib/juju/nagios.passwd') +grafana_passwd=$(${juju_run_action} grafana/leader get-admin-password | grep password | awk '{print $2}') +graylog_passwd=$(${juju_run_action} graylog/leader show-admin-password | grep admin-password | awk '{print $2}') +mysql_passwd=$(${juju_run} -u mysql/leader 'leader-get root-password') +innodb_admin_passwd=$(${juju_run} -u mysql-innodb-cluster/leader 'leader-get mysql.passwd') +innodb_cluster_passwd=$(${juju_run} -u mysql-innodb-cluster/leader 'leader-get cluster-password') echo "Keystone admin password: ... ${keystone_passwd}" echo "nagios password: ... ${nagios_passwd}" echo "grafana password: ... ${grafana_passwd}" echo "graylog password: ... ${graylog_passwd}" -echo "mysql password: ... ${mysql_passwd}" +echo "percona admin password: ... ${mysql_passwd}" +echo "mysql admin password: ... ${innodb_admin_passwd}" +echo "mysql cluster password: ... ${innodb_cluster_passwd}"