Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 5 | ) |
| 6 | |
| 7 | type NetDevConfig map[string]interface{} |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 8 | type ContainerConfig map[string]interface{} |
Maros Ondrejicka | f719adf | 2022-12-20 15:10:50 +0100 | [diff] [blame] | 9 | type VolumeConfig map[string]interface{} |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 10 | |
| 11 | type YamlTopology struct { |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 12 | Devices []NetDevConfig `yaml:"devices"` |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 13 | Containers []ContainerConfig `yaml:"containers"` |
Maros Ondrejicka | f719adf | 2022-12-20 15:10:50 +0100 | [diff] [blame] | 14 | Volumes []VolumeConfig `yaml:"volumes"` |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | func AddAddress(device, address, ns string) error { |
| 18 | c := []string{"ip", "addr", "add", address, "dev", device} |
| 19 | cmd := appendNetns(c, ns) |
| 20 | err := cmd.Run() |
| 21 | if err != nil { |
| 22 | return fmt.Errorf("failed to set ip address for %s: %v", device, err) |
| 23 | } |
| 24 | return nil |
| 25 | } |