f-62: vm: MAC fournie à la création par interface, fin de la table préchargée, migration #62
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
c26606787e
commit
077141443e
20 changed files with 338 additions and 171 deletions
|
|
@ -8,7 +8,6 @@ import (
|
|||
"strings"
|
||||
|
||||
dhcpapi "git.g3e.fr/syonad/two/internal/api/dhcp"
|
||||
"git.g3e.fr/syonad/two/internal/dhcp"
|
||||
"git.g3e.fr/syonad/two/internal/dhcpbackend"
|
||||
"git.g3e.fr/syonad/two/internal/state"
|
||||
"git.g3e.fr/syonad/two/internal/watchdog/notify"
|
||||
|
|
@ -111,9 +110,9 @@ func expectedVMHosts(db *badger.DB, vmName, subnetName string) ([]dhcpapi.Host,
|
|||
if ip == "" {
|
||||
return nil, fmt.Errorf("nic %d of vm %s has no ip", idx, vmName)
|
||||
}
|
||||
mac, err := dhcp.GetMACForIP(db, subnetName, ip)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get mac for ip %s: %w", ip, err)
|
||||
mac := entries[nic+"mac"]
|
||||
if mac == "" {
|
||||
return nil, fmt.Errorf("nic %d of vm %s has no mac", idx, vmName)
|
||||
}
|
||||
|
||||
hosts = append(hosts, dhcpapi.Host{
|
||||
|
|
|
|||
|
|
@ -69,13 +69,13 @@ func seedSubnetWithVM(t *testing.T, db *badger.DB, vmName, ip, mac string, prima
|
|||
t.Helper()
|
||||
|
||||
seedKV(t, db, "subnet/"+testSubnetName+"/vpc", testVPC)
|
||||
seedKV(t, db, "subnet/"+testSubnetName+"/dhcp/"+ip, mac)
|
||||
|
||||
if err := state.Set(db, "vm/"+vmName, state.Running); err != nil {
|
||||
t.Fatalf("state.Set: %v", err)
|
||||
}
|
||||
seedKV(t, db, "vm/"+vmName+"/nic/0/subnet", testSubnetName)
|
||||
seedKV(t, db, "vm/"+vmName+"/nic/0/ip", ip)
|
||||
seedKV(t, db, "vm/"+vmName+"/nic/0/mac", mac)
|
||||
seedKV(t, db, "vm/"+vmName+"/nic/0/primary", fmt.Sprintf("%t", primary))
|
||||
}
|
||||
|
||||
|
|
@ -147,13 +147,14 @@ func TestExpectedHosts_SortsByMAC(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestExpectedHosts_ReportsAnIPWithoutAMAC(t *testing.T) {
|
||||
func TestExpectedHosts_ReportsAnInterfaceWithoutAMAC(t *testing.T) {
|
||||
db := newTestDB(t)
|
||||
seedSubnetWithVM(t, db, "vm-web", "10.0.5.10", "00:22:33:00:00:0A", true)
|
||||
seedKV(t, db, "vm/vm-web/nic/0/ip", "10.0.5.99")
|
||||
seedResource(t, db, "vm/", "vm-web", state.Running)
|
||||
seedKV(t, db, "vm/vm-web/nic/0/subnet", testSubnetName)
|
||||
seedKV(t, db, "vm/vm-web/nic/0/ip", "10.0.5.10")
|
||||
|
||||
if _, _, err := expectedHosts(db, testSubnetName); err == nil {
|
||||
t.Fatal("an ip absent from the address plan must be reported, not skipped")
|
||||
t.Fatal("an interface without a mac must be reported, not skipped")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue