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
2b252bb40c
commit
047d231556
6 changed files with 25 additions and 4 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
configuration "git.g3e.fr/syonad/two/internal/config/agent"
|
||||
"git.g3e.fr/syonad/two/internal/fip"
|
||||
"git.g3e.fr/syonad/two/internal/state"
|
||||
"git.g3e.fr/syonad/two/internal/subnet"
|
||||
"git.g3e.fr/syonad/two/pkg/db/kv"
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
)
|
||||
|
|
@ -39,9 +40,13 @@ func (c CreateFloatingIPCommand) Prepare(db *badger.DB, _ *configuration.Config)
|
|||
if vmState != state.Running {
|
||||
return fmt.Errorf("vm %q is %s", c.VM, vmState)
|
||||
}
|
||||
if _, err := fip.Resolve(db, c.VM, c.Interface); err != nil {
|
||||
target, err := fip.Resolve(db, c.VM, c.Interface)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if target.Mode == subnet.ModePublicIP {
|
||||
return fmt.Errorf("interface %q of vm %q is on public_ip subnet %q: it carries its public ip itself", c.Interface, c.VM, target.Subnet)
|
||||
}
|
||||
others, err := floatingIPs(db)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue