shell

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package shell generate shell script

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DockerPs

func DockerPs(all bool) (dockerPsCmd string)

DockerPs Show docker ps

func ExecCmd

func ExecCmd(cmds []Cmd) (execCmds []string)

ExecCmd Execute cmds

func GenerateFile

func GenerateFile() (genContent string, err error)

GenerateFile Generate tinet template config file

func GetContainerPid

func GetContainerPid(nodename string) (getpidCmd string)

GetContainerPid func is Output get Docker PID Command

func HostLinkUp

func HostLinkUp(linkName string) (linkUpCmd string)

HostLinkUp Link up link of host

func NetnsLinkUp

func NetnsLinkUp(netnsName string, linkName string) (netnsLinkUpCmd string)

NetnsLinkUp Link up link of netns

func NetnsPs

func NetnsPs() (netnsListCmd string)

NetnsPs Show ip netns list

func Pull

func Pull(nodes []Node) (pullCmds []string)

Pull pull Docker Image

Types

type Cmd

type Cmd struct {
	Cmd string `yaml:"cmd"`
}

Cmd

type Interface

type Interface struct {
	Name  string `yaml:"name"`
	Type  string `yaml:"type"`
	Args  string `yaml:"args"`
	Addr  string `yaml:"addr"`
	Label string `yaml:"label"`
}

Interface

func (*Interface) AddrSet added in v0.0.3

func (inf *Interface) AddrSet(nodeName string) (addrSetCmd string)
func (inf *Interface) N2nLink(nodeName string) (n2nLinkCmds []string)

N2nLink Connect links between nodes

func (inf *Interface) P2cLink(nodeName string) (p2cLinkCmds []string)

P2cLink Connect links between phys-eth and container

func (inf *Interface) S2nLink(nodeName string) (s2nLinkCmds []string)

S2nLink Connect links between nodes and switches

func (inf *Interface) V2cLink(nodeName string) (v2cLinkCmds []string)

V2cLink Connect links between veth and container

type Node

type Node struct {
	Name           string                 `yaml:"name" mapstructure:"name"`
	Type           string                 `yaml:"type" mapstructure:"type"`
	NetBase        string                 `yaml:"net_base" mapstructure:"net_base"`
	VolumeBase     string                 `yaml:"volume" mapstructure:"volume"`
	Image          string                 `yaml:"image" mapstructure:"image"`
	BuildFile      string                 `yaml:"buildfile" mapstructure:"buildfile"`
	BuildContext   string                 `yaml:"buildcontext" mapstructure:"buildcontext"`
	Interfaces     []Interface            `yaml:"interfaces" mapstructure:"interfaces"`
	Sysctls        []Sysctl               `yaml:"sysctls" mapstructure:"sysctls"`
	Mounts         []string               `yaml:"mounts,flow" mapstructure:"mounts,flow"`
	DNS            []string               `yaml:"dns,flow" mapstructure:"dns,flow"`
	DNSSearches    []string               `yaml:"dns_search,flow" mapstructure:"dns_search,flow"`
	HostNameIgnore bool                   `yaml:"hostname_ignore" mapstructure:"hostname_ignore"`
	EntryPoint     string                 `yaml:"entrypoint" mapstructure:"entrypoint"`
	ExtraArgs      string                 `yaml:"docker_run_extra_args" mapstructure:"docker_run_extra_args"`
	Vars           map[string]interface{} `yaml:"vars" mapstructure:"vars"`
	Templates      []Template             `yaml:"templates" mapstructure:"templates"`
}

Node

func (*Node) BuildCmd added in v0.0.2

func (node *Node) BuildCmd() (buildCmd string)

BuildCmd

func (*Node) CreateNode

func (node *Node) CreateNode() (createNodeCmds []string)

CreateNode Create nodes set in config

func (*Node) DelNsCmd

func (node *Node) DelNsCmd() (delNsCmd string)

DelNsCmds

func (*Node) DeleteNode

func (node *Node) DeleteNode() (deleteNodeCmds []string)

DeleteNode Delete docker and netns

func (*Node) MountTmpl added in v0.0.3

func (node *Node) MountTmpl() (mountTmplCmd []string, err error)

MountTmpl

func (*Node) Mount_docker_netns

func (node *Node) Mount_docker_netns() (mountDockerNetnsCmds []string)

Mount_docker_netns Mount docker netns to ip netns

type NodeConfig

type NodeConfig struct {
	Name string `yaml:"name"`
	Cmds []Cmd  `yaml:"cmds" mapstructure:"cmds"`
}

NodeConfig

func (*NodeConfig) ExecConf

func (nodeConfig *NodeConfig) ExecConf(nodeType string) (execConfCmds []string)

ExecConf Execute NodeConfig command

type PostFini

type PostFini struct {
	Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
}

PostFini

type PostInit

type PostInit struct {
	Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
}

PostInit

type PreCmd

type PreCmd struct {
	// Cmds []Cmd `yaml:"cmds"`
	Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
}

PreCmd

type PreInit

type PreInit struct {
	Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
}

PreInit

type Switch

type Switch struct {
	Name       string      `yaml:"name"`
	Interfaces []Interface `yaml:"interfaces" mapstructure:"interfaces"`
}

Switch

func (*Switch) CreateSwitch

func (bridge *Switch) CreateSwitch() (createSwitchCmds []string)

CreateSwitch Create bridge set in config

func (*Switch) DeleteSwitch

func (br *Switch) DeleteSwitch() (deleteBrCmd string)

DeleteSwitch Delete bridge

type Sysctl

type Sysctl struct {
	Sysctl string `yaml:"string"`
}

Sysctl

type Template added in v0.0.3

type Template struct {
	Src     string `yaml:"src"`
	Dst     string `yaml:"dst"`
	Content string `yaml:"content"`
}

type Test

type Test struct {
	Name string
	Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
}

Test

func (*Test) TnTestCmdExec

func (t *Test) TnTestCmdExec() (tnTestCmds []string)

TnTestCmdExec Execute test cmds

type Tn

type Tn struct {
	PreCmd      []PreCmd     `yaml:"precmd"`
	PreInit     []PreInit    `yaml:"preinit"`
	PostInit    []PostInit   `yaml:"postinit"`
	PostFini    []PostFini   `yaml:"postfini"`
	Nodes       []Node       `yaml:"nodes" mapstructure:"nodes"`
	Switches    []Switch     `yaml:"switches" mapstructure:"switches"`
	NodeConfigs []NodeConfig `yaml:"node_configs" mapstructure:"node_configs"`
	Test        []Test       `yaml:"test"`
}

Tn tinet config

func (*Tn) Exec

func (tnconfig *Tn) Exec(nodeName string, Cmds []string) (execCommand string)

Exec Select Node exec command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL