Adrian Villin | 4677d92 | 2024-06-14 09:32:39 +0200 | [diff] [blame^] | 1 | package hst |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 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 | |
Maros Ondrejicka | e7625d0 | 2023-02-28 16:55:01 +0100 | [diff] [blame] | 17 | func addAddress(device, address, ns string) error { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 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 | } |