hs-test: add vppctl wrapper script
[vpp.git] / extras / hs-test / topo.go
1 package main
2
3 import (
4         "fmt"
5 )
6
7 type NetDevConfig map[string]interface{}
8 type ContainerConfig map[string]interface{}
9 type VolumeConfig map[string]interface{}
10
11 type YamlTopology struct {
12         Devices    []NetDevConfig    `yaml:"devices"`
13         Containers []ContainerConfig `yaml:"containers"`
14         Volumes    []VolumeConfig    `yaml:"volumes"`
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 }