Documentation ¶
Index ¶
- Constants
- Variables
- func AddBeforeNetworkRemoveHook(hook BeforeNetworkRemove)
- func AddOnContainerLaunchHook(hook OnContainerLaunch)
- func AddOnContainerStopHook(hook OnContainerStop)
- func AddOnDockerDaemonStartHook(hook OnDockerDaemonStart)
- func AddOnNetworkCreateHook(hook OnNetworkCreate)
- func AddOnNetworkRemoveHook(hook OnNetworkRemove)
- func InitCIDRPool(cidr_expression string) (int, error)
- func InitDocker()
- func ParseCIDRRange(cidr string) ([]string, error)
- type BeforeNetworkRemove
- type ContainerNetworkInfo
- type Docker
- func (c *Docker) BuildImage(tar_file io.Reader, image_name string, message_callback func(string), ...) error
- func (c *Docker) CheckImageExist(image_name string) bool
- func (c *Docker) ConnectContainerToNetwork(container_id string, network_id string) error
- func (c *Docker) CreateContainer(image string, uid int, port_protocol string, subnet_names []string, ...) (*kisara_types.Container, error)
- func (c *Docker) CreateNetwork(subnet string, name string, internal bool, driver string) (*kisara_types.Network, error)
- func (c *Docker) CreateRandomCIDRNetwork(internal bool, driver string) (*kisara_types.Network, error)
- func (c *Docker) CreateService(service_config types.KisaraService, message_callback ...func(string)) (*types.Service, error)
- func (c *Docker) DeleteImage(uuid string) error
- func (c *Docker) DeleteNetwork(network_id string) error
- func (c *Docker) DeleteService(service_id string) error
- func (c *Docker) DisconnectContainerFromNetwork(container_id string, network_id string) error
- func (c *Docker) Exec(container_id string, cmd string) error
- func (c *Docker) ExecWarp(container_id string, cmd string, timeout time.Duration) ([]byte, error)
- func (c *Docker) GetContainerNetwork(container_id string) (ContainerNetworkInfo, error)
- func (c *Docker) GetContainerNumber() (int, error)
- func (c *Docker) GetImage(image_name string) (*kisara_types.Image, error)
- func (c *Docker) GetNetworkByName(name string) (*kisara_types.Network, error)
- func (c *Docker) GetService(service_id string) (*types.Service, error)
- func (c *Docker) InitImage() error
- func (c *Docker) InspectContainer(container_id string, has_state ...bool) (*kisara_types.Container, error)
- func (c *Docker) LaunchAWD(image_name string, port_protocols string, uid int, subnet_name string, ...) (*kisara_types.Container, error)
- func (c *Docker) LaunchContainer(image_name string, uid int, port_protocol string, subnet_name string, ...) (*kisara_types.Container, error)
- func (c *Docker) LaunchServiceContainer(image_name string, port_protocols string, uid int, subnet_names []string, ...) (*kisara_types.Container, error)
- func (c *Docker) LaunchTargetMachine(image_name string, port_protocol string, subnet_name string, uid int, ...) (*kisara_types.Container, error)
- func (c *Docker) ListContainer() (*[]*kisara_types.Container, error)
- func (c *Docker) ListImage() (*[]*kisara_types.Image, error)
- func (c *Docker) ListNetwork() ([]kisara_types.Network, error)
- func (c *Docker) ListServices() ([]*types.Service, error)
- func (c *Docker) PullImage(image_name string, event_callback func(message string)) (*kisara_types.Image, error)
- func (c *Docker) ReleaseCIDRNetwork(cidr string) error
- func (c *Docker) RemoveContainer(id string) error
- func (c *Docker) RequireImage(image_name string, message_callback func(string)) (*kisara_types.Image, error)
- func (c *Docker) RunNetworkMonitor(network_name string, context io.Reader, message_callback func(string)) (*types.KisaraNetworkMonitorContainer, error)
- func (c *Docker) RunNetworkMonitorScript(containers *types.KisaraNetworkTestSet) (*types.KisaraNetworkTestResultSet, error)
- func (c *Docker) Stop()
- func (c *Docker) StopContainer(id string) error
- func (c *Docker) StopNetworkMonitor(container *types.KisaraNetworkMonitorContainer) error
- type KisaraNetworkMonitor
- type OnContainerLaunch
- type OnContainerStop
- type OnDockerDaemonStart
- type OnNetworkCreate
- type OnNetworkRemove
- type VirtualMachine
- func (vm *VirtualMachine) Init(docker *Docker) error
- func (vm *VirtualMachine) LaunchVm(docker *Docker, image_id string, port_protocols string, networks []string, ...) (*types.VM, error)
- func (vm *VirtualMachine) ListVm(docker *Docker) ([]*types.VM, error)
- func (vm *VirtualMachine) StopVm(docker *Docker, vm_id string) error
- type VirtualMachineInf
Constants ¶
const ( BYTES = 1 KBYTES = BYTES * 1024 MBYTES = KBYTES * 1024 GBYTES = MBYTES * 1024 )
const (
IMAGE_EXPIRE_DURATION = time.Hour * 24 * 30
)
Variables ¶
var ( ErrVmNotFound = errors.New("VM not found") ErrVmNotSupportedArch = errors.New("VM arch not supported") )
Functions ¶
func AddBeforeNetworkRemoveHook ¶
func AddBeforeNetworkRemoveHook(hook BeforeNetworkRemove)
AddBeforeNetworkRemoveHook adds a hook to the BeforeNetworkRemoveHook list
func AddOnContainerLaunchHook ¶
func AddOnContainerLaunchHook(hook OnContainerLaunch)
AddOnContainerLaunchHook adds a hook to the OnContainerLaunchHook list
func AddOnContainerStopHook ¶
func AddOnContainerStopHook(hook OnContainerStop)
AddOnContainerStopHook adds a hook to the OnContainerStopHook list
func AddOnDockerDaemonStartHook ¶
func AddOnDockerDaemonStartHook(hook OnDockerDaemonStart)
AddOnDockerDaemonStartHook adds a hook to the OnDockerDaemonStartHook list
func AddOnNetworkCreateHook ¶
func AddOnNetworkCreateHook(hook OnNetworkCreate)
AddOnNetworkCreateHook adds a hook to the OnNetworkCreateHook list
func AddOnNetworkRemoveHook ¶
func AddOnNetworkRemoveHook(hook OnNetworkRemove)
AddOnNetworkRemoveHook adds a hook to the OnNetworkRemoveHook list
func InitCIDRPool ¶
func InitDocker ¶
func InitDocker()
func ParseCIDRRange ¶
Parse a CIDR expression into a list of CIDR CIDR expression like: 172.[128-255].[0-255].0/24 every number in the expression can be a range or a single number
Types ¶
type ContainerNetworkInfo ¶
type ContainerNetworkInfo struct { ContainerId string Networks []struct { Network kisara_types.Network Ip string } }
type Docker ¶
type Docker struct { KisaraNetworkMonitor Client *client.Client Ctx *context.Context Vm VirtualMachineInf }
func (*Docker) BuildImage ¶
func (c *Docker) BuildImage(tar_file io.Reader, image_name string, message_callback func(string), fault_callback func(string), finish ...chan struct{}) error
BuildImage will build a docker image from a tar file
func (*Docker) CheckImageExist ¶
func (*Docker) ConnectContainerToNetwork ¶
Connect a container to a network
func (*Docker) CreateContainer ¶
func (*Docker) CreateNetwork ¶
func (c *Docker) CreateNetwork(subnet string, name string, internal bool, driver string) (*kisara_types.Network, error)
Create a new docker virtual network
func (*Docker) CreateRandomCIDRNetwork ¶
func (c *Docker) CreateRandomCIDRNetwork(internal bool, driver string) (*kisara_types.Network, error)
Create a Random CIDR network
func (*Docker) CreateService ¶
func (c *Docker) CreateService(service_config types.KisaraService, message_callback ...func(string)) (*types.Service, error)
create a service from a service config
func (*Docker) DeleteImage ¶
func (*Docker) DeleteNetwork ¶
Delete a docker virtual network
func (*Docker) DeleteService ¶
delete a service
func (*Docker) DisconnectContainerFromNetwork ¶
Disconnect a container from a network
func (*Docker) GetContainerNetwork ¶
func (c *Docker) GetContainerNetwork(container_id string) (ContainerNetworkInfo, error)
Get a container's network info
func (*Docker) GetContainerNumber ¶
Get container Number
func (*Docker) GetNetworkByName ¶
func (c *Docker) GetNetworkByName(name string) (*kisara_types.Network, error)
Get a docker virtual network by name
func (*Docker) InspectContainer ¶
func (c *Docker) InspectContainer(container_id string, has_state ...bool) (*kisara_types.Container, error)
InspectContainer will insepct to docker container and return some information about the container like host_port, container status, etc.
func (*Docker) LaunchContainer ¶
func (*Docker) LaunchServiceContainer ¶
func (*Docker) LaunchTargetMachine ¶
func (*Docker) ListContainer ¶
func (c *Docker) ListContainer() (*[]*kisara_types.Container, error)
func (*Docker) ListNetwork ¶
func (c *Docker) ListNetwork() ([]kisara_types.Network, error)
List all docker virtual network
func (*Docker) ReleaseCIDRNetwork ¶
Release a CIDR network
func (*Docker) RemoveContainer ¶
func (*Docker) RequireImage ¶
func (c *Docker) RequireImage(image_name string, message_callback func(string)) (*kisara_types.Image, error)
when launch container, it's nessesscry to require image first it will lock the image to avoid image deletion before launch container it will also automatically pull image if not exists
func (*Docker) RunNetworkMonitor ¶
func (*Docker) RunNetworkMonitorScript ¶
func (c *Docker) RunNetworkMonitorScript(containers *types.KisaraNetworkTestSet) (*types.KisaraNetworkTestResultSet, error)
Run the test script, support multiple containers result and error should be all considered beacuse of multiple tests
func (*Docker) StopContainer ¶
func (*Docker) StopNetworkMonitor ¶
func (c *Docker) StopNetworkMonitor(container *types.KisaraNetworkMonitorContainer) error
type KisaraNetworkMonitor ¶
type KisaraNetworkMonitor interface { // Run the test container //@param network_name: the network name to run the test container //@param context: the context to build the test container, should be a tar file and contains dockerfile etc. RunNetworkMonitor(network_name string, context io.Reader, message_callback func(string)) (*types.KisaraNetworkMonitorContainer, error) // Stop the test container, and automatically remove it StopNetworkMonitor(container *types.KisaraNetworkMonitorContainer) error // Run the test script, support multiple containers RunNetworkMonitorScript(containers *types.KisaraNetworkTestSet) (*types.KisaraNetworkTestResultSet, error) // contains filtered or unexported methods }
type OnContainerLaunch ¶
type OnContainerStop ¶
type OnDockerDaemonStart ¶
type OnNetworkCreate ¶
type OnNetworkRemove ¶
type VirtualMachine ¶
type VirtualMachine struct { VirtualMachineInf // contains filtered or unexported fields }
func GetVirtualMachine ¶
func GetVirtualMachine() *VirtualMachine
func (*VirtualMachine) Init ¶
func (vm *VirtualMachine) Init(docker *Docker) error
func (*VirtualMachine) LaunchVm ¶
func (vm *VirtualMachine) LaunchVm( docker *Docker, image_id string, port_protocols string, networks []string, limit types.KisaraVmLimit, ) (*types.VM, error)
type VirtualMachineInf ¶
type VirtualMachineInf interface { // init vm Init(docker *Docker) error // launch vm LaunchVm(docker *Docker, image_id string, port_protocols string, networks []string, limit types.KisaraVmLimit) (*types.VM, error) // stop vm StopVm(docker *Docker, vm_id string) error // list vm ListVm(docker *Docker) ([]*types.VM, error) // get vm GetVm(docker *Docker, vm_id string) (*types.VM, error) }