blob: f9c6528ba93413c898e36223f2180b07a05f0bad [file] [log] [blame]
Adrian Villin4677d922024-06-14 09:32:39 +02001package hst
Filip Tehlar229f5fc2022-08-09 14:44:47 +00002
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
Maros Ondrejickae7625d02023-02-28 16:55:01 +010017func addAddress(device, address, ns string) error {
Filip Tehlar229f5fc2022-08-09 14:44:47 +000018 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}