examples, cloud-init: remove duplicated network data
Move this network data configuration to a const, and re-use it
when appropriate.
@@ -110,6 +110,12 @@ runcmd:
cloudConfigUserPassword = `password: fedora
chpasswd: { expire: False }`
+
+ secondaryIfaceDhcpNetworkData = `version: 2
+ethernets:
+ eth1:
+ dhcp4: true
+`
)
var DockerPrefix = "registry:5000/kubevirt"
@@ -489,8 +495,7 @@ func GetVMISRIOV() *v1.VirtualMachineInstance {
vm.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("1024M")
vm.Spec.Networks = []v1.Network{*v1.DefaultPodNetwork(), {Name: "sriov-net", NetworkSource: v1.NetworkSource{Multus: &v1.MultusNetwork{NetworkName: "sriov/sriov-network"}}}}
initFedora(&vm.Spec)
- networkData := "version: 2\nethernets:\n eth1:\n dhcp4: true\n"
- addNoCloudDiskWitUserDataNetworkData(&vm.Spec, generateCloudConfigString(cloudConfigUserPassword), networkData)
+ addNoCloudDiskWitUserDataNetworkData(&vm.Spec, generateCloudConfigString(cloudConfigUserPassword), secondaryIfaceDhcpNetworkData)
vm.Spec.Domain.Devices.Interfaces = []v1.Interface{{Name: "default", InterfaceBindingMethod: v1.InterfaceBindingMethod{Masquerade: &v1.InterfaceMasquerade{}}},
{Name: "sriov-net", InterfaceBindingMethod: v1.InterfaceBindingMethod{SRIOV: &v1.InterfaceSRIOV{}}}}
@@ -515,8 +520,7 @@ func GetVMIMultusMultipleNet() *v1.VirtualMachineInstance {
vm.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("1024M")
vm.Spec.Networks = []v1.Network{*v1.DefaultPodNetwork(), {Name: "ptp", NetworkSource: v1.NetworkSource{Multus: &v1.MultusNetwork{NetworkName: "ptp-conf"}}}}
initFedora(&vm.Spec)
- networkData := "version: 2\nethernets:\n eth1:\n dhcp4: true\n"
- addNoCloudDiskWitUserDataNetworkData(&vm.Spec, generateCloudConfigString(cloudConfigUserPassword), networkData)
+ addNoCloudDiskWitUserDataNetworkData(&vm.Spec, generateCloudConfigString(cloudConfigUserPassword), secondaryIfaceDhcpNetworkData)
vm.Spec.Domain.Devices.Interfaces = []v1.Interface{{Name: "default", InterfaceBindingMethod: v1.InterfaceBindingMethod{Masquerade: &v1.InterfaceMasquerade{}}},
{Name: "ptp", InterfaceBindingMethod: v1.InterfaceBindingMethod{Bridge: &v1.InterfaceBridge{}}}}
