summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/topo.go
blob: 6cb294511b34573f004db02c65d6c76df4fee9bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main

import (
	"fmt"
)

type NetDevConfig map[string]interface{}
type ContainerConfig map[string]interface{}
type VolumeConfig map[string]interface{}

type YamlTopology struct {
	Devices    []NetDevConfig    `yaml:"devices"`
	Containers []ContainerConfig `yaml:"containers"`
	Volumes    []VolumeConfig    `yaml:"volumes"`
}

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
}