-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbms-disable-cloudinit-network
More file actions
executable file
·112 lines (100 loc) · 2.89 KB
/
bms-disable-cloudinit-network
File metadata and controls
executable file
·112 lines (100 loc) · 2.89 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Script that checks whether bms-network-config was running successfully
# If so, it disables the network config in cloud-init, as this creates a
# conflict otherwise on SLES12 where it renames eth0 to bond0 ...
# Reference: osTicket #579132
# (c) Kurt Garloff <kurt.garloff@t-systems.com>, 9/2017
# License: CC-BY-SA-3.0
BMSCLOUDCFG=${BMSCLOUDCFG:-/etc/cloud/cloud.cfg.d/91_bms_netdisable.cfg}
BMSCLOUDDS=${BMSCLOUDDS:-/etc/cloud/cloud.cfg.d/92_bms_configdrivedisable.cfg}
disable_netcfg()
{
echo "Disabling network.config for cloud-init $BL"
cat >$BMSCLOUDCFG <<EOT
## File autogenerated by bms-disable-cloudinit-network
## Your changes will be overwritten!
network:
config: disabled
datasource:
OpenStack:
max_wait: 120
timeout: 50
retries: 5
apply_network_config: false
EOT
# TODO: Should we detect whether we need to disable the ConfigDrive DataSource
# 'cause meta_data.json is incomplete/broke on OTC BMS? Looking at hostname ...
echo "Disabling ConfigDrive DataSource for cloud-init"
cat >$BMSCLOUDDS <<EOT
## File autogenerated by bms-disable-cloudinit-network
## Your changes will be overwritten!
# Remove ConfigDrive from OTC standard DataSource list
datasource_list: [ OpenStack ]
EOT
#echo "Disabling cloud-init-local"
#systemctl disable cloud-init-local.service
cat >/etc/cloud/ds-identify.cfg <<EOT
policy: search,found=first,maybe=all,notfound=disabled
datasource_list: [ OpenStack ]
EOT
echo ""
echo "$(date) show /etc/cloud/ds-identify.cfg:"
cat /etc/cloud/ds-identify.cfg
echo ""
echo ""
echo "$(date) show ${BMSCLOUDCFG}:"
cat ${BMSCLOUDCFG}
echo ""
echo ""
echo "$(date) show ${BMSCLOUDDS}:"
cat ${BMSCLOUDDS}
echo ""
echo ""
echo "$(date) bms-network-setup, finished: disable_netcfg"
echo ""
}
enable_netcfg()
{
echo "Enabling network.config for cloud-init"
cat >$BMSCLOUDCFG <<EOT
## File autogenerated by bms-disable-cloudinit-network
## Your changes will be overwritten!
#network:
# config: disabled
#datasource:
# OpenStack:
# max_wait: 120
# timeout: 50
# retries: 5
# apply_network_config: false
EOT
echo "Enabling ConfigDrive DataSource for cloud-init"
cat >$BMSCLOUDDS <<EOT
## File autogenerated by bms-disable-cloudinit-network
## Your changes will be overwritten!
# Remove ConfigDrive from OTC standard DataSource list
#datasource_list: [ OpenStack ]
EOT
#echo "Enabling cloud-init-local"
#systemctl enable cloud-init-local.service
cat >/etc/cloud/ds-identify.cfg <<EOT
policy: search,found=first,maybe=all,notfound=disabled
datasource_list: [ OpenStack ]
EOT
}
is_disabled()
{
grep '^[^#].*config: disabled[ }]*$' $BMSCLOUDCFG >/dev/null 2>&1
}
detect_bms()
{
if test -n "$DEBUG"; then return $DEBUG; fi
if test -e /etc/is_bms; then return 0; fi
return 1
}
# main
if detect_bms; then
if ! is_disabled; then disable_netcfg; fi
else
if is_disabled; then enable_netcfg; fi
fi