f-89: fip: IP flottante refusée sur une interface public_ip #89
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
46aad1e7c5
commit
7d15ccf56f
6 changed files with 25 additions and 4 deletions
|
|
@ -24,6 +24,8 @@ type Target struct {
|
|||
VPC string
|
||||
CIDR *net.IPNet
|
||||
Private net.IP
|
||||
Subnet string
|
||||
Mode string
|
||||
}
|
||||
|
||||
type floatingIP struct {
|
||||
|
|
@ -85,7 +87,11 @@ func Resolve(db *badger.DB, vmName, ifaceName string) (Target, error) {
|
|||
if err != nil {
|
||||
return Target{}, fmt.Errorf("vm %q: interface %q: invalid cidr %q of vpc %q", vmName, ifaceName, raw, vpc)
|
||||
}
|
||||
return Target{VPC: vpc, CIDR: cidr, Private: ip}, nil
|
||||
mode, err := kv.GetFromDB(db, "subnet/"+subnet+"/mode")
|
||||
if err != nil {
|
||||
return Target{}, fmt.Errorf("vm %q: interface %q: mode of subnet %q: %w", vmName, ifaceName, subnet, err)
|
||||
}
|
||||
return Target{VPC: vpc, CIDR: cidr, Private: ip, Subnet: subnet, Mode: mode}, nil
|
||||
}
|
||||
return Target{}, fmt.Errorf("vm %q has no interface %q", vmName, ifaceName)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ func seedVM(t *testing.T) *badger.DB {
|
|||
t.Cleanup(func() { db.Close() })
|
||||
for key, value := range map[string]string{
|
||||
"vpc/vp-t47/cidr": "10.47.0.0/16",
|
||||
"subnet/sn-a/mode": "vxlan",
|
||||
"subnet/sn-b/mode": "public_ip",
|
||||
"subnet/sn-a/vpc": "vp-t47",
|
||||
"subnet/sn-b/vpc": "vp-t47",
|
||||
"vm/vm-1/nic/0/name": "nic-a1b2",
|
||||
|
|
@ -206,7 +208,7 @@ func TestResolveFindsTheInterfaceByName(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.VPC != "vp-t47" || got.CIDR.String() != "10.47.0.0/16" || got.Private.String() != "10.47.2.10" {
|
||||
if got.VPC != "vp-t47" || got.CIDR.String() != "10.47.0.0/16" || got.Private.String() != "10.47.2.10" || got.Subnet != "sn-b" || got.Mode != "public_ip" {
|
||||
t.Errorf("cible %+v", got)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue