cloud-init, tests: fedora VMI creation will use networkData
Fedora based VMIs whose cloudInit userData scripts require
connectivity will have their IPv6 address configuration performed
via cloud-init's networkData section.
@@ -2103,7 +2103,16 @@ func NewRandomFedora32VMIWithFedoraUser() *v1.VirtualMachineInstance {
}
func NewRandomFedoraVMIWitGuestAgent() *v1.VirtualMachineInstance {
- agentVMI := NewRandomVMIWithEphemeralDiskAndUserdata(ContainerDiskFor(ContainerDiskFedora), GetGuestAgentUserData())
+ virtClient, err := kubecli.GetKubevirtClient()
+ PanicOnError(err)
+
+ dnsServerIP, err := getClusterDnsServiceIP(virtClient)
+ PanicOnError(err)
+
+ searchDomains := getVMISeachDomains()
+ networkData := GetCloudInitNetworkData(ipv6MasqueradeAddress, ipv6MasqueradeGateway, dnsServerIP, searchDomains)
+
+ agentVMI := NewRandomVMIWithEphemeralDiskAndUserdataNetworkData(ContainerDiskFor(ContainerDiskFedora), GetGuestAgentUserData(), networkData, false)
agentVMI.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("512M")
return agentVMI
}
@@ -2120,34 +2129,23 @@ func NewRandomFedoraVMIWithDmidecode() *v1.VirtualMachineInstance {
}
func GetGuestAgentUserData() string {
- virtClient, err := kubecli.GetKubevirtClient()
- PanicOnError(err)
-
- dnsServerIP, err := getClusterDnsServiceIP(virtClient)
- PanicOnError(err)
-
- ipv6UserDataString := ""
- if netutils.IsIPv6String(dnsServerIP) {
- ipv6UserDataString = fmt.Sprintf(`sudo ip -6 addr add fd10:0:2::2/120 dev eth0
- for i in {1..20}; do sudo ip -6 route add default via fd10:0:2::1 src fd10:0:2::2 && break || sleep 0.1; done
- echo "nameserver %s" >> /etc/resolv.conf`, dnsServerIP)
- }
+ guestAgentUrl := GetUrl(GuestAgentHttpUrl)
return fmt.Sprintf(`#!/bin/bash
echo "fedora" |passwd fedora --stdin
- systemctl disable NetworkManager
- systemctl stop NetworkManager
- %s
mkdir -p /usr/local/bin
+ for i in {1..20}; do curl -I %s | grep "200 OK" && break || sleep 0.1; done
curl %s > /usr/local/bin/qemu-ga
chmod +x /usr/local/bin/qemu-ga
curl %s > /usr/local/bin/stress
chmod +x /usr/local/bin/stress
setenforce 0
systemd-run --unit=guestagent /usr/local/bin/qemu-ga
- `, ipv6UserDataString, GetUrl(GuestAgentHttpUrl), GetUrl(StressHttpUrl))
+ `, guestAgentUrl, guestAgentUrl, GetUrl(StressHttpUrl))
}
-func GetIPv6NetworkData(ipAddress string, gateway string, dnsServer string, searchDomains []string) string {
+// Returns NetworkData for configuring a dynamic IPv4 address, and a static
+//IPv6 address, along with DNS configuration.
+func GetCloudInitNetworkData(ipAddress string, gateway string, dnsServer string, searchDomains []string) string {
networkData := fmt.Sprintf(`
version: 2
ethernets:
