Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | {{/* |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */}} |
| 16 | |
| 17 | set -ex |
| 18 | |
| 19 | # Make the Nova Instances Dir as this is not autocreated. |
| 20 | mkdir -p /var/lib/nova/instances |
| 21 | |
| 22 | # Set Ownership of nova dirs to the nova user |
| 23 | chown ${NOVA_USER_UID} /var/lib/nova /var/lib/nova/instances |
| 24 | |
| 25 | migration_interface="{{- .Values.conf.libvirt.live_migration_interface -}}" |
Mohammed Naser | 733635e | 2023-03-30 17:34:09 +0000 | [diff] [blame] | 26 | if [[ -z $migration_interface ]]; then |
| 27 | # search for interface with default routing |
| 28 | # If there is not default gateway, exit |
Oleksandr K. | 24c88fd | 2024-12-08 22:28:50 -0800 | [diff] [blame] | 29 | migration_network_cidr="{{- .Values.conf.libvirt.live_migration_network_cidr -}}" |
| 30 | if [ -z "${migration_network_cidr}" ] ; then |
| 31 | migration_network_cidr="0/0" |
| 32 | fi |
| 33 | migration_interface=$(ip -4 route list ${migration_network_cidr} | awk -F 'dev' '{ print $2; exit }' | awk '{ print $1 }') || exit 1 |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 34 | fi |
| 35 | |
Mohammed Naser | 733635e | 2023-03-30 17:34:09 +0000 | [diff] [blame] | 36 | migration_address=$(ip a s $migration_interface | grep 'inet ' | awk '{print $2}' | awk -F "/" '{print $1}' | head -1) |
| 37 | |
| 38 | if [ -z "${migration_address}" ] ; then |
| 39 | echo "Var live_migration_interface is empty" |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
| 43 | tee > /tmp/pod-shared/nova-libvirt.conf << EOF |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 44 | [libvirt] |
| 45 | live_migration_inbound_addr = $migration_address |
| 46 | EOF |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 47 | |
| 48 | hypervisor_interface="{{- .Values.conf.hypervisor.host_interface -}}" |
| 49 | if [[ -z $hypervisor_interface ]]; then |
| 50 | # search for interface with default routing |
| 51 | # If there is not default gateway, exit |
Oleksandr K. | 24c88fd | 2024-12-08 22:28:50 -0800 | [diff] [blame] | 52 | hypervisor_network_cidr="{{- .Values.conf.hypervisor.host_network_cidr -}}" |
| 53 | if [ -z "${hypervisor_network_cidr}" ] ; then |
| 54 | hypervisor_network_cidr="0/0" |
| 55 | fi |
| 56 | hypervisor_interface=$(ip -4 route list ${hypervisor_network_cidr} | awk -F 'dev' '{ print $2; exit }' | awk '{ print $1 }') || exit 1 |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 57 | fi |
| 58 | |
| 59 | hypervisor_address=$(ip a s $hypervisor_interface | grep 'inet ' | awk '{print $2}' | awk -F "/" '{print $1}' | head -1) |
| 60 | |
| 61 | if [ -z "${hypervisor_address}" ] ; then |
| 62 | echo "Var my_ip is empty" |
| 63 | exit 1 |
| 64 | fi |
| 65 | |
| 66 | tee > /tmp/pod-shared/nova-hypervisor.conf << EOF |
| 67 | [DEFAULT] |
| 68 | my_ip = $hypervisor_address |
| 69 | EOF |
| 70 | |
| 71 | {{- if and ( empty .Values.conf.nova.DEFAULT.host ) ( .Values.pod.use_fqdn.compute ) }} |
| 72 | tee > /tmp/pod-shared/nova-compute-fqdn.conf << EOF |
| 73 | [DEFAULT] |
| 74 | host = $(hostname --fqdn) |
| 75 | EOF |
| 76 | {{- end }} |