2022-08-09 14:44:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type NetDevConfig map[string]interface{}
|
2022-12-14 16:30:04 +01:00
|
|
|
type ContainerConfig map[string]interface{}
|
2022-12-20 15:10:50 +01:00
|
|
|
type VolumeConfig map[string]interface{}
|
2022-08-09 14:44:47 +00:00
|
|
|
|
|
|
|
type YamlTopology struct {
|
2023-01-09 12:07:09 +01:00
|
|
|
Devices []NetDevConfig `yaml:"devices"`
|
2022-12-14 16:30:04 +01:00
|
|
|
Containers []ContainerConfig `yaml:"containers"`
|
2022-12-20 15:10:50 +01:00
|
|
|
Volumes []VolumeConfig `yaml:"volumes"`
|
2022-08-09 14:44:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func AddAddress(device, address, ns string) error {
|
|
|
|
c := []string{"ip", "addr", "add", address, "dev", device}
|
|
|
|
cmd := appendNetns(c, ns)
|
|
|
|
err := cmd.Run()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to set ip address for %s: %v", device, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|