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