Documentation
¶
Index ¶
- Constants
- func AddMachine(f Factory) (string, error)
- func CheckExist(id string) bool
- func ContainerConnectNetwork(id string, network *Network) error
- func DeleteContainer(containerID string) error
- func DeleteVM(UUID string) error
- func KillContainer(containerID string, signal string) error
- func KillVM(UUID string, signal string) error
- func PauseContainer(containerID string) error
- func PauseVM(UUID string) error
- func RestartContainer(timeout int32, containerID string) error
- func RestartVM(timeout int32, UUID string) error
- func StartContainer(containerID string) error
- func StartVM(UUID string) error
- func StopContainer(timeout int32, containerID string) error
- func StopVM(timeout int32, UUID string) error
- func UnpauseContainer(containerID string) error
- func UnpauseVM(UUID string) error
- func VMConnectNetwork(id string, nw *Network) error
- type Base
- func (m *Base) Commit(name string) (string, error)
- func (m *Base) ConnectNetWork(nw *Network) error
- func (m *Base) Delete() error
- func (m *Base) GetImageID() string
- func (m *Base) GetName() string
- func (m *Base) GetState() string
- func (m *Base) GetStdio(detachKey string) (chan []byte, chan []byte, chan []byte, error)
- func (m *Base) Inspect() (name string, runtimeSetting string, spec string, machineType string, err error)
- func (m *Base) Kill(signal string) error
- func (m *Base) Pause() error
- func (m *Base) Rename(newName string) error
- func (m *Base) ResizeTTY(h uint32, w uint32) error
- func (m *Base) Restart(timeout int32) error
- func (m *Base) Start() error
- func (m *Base) Stop(timeout int32) error
- func (m *Base) Unpause() error
- type BaseContainer
- func (container *BaseContainer) Create() error
- func (container *BaseContainer) GetBase() (*Base, error)
- func (container *BaseContainer) SetCgroups(res docker.Resources)
- func (container *BaseContainer) SetCmd(cmd []string)
- func (container *BaseContainer) SetEntrypoint(entrypoint []string)
- func (container *BaseContainer) SetEnv(env []string)
- func (container *BaseContainer) SetExposedPorts(info []proxy.ProxyInfo)
- func (container *BaseContainer) SetHostname(name string)
- func (container *BaseContainer) SetHosts(hosts []string)
- func (container *BaseContainer) SetImage(imageID string, path string, name string)
- func (container *BaseContainer) SetName(name string) error
- func (container *BaseContainer) SetNetworks(networks []*Network)
- func (container *BaseContainer) SetRoutes(routes []*Route)
- func (container *BaseContainer) SetTTY(tty bool)
- func (container *BaseContainer) SetTTYSize(width, height uint16)
- func (container *BaseContainer) SetUser(user string)
- func (container *BaseContainer) SetVolumes(volumes []*Volume)
- func (container *BaseContainer) SetWorkingDir(dir string)
- type BaseVM
- func (VM *BaseVM) Create() error
- func (VM *BaseVM) GetBase() (*Base, error)
- func (VM *BaseVM) SetCgroups(res container.Resources)
- func (VM *BaseVM) SetCmd(cmd []string)
- func (VM *BaseVM) SetEntrypoint(entrypoint []string)
- func (VM *BaseVM) SetEnv(env []string)
- func (VM *BaseVM) SetExposedPorts(info []proxy.ProxyInfo)
- func (VM *BaseVM) SetHostname(name string)
- func (VM *BaseVM) SetHosts(hosts []string)
- func (VM *BaseVM) SetImage(imageID string, path string, name string)
- func (VM *BaseVM) SetName(name string) error
- func (VM *BaseVM) SetNetworks(networks []*Network)
- func (VM *BaseVM) SetRoutes([]*Route)
- func (VM *BaseVM) SetTTY(tty bool)
- func (VM *BaseVM) SetTTYSize(width, height uint16)
- func (VM *BaseVM) SetUser(user string)
- func (VM *BaseVM) SetVolumes(volumes []*Volume)
- func (VM *BaseVM) SetWorkingDir(dir string)
- type CgroupsConfig
- type Factory
- type HostEntry
- type Machine
- type MachineInfo
- type Network
- type Route
- type RuntimeConfig
- type Volume
Constants ¶
View Source
const ( ReadPermission uint8 = 1 WritePermission uint8 = 2 )
volume permission
View Source
const ( StatusRunning = "running" StatusCreated = "created" StatusExited = "exited" StatusRemoving = "removing" StatusDead = "dead" StatusRestarting = "restarting" StatusPaused = "paused" )
View Source
const TIME_LAYOUT = "2006-01-02 15:04:05.999999999 -0700 MST"
Variables ¶
This section is empty.
Functions ¶
func AddMachine ¶
func CheckExist ¶
func ContainerConnectNetwork ¶
func DeleteContainer ¶
func KillContainer ¶
func PauseContainer ¶
func RestartContainer ¶
func StartContainer ¶
func StopContainer ¶
func UnpauseContainer ¶
func VMConnectNetwork ¶
Types ¶
type Base ¶
type Base struct {
IsDocker bool `json:"is_docker"`
ImageID string `json:"image_id"`
ID string `json:"id"`
ImageName string `json:"imageName"`
ImagePath string `json:"image_path"`
ImageType string `json:"image_type"`
Name string `json:"name"` // 名字
CreateTime time.Time `json:"create_time"`
RuntimeConfig *RuntimeConfig `json:"runtime_config"` // 运行配置
}
func (*Base) ConnectNetWork ¶
func (*Base) GetImageID ¶
type BaseContainer ¶
type BaseContainer struct {
Base *Base
ContainerConfig *container.Config `json:"container_config"`
HostConfig *container.HostConfig `json:"host_config"`
}
func (*BaseContainer) GetBase ¶
func (container *BaseContainer) GetBase() (*Base, error)
func (*BaseContainer) SetCgroups ¶
func (container *BaseContainer) SetCgroups(res docker.Resources)
func (*BaseContainer) SetCmd ¶
func (container *BaseContainer) SetCmd(cmd []string)
func (*BaseContainer) SetEntrypoint ¶
func (container *BaseContainer) SetEntrypoint(entrypoint []string)
func (*BaseContainer) SetEnv ¶
func (container *BaseContainer) SetEnv(env []string)
func (*BaseContainer) SetExposedPorts ¶
func (container *BaseContainer) SetExposedPorts(info []proxy.ProxyInfo)
func (*BaseContainer) SetHostname ¶
func (container *BaseContainer) SetHostname(name string)
func (*BaseContainer) SetHosts ¶
func (container *BaseContainer) SetHosts(hosts []string)
func (*BaseContainer) SetImage ¶
func (container *BaseContainer) SetImage(imageID string, path string, name string)
func (*BaseContainer) SetName ¶
func (container *BaseContainer) SetName(name string) error
func (*BaseContainer) SetNetworks ¶
func (container *BaseContainer) SetNetworks(networks []*Network)
func (*BaseContainer) SetRoutes ¶
func (container *BaseContainer) SetRoutes(routes []*Route)
func (*BaseContainer) SetTTY ¶
func (container *BaseContainer) SetTTY(tty bool)
func (*BaseContainer) SetTTYSize ¶
func (container *BaseContainer) SetTTYSize(width, height uint16)
func (*BaseContainer) SetUser ¶
func (container *BaseContainer) SetUser(user string)
func (*BaseContainer) SetVolumes ¶
func (container *BaseContainer) SetVolumes(volumes []*Volume)
func (*BaseContainer) SetWorkingDir ¶
func (container *BaseContainer) SetWorkingDir(dir string)
type BaseVM ¶
type BaseVM struct {
BaseInfo *Base
VMConfig *libvirtxml.Domain
}
func (*BaseVM) SetCgroups ¶
func (*BaseVM) SetEntrypoint ¶
func (*BaseVM) SetExposedPorts ¶
func (*BaseVM) SetHostname ¶
func (*BaseVM) SetNetworks ¶
func (*BaseVM) SetTTYSize ¶
func (*BaseVM) SetVolumes ¶
func (*BaseVM) SetWorkingDir ¶
type CgroupsConfig ¶
type Factory ¶
type Factory interface {
SetName(string) error // 容器的名字
SetHostname(string) // 设置主机名
SetTTY(bool) // 设置是否使用终端
SetNetworks([]*Network) // 添加网络
SetRoutes([]*Route) // 添加路由
SetImage(string, string, string) // 添加镜像地址
SetVolumes([]*Volume) // 添加卷
SetEntrypoint([]string) // EntryPoint (entrypoint, cmd)
SetCmd([]string) // Cmd
SetWorkingDir(string) // WorkingDir 默认 "/"
SetUser(string) // User
SetEnv([]string) // Env
SetTTYSize(width, height uint16)
GetBase() (*Base, error) // get machine entry
SetHosts([]string) // 格式:{"hostname:192.168.0.2"}
SetExposedPorts(info []proxy.ProxyInfo)
Create() error
SetCgroups(container.Resources)
}
func CreateContainer ¶
type Machine ¶
type Machine interface {
Start() error // 运行machine
Kill(string) error // 使用指定的信号来停止一个容器
Pause() error // 暂停
Unpause() error // 恢复
Delete() error // 删除这个machine所占用的资源
Stop(int32) error // 停止
Restart(int32) error // 重启
GetImageID() string //
Rename(string) error // rename
ResizeTTY(h uint32, w uint32) error
GetStdio(string) (chan []byte, chan []byte, chan []byte, error) // stdin, stdout, stderr
GetState() string // get machine state
Inspect() (name string, runtimeSetting string, spec string, machineType string, err error)
Commit(name string) (string, error)
ConnectNetWork(*Network) error
GetName() string
}
func GetMachine ¶
type MachineInfo ¶
type MachineInfo struct {
ImageName string
ID string
Name string
CreateTime string
ImageType string
Status string
ImageId string
}
func ListMachine ¶
func ListMachine() []MachineInfo
type Network ¶
type Network struct {
// Type 设置 networks type, 通常设置为 veth 或者 loopback
Type string `json:"type"`
// Name 设置网络接口名字比如 eth0
Name string `json:"name"`
// Bridge 设置要使用的网桥
Bridge string `json:"bridge"`
// MacAddress 设置接口的 mac 地址
MacAddress string `json:"mac_address"`
// Address 设置包含 mask 的 IPV4 地址 比如 192.169.10.2/24
Address []string `json:"address"`
// Gateway 设置接口的默认 ipv4 网关地址
Gateway string `json:"gateway"`
// IPv6Address 设置包含 mask 的 IPV6 地址
IPv6Address []string `json:"ipv6_address"`
// IPv6Gateway 设置接口的默认 ipv6 网关地址
IPv6Gateway string `json:"ipv6_gateway"`
// 设置一対 veth 之间的 mtu
// 注意:不会作用于:loopback
Mtu int `json:"mtu"`
// 设置一対 veth 之间的 tx_queuelen
// 注意:不会作用于:loopback
TxQueueLen int `json:"txqueuelen"`
// 一対 veth 中在宿主机上的 veth 的名字
HostInterfaceName string `json:"host_interface_name"`
}
type Route ¶
type Route struct {
// 设置 destination 和 mask 必须是 CIDR 格式
// 支持 IPV4 和 IPV6 比如:192.168.1.2/24
Destination string `json:"destination"`
// 设置 source 和 mask 必须是 CIDR 格式
// 支持 IPV4 和 IPV6 比如:192.168.1.3/24
Source string `json:"source"`
// 设置网关
// 支持 IPV4 和 IPV6 比如:192.168.1.1
Gateway string `json:"gateway"`
// 设备名 比如 eth0
InterfaceName string `json:"interface_name"`
}
type RuntimeConfig ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.