summaryrefslogtreecommitdiff
path: root/openstack-ironic.configure
blob: 57c572663ea9ea401ca3e6782c20b2d461c640e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash

# Copyright (C) 2014-2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

set -e

ROOT="$1"

##########################################################################
# Substitutions in configuration files                                   #
##########################################################################

cat <<EOF > "$ROOT"/etc/openstack-ironic-setup.sed
s/##IRONIC_HOST##/$IRONIC_HOST/g
s/##IRONIC_SERVICE_USER##/$IRONIC_SERVICE_USER/g
s/##IRONIC_SERVICE_PASSWORD##/$IRONIC_SERVICE_PASSWORD/g
s/##IRONIC_DB_USER##/$IRONIC_DB_USER/g
s/##IRONIC_DB_PASSWORD##/$IRONIC_DB_PASSWORD/g
s/##IRONIC_PUBLIC_URL##/$IRONIC_PUBLIC_URL/g
s/##IRONIC_INTERNAL_URL##/$IRONIC_INTERNAL_URL/g
s/##IRONIC_ADMIN_URL##/$IRONIC_ADMIN_URL/g
s/##GLANCE_HOST##/$GLANCE_HOST/g
s/##OPENSTACK_AUTH_HOST##/$OPENSTACK_AUTH_HOST/g
s/##OPENSTACK_AUTH_PORT##/$OPENSTACK_AUTH_PORT/g
s/##RABBITMQ_HOST##/$RABBITMQ_HOST/g
s/##IDENTITY_URI##/$IDENTITY_URI/g

EOF

sed -f "$ROOT"/etc/openstack-ironic-setup.sed -i \
       "$ROOT"/etc/ironic/ironic.conf \
       "$ROOT"/usr/share/openstack/openstack-ironic-setup

##########################################################################
# Create the links to enable the ironic systemd services                 #
##########################################################################

services=("openstack-ironic-setup.service" \
          "openstack-ironic-api.service" \
          "openstack-ironic-conductor.service")

for service in ${services[@]}; do
    ln -sf "/etc/systemd/system/$service" \
        "$ROOT/etc/systemd/system/multi-user.target.wants/$service"
done


##########################################################################
# Configure the TFTP service                                             #
##########################################################################

tftp_root="/srv/tftp_root/" # trailing slash is essential
mkdir -p "$ROOT/$tftp_root"

install -D /dev/stdin "$ROOT/usr/lib/systemd/system/tftp-hpa.service" <<EOF
[Unit]
Description=tftp service for booting kernels
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/udpsvd -E 0 69 /usr/sbin/in.tftpd -v -v -v -v -v --map-file $tftp_root/map-file $tftp_root

[Install]
WantedBy=multi-user.target
EOF

ln -sf /usr/lib/systemd/system/tftp-hpa.service \
    "$ROOT"/etc/systemd/system/multi-user.target.wants/tftp-hpa.service

echo "r ^([^/]) $tftp_root\1" > "$ROOT/$tftp_root"/map-file
echo "r ^/tftpboot/ $tftp_root\2" >> "$ROOT/$tftp_root"/map-file

cp "$ROOT"/usr/share/syslinux/pxelinux.0 "$ROOT/$tftp_root"