Skip to content

Commit

Permalink
Add mounts option for tinet spec
Browse files Browse the repository at this point in the history
This commit is add mounts option for spec file.
For example, If I want to mount `pwd` direcotry as follows:
```
nodes:
  - name: T1
    image: slankdev/frr
    mounts:
      - "`pwd`:/mnt/test"
    interfaces:
      - { name: net0, type: direct, args: T2#net0 }
  - name: T2
    image: slankdev/frr
    interfaces:
      - { name: net0, type: direct, args: T1#net0 }
`
```
  • Loading branch information
Kento Kawakami committed Jan 16, 2020
1 parent 7b7db02 commit cb832af
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/pkg/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Node struct {
Image string `yaml:"image"`
Interfaces []Interface `yaml:"interfaces" mapstructure:"interfaces"`
Sysctls []Sysctl `yaml:"sysctls" mapstructure:"sysctls"`
Mounts []string `yaml:"mounts,flow"`
}

// Interface
Expand Down Expand Up @@ -367,6 +368,13 @@ func CreateNode(node Node) []string {
createNodeCmd += fmt.Sprintf("--sysctl %s ", sysctl.Sysctl)
}
}

if len(node.Mounts) != 0 {
for _, mount := range node.Mounts {
createNodeCmd += fmt.Sprintf("-v %s ", mount)
}
}

createNodeCmd += node.Image
} else if node.Type == "netns" {
createNodeCmd = fmt.Sprintf("ip netns add %s", node.Name)
Expand All @@ -377,6 +385,13 @@ func CreateNode(node Node) []string {
createNodeCmd += fmt.Sprintf("--sysctl %s ", sysctl.Sysctl)
}
}

if len(node.Mounts) != 0 {
for _, mount := range node.Mounts {
createNodeCmd += fmt.Sprintf("-v %s ", mount)
}
}

createNodeCmd += node.Image
} else {
// err := fmt.Errorf("unknown nodetype %s", node.Type)
Expand Down

0 comments on commit cb832af

Please sign in to comment.