mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2026-06-21 00:07:16 +03:00
nocloud: add static IPv4 network-config support
This commit is contained in:
parent
90e028231e
commit
dfe114dbed
@ -87,6 +87,26 @@ set_network_config_v2() {
|
||||
"use dhcp" >> "$ETC/network/interfaces"
|
||||
configured=1
|
||||
;;
|
||||
*)
|
||||
local address gateway nameservers server
|
||||
address="$(get_network_config ethernets/$iface/addresses/1)"
|
||||
[ -n "$address" ] || continue
|
||||
printf "%s\n%s\n\taddress %s\n" \
|
||||
"auto $target_name" \
|
||||
"iface $target_name" \
|
||||
"$address" >> "$ETC/network/interfaces"
|
||||
gateway="$(get_network_config ethernets/$iface/gateway4)"
|
||||
if [ -n "$gateway" ]; then
|
||||
printf "\tgateway %s\n" "$gateway" >> "$ETC/network/interfaces"
|
||||
fi
|
||||
printf "\n" >> "$ETC/network/interfaces"
|
||||
nameservers="$(get_network_config ethernets/$iface/nameservers/addresses)"
|
||||
for server in $nameservers; do
|
||||
add_once "$ETC/resolv.conf" \
|
||||
"nameserver $(get_network_config ethernets/$iface/nameservers/addresses/$server)"
|
||||
done
|
||||
configured=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ init_tests \
|
||||
set_network_config_v2_dhcp4 \
|
||||
set_network_config_v2_match_macaddress_set_name_dhcp4 \
|
||||
set_network_config_v2_configures_macifrename_service \
|
||||
set_network_config_v2_static_ipv4 \
|
||||
set_network_config_auto \
|
||||
userdata_user_name \
|
||||
userdata_user_homedir \
|
||||
@ -170,6 +171,7 @@ set_network_config_v2_configures_macifrename_service_body() {
|
||||
atf_check \
|
||||
-o match:"rc-update add macifrename boot" \
|
||||
-o match:"rc-service macifrename start" \
|
||||
-o match:"rc-update add sshd default" \
|
||||
-e match:"set_network_interfaces: done" \
|
||||
tiny-cloud boot
|
||||
|
||||
@ -178,6 +180,41 @@ set_network_config_v2_configures_macifrename_service_body() {
|
||||
cat etc/conf.d/macifrename
|
||||
}
|
||||
|
||||
set_network_config_v2_static_ipv4_body() {
|
||||
fake_network_config_nocloud <<-EOF
|
||||
version: 2
|
||||
ethernets:
|
||||
net0:
|
||||
match:
|
||||
macaddress: 52:55:55:1d:2a:0b
|
||||
set-name: lima0
|
||||
addresses:
|
||||
- 192.168.100.10/24
|
||||
gateway4: 192.168.100.1
|
||||
nameservers:
|
||||
addresses:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
EOF
|
||||
|
||||
atf_check \
|
||||
-o ignore \
|
||||
-e match:"set_network_interfaces: done" \
|
||||
tiny-cloud boot
|
||||
|
||||
atf_check \
|
||||
-o match:"auto lima0" \
|
||||
-o match:"iface lima0" \
|
||||
-o match:"address 192.168.100.10/24" \
|
||||
-o match:"gateway 192.168.100.1" \
|
||||
cat etc/network/interfaces
|
||||
|
||||
atf_check \
|
||||
-o match:"^nameserver 8.8.8.8$" \
|
||||
-o match:"^nameserver 8.8.4.4$" \
|
||||
cat etc/resolv.conf
|
||||
}
|
||||
|
||||
set_network_config_auto_body() {
|
||||
fake_metadata_nocloud <<-EOF
|
||||
resolv_conf:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user