blob: d77d2dab33fb26e867a5c5127502cf2dc14b557f [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
3import (
4 "fmt"
Filip Tehlar229f5fc2022-08-09 14:44:47 +00005)
6
7type NetDevConfig map[string]interface{}
Maros Ondrejickadb823ed2022-12-14 16:30:04 +01008type ContainerConfig map[string]interface{}
Maros Ondrejickaf719adf2022-12-20 15:10:50 +01009type VolumeConfig map[string]interface{}
Filip Tehlar229f5fc2022-08-09 14:44:47 +000010
11type YamlTopology struct {
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010012 Devices []NetDevConfig `yaml:"devices"`
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010013 Containers []ContainerConfig `yaml:"containers"`
Maros Ondrejickaf719adf2022-12-20 15:10:50 +010014 Volumes []VolumeConfig `yaml:"volumes"`
Filip Tehlar229f5fc2022-08-09 14:44:47 +000015}
16
17func 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}