daemon

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2016 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_DM_POOL      string = "hyper-volume-pool"
	DEFAULT_DM_POOL_SIZE int    = 20971520 * 512
	DEFAULT_DM_DATA_LOOP string = "/dev/loop6"
	DEFAULT_DM_META_LOOP string = "/dev/loop7"
	DEFAULT_DM_VOL_SIZE  int    = 2 * 1024 * 1024 * 1024
	DEFAULT_VOL_FS              = "ext4"
)

Variables

View Source
var (
	DefaultResourcePath string = "/var/run/hyper/Pods"
)
View Source
var NewDockerImpl = func() (DockerInterface, error) {
	return nil, fmt.Errorf("no docker create function")
}
View Source
var StorageDrivers map[string]func(*dockertypes.Info) (Storage, error) = map[string]func(*dockertypes.Info) (Storage, error){
	"devicemapper": DMFactory,
	"aufs":         AufsFactory,
	"overlay":      OverlayFsFactory,
	"vbox":         VBoxStorageFactory,
}

Functions

func ProbeExistingVolume added in v0.5.0

func ProbeExistingVolume(v *pod.UserVolume, sharedDir string) (*hypervisor.VolumeInfo, error)

func ProcessPodBytes added in v0.5.0

func ProcessPodBytes(body []byte, podId string) (*pod.UserPod, error)

func ServiceDiscoveryContainerName added in v0.5.0

func ServiceDiscoveryContainerName(podName string) string

Types

type AufsStorage added in v0.5.0

type AufsStorage struct {
	// contains filtered or unexported fields
}

func (*AufsStorage) CleanUp added in v0.5.0

func (*AufsStorage) CleanUp() error

func (*AufsStorage) CreateVolume added in v0.5.0

func (a *AufsStorage) CreateVolume(daemon *Daemon, podId, shortName string) (*hypervisor.VolumeInfo, error)

func (*AufsStorage) Init added in v0.5.0

func (*AufsStorage) Init() error

func (*AufsStorage) InjectFile added in v0.5.0

func (a *AufsStorage) InjectFile(src io.Reader, containerId, target, rootDir string, perm, uid, gid int) error

func (*AufsStorage) PrepareContainer added in v0.5.0

func (a *AufsStorage) PrepareContainer(id, sharedDir string) (*hypervisor.ContainerInfo, error)

func (*AufsStorage) RemoveVolume added in v0.5.0

func (a *AufsStorage) RemoveVolume(podId string, record []byte) error

func (*AufsStorage) RootPath added in v0.5.0

func (a *AufsStorage) RootPath() string

func (*AufsStorage) Type added in v0.5.0

func (a *AufsStorage) Type() string

type Daemon

type Daemon struct {
	ID string

	DockerCli DockerInterface
	PodList   *PodList
	VmList    map[string]*hypervisor.Vm

	Kernel      string
	Initrd      string
	Bios        string
	Cbfs        string
	VboxImage   string
	BridgeIface string
	BridgeIP    string
	Host        string
	Storage     Storage
	Hypervisor  string
	DefaultLog  *pod.PodLogConfig
	// contains filtered or unexported fields
}

func NewDaemon

func NewDaemon(eng *engine.Engine) (*Daemon, error)

func NewDaemonFromDirectory

func NewDaemonFromDirectory(eng *engine.Engine) (*Daemon, error)

func (*Daemon) AddPod

func (daemon *Daemon) AddPod(pod *Pod, podArgs string) (err error)

func (*Daemon) AddService added in v0.5.0

func (daemon *Daemon) AddService(job *engine.Job) error

func (*Daemon) AddVm

func (daemon *Daemon) AddVm(vm *hypervisor.Vm)

func (*Daemon) CleanPod added in v0.5.0

func (daemon *Daemon) CleanPod(podId string) (int, string, error)

func (*Daemon) CmdAttach

func (daemon *Daemon) CmdAttach(job *engine.Job) (err error)

func (*Daemon) CmdAuth added in v0.5.0

func (daemon *Daemon) CmdAuth(job *engine.Job) error

func (*Daemon) CmdBuild added in v0.5.0

func (daemon *Daemon) CmdBuild(job *engine.Job) error

func (*Daemon) CmdCommit added in v0.5.0

func (daemon *Daemon) CmdCommit(job *engine.Job) error

func (*Daemon) CmdContainerInfo added in v0.5.0

func (daemon *Daemon) CmdContainerInfo(job *engine.Job) error

func (*Daemon) CmdCreate

func (daemon *Daemon) CmdCreate(job *engine.Job) error

func (*Daemon) CmdExec

func (daemon *Daemon) CmdExec(job *engine.Job) (err error)

func (*Daemon) CmdExitCode added in v0.5.0

func (daemon *Daemon) CmdExitCode(job *engine.Job) (err error)

func (*Daemon) CmdImages added in v0.5.0

func (daemon *Daemon) CmdImages(job *engine.Job) error

func (*Daemon) CmdImagesRemove added in v0.5.0

func (daemon *Daemon) CmdImagesRemove(job *engine.Job) error

func (*Daemon) CmdInfo

func (daemon *Daemon) CmdInfo(job *engine.Job) error

func (*Daemon) CmdList

func (daemon *Daemon) CmdList(job *engine.Job) error

func (*Daemon) CmdLogs added in v0.5.0

func (daemon *Daemon) CmdLogs(job *engine.Job) (err error)

func (*Daemon) CmdPause added in v0.5.0

func (daemon *Daemon) CmdPause(job *engine.Job) error

func (*Daemon) CmdPodCreate

func (daemon *Daemon) CmdPodCreate(job *engine.Job) error

func (*Daemon) CmdPodInfo

func (daemon *Daemon) CmdPodInfo(job *engine.Job) error

func (*Daemon) CmdPodLabels added in v0.5.0

func (daemon *Daemon) CmdPodLabels(job *engine.Job) error

CmdPodLabels updates labels of the specified pod

func (*Daemon) CmdPodRm

func (daemon *Daemon) CmdPodRm(job *engine.Job) (err error)

func (*Daemon) CmdPodStart

func (daemon *Daemon) CmdPodStart(job *engine.Job) error

func (*Daemon) CmdPodStats added in v0.5.0

func (daemon *Daemon) CmdPodStats(job *engine.Job) error

func (*Daemon) CmdPodStop

func (daemon *Daemon) CmdPodStop(job *engine.Job) error

func (*Daemon) CmdPull

func (daemon *Daemon) CmdPull(job *engine.Job) error

func (*Daemon) CmdPush added in v0.5.0

func (daemon *Daemon) CmdPush(job *engine.Job) error

func (*Daemon) CmdRename added in v0.5.0

func (daemon *Daemon) CmdRename(job *engine.Job) error

func (*Daemon) CmdTty

func (daemon *Daemon) CmdTty(job *engine.Job) (err error)

func (*Daemon) CmdUnpause added in v0.5.0

func (daemon *Daemon) CmdUnpause(job *engine.Job) error

func (*Daemon) CmdVersion

func (daemon *Daemon) CmdVersion(job *engine.Job) error

func (*Daemon) CmdVmCreate

func (daemon *Daemon) CmdVmCreate(job *engine.Job) (err error)

func (*Daemon) CmdVmKill

func (daemon *Daemon) CmdVmKill(job *engine.Job) error

func (*Daemon) CreatePod

func (daemon *Daemon) CreatePod(podId, podArgs string, autoremove bool) error

FIXME: there was a `config` argument passed by docker/builder, but we never processed it.

func (*Daemon) DbGetVmByPod added in v0.5.0

func (daemon *Daemon) DbGetVmByPod(podId string) (string, error)

func (*Daemon) DefaultLogCfg added in v0.5.0

func (daemon *Daemon) DefaultLogCfg(driver string, cfg map[string]string)

func (*Daemon) DeletePodContainerFromDB

func (daemon *Daemon) DeletePodContainerFromDB(podName string) error

func (*Daemon) DeletePodFromDB

func (daemon *Daemon) DeletePodFromDB(podName string) error

func (*Daemon) DeleteService added in v0.5.0

func (daemon *Daemon) DeleteService(job *engine.Job) error

func (*Daemon) DeleteVmByPod

func (daemon *Daemon) DeleteVmByPod(podId string) error

func (*Daemon) DeleteVmData

func (daemon *Daemon) DeleteVmData(vmId string) error

func (*Daemon) DeleteVolumeId

func (daemon *Daemon) DeleteVolumeId(podId string) error

func (*Daemon) DestroyAllVm

func (daemon *Daemon) DestroyAllVm() error

func (*Daemon) DestroyAndKeepVm

func (daemon *Daemon) DestroyAndKeepVm() error

func (*Daemon) GetExitCode added in v0.5.0

func (daemon *Daemon) GetExitCode(podId, tag string, callback chan *types.VmResponse) error

func (*Daemon) GetPod added in v0.5.0

func (daemon *Daemon) GetPod(podId, podArgs string, autoremove bool) (*Pod, error)

func (*Daemon) GetPodByContainer

func (daemon *Daemon) GetPodByContainer(containerId string) (string, error)

func (*Daemon) GetPodByContainerIdOrName added in v0.5.0

func (daemon *Daemon) GetPodByContainerIdOrName(name string) (pod *Pod, idx int, err error)

func (*Daemon) GetPodByName

func (daemon *Daemon) GetPodByName(podName string) ([]byte, error)

func (*Daemon) GetPodContainersByName

func (daemon *Daemon) GetPodContainersByName(podName string) ([]string, error)

func (*Daemon) GetPodNum

func (daemon *Daemon) GetPodNum() int64

func (*Daemon) GetRunningPodNum

func (daemon *Daemon) GetRunningPodNum() int64

func (*Daemon) GetServiceContainerInfo added in v0.5.0

func (daemon *Daemon) GetServiceContainerInfo(podId string) (*hypervisor.Vm, string, error)

func (*Daemon) GetServices added in v0.5.0

func (daemon *Daemon) GetServices(job *engine.Job) error

func (*Daemon) GetVM added in v0.5.0

func (daemon *Daemon) GetVM(vmId string, resource *pod.UserResource, lazy bool, keep int) (*hypervisor.Vm, error)

func (*Daemon) GetVmByPodId added in v0.5.0

func (daemon *Daemon) GetVmByPodId(podId string) (string, error)

func (*Daemon) GetVmData

func (daemon *Daemon) GetVmData(vmId string) ([]byte, error)

func (*Daemon) GetVolumeId

func (daemon *Daemon) GetVolumeId(podId, volName string) (int, error)

func (*Daemon) InitVmCache added in v0.5.0

func (daemon *Daemon) InitVmCache(cache_policy string) error

func (*Daemon) Install

func (daemon *Daemon) Install(eng *engine.Engine) error

Install installs daemon capabilities to eng.

func (*Daemon) KillVm

func (daemon *Daemon) KillVm(vmId string) (int, string, error)

func (*Daemon) NewVm added in v0.5.0

func (daemon *Daemon) NewVm(id string, cpu, memory int, lazy bool, keep int) *hypervisor.Vm

func (Daemon) PauseContainer added in v0.5.0

func (daemon Daemon) PauseContainer(container string) error

func (Daemon) PausePod added in v0.5.0

func (daemon Daemon) PausePod(podId string) error

func (*Daemon) PodStopped added in v0.5.0

func (daemon *Daemon) PodStopped(podId string)

func (*Daemon) ReleaseAllVms

func (daemon *Daemon) ReleaseAllVms() (int, error)

func (*Daemon) RemovePod

func (daemon *Daemon) RemovePod(podId string)

func (*Daemon) RemoveVm

func (daemon *Daemon) RemoveVm(vmId string)

func (*Daemon) RestartPod

func (daemon *Daemon) RestartPod(mypod *hypervisor.PodStatus) error

The caller must make sure that the restart policy and the status is right to restart

func (*Daemon) Restore

func (daemon *Daemon) Restore() error

func (*Daemon) SetVolumeId

func (daemon *Daemon) SetVolumeId(podId, volName, dev_id string) error

func (*Daemon) StartPod

func (daemon *Daemon) StartPod(podId, podArgs, vmId string, config interface{}, lazy, autoremove bool, keep int, streams []*hypervisor.TtyIO) (int, string, error)

func (*Daemon) StartVm added in v0.5.0

func (daemon *Daemon) StartVm(vmId string, cpu, mem int, lazy, cache bool, keep int) (*hypervisor.Vm, error)

func (*Daemon) StopPod

func (daemon *Daemon) StopPod(podId, stopVm string) (int, string, error)

func (*Daemon) UnpauseContainer added in v0.5.0

func (daemon *Daemon) UnpauseContainer(container string) error

func (*Daemon) UnpausePod added in v0.5.0

func (daemon *Daemon) UnpausePod(podId string) error

func (*Daemon) UpdateService added in v0.5.0

func (daemon *Daemon) UpdateService(job *engine.Job) error

func (*Daemon) UpdateVmByPod

func (daemon *Daemon) UpdateVmByPod(podId, vmId string) error

func (*Daemon) UpdateVmData

func (daemon *Daemon) UpdateVmData(vmId string, data []byte) error

func (*Daemon) WaitVmStart added in v0.5.0

func (daemon *Daemon) WaitVmStart(vm *hypervisor.Vm) error

func (*Daemon) WritePodAndContainers

func (daemon *Daemon) WritePodAndContainers(podId string) error

func (*Daemon) WritePodToDB

func (daemon *Daemon) WritePodToDB(podName string, podData []byte) error

type DevMapperStorage added in v0.5.0

type DevMapperStorage struct {
	CtnPoolName string
	VolPoolName string
	DevPrefix   string
	FsType      string

	DmPoolData *dm.DeviceMapper
	// contains filtered or unexported fields
}

func (*DevMapperStorage) CleanUp added in v0.5.0

func (dms *DevMapperStorage) CleanUp() error

func (*DevMapperStorage) CreateVolume added in v0.5.0

func (dms *DevMapperStorage) CreateVolume(daemon *Daemon, podId, shortName string) (*hypervisor.VolumeInfo, error)

func (*DevMapperStorage) Init added in v0.5.0

func (dms *DevMapperStorage) Init() error

func (*DevMapperStorage) InjectFile added in v0.5.0

func (dms *DevMapperStorage) InjectFile(src io.Reader, containerId, target, rootDir string, perm, uid, gid int) error

func (*DevMapperStorage) PrepareContainer added in v0.5.0

func (dms *DevMapperStorage) PrepareContainer(id, sharedDir string) (*hypervisor.ContainerInfo, error)

func (*DevMapperStorage) RemoveVolume added in v0.5.0

func (dms *DevMapperStorage) RemoveVolume(podId string, record []byte) error

func (*DevMapperStorage) RootPath added in v0.5.0

func (dms *DevMapperStorage) RootPath() string

func (*DevMapperStorage) Type added in v0.5.0

func (dms *DevMapperStorage) Type() string

type DockerInterface added in v0.5.0

type DockerInterface interface {
	SendCmdCreate(name, image string, entripoint, cmds []string, config interface{}) ([]byte, int, error)
	SendCmdDelete(arg ...string) ([]byte, int, error)
	SendCmdInfo(args ...string) (*dockertypes.Info, error)
	SendCmdImages(all string) ([]*dockertypes.Image, error)
	GetContainerInfo(args ...string) (*dockertypes.ContainerJSON, error)
	SendCmdPull(image string, config *graph.ImagePullConfig) ([]byte, int, error)
	SendCmdAuth(body io.ReadCloser) (string, error)
	SendCmdPush(remote string, ipconfig *graph.ImagePushConfig) error
	SendImageDelete(args ...string) ([]dockertypes.ImageDelete, error)
	SendImageBuild(image string, size int, context io.ReadCloser) ([]byte, int, error)
	SendContainerCommit(args ...string) ([]byte, int, error)
	SendContainerRename(oName, nName string) error
	Shutdown() error
	Setup() error
}

func NewDocker added in v0.5.0

func NewDocker() (DockerInterface, error)

type OverlayFsStorage added in v0.5.0

type OverlayFsStorage struct {
	// contains filtered or unexported fields
}

func (*OverlayFsStorage) CleanUp added in v0.5.0

func (*OverlayFsStorage) CleanUp() error

func (*OverlayFsStorage) CreateVolume added in v0.5.0

func (o *OverlayFsStorage) CreateVolume(daemon *Daemon, podId, shortName string) (*hypervisor.VolumeInfo, error)

func (*OverlayFsStorage) Init added in v0.5.0

func (*OverlayFsStorage) Init() error

func (*OverlayFsStorage) InjectFile added in v0.5.0

func (o *OverlayFsStorage) InjectFile(src io.Reader, containerId, target, rootDir string, perm, uid, gid int) error

func (*OverlayFsStorage) PrepareContainer added in v0.5.0

func (o *OverlayFsStorage) PrepareContainer(id, sharedDir string) (*hypervisor.ContainerInfo, error)

func (*OverlayFsStorage) RemoveVolume added in v0.5.0

func (o *OverlayFsStorage) RemoveVolume(podId string, record []byte) error

func (*OverlayFsStorage) RootPath added in v0.5.0

func (o *OverlayFsStorage) RootPath() string

func (*OverlayFsStorage) Type added in v0.5.0

func (o *OverlayFsStorage) Type() string

type Pod

type Pod struct {
	// contains filtered or unexported fields
}

I'd like to move the remain part of this file to another file.

func CreatePod added in v0.5.0

func CreatePod(daemon *Daemon, dclient DockerInterface, podId, podArgs string, autoremove bool) (*Pod, error)

func (*Pod) AssociateVm added in v0.5.0

func (p *Pod) AssociateVm(daemon *Daemon, vmId string) error

func (*Pod) AttachTtys added in v0.5.0

func (p *Pod) AttachTtys(streams []*hypervisor.TtyIO) (err error)

func (*Pod) GetVM added in v0.5.0

func (p *Pod) GetVM(daemon *Daemon, id string, lazy bool, keep int) (err error)

func (*Pod) InitContainers added in v0.5.0

func (p *Pod) InitContainers(daemon *Daemon, dclient DockerInterface) (err error)

func (*Pod) KillVM added in v0.5.0

func (p *Pod) KillVM(daemon *Daemon)

func (*Pod) Prepare added in v0.5.0

func (p *Pod) Prepare(daemon *Daemon) (err error)

func (*Pod) PrepareContainers added in v0.5.0

func (p *Pod) PrepareContainers(sd Storage, dclient DockerInterface) (err error)

func (*Pod) PrepareDNS added in v0.5.0

func (p *Pod) PrepareDNS() (err error)

**

PrepareDNS() Set the resolv.conf of host to each container, except the following cases:

- if the pod has a `dns` field with values, the pod will follow the dns setup, and daemon
  won't insert resolv.conf file into any containers
- if the pod has a `file` which source is uri "file:///etc/resolv.conf", this mean the user
  will handle this file by himself/herself, daemon won't touch the dns setting even if the file
  is not referenced by any containers. This could be a method to prevent the daemon from unwanted
  setting the dns configuration
- if a container has a file config in the pod spec with `/etc/resolv.conf` as target `path`,
  then this container won't be set as the file from hosts. Then a user can specify the content
  of the file.

func (*Pod) PrepareEtcHosts added in v0.5.0

func (p *Pod) PrepareEtcHosts() (err error)

PrepareEtcHosts sets /etc/hosts for each container

func (*Pod) PrepareServices added in v0.5.0

func (p *Pod) PrepareServices() error

func (*Pod) PrepareVolume added in v0.5.0

func (p *Pod) PrepareVolume(daemon *Daemon, sd Storage) (err error)

func (*Pod) SetVM added in v0.5.0

func (p *Pod) SetVM(id string, vm *hypervisor.Vm)

func (*Pod) Start added in v0.5.0

func (p *Pod) Start(daemon *Daemon, vmId string, lazy, autoremove bool, keep int, streams []*hypervisor.TtyIO) (*types.VmResponse, error)

func (*Pod) Status

func (p *Pod) Status() *hypervisor.PodStatus

type PodFilterOp added in v0.5.0

type PodFilterOp func(*Pod) bool

type PodList added in v0.5.0

type PodList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewPodList added in v0.5.0

func NewPodList() *PodList

func (*PodList) CountContainers added in v0.5.0

func (pl *PodList) CountContainers() (num int64)

func (*PodList) CountRunning added in v0.5.0

func (pl *PodList) CountRunning() int64

func (*PodList) CountStatus added in v0.5.0

func (pl *PodList) CountStatus(status uint) (num int64)

func (*PodList) Delete added in v0.5.0

func (pl *PodList) Delete(id string)

func (*PodList) Find added in v0.5.0

func (pl *PodList) Find(fn PodFilterOp) *Pod

func (*PodList) Foreach added in v0.5.0

func (pl *PodList) Foreach(fn PodOp) error

func (*PodList) Get added in v0.5.0

func (pl *PodList) Get(id string) (*Pod, bool)

func (*PodList) GetByName added in v0.5.0

func (pl *PodList) GetByName(name string) *Pod

func (*PodList) GetStatus added in v0.5.0

func (pl *PodList) GetStatus(id string) (*hypervisor.PodStatus, bool)

func (*PodList) Put added in v0.5.0

func (pl *PodList) Put(p *Pod)

type PodOp added in v0.5.0

type PodOp func(*Pod) error

type Record added in v0.5.0

type Record struct {
	Hosts string
	IP    string
}

Record Structure for a single host record

func (Record) WriteTo added in v0.5.0

func (r Record) WriteTo(w io.Writer) (int64, error)

WriteTo writes record to file and returns bytes written or error

type Storage

type Storage interface {
	Type() string
	RootPath() string

	Init() error
	CleanUp() error

	PrepareContainer(id, sharedir string) (*hypervisor.ContainerInfo, error)
	InjectFile(src io.Reader, containerId, target, rootDir string, perm, uid, gid int) error
	CreateVolume(daemon *Daemon, podId, shortName string) (*hypervisor.VolumeInfo, error)
	RemoveVolume(podId string, record []byte) error
}

func AufsFactory added in v0.5.0

func AufsFactory(sysinfo *dockertypes.Info) (Storage, error)

func DMFactory added in v0.5.0

func DMFactory(sysinfo *dockertypes.Info) (Storage, error)

func OverlayFsFactory added in v0.5.0

func OverlayFsFactory(_ *dockertypes.Info) (Storage, error)

func StorageFactory added in v0.5.0

func StorageFactory(sysinfo *dockertypes.Info) (Storage, error)

func VBoxStorageFactory added in v0.5.0

func VBoxStorageFactory(_ *dockertypes.Info) (Storage, error)

type VBoxStorage added in v0.5.0

type VBoxStorage struct {
	// contains filtered or unexported fields
}

func (*VBoxStorage) CleanUp added in v0.5.0

func (*VBoxStorage) CleanUp() error

func (*VBoxStorage) CreateVolume added in v0.5.0

func (v *VBoxStorage) CreateVolume(daemon *Daemon, podId, shortName string) (*hypervisor.VolumeInfo, error)

func (*VBoxStorage) Init added in v0.5.0

func (*VBoxStorage) Init() error

func (*VBoxStorage) InjectFile added in v0.5.0

func (v *VBoxStorage) InjectFile(src io.Reader, containerId, target, rootDir string, perm, uid, gid int) error

func (*VBoxStorage) PrepareContainer added in v0.5.0

func (v *VBoxStorage) PrepareContainer(id, sharedDir string) (*hypervisor.ContainerInfo, error)

func (*VBoxStorage) RemoveVolume added in v0.5.0

func (v *VBoxStorage) RemoveVolume(podId string, record []byte) error

func (*VBoxStorage) RootPath added in v0.5.0

func (v *VBoxStorage) RootPath() string

func (*VBoxStorage) Type added in v0.5.0

func (v *VBoxStorage) Type() string

type VmCache added in v0.5.0

type VmCache struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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