f-73: metadata: network-config par VM, une entrée ethN par NIC visée par sa MAC, métrique croissante des NIC secondaires #73
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
c26606787e
commit
450d0c801a
5 changed files with 86 additions and 7 deletions
|
|
@ -78,14 +78,30 @@ func TestRenderConfig_VendorData_ContainsSSHKey(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRenderConfig_NetworkConfig(t *testing.T) {
|
||||
func TestRenderConfig_NetworkConfigMatchesEveryInterfaceByMAC(t *testing.T) {
|
||||
cfg := newCfg()
|
||||
out, err := RenderConfig("templates/network-config.tmpl", cfg)
|
||||
cfg.NICs = []NIC{{MAC: "52:54:00:49:01:0c", RouteMetric: 100}, {MAC: "52:54:00:49:02:16", RouteMetric: 200}}
|
||||
out, err := renderDocument(DocNetworkConfig, cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("RenderConfig network-config : %v", err)
|
||||
t.Fatalf("renderDocument network-config : %v", err)
|
||||
}
|
||||
if !strings.Contains(out, "dhcp4: true") {
|
||||
t.Errorf("dhcp4 absent du network-config :\n%s", out)
|
||||
want := `version: 2
|
||||
ethernets:
|
||||
eth0:
|
||||
match:
|
||||
macaddress: "52:54:00:49:01:0c"
|
||||
dhcp4: true
|
||||
dhcp4-overrides:
|
||||
route-metric: 100
|
||||
eth1:
|
||||
match:
|
||||
macaddress: "52:54:00:49:02:16"
|
||||
dhcp4: true
|
||||
dhcp4-overrides:
|
||||
route-metric: 200
|
||||
`
|
||||
if out != want {
|
||||
t.Errorf("network-config :\n%s\nattendu :\n%s", out, want)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue