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
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
configuration "git.g3e.fr/syonad/two/internal/config/agent"
|
||||
"git.g3e.fr/syonad/two/internal/dhcpbackend"
|
||||
|
|
@ -71,6 +72,7 @@ func StartVM(db *badger.DB, name string, cfg *configuration.Config) error {
|
|||
BindPort: d.metadataPort,
|
||||
Password: d.password,
|
||||
SSHKEY: d.sshkey,
|
||||
NICs: metadataNICs(d.nics),
|
||||
Documents: d.documents,
|
||||
}, cfg, false); err != nil {
|
||||
return fmt.Errorf("start metadata: %w", err)
|
||||
|
|
@ -171,3 +173,16 @@ func copyFile(src, dst string) error {
|
|||
}
|
||||
return out.Sync()
|
||||
}
|
||||
|
||||
func metadataNICs(nics []nicData) []metadata.NIC {
|
||||
out := make([]metadata.NIC, len(nics))
|
||||
next := 200
|
||||
for i, n := range nics {
|
||||
out[i] = metadata.NIC{MAC: strings.ToLower(n.mac), RouteMetric: 100}
|
||||
if !n.primary {
|
||||
out[i].RouteMetric = next
|
||||
next += 100
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue